local-operator-ui 0.33.5 → 0.33.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/renderer/assets/{_basePickBy-B98zzKZM.js → _basePickBy-CkoMFf5J.js} +1 -1
- package/out/renderer/assets/{_baseUniq-CKsm1EGz.js → _baseUniq-BoGp7aXg.js} +1 -1
- package/out/renderer/assets/{agent-details-page-BA98pqdM.js → agent-details-page-DnKxplQb.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-BR-1U2SD.js → agent-hub-page-DaWE1zkN.js} +1 -1
- package/out/renderer/assets/{agents-page-DFOw5NhG.js → agents-page-DRLL1A2Z.js} +3 -3
- package/out/renderer/assets/{arc-mGB_EZAe.js → arc-DDbm191y.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CdCvyAIc.js → architectureDiagram-IEHRJDOE-CtQo1Whw.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-D-i8NnLi.js → blockDiagram-JOT3LUYC-BIYZ30Qj.js} +1 -1
- package/out/renderer/assets/{book-open-A87t0_71.js → book-open-D8j_ZoIP.js} +1 -1
- package/out/renderer/assets/browser-page-Vhnv-3jT.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-BzOGUKTW.js → browser-webauthn-prompt-Btk4lmO0.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-ByfakdDp.js → c4Diagram-VJAJSXHY-Xf4s2RLR.js} +1 -1
- package/out/renderer/assets/channel-DsyGqe4G.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-NmviAOlm.js → chunk-4BMEZGHF-BeSTkHZN.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-DAM4iS_R.js → chunk-A2AXSNBT-Du_mT84q.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-B7pIjpHp.js → chunk-AEK57VVT-Cx-awbJf.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-DZbYn2cT.js → chunk-D6G4REZN-CjB8Mrju.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-ChtoB-0l.js → chunk-RZ5BOZE2-CeWf6wWy.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-SVUC9_vr.js → chunk-XZIHB7SX-C0vOXPUC.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BKxxjeHy.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BKxxjeHy.js +1 -0
- package/out/renderer/assets/clone-CjIB6OC_.js +1 -0
- package/out/renderer/assets/{console-mirror-BfouQAb6.js → console-mirror-C021Pleg.js} +1 -1
- package/out/renderer/assets/{consoleCapture-CAhC9KBI.js → consoleCapture-CwsR7Pk5.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-BuNCxZ7H.js → conversation-input-sync-CKFZgmQ4.js} +5 -5
- package/out/renderer/assets/{dagre-OKDRZEBW-C5Z7Yhok.js → dagre-OKDRZEBW-Dlb8udV9.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DBsVQC-o.js → diagram-SSKATNLV-9pQBfRIV.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-UKuH13tY.js → diagram-VNBRO52H-XJhBN8f8.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-JMWGS1PK.js → erDiagram-Q7BY3M3F-CsiOSnwr.js} +1 -1
- package/out/renderer/assets/{error-boundary-BtSNu6UL.js → error-boundary-CYOMGBqy.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-DmOe9kmN.js → flowDiagram-4HSFHLVR-0jdxtrwY.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-BZMOzbBr.js → ganttDiagram-APWFNJXF-Dx1qFOJp.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BlfAe0Nz.js → gitGraphDiagram-7IBYFJ6S-DnrtQqzQ.js} +1 -1
- package/out/renderer/assets/{graph-CMpNoI7b.js → graph-B3AxGVxQ.js} +1 -1
- package/out/renderer/assets/{index-C6XPeDkS.js → index-BCtcy-Az.js} +1 -1
- package/out/renderer/assets/{index-BUF9222g.js → index-C90HwIjj.js} +167 -167
- package/out/renderer/assets/{index-mogv7CG7.js → index-dDgWp_lK.js} +1 -1
- package/out/renderer/assets/index-oPdbJBXR.css +1 -0
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-BvCPK6Gk.js → infoDiagram-PH2N3AL5-BxhAX0zq.js} +1 -1
- package/out/renderer/assets/{installer-BZ2LwP7g.js → installer-BaX_sXt9.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-CjKrMxxh.js → journeyDiagram-U35MCT3I-C2ESsRrd.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BxioVQg0.js → kanban-definition-NDS4AKOZ-Sy7_JQxl.js} +1 -1
- package/out/renderer/assets/{layout-B2a5sFst.js → layout-BIY9Aicm.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-ZFnTQgw6.js → legacy-agents-page-Cc0APBCV.js} +1 -1
- package/out/renderer/assets/{mermaid.core-mY1aEGAJ.js → mermaid.core-Dd6Z4632.js} +5 -5
- package/out/renderer/assets/{mesh-page-jUGHCyuu.js → mesh-page-DZvWWqUP.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-C_s8Z-gm.js → mindmap-definition-ALO5MXBD-g4Yb3UNq.js} +1 -1
- package/out/renderer/assets/{mini-Djd85Uxj.js → mini-DYCxYiKw.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-DemlF3Bf.js → org-surface-gate-B8fnNPpi.js} +1 -1
- package/out/renderer/assets/{page-header-CdZzFIhg.js → page-header-CZYftvB1.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-CqJSXjQp.js → pieDiagram-IB7DONF6-F8LZExN5.js} +1 -1
- package/out/renderer/assets/{projects-page-CppbUxuL.js → projects-page-B1bg7q_9.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-SFgJZto9.js → quadrantDiagram-7GDLP6J5-rh4mk2d5.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-BDEyyHau.js → radar-MK3ICKWK-DRGWqtCX.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-DrOPRh6r.js → radient-auth-buttons-BYdsYX04.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-BMjR7asa.js → requirementDiagram-KVF5MWMF-BW_W32AN.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-BFy48dsY.js → sankeyDiagram-QLVOVGJD-Da2ruw_B.js} +1 -1
- package/out/renderer/assets/{schedules-page-DXxgKffJ.js → schedules-page-BgdW7H8B.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DhuzDrPE.js → sequenceDiagram-X6HHIX6F-DOFQE45B.js} +1 -1
- package/out/renderer/assets/{settings-page-7TSVpKoV.js → settings-page-DWD7khMF.js} +1 -1
- package/out/renderer/assets/{settings-section-BjmxaSQh.js → settings-section-Z6n84Hu2.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-vInRe9wE.js → stateDiagram-DGXRK772-WWWtsm-s.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-SFa2-GCO.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-B0KZFCtP.js → timeline-definition-BDJGKUSR-97ZqUIJR.js} +1 -1
- package/out/renderer/assets/{ui-preferences-store-Df8tktLT.js → ui-preferences-store-CC8aFabY.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-CLzfMzVi.js → use-download-agent-mutation-Cc1YKh4G.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-CsrCm6L1.js → use-memberships-query-mPXx5KM6.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-CnxwlYUz.js → use-session-snapshot-TukjnWYL.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BhE5cqrS.js → xychartDiagram-VJFVF3MP-g4T0Cb0k.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +2 -2
- package/out/renderer/assets/browser-page-NaMJJp_m.js +0 -1
- package/out/renderer/assets/channel-DcXmjTnk.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DAHHmXqw.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DAHHmXqw.js +0 -1
- package/out/renderer/assets/clone-BHSxSyTM.js +0 -1
- package/out/renderer/assets/index-B_kljxo9.css +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DqFxtv0T.js +0 -1
- /package/out/renderer/assets/{index-CT65QA5C.js → index-mu0fzQM7.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
2
|
-
import{d as Ki,p as jl,ad as uPe,u as Bn,ae as OPe,af as dPe,ag as fPe,ah as yU,ai as hPe,a0 as pPe,a7 as mPe,aj as gPe,ab as $Pe,ak as yPe,al as vPe,a2 as vU,a3 as bPe,am as Qie,an as bU,ao as wU,ap as UP,aq as WP,ar as wPe,as as SPe,at as xPe,f as SU,C as Ai,c as kie,au as QPe,b as kPe}from"./ui-preferences-store-Df8tktLT.js";import{r as y,b as F,j as h,f as PPe,c as j,g as Vn,w as Pie,x as vv,e as gn,t as xE}from"./index-CT65QA5C.js";import{a6 as TPe,c as De,B as Ve,ak as q7,al as j7,am as C7,an as _Pe,ao as z7,ap as XPe,f as At,q as Ow,r as RPe,j as vd,C as Lc,X as Ri,a7 as EPe,aC as qPe,aD as jPe,aE as CPe,A as xc,S as Fo,Z as zPe,aH as APe,aI as UPe,aJ as WPe,aK as YPe,k as Tie,g as b1,h as w1,aB as A7,i as Mh,D as _ie,l as Xie,m as Rie,p as hc,aL as GPe,U as NPe,V as ZPe,W as IPe,y as DPe,I as po,T as Lh,s as VPe,t as MPe,u as LPe,v as FPe,w as BPe,x as HPe,R as U7,ai as QE,L as Eie,aM as KPe,Y as JPe,e as eo,z as e5e,F as t5e,G as xU,H as QU,J as n5e,K as kU,aq as r5e,aN as i5e,a as a5e,n as YP,o as PU,E as TU}from"./error-boundary-BtSNu6UL.js";var yn;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const a={};for(const o of i)a[o]=o;return a},e.getValidEnumValues=i=>{const a=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(const s of a)o[s]=i[s];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},e.find=(i,a)=>{for(const o of i)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=r,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(yn||(yn={}));var kE;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(kE||(kE={}));const tt=yn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Oc=e=>{switch(typeof e){case"undefined":return tt.undefined;case"string":return tt.string;case"number":return isNaN(e)?tt.nan:tt.number;case"boolean":return tt.boolean;case"function":return tt.function;case"bigint":return tt.bigint;case"symbol":return tt.symbol;case"object":return Array.isArray(e)?tt.array:e===null?tt.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?tt.promise:typeof Map<"u"&&e instanceof Map?tt.map:typeof Set<"u"&&e instanceof Set?tt.set:typeof Date<"u"&&e instanceof Date?tt.date:tt.object;default:return tt.unknown}},Ce=yn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),o5e=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class qa extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(a){return a.message},r={_errors:[]},i=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let s=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(n(o))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof qa))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,yn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}qa.create=e=>new qa(e);const Fh=(e,t)=>{let n;switch(e.code){case Ce.invalid_type:e.received===tt.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Ce.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,yn.jsonStringifyReplacer)}`;break;case Ce.unrecognized_keys:n=`Unrecognized key(s) in object: ${yn.joinValues(e.keys,", ")}`;break;case Ce.invalid_union:n="Invalid input";break;case Ce.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${yn.joinValues(e.options)}`;break;case Ce.invalid_enum_value:n=`Invalid enum value. Expected ${yn.joinValues(e.options)}, received '${e.received}'`;break;case Ce.invalid_arguments:n="Invalid function arguments";break;case Ce.invalid_return_type:n="Invalid function return type";break;case Ce.invalid_date:n="Invalid date";break;case Ce.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:yn.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Ce.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Ce.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Ce.custom:n="Invalid input";break;case Ce.invalid_intersection_types:n="Intersection results could not be merged";break;case Ce.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Ce.not_finite:n="Number must be finite";break;default:n=t.defaultError,yn.assertNever(e)}return{message:n}};let qie=Fh;function s5e(e){qie=e}function dw(){return qie}const fw=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)s=c(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},l5e=[];function Be(e,t){const n=dw(),r=fw({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Fh?void 0:Fh].filter(i=>!!i)});e.common.issues.push(r)}class Bi{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return jt;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const a=await i.key,o=await i.value;r.push({key:a,value:o})}return Bi.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return jt;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[a.value]=o.value)}return{status:t.value,value:r}}}const jt=Object.freeze({status:"aborted"}),hh=e=>({status:"dirty",value:e}),ma=e=>({status:"valid",value:e}),PE=e=>e.status==="aborted",TE=e=>e.status==="dirty",Cd=e=>e.status==="valid",q0=e=>typeof Promise<"u"&&e instanceof Promise;function hw(e,t,n,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function jie(e,t,n,r,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var mt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(mt||(mt={}));var _g,Xg;class kl{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const _U=(e,t)=>{if(Cd(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new qa(e.common.issues);return this._error=n,this._error}}};function Mt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,s)=>{var l,c;const{message:u}=e;return o.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:(l=u??r)!==null&&l!==void 0?l:s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:(c=u??n)!==null&&c!==void 0?c:s.defaultError}},description:i}}class nn{get description(){return this._def.description}_getType(t){return Oc(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Oc(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Bi,ctx:{common:t.parent.common,data:t.data,parsedType:Oc(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(q0(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const i={common:{issues:[],async:(r=n?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oc(t)},a=this._parseSync({data:t,path:i.path,parent:i});return _U(i,a)}"~validate"(t){var n,r;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oc(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:i});return Cd(a)?{value:a.value}:{issues:i.common.issues}}catch(a){!((r=(n=a?.message)===null||n===void 0?void 0:n.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:i}).then(a=>Cd(a)?{value:a.value}:{issues:i.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oc(t)},i=this._parse({data:t,path:r.path,parent:r}),a=await(q0(i)?i:Promise.resolve(i));return _U(r,a)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,a)=>{const o=t(i),s=()=>a.addIssue({code:Ce.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new js({schema:this,typeName:Rt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return yl.create(this,this._def)}nullable(){return tO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xs.create(this)}promise(){return Hh.create(this,this._def)}or(t){return A0.create([this,t],this._def)}and(t){return U0.create(this,t,this._def)}transform(t){return new js({...Mt(this._def),schema:this,typeName:Rt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Z0({...Mt(this._def),innerType:this,defaultValue:n,typeName:Rt.ZodDefault})}brand(){return new W7({typeName:Rt.ZodBranded,type:this,...Mt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new I0({...Mt(this._def),innerType:this,catchValue:n,typeName:Rt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Py.create(this,t)}readonly(){return D0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const c5e=/^c[^\s-]{8,}$/i,u5e=/^[0-9a-z]+$/,O5e=/^[0-9A-HJKMNP-TV-Z]{26}$/i,d5e=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,f5e=/^[a-z0-9_-]{21}$/i,h5e=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,p5e=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,m5e=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,g5e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let GP;const $5e=/^(?:(?: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])$/,y5e=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,v5e=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,b5e=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,w5e=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,S5e=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cie="((\\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])))",x5e=new RegExp(`^${Cie}$`);function zie(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Q5e(e){return new RegExp(`^${zie(e)}$`)}function Aie(e){let t=`${Cie}T${zie(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function k5e(e,t){return!!((t==="v4"||!t)&&$5e.test(e)||(t==="v6"||!t)&&v5e.test(e))}function P5e(e,t){if(!h5e.test(e))return!1;try{const[n]=e.split("."),r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function T5e(e,t){return!!((t==="v4"||!t)&&y5e.test(e)||(t==="v6"||!t)&&b5e.test(e))}class Ts extends nn{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==tt.string){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:tt.string,received:a.parsedType}),jt}const r=new Bi;let i;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(t,i),o?Be(i,{code:Ce.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Be(i,{code:Ce.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")m5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"email",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")GP||(GP=new RegExp(g5e,"u")),GP.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"emoji",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")d5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"uuid",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")f5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"nanoid",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")c5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"cuid",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")u5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"cuid2",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")O5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"ulid",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Be(i,{validation:"url",code:Ce.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"regex",code:Ce.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Aie(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?x5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Q5e(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?p5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"duration",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?k5e(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"ip",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?P5e(t.data,a.alg)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"jwt",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?T5e(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"cidr",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?w5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"base64",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?S5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"base64url",code:Ce.invalid_string,message:a.message}),r.dirty()):yn.assertNever(a);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Ce.invalid_string,...mt.errToObj(r)})}_addCheck(t){return new Ts({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...mt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...mt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...mt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...mt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...mt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...mt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...mt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...mt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...mt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...mt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...mt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...mt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...mt.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...mt.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...mt.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...mt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...mt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...mt.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...mt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...mt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...mt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...mt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...mt.errToObj(n)})}nonempty(t){return this.min(1,mt.errToObj(t))}trim(){return new Ts({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ts({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ts({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Ts.create=e=>{var t;return new Ts({checks:[],typeName:Rt.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Mt(e)})};function _5e(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,a=parseInt(e.toFixed(i).replace(".","")),o=parseInt(t.toFixed(i).replace(".",""));return a%o/Math.pow(10,i)}class Ku extends nn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==tt.number){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:tt.number,received:a.parsedType}),jt}let r;const i=new Bi;for(const a of this._def.checks)a.kind==="int"?yn.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?_5e(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.not_finite,message:a.message}),i.dirty()):yn.assertNever(a);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,mt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,mt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,mt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,mt.toString(n))}setLimit(t,n,r,i){return new Ku({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mt.toString(i)}]})}_addCheck(t){return new Ku({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:mt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:mt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:mt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:mt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:mt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:mt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:mt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:mt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:mt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&yn.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Ku.create=e=>new Ku({checks:[],typeName:Rt.ZodNumber,coerce:e?.coerce||!1,...Mt(e)});class Ju extends nn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==tt.bigint)return this._getInvalidInput(t);let r;const i=new Bi;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):yn.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Be(n,{code:Ce.invalid_type,expected:tt.bigint,received:n.parsedType}),jt}gte(t,n){return this.setLimit("min",t,!0,mt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,mt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,mt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,mt.toString(n))}setLimit(t,n,r,i){return new Ju({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mt.toString(i)}]})}_addCheck(t){return new Ju({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:mt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:mt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:mt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:mt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:mt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Ju.create=e=>{var t;return new Ju({checks:[],typeName:Rt.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Mt(e)})};class j0 extends nn{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==tt.boolean){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.boolean,received:r.parsedType}),jt}return ma(t.data)}}j0.create=e=>new j0({typeName:Rt.ZodBoolean,coerce:e?.coerce||!1,...Mt(e)});class zd extends nn{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==tt.date){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:tt.date,received:a.parsedType}),jt}if(isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_date}),jt}const r=new Bi;let i;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):yn.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new zd({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:mt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:mt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}zd.create=e=>new zd({checks:[],coerce:e?.coerce||!1,typeName:Rt.ZodDate,...Mt(e)});class pw extends nn{_parse(t){if(this._getType(t)!==tt.symbol){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.symbol,received:r.parsedType}),jt}return ma(t.data)}}pw.create=e=>new pw({typeName:Rt.ZodSymbol,...Mt(e)});class C0 extends nn{_parse(t){if(this._getType(t)!==tt.undefined){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.undefined,received:r.parsedType}),jt}return ma(t.data)}}C0.create=e=>new C0({typeName:Rt.ZodUndefined,...Mt(e)});class z0 extends nn{_parse(t){if(this._getType(t)!==tt.null){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.null,received:r.parsedType}),jt}return ma(t.data)}}z0.create=e=>new z0({typeName:Rt.ZodNull,...Mt(e)});class Bh extends nn{constructor(){super(...arguments),this._any=!0}_parse(t){return ma(t.data)}}Bh.create=e=>new Bh({typeName:Rt.ZodAny,...Mt(e)});class bd extends nn{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ma(t.data)}}bd.create=e=>new bd({typeName:Rt.ZodUnknown,...Mt(e)});class qc extends nn{_parse(t){const n=this._getOrReturnCtx(t);return Be(n,{code:Ce.invalid_type,expected:tt.never,received:n.parsedType}),jt}}qc.create=e=>new qc({typeName:Rt.ZodNever,...Mt(e)});class mw extends nn{_parse(t){if(this._getType(t)!==tt.undefined){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.void,received:r.parsedType}),jt}return ma(t.data)}}mw.create=e=>new mw({typeName:Rt.ZodVoid,...Mt(e)});class Xs extends nn{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==tt.array)return Be(n,{code:Ce.invalid_type,expected:tt.array,received:n.parsedType}),jt;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(o||s)&&(Be(n,{code:o?Ce.too_big:Ce.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(Be(n,{code:Ce.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Be(n,{code:Ce.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,s)=>i.type._parseAsync(new kl(n,o,n.path,s)))).then(o=>Bi.mergeArray(r,o));const a=[...n.data].map((o,s)=>i.type._parseSync(new kl(n,o,n.path,s)));return Bi.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new Xs({...this._def,minLength:{value:t,message:mt.toString(n)}})}max(t,n){return new Xs({...this._def,maxLength:{value:t,message:mt.toString(n)}})}length(t,n){return new Xs({...this._def,exactLength:{value:t,message:mt.toString(n)}})}nonempty(t){return this.min(1,t)}}Xs.create=(e,t)=>new Xs({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Rt.ZodArray,...Mt(t)});function lh(e){if(e instanceof xr){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=yl.create(lh(r))}return new xr({...e._def,shape:()=>t})}else return e instanceof Xs?new Xs({...e._def,type:lh(e.element)}):e instanceof yl?yl.create(lh(e.unwrap())):e instanceof tO?tO.create(lh(e.unwrap())):e instanceof Pl?Pl.create(e.items.map(t=>lh(t))):e}class xr extends nn{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=yn.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==tt.object){const c=this._getOrReturnCtx(t);return Be(c,{code:Ce.invalid_type,expected:tt.object,received:c.parsedType}),jt}const{status:r,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof qc&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||s.push(c);const l=[];for(const c of o){const u=a[c],O=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new kl(i,O,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof qc){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")s.length>0&&(Be(i,{code:Ce.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of s){const O=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new kl(i,O,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const O=await u.key,d=await u.value;c.push({key:O,value:d,alwaysSet:u.alwaysSet})}return c}).then(c=>Bi.mergeObjectSync(r,c)):Bi.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return mt.errToObj,new xr({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,a,o,s;const l=(o=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(s=mt.errToObj(t).message)!==null&&s!==void 0?s:l}:{message:l}}}:{}})}strip(){return new xr({...this._def,unknownKeys:"strip"})}passthrough(){return new xr({...this._def,unknownKeys:"passthrough"})}extend(t){return new xr({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new xr({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Rt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new xr({...this._def,catchall:t})}pick(t){const n={};return yn.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new xr({...this._def,shape:()=>n})}omit(t){const n={};return yn.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new xr({...this._def,shape:()=>n})}deepPartial(){return lh(this)}partial(t){const n={};return yn.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}),new xr({...this._def,shape:()=>n})}required(t){const n={};return yn.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof yl;)a=a._def.innerType;n[r]=a}}),new xr({...this._def,shape:()=>n})}keyof(){return Uie(yn.objectKeys(this.shape))}}xr.create=(e,t)=>new xr({shape:()=>e,unknownKeys:"strip",catchall:qc.create(),typeName:Rt.ZodObject,...Mt(t)});xr.strictCreate=(e,t)=>new xr({shape:()=>e,unknownKeys:"strict",catchall:qc.create(),typeName:Rt.ZodObject,...Mt(t)});xr.lazycreate=(e,t)=>new xr({shape:e,unknownKeys:"strip",catchall:qc.create(),typeName:Rt.ZodObject,...Mt(t)});class A0 extends nn{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(s=>new qa(s.ctx.common.issues));return Be(n,{code:Ce.invalid_union,unionErrors:o}),jt}if(n.common.async)return Promise.all(r.map(async a=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let a;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const s=o.map(l=>new qa(l));return Be(n,{code:Ce.invalid_union,unionErrors:s}),jt}}get options(){return this._def.options}}A0.create=(e,t)=>new A0({options:e,typeName:Rt.ZodUnion,...Mt(t)});const Hl=e=>e instanceof Y0?Hl(e.schema):e instanceof js?Hl(e.innerType()):e instanceof G0?[e.value]:e instanceof eO?e.options:e instanceof N0?yn.objectValues(e.enum):e instanceof Z0?Hl(e._def.innerType):e instanceof C0?[void 0]:e instanceof z0?[null]:e instanceof yl?[void 0,...Hl(e.unwrap())]:e instanceof tO?[null,...Hl(e.unwrap())]:e instanceof W7||e instanceof D0?Hl(e.unwrap()):e instanceof I0?Hl(e._def.innerType):[];class Mx extends nn{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==tt.object)return Be(n,{code:Ce.invalid_type,expected:tt.object,received:n.parsedType}),jt;const r=this.discriminator,i=n.data[r],a=this.optionsMap.get(i);return a?n.common.async?a._parseAsync({data:n.data,path:n.path,parent:n}):a._parseSync({data:n.data,path:n.path,parent:n}):(Be(n,{code:Ce.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),jt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const a of n){const o=Hl(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const s of o){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,a)}}return new Mx({typeName:Rt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Mt(r)})}}function _E(e,t){const n=Oc(e),r=Oc(t);if(e===t)return{valid:!0,data:e};if(n===tt.object&&r===tt.object){const i=yn.objectKeys(t),a=yn.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(const s of a){const l=_E(e[s],t[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(n===tt.array&&r===tt.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let a=0;a<e.length;a++){const o=e[a],s=t[a],l=_E(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===tt.date&&r===tt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class U0 extends nn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(a,o)=>{if(PE(a)||PE(o))return jt;const s=_E(a.value,o.value);return s.valid?((TE(a)||TE(o))&&n.dirty(),{status:n.value,value:s.data}):(Be(r,{code:Ce.invalid_intersection_types}),jt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}U0.create=(e,t,n)=>new U0({left:e,right:t,typeName:Rt.ZodIntersection,...Mt(n)});class Pl extends nn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==tt.array)return Be(r,{code:Ce.invalid_type,expected:tt.array,received:r.parsedType}),jt;if(r.data.length<this._def.items.length)return Be(r,{code:Ce.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),jt;!this._def.rest&&r.data.length>this._def.items.length&&(Be(r,{code:Ce.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...r.data].map((o,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new kl(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>Bi.mergeArray(n,o)):Bi.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Pl({...this._def,rest:t})}}Pl.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pl({items:e,typeName:Rt.ZodTuple,rest:null,...Mt(t)})};class W0 extends nn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==tt.object)return Be(r,{code:Ce.invalid_type,expected:tt.object,received:r.parsedType}),jt;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in r.data)i.push({key:a._parse(new kl(r,s,r.path,s)),value:o._parse(new kl(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?Bi.mergeObjectAsync(n,i):Bi.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof nn?new W0({keyType:t,valueType:n,typeName:Rt.ZodRecord,...Mt(r)}):new W0({keyType:Ts.create(),valueType:t,typeName:Rt.ZodRecord,...Mt(n)})}}class gw extends nn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==tt.map)return Be(r,{code:Ce.invalid_type,expected:tt.map,received:r.parsedType}),jt;const i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,l],c)=>({key:i._parse(new kl(r,s,r.path,[c,"key"])),value:a._parse(new kl(r,l,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return jt;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return jt;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}}}}gw.create=(e,t,n)=>new gw({valueType:t,keyType:e,typeName:Rt.ZodMap,...Mt(n)});class Ad extends nn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==tt.set)return Be(r,{code:Ce.invalid_type,expected:tt.set,received:r.parsedType}),jt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Be(r,{code:Ce.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Be(r,{code:Ce.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const a=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return jt;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const s=[...r.data.values()].map((l,c)=>a._parse(new kl(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(t,n){return new Ad({...this._def,minSize:{value:t,message:mt.toString(n)}})}max(t,n){return new Ad({...this._def,maxSize:{value:t,message:mt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Ad.create=(e,t)=>new Ad({valueType:e,minSize:null,maxSize:null,typeName:Rt.ZodSet,...Mt(t)});class Ph extends nn{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==tt.function)return Be(n,{code:Ce.invalid_type,expected:tt.function,received:n.parsedType}),jt;function r(s,l){return fw({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dw(),Fh].filter(c=>!!c),issueData:{code:Ce.invalid_arguments,argumentsError:l}})}function i(s,l){return fw({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dw(),Fh].filter(c=>!!c),issueData:{code:Ce.invalid_return_type,returnTypeError:l}})}const a={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Hh){const s=this;return ma(async function(...l){const c=new qa([]),u=await s._def.args.parseAsync(l,a).catch(f=>{throw c.addIssue(r(l,f)),c}),O=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(O,a).catch(f=>{throw c.addIssue(i(O,f)),c})})}else{const s=this;return ma(function(...l){const c=s._def.args.safeParse(l,a);if(!c.success)throw new qa([r(l,c.error)]);const u=Reflect.apply(o,this,c.data),O=s._def.returns.safeParse(u,a);if(!O.success)throw new qa([i(u,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Ph({...this._def,args:Pl.create(t).rest(bd.create())})}returns(t){return new Ph({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new Ph({args:t||Pl.create([]).rest(bd.create()),returns:n||bd.create(),typeName:Rt.ZodFunction,...Mt(r)})}}class Y0 extends nn{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Y0.create=(e,t)=>new Y0({getter:e,typeName:Rt.ZodLazy,...Mt(t)});class G0 extends nn{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Be(n,{received:n.data,code:Ce.invalid_literal,expected:this._def.value}),jt}return{status:"valid",value:t.data}}get value(){return this._def.value}}G0.create=(e,t)=>new G0({value:e,typeName:Rt.ZodLiteral,...Mt(t)});function Uie(e,t){return new eO({values:e,typeName:Rt.ZodEnum,...Mt(t)})}class eO extends nn{constructor(){super(...arguments),_g.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Be(n,{expected:yn.joinValues(r),received:n.parsedType,code:Ce.invalid_type}),jt}if(hw(this,_g)||jie(this,_g,new Set(this._def.values)),!hw(this,_g).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return Be(n,{received:n.data,code:Ce.invalid_enum_value,options:r}),jt}return ma(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return eO.create(t,{...this._def,...n})}exclude(t,n=this._def){return eO.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}_g=new WeakMap;eO.create=Uie;class N0 extends nn{constructor(){super(...arguments),Xg.set(this,void 0)}_parse(t){const n=yn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==tt.string&&r.parsedType!==tt.number){const i=yn.objectValues(n);return Be(r,{expected:yn.joinValues(i),received:r.parsedType,code:Ce.invalid_type}),jt}if(hw(this,Xg)||jie(this,Xg,new Set(yn.getValidEnumValues(this._def.values))),!hw(this,Xg).has(t.data)){const i=yn.objectValues(n);return Be(r,{received:r.data,code:Ce.invalid_enum_value,options:i}),jt}return ma(t.data)}get enum(){return this._def.values}}Xg=new WeakMap;N0.create=(e,t)=>new N0({values:e,typeName:Rt.ZodNativeEnum,...Mt(t)});class Hh extends nn{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==tt.promise&&n.common.async===!1)return Be(n,{code:Ce.invalid_type,expected:tt.promise,received:n.parsedType}),jt;const r=n.parsedType===tt.promise?n.data:Promise.resolve(n.data);return ma(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Hh.create=(e,t)=>new Hh({type:e,typeName:Rt.ZodPromise,...Mt(t)});class js extends nn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Rt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:o=>{Be(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const o=i.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async s=>{if(n.value==="aborted")return jt;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?jt:l.status==="dirty"||n.value==="dirty"?hh(l.value):l});{if(n.value==="aborted")return jt;const s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?jt:s.status==="dirty"||n.value==="dirty"?hh(s.value):s}}if(i.type==="refinement"){const o=s=>{const l=i.refinement(s,a);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?jt:(s.status==="dirty"&&n.dirty(),o(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?jt:(s.status==="dirty"&&n.dirty(),o(s.value).then(()=>({status:n.value,value:s.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Cd(o))return o;const s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Cd(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):o);yn.assertNever(i)}}js.create=(e,t,n)=>new js({schema:e,typeName:Rt.ZodEffects,effect:t,...Mt(n)});js.createWithPreprocess=(e,t,n)=>new js({schema:t,effect:{type:"preprocess",transform:e},typeName:Rt.ZodEffects,...Mt(n)});class yl extends nn{_parse(t){return this._getType(t)===tt.undefined?ma(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}yl.create=(e,t)=>new yl({innerType:e,typeName:Rt.ZodOptional,...Mt(t)});class tO extends nn{_parse(t){return this._getType(t)===tt.null?ma(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}tO.create=(e,t)=>new tO({innerType:e,typeName:Rt.ZodNullable,...Mt(t)});class Z0 extends nn{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===tt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Z0.create=(e,t)=>new Z0({innerType:e,typeName:Rt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Mt(t)});class I0 extends nn{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return q0(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new qa(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new qa(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}I0.create=(e,t)=>new I0({innerType:e,typeName:Rt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Mt(t)});class $w extends nn{_parse(t){if(this._getType(t)!==tt.nan){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.nan,received:r.parsedType}),jt}return{status:"valid",value:t.data}}}$w.create=e=>new $w({typeName:Rt.ZodNaN,...Mt(e)});const X5e=Symbol("zod_brand");class W7 extends nn{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Py extends nn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?jt:a.status==="dirty"?(n.dirty(),hh(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?jt:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new Py({in:t,out:n,typeName:Rt.ZodPipeline})}}class D0 extends nn{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Cd(i)&&(i.value=Object.freeze(i.value)),i);return q0(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}D0.create=(e,t)=>new D0({innerType:e,typeName:Rt.ZodReadonly,...Mt(t)});function XU(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Wie(e,t={},n){return e?Bh.create().superRefine((r,i)=>{var a,o;const s=e(r);if(s instanceof Promise)return s.then(l=>{var c,u;if(!l){const O=XU(t,r),d=(u=(c=O.fatal)!==null&&c!==void 0?c:n)!==null&&u!==void 0?u:!0;i.addIssue({code:"custom",...O,fatal:d})}});if(!s){const l=XU(t,r),c=(o=(a=l.fatal)!==null&&a!==void 0?a:n)!==null&&o!==void 0?o:!0;i.addIssue({code:"custom",...l,fatal:c})}}):Bh.create()}const R5e={object:xr.lazycreate};var Rt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Rt||(Rt={}));const E5e=(e,t={message:`Input not instance of ${e.name}`})=>Wie(n=>n instanceof e,t),Yie=Ts.create,Gie=Ku.create,q5e=$w.create,j5e=Ju.create,Nie=j0.create,C5e=zd.create,z5e=pw.create,A5e=C0.create,U5e=z0.create,W5e=Bh.create,Y5e=bd.create,G5e=qc.create,N5e=mw.create,Z5e=Xs.create,I5e=xr.create,D5e=xr.strictCreate,V5e=A0.create,M5e=Mx.create,L5e=U0.create,F5e=Pl.create,B5e=W0.create,H5e=gw.create,K5e=Ad.create,J5e=Ph.create,eTe=Y0.create,tTe=G0.create,nTe=eO.create,rTe=N0.create,iTe=Hh.create,RU=js.create,aTe=yl.create,oTe=tO.create,sTe=js.createWithPreprocess,lTe=Py.create,cTe=()=>Yie().optional(),uTe=()=>Gie().optional(),OTe=()=>Nie().optional(),dTe={string:e=>Ts.create({...e,coerce:!0}),number:e=>Ku.create({...e,coerce:!0}),boolean:e=>j0.create({...e,coerce:!0}),bigint:e=>Ju.create({...e,coerce:!0}),date:e=>zd.create({...e,coerce:!0})},fTe=jt;var X=Object.freeze({__proto__:null,defaultErrorMap:Fh,setErrorMap:s5e,getErrorMap:dw,makeIssue:fw,EMPTY_PATH:l5e,addIssueToContext:Be,ParseStatus:Bi,INVALID:jt,DIRTY:hh,OK:ma,isAborted:PE,isDirty:TE,isValid:Cd,isAsync:q0,get util(){return yn},get objectUtil(){return kE},ZodParsedType:tt,getParsedType:Oc,ZodType:nn,datetimeRegex:Aie,ZodString:Ts,ZodNumber:Ku,ZodBigInt:Ju,ZodBoolean:j0,ZodDate:zd,ZodSymbol:pw,ZodUndefined:C0,ZodNull:z0,ZodAny:Bh,ZodUnknown:bd,ZodNever:qc,ZodVoid:mw,ZodArray:Xs,ZodObject:xr,ZodUnion:A0,ZodDiscriminatedUnion:Mx,ZodIntersection:U0,ZodTuple:Pl,ZodRecord:W0,ZodMap:gw,ZodSet:Ad,ZodFunction:Ph,ZodLazy:Y0,ZodLiteral:G0,ZodEnum:eO,ZodNativeEnum:N0,ZodPromise:Hh,ZodEffects:js,ZodTransformer:js,ZodOptional:yl,ZodNullable:tO,ZodDefault:Z0,ZodCatch:I0,ZodNaN:$w,BRAND:X5e,ZodBranded:W7,ZodPipeline:Py,ZodReadonly:D0,custom:Wie,Schema:nn,ZodSchema:nn,late:R5e,get ZodFirstPartyTypeKind(){return Rt},coerce:dTe,any:W5e,array:Z5e,bigint:j5e,boolean:Nie,date:C5e,discriminatedUnion:M5e,effect:RU,enum:nTe,function:J5e,instanceof:E5e,intersection:L5e,lazy:eTe,literal:tTe,map:H5e,nan:q5e,nativeEnum:rTe,never:G5e,null:U5e,nullable:oTe,number:Gie,object:I5e,oboolean:OTe,onumber:uTe,optional:aTe,ostring:cTe,pipeline:lTe,preprocess:sTe,promise:iTe,record:B5e,set:K5e,strictObject:D5e,string:Yie,symbol:z5e,transformer:RU,tuple:F5e,undefined:A5e,union:V5e,unknown:Y5e,void:N5e,NEVER:fTe,ZodIssueCode:Ce,quotelessJson:o5e,ZodError:qa});const Ct=X.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),bv=X.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),wv=X.string().min(1).max(32768),Y7=/^[a-f0-9]{12}$/,Xt=X.string().regex(Y7),hTe=X.string().min(1).max(4096),NP=X.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),Sv=X.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),EU=X.string().regex(/^[a-f0-9]{32}$/),Zie=/^(\/|[A-Za-z]:[\\/])/,ZP=X.string().min(1).max(4096).regex(Zie),qU=/^[a-f0-9]{32}$/,Fn=X.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Af=X.string().regex(/^[A-Za-z0-9_-]{1,128}$/),jU=X.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),CU=X.object({data_b64:X.string().min(1).max(1e6),mime_type:X.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),nO=2e5,V0=8,pTe=256,mTe=100,XE=16,G7=256,Iie=100,Die=200,RE=1e6,Po=X.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),xv=X.object({kind:X.enum(["agent","team"]),name:Po}).strict(),IP=X.object({provider:X.string().min(1).max(128),model_id:X.string().min(1).max(512),reasoning_effort:X.string().min(1).max(64).nullable()}).strict(),zU=X.object({kind:X.enum(["role","specialist"]).optional(),description:X.string().max(8e3).optional(),instructions:X.string().max(8e3).optional(),tools:X.array(X.string().min(1).max(128)).max(256).optional(),effort:X.string().max(64).optional(),delegate:X.boolean().optional(),action_class:X.enum(["reactive","proactive"]).optional()}).strict(),AU=X.object({name:X.string().min(1).max(64).optional(),description:X.string().max(8e3).optional(),manager:Po.optional(),members:X.array(X.object({role:Po,count:X.number().int().min(1).max(16),kind:X.enum(["agent","team"])}).strict()).max(128).optional(),instructions:X.string().max(8e3).optional(),project:X.string().max(8e3).optional()}).strict(),gTe=X.record(X.array(X.string().max(1024)).max(100)),UU=X.enum(["minutes","hours","days"]);function $Te(e){return!/^\.+$/.test(e)}const hHt=e=>S1.safeParse(e).success,S1=X.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine($Te),WU=X.enum(["str","int","float","bool","list","dict"]),YU=X.string().max(16384),yTe=2e3,GU=X.string().min(1).max(yTe),NU=X.string().min(1).max(64),vTe=X.string().min(1).max(64),ZU=X.object({is_active:X.boolean().nullish(),one_time:X.boolean().nullish(),start_time_utc:X.string().max(64).nullish(),end_time_utc:X.string().max(64).nullish()}).strict(),bTe=X.object({conversation_length:X.number().int().optional(),detail_length:X.number().int().optional(),max_learnings_history:X.number().int().optional(),hosting:X.string().max(256).optional(),model_name:X.string().max(1024).optional(),auto_save_conversation:X.boolean().optional()}).strict(),EE=128,IU=2e3,DU=8e3,VU=64,MU=64,Lx=e=>[...e].length,qE=e=>e>=9&&e<=13||e>=28&&e<=32||e===133||e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288,wTe=e=>e===9||e===10||e===11||e===12||e===13||e===133,STe=e=>e<=31||e>=127&&e<=159,xTe=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),QTe=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,Qv=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},Vie=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&qE(t[n].codePointAt(0)??0);)n++;for(;r>n&&qE(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},kTe=e=>{let t="",n=!1;for(const r of e){if(qE(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function PTe(e){const t=Vie(e);if(!t)return"must not be empty";if(Lx(t)>EE)return`must be at most ${EE} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(Qv(t,QTe))return"must not contain Unicode bidirectional override characters";if(Qv(t,wTe))return"must not contain whitespace";if(Qv(t,STe))return"must not contain control characters";if(Qv(t,xTe))return"must not contain invisible Unicode formatting characters";const n=[...t];return"-.".includes(n[0])||"-.".includes(n[n.length-1])?'must not begin or end with "-" or "."':null}function pHt(e){return kTe(Vie(e).normalize("NFKC").toLowerCase())}function TTe(e){return e.trim()?Lx(e)>IU?`must be at most ${IU} characters`:null:"must not be empty"}function _Te(e){return e.trim()?Lx(e)>DU?`must be at most ${DU} characters`:null:"must not be empty"}function XTe(e){if(e.length>MU)return`must hold at most ${MU} items`;for(const t of e)if(!t.trim()||Lx(t)>VU)return`must hold items of 1 to ${VU} characters`;return null}const RTe=e=>PTe(e)===null,ETe=X.string().refine(RTe,{message:"That is not a name the hub can publish."}),qTe=X.string().refine(e=>_Te(e)===null,{message:"That instruction body cannot be published."}),jTe=X.string().refine(e=>TTe(e)===null,{message:"That description cannot be published."}),CTe=X.array(X.string()).refine(e=>XTe(e)===null,{message:"That tool list cannot be published."}),LU=X.object({name:ETe,description:jTe,instructions:qTe,kind:X.enum(["role","specialist"]),when_to_use:X.string(),tools:CTe,effort:X.string(),delegate:X.boolean(),version:X.string(),categories:X.array(X.string()),tags:X.array(X.string())}).partial().strict(),zTe=X.enum(["team","agent"]),ATe=X.string().min(1).max(64),UTe=X.string().min(1).max(256),Mie=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,DP=X.string().regex(Mie,{message:"Letters, digits, dot, underscore and dash; no spaces."}),WTe=["planning","active","qa","validation","done","paused","archived"],FU=X.enum(WTe),kv=X.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),BU=X.array(X.string().min(1).max(24)).max(8),fu=X.string().min(1).max(64),YTe=1e3,HU=240,KU=80,GTe=256,NTe=100,ZTe=200,ITe=/^[a-z0-9][a-z0-9_-]{0,23}$/;function mHt(e){return e?Mie.test(e)?null:"Names start with a letter or digit and may use letters, digits, dot, underscore or dash.":"Give the project a name."}function gHt(e){return ITe.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const Pv=X.enum(["agent","team"]),DTe=X.discriminatedUnion("op",[X.object({op:X.literal("capabilities")}).strict(),X.object({op:X.literal("runtimes.list")}).strict(),X.object({op:X.literal("profiles.list")}).strict(),X.object({op:X.literal("profiles.get"),name:Po}).strict(),X.object({op:X.literal("profiles.install"),name:Po,requestId:Fn}).strict(),X.object({op:X.literal("profiles.create"),name:Po,requestId:Fn,fields:zU.extend({description:X.string().max(8e3),instructions:X.string().min(1).max(8e3)})}).strict(),X.object({op:X.literal("profiles.update"),name:Po,requestId:Fn,fields:zU}).strict(),X.object({op:X.literal("hub.updates")}).strict(),X.object({op:X.literal("hub.check"),requestId:Fn,kind:Pv.optional(),name:Po.optional()}).strict(),X.object({op:X.literal("hub.apply"),requestId:Fn,kind:Pv,name:Po,prefer:X.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:X.boolean().optional(),dryRun:X.boolean().optional()}).strict(),X.object({op:X.literal("hub.applyAll"),requestId:Fn,kind:Pv.optional()}).strict(),X.object({op:X.literal("hub.retry"),requestId:Fn,kind:Pv,name:Po}).strict(),X.object({op:X.literal("teams.list")}).strict(),X.object({op:X.literal("teams.get"),name:Po}).strict(),X.object({op:X.literal("teams.create"),requestId:Fn,fields:AU.extend({name:X.string().min(1).max(64)})}).strict(),X.object({op:X.literal("teams.update"),name:Po,requestId:Fn,fields:AU}).strict(),X.object({op:X.literal("sessions.list"),limit:X.number().int().min(1).max(500).optional(),include_archived:X.boolean().optional(),include_peers:X.boolean().optional(),scope_kind:zTe.optional(),scope_name:ATe.optional(),cursor:UTe.optional(),with_counts:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.search"),q:X.string().min(1).max(pTe),limit:X.number().int().min(1).max(500).optional(),include_archived:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.archive"),sessionId:Xt,archived:X.boolean()}).strict(),X.object({op:X.literal("sessions.delete"),sessionId:Xt,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.create"),requestId:Fn,cwd:X.string().min(1).max(4096).optional(),target:xv.optional(),purpose:X.literal("agents-config").optional(),model:IP.optional(),draftId:Xt.optional(),peer:Af.optional()}).strict(),X.object({op:X.literal("sessions.preview"),requestId:Fn,cwd:X.string().min(1).max(4096),target:xv.optional(),model:IP.optional()}).strict(),X.object({op:X.literal("sessions.draft"),requestId:Fn,cwd:X.string().min(1).max(4096),target:xv.optional(),model:IP.optional()}).strict(),X.object({op:X.literal("sessions.get"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.history"),sessionId:Xt,beforeId:Ct.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.checkpoints"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.checkpoints.warm"),sessionId:Xt,ids:X.array(Ct).max(XE).optional(),limit:X.number().int().min(1).max(XE).optional()}).strict(),X.object({op:X.literal("sessions.find"),sessionId:Xt,q:X.string().min(1).max(G7),limit:X.number().int().min(1).max(Die).optional()}).strict(),X.object({op:X.literal("subagents.transcript"),sessionId:Xt,childId:Xt,beforeId:Ct.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.message"),sessionId:Xt,requestId:Fn,text:X.string().max(nO),images:X.array(CU).max(V0).optional(),mode:X.enum(["prompt","steer"]).optional(),inputMode:X.enum(["typed","dictated","mixed"]).optional(),inputPath:X.string().max(1024).optional()}).strict(),X.object({op:X.literal("sessions.command"),sessionId:Xt,requestId:Fn,command:X.string().regex(/^\/?[A-Za-z]+$/).max(64),args:X.string().max(nO).optional(),images:X.array(CU).max(V0).optional()}).strict(),X.object({op:X.literal("sessions.move"),sessionId:Xt,requestId:Fn,cwd:X.string().min(1).max(4096)}).strict(),X.object({op:X.literal("sessions.answer"),sessionId:Xt,epoch:Ct.optional(),requestId:Ct.optional(),value:X.string().max(32768).optional(),approved:X.boolean().optional(),questionIndex:X.number().int().min(0).optional(),askId:Ct.optional(),answers:X.record(X.string(),X.array(X.string().max(32768))).optional(),decline:X.boolean().optional(),revise:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.seen"),sessionId:Xt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("attention.seen"),items:X.array(X.object({sessionId:Xt,completionToken:X.string().uuid()}).strict()).min(1).max(500)}).strict(),X.object({op:X.literal("sessions.notified"),sessionId:Xt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("sessions.pin"),sessionId:Xt,pinned:X.boolean()}).strict(),X.object({op:X.literal("sessions.watch"),sessionId:Xt,subscriptionId:X.string().regex(qU),visible:X.boolean(),canNotify:X.boolean()}).strict(),X.object({op:X.literal("sessions.warm"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.interrupt"),sessionId:Xt,requestId:Fn}).strict(),X.object({op:X.literal("sessions.variables.list"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.variables.create"),sessionId:Xt,key:S1,value:YU,type:WU}).strict(),X.object({op:X.literal("sessions.variables.update"),sessionId:Xt,key:S1,value:YU,type:WU}).strict(),X.object({op:X.literal("sessions.variables.delete"),sessionId:Xt,key:S1}).strict(),X.object({op:X.literal("sessions.presence"),subscriptionId:X.string().regex(/^[a-f0-9]{1,64}$/),canNotify:X.boolean(),canNotifyKinds:X.array(X.enum(["complete","error"])).max(4),sessionId:X.string().regex(/^([a-f0-9]{12})?$/),window:X.object({exists:X.boolean(),focused:X.boolean(),visible:X.boolean(),minimized:X.boolean()}).strict()}).strict(),X.object({op:X.literal("legacy.models"),provider:X.string().max(128).optional(),sort:X.enum(["id","name","provider","recommended"]).optional(),direction:X.enum(["ascending","descending"]).optional()}).strict(),X.object({op:X.literal("legacy.models.providers")}).strict(),X.object({op:X.literal("auth.probe"),provider:Ct}).strict(),X.object({op:X.literal("legacy.agent.upload"),agentId:Ct}).strict(),X.object({op:X.literal("agent.publish"),agentId:Ct,document:LU.optional(),visibility:X.literal("org").optional(),tenantId:Ct.optional()}).strict(),X.object({op:X.literal("agent.republish"),agentId:Ct,hubAgentId:Ct,document:LU.optional(),visibility:X.literal("org").optional(),tenantId:Ct.optional()}).strict(),X.object({op:X.literal("team.pull"),teamId:Ct,tenantId:Ct.optional()}).strict(),X.object({op:X.literal("agent.nameAvailability"),name:X.string().min(1).max(EE)}).strict(),X.object({op:X.literal("legacy.agents.list"),page:X.number().int().min(1).optional(),perPage:X.number().int().min(1).max(500).optional(),name:X.string().max(256).optional(),sort:X.string().max(64).optional(),direction:X.enum(["asc","desc"]).optional()}).strict(),X.object({op:X.literal("legacy.agent.get"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.agent.history"),agentId:Ct,page:X.number().int().min(1).optional(),perPage:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("legacy.jobs.list"),agentId:Ct.optional(),status:X.string().max(64).optional()}).strict(),X.object({op:X.literal("legacy.job.get"),jobId:Ct}).strict(),X.object({op:X.literal("legacy.schedules.list"),page:X.number().int().min(1).optional(),perPage:X.number().int().min(1).max(100).optional()}).strict(),X.object({op:X.literal("legacy.agent.schedules.list"),agentId:Ct,page:X.number().int().min(1).optional(),perPage:X.number().int().min(1).max(100).optional()}).strict(),X.object({op:X.literal("legacy.agent.schedule.create"),agentId:Ct,schedule:ZU.extend({prompt:X.string().max(64e3),interval:X.number().int().min(1),unit:UU})}).strict(),X.object({op:X.literal("legacy.schedule.get"),scheduleId:Ct}).strict(),X.object({op:X.literal("legacy.schedule.edit"),scheduleId:Ct,schedule:ZU.extend({prompt:X.string().max(64e3).nullish(),interval:X.number().int().min(1).nullish(),unit:UU.nullish()})}).strict(),X.object({op:X.literal("legacy.schedule.remove"),scheduleId:Ct}).strict(),X.object({op:X.literal("legacy.agent.create"),agent:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.update"),agentId:Ct,update:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.delete"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.agent.conversation.clear"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.get"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.update"),agentId:Ct,systemPrompt:X.string().max(RE)}).strict(),X.object({op:X.literal("legacy.agent.download"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.job.cancel"),jobId:Ct}).strict(),X.object({op:X.literal("commands.list")}).strict(),X.object({op:X.literal("commands.entities"),sessionId:Xt,command:Ct,name:X.string().max(128).optional()}).strict(),X.object({op:X.literal("models.catalogue"),live:X.boolean().optional()}).strict(),X.object({op:X.literal("usage.get"),provider:Ct.optional(),live:X.boolean().optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("analytics.get"),sessionId:Xt.optional(),sinceMs:X.number().int().nonnegative().optional(),untilMs:X.number().int().nonnegative().optional(),days:X.number().int().min(1).max(366).optional()}).strict(),X.object({op:X.literal("analytics.models"),sessionId:Xt.optional(),sinceMs:X.number().int().nonnegative().optional(),untilMs:X.number().int().nonnegative().optional(),days:X.number().int().min(1).max(366).optional()}).strict(),X.object({op:X.literal("info.get")}).strict(),X.object({op:X.literal("sessions.report"),sessionId:Xt,recentLimit:X.number().int().min(0).max(50).optional()}).strict(),X.object({op:X.literal("skills.list"),sessionId:Xt.optional(),cwd:hTe.optional(),name:Ct.optional()}).strict(),X.object({op:X.literal("sessions.failovers"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.credential"),sessionId:Xt,action:X.enum(["list","store","forget"]),key:bv.optional(),value:wv.optional(),confirmed:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.fork"),sessionId:Xt,requestId:Fn,message:X.string().max(2e5).optional(),boundary:X.enum(["next_safe","at_entry"]).optional(),entryId:X.string().max(128).optional()}).strict(),X.object({op:X.literal("sessions.stop"),requestId:Fn,targets:X.array(Xt).min(1).max(100),confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside"),sessionId:Xt,requestId:Fn,text:X.string().min(1).max(32768),asideId:Fn.optional(),subscriptionId:X.string().regex(qU).optional()}).strict(),X.object({op:X.literal("sessions.adopt"),sessionId:Xt,requestId:Fn,asideId:Fn,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside.get"),sessionId:Xt,asideId:Fn}).strict(),X.object({op:X.literal("sessions.aside.close"),sessionId:Xt,asideId:Fn}).strict(),X.object({op:X.literal("wakes.list"),limit:X.number().int().min(1).max(500).optional(),includeDormant:X.boolean().optional()}).strict(),X.object({op:X.literal("wakes.create"),requestId:Fn,sessionId:Xt.optional(),cwd:X.string().min(1).max(4096).optional(),target:xv.optional(),message:GU,in:X.string().min(1).max(64).optional(),at:X.string().min(1).max(64).optional(),every:X.string().min(1).max(64).optional(),until:X.string().min(1).max(64).optional(),limit:X.number().int().min(1).optional(),title:X.string().min(1).max(200).optional()}).strict(),X.object({op:X.literal("wakes.edit"),sessionId:Xt,wakeId:NU,message:GU.optional(),in:X.string().min(1).max(64).optional(),at:X.string().min(1).max(64).optional(),every:X.string().min(1).max(64).optional(),until:X.string().min(1).max(64).optional(),limit:X.number().int().min(1).optional()}).strict(),X.object({op:X.literal("wakes.remove"),sessionId:Xt,wakeId:NU}).strict(),X.object({op:X.literal("monitors.cancel"),sessionId:Xt,monitorId:vTe}).strict(),X.object({op:X.literal("mcp.list"),sessionId:Xt}).strict(),X.object({op:X.literal("mcp.credentials.store"),sessionId:Xt,name:X.string().min(1).max(256),values:X.record(X.string().min(1).max(128),X.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:X.array(X.string().min(1).max(128)).max(32)}).strict(),X.object({op:X.literal("mcp.control"),sessionId:Xt,control:X.object({action:X.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:NP.optional(),scope:X.enum(["global","project"]).optional(),command:X.string().min(1).max(4096).optional(),args:X.array(X.string().max(8192)).max(128).optional(),env:X.record(Sv).optional(),url:X.string().max(4096).optional(),headers:X.record(Sv).optional(),oauth:X.boolean().optional(),confirmed:X.boolean().optional(),operation_id:EU.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog"),cwd:ZP.optional(),sessionId:Xt.optional()}).strict(),X.object({op:X.literal("mcp.catalog.control"),cwd:ZP.optional(),control:X.object({action:X.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:NP.optional(),scope:X.enum(["global","project"]).optional(),command:X.string().min(1).max(4096).optional(),args:X.array(X.string().max(8192)).max(128).optional(),env:X.record(Sv).optional(),url:X.string().max(4096).optional(),headers:X.record(Sv).optional(),confirmed:X.boolean().optional(),operation_id:EU.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog.credentials"),header:X.string().min(1).max(128).optional(),cwd:ZP.optional(),name:NP,values:X.record(X.string().min(1).max(128),X.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:X.array(X.string().min(1).max(128)).max(32)}).strict(),X.object({op:X.literal("radient.request"),control:X.object({operation:X.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","agents.statuses","comments.list","comments.create","comments.update","comments.delete","account.agents","memberships.list","org_agents.list","org_team.get","org_teams.list"]),request_id:Fn.optional(),tenant_id:Ct.optional(),account_id:Ct.optional(),agent_id:Ct.optional(),comment_id:Ct.optional(),team_id:Ct.optional(),query:X.record(X.union([X.string().max(1024),X.number().int()])).optional(),payload:X.record(X.unknown()).optional(),confirmed:X.boolean().optional()}).strict()}).strict(),X.object({op:X.literal("providers.list")}).strict(),X.object({op:X.literal("accounts.list")}).strict(),X.object({op:X.literal("accounts.remove"),accountId:X.number().int().positive(),confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("auth.start"),provider:Ct}).strict(),X.object({op:X.literal("auth.status"),id:Ct}).strict(),X.object({op:X.literal("auth.input"),id:Ct,promptId:Ct,value:wv}).strict(),X.object({op:X.literal("auth.cancel"),id:Ct}).strict(),X.object({op:X.literal("auth.key"),provider:Ct,value:wv}).strict(),X.object({op:X.literal("auth.logout"),provider:Ct}).strict(),X.object({op:X.literal("settings.list")}).strict(),X.object({op:X.literal("settings.edit"),key:bv,value:X.unknown().refine(e=>e!==void 0,"A setting value is required."),base:gTe.optional()}).strict(),X.object({op:X.literal("settings.reset"),key:bv}).strict(),X.object({op:X.literal("tts.paths")}).strict(),X.object({op:X.literal("config.get")}).strict(),X.object({op:X.literal("config.update"),value:bTe}).strict(),X.object({op:X.literal("instructions.get")}).strict(),X.object({op:X.literal("instructions.update"),content:X.string().max(64e3)}).strict(),X.object({op:X.literal("credentials.list")}).strict(),X.object({op:X.literal("credentials.update"),key:bv,value:wv}).strict(),X.object({op:X.literal("peers.list")}).strict(),X.object({op:X.literal("networks.list")}).strict(),X.object({op:X.literal("networks.invite"),networkId:Af,role:X.enum(["read","drive","admin"]),deviceId:Af.optional()}).strict(),X.object({op:X.literal("networks.member.remove"),networkId:Af,deviceId:Af,confirm:X.string().min(1).max(256)}).strict(),X.object({op:X.literal("sessions.transfer"),sessionId:Xt,to:X.union([X.literal("local"),Af]),keep:X.boolean().optional(),waitS:X.number().min(0).max(300).optional(),requestId:Fn.optional()}).strict(),X.object({op:X.literal("approvals.list")}).strict(),X.object({op:X.literal("approvals.approve"),approvalId:jU}).strict(),X.object({op:X.literal("approvals.deny"),approvalId:jU}).strict(),X.object({op:X.literal("asks.list")}).strict(),X.object({op:X.literal("projects.list")}).strict(),X.object({op:X.literal("projects.get"),key:fu}).strict(),X.object({op:X.literal("projects.create"),name:DP,description:X.string().max(HU).optional(),status:FU.optional(),tags:BU.optional()}).strict(),X.object({op:X.literal("projects.update"),key:fu,fields:X.object({name:DP.optional(),title:X.string().max(80).optional(),owner:X.string().max(80).optional(),team:X.string().max(80).optional(),description:X.string().max(HU).optional(),status:FU.optional(),progress:X.string().max(YTe).optional(),tags:BU.optional(),start_date:kv.optional(),target_date:kv.optional(),completed_at:kv.optional(),estimate:X.number().positive().max(1e3).optional(),estimate_unit:X.enum(["points","days"]).optional()}).strict()}).strict(),X.object({op:X.literal("projects.delete"),key:fu,confirmed_name:DP}).strict(),X.object({op:X.literal("projects.link"),key:fu,sessionId:Xt}).strict(),X.object({op:X.literal("projects.unlink"),key:fu,sessionId:Xt}).strict(),X.object({op:X.literal("projects.milestone"),key:fu,name:X.string().min(1).max(KU),targetDate:kv.optional(),completed:X.boolean().optional()}).strict(),X.object({op:X.literal("projects.milestone.remove"),key:fu,name:X.string().min(1).max(KU)}).strict(),X.object({op:X.literal("projects.request_update"),key:fu}).strict(),X.object({op:X.literal("projects.search"),q:X.string().min(1).max(GTe),limit:X.number().int().min(1).max(ZTe).optional()}).strict(),X.object({op:X.literal("aida.status")}).strict(),X.object({op:X.literal("aida.control"),action:X.enum(["open","pause","resume","greet","status"])}).strict()]);DTe.superRefine((e,t)=>{if(e.op==="sessions.answer"){if(e.askId!==void 0){e.askId||t.addIssue({code:X.ZodIssueCode.custom,message:"ask_id must be a non-empty string",path:["askId"]}),e.decline!==!0&&!e.answers?t.addIssue({code:X.ZodIssueCode.custom,message:"A queued-ask answer needs answers or decline",path:["answers"]}):e.decline===!0&&e.answers!==void 0?t.addIssue({code:X.ZodIssueCode.custom,message:"Supply either answers or decline",path:["decline"]}):e.revise===!0&&e.decline===!0?t.addIssue({code:X.ZodIssueCode.custom,message:"Supply either decline or revise",path:["revise"]}):e.answers!==void 0&&Object.keys(e.answers).length===0&&t.addIssue({code:X.ZodIssueCode.custom,message:"answers must name at least one question",path:["answers"]});return}e.epoch||t.addIssue({code:X.ZodIssueCode.custom,message:"An epoch is required to answer a gate",path:["epoch"]}),e.requestId||t.addIssue({code:X.ZodIssueCode.custom,message:"A request id is required to answer a gate",path:["requestId"]}),e.revise===!0&&t.addIssue({code:X.ZodIssueCode.custom,message:"revise applies to a queued ask",path:["revise"]});return}if(e.op==="sessions.create"&&e.purpose===void 0){e.cwd===void 0&&t.addIssue({code:X.ZodIssueCode.custom,message:"A conversation needs a working directory: only a configuration run (`purpose`) may omit `cwd`.",path:["cwd"]});return}if(e.op==="sessions.create"&&e.purpose!==void 0){for(const n of["cwd","target","model","draftId"])e[n]!==void 0&&t.addIssue({code:X.ZodIssueCode.custom,message:`A configuration run resolves its own \`${n}\`: send \`purpose\` alone.`,path:[n]});return}e.op!=="agent.publish"&&e.op!=="agent.republish"||e.visibility==="org"!=!!e.tenantId&&t.addIssue({code:X.ZodIssueCode.custom,message:'A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.'})});const so={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},N7={runtimeUnreachable:"runtime_unreachable"},Kp="runtime_busy",Lie="runtime_retiring",Fx={[so.noCredential]:"This app is not paired with the running Local Operator server, so this control is unavailable.",[so.refused]:"This app's credential for the running Local Operator server was refused, so this control is unavailable.",[so.planeClosed]:"The running Local Operator server does not accept this app's desktop controls.",[so.transportFailed]:"The Local Operator server did not answer this request."},M0={noCredential:"Restart with a desktop-managed backend to use these controls.",transportFailed:"The backend could not complete this request. Check its connection and try again."};function L0(e){return e!==void 0&&Object.values(so).includes(e)}function VTe(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return so.refused;if(t===503)return so.planeClosed}}const MTe=88e4,LTe=11e5,FTe=2e4,BTe=9e4,HTe=new Set(["analytics.get","analytics.models","sessions.report"]),KTe=new Set(["usage.get"]),JTe=new Set(["networks.list","peers.list"]),e_e=new Set([...HTe,...KTe,...JTe]),t_e=90,n_e=30,r_e=300,i_e=10,Fie=15,a_e=1e4;function o_e(e){const n=e.to==="local"||e.keep?r_e:n_e,r=Math.max(0,e.waitS??0);return(t_e+n+i_e+Fie)*1e3+r*1e3}const s_e=18e4,l_e=s_e+15e3,c_e=120,Bie=(c_e+30+Fie)*1e3,u_e=6e4,O_e=5*Bie,d_e=new Set(["hub.apply","hub.retry","hub.check","hub.applyAll"]);function f_e(e){switch(e){case"hub.apply":case"hub.retry":return Bie;case"hub.check":return u_e;case"hub.applyAll":return O_e;default:return null}}function h_e(e){if(typeof e!="string"&&e.op==="sessions.transfer")return o_e(e)+a_e;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return l_e;const n=f_e(t);return n!==null?n:e_e.has(t)?BTe:FTe}const p_e=5e3;function Z7(e){return h_e(e)+p_e}const Bx="deadline_exceeded",Hie="foreground_required",Kie="View these completions in the foreground before marking them read.",m_e=new Set(["capabilities","accounts.list","analytics.get","analytics.models","approvals.list","commands.entities","commands.list","config.get","credentials.list","hub.updates","info.get","instructions.get","legacy.agent.get","legacy.agent.history","legacy.agent.schedules.list","legacy.agents.list","legacy.job.get","legacy.jobs.list","legacy.models","legacy.models.providers","legacy.schedule.get","legacy.schedules.list","mcp.catalog","mcp.list","models.catalogue","networks.list","peers.list","profiles.get","profiles.list","projects.search","providers.list","runtimes.list","sessions.aside.get","sessions.checkpoints","sessions.failovers","sessions.find","sessions.get","sessions.history","sessions.list","sessions.preview","sessions.report","sessions.search","sessions.variables.list","skills.list","subagents.transcript","teams.get","teams.list","usage.get"]),g_e=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function $_e(e,t){const n=Math.round(t/1e3),r=Bx;return e==="sessions.transfer"?{code:r,message:`The app waits up to ${n} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`}:e==="approvals.approve"?{code:r,message:`The app waits up to ${n} seconds for an approval, and the signing prompt was still open when it stopped waiting. The request was sent, so the decision may or may not have landed: read the approvals again — if the record still waits, answering it again is safe, because the store keeps the first decision and refuses a second.`}:d_e.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:m_e.has(e)?{code:r,message:g_e.has(e)?`The app waits up to ${n} seconds for this panel's data, and the read was still running when the app stopped waiting. Nothing was read; reopen the panel to ask again.`:`The app waits up to ${n} seconds for this read, and it was still running when the app stopped waiting. Nothing was read; ask again.`}:{code:r,message:`The app waits up to ${n} seconds for this request, and it was still running when the app stopped waiting. It may or may not have reached the server; check the result before repeating it.`}}const Hx=MTe,y_e=LTe;function v_e(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function JU(e){return{...e.in!==void 0?{in:e.in}:{},...e.at!==void 0?{at:e.at}:{},...e.every!==void 0?{every:e.every}:{},...e.until!==void 0?{until:e.until}:{},...e.limit!==void 0?{limit:e.limit}:{}}}function eW(e){if(e.visibility==="org"!=!!e.tenantId)throw new Error('A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.')}function Kx(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"runtimes.list":return{path:"/v1/desktop/runtimes?probe=false",method:"GET"};case"peers.list":return{path:"/v1/desktop/peers",method:"GET"};case"networks.list":return{path:"/v1/desktop/networks",method:"GET"};case"asks.list":return{path:"/v1/desktop/asks",method:"GET"};case"networks.invite":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/invite`,method:"POST",body:{role:e.role,device:e.deviceId??null}};case"networks.member.remove":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/members/${encodeURIComponent(e.deviceId)}`,method:"DELETE",body:{confirm:e.confirm}};case"sessions.transfer":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/transfer`,method:"POST",body:{to:e.to,keep:e.keep??!1,wait_s:e.waitS??0,...e.requestId?{request_id:e.requestId}:{}}};case"approvals.list":return{path:"/v1/desktop/approvals",method:"GET"};case"approvals.approve":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/approve`,method:"POST"};case"approvals.deny":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/deny`,method:"POST"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"hub.updates":return{path:"/v1/desktop/hub/updates",method:"GET"};case"hub.check":return{path:"/v1/desktop/hub/updates/check",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{}}};case"hub.apply":return{path:"/v1/desktop/hub/updates/apply",method:"POST",body:{request_id:e.requestId,kind:e.kind,name:e.name,...e.prefer?{prefer:e.prefer}:{},...e.acknowledgeUnknownBaseline!==void 0?{acknowledge_unknown_baseline:e.acknowledgeUnknownBaseline}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{}}};case"hub.applyAll":return{path:"/v1/desktop/hub/updates/apply-all",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{}}};case"hub.retry":return{path:"/v1/desktop/hub/updates/retry",method:"POST",body:{request_id:e.requestId,kind:e.kind,name:e.name}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"sessions.list":{const t=new URLSearchParams;return t.set("limit",String(e.limit??100)),e.include_archived&&t.set("include_archived","true"),e.scope_kind&&t.set("scope_kind",e.scope_kind),e.scope_name&&t.set("scope_name",e.scope_name),e.cursor&&t.set("cursor",e.cursor),e.with_counts&&t.set("with_counts","true"),e.include_peers&&t.set("include_peers","true"),{path:`/v1/desktop/sessions?${t}`,method:"GET"}}case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??mTe)});return e.include_archived&&t.set("include_archived","true"),{path:`/v1/desktop/sessions/search?${t}`,method:"GET"}}case"sessions.archive":return{path:`/v1/desktop/sessions/${e.sessionId}/archive`,method:"POST",body:{archived:e.archived}};case"sessions.delete":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"DELETE",body:{confirmed:!0}};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.peer?{peer:e.peer}:{},...e.target?{target:e.target}:{},...e.model?{model:e.model}:{},...e.draftId?{draft_id:e.draftId}:{},...e.purpose?{purpose:e.purpose}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.draft":return{path:"/v1/desktop/sessions/draft",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"GET"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"sessions.checkpoints":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints`,method:"GET"};case"sessions.checkpoints.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints/warm`,method:"POST",body:{...e.ids?{ids:e.ids}:{},...e.limit!==void 0?{limit:e.limit}:{}}};case"sessions.find":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??Iie)});return{path:`/v1/desktop/sessions/${e.sessionId}/find?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],mode:e.mode??"prompt",...e.inputMode?{input_mode:e.inputMode}:{},...e.inputPath?{input_path:e.inputPath}:{}}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return e.askId!==void 0?{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{ask_id:e.askId,answers:e.answers,decline:e.decline,...e.revise===!0?{revise:!0}:{}}}:{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"attention.seen":return{path:"/v1/desktop/attention/seen",method:"POST",body:{items:e.items.map(t=>({session_id:t.sessionId,completion_token:t.completionToken}))}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"sessions.pin":return{path:`/v1/desktop/sessions/${e.sessionId}/pin`,method:"POST",body:{pinned:e.pinned}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"agent.publish":{eW(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"POST",body:{document:e.document??{}}}}case"agent.republish":{eW(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"PUT",body:{hub_agent_id:e.hubAgentId,document:e.document??{}}}}case"team.pull":{const t=new URLSearchParams;e.tenantId&&t.set("tenant_id",e.tenantId);const n=t.toString();return{path:`/v1/teams/pull/${e.teamId}${n?`?${n}`:""}`,method:"GET"}}case"agent.nameAvailability":return{path:`/v1/agent-name-availability?${new URLSearchParams({name:e.name})}`,method:"GET"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"wakes.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/wakes?${t}`:"/v1/desktop/wakes",method:"GET"}}case"wakes.create":return{path:"/v1/desktop/wakes",method:"POST",body:{request_id:e.requestId,...v_e(e),message:e.message,...JU(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...JU(e)}};case"wakes.remove":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"DELETE"};case"monitors.cancel":return{path:`/v1/desktop/monitors/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(e.monitorId)}`,method:"DELETE"};case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":return{path:`/v1/desktop/models?live=${e.live??!1}`,method:"GET"};case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"analytics.models":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics/models?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":{const t=new URLSearchParams;e.sessionId&&t.set("session_id",e.sessionId),e.cwd&&t.set("cwd",e.cwd),e.name&&t.set("name",e.name);const n=t.toString();return{path:`/v1/desktop/skills${n?`?${n}`:""}`,method:"GET"}}case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary,entry_id:e.entryId}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId,subscription_id:e.subscriptionId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"mcp.catalog":{const t=new URLSearchParams;e.cwd&&t.set("cwd",e.cwd),e.sessionId&&t.set("session_id",e.sessionId);const n=t.toString();return{path:n?`/v1/desktop/mcp?${n}`:"/v1/desktop/mcp",method:"GET"}}case"mcp.catalog.control":return{path:"/v1/desktop/mcp",method:"POST",body:{...e.control,...e.cwd?{cwd:e.cwd}:{}}};case"mcp.catalog.credentials":return{path:"/v1/desktop/mcp/credentials",method:"POST",body:{name:e.name,values:e.values,...e.header?{header:e.header}:{},confirmed_replace:e.confirmedReplace,...e.cwd?{cwd:e.cwd}:{}}};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"tts.paths":return{path:"/v1/tts/paths",method:"GET"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}};case"projects.list":return{path:"/v1/desktop/projects",method:"GET"};case"projects.get":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"GET"};case"projects.create":return{path:"/v1/desktop/projects",method:"POST",body:{name:e.name,...e.description!==void 0?{description:e.description}:{},...e.status!==void 0?{status:e.status}:{},...e.tags!==void 0?{tags:e.tags}:{}}};case"projects.update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"PATCH",body:{...e.fields}};case"projects.delete":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"DELETE",body:{confirm:e.confirmed_name}};case"projects.link":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links`,method:"POST",body:{session_id:e.sessionId}};case"projects.unlink":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links/${encodeURIComponent(e.sessionId)}`,method:"DELETE"};case"projects.milestone":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones`,method:"POST",body:{name:e.name,...e.targetDate!==void 0?{target_date:e.targetDate}:{},...e.completed!==void 0?{completed:e.completed}:{}}};case"projects.milestone.remove":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones/${encodeURIComponent(e.name)}`,method:"DELETE"};case"projects.request_update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/request-update`,method:"POST"};case"projects.search":return{path:`/v1/desktop/projects/search?${new URLSearchParams({q:e.q,limit:String(e.limit??NTe)})}`,method:"GET"};case"aida.status":return{path:"/v1/desktop/aida",method:"GET"};case"aida.control":return{path:"/v1/desktop/aida",method:"POST",body:{op:e.action}}}}const Jie=64,$Ht=64*1024*1024,b_e="superseded_completion_token",w_e="store_busy",S_e="session_is_remote",x_e="owner_build_behind";function Q_e(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function ld(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function eae(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const tae=e=>typeof e?.goal_status=="string",nae=e=>(e?.goal??"").trim().length>0;function k_e(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const Hg={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."},tW={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},P_e={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},T_e={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},__e={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},X_e={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function nW(e){return e?e===Hg.notPaired?T_e:e===Hg.serverDown?P_e:e===Hg.frameBudget?X_e:tW:tW}async function rae(e){if(window.api?.desktop)try{return await R_e(window.api.desktop.request(e),e)}catch(n){throw n instanceof Nt?n:C_e(n)?new jc(Kie,Hie):new Nt(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new Nt(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Nt(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function R_e(e,t){const n=Z7(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=$_e(t.op,n);a(new Nt(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const iae="This server did not answer the request for its desktop controls.";class Nt extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,i,a,o){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=i,this.retryAfterMs=a,this.detail=o}}class jc extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function mo(e,t){return e instanceof Nt||e instanceof jc?L0(e.code)?Fx[e.code]:e.message:t}function E_e(e,t,n,r){return typeof r=="string"?r:n===M0.noCredential?so.noCredential:n===M0.transportFailed?so.transportFailed:VTe(Kx(e).path,t)}async function Xe(e){const t=await rae(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Nt(t.status,r??iae,void 0,E_e(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return n?.result}function aae(e){return e instanceof Nt&&e.code===Bx}function yHt(e){return e instanceof Nt?e.status===null||e.status===503:!1}function q_e(e){if(!(e instanceof Nt))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===x_e:e.code===S_e}function j_e(e){return e instanceof jc&&e.code===Hie}function C_e(e){return e instanceof Error&&e.message.includes(Kie)}async function Tn(e){const t=await rae(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function z_e(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Xe({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function A_e(e,t){const n=window.api?.desktop?.stream;if(n){const a=n.subscribe(e,t);return()=>a.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1");const i=new EventSource(`/__desktop/stream?${r}`);return i.onmessage=a=>{t({kind:"data",data:a.data})},i.onerror=()=>{i.readyState===EventSource.CLOSED&&(t({kind:"error",detail:Hg.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function Kh(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),i=r.headers.get("content-type")??"";if(!r.ok){let a="The media request failed.";if(i.includes("application/json"))try{const o=await r.json();typeof o.detail=="string"&&(a=o.detail)}catch{}return{status:r.status,kind:"error",detail:a,code:a===M0.noCredential?so.noCredential:void 0}}return i.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:i||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function F0(e){return e.kind==="error"?L0(e.code)?new jc(Fx[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const oae=/\s+/,U_e=/[\\/]+$/,W_e=/[\\/]/,sae=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-dDgWp_lK.js","./ui-preferences-store-CC8aFabY.js","./index-mu0fzQM7.js","./index-oPdbJBXR.css","./error-boundary-CYOMGBqy.js","./index-BCtcy-Az.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-Dd6Z4632.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{d as Ki,p as jl,ad as uPe,u as Bn,ae as OPe,af as dPe,ag as fPe,ah as yU,ai as hPe,a0 as pPe,a7 as mPe,aj as gPe,ab as $Pe,ak as yPe,al as vPe,a2 as vU,a3 as bPe,am as Qie,an as bU,ao as wU,ap as UP,aq as WP,ar as wPe,as as SPe,at as xPe,f as SU,C as Ai,c as kie,au as QPe,b as kPe}from"./ui-preferences-store-CC8aFabY.js";import{r as y,b as F,j as h,f as PPe,c as j,g as Vn,w as Pie,x as vv,e as gn,t as xE}from"./index-mu0fzQM7.js";import{a6 as TPe,c as De,B as Ve,ak as q7,al as j7,am as C7,an as _Pe,ao as z7,ap as XPe,f as At,q as Ow,r as RPe,j as vd,C as Lc,X as Ri,a7 as EPe,aC as qPe,aD as jPe,aE as CPe,A as xc,S as Fo,Z as zPe,aH as APe,aI as UPe,aJ as WPe,aK as YPe,k as Tie,g as b1,h as w1,aB as A7,i as Mh,D as _ie,l as Xie,m as Rie,p as hc,aL as GPe,U as NPe,V as ZPe,W as IPe,y as DPe,I as po,T as Lh,s as VPe,t as MPe,u as LPe,v as FPe,w as BPe,x as HPe,R as U7,ai as QE,L as Eie,aM as KPe,Y as JPe,e as eo,z as e5e,F as t5e,G as xU,H as QU,J as n5e,K as kU,aq as r5e,aN as i5e,a as a5e,n as YP,o as PU,E as TU}from"./error-boundary-CYOMGBqy.js";var yn;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const a={};for(const o of i)a[o]=o;return a},e.getValidEnumValues=i=>{const a=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(const s of a)o[s]=i[s];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},e.find=(i,a)=>{for(const o of i)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=r,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(yn||(yn={}));var kE;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(kE||(kE={}));const tt=yn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Oc=e=>{switch(typeof e){case"undefined":return tt.undefined;case"string":return tt.string;case"number":return isNaN(e)?tt.nan:tt.number;case"boolean":return tt.boolean;case"function":return tt.function;case"bigint":return tt.bigint;case"symbol":return tt.symbol;case"object":return Array.isArray(e)?tt.array:e===null?tt.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?tt.promise:typeof Map<"u"&&e instanceof Map?tt.map:typeof Set<"u"&&e instanceof Set?tt.set:typeof Date<"u"&&e instanceof Date?tt.date:tt.object;default:return tt.unknown}},Ce=yn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),o5e=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class qa extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(a){return a.message},r={_errors:[]},i=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let s=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(n(o))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof qa))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,yn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}qa.create=e=>new qa(e);const Fh=(e,t)=>{let n;switch(e.code){case Ce.invalid_type:e.received===tt.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Ce.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,yn.jsonStringifyReplacer)}`;break;case Ce.unrecognized_keys:n=`Unrecognized key(s) in object: ${yn.joinValues(e.keys,", ")}`;break;case Ce.invalid_union:n="Invalid input";break;case Ce.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${yn.joinValues(e.options)}`;break;case Ce.invalid_enum_value:n=`Invalid enum value. Expected ${yn.joinValues(e.options)}, received '${e.received}'`;break;case Ce.invalid_arguments:n="Invalid function arguments";break;case Ce.invalid_return_type:n="Invalid function return type";break;case Ce.invalid_date:n="Invalid date";break;case Ce.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:yn.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Ce.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Ce.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Ce.custom:n="Invalid input";break;case Ce.invalid_intersection_types:n="Intersection results could not be merged";break;case Ce.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Ce.not_finite:n="Number must be finite";break;default:n=t.defaultError,yn.assertNever(e)}return{message:n}};let qie=Fh;function s5e(e){qie=e}function dw(){return qie}const fw=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)s=c(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},l5e=[];function Be(e,t){const n=dw(),r=fw({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Fh?void 0:Fh].filter(i=>!!i)});e.common.issues.push(r)}class Bi{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return jt;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const a=await i.key,o=await i.value;r.push({key:a,value:o})}return Bi.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return jt;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[a.value]=o.value)}return{status:t.value,value:r}}}const jt=Object.freeze({status:"aborted"}),hh=e=>({status:"dirty",value:e}),ma=e=>({status:"valid",value:e}),PE=e=>e.status==="aborted",TE=e=>e.status==="dirty",Cd=e=>e.status==="valid",q0=e=>typeof Promise<"u"&&e instanceof Promise;function hw(e,t,n,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}function jie(e,t,n,r,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var mt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(mt||(mt={}));var _g,Xg;class kl{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const _U=(e,t)=>{if(Cd(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new qa(e.common.issues);return this._error=n,this._error}}};function Mt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,s)=>{var l,c;const{message:u}=e;return o.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:(l=u??r)!==null&&l!==void 0?l:s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:(c=u??n)!==null&&c!==void 0?c:s.defaultError}},description:i}}class nn{get description(){return this._def.description}_getType(t){return Oc(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Oc(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Bi,ctx:{common:t.parent.common,data:t.data,parsedType:Oc(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(q0(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const i={common:{issues:[],async:(r=n?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oc(t)},a=this._parseSync({data:t,path:i.path,parent:i});return _U(i,a)}"~validate"(t){var n,r;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oc(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:i});return Cd(a)?{value:a.value}:{issues:i.common.issues}}catch(a){!((r=(n=a?.message)===null||n===void 0?void 0:n.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:i}).then(a=>Cd(a)?{value:a.value}:{issues:i.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oc(t)},i=this._parse({data:t,path:r.path,parent:r}),a=await(q0(i)?i:Promise.resolve(i));return _U(r,a)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,a)=>{const o=t(i),s=()=>a.addIssue({code:Ce.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new js({schema:this,typeName:Rt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return yl.create(this,this._def)}nullable(){return tO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xs.create(this)}promise(){return Hh.create(this,this._def)}or(t){return A0.create([this,t],this._def)}and(t){return U0.create(this,t,this._def)}transform(t){return new js({...Mt(this._def),schema:this,typeName:Rt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Z0({...Mt(this._def),innerType:this,defaultValue:n,typeName:Rt.ZodDefault})}brand(){return new W7({typeName:Rt.ZodBranded,type:this,...Mt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new I0({...Mt(this._def),innerType:this,catchValue:n,typeName:Rt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Py.create(this,t)}readonly(){return D0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const c5e=/^c[^\s-]{8,}$/i,u5e=/^[0-9a-z]+$/,O5e=/^[0-9A-HJKMNP-TV-Z]{26}$/i,d5e=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,f5e=/^[a-z0-9_-]{21}$/i,h5e=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,p5e=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,m5e=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,g5e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let GP;const $5e=/^(?:(?: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])$/,y5e=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,v5e=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,b5e=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,w5e=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,S5e=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cie="((\\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])))",x5e=new RegExp(`^${Cie}$`);function zie(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Q5e(e){return new RegExp(`^${zie(e)}$`)}function Aie(e){let t=`${Cie}T${zie(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function k5e(e,t){return!!((t==="v4"||!t)&&$5e.test(e)||(t==="v6"||!t)&&v5e.test(e))}function P5e(e,t){if(!h5e.test(e))return!1;try{const[n]=e.split("."),r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function T5e(e,t){return!!((t==="v4"||!t)&&y5e.test(e)||(t==="v6"||!t)&&b5e.test(e))}class Ts extends nn{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==tt.string){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:tt.string,received:a.parsedType}),jt}const r=new Bi;let i;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(t,i),o?Be(i,{code:Ce.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Be(i,{code:Ce.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")m5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"email",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")GP||(GP=new RegExp(g5e,"u")),GP.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"emoji",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")d5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"uuid",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")f5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"nanoid",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")c5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"cuid",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")u5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"cuid2",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")O5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"ulid",code:Ce.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Be(i,{validation:"url",code:Ce.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"regex",code:Ce.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Aie(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?x5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Q5e(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?p5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"duration",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?k5e(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"ip",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?P5e(t.data,a.alg)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"jwt",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?T5e(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"cidr",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?w5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"base64",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?S5e.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"base64url",code:Ce.invalid_string,message:a.message}),r.dirty()):yn.assertNever(a);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Ce.invalid_string,...mt.errToObj(r)})}_addCheck(t){return new Ts({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...mt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...mt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...mt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...mt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...mt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...mt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...mt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...mt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...mt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...mt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...mt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...mt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...mt.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...mt.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...mt.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...mt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...mt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...mt.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...mt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...mt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...mt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...mt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...mt.errToObj(n)})}nonempty(t){return this.min(1,mt.errToObj(t))}trim(){return new Ts({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ts({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ts({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Ts.create=e=>{var t;return new Ts({checks:[],typeName:Rt.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Mt(e)})};function _5e(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,a=parseInt(e.toFixed(i).replace(".","")),o=parseInt(t.toFixed(i).replace(".",""));return a%o/Math.pow(10,i)}class Ku extends nn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==tt.number){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:tt.number,received:a.parsedType}),jt}let r;const i=new Bi;for(const a of this._def.checks)a.kind==="int"?yn.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?_5e(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.not_finite,message:a.message}),i.dirty()):yn.assertNever(a);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,mt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,mt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,mt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,mt.toString(n))}setLimit(t,n,r,i){return new Ku({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mt.toString(i)}]})}_addCheck(t){return new Ku({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:mt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:mt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:mt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:mt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:mt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:mt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:mt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:mt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:mt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&yn.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Ku.create=e=>new Ku({checks:[],typeName:Rt.ZodNumber,coerce:e?.coerce||!1,...Mt(e)});class Ju extends nn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==tt.bigint)return this._getInvalidInput(t);let r;const i=new Bi;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),Be(r,{code:Ce.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):yn.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Be(n,{code:Ce.invalid_type,expected:tt.bigint,received:n.parsedType}),jt}gte(t,n){return this.setLimit("min",t,!0,mt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,mt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,mt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,mt.toString(n))}setLimit(t,n,r,i){return new Ju({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mt.toString(i)}]})}_addCheck(t){return new Ju({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:mt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:mt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:mt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:mt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:mt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Ju.create=e=>{var t;return new Ju({checks:[],typeName:Rt.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Mt(e)})};class j0 extends nn{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==tt.boolean){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.boolean,received:r.parsedType}),jt}return ma(t.data)}}j0.create=e=>new j0({typeName:Rt.ZodBoolean,coerce:e?.coerce||!1,...Mt(e)});class zd extends nn{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==tt.date){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:tt.date,received:a.parsedType}),jt}if(isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_date}),jt}const r=new Bi;let i;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):yn.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new zd({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:mt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:mt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}zd.create=e=>new zd({checks:[],coerce:e?.coerce||!1,typeName:Rt.ZodDate,...Mt(e)});class pw extends nn{_parse(t){if(this._getType(t)!==tt.symbol){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.symbol,received:r.parsedType}),jt}return ma(t.data)}}pw.create=e=>new pw({typeName:Rt.ZodSymbol,...Mt(e)});class C0 extends nn{_parse(t){if(this._getType(t)!==tt.undefined){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.undefined,received:r.parsedType}),jt}return ma(t.data)}}C0.create=e=>new C0({typeName:Rt.ZodUndefined,...Mt(e)});class z0 extends nn{_parse(t){if(this._getType(t)!==tt.null){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.null,received:r.parsedType}),jt}return ma(t.data)}}z0.create=e=>new z0({typeName:Rt.ZodNull,...Mt(e)});class Bh extends nn{constructor(){super(...arguments),this._any=!0}_parse(t){return ma(t.data)}}Bh.create=e=>new Bh({typeName:Rt.ZodAny,...Mt(e)});class bd extends nn{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ma(t.data)}}bd.create=e=>new bd({typeName:Rt.ZodUnknown,...Mt(e)});class qc extends nn{_parse(t){const n=this._getOrReturnCtx(t);return Be(n,{code:Ce.invalid_type,expected:tt.never,received:n.parsedType}),jt}}qc.create=e=>new qc({typeName:Rt.ZodNever,...Mt(e)});class mw extends nn{_parse(t){if(this._getType(t)!==tt.undefined){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.void,received:r.parsedType}),jt}return ma(t.data)}}mw.create=e=>new mw({typeName:Rt.ZodVoid,...Mt(e)});class Xs extends nn{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==tt.array)return Be(n,{code:Ce.invalid_type,expected:tt.array,received:n.parsedType}),jt;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(o||s)&&(Be(n,{code:o?Ce.too_big:Ce.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(Be(n,{code:Ce.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Be(n,{code:Ce.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,s)=>i.type._parseAsync(new kl(n,o,n.path,s)))).then(o=>Bi.mergeArray(r,o));const a=[...n.data].map((o,s)=>i.type._parseSync(new kl(n,o,n.path,s)));return Bi.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new Xs({...this._def,minLength:{value:t,message:mt.toString(n)}})}max(t,n){return new Xs({...this._def,maxLength:{value:t,message:mt.toString(n)}})}length(t,n){return new Xs({...this._def,exactLength:{value:t,message:mt.toString(n)}})}nonempty(t){return this.min(1,t)}}Xs.create=(e,t)=>new Xs({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Rt.ZodArray,...Mt(t)});function lh(e){if(e instanceof xr){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=yl.create(lh(r))}return new xr({...e._def,shape:()=>t})}else return e instanceof Xs?new Xs({...e._def,type:lh(e.element)}):e instanceof yl?yl.create(lh(e.unwrap())):e instanceof tO?tO.create(lh(e.unwrap())):e instanceof Pl?Pl.create(e.items.map(t=>lh(t))):e}class xr extends nn{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=yn.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==tt.object){const c=this._getOrReturnCtx(t);return Be(c,{code:Ce.invalid_type,expected:tt.object,received:c.parsedType}),jt}const{status:r,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof qc&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||s.push(c);const l=[];for(const c of o){const u=a[c],O=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new kl(i,O,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof qc){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")s.length>0&&(Be(i,{code:Ce.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of s){const O=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new kl(i,O,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const O=await u.key,d=await u.value;c.push({key:O,value:d,alwaysSet:u.alwaysSet})}return c}).then(c=>Bi.mergeObjectSync(r,c)):Bi.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return mt.errToObj,new xr({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,a,o,s;const l=(o=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(s=mt.errToObj(t).message)!==null&&s!==void 0?s:l}:{message:l}}}:{}})}strip(){return new xr({...this._def,unknownKeys:"strip"})}passthrough(){return new xr({...this._def,unknownKeys:"passthrough"})}extend(t){return new xr({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new xr({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Rt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new xr({...this._def,catchall:t})}pick(t){const n={};return yn.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new xr({...this._def,shape:()=>n})}omit(t){const n={};return yn.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new xr({...this._def,shape:()=>n})}deepPartial(){return lh(this)}partial(t){const n={};return yn.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}),new xr({...this._def,shape:()=>n})}required(t){const n={};return yn.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof yl;)a=a._def.innerType;n[r]=a}}),new xr({...this._def,shape:()=>n})}keyof(){return Uie(yn.objectKeys(this.shape))}}xr.create=(e,t)=>new xr({shape:()=>e,unknownKeys:"strip",catchall:qc.create(),typeName:Rt.ZodObject,...Mt(t)});xr.strictCreate=(e,t)=>new xr({shape:()=>e,unknownKeys:"strict",catchall:qc.create(),typeName:Rt.ZodObject,...Mt(t)});xr.lazycreate=(e,t)=>new xr({shape:e,unknownKeys:"strip",catchall:qc.create(),typeName:Rt.ZodObject,...Mt(t)});class A0 extends nn{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(s=>new qa(s.ctx.common.issues));return Be(n,{code:Ce.invalid_union,unionErrors:o}),jt}if(n.common.async)return Promise.all(r.map(async a=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let a;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const s=o.map(l=>new qa(l));return Be(n,{code:Ce.invalid_union,unionErrors:s}),jt}}get options(){return this._def.options}}A0.create=(e,t)=>new A0({options:e,typeName:Rt.ZodUnion,...Mt(t)});const Hl=e=>e instanceof Y0?Hl(e.schema):e instanceof js?Hl(e.innerType()):e instanceof G0?[e.value]:e instanceof eO?e.options:e instanceof N0?yn.objectValues(e.enum):e instanceof Z0?Hl(e._def.innerType):e instanceof C0?[void 0]:e instanceof z0?[null]:e instanceof yl?[void 0,...Hl(e.unwrap())]:e instanceof tO?[null,...Hl(e.unwrap())]:e instanceof W7||e instanceof D0?Hl(e.unwrap()):e instanceof I0?Hl(e._def.innerType):[];class Mx extends nn{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==tt.object)return Be(n,{code:Ce.invalid_type,expected:tt.object,received:n.parsedType}),jt;const r=this.discriminator,i=n.data[r],a=this.optionsMap.get(i);return a?n.common.async?a._parseAsync({data:n.data,path:n.path,parent:n}):a._parseSync({data:n.data,path:n.path,parent:n}):(Be(n,{code:Ce.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),jt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const a of n){const o=Hl(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const s of o){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,a)}}return new Mx({typeName:Rt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Mt(r)})}}function _E(e,t){const n=Oc(e),r=Oc(t);if(e===t)return{valid:!0,data:e};if(n===tt.object&&r===tt.object){const i=yn.objectKeys(t),a=yn.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(const s of a){const l=_E(e[s],t[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(n===tt.array&&r===tt.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let a=0;a<e.length;a++){const o=e[a],s=t[a],l=_E(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===tt.date&&r===tt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class U0 extends nn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(a,o)=>{if(PE(a)||PE(o))return jt;const s=_E(a.value,o.value);return s.valid?((TE(a)||TE(o))&&n.dirty(),{status:n.value,value:s.data}):(Be(r,{code:Ce.invalid_intersection_types}),jt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}U0.create=(e,t,n)=>new U0({left:e,right:t,typeName:Rt.ZodIntersection,...Mt(n)});class Pl extends nn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==tt.array)return Be(r,{code:Ce.invalid_type,expected:tt.array,received:r.parsedType}),jt;if(r.data.length<this._def.items.length)return Be(r,{code:Ce.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),jt;!this._def.rest&&r.data.length>this._def.items.length&&(Be(r,{code:Ce.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...r.data].map((o,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new kl(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>Bi.mergeArray(n,o)):Bi.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Pl({...this._def,rest:t})}}Pl.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pl({items:e,typeName:Rt.ZodTuple,rest:null,...Mt(t)})};class W0 extends nn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==tt.object)return Be(r,{code:Ce.invalid_type,expected:tt.object,received:r.parsedType}),jt;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in r.data)i.push({key:a._parse(new kl(r,s,r.path,s)),value:o._parse(new kl(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?Bi.mergeObjectAsync(n,i):Bi.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof nn?new W0({keyType:t,valueType:n,typeName:Rt.ZodRecord,...Mt(r)}):new W0({keyType:Ts.create(),valueType:t,typeName:Rt.ZodRecord,...Mt(n)})}}class gw extends nn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==tt.map)return Be(r,{code:Ce.invalid_type,expected:tt.map,received:r.parsedType}),jt;const i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,l],c)=>({key:i._parse(new kl(r,s,r.path,[c,"key"])),value:a._parse(new kl(r,l,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return jt;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return jt;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}}}}gw.create=(e,t,n)=>new gw({valueType:t,keyType:e,typeName:Rt.ZodMap,...Mt(n)});class Ad extends nn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==tt.set)return Be(r,{code:Ce.invalid_type,expected:tt.set,received:r.parsedType}),jt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Be(r,{code:Ce.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Be(r,{code:Ce.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const a=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return jt;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const s=[...r.data.values()].map((l,c)=>a._parse(new kl(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(t,n){return new Ad({...this._def,minSize:{value:t,message:mt.toString(n)}})}max(t,n){return new Ad({...this._def,maxSize:{value:t,message:mt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Ad.create=(e,t)=>new Ad({valueType:e,minSize:null,maxSize:null,typeName:Rt.ZodSet,...Mt(t)});class Ph extends nn{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==tt.function)return Be(n,{code:Ce.invalid_type,expected:tt.function,received:n.parsedType}),jt;function r(s,l){return fw({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dw(),Fh].filter(c=>!!c),issueData:{code:Ce.invalid_arguments,argumentsError:l}})}function i(s,l){return fw({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dw(),Fh].filter(c=>!!c),issueData:{code:Ce.invalid_return_type,returnTypeError:l}})}const a={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Hh){const s=this;return ma(async function(...l){const c=new qa([]),u=await s._def.args.parseAsync(l,a).catch(f=>{throw c.addIssue(r(l,f)),c}),O=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(O,a).catch(f=>{throw c.addIssue(i(O,f)),c})})}else{const s=this;return ma(function(...l){const c=s._def.args.safeParse(l,a);if(!c.success)throw new qa([r(l,c.error)]);const u=Reflect.apply(o,this,c.data),O=s._def.returns.safeParse(u,a);if(!O.success)throw new qa([i(u,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Ph({...this._def,args:Pl.create(t).rest(bd.create())})}returns(t){return new Ph({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new Ph({args:t||Pl.create([]).rest(bd.create()),returns:n||bd.create(),typeName:Rt.ZodFunction,...Mt(r)})}}class Y0 extends nn{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Y0.create=(e,t)=>new Y0({getter:e,typeName:Rt.ZodLazy,...Mt(t)});class G0 extends nn{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Be(n,{received:n.data,code:Ce.invalid_literal,expected:this._def.value}),jt}return{status:"valid",value:t.data}}get value(){return this._def.value}}G0.create=(e,t)=>new G0({value:e,typeName:Rt.ZodLiteral,...Mt(t)});function Uie(e,t){return new eO({values:e,typeName:Rt.ZodEnum,...Mt(t)})}class eO extends nn{constructor(){super(...arguments),_g.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Be(n,{expected:yn.joinValues(r),received:n.parsedType,code:Ce.invalid_type}),jt}if(hw(this,_g)||jie(this,_g,new Set(this._def.values)),!hw(this,_g).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return Be(n,{received:n.data,code:Ce.invalid_enum_value,options:r}),jt}return ma(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return eO.create(t,{...this._def,...n})}exclude(t,n=this._def){return eO.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}_g=new WeakMap;eO.create=Uie;class N0 extends nn{constructor(){super(...arguments),Xg.set(this,void 0)}_parse(t){const n=yn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==tt.string&&r.parsedType!==tt.number){const i=yn.objectValues(n);return Be(r,{expected:yn.joinValues(i),received:r.parsedType,code:Ce.invalid_type}),jt}if(hw(this,Xg)||jie(this,Xg,new Set(yn.getValidEnumValues(this._def.values))),!hw(this,Xg).has(t.data)){const i=yn.objectValues(n);return Be(r,{received:r.data,code:Ce.invalid_enum_value,options:i}),jt}return ma(t.data)}get enum(){return this._def.values}}Xg=new WeakMap;N0.create=(e,t)=>new N0({values:e,typeName:Rt.ZodNativeEnum,...Mt(t)});class Hh extends nn{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==tt.promise&&n.common.async===!1)return Be(n,{code:Ce.invalid_type,expected:tt.promise,received:n.parsedType}),jt;const r=n.parsedType===tt.promise?n.data:Promise.resolve(n.data);return ma(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Hh.create=(e,t)=>new Hh({type:e,typeName:Rt.ZodPromise,...Mt(t)});class js extends nn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Rt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:o=>{Be(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const o=i.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async s=>{if(n.value==="aborted")return jt;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?jt:l.status==="dirty"||n.value==="dirty"?hh(l.value):l});{if(n.value==="aborted")return jt;const s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?jt:s.status==="dirty"||n.value==="dirty"?hh(s.value):s}}if(i.type==="refinement"){const o=s=>{const l=i.refinement(s,a);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?jt:(s.status==="dirty"&&n.dirty(),o(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?jt:(s.status==="dirty"&&n.dirty(),o(s.value).then(()=>({status:n.value,value:s.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Cd(o))return o;const s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Cd(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):o);yn.assertNever(i)}}js.create=(e,t,n)=>new js({schema:e,typeName:Rt.ZodEffects,effect:t,...Mt(n)});js.createWithPreprocess=(e,t,n)=>new js({schema:t,effect:{type:"preprocess",transform:e},typeName:Rt.ZodEffects,...Mt(n)});class yl extends nn{_parse(t){return this._getType(t)===tt.undefined?ma(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}yl.create=(e,t)=>new yl({innerType:e,typeName:Rt.ZodOptional,...Mt(t)});class tO extends nn{_parse(t){return this._getType(t)===tt.null?ma(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}tO.create=(e,t)=>new tO({innerType:e,typeName:Rt.ZodNullable,...Mt(t)});class Z0 extends nn{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===tt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Z0.create=(e,t)=>new Z0({innerType:e,typeName:Rt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Mt(t)});class I0 extends nn{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return q0(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new qa(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new qa(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}I0.create=(e,t)=>new I0({innerType:e,typeName:Rt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Mt(t)});class $w extends nn{_parse(t){if(this._getType(t)!==tt.nan){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:tt.nan,received:r.parsedType}),jt}return{status:"valid",value:t.data}}}$w.create=e=>new $w({typeName:Rt.ZodNaN,...Mt(e)});const X5e=Symbol("zod_brand");class W7 extends nn{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Py extends nn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?jt:a.status==="dirty"?(n.dirty(),hh(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?jt:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new Py({in:t,out:n,typeName:Rt.ZodPipeline})}}class D0 extends nn{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Cd(i)&&(i.value=Object.freeze(i.value)),i);return q0(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}D0.create=(e,t)=>new D0({innerType:e,typeName:Rt.ZodReadonly,...Mt(t)});function XU(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Wie(e,t={},n){return e?Bh.create().superRefine((r,i)=>{var a,o;const s=e(r);if(s instanceof Promise)return s.then(l=>{var c,u;if(!l){const O=XU(t,r),d=(u=(c=O.fatal)!==null&&c!==void 0?c:n)!==null&&u!==void 0?u:!0;i.addIssue({code:"custom",...O,fatal:d})}});if(!s){const l=XU(t,r),c=(o=(a=l.fatal)!==null&&a!==void 0?a:n)!==null&&o!==void 0?o:!0;i.addIssue({code:"custom",...l,fatal:c})}}):Bh.create()}const R5e={object:xr.lazycreate};var Rt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Rt||(Rt={}));const E5e=(e,t={message:`Input not instance of ${e.name}`})=>Wie(n=>n instanceof e,t),Yie=Ts.create,Gie=Ku.create,q5e=$w.create,j5e=Ju.create,Nie=j0.create,C5e=zd.create,z5e=pw.create,A5e=C0.create,U5e=z0.create,W5e=Bh.create,Y5e=bd.create,G5e=qc.create,N5e=mw.create,Z5e=Xs.create,I5e=xr.create,D5e=xr.strictCreate,V5e=A0.create,M5e=Mx.create,L5e=U0.create,F5e=Pl.create,B5e=W0.create,H5e=gw.create,K5e=Ad.create,J5e=Ph.create,eTe=Y0.create,tTe=G0.create,nTe=eO.create,rTe=N0.create,iTe=Hh.create,RU=js.create,aTe=yl.create,oTe=tO.create,sTe=js.createWithPreprocess,lTe=Py.create,cTe=()=>Yie().optional(),uTe=()=>Gie().optional(),OTe=()=>Nie().optional(),dTe={string:e=>Ts.create({...e,coerce:!0}),number:e=>Ku.create({...e,coerce:!0}),boolean:e=>j0.create({...e,coerce:!0}),bigint:e=>Ju.create({...e,coerce:!0}),date:e=>zd.create({...e,coerce:!0})},fTe=jt;var X=Object.freeze({__proto__:null,defaultErrorMap:Fh,setErrorMap:s5e,getErrorMap:dw,makeIssue:fw,EMPTY_PATH:l5e,addIssueToContext:Be,ParseStatus:Bi,INVALID:jt,DIRTY:hh,OK:ma,isAborted:PE,isDirty:TE,isValid:Cd,isAsync:q0,get util(){return yn},get objectUtil(){return kE},ZodParsedType:tt,getParsedType:Oc,ZodType:nn,datetimeRegex:Aie,ZodString:Ts,ZodNumber:Ku,ZodBigInt:Ju,ZodBoolean:j0,ZodDate:zd,ZodSymbol:pw,ZodUndefined:C0,ZodNull:z0,ZodAny:Bh,ZodUnknown:bd,ZodNever:qc,ZodVoid:mw,ZodArray:Xs,ZodObject:xr,ZodUnion:A0,ZodDiscriminatedUnion:Mx,ZodIntersection:U0,ZodTuple:Pl,ZodRecord:W0,ZodMap:gw,ZodSet:Ad,ZodFunction:Ph,ZodLazy:Y0,ZodLiteral:G0,ZodEnum:eO,ZodNativeEnum:N0,ZodPromise:Hh,ZodEffects:js,ZodTransformer:js,ZodOptional:yl,ZodNullable:tO,ZodDefault:Z0,ZodCatch:I0,ZodNaN:$w,BRAND:X5e,ZodBranded:W7,ZodPipeline:Py,ZodReadonly:D0,custom:Wie,Schema:nn,ZodSchema:nn,late:R5e,get ZodFirstPartyTypeKind(){return Rt},coerce:dTe,any:W5e,array:Z5e,bigint:j5e,boolean:Nie,date:C5e,discriminatedUnion:M5e,effect:RU,enum:nTe,function:J5e,instanceof:E5e,intersection:L5e,lazy:eTe,literal:tTe,map:H5e,nan:q5e,nativeEnum:rTe,never:G5e,null:U5e,nullable:oTe,number:Gie,object:I5e,oboolean:OTe,onumber:uTe,optional:aTe,ostring:cTe,pipeline:lTe,preprocess:sTe,promise:iTe,record:B5e,set:K5e,strictObject:D5e,string:Yie,symbol:z5e,transformer:RU,tuple:F5e,undefined:A5e,union:V5e,unknown:Y5e,void:N5e,NEVER:fTe,ZodIssueCode:Ce,quotelessJson:o5e,ZodError:qa});const Ct=X.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),bv=X.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),wv=X.string().min(1).max(32768),Y7=/^[a-f0-9]{12}$/,Xt=X.string().regex(Y7),hTe=X.string().min(1).max(4096),NP=X.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),Sv=X.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),EU=X.string().regex(/^[a-f0-9]{32}$/),Zie=/^(\/|[A-Za-z]:[\\/])/,ZP=X.string().min(1).max(4096).regex(Zie),qU=/^[a-f0-9]{32}$/,Fn=X.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Af=X.string().regex(/^[A-Za-z0-9_-]{1,128}$/),jU=X.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),CU=X.object({data_b64:X.string().min(1).max(1e6),mime_type:X.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),nO=2e5,V0=8,pTe=256,mTe=100,XE=16,G7=256,Iie=100,Die=200,RE=1e6,Po=X.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),xv=X.object({kind:X.enum(["agent","team"]),name:Po}).strict(),IP=X.object({provider:X.string().min(1).max(128),model_id:X.string().min(1).max(512),reasoning_effort:X.string().min(1).max(64).nullable()}).strict(),zU=X.object({kind:X.enum(["role","specialist"]).optional(),description:X.string().max(8e3).optional(),instructions:X.string().max(8e3).optional(),tools:X.array(X.string().min(1).max(128)).max(256).optional(),effort:X.string().max(64).optional(),delegate:X.boolean().optional(),action_class:X.enum(["reactive","proactive"]).optional()}).strict(),AU=X.object({name:X.string().min(1).max(64).optional(),description:X.string().max(8e3).optional(),manager:Po.optional(),members:X.array(X.object({role:Po,count:X.number().int().min(1).max(16),kind:X.enum(["agent","team"])}).strict()).max(128).optional(),instructions:X.string().max(8e3).optional(),project:X.string().max(8e3).optional()}).strict(),gTe=X.record(X.array(X.string().max(1024)).max(100)),UU=X.enum(["minutes","hours","days"]);function $Te(e){return!/^\.+$/.test(e)}const hHt=e=>S1.safeParse(e).success,S1=X.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine($Te),WU=X.enum(["str","int","float","bool","list","dict"]),YU=X.string().max(16384),yTe=2e3,GU=X.string().min(1).max(yTe),NU=X.string().min(1).max(64),vTe=X.string().min(1).max(64),ZU=X.object({is_active:X.boolean().nullish(),one_time:X.boolean().nullish(),start_time_utc:X.string().max(64).nullish(),end_time_utc:X.string().max(64).nullish()}).strict(),bTe=X.object({conversation_length:X.number().int().optional(),detail_length:X.number().int().optional(),max_learnings_history:X.number().int().optional(),hosting:X.string().max(256).optional(),model_name:X.string().max(1024).optional(),auto_save_conversation:X.boolean().optional()}).strict(),EE=128,IU=2e3,DU=8e3,VU=64,MU=64,Lx=e=>[...e].length,qE=e=>e>=9&&e<=13||e>=28&&e<=32||e===133||e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288,wTe=e=>e===9||e===10||e===11||e===12||e===13||e===133,STe=e=>e<=31||e>=127&&e<=159,xTe=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),QTe=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,Qv=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},Vie=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&qE(t[n].codePointAt(0)??0);)n++;for(;r>n&&qE(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},kTe=e=>{let t="",n=!1;for(const r of e){if(qE(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function PTe(e){const t=Vie(e);if(!t)return"must not be empty";if(Lx(t)>EE)return`must be at most ${EE} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(Qv(t,QTe))return"must not contain Unicode bidirectional override characters";if(Qv(t,wTe))return"must not contain whitespace";if(Qv(t,STe))return"must not contain control characters";if(Qv(t,xTe))return"must not contain invisible Unicode formatting characters";const n=[...t];return"-.".includes(n[0])||"-.".includes(n[n.length-1])?'must not begin or end with "-" or "."':null}function pHt(e){return kTe(Vie(e).normalize("NFKC").toLowerCase())}function TTe(e){return e.trim()?Lx(e)>IU?`must be at most ${IU} characters`:null:"must not be empty"}function _Te(e){return e.trim()?Lx(e)>DU?`must be at most ${DU} characters`:null:"must not be empty"}function XTe(e){if(e.length>MU)return`must hold at most ${MU} items`;for(const t of e)if(!t.trim()||Lx(t)>VU)return`must hold items of 1 to ${VU} characters`;return null}const RTe=e=>PTe(e)===null,ETe=X.string().refine(RTe,{message:"That is not a name the hub can publish."}),qTe=X.string().refine(e=>_Te(e)===null,{message:"That instruction body cannot be published."}),jTe=X.string().refine(e=>TTe(e)===null,{message:"That description cannot be published."}),CTe=X.array(X.string()).refine(e=>XTe(e)===null,{message:"That tool list cannot be published."}),LU=X.object({name:ETe,description:jTe,instructions:qTe,kind:X.enum(["role","specialist"]),when_to_use:X.string(),tools:CTe,effort:X.string(),delegate:X.boolean(),version:X.string(),categories:X.array(X.string()),tags:X.array(X.string())}).partial().strict(),zTe=X.enum(["team","agent"]),ATe=X.string().min(1).max(64),UTe=X.string().min(1).max(256),Mie=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,DP=X.string().regex(Mie,{message:"Letters, digits, dot, underscore and dash; no spaces."}),WTe=["planning","active","qa","validation","done","paused","archived"],FU=X.enum(WTe),kv=X.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),BU=X.array(X.string().min(1).max(24)).max(8),fu=X.string().min(1).max(64),YTe=1e3,HU=240,KU=80,GTe=256,NTe=100,ZTe=200,ITe=/^[a-z0-9][a-z0-9_-]{0,23}$/;function mHt(e){return e?Mie.test(e)?null:"Names start with a letter or digit and may use letters, digits, dot, underscore or dash.":"Give the project a name."}function gHt(e){return ITe.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const Pv=X.enum(["agent","team"]),DTe=X.discriminatedUnion("op",[X.object({op:X.literal("capabilities")}).strict(),X.object({op:X.literal("runtimes.list")}).strict(),X.object({op:X.literal("profiles.list")}).strict(),X.object({op:X.literal("profiles.get"),name:Po}).strict(),X.object({op:X.literal("profiles.install"),name:Po,requestId:Fn}).strict(),X.object({op:X.literal("profiles.create"),name:Po,requestId:Fn,fields:zU.extend({description:X.string().max(8e3),instructions:X.string().min(1).max(8e3)})}).strict(),X.object({op:X.literal("profiles.update"),name:Po,requestId:Fn,fields:zU}).strict(),X.object({op:X.literal("hub.updates")}).strict(),X.object({op:X.literal("hub.check"),requestId:Fn,kind:Pv.optional(),name:Po.optional()}).strict(),X.object({op:X.literal("hub.apply"),requestId:Fn,kind:Pv,name:Po,prefer:X.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:X.boolean().optional(),dryRun:X.boolean().optional()}).strict(),X.object({op:X.literal("hub.applyAll"),requestId:Fn,kind:Pv.optional()}).strict(),X.object({op:X.literal("hub.retry"),requestId:Fn,kind:Pv,name:Po}).strict(),X.object({op:X.literal("teams.list")}).strict(),X.object({op:X.literal("teams.get"),name:Po}).strict(),X.object({op:X.literal("teams.create"),requestId:Fn,fields:AU.extend({name:X.string().min(1).max(64)})}).strict(),X.object({op:X.literal("teams.update"),name:Po,requestId:Fn,fields:AU}).strict(),X.object({op:X.literal("sessions.list"),limit:X.number().int().min(1).max(500).optional(),include_archived:X.boolean().optional(),include_peers:X.boolean().optional(),scope_kind:zTe.optional(),scope_name:ATe.optional(),cursor:UTe.optional(),with_counts:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.search"),q:X.string().min(1).max(pTe),limit:X.number().int().min(1).max(500).optional(),include_archived:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.archive"),sessionId:Xt,archived:X.boolean()}).strict(),X.object({op:X.literal("sessions.delete"),sessionId:Xt,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.create"),requestId:Fn,cwd:X.string().min(1).max(4096).optional(),target:xv.optional(),purpose:X.literal("agents-config").optional(),model:IP.optional(),draftId:Xt.optional(),peer:Af.optional()}).strict(),X.object({op:X.literal("sessions.preview"),requestId:Fn,cwd:X.string().min(1).max(4096),target:xv.optional(),model:IP.optional()}).strict(),X.object({op:X.literal("sessions.draft"),requestId:Fn,cwd:X.string().min(1).max(4096),target:xv.optional(),model:IP.optional()}).strict(),X.object({op:X.literal("sessions.get"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.history"),sessionId:Xt,beforeId:Ct.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.checkpoints"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.checkpoints.warm"),sessionId:Xt,ids:X.array(Ct).max(XE).optional(),limit:X.number().int().min(1).max(XE).optional()}).strict(),X.object({op:X.literal("sessions.find"),sessionId:Xt,q:X.string().min(1).max(G7),limit:X.number().int().min(1).max(Die).optional()}).strict(),X.object({op:X.literal("subagents.transcript"),sessionId:Xt,childId:Xt,beforeId:Ct.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.message"),sessionId:Xt,requestId:Fn,text:X.string().max(nO),images:X.array(CU).max(V0).optional(),mode:X.enum(["prompt","steer"]).optional(),inputMode:X.enum(["typed","dictated","mixed"]).optional(),inputPath:X.string().max(1024).optional()}).strict(),X.object({op:X.literal("sessions.command"),sessionId:Xt,requestId:Fn,command:X.string().regex(/^\/?[A-Za-z]+$/).max(64),args:X.string().max(nO).optional(),images:X.array(CU).max(V0).optional()}).strict(),X.object({op:X.literal("sessions.move"),sessionId:Xt,requestId:Fn,cwd:X.string().min(1).max(4096)}).strict(),X.object({op:X.literal("sessions.answer"),sessionId:Xt,epoch:Ct.optional(),requestId:Ct.optional(),value:X.string().max(32768).optional(),approved:X.boolean().optional(),questionIndex:X.number().int().min(0).optional(),askId:Ct.optional(),answers:X.record(X.string(),X.array(X.string().max(32768))).optional(),decline:X.boolean().optional(),revise:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.seen"),sessionId:Xt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("attention.seen"),items:X.array(X.object({sessionId:Xt,completionToken:X.string().uuid()}).strict()).min(1).max(500)}).strict(),X.object({op:X.literal("sessions.notified"),sessionId:Xt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("sessions.pin"),sessionId:Xt,pinned:X.boolean()}).strict(),X.object({op:X.literal("sessions.watch"),sessionId:Xt,subscriptionId:X.string().regex(qU),visible:X.boolean(),canNotify:X.boolean()}).strict(),X.object({op:X.literal("sessions.warm"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.interrupt"),sessionId:Xt,requestId:Fn}).strict(),X.object({op:X.literal("sessions.variables.list"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.variables.create"),sessionId:Xt,key:S1,value:YU,type:WU}).strict(),X.object({op:X.literal("sessions.variables.update"),sessionId:Xt,key:S1,value:YU,type:WU}).strict(),X.object({op:X.literal("sessions.variables.delete"),sessionId:Xt,key:S1}).strict(),X.object({op:X.literal("sessions.presence"),subscriptionId:X.string().regex(/^[a-f0-9]{1,64}$/),canNotify:X.boolean(),canNotifyKinds:X.array(X.enum(["complete","error"])).max(4),sessionId:X.string().regex(/^([a-f0-9]{12})?$/),window:X.object({exists:X.boolean(),focused:X.boolean(),visible:X.boolean(),minimized:X.boolean()}).strict()}).strict(),X.object({op:X.literal("legacy.models"),provider:X.string().max(128).optional(),sort:X.enum(["id","name","provider","recommended"]).optional(),direction:X.enum(["ascending","descending"]).optional()}).strict(),X.object({op:X.literal("legacy.models.providers")}).strict(),X.object({op:X.literal("auth.probe"),provider:Ct}).strict(),X.object({op:X.literal("legacy.agent.upload"),agentId:Ct}).strict(),X.object({op:X.literal("agent.publish"),agentId:Ct,document:LU.optional(),visibility:X.literal("org").optional(),tenantId:Ct.optional()}).strict(),X.object({op:X.literal("agent.republish"),agentId:Ct,hubAgentId:Ct,document:LU.optional(),visibility:X.literal("org").optional(),tenantId:Ct.optional()}).strict(),X.object({op:X.literal("team.pull"),teamId:Ct,tenantId:Ct.optional()}).strict(),X.object({op:X.literal("agent.nameAvailability"),name:X.string().min(1).max(EE)}).strict(),X.object({op:X.literal("legacy.agents.list"),page:X.number().int().min(1).optional(),perPage:X.number().int().min(1).max(500).optional(),name:X.string().max(256).optional(),sort:X.string().max(64).optional(),direction:X.enum(["asc","desc"]).optional()}).strict(),X.object({op:X.literal("legacy.agent.get"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.agent.history"),agentId:Ct,page:X.number().int().min(1).optional(),perPage:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("legacy.jobs.list"),agentId:Ct.optional(),status:X.string().max(64).optional()}).strict(),X.object({op:X.literal("legacy.job.get"),jobId:Ct}).strict(),X.object({op:X.literal("legacy.schedules.list"),page:X.number().int().min(1).optional(),perPage:X.number().int().min(1).max(100).optional()}).strict(),X.object({op:X.literal("legacy.agent.schedules.list"),agentId:Ct,page:X.number().int().min(1).optional(),perPage:X.number().int().min(1).max(100).optional()}).strict(),X.object({op:X.literal("legacy.agent.schedule.create"),agentId:Ct,schedule:ZU.extend({prompt:X.string().max(64e3),interval:X.number().int().min(1),unit:UU})}).strict(),X.object({op:X.literal("legacy.schedule.get"),scheduleId:Ct}).strict(),X.object({op:X.literal("legacy.schedule.edit"),scheduleId:Ct,schedule:ZU.extend({prompt:X.string().max(64e3).nullish(),interval:X.number().int().min(1).nullish(),unit:UU.nullish()})}).strict(),X.object({op:X.literal("legacy.schedule.remove"),scheduleId:Ct}).strict(),X.object({op:X.literal("legacy.agent.create"),agent:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.update"),agentId:Ct,update:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.delete"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.agent.conversation.clear"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.get"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.update"),agentId:Ct,systemPrompt:X.string().max(RE)}).strict(),X.object({op:X.literal("legacy.agent.download"),agentId:Ct}).strict(),X.object({op:X.literal("legacy.job.cancel"),jobId:Ct}).strict(),X.object({op:X.literal("commands.list")}).strict(),X.object({op:X.literal("commands.entities"),sessionId:Xt,command:Ct,name:X.string().max(128).optional()}).strict(),X.object({op:X.literal("models.catalogue"),live:X.boolean().optional()}).strict(),X.object({op:X.literal("usage.get"),provider:Ct.optional(),live:X.boolean().optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("analytics.get"),sessionId:Xt.optional(),sinceMs:X.number().int().nonnegative().optional(),untilMs:X.number().int().nonnegative().optional(),days:X.number().int().min(1).max(366).optional()}).strict(),X.object({op:X.literal("analytics.models"),sessionId:Xt.optional(),sinceMs:X.number().int().nonnegative().optional(),untilMs:X.number().int().nonnegative().optional(),days:X.number().int().min(1).max(366).optional()}).strict(),X.object({op:X.literal("info.get")}).strict(),X.object({op:X.literal("sessions.report"),sessionId:Xt,recentLimit:X.number().int().min(0).max(50).optional()}).strict(),X.object({op:X.literal("skills.list"),sessionId:Xt.optional(),cwd:hTe.optional(),name:Ct.optional()}).strict(),X.object({op:X.literal("sessions.failovers"),sessionId:Xt}).strict(),X.object({op:X.literal("sessions.credential"),sessionId:Xt,action:X.enum(["list","store","forget"]),key:bv.optional(),value:wv.optional(),confirmed:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.fork"),sessionId:Xt,requestId:Fn,message:X.string().max(2e5).optional(),boundary:X.enum(["next_safe","at_entry"]).optional(),entryId:X.string().max(128).optional()}).strict(),X.object({op:X.literal("sessions.stop"),requestId:Fn,targets:X.array(Xt).min(1).max(100),confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside"),sessionId:Xt,requestId:Fn,text:X.string().min(1).max(32768),asideId:Fn.optional(),subscriptionId:X.string().regex(qU).optional()}).strict(),X.object({op:X.literal("sessions.adopt"),sessionId:Xt,requestId:Fn,asideId:Fn,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside.get"),sessionId:Xt,asideId:Fn}).strict(),X.object({op:X.literal("sessions.aside.close"),sessionId:Xt,asideId:Fn}).strict(),X.object({op:X.literal("wakes.list"),limit:X.number().int().min(1).max(500).optional(),includeDormant:X.boolean().optional()}).strict(),X.object({op:X.literal("wakes.create"),requestId:Fn,sessionId:Xt.optional(),cwd:X.string().min(1).max(4096).optional(),target:xv.optional(),message:GU,in:X.string().min(1).max(64).optional(),at:X.string().min(1).max(64).optional(),every:X.string().min(1).max(64).optional(),until:X.string().min(1).max(64).optional(),limit:X.number().int().min(1).optional(),title:X.string().min(1).max(200).optional()}).strict(),X.object({op:X.literal("wakes.edit"),sessionId:Xt,wakeId:NU,message:GU.optional(),in:X.string().min(1).max(64).optional(),at:X.string().min(1).max(64).optional(),every:X.string().min(1).max(64).optional(),until:X.string().min(1).max(64).optional(),limit:X.number().int().min(1).optional()}).strict(),X.object({op:X.literal("wakes.remove"),sessionId:Xt,wakeId:NU}).strict(),X.object({op:X.literal("monitors.cancel"),sessionId:Xt,monitorId:vTe}).strict(),X.object({op:X.literal("mcp.list"),sessionId:Xt}).strict(),X.object({op:X.literal("mcp.credentials.store"),sessionId:Xt,name:X.string().min(1).max(256),values:X.record(X.string().min(1).max(128),X.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:X.array(X.string().min(1).max(128)).max(32)}).strict(),X.object({op:X.literal("mcp.control"),sessionId:Xt,control:X.object({action:X.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:NP.optional(),scope:X.enum(["global","project"]).optional(),command:X.string().min(1).max(4096).optional(),args:X.array(X.string().max(8192)).max(128).optional(),env:X.record(Sv).optional(),url:X.string().max(4096).optional(),headers:X.record(Sv).optional(),oauth:X.boolean().optional(),confirmed:X.boolean().optional(),operation_id:EU.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog"),cwd:ZP.optional(),sessionId:Xt.optional()}).strict(),X.object({op:X.literal("mcp.catalog.control"),cwd:ZP.optional(),control:X.object({action:X.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:NP.optional(),scope:X.enum(["global","project"]).optional(),command:X.string().min(1).max(4096).optional(),args:X.array(X.string().max(8192)).max(128).optional(),env:X.record(Sv).optional(),url:X.string().max(4096).optional(),headers:X.record(Sv).optional(),confirmed:X.boolean().optional(),operation_id:EU.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog.credentials"),header:X.string().min(1).max(128).optional(),cwd:ZP.optional(),name:NP,values:X.record(X.string().min(1).max(128),X.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:X.array(X.string().min(1).max(128)).max(32)}).strict(),X.object({op:X.literal("radient.request"),control:X.object({operation:X.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","agents.statuses","comments.list","comments.create","comments.update","comments.delete","account.agents","memberships.list","org_agents.list","org_team.get","org_teams.list"]),request_id:Fn.optional(),tenant_id:Ct.optional(),account_id:Ct.optional(),agent_id:Ct.optional(),comment_id:Ct.optional(),team_id:Ct.optional(),query:X.record(X.union([X.string().max(1024),X.number().int()])).optional(),payload:X.record(X.unknown()).optional(),confirmed:X.boolean().optional()}).strict()}).strict(),X.object({op:X.literal("providers.list")}).strict(),X.object({op:X.literal("accounts.list")}).strict(),X.object({op:X.literal("accounts.remove"),accountId:X.number().int().positive(),confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("auth.start"),provider:Ct}).strict(),X.object({op:X.literal("auth.status"),id:Ct}).strict(),X.object({op:X.literal("auth.input"),id:Ct,promptId:Ct,value:wv}).strict(),X.object({op:X.literal("auth.cancel"),id:Ct}).strict(),X.object({op:X.literal("auth.key"),provider:Ct,value:wv}).strict(),X.object({op:X.literal("auth.logout"),provider:Ct}).strict(),X.object({op:X.literal("settings.list")}).strict(),X.object({op:X.literal("settings.edit"),key:bv,value:X.unknown().refine(e=>e!==void 0,"A setting value is required."),base:gTe.optional()}).strict(),X.object({op:X.literal("settings.reset"),key:bv}).strict(),X.object({op:X.literal("tts.paths")}).strict(),X.object({op:X.literal("config.get")}).strict(),X.object({op:X.literal("config.update"),value:bTe}).strict(),X.object({op:X.literal("instructions.get")}).strict(),X.object({op:X.literal("instructions.update"),content:X.string().max(64e3)}).strict(),X.object({op:X.literal("credentials.list")}).strict(),X.object({op:X.literal("credentials.update"),key:bv,value:wv}).strict(),X.object({op:X.literal("peers.list")}).strict(),X.object({op:X.literal("networks.list")}).strict(),X.object({op:X.literal("networks.invite"),networkId:Af,role:X.enum(["read","drive","admin"]),deviceId:Af.optional()}).strict(),X.object({op:X.literal("networks.member.remove"),networkId:Af,deviceId:Af,confirm:X.string().min(1).max(256)}).strict(),X.object({op:X.literal("sessions.transfer"),sessionId:Xt,to:X.union([X.literal("local"),Af]),keep:X.boolean().optional(),waitS:X.number().min(0).max(300).optional(),requestId:Fn.optional()}).strict(),X.object({op:X.literal("approvals.list")}).strict(),X.object({op:X.literal("approvals.approve"),approvalId:jU}).strict(),X.object({op:X.literal("approvals.deny"),approvalId:jU}).strict(),X.object({op:X.literal("asks.list")}).strict(),X.object({op:X.literal("projects.list")}).strict(),X.object({op:X.literal("projects.get"),key:fu}).strict(),X.object({op:X.literal("projects.create"),name:DP,description:X.string().max(HU).optional(),status:FU.optional(),tags:BU.optional()}).strict(),X.object({op:X.literal("projects.update"),key:fu,fields:X.object({name:DP.optional(),title:X.string().max(80).optional(),owner:X.string().max(80).optional(),team:X.string().max(80).optional(),description:X.string().max(HU).optional(),status:FU.optional(),progress:X.string().max(YTe).optional(),tags:BU.optional(),start_date:kv.optional(),target_date:kv.optional(),completed_at:kv.optional(),estimate:X.number().positive().max(1e3).optional(),estimate_unit:X.enum(["points","days"]).optional()}).strict()}).strict(),X.object({op:X.literal("projects.delete"),key:fu,confirmed_name:DP}).strict(),X.object({op:X.literal("projects.link"),key:fu,sessionId:Xt}).strict(),X.object({op:X.literal("projects.unlink"),key:fu,sessionId:Xt}).strict(),X.object({op:X.literal("projects.milestone"),key:fu,name:X.string().min(1).max(KU),targetDate:kv.optional(),completed:X.boolean().optional()}).strict(),X.object({op:X.literal("projects.milestone.remove"),key:fu,name:X.string().min(1).max(KU)}).strict(),X.object({op:X.literal("projects.request_update"),key:fu}).strict(),X.object({op:X.literal("projects.search"),q:X.string().min(1).max(GTe),limit:X.number().int().min(1).max(ZTe).optional()}).strict(),X.object({op:X.literal("aida.status")}).strict(),X.object({op:X.literal("aida.control"),action:X.enum(["open","pause","resume","greet","status"])}).strict()]);DTe.superRefine((e,t)=>{if(e.op==="sessions.answer"){if(e.askId!==void 0){e.askId||t.addIssue({code:X.ZodIssueCode.custom,message:"ask_id must be a non-empty string",path:["askId"]}),e.decline!==!0&&!e.answers?t.addIssue({code:X.ZodIssueCode.custom,message:"A queued-ask answer needs answers or decline",path:["answers"]}):e.decline===!0&&e.answers!==void 0?t.addIssue({code:X.ZodIssueCode.custom,message:"Supply either answers or decline",path:["decline"]}):e.revise===!0&&e.decline===!0?t.addIssue({code:X.ZodIssueCode.custom,message:"Supply either decline or revise",path:["revise"]}):e.answers!==void 0&&Object.keys(e.answers).length===0&&t.addIssue({code:X.ZodIssueCode.custom,message:"answers must name at least one question",path:["answers"]});return}e.epoch||t.addIssue({code:X.ZodIssueCode.custom,message:"An epoch is required to answer a gate",path:["epoch"]}),e.requestId||t.addIssue({code:X.ZodIssueCode.custom,message:"A request id is required to answer a gate",path:["requestId"]}),e.revise===!0&&t.addIssue({code:X.ZodIssueCode.custom,message:"revise applies to a queued ask",path:["revise"]});return}if(e.op==="sessions.create"&&e.purpose===void 0){e.cwd===void 0&&t.addIssue({code:X.ZodIssueCode.custom,message:"A conversation needs a working directory: only a configuration run (`purpose`) may omit `cwd`.",path:["cwd"]});return}if(e.op==="sessions.create"&&e.purpose!==void 0){for(const n of["cwd","target","model","draftId"])e[n]!==void 0&&t.addIssue({code:X.ZodIssueCode.custom,message:`A configuration run resolves its own \`${n}\`: send \`purpose\` alone.`,path:[n]});return}e.op!=="agent.publish"&&e.op!=="agent.republish"||e.visibility==="org"!=!!e.tenantId&&t.addIssue({code:X.ZodIssueCode.custom,message:'A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.'})});const so={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},N7={runtimeUnreachable:"runtime_unreachable"},Kp="runtime_busy",Lie="runtime_retiring",Fx={[so.noCredential]:"This app is not paired with the running Local Operator server, so this control is unavailable.",[so.refused]:"This app's credential for the running Local Operator server was refused, so this control is unavailable.",[so.planeClosed]:"The running Local Operator server does not accept this app's desktop controls.",[so.transportFailed]:"The Local Operator server did not answer this request."},M0={noCredential:"Restart with a desktop-managed backend to use these controls.",transportFailed:"The backend could not complete this request. Check its connection and try again."};function L0(e){return e!==void 0&&Object.values(so).includes(e)}function VTe(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return so.refused;if(t===503)return so.planeClosed}}const MTe=88e4,LTe=11e5,FTe=2e4,BTe=9e4,HTe=new Set(["analytics.get","analytics.models","sessions.report"]),KTe=new Set(["usage.get"]),JTe=new Set(["networks.list","peers.list"]),e_e=new Set([...HTe,...KTe,...JTe]),t_e=90,n_e=30,r_e=300,i_e=10,Fie=15,a_e=1e4;function o_e(e){const n=e.to==="local"||e.keep?r_e:n_e,r=Math.max(0,e.waitS??0);return(t_e+n+i_e+Fie)*1e3+r*1e3}const s_e=18e4,l_e=s_e+15e3,c_e=120,Bie=(c_e+30+Fie)*1e3,u_e=6e4,O_e=5*Bie,d_e=new Set(["hub.apply","hub.retry","hub.check","hub.applyAll"]);function f_e(e){switch(e){case"hub.apply":case"hub.retry":return Bie;case"hub.check":return u_e;case"hub.applyAll":return O_e;default:return null}}function h_e(e){if(typeof e!="string"&&e.op==="sessions.transfer")return o_e(e)+a_e;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return l_e;const n=f_e(t);return n!==null?n:e_e.has(t)?BTe:FTe}const p_e=5e3;function Z7(e){return h_e(e)+p_e}const Bx="deadline_exceeded",Hie="foreground_required",Kie="View these completions in the foreground before marking them read.",m_e=new Set(["capabilities","accounts.list","analytics.get","analytics.models","approvals.list","commands.entities","commands.list","config.get","credentials.list","hub.updates","info.get","instructions.get","legacy.agent.get","legacy.agent.history","legacy.agent.schedules.list","legacy.agents.list","legacy.job.get","legacy.jobs.list","legacy.models","legacy.models.providers","legacy.schedule.get","legacy.schedules.list","mcp.catalog","mcp.list","models.catalogue","networks.list","peers.list","profiles.get","profiles.list","projects.search","providers.list","runtimes.list","sessions.aside.get","sessions.checkpoints","sessions.failovers","sessions.find","sessions.get","sessions.history","sessions.list","sessions.preview","sessions.report","sessions.search","sessions.variables.list","skills.list","subagents.transcript","teams.get","teams.list","usage.get"]),g_e=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function $_e(e,t){const n=Math.round(t/1e3),r=Bx;return e==="sessions.transfer"?{code:r,message:`The app waits up to ${n} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`}:e==="approvals.approve"?{code:r,message:`The app waits up to ${n} seconds for an approval, and the signing prompt was still open when it stopped waiting. The request was sent, so the decision may or may not have landed: read the approvals again — if the record still waits, answering it again is safe, because the store keeps the first decision and refuses a second.`}:d_e.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:m_e.has(e)?{code:r,message:g_e.has(e)?`The app waits up to ${n} seconds for this panel's data, and the read was still running when the app stopped waiting. Nothing was read; reopen the panel to ask again.`:`The app waits up to ${n} seconds for this read, and it was still running when the app stopped waiting. Nothing was read; ask again.`}:{code:r,message:`The app waits up to ${n} seconds for this request, and it was still running when the app stopped waiting. It may or may not have reached the server; check the result before repeating it.`}}const Hx=MTe,y_e=LTe;function v_e(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function JU(e){return{...e.in!==void 0?{in:e.in}:{},...e.at!==void 0?{at:e.at}:{},...e.every!==void 0?{every:e.every}:{},...e.until!==void 0?{until:e.until}:{},...e.limit!==void 0?{limit:e.limit}:{}}}function eW(e){if(e.visibility==="org"!=!!e.tenantId)throw new Error('A publication target needs both `visibility: "org"` and `tenantId`, or neither: one half would publish to the public hub.')}function Kx(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"runtimes.list":return{path:"/v1/desktop/runtimes?probe=false",method:"GET"};case"peers.list":return{path:"/v1/desktop/peers",method:"GET"};case"networks.list":return{path:"/v1/desktop/networks",method:"GET"};case"asks.list":return{path:"/v1/desktop/asks",method:"GET"};case"networks.invite":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/invite`,method:"POST",body:{role:e.role,device:e.deviceId??null}};case"networks.member.remove":return{path:`/v1/desktop/networks/${encodeURIComponent(e.networkId)}/members/${encodeURIComponent(e.deviceId)}`,method:"DELETE",body:{confirm:e.confirm}};case"sessions.transfer":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/transfer`,method:"POST",body:{to:e.to,keep:e.keep??!1,wait_s:e.waitS??0,...e.requestId?{request_id:e.requestId}:{}}};case"approvals.list":return{path:"/v1/desktop/approvals",method:"GET"};case"approvals.approve":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/approve`,method:"POST"};case"approvals.deny":return{path:`/v1/desktop/approvals/${encodeURIComponent(e.approvalId)}/deny`,method:"POST"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"hub.updates":return{path:"/v1/desktop/hub/updates",method:"GET"};case"hub.check":return{path:"/v1/desktop/hub/updates/check",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{},...e.name?{name:e.name}:{}}};case"hub.apply":return{path:"/v1/desktop/hub/updates/apply",method:"POST",body:{request_id:e.requestId,kind:e.kind,name:e.name,...e.prefer?{prefer:e.prefer}:{},...e.acknowledgeUnknownBaseline!==void 0?{acknowledge_unknown_baseline:e.acknowledgeUnknownBaseline}:{},...e.dryRun!==void 0?{dry_run:e.dryRun}:{}}};case"hub.applyAll":return{path:"/v1/desktop/hub/updates/apply-all",method:"POST",body:{request_id:e.requestId,...e.kind?{kind:e.kind}:{}}};case"hub.retry":return{path:"/v1/desktop/hub/updates/retry",method:"POST",body:{request_id:e.requestId,kind:e.kind,name:e.name}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"sessions.list":{const t=new URLSearchParams;return t.set("limit",String(e.limit??100)),e.include_archived&&t.set("include_archived","true"),e.scope_kind&&t.set("scope_kind",e.scope_kind),e.scope_name&&t.set("scope_name",e.scope_name),e.cursor&&t.set("cursor",e.cursor),e.with_counts&&t.set("with_counts","true"),e.include_peers&&t.set("include_peers","true"),{path:`/v1/desktop/sessions?${t}`,method:"GET"}}case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??mTe)});return e.include_archived&&t.set("include_archived","true"),{path:`/v1/desktop/sessions/search?${t}`,method:"GET"}}case"sessions.archive":return{path:`/v1/desktop/sessions/${e.sessionId}/archive`,method:"POST",body:{archived:e.archived}};case"sessions.delete":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"DELETE",body:{confirmed:!0}};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.peer?{peer:e.peer}:{},...e.target?{target:e.target}:{},...e.model?{model:e.model}:{},...e.draftId?{draft_id:e.draftId}:{},...e.purpose?{purpose:e.purpose}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.draft":return{path:"/v1/desktop/sessions/draft",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"GET"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"sessions.checkpoints":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints`,method:"GET"};case"sessions.checkpoints.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/checkpoints/warm`,method:"POST",body:{...e.ids?{ids:e.ids}:{},...e.limit!==void 0?{limit:e.limit}:{}}};case"sessions.find":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??Iie)});return{path:`/v1/desktop/sessions/${e.sessionId}/find?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],mode:e.mode??"prompt",...e.inputMode?{input_mode:e.inputMode}:{},...e.inputPath?{input_path:e.inputPath}:{}}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return e.askId!==void 0?{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{ask_id:e.askId,answers:e.answers,decline:e.decline,...e.revise===!0?{revise:!0}:{}}}:{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"attention.seen":return{path:"/v1/desktop/attention/seen",method:"POST",body:{items:e.items.map(t=>({session_id:t.sessionId,completion_token:t.completionToken}))}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"sessions.pin":return{path:`/v1/desktop/sessions/${e.sessionId}/pin`,method:"POST",body:{pinned:e.pinned}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"agent.publish":{eW(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"POST",body:{document:e.document??{}}}}case"agent.republish":{eW(e);const t=new URLSearchParams;e.visibility==="org"&&e.tenantId&&(t.set("visibility","org"),t.set("tenant_id",e.tenantId));const n=t.toString();return{path:`/v1/agents/${e.agentId}/publish${n?`?${n}`:""}`,method:"PUT",body:{hub_agent_id:e.hubAgentId,document:e.document??{}}}}case"team.pull":{const t=new URLSearchParams;e.tenantId&&t.set("tenant_id",e.tenantId);const n=t.toString();return{path:`/v1/teams/pull/${e.teamId}${n?`?${n}`:""}`,method:"GET"}}case"agent.nameAvailability":return{path:`/v1/agent-name-availability?${new URLSearchParams({name:e.name})}`,method:"GET"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"wakes.list":{const t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",String(e.limit)),e.includeDormant!==void 0&&t.set("include_dormant",String(e.includeDormant)),{path:t.size>0?`/v1/desktop/wakes?${t}`:"/v1/desktop/wakes",method:"GET"}}case"wakes.create":return{path:"/v1/desktop/wakes",method:"POST",body:{request_id:e.requestId,...v_e(e),message:e.message,...JU(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...JU(e)}};case"wakes.remove":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"DELETE"};case"monitors.cancel":return{path:`/v1/desktop/monitors/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(e.monitorId)}`,method:"DELETE"};case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":return{path:`/v1/desktop/models?live=${e.live??!1}`,method:"GET"};case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"analytics.models":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics/models?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":{const t=new URLSearchParams;e.sessionId&&t.set("session_id",e.sessionId),e.cwd&&t.set("cwd",e.cwd),e.name&&t.set("name",e.name);const n=t.toString();return{path:`/v1/desktop/skills${n?`?${n}`:""}`,method:"GET"}}case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary,entry_id:e.entryId}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId,subscription_id:e.subscriptionId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"mcp.catalog":{const t=new URLSearchParams;e.cwd&&t.set("cwd",e.cwd),e.sessionId&&t.set("session_id",e.sessionId);const n=t.toString();return{path:n?`/v1/desktop/mcp?${n}`:"/v1/desktop/mcp",method:"GET"}}case"mcp.catalog.control":return{path:"/v1/desktop/mcp",method:"POST",body:{...e.control,...e.cwd?{cwd:e.cwd}:{}}};case"mcp.catalog.credentials":return{path:"/v1/desktop/mcp/credentials",method:"POST",body:{name:e.name,values:e.values,...e.header?{header:e.header}:{},confirmed_replace:e.confirmedReplace,...e.cwd?{cwd:e.cwd}:{}}};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"tts.paths":return{path:"/v1/tts/paths",method:"GET"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}};case"projects.list":return{path:"/v1/desktop/projects",method:"GET"};case"projects.get":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"GET"};case"projects.create":return{path:"/v1/desktop/projects",method:"POST",body:{name:e.name,...e.description!==void 0?{description:e.description}:{},...e.status!==void 0?{status:e.status}:{},...e.tags!==void 0?{tags:e.tags}:{}}};case"projects.update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"PATCH",body:{...e.fields}};case"projects.delete":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}`,method:"DELETE",body:{confirm:e.confirmed_name}};case"projects.link":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links`,method:"POST",body:{session_id:e.sessionId}};case"projects.unlink":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/links/${encodeURIComponent(e.sessionId)}`,method:"DELETE"};case"projects.milestone":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones`,method:"POST",body:{name:e.name,...e.targetDate!==void 0?{target_date:e.targetDate}:{},...e.completed!==void 0?{completed:e.completed}:{}}};case"projects.milestone.remove":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/milestones/${encodeURIComponent(e.name)}`,method:"DELETE"};case"projects.request_update":return{path:`/v1/desktop/projects/${encodeURIComponent(e.key)}/request-update`,method:"POST"};case"projects.search":return{path:`/v1/desktop/projects/search?${new URLSearchParams({q:e.q,limit:String(e.limit??NTe)})}`,method:"GET"};case"aida.status":return{path:"/v1/desktop/aida",method:"GET"};case"aida.control":return{path:"/v1/desktop/aida",method:"POST",body:{op:e.action}}}}const Jie=64,$Ht=64*1024*1024,b_e="superseded_completion_token",w_e="store_busy",S_e="session_is_remote",x_e="owner_build_behind";function Q_e(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function ld(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function eae(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const tae=e=>typeof e?.goal_status=="string",nae=e=>(e?.goal??"").trim().length>0;function k_e(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const Hg={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."},tW={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},P_e={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},T_e={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},__e={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},X_e={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function nW(e){return e?e===Hg.notPaired?T_e:e===Hg.serverDown?P_e:e===Hg.frameBudget?X_e:tW:tW}async function rae(e){if(window.api?.desktop)try{return await R_e(window.api.desktop.request(e),e)}catch(n){throw n instanceof Nt?n:C_e(n)?new jc(Kie,Hie):new Nt(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new Nt(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Nt(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function R_e(e,t){const n=Z7(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=$_e(t.op,n);a(new Nt(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const iae="This server did not answer the request for its desktop controls.";class Nt extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,i,a,o){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=i,this.retryAfterMs=a,this.detail=o}}class jc extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function mo(e,t){return e instanceof Nt||e instanceof jc?L0(e.code)?Fx[e.code]:e.message:t}function E_e(e,t,n,r){return typeof r=="string"?r:n===M0.noCredential?so.noCredential:n===M0.transportFailed?so.transportFailed:VTe(Kx(e).path,t)}async function Xe(e){const t=await rae(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Nt(t.status,r??iae,void 0,E_e(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return n?.result}function aae(e){return e instanceof Nt&&e.code===Bx}function yHt(e){return e instanceof Nt?e.status===null||e.status===503:!1}function q_e(e){if(!(e instanceof Nt))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===x_e:e.code===S_e}function j_e(e){return e instanceof jc&&e.code===Hie}function C_e(e){return e instanceof Error&&e.message.includes(Kie)}async function Tn(e){const t=await rae(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function z_e(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Xe({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function A_e(e,t){const n=window.api?.desktop?.stream;if(n){const a=n.subscribe(e,t);return()=>a.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1");const i=new EventSource(`/__desktop/stream?${r}`);return i.onmessage=a=>{t({kind:"data",data:a.data})},i.onerror=()=>{i.readyState===EventSource.CLOSED&&(t({kind:"error",detail:Hg.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function Kh(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),i=r.headers.get("content-type")??"";if(!r.ok){let a="The media request failed.";if(i.includes("application/json"))try{const o=await r.json();typeof o.detail=="string"&&(a=o.detail)}catch{}return{status:r.status,kind:"error",detail:a,code:a===M0.noCredential?so.noCredential:void 0}}return i.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:i||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function F0(e){return e.kind==="error"?L0(e.code)?new jc(Fx[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const oae=/\s+/,U_e=/[\\/]+$/,W_e=/[\\/]/,sae=`
|
|
3
3
|
|
|
4
4
|
`,Y_e=" — cancel with wake(",G_e=120,N_e=/(?:\u001b[\]PX^_]|[\u009d\u0090\u0098\u009e\u009f])(?:(?!\u0007|\u001b\\|\u009c)[\s\S])*(?:\u0007|\u001b\\|\u009c|$)|(?:\u001b\[|\u009b)[0-?]*[ -/]*[@-~]|(?:\u001b\[|\u009b)[0-?]*[ -/]*$|\u001b[ -/]+[0-~]|\u001b[@-Z\\-_]|\u001b$|[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g,Z_e=new RegExp("\\p{Cf}","gu"),I_e=4096;function jE(e){return e==null?"":(typeof e=="string"?e:String(e)).replace(N_e,"").replace(Z_e,"").split(oae).filter(Boolean).join(" ").slice(0,G_e)}function lae(e){if(e.conversationName)return{name:e.conversationName,quoted:!0};const t=e.cwd.replace(U_e,"");if(t){const n=t.split(W_e).pop()??"";if(n)return{name:`${n}/`,quoted:!1}}return e.sessionId?{name:e.sessionId.slice(0,8),quoted:!1}:{name:"",quoted:!1}}function cae(e){const{name:t,quoted:n}=lae(e);return t?n?`"${t}"`:t:e.pid?`pid ${e.pid}`:"another session"}function uae(e){const{name:t,quoted:n}=lae(e),r=[];return e.pid&&r.push(`pid ${e.pid}`),e.modelLabel&&r.push(e.modelLabel),t?[n?`"${t}"`:t,...r].join(" · "):r.length>0?r.join(" · "):"another session"}function D_e(e,t){return t.trim()?!0:uae(e)!==cae(e)}function V_e(e){for(const t of e.slice(0,I_e).split(`
|
|
5
5
|
`)){const n=jE(t);if(n)return n}return""}function rW(e,t){const n=cae(e),r=V_e(t);return r?`${n} · ${r}`:n}function M_e(e,t){return e.pid===t.pid&&e.conversationName===t.conversationName&&e.cwd===t.cwd&&e.sessionId===t.sessionId&&e.modelLabel===t.modelLabel}const L_e=/^<peer-session-message\s+((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/peer-session-message>\s*$/,F_e=/<\/?peer-session-message(?:[^>"']|"[^"]*"|'[^']*')*>/g,B_e=/^<peer-session-message[^>]*>/,H_e=/([a-zA-Z_]+)\s*=\s*(?:'([^']*)'|"([^"]*)"|([^\s>]+))/g;function K_e(e){const t=String(e.text??e.detail??""),n=L_e.exec(t.trim()),r={};if(n)for(const c of n[1].matchAll(H_e))r[c[1]]=c[2]??c[3]??c[4]??"";const i=n?n[2]:"",o=(String(e.body??"").trim()||i||(n?"":t.trim().replace(B_e,""))).replace(F_e,"").trim(),s=e.sender??{},l=(c,u)=>jE(c)||jE(u);return{body:o,sender:{pid:l(s.pid,r.from_pid),conversationName:l(s.conversation_name,r.conversation),cwd:l(s.cwd,void 0),sessionId:l(s.session_id,void 0),modelLabel:l(s.model_label,r.model)}}}function J_e(e){return!!e.wake_catchup}function e2e(e){let t=e.split(sae)[0]??"";t=t.split(oae).filter(Boolean).join(" "),t=t.split(Y_e)[0];const n="(alarm) ";for(;t.startsWith(n);)t=t.slice(n.length);const r="Scheduled wake ";return t.startsWith(r)&&(t=t.slice(r.length)),t.trim()}function t2e(e){const t=e.indexOf(sae);return t===-1?"":e.slice(t+2).trim()}const n2e=new Set(["command","path","file_path","url","pattern","query","name","target","message","milestone"]),r2e=new Set(["true","yes","y","t","on","1"]),i2e={hub:{steps:e=>{const t=Th(e);return t!==null&&Number.isInteger(t)&&t>=0?`${t} ${t===1?"step":"steps"}`:""}},wait:{wait_ms:e=>{const t=Th(e);return t!==null&&t>0?`· ${uf(t/1e3)}`:""}}};function Th(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}const iW="mcp__",a2e=/^\/(?:Users|home)\/[^/]+\//,o2e=/\s+/;function Oae(e){return!e.startsWith("/")||e.includes(" ")?e:e.replace(a2e,"~/")}function lo(e){return typeof e=="string"?Oae(e.trim()).replace(/\n/g," ").trim():typeof e=="number"||typeof e=="boolean"?String(e):""}function s2e(e){return e.now?"now":e.wake===!1?"quiet":"wake"}function l2e(e){const t=e.pid;if(typeof t=="number"&&Number.isFinite(t))return`pid ${t}`;const n=String(e.session??"").trim();return n?`session ${n}`:String(e.target??"").split(o2e).filter(Boolean).join(" ")||"?"}function c2e(e){return[s2e(e),lo(l2e(e))||"?",lo(e.message)].filter(Boolean).join(" · ")}const u2e=new Set(["delivered","mailbox","unconfirmed","failed"]);function O2e(e){if(!e||typeof e!="object")return null;const t=e.delivery;if(!t||typeof t!="object")return null;const n=t.state;return typeof n=="string"&&u2e.has(n)?n:null}function dae(e,t){return!e||typeof e!="object"?t??null:O2e(e)}const d2e={mailbox:"wake unconfirmed",unconfirmed:"delivery unconfirmed",failed:"not delivered"},f2e={mailbox:"In their mailbox. The wake got no answer, so they will read it on their next turn.",unconfirmed:"No wake answer and not yet in their transcript — it may still arrive. Check before resending."},h2e={mailbox:"Delivered to their mailbox. The wake got no answer, so they will read the message on their next turn. Do not send it again.",unconfirmed:"Not confirmed: there was no answer and the message is not in their transcript. It may still arrive, so check before resending.",failed:"Nothing was delivered. Fix the cause named below, or retry the send."},p2e={mailbox:"delivered, wake unconfirmed",unconfirmed:"delivery unconfirmed — it may still arrive, so check before resending"};function I7(e){return e==="mailbox"||e==="unconfirmed"}function m2e(e){return I7(e)?"partial":null}function g2e(e){return e==="failed"?"Attempted":null}function CE(e,t){return e!==!0?!1:!I7(t)}function aW(e){const t=Th(e.pid);return t!==null&&Number.isInteger(t)?`pid ${t}`:lo(e.session)||lo(e.target)||"?"}function $2e(e){const t=lo(e.query);if(t){const o=Th(e.steps);return o!==null&&Number.isInteger(o)&&o>=0?`search ${t} · ${o} around`:`search ${t}`}const n=Th(e.steps);if(n!==null&&Number.isInteger(n)&&n>=0)return`last ${n}`;const r=Th(e.head);if(r!==null&&Number.isInteger(r)&&r>=0)return`first ${r}`;if(e.digest===!0)return"digest";const i=lo(e.before_id);if(i)return`before ${i}`;const a=lo(e.around_id);return a?`around ${a}`:""}function y2e(e){const t=D7(e);if(t==="spawn"){const n=lo(e.visibility)||"workstream",r=lo(e.name)||lo(e.prompt);return[n,r].filter(Boolean).join(" · ")}if(t==="stop"||t==="resume"||t==="info")return aW(e);if(t==="peek")return[aW(e),$2e(e)].filter(Boolean).join(" · ");if(t==="list"){const n=[];e.include_stored===!0&&n.push("stored");const r=lo(e.query);return r&&n.push(r),n.join(" · ")}return null}function v2e(e,t){const n=e.trim();if(!t)return n;if(n==="send")return c2e(t)||n;if(n.toLowerCase()==="sessions"){const a=y2e(t);if(a!==null)return a||n}const r=Q2e(n)?Object.entries(t).filter(([a])=>!pae.has(a)):Object.entries(t);let i=r.filter(([a])=>n2e.has(a)).map(([,a])=>lo(a)).filter(Boolean);if(i.length===0){const a=i2e[n.toLowerCase()];i=r.map(([o,s])=>a?.[o]?.(s)||lo(s)).filter(Boolean)}return i.slice(0,2).join(" ")||n}function Ud(e){const t=e.trim();if(!t.toLowerCase().startsWith(iW))return t;const n=t.slice(iW.length),r=n.indexOf("_");return r<=0?n||t:n.slice(r+1)||n}function fae(e,t){return e===t||e===Ud(t)}const b2e=/^(?:exit code:?\s*-?\d*|\(empty\)|--- (?:stdout|stderr) ---)$/,w2e="… ";function S2e(e,t=!1){if(!e||t)return null;for(const n of e.split(`
|
|
@@ -784,7 +784,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
784
784
|
`))};if(c.from==this.from&&a<this.from?c.from=a:c.to==this.to&&a>this.to&&(c.to=a),c.from==c.to&&!c.insert.length){let u=Ye.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((at.mac||at.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:Zn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);Iz(t,c,Ye.single(this.toEditorPos(r.selectionStart,u),this.toEditorPos(r.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=r=>{let i=[],a=null;for(let o=this.toEditorPos(r.rangeStart),s=this.toEditorPos(r.rangeEnd);o<s;o++){let l=t.coordsForChar(o);a=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||a||new DOMRect,i.push(a)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let a of r.getTextFormats()){let o=a.underlineStyle,s=a.underlineThickness;if(o!="None"&&s!="None"){let l=this.toEditorPos(a.rangeStart),c=this.toEditorPos(a.rangeEnd);if(l<c){let u=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${s=="Thin"?1:2}px`;i.push(ln.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:Nde.of(ln.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(t.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let i=g$(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,r=!1,i=this.pendingContextChange;return t.changes.iterChanges((a,o,s,l,c)=>{if(r)return;let u=c.length-(o-a);if(i&&o>=i.to)if(i.from==a&&i.to==o&&i.insert.eq(c)){i=this.pendingContextChange=null,n+=u,this.to+=u;return}else i=null,this.revertPending(t.state);if(a+=n,o+=n,o<=this.from)this.from+=u,this.to+=u;else if(a<this.to){if(a<this.from||o>this.to||this.to-this.from+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(o),c.toString()),this.to+=u}n+=u}),i&&!r&&this.revertPending(t.state),!r}update(t){let n=this.pendingContextChange,r=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(r.from,r.to)&&t.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to<t.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let r=this.composing;return r&&r.drifted?r.editorBase+(t-r.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class vt{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(i=>i.forEach(a=>r(a,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||gFe(t.parent)||document,this.viewState=new DZ(t.state||Cn.create(t)),t.scrollTo&&t.scrollTo.is(nb)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(mh).map(i=>new mT(i));for(let i of this.plugins)i.update(this);this.observer=new CBe(this),this.inputState=new iBe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new kZ(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let n=t.length==1&&t[0]instanceof _i?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,a=this.state;for(let d of t){if(d.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=d.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,l=null;t.some(d=>d.annotation(tfe))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=nfe(a,o),l||(s=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(Cn.phrases)!=this.state.facet(Cn.phrases))return this.setState(a);i=Mw.create(this,a,t),i.flags|=s;let O=this.viewState.scrollTarget;try{this.updateState=2;for(let d of t){if(O&&(O=O.map(d.changes)),d.scrollIntoView){let{main:f}=d.state.selection;O=new Ah(f.empty?f:Ye.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of d.effects)f.is(nb)&&(O=f.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=Fw.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Ag)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(lb)!=i.state.facet(lb)&&(this.viewState.mustMeasureContent=!0),(n||r||O||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(wq))try{d(i)}catch(f){Xa(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Fde(this,u)&&c.force&&zh(this.contentDOM,c.key,c.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new DZ(t),this.plugins=t.facet(mh).map(r=>new mT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new kZ(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(mh),r=t.state.facet(mh);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new mT(a));else{let s=this.plugins[o];s.mustUpdate=t,i.push(s)}}for(let a of this.plugins)a.mustUpdate!=t&&a.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=t;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let n=t.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){Xa(this.state,r,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:a,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let s=0;;s++){if(o<0)if(mde(r))a=-1,o=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(i);a=f.from,o=f.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(s>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(f=>{try{return f.read(this)}catch(p){return Xa(this.state,p),FZ}}),O=Mw.create(this,this.state,[]),d=!1;O.flags|=l,n?n.flags|=l:n=O,this.updateState=2,O.empty||(this.updatePlugins(O),this.inputState.update(O),this.updateAttrs(),d=this.docView.update(O),d&&this.docViewUpdate());for(let f=0;f<c.length;f++)if(u[f]!=FZ)try{let p=c[f];p.write&&p.write(u[f],this)}catch(p){Xa(this.state,p)}if(d&&this.docView.updateSelection(!0),!O.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(a<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(a).top)-o;if(p>1||p<-1){i=i+p,r.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let s of this.state.facet(wq))s(n)}get themeClasses(){return Pq+" "+(this.state.facet(kq)?ofe:afe)+" "+this.state.facet(lb)}updateAttrs(){let t=BZ(this,Zde,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(mc)?"true":"false",class:"cm-content",style:`${at.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),BZ(this,Gz,n);let r=this.observer.ignore(()=>{let i=gq(this.contentDOM,this.contentAttrs,n),a=gq(this.dom,this.editorAttrs,t);return i||a});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(vt.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Ag);let t=this.state.facet(vt.cspNonce);lO.mount(this.root,this.styleModules.concat(qBe).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===t.key){this.measureRequests[n]=t;return}}this.measureRequests.push(t)}}plugin(t){let n=this.pluginMap.get(t);return(n===void 0||n&&n.plugin!=t)&&this.pluginMap.set(t,n=this.plugins.find(r=>r.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,r){return $T(this,t,RZ(this,t,n,r))}moveByGroup(t,n){return $T(this,t,RZ(this,t,n,r=>FFe(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),a=r[n?r.length-1:0];return Ye.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return LFe(this,t,n,r)}moveVertically(t,n,r){return $T(this,t,BFe(this,t,n,r))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){return this.readMeasured(),Lde(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.docView.coordsAt(t,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(t),a=this.bidiSpans(i),o=a[Gu.find(a,t-i.from,-1,n)];return Uy(r,o.dir==gr.LTR==n>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Wde)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>UBe)return Rde(t.length);let n=this.textDirectionAt(t.from),r;for(let a of this.bidiCache)if(a.from==t.from&&a.dir==n&&(a.fresh||Xde(a.isolates,r=QZ(this,t))))return a.order;r||(r=QZ(this,t));let i=EFe(t.text,n,r);return this.bidiCache.push(new Fw(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||at.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{hde(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){return nb.of(new Ah(typeof t=="number"?Ye.cursor(t):t,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return nb.of(new Ah(Ye.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return oi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return oi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=lO.newName(),i=[lb.of(r),Ag.of(Tq(`.${r}`,t))];return n&&n.dark&&i.push(kq.of(!0)),i}static baseTheme(t){return bO.lowest(Ag.of(Tq("."+Pq,t,sfe)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&Jn.get(r)||Jn.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}vt.styleModule=Ag;vt.inputHandler=Ade;vt.clipboardInputFilter=Wz;vt.clipboardOutputFilter=Yz;vt.scrollHandler=Gde;vt.focusChangeEffect=Ude;vt.perLineTextDirection=Wde;vt.exceptionSink=zde;vt.updateListener=wq;vt.editable=mc;vt.mouseSelectionStyle=Cde;vt.dragMovesSelection=jde;vt.clickAddsSelectionRange=qde;vt.decorations=$$;vt.outerDecorations=Ide;vt.atomicRanges=Nz;vt.bidiIsolatedRanges=Dde;vt.scrollMargins=Vde;vt.darkTheme=kq;vt.cspNonce=Ot.define({combine:e=>e.length?e[0]:""});vt.contentAttributes=Gz;vt.editorAttributes=Zde;vt.lineWrapping=vt.contentAttributes.of({class:"cm-lineWrapping"});vt.announce=xn.define();const UBe=4096,FZ={};class Fw{constructor(t,n,r,i,a,o){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=a,this.order=o}static update(t,n){if(n.empty&&!t.some(a=>a.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:gr.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new Fw(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function BZ(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let a=r[i],o=typeof a=="function"?a(e):a;o&&mq(o,n)}return n}const WBe=at.mac?"mac":at.windows?"win":at.linux?"linux":"key";function YBe(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,a,o,s;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))a=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))t=="mac"?s=!0:a=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),a&&(r="Ctrl-"+r),s&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function cb(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}const GBe=bO.default(vt.domEventHandlers({keydown(e,t){return cfe(lfe(t.state),e,t,"editor")}})),CQ=Ot.define({enables:GBe}),HZ=new WeakMap;function lfe(e){let t=e.facet(CQ),n=HZ.get(t);return n||HZ.set(t,n=ZBe(t.reduce((r,i)=>r.concat(i),[]))),n}function UJt(e,t,n){return cfe(lfe(e.state),t,e,n)}let ju=null;const NBe=4e3;function ZBe(e,t=WBe){let n=Object.create(null),r=Object.create(null),i=(o,s)=>{let l=r[o];if(l==null)r[o]=s;else if(l!=s)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},a=(o,s,l,c,u)=>{var O,d;let f=n[o]||(n[o]=Object.create(null)),p=s.split(/ (?!$)/).map($=>YBe($,t));for(let $=1;$<p.length;$++){let v=p.slice(0,$).join(" ");i(v,!0),f[v]||(f[v]={preventDefault:!0,stopPropagation:!1,run:[w=>{let x=ju={view:w,prefix:v,scope:o};return setTimeout(()=>{ju==x&&(ju=null)},NBe),!0}]})}let m=p.join(" ");i(m,!1);let g=f[m]||(f[m]={preventDefault:!1,stopPropagation:!1,run:((d=(O=f._any)===null||O===void 0?void 0:O.run)===null||d===void 0?void 0:d.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let o of e){let s=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of s){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:O}=o;for(let d in u)u[d].run.push(f=>O(f,_q))}let l=o[t]||o.key;if(l)for(let c of s)a(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&a(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}let _q=null;function cfe(e,t,n,r){_q=t;let i=dFe(t),a=no(i,0),o=pc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;ju&&ju.view==n&&ju.scope==r&&(s=ju.prefix+" ",Hde.indexOf(t.keyCode)<0&&(c=!0,ju=null));let O=new Set,d=g=>{if(g){for(let $ of g.run)if(!O.has($)&&(O.add($),$(n)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[s+cb(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(at.windows&&t.ctrlKey&&t.altKey)&&(p=cO[t.keyCode])&&p!=i?(d(f[s+cb(p,t,!0)])||t.shiftKey&&(m=m$[t.keyCode])!=i&&m!=p&&d(f[s+cb(m,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(f[s+cb(i,t,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),_q=null,l}class Gy{constructor(t,n,r,i,a){this.className=t,this.left=n,this.top=r,this.width=i,this.height=a}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=ufe(t);return[new Gy(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return IBe(t,n,r)}}function ufe(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==gr.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function KZ(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),l=e.posAtCoords({x:a.right-1,y:o});return s==null||l==null?r:{from:Math.max(r.from,Math.min(s,l)),to:Math.min(r.to,Math.max(s,l))}}function IBe(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==gr.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=ufe(e),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),O=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=s.right-(u?parseInt(u.paddingRight):0),f=xq(e,r,1),p=xq(e,i,-1),m=f.type==ha.Text?f:null,g=p.type==ha.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=KZ(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=KZ(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(w(n.from,n.to,m));{let b=m?w(n.from,null,m):x(f,!1),S=g?w(null,n.to,g):x(p,!0),Q=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&b.bottom+e.defaultLineHeight/2<S.top?Q.push($(O,b.bottom,d,S.top)):b.bottom<S.top&&e.elementAtHeight((b.bottom+S.top)/2).type==ha.Text&&(b.bottom=S.top=(b.bottom+S.top)/2),v(b).concat(Q).concat(v(S))}function $(b,S,Q,P){return new Gy(t,b-l.left,S-l.top,Q-b,P-S)}function v({top:b,bottom:S,horizontal:Q}){let P=[];for(let R=0;R<Q.length;R+=2)P.push($(Q[R],b,Q[R+1],S));return P}function w(b,S,Q){let P=1e9,R=-1e9,_=[];function E(U,Y,V,M,B){let G=e.coordsAtPos(U,U==Q.to?-2:2),A=e.coordsAtPos(V,V==Q.from?2:-2);!G||!A||(P=Math.min(G.top,A.top,P),R=Math.max(G.bottom,A.bottom,R),B==gr.LTR?_.push(a&&Y?O:G.left,a&&M?d:A.right):_.push(!a&&M?O:A.left,!a&&Y?d:G.right))}let C=b??Q.from,W=S??Q.to;for(let U of e.visibleRanges)if(U.to>C&&U.from<W)for(let Y=Math.max(U.from,C),V=Math.min(U.to,W);;){let M=e.state.doc.lineAt(Y);for(let B of e.bidiSpans(M)){let G=B.from+M.from,A=B.to+M.from;if(G>=V)break;A>Y&&E(Math.max(G,Y),b==null&&G<=C,Math.min(A,V),S==null&&A>=W,B.dir)}if(Y=M.to+1,Y>=V)break}return _.length==0&&E(C,b==null,W,S==null,e.textDirection),{top:P,bottom:R,horizontal:_}}function x(b,S){let Q=s.top+(S?b.top:b.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function DBe(e,t){return e.constructor==t.constructor&&e.eq(t)}class VBe{constructor(t,n){this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)}update(t){t.startState.facet(W1)!=t.state.facet(W1)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let n=0,r=t.facet(W1);for(;n<r.length&&r[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:n}=this.view;(t!=this.scaleX||n!=this.scaleY)&&(this.scaleX=t,this.scaleY=n,this.dom.style.transform=`scale(${1/t}, ${1/n})`)}draw(t){if(t.length!=this.drawn.length||t.some((n,r)=>!DBe(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let i of t)i.update&&n&&i.constructor&&this.drawn[r].constructor&&i.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(i.draw(),n);for(;n;){let i=n.nextSibling;n.remove(),n=i}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const W1=Ot.define();function Ofe(e){return[oi.define(t=>new VBe(t,e)),W1.of(e)]}const y$=Ot.define({combine(e){return lm(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function WJt(e={}){return[y$.of(e),MBe,LBe,FBe,Yde.of(!0)]}function dfe(e){return e.startState.facet(y$)!=e.state.facet(y$)}const MBe=Ofe({above:!0,markers(e){let{state:t}=e,n=t.facet(y$),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor){let o=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",s=i.empty?i:Ye.cursor(i.head,i.head>i.anchor?-1:1);for(let l of Gy.forRange(e,o,s))r.push(l)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=dfe(e);return n&&JZ(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){JZ(t.state,e)},class:"cm-cursorLayer"});function JZ(e,t){t.style.animationDuration=e.facet(y$).cursorBlinkRate+"ms"}const LBe=Ofe({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:Gy.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||dfe(e)},class:"cm-selectionLayer"}),FBe=bO.highest(vt.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),ffe=xn.define({map(e,t){return e==null?null:t.mapPos(e)}}),Yg=Aa.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(ffe)?r.value:n,e)}}),BBe=oi.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(Yg);n==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(Yg)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Yg),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(Yg)!=e&&this.view.dispatch({effects:ffe.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function YJt(){return[Yg,BBe]}function eI(e,t,n,r,i){t.lastIndex=0;for(let a=e.iterRange(n,r),o=n,s;!a.next().done;o+=a.value.length)if(!a.lineBreak)for(;s=t.exec(a.value);)i(o+s.index,s)}function HBe(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:a}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),a=Math.min(e.state.doc.lineAt(a).to,a+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=a:r.push({from:i,to:a});return r}class KBe{constructor(t){const{regexp:n,decoration:r,decorate:i,boundary:a,maxLength:o=1e3}=t;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=(s,l,c,u)=>i(u,c,c+s[0].length,s,l);else if(typeof r=="function")this.addMatch=(s,l,c,u)=>{let O=r(s,l,c);O&&u(c,c+s[0].length,O)};else if(r)this.addMatch=(s,l,c,u)=>u(c,c+s[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=a,this.maxLength=o}createDeco(t){let n=new Id,r=n.add.bind(n);for(let{from:i,to:a}of HBe(t,this.maxLength))eI(t.state.doc,this.regexp,i,a,(o,s)=>this.addMatch(s,t,o,r));return n.finish()}updateDeco(t,n){let r=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((a,o,s,l)=>{l>=t.view.viewport.from&&s<=t.view.viewport.to&&(r=Math.min(s,r),i=Math.max(l,i))}),t.viewportMoved||i-r>1e3?this.createDeco(t.view):i>-1?this.updateRange(t.view,n.map(t.changes),r,i):n}updateRange(t,n,r,i){for(let a of t.visibleRanges){let o=Math.max(a.from,r),s=Math.min(a.to,i);if(s>=o){let l=t.state.doc.lineAt(o),c=l.to<s?t.state.doc.lineAt(s):l,u=Math.max(a.from,l.from),O=Math.min(a.to,c.to);if(this.boundary){for(;o>l.from;o--)if(this.boundary.test(l.text[o-1-l.from])){u=o;break}for(;s<c.to;s++)if(this.boundary.test(c.text[s-c.from])){O=s;break}}let d=[],f,p=(m,g,$)=>d.push($.range(m,g));if(l==c)for(this.regexp.lastIndex=u-l.from;(f=this.regexp.exec(l.text))&&f.index<O-l.from;)this.addMatch(f,t,f.index+l.from,p);else eI(t.state.doc,this.regexp,u,O,(m,g)=>this.addMatch(g,t,m,p));n=n.update({filterFrom:u,filterTo:O,filter:(m,g)=>m<u||g>O,add:d})}}return n}}const Xq=/x/.unicode!=null?"gu":"g",JBe=new RegExp(`[\0-\b
|
|
785
785
|
--\u2028\u2029\uFEFF-]`,Xq),eHe={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let bT=null;function tHe(){var e;if(bT==null&&typeof document<"u"&&document.body){let t=document.body.style;bT=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return bT||!1}const Y1=Ot.define({combine(e){let t=lm(e,{render:null,specialChars:JBe,addSpecialChars:null});return(t.replaceTabs=!tHe())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,Xq)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Xq)),t}});function GJt(e={}){return[Y1.of(e),nHe()]}let tI=null;function nHe(){return tI||(tI=oi.fromClass(class{constructor(e){this.view=e,this.decorations=ln.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Y1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new KBe({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=no(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=sO(o.text,s,r-o.from);return ln.replace({widget:new oHe((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=ln.replace({widget:new aHe(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Y1);e.startState.facet(Y1)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const rHe="•";function iHe(e){return e>=32?rHe:e==10?"":String.fromCharCode(9216+e)}class aHe extends eu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=iHe(this.code),r=t.state.phrase("Control character")+" "+(eHe[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let a=document.createElement("span");return a.textContent=n,a.title=r,a.setAttribute("aria-label",r),a.className="cm-specialChar",a}ignoreEvent(){return!1}}class oHe extends eu{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function NJt(){return lHe}const sHe=ln.line({class:"cm-activeLine"}),lHe=oi.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(sHe.range(i.from)),t=i.from)}return ln.set(n)}},{decorations:e=>e.decorations});class cHe extends eu{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?ap(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=Uy(n[0],r.direction!="rtl"),a=parseInt(r.lineHeight);return i.bottom-i.top>a*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+a}:i}ignoreEvent(){return!1}}function ZJt(e){let t=oi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?ln.set([ln.widget({widget:new cHe(e),side:1}).range(0)]):ln.none}get decorations(){return this.view.state.doc.length?ln.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,vt.contentAttributes.of({"aria-placeholder":e})]:t}const Rq=2e3;function uHe(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>Rq||n.off>Rq||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=s&&a.push(Ye.range(c.from+o,c.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=cq(c.text,o,e.tabSize,!0);if(u<0)a.push(Ye.cursor(c.to));else{let O=cq(c.text,s,e.tabSize);a.push(Ye.range(c.from+u,c.from+O))}}}return a}function OHe(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function nI(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>Rq?-1:i==r.length?OHe(e,t.clientX):sO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function dHe(e,t){let n=nI(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let a=i.changes.mapPos(i.startState.doc.line(n.line).from),o=i.state.doc.lineAt(a);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},r=r.map(i.changes)}},get(i,a,o){let s=nI(e,i);if(!s)return r;let l=uHe(e.state,n,s);return l.length?o?Ye.create(l.concat(r.ranges)):Ye.create(l):r}}:null}function IJt(e){let t=n=>n.altKey&&n.button==0;return vt.mouseSelectionStyle.of((n,r)=>t(r)?dHe(n,r):null)}const fHe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},hHe={style:"cursor: crosshair"};function DJt(e={}){let[t,n]=fHe[e.key||"Alt"],r=oi.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,vt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?hHe:null})]}const Bm="-10000px";class hfe{constructor(t,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(o=>o);let a=null;this.tooltipViews=this.tooltips.map(o=>a=r(o,a))}update(t,n){var r;let i=t.state.facet(this.facet),a=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(t);return!1}let o=[],s=n?[]:null;for(let l=0;l<a.length;l++){let c=a[l],u=-1;if(c){for(let O=0;O<this.tooltips.length;O++){let d=this.tooltips[O];d&&d.create==c.create&&(u=O)}if(u<0)o[l]=this.createTooltipView(c,l?o[l-1]:null),s&&(s[l]=!!c.above);else{let O=o[l]=this.tooltipViews[u];s&&(s[l]=n[u]),O.update&&O.update(t)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(s.forEach((l,c)=>n[c]=l),n.length=s.length),this.input=i,this.tooltips=a,this.tooltipViews=o,!0}}function pHe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const wT=Ot.define({combine:e=>{var t,n,r;return{position:at.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||pHe}}}),rI=new WeakMap,Mz=oi.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(wT);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new hfe(e,Lz,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(wT);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=Bm,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(at.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==Bm&&a.style.left=="0px"){let o=a.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(n||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(e=a.width/this.parent.offsetWidth,t=a.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Zz(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,o)=>{let s=this.manager.tooltipViews[o];return s.getCoords?s.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(wT).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let s of this.manager.tooltipViews)s.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:a}=e,o=[];for(let s=0;s<this.manager.tooltips.length;s++){let l=this.manager.tooltips[s],c=this.manager.tooltipViews[s],{dom:u}=c,O=e.pos[s],d=e.size[s];if(!O||l.clip!==!1&&(O.bottom<=Math.max(n.top,r.top)||O.top>=Math.min(n.bottom,r.bottom)||O.right<Math.max(n.left,r.left)-.1||O.left>Math.min(n.right,r.right)+.1)){u.style.top=Bm;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=(t=rI.get(c))!==null&&t!==void 0?t:d.bottom-d.top,$=c.offset||gHe,v=this.view.textDirection==gr.LTR,w=d.width>r.right-r.left?v?r.left:r.right-d.width:v?Math.max(r.left,Math.min(O.left-(f?14:0)+$.x,r.right-m)):Math.min(Math.max(r.left,O.left-m+(f?14:0)-$.x),r.right-m),x=this.above[s];!l.strictSide&&(x?O.top-g-p-$.y<r.top:O.bottom+g+p+$.y>r.bottom)&&x==r.bottom-O.bottom>O.top-r.top&&(x=this.above[s]=!x);let b=(x?O.top-r.top:r.bottom-O.bottom)-p;if(b<g&&c.resize!==!1){if(b<this.view.defaultLineHeight){u.style.top=Bm;continue}rI.set(c,g),u.style.height=(g=b)/a+"px"}else u.style.height&&(u.style.height="");let S=x?O.top-g-p-$.y:O.bottom+p+$.y,Q=w+m;if(c.overlap!==!0)for(let P of o)P.left<Q&&P.right>w&&P.top<S+g&&P.bottom>S&&(S=x?P.top-g-2-p:P.bottom+p+2);if(this.position=="absolute"?(u.style.top=(S-e.parent.top)/a+"px",iI(u,(w-e.parent.left)/i)):(u.style.top=S/a+"px",iI(u,w/i)),f){let P=O.left+(v?$.x:-$.x)-(w+14-7);f.style.left=P/i+"px"}c.overlap!==!0&&o.push({left:w,top:S,right:Q,bottom:S+g}),u.classList.toggle("cm-tooltip-above",x),u.classList.toggle("cm-tooltip-below",!x),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=Bm}},{eventObservers:{scroll(){this.maybeMeasure()}}});function iI(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const mHe=vt.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),gHe={x:0,y:0},Lz=Ot.define({enables:[Mz,mHe]}),Bw=Ot.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class zQ{static create(t){return new zQ(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new hfe(t,Bw,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const $He=Lz.compute([Bw],e=>{let t=e.facet(Bw);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:zQ.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class yHe{constructor(t,n,r,i,a){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:n}=this,r=t.docView.nearest(n.target);if(!r)return;let i,a=1;if(r instanceof Yu)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let s=t.coordsAtPos(i);if(!s||n.y<s.top||n.y>s.bottom||n.x<s.left-t.defaultCharacterWidth||n.x>s.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==gr.RTL?-1:1;a=n.x<s.left?-c:c}let o=this.source(t,i,a);if(o?.then){let s=this.pending={pos:i};o.then(l=>{this.pending==s&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Xa(t.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(Mz),n=t?t.manager.tooltips.findIndex(r=>r.create==zQ.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,r;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:a}=this;if(i.length&&a&&!vHe(a.dom,t)||this.pending){let{pos:o}=i[0]||this.pending,s=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==s?this.view.posAtCoords(this.lastMove)!=o:!bHe(this.view,o,s,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(t.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=r=>{t.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ub=4;function vHe(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let s=o.getBoundingClientRect();i=Math.min(s.top,i),a=Math.max(s.bottom,a)}return t.clientX>=n-ub&&t.clientX<=r+ub&&t.clientY>=i-ub&&t.clientY<=a+ub}function bHe(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function VJt(e,t={}){let n=xn.define(),r=Aa.define({create(){return[]},update(i,a){if(i.length&&(t.hideOnChange&&(a.docChanged||a.selection)?i=[]:t.hideOn&&(i=i.filter(o=>!t.hideOn(a,o))),a.docChanged)){let o=[];for(let s of i){let l=a.changes.mapPos(s.pos,-1,Pi.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),s);c.pos=l,c.end!=null&&(c.end=a.changes.mapPos(c.end)),o.push(c)}}i=o}for(let o of a.effects)o.is(n)&&(i=o.value),o.is(wHe)&&(i=[]);return i},provide:i=>Bw.from(i)});return{active:r,extension:[r,oi.define(i=>new yHe(i,e,r,n,t.hoverTime||300)),$He]}}function pfe(e,t){let n=e.plugin(Mz);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const wHe=xn.define(),aI=Ot.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function MJt(e,t){let n=e.plugin(mfe),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const mfe=oi.fromClass(class{constructor(e){this.input=e.state.facet(sI),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(aI);this.top=new Ob(e,!0,t.topContainer),this.bottom=new Ob(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(aI);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Ob(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ob(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(sI);if(n!=this.input){let r=n.filter(l=>l),i=[],a=[],o=[],s=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(e.view),s.push(u)):(u=this.panels[c],u.update&&u.update(e)),i.push(u),(u.top?a:o).push(u)}this.specs=r,this.panels=i,this.top.sync(a),this.bottom.sync(o);for(let l of s)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>vt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Ob{constructor(t,n,r){this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=oI(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=oI(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function oI(e){let t=e.nextSibling;return e.remove(),t}const sI=Ot.define({enables:mfe});class Wc extends Zd{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Wc.prototype.elementClass="";Wc.prototype.toDOM=void 0;Wc.prototype.mapMode=Pi.TrackBefore;Wc.prototype.startSide=Wc.prototype.endSide=-1;Wc.prototype.point=!0;const G1=Ot.define(),SHe=Ot.define(),xHe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Sn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},d0=Ot.define();function QHe(e){return[gfe(),d0.of({...xHe,...e})]}const lI=Ot.define({combine:e=>e.some(t=>t)});function gfe(e){return[kHe]}const kHe=oi.fromClass(class{constructor(e){this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(d0).map(t=>new uI(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(lI),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(lI)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&this.dom.remove();let n=Sn.iter(this.view.state.facet(G1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new PHe(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let o=!0;for(let s of a.type)if(s.type==ha.Text&&o){Eq(n,r,s.from);for(let l of i)l.line(this.view,s,r);o=!1}else if(s.widget)for(let l of i)l.widget(this.view,s)}else if(a.type==ha.Text){Eq(n,r,a.from);for(let o of i)o.line(this.view,a,r)}else if(a.widget)for(let o of i)o.widget(this.view,a);for(let a of i)a.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(d0),n=e.state.facet(d0),r=e.docChanged||e.heightChanged||e.viewportChanged||!Sn.eq(e.startState.facet(G1),e.state.facet(G1),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let a of n){let o=t.indexOf(a);o<0?i.push(new uI(this.view,a)):(this.gutters[o].update(e),i.push(this.gutters[o]))}for(let a of this.gutters)a.dom.remove(),i.indexOf(a)<0&&a.destroy();for(let a of i)this.dom.appendChild(a.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>vt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==gr.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function cI(e){return Array.isArray(e)?e:[e]}function Eq(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class PHe{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=Sn.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,a=(n.top-this.height)/t.scaleY,o=n.height/t.scaleY;if(this.i==i.elements.length){let s=new $fe(t,o,a,r);i.elements.push(s),i.dom.appendChild(s.dom)}else i.elements[this.i].update(t,o,a,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];Eq(this.cursor,i,n.from),r.length&&(i=i.concat(r));let a=this.gutter.config.lineMarker(t,n,i);a&&i.unshift(a);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(t,n,i)}widget(t,n){let r=this.gutter.config.widgetMarker(t,n.widget,n),i=r?[r]:null;for(let a of t.state.facet(SHe)){let o=a(t,n.widget,n);o&&(i||(i=[])).push(o)}i&&this.addElement(t,n,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class uI{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let a=i.target,o;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let l=a.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let s=t.lineBlockAtHeight(o-t.documentTop);n.domEventHandlers[r](t,s,i)&&i.preventDefault()});this.markers=cI(n.markers(t)),n.initialSpacer&&(this.spacer=new $fe(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=cI(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let r=t.view.viewport;return!Sn.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class $fe{constructor(t,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)}update(t,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),THe(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let a=0,o=0;;){let s=o,l=a<n.length?n[a++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let O=o;O<this.markers.length;O++)if(this.markers[O].compare(l)){s=O,c=!0;break}}else s=this.markers.length;for(;o<s;){let u=this.markers[o++];if(u.toDOM){u.destroy(i);let O=i.nextSibling;i.remove(),i=O}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),c&&o++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function THe(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}const _He=Ot.define(),XHe=Ot.define(),gh=Ot.define({combine(e){return lm(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let a=r[i],o=n[i];r[i]=a?(s,l,c)=>a(s,l,c)||o(s,l,c):o}return r}})}});class ST extends Wc{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function xT(e,t){return e.state.facet(gh).formatNumber(t,e.state)}const RHe=d0.compute([gh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(_He)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new ST(xT(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(XHe)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(gh)!=t.state.facet(gh),initialSpacer(t){return new ST(xT(t,OI(t.state.doc.lines)))},updateSpacer(t,n){let r=xT(n.view,OI(n.view.state.doc.lines));return r==t.number?t:new ST(r)},domEventHandlers:e.facet(gh).domEventHandlers}));function LJt(e={}){return[gh.of(e),gfe(),RHe]}function OI(e){let t=9;for(;t<e;)t=t*10+9;return t}const EHe=new class extends Wc{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},qHe=G1.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(EHe.range(i)))}return Sn.of(t)});function FJt(){return qHe}let jHe=0;class He{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=jHe++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof He&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new He(r,[],null,[]);if(i.set.push(i),n)for(let a of n.set)i.set.push(a);return i}static defineModifier(t){let n=new Hw(t);return r=>r.modified.indexOf(n)>-1?r:Hw.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let CHe=0;class Hw{constructor(t){this.name=t,this.instances=[],this.id=CHe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&zHe(n,s.modified));if(r)return r;let i=[],a=new He(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=AHe(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(Hw.get(s,l));return a}}function zHe(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function AHe(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function Xn(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let a=[],o=2,s=i;for(let O=0;;){if(s=="..."&&O>0&&O+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!d)throw new RangeError("Invalid path: "+i);if(a.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),O+=d[0].length,O==i.length)break;let f=i[O++];if(O==i.length&&f=="!"){o=0;break}if(f!="/")throw new RangeError("Invalid path: "+i);s=i.slice(O)}let l=a.length-1,c=a[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new Kw(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return yfe.add(t)}const yfe=new Ut;let Kw=class{constructor(t,n,r,i){this.tags=t,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};Kw.empty=new Kw([],2,null);function vfe(e,t){let n=Object.create(null);for(let a of e)if(!Array.isArray(a.tag))n[a.tag.id]=a.class;else for(let o of a.tag)n[o.id]=a.class;let{scope:r,all:i=null}=t||{};return{style:a=>{let o=i;for(let s of a)for(let l of s.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function UHe(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function WHe(e,t,n,r=0,i=e.length){let a=new YHe(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class YHe{constructor(t,n,r){this.at=t,this.highlighters=n,this.span=r,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,r,i,a){let{type:o,from:s,to:l}=t;if(s>=r||l<=n)return;o.isTop&&(a=this.highlighters.filter(f=>!f.scope||f.scope(o)));let c=i,u=GHe(t)||Kw.empty,O=UHe(a,u.tags);if(O&&(c&&(c+=" "),c+=O,u.mode==1&&(i+=(i?" ":"")+O)),this.startSpan(Math.max(n,s),c),u.opaque)return;let d=t.tree&&t.tree.prop(Ut.mounted);if(d&&d.overlay){let f=t.node.enter(d.overlay[0].from+s,1),p=this.highlighters.filter(g=>!g.scope||g.scope(d.tree.type)),m=t.firstChild();for(let g=0,$=s;;g++){let v=g<d.overlay.length?d.overlay[g]:null,w=v?v.from+s:l,x=Math.max(n,$),b=Math.min(r,w);if(x<b&&m)for(;t.from<b&&(this.highlightRange(t,x,b,i,a),this.startSpan(Math.min(b,t.to),c),!(t.to>=w||!t.nextSibling())););if(!v||w>r)break;$=v.to+s,$>n&&(this.highlightRange(f.cursor(),Math.max(n,v.from+s),Math.min(r,$),"",p),this.startSpan(Math.min(r,$),c))}m&&t.parent()}else if(t.firstChild()){d&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,a),this.startSpan(Math.min(r,t.to),c)}while(t.nextSibling());t.parent()}}}function GHe(e){let t=e.type.prop(yfe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Me=He.define,db=Me(),Pu=Me(),dI=Me(Pu),fI=Me(Pu),Tu=Me(),fb=Me(Tu),QT=Me(Tu),Js=Me(),NO=Me(Js),Ms=Me(),Ls=Me(),qq=Me(),Hm=Me(qq),hb=Me(),k={comment:db,lineComment:Me(db),blockComment:Me(db),docComment:Me(db),name:Pu,variableName:Me(Pu),typeName:dI,tagName:Me(dI),propertyName:fI,attributeName:Me(fI),className:Me(Pu),labelName:Me(Pu),namespace:Me(Pu),macroName:Me(Pu),literal:Tu,string:fb,docString:Me(fb),character:Me(fb),attributeValue:Me(fb),number:QT,integer:Me(QT),float:Me(QT),bool:Me(Tu),regexp:Me(Tu),escape:Me(Tu),color:Me(Tu),url:Me(Tu),keyword:Ms,self:Me(Ms),null:Me(Ms),atom:Me(Ms),unit:Me(Ms),modifier:Me(Ms),operatorKeyword:Me(Ms),controlKeyword:Me(Ms),definitionKeyword:Me(Ms),moduleKeyword:Me(Ms),operator:Ls,derefOperator:Me(Ls),arithmeticOperator:Me(Ls),logicOperator:Me(Ls),bitwiseOperator:Me(Ls),compareOperator:Me(Ls),updateOperator:Me(Ls),definitionOperator:Me(Ls),typeOperator:Me(Ls),controlOperator:Me(Ls),punctuation:qq,separator:Me(qq),bracket:Hm,angleBracket:Me(Hm),squareBracket:Me(Hm),paren:Me(Hm),brace:Me(Hm),content:Js,heading:NO,heading1:Me(NO),heading2:Me(NO),heading3:Me(NO),heading4:Me(NO),heading5:Me(NO),heading6:Me(NO),contentSeparator:Me(Js),list:Me(Js),quote:Me(Js),emphasis:Me(Js),strong:Me(Js),link:Me(Js),monospace:Me(Js),strikethrough:Me(Js),inserted:Me(),deleted:Me(),changed:Me(),invalid:Me(),meta:hb,documentMeta:Me(hb),annotation:Me(hb),processingInstruction:Me(hb),definition:He.defineModifier("definition"),constant:He.defineModifier("constant"),function:He.defineModifier("function"),standard:He.defineModifier("standard"),local:He.defineModifier("local"),special:He.defineModifier("special")};for(let e in k){let t=k[e];t instanceof He&&(t.name=e)}vfe([{tag:k.link,class:"tok-link"},{tag:k.heading,class:"tok-heading"},{tag:k.emphasis,class:"tok-emphasis"},{tag:k.strong,class:"tok-strong"},{tag:k.keyword,class:"tok-keyword"},{tag:k.atom,class:"tok-atom"},{tag:k.bool,class:"tok-bool"},{tag:k.url,class:"tok-url"},{tag:k.labelName,class:"tok-labelName"},{tag:k.inserted,class:"tok-inserted"},{tag:k.deleted,class:"tok-deleted"},{tag:k.literal,class:"tok-literal"},{tag:k.string,class:"tok-string"},{tag:k.number,class:"tok-number"},{tag:[k.regexp,k.escape,k.special(k.string)],class:"tok-string2"},{tag:k.variableName,class:"tok-variableName"},{tag:k.local(k.variableName),class:"tok-variableName tok-local"},{tag:k.definition(k.variableName),class:"tok-variableName tok-definition"},{tag:k.special(k.variableName),class:"tok-variableName2"},{tag:k.definition(k.propertyName),class:"tok-propertyName tok-definition"},{tag:k.typeName,class:"tok-typeName"},{tag:k.namespace,class:"tok-namespace"},{tag:k.className,class:"tok-className"},{tag:k.macroName,class:"tok-macroName"},{tag:k.propertyName,class:"tok-propertyName"},{tag:k.operator,class:"tok-operator"},{tag:k.comment,class:"tok-comment"},{tag:k.meta,class:"tok-meta"},{tag:k.invalid,class:"tok-invalid"},{tag:k.punctuation,class:"tok-punctuation"}]);var kT;const Nu=new Ut;function AQ(e){return Ot.define({combine:e?t=>t.concat(e):void 0})}const Fz=new Ut;class co{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Cn.prototype.hasOwnProperty("tree")||Object.defineProperty(Cn.prototype,"tree",{get(){return In(this)}}),this.parser=n,this.extension=[OO.of(this),Cn.languageData.of((a,o,s)=>{let l=hI(a,o,s),c=l.type.prop(Nu);if(!c)return[];let u=a.facet(c),O=l.type.prop(Fz);if(O){let d=l.resolve(o-l.from,s);for(let f of O)if(f.test(d,a)){let p=a.facet(f.facet);return f.type=="replace"?p:p.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return hI(t,n,r).type.prop(Nu)==this.data}findRegions(t){let n=t.facet(OO);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(a,o)=>{if(a.prop(Nu)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(Ut.mounted);if(s){if(s.tree.prop(Nu)==this.data){if(s.overlay)for(let l of s.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+a.length});return}else if(s.overlay){let l=r.length;if(i(s.tree,s.overlay[0].from+o),r.length>l)return}}for(let l=0;l<a.children.length;l++){let c=a.children[l];c instanceof hn&&i(c,a.positions[l]+o)}};return i(In(t),0),r}get allowsNesting(){return!0}}co.setState=xn.define();function hI(e,t,n){let r=e.facet(OO),i=In(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,Kn.ExcludeBuffers))a.type.isTop&&(i=a);return i}class kn extends co{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=AQ(t.languageData);return new kn(n,t.parser.configure({props:[Nu.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new kn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function In(e){let t=e.field(co.state,!1);return t?t.tree:hn.empty}class NHe{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let r=this.cursorPos-this.string.length;return t<r||n>=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-r,n-r)}}let Km=null;class Ld{constructor(t,n,r=[],i,a,o,s,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=a,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new Ld(t,n,[],hn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new NHe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=hn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(Pc.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,n;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(Pc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Km;Km=this;try{return t()}finally{Km=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=pI(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((c,u,O,d)=>l.push({fromA:c,toA:u,fromB:O,toB:d})),r=Pc.applyChanges(r,l),i=hn.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let c of this.skipped){let u=t.mapPos(c.from,1),O=t.mapPos(c.to,-1);u<O&&s.push({from:u,to:O})}}}return new Ld(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:a}=this.skipped[r];i<t.to&&a>t.from&&(this.fragments=pI(this.fragments,i,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends RQ{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=Km;if(l){for(let c of i)l.tempSkipped.push(c);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new hn(Hr.none,[],[],o-a)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return Km}}function pI(e,t,n){return Pc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class cp{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new cp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Ld.create(t.facet(OO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new cp(r)}}co.state=Aa.define({create:cp.init,update(e,t){for(let n of t.effects)if(n.is(co.setState))return n.value;return t.startState.facet(OO)!=t.state.facet(OO)?cp.init(t.state):e.apply(t)}});let bfe=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(bfe=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const PT=typeof navigator<"u"&&(!((kT=navigator.scheduling)===null||kT===void 0)&&kT.isInputPending)?()=>navigator.scheduling.isInputPending():null,ZHe=oi.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(co.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(co.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=bfe(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,a=r.field(co.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!PT?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>PT&&PT()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:co.setState.of(new cp(a.context))})),this.chunkBudget>0&&!(l&&!s)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Xa(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),OO=Ot.define({combine(e){return e.length?e[0]:null},enables:e=>[co.state,ZHe,vt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class vn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class ue{constructor(t,n,r,i,a,o=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=a,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new ue(t.name,(t.alias||[]).concat(t.name).map(i=>i.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(t,n){for(let i of t)if(i.filename&&i.filename.test(n))return i;let r=/\.([^.]+)$/.exec(n);if(r){for(let i of t)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(t,n,r=!0){n=n.toLowerCase();for(let i of t)if(i.alias.some(a=>a==n))return i;if(r)for(let i of t)for(let a of i.alias){let o=n.indexOf(a);if(o>-1&&(a.length>2||!/\w/.test(n[o-1])&&!/\w/.test(n[o+a.length])))return i}return null}}const IHe=Ot.define(),UQ=Ot.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function Jw(e){let t=e.facet(UQ);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function DHe(e,t){let n="",r=e.tabSize,i=e.facet(UQ)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function VHe(e,t){e instanceof Cn&&(e=new wfe(e));for(let r of e.state.facet(IHe)){let i=r(e,t);if(i!==void 0)return i}let n=In(e.state);return n.length>=t?MHe(e,n,t):null}class wfe{constructor(t,n={}){this.state=t,this.options=n,this.unit=Jw(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:a}=this.options;return i!=null&&i>=r.from&&i<=r.to?a&&i==t?{text:"",from:t}:(n<0?i<t:i<=t)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(t,n=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(t,n);return r.slice(t-i,Math.min(r.length,t+100-i))}column(t,n=1){let{text:r,from:i}=this.lineAt(t,n),a=this.countColumn(r,t-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(a+=o-this.countColumn(r,r.search(/\S|$/))),a}countColumn(t,n=t.length){return sO(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),a=this.options.overrideIndentation;if(a){let o=a(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Pr=new Ut;function MHe(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let a=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)a.push(o);for(let o=a.length-1;o>=0;o--)r={node:a[o],next:r}}return Sfe(r,e,n)}function Sfe(e,t,n){for(let r=e;r;r=r.next){let i=FHe(r.node);if(i)return i(Bz.create(t,n,r))}return 0}function LHe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function FHe(e){let t=e.type.prop(Pr);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Ut.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>xfe(o,!0,1,void 0,a&&!LHe(o)?i.from:void 0)}return e.parent==null?BHe:null}function BHe(){return 0}class Bz extends wfe{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new Bz(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(HHe(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Sfe(this.context.next,this.base,this.pos)}}function HHe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function KHe(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let s=n.to;;){let l=t.childAfter(s);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+c}}s=l.to}}function Mo({closing:e,align:t=!0,units:n=1}){return r=>xfe(r,t,n,e)}function xfe(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,l=t?KHe(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const Hz=e=>e.baseIndent;function Er({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const JHe=200;function KJt(){return Cn.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+JHe)return e;let a=n.sliceString(i.from,r);if(!t.some(c=>c.test(a)))return e;let{state:o}=e,s=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==s)continue;s=u.from;let O=VHe(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],f=DHe(o,O);d!=f&&l.push({from:u.from,to:u.from+d.length,insert:f})}return l.length?[e,{changes:l,sequential:!0}]:e})}const Qfe=Ot.define(),vr=new Ut;function Hi(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function eKe(e,t,n){let r=In(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(a&&s.from<t)break;let l=s.type.prop(vr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!tKe(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function tKe(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function eS(e,t,n){for(let r of e.facet(Qfe)){let i=r(e,t,n);if(i)return i}return eKe(e,t,n)}function kfe(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const WQ=xn.define({map:kfe}),Ny=xn.define({map:kfe});function Pfe(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}const Fd=Aa.define({create(){return ln.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(WQ)&&!nKe(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Xfe),i=r?ln.replace({widget:new lKe(r(t.state,n.value))}):mI;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Ny)&&(e=e.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,(i,a)=>{i<r&&a>r&&(n=!0)}),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(i,a)=>a<=r||i>=r}))}return e},provide:e=>vt.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(mI.range(r,i))}return ln.set(t,!0)}});function tS(e,t,n){var r;let i=null;return(r=e.field(Fd,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function nKe(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function Tfe(e,t){return e.field(Fd,!1)?t:t.concat(xn.appendConfig.of(Rfe()))}const rKe=e=>{for(let t of Pfe(e)){let n=eS(e.state,t.from,t.to);if(n)return e.dispatch({effects:Tfe(e.state,[WQ.of(n),_fe(e,n)])}),!0}return!1},iKe=e=>{if(!e.state.field(Fd,!1))return!1;let t=[];for(let n of Pfe(e)){let r=tS(e.state,n.from,n.to);r&&t.push(Ny.of(r),_fe(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function _fe(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return vt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const aKe=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=eS(t,i.from,i.to);a&&n.push(WQ.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Tfe(e.state,n)}),!!n.length},oKe=e=>{let t=e.state.field(Fd,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(Ny.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},JJt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:rKe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:iKe},{key:"Ctrl-Alt-[",run:aKe},{key:"Ctrl-Alt-]",run:oKe}],sKe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Xfe=Ot.define({combine(e){return lm(e,sKe)}});function Rfe(e){return[Fd,uKe]}function Efe(e,t){let{state:n}=e,r=n.facet(Xfe),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=tS(e.state,s.from,s.to);l&&e.dispatch({effects:Ny.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement("span");return a.textContent=r.placeholderText,a.setAttribute("aria-label",n.phrase("folded code")),a.title=n.phrase("unfold"),a.className="cm-foldPlaceholder",a.onclick=i,a}const mI=ln.replace({widget:new class extends eu{toDOM(e){return Efe(e,null)}}});class lKe extends eu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Efe(t,this.value)}}const cKe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class TT extends Wc{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function een(e={}){let t={...cKe,...e},n=new TT(t,!0),r=new TT(t,!1),i=oi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(OO)!=o.state.facet(OO)||o.startState.field(Fd,!1)!=o.state.field(Fd,!1)||In(o.startState)!=In(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new Id;for(let l of o.viewportLineBlocks){let c=tS(o.state,l.from,l.to)?r:eS(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,QHe({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||Sn.empty},initialSpacer(){return new TT(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=tS(o.state,s.from,s.to);if(c)return o.dispatch({effects:Ny.of(c)}),!0;let u=eS(o.state,s.from,s.to);return u?(o.dispatch({effects:WQ.of(u)}),!0):!1}}}),Rfe()]}const uKe=vt.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class YQ{constructor(t,n){this.specs=t;let r;function i(s){let l=lO.newName();return(r||(r=Object.create(null)))["."+l]=s,l}const a=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof co?s=>s.prop(Nu)==o.data:o?s=>s==o:void 0,this.style=vfe(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new lO(r):null,this.themeType=n.themeType}static define(t,n){return new YQ(t,n||{})}}const jq=Ot.define(),qfe=Ot.define({combine(e){return e.length?[e[0]]:null}});function _T(e){let t=e.facet(jq);return t.length?t:e.facet(qfe)}function ten(e,t){let n=[dKe],r;return e instanceof YQ&&(e.module&&n.push(vt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(qfe.of(e)):r?n.push(jq.computeN([vt.darkTheme],i=>i.facet(vt.darkTheme)==(r=="dark")?[e]:[])):n.push(jq.of(e)),n}class OKe{constructor(t){this.markCache=Object.create(null),this.tree=In(t.state),this.decorations=this.buildDeco(t,_T(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=In(t.state),r=_T(t.state),i=r!=_T(t.startState),{viewport:a}=t.view,o=t.changes.mapPos(this.decoratedTo,1);n.length<a.to&&!i&&n.type==this.tree.type&&o>=a.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=a.to)}buildDeco(t,n){if(!n||!this.tree.length)return ln.none;let r=new Id;for(let{from:i,to:a}of t.visibleRanges)WHe(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=ln.mark({class:l})))},i,a);return r.finish()}}const dKe=bO.high(oi.fromClass(OKe,{decorations:e=>e.decorations})),nen=YQ.define([{tag:k.meta,color:"#404740"},{tag:k.link,textDecoration:"underline"},{tag:k.heading,textDecoration:"underline",fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strong,fontWeight:"bold"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.keyword,color:"#708"},{tag:[k.atom,k.bool,k.url,k.contentSeparator,k.labelName],color:"#219"},{tag:[k.literal,k.inserted],color:"#164"},{tag:[k.string,k.deleted],color:"#a11"},{tag:[k.regexp,k.escape,k.special(k.string)],color:"#e40"},{tag:k.definition(k.variableName),color:"#00f"},{tag:k.local(k.variableName),color:"#30a"},{tag:[k.typeName,k.namespace],color:"#085"},{tag:k.className,color:"#167"},{tag:[k.special(k.variableName),k.macroName],color:"#256"},{tag:k.definition(k.propertyName),color:"#00c"},{tag:k.comment,color:"#940"},{tag:k.invalid,color:"#f00"}]),fKe=vt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),jfe=1e4,Cfe="()[]{}",zfe=Ot.define({combine(e){return lm(e,{afterCursor:!0,brackets:Cfe,maxScanDistance:jfe,renderMatch:mKe})}}),hKe=ln.mark({class:"cm-matchingBracket"}),pKe=ln.mark({class:"cm-nonmatchingBracket"});function mKe(e){let t=[],n=e.matched?hKe:pKe;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const gKe=Aa.define({create(){return ln.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(zfe);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=pb(t.state,i.head,-1,r)||i.head>0&&pb(t.state,i.head-1,1,r)||r.afterCursor&&(pb(t.state,i.head,1,r)||i.head<t.state.doc.length&&pb(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return ln.set(n,!0)},provide:e=>vt.decorations.from(e)}),$Ke=[gKe,fKe];function ren(e={}){return[zfe.of(e),$Ke]}const Kz=new Ut;function Cq(e,t,n){let r=e.prop(t<0?Ut.openedBy:Ut.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function zq(e){let t=e.type.prop(Kz);return t?t(e.node):e}function pb(e,t,n,r={}){let i=r.maxScanDistance||jfe,a=r.brackets||Cfe,o=In(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=Cq(l.type,n,a);if(c&&l.from<l.to){let u=zq(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return yKe(e,t,n,l,u,c,a)}}return vKe(e,t,n,o,s.type,i,a)}function yKe(e,t,n,r,i,a,o){let s=r.parent,l={from:i.from,to:i.to},c=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(c==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let O=zq(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(Cq(u.type,n,o))c++;else if(Cq(u.type,-n,o)){if(c==0){let O=zq(u);return{start:l,end:O&&O.from<O.to?{from:O.from,to:O.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function vKe(e,t,n,r,i,a,o){let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(s);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),O=0;for(let d=0;!u.next().done&&d<=a;){let f=u.value;n<0&&(d+=f.length);let p=t+d*n;for(let m=n>0?0:f.length-1,g=n>0?f.length:-1;m!=g;m+=n){let $=o.indexOf(f[m]);if(!($<0||r.resolveInner(p+m,1).type!=i))if($%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:p+m,to:p+m+1},matched:$>>1==l>>1};O--}}n>0&&(d+=f.length)}return u.done?{start:c,matched:!1}:null}function gI(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let o=r;o<t;o++)e.charCodeAt(o)==9?a+=n-a%n:a++;return a}class Afe{constructor(t,n,r,i){this.string=t,this.tabSize=n,this.indentUnit=r,this.overrideIndent=i,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let n=this.string.charAt(this.pos),r;if(typeof t=="string"?r=n==t:r=n&&(t instanceof RegExp?t.test(n):t(n)),r)return++this.pos,n}eatWhile(t){let n=this.pos;for(;this.eat(t););return this.pos>n}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let n=this.string.indexOf(t,this.pos);if(n>-1)return this.pos=n,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=gI(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:gI(this.string,null,this.tabSize)}match(t,n,r){if(typeof t=="string"){let i=o=>r?o.toLowerCase():o,a=this.string.substr(this.pos,t.length);return i(a)==i(t)?(n!==!1&&(this.pos+=t.length),!0):null}else{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&n!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function bKe(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||wKe,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||e9,mergeTokens:e.mergeTokens!==!1}}function wKe(e){if(typeof e!="object")return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}const $I=new WeakMap;class Pe extends co{constructor(t){let n=AQ(t.languageData),r=bKe(t),i,a=new class extends RQ{createParse(o,s,l){return new xKe(i,o,s,l)}};super(n,a,[],t.name),this.topNode=PKe(n,this),i=this,this.streamParser=r,this.stateAfter=new Ut({perNode:!0}),this.tokenTable=t.tokenTable?new Gfe(r.tokenTable):kKe}static define(t){return new Pe(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=$I.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=Jz(this,t.node.tree,t.node.from,t.node.from,n??t.pos),a,o;if(i?(o=i.state,a=i.pos+1):(o=this.streamParser.startState(t.unit),a=t.node.from),t.pos-a>1e4)return null;for(;a<t.pos;){let l=t.state.doc.lineAt(a),c=Math.min(t.pos,l.to);if(l.length){let u=r?r(l.from):-1,O=new Afe(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Wfe(this.streamParser.token,O,o)}else this.streamParser.blankLine(o,t.unit);if(c==t.pos)break;a=l.to+1}let s=t.lineAt(t.pos);return r&&n==null&&$I.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function Jz(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let o=t.children.length-1;o>=0;o--){let s=t.children[o],l=n+t.positions[o],c=s instanceof hn&&l<i&&Jz(e,s,l,r,i);if(c)return c}return null}function Ufe(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],l;if(o<r&&s instanceof hn){if(!(l=Ufe(e,s,n-o,r-o,i)))break;return i?new hn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function SKe(e,t,n,r,i){for(let a of t){let o=a.from+(a.openStart?25:0),s=a.to-(a.openEnd?25:0),l=o<=n&&s>n&&Jz(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Ufe(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?Jw(i):4),tree:hn.empty}}let xKe=class{constructor(t,n,r,i){this.lang=t,this.input=n,this.fragments=r,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let a=Ld.get(),o=i[0].from,{state:s,tree:l}=SKe(t,r,o,this.to,a?.state);this.state=s,this.parsedPos=this.chunkStart=o+l.length;for(let c=0;c<l.children.length;c++)this.chunks.push(l.children[c]),this.chunkPos.push(l.positions[c]);a&&this.parsedPos<a.viewport.from-1e5&&i.some(c=>c.from<=a.viewport.from&&c.to>=a.viewport.from)&&(this.state=this.lang.streamParser.startState(Jw(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=Ld.get(),n=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(n,this.chunkStart+2048);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=n?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,n),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let n=this.input.chunk(t);if(this.input.lineChunks)n==`
|
|
786
786
|
`&&(n="");else{let r=n.indexOf(`
|
|
787
|
-
`);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let a=this.ranges[i].to;if(a>=r||(n=n.slice(0,a-(r-n.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,s=this.lineAfter(o);n+=s,r=o+s.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,a=t+n;if(r>0?i>a:i>=a)break;let o=this.ranges[++this.rangeIndex].from;n+=o-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let a=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let s=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-s}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==n?this.chunk[o+2]=r:this.chunk.push(t,n,r,a),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:a}=this.lang,o=new Afe(n,t?t.state.tabSize:4,t?Jw(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Wfe(a.token,o,this.state);if(s&&(i=this.emitToken(this.lang.tokenTable.resolve(s),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=hn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:QKe,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new hn(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new hn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Wfe(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const e9=Object.create(null),v$=[Hr.none],QKe=new sm(v$),yI=[],vI=Object.create(null),Yfe=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Yfe[e]=Nfe(e9,t);class Gfe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Yfe)}resolve(t){return t?this.table[t]||(this.table[t]=Nfe(this.extra,t)):0}}const kKe=new Gfe(e9);function XT(e,t){yI.indexOf(e)>-1||(yI.push(e),console.warn(t))}function Nfe(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||k[c];u?typeof u=="function"?l.length?l=l.map(u):XT(c,`Modifier ${c} used at start of tag`):l.length?XT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:XT(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=vI[i];if(a)return a.id;let o=vI[i]=Hr.define({id:v$.length,name:r,props:[Xn({[r]:n})]});return v$.push(o),o.id}function PKe(e,t){let n=Hr.define({id:v$.length,name:"Document",props:[Nu.add(()=>e),Pr.add(()=>r=>t.getIndent(r))],top:!0});return v$.push(n),n}gr.RTL,gr.LTR;function be(e){return new vn(Pe.define(e))}function gu(e){return de(()=>Promise.resolve().then(()=>Jst),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const TKe=[ue.of({name:"C",extensions:["c","h","ino"],load(){return de(()=>Promise.resolve().then(()=>OV),void 0,import.meta.url).then(e=>e.cpp())}}),ue.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return de(()=>Promise.resolve().then(()=>OV),void 0,import.meta.url).then(e=>e.cpp())}}),ue.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return gu("Cassandra")}}),ue.of({name:"CSS",extensions:["css"],load(){return de(()=>Promise.resolve().then(()=>htt),void 0,import.meta.url).then(e=>e.css())}}),ue.of({name:"Go",extensions:["go"],load(){return de(()=>import("./index-mogv7CG7.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),ue.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return de(()=>Promise.resolve().then(()=>ant),void 0,import.meta.url).then(e=>e.html())}}),ue.of({name:"Java",extensions:["java"],load(){return de(()=>Promise.resolve().then(()=>rlt),void 0,import.meta.url).then(e=>e.java())}}),ue.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return de(()=>Promise.resolve().then(()=>yb),void 0,import.meta.url).then(e=>e.javascript())}}),ue.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return de(()=>Promise.resolve().then(()=>urt),void 0,import.meta.url).then(e=>e.json())}}),ue.of({name:"JSX",extensions:["jsx"],load(){return de(()=>Promise.resolve().then(()=>yb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ue.of({name:"LESS",extensions:["less"],load(){return de(()=>Promise.resolve().then(()=>knt),void 0,import.meta.url).then(e=>e.less())}}),ue.of({name:"Liquid",extensions:["liquid"],load(){return de(()=>Promise.resolve().then(()=>Nut),void 0,import.meta.url).then(e=>e.liquid())}}),ue.of({name:"MariaDB SQL",load(){return gu("MariaSQL")}}),ue.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return de(()=>Promise.resolve().then(()=>pnt),void 0,import.meta.url).then(e=>e.markdown())}}),ue.of({name:"MS SQL",load(){return gu("MSSQL")}}),ue.of({name:"MySQL",load(){return gu("MySQL")}}),ue.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return de(()=>Promise.resolve().then(()=>yut),void 0,import.meta.url).then(e=>e.php())}}),ue.of({name:"PLSQL",extensions:["pls"],load(){return gu("PLSQL")}}),ue.of({name:"PostgreSQL",load(){return gu("PostgreSQL")}}),ue.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return de(()=>Promise.resolve().then(()=>Not),void 0,import.meta.url).then(e=>e.python())}}),ue.of({name:"Rust",extensions:["rs"],load(){return de(()=>Promise.resolve().then(()=>Slt),void 0,import.meta.url).then(e=>e.rust())}}),ue.of({name:"Sass",extensions:["sass"],load(){return de(()=>Promise.resolve().then(()=>kD),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ue.of({name:"SCSS",extensions:["scss"],load(){return de(()=>Promise.resolve().then(()=>kD),void 0,import.meta.url).then(e=>e.sass())}}),ue.of({name:"SQL",extensions:["sql"],load(){return gu("StandardSQL")}}),ue.of({name:"SQLite",load(){return gu("SQLite")}}),ue.of({name:"TSX",extensions:["tsx"],load(){return de(()=>Promise.resolve().then(()=>yb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ue.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return de(()=>Promise.resolve().then(()=>yb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ue.of({name:"WebAssembly",extensions:["wat","wast"],load(){return de(()=>Promise.resolve().then(()=>Dut),void 0,import.meta.url).then(e=>e.wast())}}),ue.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return de(()=>Promise.resolve().then(()=>ust),void 0,import.meta.url).then(e=>e.xml())}}),ue.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return de(()=>import("./index-C6XPeDkS.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),ue.of({name:"APL",extensions:["dyalog","apl"],load(){return de(()=>Promise.resolve().then(()=>vft),void 0,import.meta.url).then(e=>be(e.apl))}}),ue.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return de(()=>Promise.resolve().then(()=>bft),void 0,import.meta.url).then(e=>be(e.asciiArmor))}}),ue.of({name:"ASN.1",extensions:["asn","asn1"],load(){return de(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>be(e.asn1({})))}}),ue.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return de(()=>Promise.resolve().then(()=>kft),void 0,import.meta.url).then(e=>be(e.asterisk))}}),ue.of({name:"Brainfuck",extensions:["b","bf"],load(){return de(()=>Promise.resolve().then(()=>Tft),void 0,import.meta.url).then(e=>be(e.brainfuck))}}),ue.of({name:"Cobol",extensions:["cob","cpy"],load(){return de(()=>Promise.resolve().then(()=>nht),void 0,import.meta.url).then(e=>be(e.cobol))}}),ue.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.csharp))}}),ue.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>be(e.clojure))}}),ue.of({name:"ClojureScript",extensions:["cljs"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>be(e.clojure))}}),ue.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return de(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>be(e.gss))}}),ue.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return de(()=>Promise.resolve().then(()=>Mft),void 0,import.meta.url).then(e=>be(e.cmake))}}),ue.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return de(()=>Promise.resolve().then(()=>pht),void 0,import.meta.url).then(e=>be(e.coffeeScript))}}),ue.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return de(()=>Promise.resolve().then(()=>bht),void 0,import.meta.url).then(e=>be(e.commonLisp))}}),ue.of({name:"Cypher",extensions:["cyp","cypher"],load(){return de(()=>Promise.resolve().then(()=>Wht),void 0,import.meta.url).then(e=>be(e.cypher))}}),ue.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return de(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>be(e.cython))}}),ue.of({name:"Crystal",extensions:["cr"],load(){return de(()=>Promise.resolve().then(()=>qht),void 0,import.meta.url).then(e=>be(e.crystal))}}),ue.of({name:"D",extensions:["d"],load(){return de(()=>Promise.resolve().then(()=>Vht),void 0,import.meta.url).then(e=>be(e.d))}}),ue.of({name:"Dart",extensions:["dart"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.dart))}}),ue.of({name:"diff",extensions:["diff","patch"],load(){return de(()=>Promise.resolve().then(()=>Mht),void 0,import.meta.url).then(e=>be(e.diff))}}),ue.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return de(()=>Promise.resolve().then(()=>opt),void 0,import.meta.url).then(e=>be(e.dockerFile))}}),ue.of({name:"DTD",extensions:["dtd"],load(){return de(()=>Promise.resolve().then(()=>cpt),void 0,import.meta.url).then(e=>be(e.dtd))}}),ue.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return de(()=>Promise.resolve().then(()=>hpt),void 0,import.meta.url).then(e=>be(e.dylan))}}),ue.of({name:"EBNF",load(){return de(()=>Promise.resolve().then(()=>ppt),void 0,import.meta.url).then(e=>be(e.ebnf))}}),ue.of({name:"ECL",extensions:["ecl"],load(){return de(()=>Promise.resolve().then(()=>Spt),void 0,import.meta.url).then(e=>be(e.ecl))}}),ue.of({name:"edn",extensions:["edn"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>be(e.clojure))}}),ue.of({name:"Eiffel",extensions:["e"],load(){return de(()=>Promise.resolve().then(()=>_pt),void 0,import.meta.url).then(e=>be(e.eiffel))}}),ue.of({name:"Elm",extensions:["elm"],load(){return de(()=>Promise.resolve().then(()=>Ypt),void 0,import.meta.url).then(e=>be(e.elm))}}),ue.of({name:"Erlang",extensions:["erl"],load(){return de(()=>Promise.resolve().then(()=>umt),void 0,import.meta.url).then(e=>be(e.erlang))}}),ue.of({name:"Esper",load(){return de(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>be(e.esper))}}),ue.of({name:"Factor",extensions:["factor"],load(){return de(()=>Promise.resolve().then(()=>Omt),void 0,import.meta.url).then(e=>be(e.factor))}}),ue.of({name:"FCL",load(){return de(()=>Promise.resolve().then(()=>mmt),void 0,import.meta.url).then(e=>be(e.fcl))}}),ue.of({name:"Forth",extensions:["forth","fth","4th"],load(){return de(()=>Promise.resolve().then(()=>ymt),void 0,import.meta.url).then(e=>be(e.forth))}}),ue.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return de(()=>Promise.resolve().then(()=>kmt),void 0,import.meta.url).then(e=>be(e.fortran))}}),ue.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>be(e.fSharp))}}),ue.of({name:"Gas",extensions:["s"],load(){return de(()=>Promise.resolve().then(()=>Tmt),void 0,import.meta.url).then(e=>be(e.gas))}}),ue.of({name:"Gherkin",extensions:["feature"],load(){return de(()=>Promise.resolve().then(()=>_mt),void 0,import.meta.url).then(e=>be(e.gherkin))}}),ue.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return de(()=>Promise.resolve().then(()=>Ymt),void 0,import.meta.url).then(e=>be(e.groovy))}}),ue.of({name:"Haskell",extensions:["hs"],load(){return de(()=>Promise.resolve().then(()=>Mmt),void 0,import.meta.url).then(e=>be(e.haskell))}}),ue.of({name:"Haxe",extensions:["hx"],load(){return de(()=>Promise.resolve().then(()=>jM),void 0,import.meta.url).then(e=>be(e.haxe))}}),ue.of({name:"HXML",extensions:["hxml"],load(){return de(()=>Promise.resolve().then(()=>jM),void 0,import.meta.url).then(e=>be(e.hxml))}}),ue.of({name:"HTTP",load(){return de(()=>Promise.resolve().then(()=>mgt),void 0,import.meta.url).then(e=>be(e.http))}}),ue.of({name:"IDL",extensions:["pro"],load(){return de(()=>Promise.resolve().then(()=>Sgt),void 0,import.meta.url).then(e=>be(e.idl))}}),ue.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return de(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>be(e.jsonld))}}),ue.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return de(()=>Promise.resolve().then(()=>Pgt),void 0,import.meta.url).then(e=>be(e.jinja2))}}),ue.of({name:"Julia",extensions:["jl"],load(){return de(()=>Promise.resolve().then(()=>Kgt),void 0,import.meta.url).then(e=>be(e.julia))}}),ue.of({name:"Kotlin",extensions:["kt","kts"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.kotlin))}}),ue.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return de(()=>Promise.resolve().then(()=>n0t),void 0,import.meta.url).then(e=>be(e.liveScript))}}),ue.of({name:"Lua",extensions:["lua"],load(){return de(()=>Promise.resolve().then(()=>u0t),void 0,import.meta.url).then(e=>be(e.lua))}}),ue.of({name:"mIRC",extensions:["mrc"],load(){return de(()=>Promise.resolve().then(()=>q0t),void 0,import.meta.url).then(e=>be(e.mirc))}}),ue.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return de(()=>Promise.resolve().then(()=>$0t),void 0,import.meta.url).then(e=>be(e.mathematica))}}),ue.of({name:"Modelica",extensions:["mo"],load(){return de(()=>Promise.resolve().then(()=>Z0t),void 0,import.meta.url).then(e=>be(e.modelica))}}),ue.of({name:"MUMPS",extensions:["mps"],load(){return de(()=>Promise.resolve().then(()=>a$t),void 0,import.meta.url).then(e=>be(e.mumps))}}),ue.of({name:"Mbox",extensions:["mbox"],load(){return de(()=>Promise.resolve().then(()=>X0t),void 0,import.meta.url).then(e=>be(e.mbox))}}),ue.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return de(()=>Promise.resolve().then(()=>u$t),void 0,import.meta.url).then(e=>be(e.nginx))}}),ue.of({name:"NSIS",extensions:["nsh","nsi"],load(){return de(()=>Promise.resolve().then(()=>O$t),void 0,import.meta.url).then(e=>be(e.nsis))}}),ue.of({name:"NTriples",extensions:["nt","nq"],load(){return de(()=>Promise.resolve().then(()=>d$t),void 0,import.meta.url).then(e=>be(e.ntriples))}}),ue.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.objectiveC))}}),ue.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.objectiveCpp))}}),ue.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>be(e.oCaml))}}),ue.of({name:"Octave",extensions:["m"],load(){return de(()=>Promise.resolve().then(()=>S$t),void 0,import.meta.url).then(e=>be(e.octave))}}),ue.of({name:"Oz",extensions:["oz"],load(){return de(()=>Promise.resolve().then(()=>C$t),void 0,import.meta.url).then(e=>be(e.oz))}}),ue.of({name:"Pascal",extensions:["p","pas"],load(){return de(()=>Promise.resolve().then(()=>G$t),void 0,import.meta.url).then(e=>be(e.pascal))}}),ue.of({name:"Perl",extensions:["pl","pm"],load(){return de(()=>Promise.resolve().then(()=>N$t),void 0,import.meta.url).then(e=>be(e.perl))}}),ue.of({name:"Pig",extensions:["pig"],load(){return de(()=>Promise.resolve().then(()=>D$t),void 0,import.meta.url).then(e=>be(e.pig))}}),ue.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return de(()=>Promise.resolve().then(()=>syt),void 0,import.meta.url).then(e=>be(e.powerShell))}}),ue.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return de(()=>Promise.resolve().then(()=>lyt),void 0,import.meta.url).then(e=>be(e.properties))}}),ue.of({name:"ProtoBuf",extensions:["proto"],load(){return de(()=>Promise.resolve().then(()=>fyt),void 0,import.meta.url).then(e=>be(e.protobuf))}}),ue.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return de(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>be(e.pug))}}),ue.of({name:"Puppet",extensions:["pp"],load(){return de(()=>Promise.resolve().then(()=>myt),void 0,import.meta.url).then(e=>be(e.puppet))}}),ue.of({name:"Q",extensions:["q"],load(){return de(()=>Promise.resolve().then(()=>xyt),void 0,import.meta.url).then(e=>be(e.q))}}),ue.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return de(()=>Promise.resolve().then(()=>Ryt),void 0,import.meta.url).then(e=>be(e.r))}}),ue.of({name:"RPM Changes",load(){return de(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>be(e.rpmChanges))}}),ue.of({name:"RPM Spec",extensions:["spec"],load(){return de(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>be(e.rpmSpec))}}),ue.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return de(()=>Promise.resolve().then(()=>Yyt),void 0,import.meta.url).then(e=>be(e.ruby))}}),ue.of({name:"SAS",extensions:["sas"],load(){return de(()=>Promise.resolve().then(()=>Iyt),void 0,import.meta.url).then(e=>be(e.sas))}}),ue.of({name:"Scala",extensions:["scala"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.scala))}}),ue.of({name:"Scheme",extensions:["scm","ss"],load(){return de(()=>Promise.resolve().then(()=>rvt),void 0,import.meta.url).then(e=>be(e.scheme))}}),ue.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return de(()=>Promise.resolve().then(()=>svt),void 0,import.meta.url).then(e=>be(e.shell))}}),ue.of({name:"Sieve",extensions:["siv","sieve"],load(){return de(()=>Promise.resolve().then(()=>dvt),void 0,import.meta.url).then(e=>be(e.sieve))}}),ue.of({name:"Smalltalk",extensions:["st"],load(){return de(()=>Promise.resolve().then(()=>pvt),void 0,import.meta.url).then(e=>be(e.smalltalk))}}),ue.of({name:"Solr",load(){return de(()=>Promise.resolve().then(()=>wvt),void 0,import.meta.url).then(e=>be(e.solr))}}),ue.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>be(e.sml))}}),ue.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return de(()=>Promise.resolve().then(()=>_vt),void 0,import.meta.url).then(e=>be(e.sparql))}}),ue.of({name:"Spreadsheet",alias:["excel","formula"],load(){return de(()=>Promise.resolve().then(()=>Xvt),void 0,import.meta.url).then(e=>be(e.spreadsheet))}}),ue.of({name:"Squirrel",extensions:["nut"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.squirrel))}}),ue.of({name:"Stylus",extensions:["styl"],load(){return de(()=>Promise.resolve().then(()=>Kvt),void 0,import.meta.url).then(e=>be(e.stylus))}}),ue.of({name:"Swift",extensions:["swift"],load(){return de(()=>Promise.resolve().then(()=>$bt),void 0,import.meta.url).then(e=>be(e.swift))}}),ue.of({name:"sTeX",load(){return de(()=>Promise.resolve().then(()=>QL),void 0,import.meta.url).then(e=>be(e.stex))}}),ue.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return de(()=>Promise.resolve().then(()=>QL),void 0,import.meta.url).then(e=>be(e.stex))}}),ue.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return de(()=>Promise.resolve().then(()=>DL),void 0,import.meta.url).then(e=>be(e.verilog))}}),ue.of({name:"Tcl",extensions:["tcl"],load(){return de(()=>Promise.resolve().then(()=>wbt),void 0,import.meta.url).then(e=>be(e.tcl))}}),ue.of({name:"Textile",extensions:["textile"],load(){return de(()=>Promise.resolve().then(()=>kbt),void 0,import.meta.url).then(e=>be(e.textile))}}),ue.of({name:"TiddlyWiki",load(){return de(()=>Promise.resolve().then(()=>Mbt),void 0,import.meta.url).then(e=>be(e.tiddlyWiki))}}),ue.of({name:"Tiki wiki",load(){return de(()=>Promise.resolve().then(()=>e1t),void 0,import.meta.url).then(e=>be(e.tiki))}}),ue.of({name:"TOML",extensions:["toml"],load(){return de(()=>Promise.resolve().then(()=>t1t),void 0,import.meta.url).then(e=>be(e.toml))}}),ue.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return de(()=>Promise.resolve().then(()=>i1t),void 0,import.meta.url).then(e=>be(e.troff))}}),ue.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return de(()=>Promise.resolve().then(()=>w1t),void 0,import.meta.url).then(e=>be(e.ttcn))}}),ue.of({name:"TTCN_CFG",extensions:["cfg"],load(){return de(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>be(e.ttcnCfg))}}),ue.of({name:"Turtle",extensions:["ttl"],load(){return de(()=>Promise.resolve().then(()=>Q1t),void 0,import.meta.url).then(e=>be(e.turtle))}}),ue.of({name:"Web IDL",extensions:["webidl"],load(){return de(()=>Promise.resolve().then(()=>$wt),void 0,import.meta.url).then(e=>be(e.webIDL))}}),ue.of({name:"VB.NET",extensions:["vb"],load(){return de(()=>Promise.resolve().then(()=>Y1t),void 0,import.meta.url).then(e=>be(e.vb))}}),ue.of({name:"VBScript",extensions:["vbs"],load(){return de(()=>Promise.resolve().then(()=>N1t),void 0,import.meta.url).then(e=>be(e.vbScript))}}),ue.of({name:"Velocity",extensions:["vtl"],load(){return de(()=>Promise.resolve().then(()=>D1t),void 0,import.meta.url).then(e=>be(e.velocity))}}),ue.of({name:"Verilog",extensions:["v"],load(){return de(()=>Promise.resolve().then(()=>DL),void 0,import.meta.url).then(e=>be(e.verilog))}}),ue.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return de(()=>Promise.resolve().then(()=>ewt),void 0,import.meta.url).then(e=>be(e.vhdl))}}),ue.of({name:"XQuery",extensions:["xy","xquery"],load(){return de(()=>Promise.resolve().then(()=>Twt),void 0,import.meta.url).then(e=>be(e.xQuery))}}),ue.of({name:"Yacas",extensions:["ys"],load(){return de(()=>Promise.resolve().then(()=>Uwt),void 0,import.meta.url).then(e=>be(e.yacas))}}),ue.of({name:"Z80",extensions:["z80"],load(){return de(()=>Promise.resolve().then(()=>Zwt),void 0,import.meta.url).then(e=>be(e.z80))}}),ue.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return de(()=>Promise.resolve().then(()=>z_),void 0,import.meta.url).then(e=>be(e.mscgen))}}),ue.of({name:"Xù",extensions:["xu"],load(){return de(()=>Promise.resolve().then(()=>z_),void 0,import.meta.url).then(e=>be(e.xu))}}),ue.of({name:"MsGenny",extensions:["msgenny"],load(){return de(()=>Promise.resolve().then(()=>z_),void 0,import.meta.url).then(e=>be(e.msgenny))}}),ue.of({name:"Vue",extensions:["vue"],load(){return de(()=>Promise.resolve().then(()=>Jut),void 0,import.meta.url).then(e=>e.vue())}}),ue.of({name:"Angular Template",load(){return de(()=>Promise.resolve().then(()=>$Ot),void 0,import.meta.url).then(e=>e.angular())}})];class t9{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=In(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),a=i.search(Zfe(t,!1));return a<0?null:{from:r+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function bI(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function _Ke(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let a=1;a<i.length;a++)n[i[a]]=!0}let r=bI(t)+bI(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Zy(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:_Ke(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function GQ(e,t){return n=>{for(let r=In(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class wI{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function kd(e){return e.selection.main.from}function Zfe(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",a=r[r.length-1]!="$";return!i&&!a?e:new RegExp(`${i?"^":""}(?:${r})${a?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const n9=mf.define();function XKe(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ye.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const SI=new WeakMap;function RKe(e){if(!Array.isArray(e))return e;let t=SI.get(e);return t||SI.set(e,t=Zy(e)),t}const nS=xn.define(),b$=xn.define();class EKe{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=no(t,n),i=pc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(no(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let v=no(t,0),w=pc(v),x=w==t.length?0:-100;if(v!=n[0])if(v==r[0])x+=-200;else return null;return this.ret(x,[0,w])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let v=0,w=Math.min(t.length,200);v<w&&c<l;){let x=no(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=pc(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),$=!0;for(let v=0,w=Math.min(t.length,200),x=0;v<w&&O<l;){let b=no(t,v);s<0&&(u<l&&b==n[u]&&(a[u++]=v),f<l&&(b==n[f]||b==r[f]?(f==0&&(p=v),m=v+1,f++):f=0));let S,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(S=ede(b))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!v||Q==1&&g||x==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&($=!1)),x=Q,v+=pc(b)}return O==l&&o[0]==0&&$?this.result(-100+(d?-200:0),o,t):f==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):f==l?this.ret(-900-t.length,[p,m]):O==l?this.result(-100+(d?-200:0)+-700+($?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let o of n){let s=o+(this.astral?pc(no(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class qKe{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const pi=Ot.define({combine(e){return lm(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:jKe,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>xI(t(r),n(r)),optionClass:(t,n)=>r=>xI(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function xI(e,t){return e?t?e+" "+t:e:t}function jKe(e,t,n,r,i,a){let o=e.textDirection==gr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,f)?s=!1:!s&&f<Math.min(p,d)&&(s=!0),p<=(s?d:f))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:f);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,$=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/$}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function CKe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,a){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&o.appendChild(document.createTextNode(s.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(s.slice(u,O))),d.className="cm-completionMatchedText",l=O}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function RT(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class zKe{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:a,selected:o}=i.open,s=t.state.facet(pi);this.optionContent=CKe(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=RT(a.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,O;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(O=/-(\d+)$/.exec(u.id))&&+O[1]<c.length){this.applyCompletion(t,c[+O[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(pi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:b$.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:a,selected:o,disabled:s}=r.open;(!i.open||i.open.options!=a)&&(this.range=RT(a.length,o,t.state.facet(pi).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),s!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=RT(n.options.length,n.selected,this.view.state.facet(pi).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let a=typeof i=="string"?document.createTextNode(i):i(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Xa(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&UKe(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(a.bottom,n.bottom)-10||i.bottom<Math.max(a.top,n.top)+10?null:this.view.state.facet(pi).positionInfo(this.view,n,i,r,a,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let a=null;for(let o=r.from;o<r.to;o++){let{completion:s,match:l}=t[o],{section:c}=s;if(c){let d=typeof c=="string"?c:c.name;if(d!=a&&(o>r.from||r.from==0))if(a=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let O=this.optionClass(s);O&&(u.className=O);for(let d of this.optionContent){let f=d(s,this.view.state,this.view,l);f&&u.appendChild(f)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function AKe(e,t){return n=>new zKe(n,e,t)}function UKe(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function QI(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function WKe(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let O=typeof u=="string"?u:u.name;r.some(d=>d.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(pi);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let O of c.result.options)i(new wI(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new qKe(O):new EKe(O);for(let p of c.result.options)if(d=f.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new wI(p,c.source,m,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,f)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=f.rank)!==null&&m!==void 0?m:1e9)||(d.name<f.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.name])}}let o=[],s=null,l=a.compareCompletions;for(let c of n.sort((u,O)=>O.score-u.score||l(u.completion,O.completion))){let u=c.completion;!s||s.label!=u.label||s.detail!=u.detail||s.type!=null&&u.type!=null&&s.type!=u.type||s.apply!=u.apply||s.boost!=u.boost?o.push(c):QI(c.completion)>QI(s)&&(o[o.length-1]=c),s=c.completion}return o}class $h{constructor(t,n,r,i,a,o){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=o}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new $h(this.options,kI(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(c=>c.isPending))return i.setDisabled();let s=WKe(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(pi).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<s.length;u++)if(s[u].completion==c){l=u;break}}return new $h(s,kI(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:DKe,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new $h(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new $h(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class rS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new rS(ZKe,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(pi),a=(r.override||n.languageDataAt("autocomplete",kd(n)).map(RKe)).map(l=>(this.active.find(u=>u.source==l)||new Zo(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(r9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!YKe(a,this.active)||s?o=$h.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new Zo(l.source,0):l));for(let l of t.effects)l.is(Dfe)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new rS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?GKe:NKe}}function YKe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}const GKe={"aria-autocomplete":"list"},NKe={};function kI(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const ZKe=[];function Ife(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(n9);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Zo{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Ife(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Zo(i.source,0)),r&4&&i.state==0&&(i=new Zo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(nS))i=new Zo(i.source,1,a.value);else if(a.is(b$))i=new Zo(i.source,0);else if(a.is(r9))for(let o of a.value)o.source==i.source&&(i=o);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(kd(t.state))}}class Uh extends Zo{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=kd(t.state);if(s>o||!i||n&2&&(kd(t.startState)==this.from||s<this.limit))return new Zo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return IKe(i.validFor,t.state,a,o)?new Uh(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new t9(t.state,s,!1)))?new Uh(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:kd(t.state)):new Zo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Uh(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Zo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function IKe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Zfe(e,!0).test(i)}const r9=xn.define({map(e,t){return e.map(n=>n.map(t))}}),Dfe=xn.define(),Ta=Aa.define({create(){return rS.start()},update(e,t){return e.update(t)},provide:e=>[Lz.from(e,t=>t.tooltip),vt.contentAttributes.from(e,t=>t.attrs)]});function i9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ta).active.find(i=>i.source==t.source);return r instanceof Uh?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},XKe(e.state,n,r.from,r.to)),{annotations:n9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const DKe=AKe(Ta,i9);function mb(e,t="option"){return n=>{let r=n.state.field(Ta,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(pi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=pfe(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t=="page"?0:o-1:s>=o&&(s=t=="page"?o-1:0),n.dispatch({effects:Dfe.of(s)}),!0}}const VKe=e=>{let t=e.state.field(Ta,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(pi).interactionDelay?!1:i9(e,t.open.options[t.open.selected])},PI=e=>e.state.field(Ta,!1)?(e.dispatch({effects:nS.of(!0)}),!0):!1,MKe=e=>{let t=e.state.field(Ta,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:b$.of(null)}),!0)};class LKe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const FKe=50,BKe=1e3,HKe=oi.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Ta).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ta),n=e.state.facet(pi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ta)==t)return;let r=e.transactions.some(a=>{let o=Ife(a,n);return o&8||(a.selection||a.docChanged)&&!(o&3)});for(let a=0;a<this.running.length;a++){let o=this.running[a];if(r||o.context.abortOnDocChange&&e.docChanged||o.updates.length+e.transactions.length>FKe&&Date.now()-o.time>BKe){for(let s of o.context.abortListeners)try{s()}catch(l){Xa(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(nS)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(o=>o.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of e.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Ta);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=kd(t),r=new t9(t,n,e.explicit,this.view),i=new LKe(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:b$.of(null)}),Xa(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(pi),r=this.view.state.field(Ta);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=kd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Uh(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new Zo(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:r9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ta,!1);if(t&&t.tooltip&&this.view.state.facet(pi).closeOnBlur){let n=t.open&&pfe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:b$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:nS.of(!1)}),20),this.composing=0}}}),KKe=typeof navigator=="object"&&/Win/.test(navigator.platform),JKe=bO.highest(vt.domEventHandlers({keydown(e,t){let n=t.state.field(Ta,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(KKe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&i9(t,r),!1}})),Vfe=vt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class eJe{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class a9{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Pi.TrackDel),r=t.mapPos(this.to,1,Pi.TrackDel);return n==null||r==null?null:new a9(this.field,n,r)}}class o9{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(UQ);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let s=this.fieldPositions.map(l=>new a9(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:s}}static parse(t){let n=[],r=[],i=[],a;for(let o of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let s=a[1]?+a[1]:null,l=a[2]||a[3]||"",c=-1,u=l.replace(/\\[{}]/g,O=>O[1]);for(let O=0;O<n.length;O++)(s!=null?n[O].seq==s:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(s==null||n[O].seq!=null&&n[O].seq<s);)O++;n.splice(O,0,{seq:s,name:u}),c=O;for(let d of i)d.field>=c&&d.field++}i.push(new eJe(c,r.length,a.index,a.index+u.length)),o=o.slice(0,a.index)+l+o.slice(a.index+a[0].length)}o=o.replace(/\\([{}])/g,(s,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(o)}return new o9(r,i)}}let tJe=ln.widget({widget:new class extends eu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),nJe=ln.mark({class:"cm-snippetField"});class cm{constructor(t,n){this.ranges=t,this.active=n,this.deco=ln.set(t.map(r=>(r.from==r.to?tJe:nJe).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new cm(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const Iy=xn.define({map(e,t){return e&&e.map(t)}}),rJe=xn.define(),w$=Aa.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Iy))return n.value;if(n.is(rJe)&&e)return new cm(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>vt.decorations.from(e,t=>t?t.deco:ln.none)});function s9(e,t){return Ye.create(e.filter(n=>n.field==t).map(n=>Ye.range(n.from,n.to)))}function iJe(e){let t=o9.parse(e);return(n,r,i,a)=>{let{text:o,ranges:s}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:Zn.of(o)},scrollIntoView:!0,annotations:r?[n9.of(r),_i.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=s9(s,0)),s.some(u=>u.field>0)){let u=new cm(s,0),O=c.effects=[Iy.of(u)];n.state.field(w$,!1)===void 0&&O.push(xn.appendConfig.of([w$,cJe,uJe,Vfe]))}n.dispatch(n.state.update(c))}}function Mfe(e){return({state:t,dispatch:n})=>{let r=t.field(w$,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(o=>o.field==i+e);return n(t.update({selection:s9(r.ranges,i),effects:Iy.of(a?null:new cm(r.ranges,i)),scrollIntoView:!0})),!0}}const aJe=({state:e,dispatch:t})=>e.field(w$,!1)?(t(e.update({effects:Iy.of(null)})),!0):!1,oJe=Mfe(1),sJe=Mfe(-1),lJe=[{key:"Tab",run:oJe,shift:sJe},{key:"Escape",run:aJe}],TI=Ot.define({combine(e){return e.length?e[0]:lJe}}),cJe=bO.highest(CQ.compute([TI],e=>e.facet(TI)));function dr(e,t){return Object.assign(Object.assign({},t),{apply:iJe(e)})}const uJe=vt.domEventHandlers({mousedown(e,t){let n=t.state.field(w$,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(a=>a.from<=r&&a.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:s9(n.ranges,i.field),effects:Iy.of(n.ranges.some(a=>a.field>i.field)?new cm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),S$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},fd=xn.define({map(e,t){let n=t.mapPos(e,-1,Pi.TrackAfter);return n??void 0}}),l9=new class extends Zd{};l9.startSide=1;l9.endSide=-1;const Lfe=Aa.define({create(){return Sn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(fd)&&(e=e.update({add:[l9.range(n.value,n.value+1)]}));return e}});function aen(){return[dJe,Lfe]}const ET="()[]{}<>«»»«[]{}";function Ffe(e){for(let t=0;t<ET.length;t+=2)if(ET.charCodeAt(t)==e)return ET.charAt(t+1);return ede(e<128?e:e+1)}function Bfe(e,t){return e.languageDataAt("closeBrackets",t)[0]||S$}const OJe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),dJe=vt.inputHandler.of((e,t,n,r)=>{if((OJe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&pc(no(r,0))==1||t!=i.from||n!=i.to)return!1;let a=hJe(e.state,r);return a?(e.dispatch(a),!0):!1}),fJe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Bfe(e,e.selection.main.head).brackets||S$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=pJe(e.doc,o.head);for(let l of r)if(l==s&&NQ(e.doc,o.head)==Ffe(no(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ye.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},oen=[{key:"Backspace",run:fJe}];function hJe(e,t){let n=Bfe(e,e.selection.main.head),r=n.brackets||S$.brackets;for(let i of r){let a=Ffe(no(i,0));if(t==i)return a==i?$Je(e,i,r.indexOf(i+i+i)>-1,n):mJe(e,i,a,n.before||S$.before);if(t==a&&Hfe(e,e.selection.main.from))return gJe(e,i,a)}return null}function Hfe(e,t){let n=!1;return e.field(Lfe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function NQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,pc(no(n,0)))}function pJe(e,t){let n=e.sliceString(t-2,t);return pc(no(n,0))==n.length?n:n.slice(1)}function mJe(e,t,n,r){let i=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:fd.of(o.to+t.length),range:Ye.range(o.anchor+t.length,o.head+t.length)};let s=NQ(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:fd.of(o.head+t.length),range:Ye.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function gJe(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&NQ(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ye.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function $Je(e,t,n,r){let i=r.stringPrefixes||S$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:fd.of(s.to+t.length),range:Ye.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=NQ(e.doc,l),u;if(c==t){if(_I(e,l))return{changes:{insert:t+t,from:l},effects:fd.of(l+t.length),range:Ye.cursor(l+t.length)};if(Hfe(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ye.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=XI(e,l-2*t.length,i))>-1&&_I(e,u))return{changes:{insert:t+t+t+t,from:l},effects:fd.of(l+t.length),range:Ye.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=No.Word&&XI(e,l,i)>-1&&!yJe(e,l,t,i))return{changes:{insert:t+t,from:l},effects:fd.of(l+t.length),range:Ye.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function _I(e,t){let n=In(e).resolveInner(t+1);return n.parent&&n.from==t}function yJe(e,t,n,r){let i=In(e).resolveInner(t,-1),a=r.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function XI(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=No.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=No.Word)return a}return-1}function sen(e={}){return[JKe,Ta,pi.of(e),HKe,bJe,Vfe]}const vJe=[{key:"Ctrl-Space",run:PI},{mac:"Alt-`",run:PI},{key:"Escape",run:MKe},{key:"ArrowDown",run:mb(!0)},{key:"ArrowUp",run:mb(!1)},{key:"PageDown",run:mb(!0,"page")},{key:"PageUp",run:mb(!1,"page")},{key:"Enter",run:VKe}],bJe=bO.highest(CQ.computeN([pi],e=>e.facet(pi).defaultKeymap?[vJe]:[]));class iS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new iS(t,n,r,o,a,[],[])}constructor(t,n,r,i,a,o,s){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=o,this.positions=s,this.hashProp=[[Ut.contextHash,i]]}addChild(t,n){t.prop(Ut.contextHash)!=this.hash&&(t=new hn(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new hn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new hn(Hr.none,i,a,o,this.hashProp)})}}var Ne;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(Ne||(Ne={}));class wJe{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let SJe=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return f0(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}};function RI(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==Ne.OrderedList?O9:u9)(n,t,!1);return r>0&&(e.type!=Ne.BulletList||c9(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const Kfe={[Ne.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push($n(Ne.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(is(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ne.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ne.OrderedList]:RI,[Ne.BulletList]:RI,[Ne.Document](){return!0}};function is(e){return e==32||e==9||e==10||e==13}function f0(e,t=0){for(;t<e.length&&is(e.charCodeAt(t));)t++;return t}function EI(e,t,n){for(;t>n&&is(e.charCodeAt(t-1));)t--;return t}function Jfe(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function ehe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function c9(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!is(a))return-1}return n&&e.next==45&&rhe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(she.SetextHeading)>-1||r<3?-1:1}function the(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function u9(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||is(e.text.charCodeAt(e.pos+1)))&&(!n||the(t,Ne.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function O9(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!is(e.text.charCodeAt(r+1))||n&&!the(t,Ne.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function nhe(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function rhe(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&is(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const Aq=/^[ \t]*$/,ihe=/-->/,ahe=/\?>/,Uq=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ihe],[/^\s*<\?/,ahe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?: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|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Aq],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Aq]];function ohe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=Uq.length-(n?1:0);i<a;i++)if(Uq[i][0].test(r))return i;return-1}function qI(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function ZO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ne.CodeText?e[r].to=n:e.push($n(Ne.CodeText,t,n))}const gb={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(ZO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){ZO(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==Ne.CodeText?ZO(o,c.from,c.to):o.push(c);s=[]}ZO(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&ZO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ne.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ne.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Jfe(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=EI(t.text,t.text.length,o),l=[$n(Ne.CodeMark,r,r+a)];o<s&&l.push($n(Ne.CodeInfo,e.lineStart+o,e.lineStart+s));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=a&&t.skipSpace(u)==t.text.length){for(let O of t.markers)l.push(O);l.push($n(Ne.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||ZO(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&ZO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ne.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=ehe(t);return n<0?!1:(e.startContext(Ne.Blockquote,t.pos),e.addNode(Ne.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(c9(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ne.HorizontalRule,n),!0},BulletList(e,t){let n=u9(t,e,!1);if(n<0)return!1;e.block.type!=Ne.BulletList&&e.startContext(Ne.BulletList,t.basePos,t.next);let r=qI(t,t.pos+1);return e.startContext(Ne.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ne.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=O9(t,e,!1);if(n<0)return!1;e.block.type!=Ne.OrderedList&&e.startContext(Ne.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=qI(t,t.pos+n);return e.startContext(Ne.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ne.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=nhe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=EI(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!is(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ne.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ne.HeaderMark,o-r,a-r);let l=s.finish(Ne.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=ohe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=Uq[n][1],a=[],o=i!=Aq;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let c of t.markers)a.push(c)}o&&e.nextLine();let s=i==ihe?Ne.CommentBlock:i==ahe?Ne.ProcessingInstructionBlock:Ne.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class xJe{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
|
|
787
|
+
`);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let a=this.ranges[i].to;if(a>=r||(n=n.slice(0,a-(r-n.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,s=this.lineAfter(o);n+=s,r=o+s.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,a=t+n;if(r>0?i>a:i>=a)break;let o=this.ranges[++this.rangeIndex].from;n+=o-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let a=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let s=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-s}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==n?this.chunk[o+2]=r:this.chunk.push(t,n,r,a),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:a}=this.lang,o=new Afe(n,t?t.state.tabSize:4,t?Jw(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Wfe(a.token,o,this.state);if(s&&(i=this.emitToken(this.lang.tokenTable.resolve(s),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=hn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:QKe,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new hn(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new hn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Wfe(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const e9=Object.create(null),v$=[Hr.none],QKe=new sm(v$),yI=[],vI=Object.create(null),Yfe=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Yfe[e]=Nfe(e9,t);class Gfe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Yfe)}resolve(t){return t?this.table[t]||(this.table[t]=Nfe(this.extra,t)):0}}const kKe=new Gfe(e9);function XT(e,t){yI.indexOf(e)>-1||(yI.push(e),console.warn(t))}function Nfe(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||k[c];u?typeof u=="function"?l.length?l=l.map(u):XT(c,`Modifier ${c} used at start of tag`):l.length?XT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:XT(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=vI[i];if(a)return a.id;let o=vI[i]=Hr.define({id:v$.length,name:r,props:[Xn({[r]:n})]});return v$.push(o),o.id}function PKe(e,t){let n=Hr.define({id:v$.length,name:"Document",props:[Nu.add(()=>e),Pr.add(()=>r=>t.getIndent(r))],top:!0});return v$.push(n),n}gr.RTL,gr.LTR;function be(e){return new vn(Pe.define(e))}function gu(e){return de(()=>Promise.resolve().then(()=>Jst),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const TKe=[ue.of({name:"C",extensions:["c","h","ino"],load(){return de(()=>Promise.resolve().then(()=>OV),void 0,import.meta.url).then(e=>e.cpp())}}),ue.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return de(()=>Promise.resolve().then(()=>OV),void 0,import.meta.url).then(e=>e.cpp())}}),ue.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return gu("Cassandra")}}),ue.of({name:"CSS",extensions:["css"],load(){return de(()=>Promise.resolve().then(()=>htt),void 0,import.meta.url).then(e=>e.css())}}),ue.of({name:"Go",extensions:["go"],load(){return de(()=>import("./index-dDgWp_lK.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),ue.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return de(()=>Promise.resolve().then(()=>ant),void 0,import.meta.url).then(e=>e.html())}}),ue.of({name:"Java",extensions:["java"],load(){return de(()=>Promise.resolve().then(()=>rlt),void 0,import.meta.url).then(e=>e.java())}}),ue.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return de(()=>Promise.resolve().then(()=>yb),void 0,import.meta.url).then(e=>e.javascript())}}),ue.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return de(()=>Promise.resolve().then(()=>urt),void 0,import.meta.url).then(e=>e.json())}}),ue.of({name:"JSX",extensions:["jsx"],load(){return de(()=>Promise.resolve().then(()=>yb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ue.of({name:"LESS",extensions:["less"],load(){return de(()=>Promise.resolve().then(()=>knt),void 0,import.meta.url).then(e=>e.less())}}),ue.of({name:"Liquid",extensions:["liquid"],load(){return de(()=>Promise.resolve().then(()=>Nut),void 0,import.meta.url).then(e=>e.liquid())}}),ue.of({name:"MariaDB SQL",load(){return gu("MariaSQL")}}),ue.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return de(()=>Promise.resolve().then(()=>pnt),void 0,import.meta.url).then(e=>e.markdown())}}),ue.of({name:"MS SQL",load(){return gu("MSSQL")}}),ue.of({name:"MySQL",load(){return gu("MySQL")}}),ue.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return de(()=>Promise.resolve().then(()=>yut),void 0,import.meta.url).then(e=>e.php())}}),ue.of({name:"PLSQL",extensions:["pls"],load(){return gu("PLSQL")}}),ue.of({name:"PostgreSQL",load(){return gu("PostgreSQL")}}),ue.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return de(()=>Promise.resolve().then(()=>Not),void 0,import.meta.url).then(e=>e.python())}}),ue.of({name:"Rust",extensions:["rs"],load(){return de(()=>Promise.resolve().then(()=>Slt),void 0,import.meta.url).then(e=>e.rust())}}),ue.of({name:"Sass",extensions:["sass"],load(){return de(()=>Promise.resolve().then(()=>kD),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ue.of({name:"SCSS",extensions:["scss"],load(){return de(()=>Promise.resolve().then(()=>kD),void 0,import.meta.url).then(e=>e.sass())}}),ue.of({name:"SQL",extensions:["sql"],load(){return gu("StandardSQL")}}),ue.of({name:"SQLite",load(){return gu("SQLite")}}),ue.of({name:"TSX",extensions:["tsx"],load(){return de(()=>Promise.resolve().then(()=>yb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ue.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return de(()=>Promise.resolve().then(()=>yb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ue.of({name:"WebAssembly",extensions:["wat","wast"],load(){return de(()=>Promise.resolve().then(()=>Dut),void 0,import.meta.url).then(e=>e.wast())}}),ue.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return de(()=>Promise.resolve().then(()=>ust),void 0,import.meta.url).then(e=>e.xml())}}),ue.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return de(()=>import("./index-BCtcy-Az.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),ue.of({name:"APL",extensions:["dyalog","apl"],load(){return de(()=>Promise.resolve().then(()=>vft),void 0,import.meta.url).then(e=>be(e.apl))}}),ue.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return de(()=>Promise.resolve().then(()=>bft),void 0,import.meta.url).then(e=>be(e.asciiArmor))}}),ue.of({name:"ASN.1",extensions:["asn","asn1"],load(){return de(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>be(e.asn1({})))}}),ue.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return de(()=>Promise.resolve().then(()=>kft),void 0,import.meta.url).then(e=>be(e.asterisk))}}),ue.of({name:"Brainfuck",extensions:["b","bf"],load(){return de(()=>Promise.resolve().then(()=>Tft),void 0,import.meta.url).then(e=>be(e.brainfuck))}}),ue.of({name:"Cobol",extensions:["cob","cpy"],load(){return de(()=>Promise.resolve().then(()=>nht),void 0,import.meta.url).then(e=>be(e.cobol))}}),ue.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.csharp))}}),ue.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>be(e.clojure))}}),ue.of({name:"ClojureScript",extensions:["cljs"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>be(e.clojure))}}),ue.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return de(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>be(e.gss))}}),ue.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return de(()=>Promise.resolve().then(()=>Mft),void 0,import.meta.url).then(e=>be(e.cmake))}}),ue.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return de(()=>Promise.resolve().then(()=>pht),void 0,import.meta.url).then(e=>be(e.coffeeScript))}}),ue.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return de(()=>Promise.resolve().then(()=>bht),void 0,import.meta.url).then(e=>be(e.commonLisp))}}),ue.of({name:"Cypher",extensions:["cyp","cypher"],load(){return de(()=>Promise.resolve().then(()=>Wht),void 0,import.meta.url).then(e=>be(e.cypher))}}),ue.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return de(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>be(e.cython))}}),ue.of({name:"Crystal",extensions:["cr"],load(){return de(()=>Promise.resolve().then(()=>qht),void 0,import.meta.url).then(e=>be(e.crystal))}}),ue.of({name:"D",extensions:["d"],load(){return de(()=>Promise.resolve().then(()=>Vht),void 0,import.meta.url).then(e=>be(e.d))}}),ue.of({name:"Dart",extensions:["dart"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.dart))}}),ue.of({name:"diff",extensions:["diff","patch"],load(){return de(()=>Promise.resolve().then(()=>Mht),void 0,import.meta.url).then(e=>be(e.diff))}}),ue.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return de(()=>Promise.resolve().then(()=>opt),void 0,import.meta.url).then(e=>be(e.dockerFile))}}),ue.of({name:"DTD",extensions:["dtd"],load(){return de(()=>Promise.resolve().then(()=>cpt),void 0,import.meta.url).then(e=>be(e.dtd))}}),ue.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return de(()=>Promise.resolve().then(()=>hpt),void 0,import.meta.url).then(e=>be(e.dylan))}}),ue.of({name:"EBNF",load(){return de(()=>Promise.resolve().then(()=>ppt),void 0,import.meta.url).then(e=>be(e.ebnf))}}),ue.of({name:"ECL",extensions:["ecl"],load(){return de(()=>Promise.resolve().then(()=>Spt),void 0,import.meta.url).then(e=>be(e.ecl))}}),ue.of({name:"edn",extensions:["edn"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>be(e.clojure))}}),ue.of({name:"Eiffel",extensions:["e"],load(){return de(()=>Promise.resolve().then(()=>_pt),void 0,import.meta.url).then(e=>be(e.eiffel))}}),ue.of({name:"Elm",extensions:["elm"],load(){return de(()=>Promise.resolve().then(()=>Ypt),void 0,import.meta.url).then(e=>be(e.elm))}}),ue.of({name:"Erlang",extensions:["erl"],load(){return de(()=>Promise.resolve().then(()=>umt),void 0,import.meta.url).then(e=>be(e.erlang))}}),ue.of({name:"Esper",load(){return de(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>be(e.esper))}}),ue.of({name:"Factor",extensions:["factor"],load(){return de(()=>Promise.resolve().then(()=>Omt),void 0,import.meta.url).then(e=>be(e.factor))}}),ue.of({name:"FCL",load(){return de(()=>Promise.resolve().then(()=>mmt),void 0,import.meta.url).then(e=>be(e.fcl))}}),ue.of({name:"Forth",extensions:["forth","fth","4th"],load(){return de(()=>Promise.resolve().then(()=>ymt),void 0,import.meta.url).then(e=>be(e.forth))}}),ue.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return de(()=>Promise.resolve().then(()=>kmt),void 0,import.meta.url).then(e=>be(e.fortran))}}),ue.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>be(e.fSharp))}}),ue.of({name:"Gas",extensions:["s"],load(){return de(()=>Promise.resolve().then(()=>Tmt),void 0,import.meta.url).then(e=>be(e.gas))}}),ue.of({name:"Gherkin",extensions:["feature"],load(){return de(()=>Promise.resolve().then(()=>_mt),void 0,import.meta.url).then(e=>be(e.gherkin))}}),ue.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return de(()=>Promise.resolve().then(()=>Ymt),void 0,import.meta.url).then(e=>be(e.groovy))}}),ue.of({name:"Haskell",extensions:["hs"],load(){return de(()=>Promise.resolve().then(()=>Mmt),void 0,import.meta.url).then(e=>be(e.haskell))}}),ue.of({name:"Haxe",extensions:["hx"],load(){return de(()=>Promise.resolve().then(()=>jM),void 0,import.meta.url).then(e=>be(e.haxe))}}),ue.of({name:"HXML",extensions:["hxml"],load(){return de(()=>Promise.resolve().then(()=>jM),void 0,import.meta.url).then(e=>be(e.hxml))}}),ue.of({name:"HTTP",load(){return de(()=>Promise.resolve().then(()=>mgt),void 0,import.meta.url).then(e=>be(e.http))}}),ue.of({name:"IDL",extensions:["pro"],load(){return de(()=>Promise.resolve().then(()=>Sgt),void 0,import.meta.url).then(e=>be(e.idl))}}),ue.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return de(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>be(e.jsonld))}}),ue.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return de(()=>Promise.resolve().then(()=>Pgt),void 0,import.meta.url).then(e=>be(e.jinja2))}}),ue.of({name:"Julia",extensions:["jl"],load(){return de(()=>Promise.resolve().then(()=>Kgt),void 0,import.meta.url).then(e=>be(e.julia))}}),ue.of({name:"Kotlin",extensions:["kt","kts"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.kotlin))}}),ue.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return de(()=>Promise.resolve().then(()=>n0t),void 0,import.meta.url).then(e=>be(e.liveScript))}}),ue.of({name:"Lua",extensions:["lua"],load(){return de(()=>Promise.resolve().then(()=>u0t),void 0,import.meta.url).then(e=>be(e.lua))}}),ue.of({name:"mIRC",extensions:["mrc"],load(){return de(()=>Promise.resolve().then(()=>q0t),void 0,import.meta.url).then(e=>be(e.mirc))}}),ue.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return de(()=>Promise.resolve().then(()=>$0t),void 0,import.meta.url).then(e=>be(e.mathematica))}}),ue.of({name:"Modelica",extensions:["mo"],load(){return de(()=>Promise.resolve().then(()=>Z0t),void 0,import.meta.url).then(e=>be(e.modelica))}}),ue.of({name:"MUMPS",extensions:["mps"],load(){return de(()=>Promise.resolve().then(()=>a$t),void 0,import.meta.url).then(e=>be(e.mumps))}}),ue.of({name:"Mbox",extensions:["mbox"],load(){return de(()=>Promise.resolve().then(()=>X0t),void 0,import.meta.url).then(e=>be(e.mbox))}}),ue.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return de(()=>Promise.resolve().then(()=>u$t),void 0,import.meta.url).then(e=>be(e.nginx))}}),ue.of({name:"NSIS",extensions:["nsh","nsi"],load(){return de(()=>Promise.resolve().then(()=>O$t),void 0,import.meta.url).then(e=>be(e.nsis))}}),ue.of({name:"NTriples",extensions:["nt","nq"],load(){return de(()=>Promise.resolve().then(()=>d$t),void 0,import.meta.url).then(e=>be(e.ntriples))}}),ue.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.objectiveC))}}),ue.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.objectiveCpp))}}),ue.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>be(e.oCaml))}}),ue.of({name:"Octave",extensions:["m"],load(){return de(()=>Promise.resolve().then(()=>S$t),void 0,import.meta.url).then(e=>be(e.octave))}}),ue.of({name:"Oz",extensions:["oz"],load(){return de(()=>Promise.resolve().then(()=>C$t),void 0,import.meta.url).then(e=>be(e.oz))}}),ue.of({name:"Pascal",extensions:["p","pas"],load(){return de(()=>Promise.resolve().then(()=>G$t),void 0,import.meta.url).then(e=>be(e.pascal))}}),ue.of({name:"Perl",extensions:["pl","pm"],load(){return de(()=>Promise.resolve().then(()=>N$t),void 0,import.meta.url).then(e=>be(e.perl))}}),ue.of({name:"Pig",extensions:["pig"],load(){return de(()=>Promise.resolve().then(()=>D$t),void 0,import.meta.url).then(e=>be(e.pig))}}),ue.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return de(()=>Promise.resolve().then(()=>syt),void 0,import.meta.url).then(e=>be(e.powerShell))}}),ue.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return de(()=>Promise.resolve().then(()=>lyt),void 0,import.meta.url).then(e=>be(e.properties))}}),ue.of({name:"ProtoBuf",extensions:["proto"],load(){return de(()=>Promise.resolve().then(()=>fyt),void 0,import.meta.url).then(e=>be(e.protobuf))}}),ue.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return de(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>be(e.pug))}}),ue.of({name:"Puppet",extensions:["pp"],load(){return de(()=>Promise.resolve().then(()=>myt),void 0,import.meta.url).then(e=>be(e.puppet))}}),ue.of({name:"Q",extensions:["q"],load(){return de(()=>Promise.resolve().then(()=>xyt),void 0,import.meta.url).then(e=>be(e.q))}}),ue.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return de(()=>Promise.resolve().then(()=>Ryt),void 0,import.meta.url).then(e=>be(e.r))}}),ue.of({name:"RPM Changes",load(){return de(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>be(e.rpmChanges))}}),ue.of({name:"RPM Spec",extensions:["spec"],load(){return de(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>be(e.rpmSpec))}}),ue.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return de(()=>Promise.resolve().then(()=>Yyt),void 0,import.meta.url).then(e=>be(e.ruby))}}),ue.of({name:"SAS",extensions:["sas"],load(){return de(()=>Promise.resolve().then(()=>Iyt),void 0,import.meta.url).then(e=>be(e.sas))}}),ue.of({name:"Scala",extensions:["scala"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.scala))}}),ue.of({name:"Scheme",extensions:["scm","ss"],load(){return de(()=>Promise.resolve().then(()=>rvt),void 0,import.meta.url).then(e=>be(e.scheme))}}),ue.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return de(()=>Promise.resolve().then(()=>svt),void 0,import.meta.url).then(e=>be(e.shell))}}),ue.of({name:"Sieve",extensions:["siv","sieve"],load(){return de(()=>Promise.resolve().then(()=>dvt),void 0,import.meta.url).then(e=>be(e.sieve))}}),ue.of({name:"Smalltalk",extensions:["st"],load(){return de(()=>Promise.resolve().then(()=>pvt),void 0,import.meta.url).then(e=>be(e.smalltalk))}}),ue.of({name:"Solr",load(){return de(()=>Promise.resolve().then(()=>wvt),void 0,import.meta.url).then(e=>be(e.solr))}}),ue.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>be(e.sml))}}),ue.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return de(()=>Promise.resolve().then(()=>_vt),void 0,import.meta.url).then(e=>be(e.sparql))}}),ue.of({name:"Spreadsheet",alias:["excel","formula"],load(){return de(()=>Promise.resolve().then(()=>Xvt),void 0,import.meta.url).then(e=>be(e.spreadsheet))}}),ue.of({name:"Squirrel",extensions:["nut"],load(){return de(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url).then(e=>be(e.squirrel))}}),ue.of({name:"Stylus",extensions:["styl"],load(){return de(()=>Promise.resolve().then(()=>Kvt),void 0,import.meta.url).then(e=>be(e.stylus))}}),ue.of({name:"Swift",extensions:["swift"],load(){return de(()=>Promise.resolve().then(()=>$bt),void 0,import.meta.url).then(e=>be(e.swift))}}),ue.of({name:"sTeX",load(){return de(()=>Promise.resolve().then(()=>QL),void 0,import.meta.url).then(e=>be(e.stex))}}),ue.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return de(()=>Promise.resolve().then(()=>QL),void 0,import.meta.url).then(e=>be(e.stex))}}),ue.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return de(()=>Promise.resolve().then(()=>DL),void 0,import.meta.url).then(e=>be(e.verilog))}}),ue.of({name:"Tcl",extensions:["tcl"],load(){return de(()=>Promise.resolve().then(()=>wbt),void 0,import.meta.url).then(e=>be(e.tcl))}}),ue.of({name:"Textile",extensions:["textile"],load(){return de(()=>Promise.resolve().then(()=>kbt),void 0,import.meta.url).then(e=>be(e.textile))}}),ue.of({name:"TiddlyWiki",load(){return de(()=>Promise.resolve().then(()=>Mbt),void 0,import.meta.url).then(e=>be(e.tiddlyWiki))}}),ue.of({name:"Tiki wiki",load(){return de(()=>Promise.resolve().then(()=>e1t),void 0,import.meta.url).then(e=>be(e.tiki))}}),ue.of({name:"TOML",extensions:["toml"],load(){return de(()=>Promise.resolve().then(()=>t1t),void 0,import.meta.url).then(e=>be(e.toml))}}),ue.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return de(()=>Promise.resolve().then(()=>i1t),void 0,import.meta.url).then(e=>be(e.troff))}}),ue.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return de(()=>Promise.resolve().then(()=>w1t),void 0,import.meta.url).then(e=>be(e.ttcn))}}),ue.of({name:"TTCN_CFG",extensions:["cfg"],load(){return de(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>be(e.ttcnCfg))}}),ue.of({name:"Turtle",extensions:["ttl"],load(){return de(()=>Promise.resolve().then(()=>Q1t),void 0,import.meta.url).then(e=>be(e.turtle))}}),ue.of({name:"Web IDL",extensions:["webidl"],load(){return de(()=>Promise.resolve().then(()=>$wt),void 0,import.meta.url).then(e=>be(e.webIDL))}}),ue.of({name:"VB.NET",extensions:["vb"],load(){return de(()=>Promise.resolve().then(()=>Y1t),void 0,import.meta.url).then(e=>be(e.vb))}}),ue.of({name:"VBScript",extensions:["vbs"],load(){return de(()=>Promise.resolve().then(()=>N1t),void 0,import.meta.url).then(e=>be(e.vbScript))}}),ue.of({name:"Velocity",extensions:["vtl"],load(){return de(()=>Promise.resolve().then(()=>D1t),void 0,import.meta.url).then(e=>be(e.velocity))}}),ue.of({name:"Verilog",extensions:["v"],load(){return de(()=>Promise.resolve().then(()=>DL),void 0,import.meta.url).then(e=>be(e.verilog))}}),ue.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return de(()=>Promise.resolve().then(()=>ewt),void 0,import.meta.url).then(e=>be(e.vhdl))}}),ue.of({name:"XQuery",extensions:["xy","xquery"],load(){return de(()=>Promise.resolve().then(()=>Twt),void 0,import.meta.url).then(e=>be(e.xQuery))}}),ue.of({name:"Yacas",extensions:["ys"],load(){return de(()=>Promise.resolve().then(()=>Uwt),void 0,import.meta.url).then(e=>be(e.yacas))}}),ue.of({name:"Z80",extensions:["z80"],load(){return de(()=>Promise.resolve().then(()=>Zwt),void 0,import.meta.url).then(e=>be(e.z80))}}),ue.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return de(()=>Promise.resolve().then(()=>z_),void 0,import.meta.url).then(e=>be(e.mscgen))}}),ue.of({name:"Xù",extensions:["xu"],load(){return de(()=>Promise.resolve().then(()=>z_),void 0,import.meta.url).then(e=>be(e.xu))}}),ue.of({name:"MsGenny",extensions:["msgenny"],load(){return de(()=>Promise.resolve().then(()=>z_),void 0,import.meta.url).then(e=>be(e.msgenny))}}),ue.of({name:"Vue",extensions:["vue"],load(){return de(()=>Promise.resolve().then(()=>Jut),void 0,import.meta.url).then(e=>e.vue())}}),ue.of({name:"Angular Template",load(){return de(()=>Promise.resolve().then(()=>$Ot),void 0,import.meta.url).then(e=>e.angular())}})];class t9{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=In(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),a=i.search(Zfe(t,!1));return a<0?null:{from:r+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function bI(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function _Ke(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let a=1;a<i.length;a++)n[i[a]]=!0}let r=bI(t)+bI(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Zy(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:_Ke(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function GQ(e,t){return n=>{for(let r=In(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class wI{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function kd(e){return e.selection.main.from}function Zfe(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",a=r[r.length-1]!="$";return!i&&!a?e:new RegExp(`${i?"^":""}(?:${r})${a?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const n9=mf.define();function XKe(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ye.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const SI=new WeakMap;function RKe(e){if(!Array.isArray(e))return e;let t=SI.get(e);return t||SI.set(e,t=Zy(e)),t}const nS=xn.define(),b$=xn.define();class EKe{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=no(t,n),i=pc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(no(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let v=no(t,0),w=pc(v),x=w==t.length?0:-100;if(v!=n[0])if(v==r[0])x+=-200;else return null;return this.ret(x,[0,w])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let v=0,w=Math.min(t.length,200);v<w&&c<l;){let x=no(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=pc(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),$=!0;for(let v=0,w=Math.min(t.length,200),x=0;v<w&&O<l;){let b=no(t,v);s<0&&(u<l&&b==n[u]&&(a[u++]=v),f<l&&(b==n[f]||b==r[f]?(f==0&&(p=v),m=v+1,f++):f=0));let S,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(S=ede(b))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!v||Q==1&&g||x==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&($=!1)),x=Q,v+=pc(b)}return O==l&&o[0]==0&&$?this.result(-100+(d?-200:0),o,t):f==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):f==l?this.ret(-900-t.length,[p,m]):O==l?this.result(-100+(d?-200:0)+-700+($?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let o of n){let s=o+(this.astral?pc(no(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class qKe{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const pi=Ot.define({combine(e){return lm(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:jKe,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>xI(t(r),n(r)),optionClass:(t,n)=>r=>xI(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function xI(e,t){return e?t?e+" "+t:e:t}function jKe(e,t,n,r,i,a){let o=e.textDirection==gr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,f)?s=!1:!s&&f<Math.min(p,d)&&(s=!0),p<=(s?d:f))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:f);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,$=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/$}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function CKe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,a){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&o.appendChild(document.createTextNode(s.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(s.slice(u,O))),d.className="cm-completionMatchedText",l=O}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function RT(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class zKe{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:a,selected:o}=i.open,s=t.state.facet(pi);this.optionContent=CKe(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=RT(a.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,O;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(O=/-(\d+)$/.exec(u.id))&&+O[1]<c.length){this.applyCompletion(t,c[+O[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(pi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:b$.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:a,selected:o,disabled:s}=r.open;(!i.open||i.open.options!=a)&&(this.range=RT(a.length,o,t.state.facet(pi).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),s!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=RT(n.options.length,n.selected,this.view.state.facet(pi).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let a=typeof i=="string"?document.createTextNode(i):i(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Xa(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&UKe(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(a.bottom,n.bottom)-10||i.bottom<Math.max(a.top,n.top)+10?null:this.view.state.facet(pi).positionInfo(this.view,n,i,r,a,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let a=null;for(let o=r.from;o<r.to;o++){let{completion:s,match:l}=t[o],{section:c}=s;if(c){let d=typeof c=="string"?c:c.name;if(d!=a&&(o>r.from||r.from==0))if(a=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let O=this.optionClass(s);O&&(u.className=O);for(let d of this.optionContent){let f=d(s,this.view.state,this.view,l);f&&u.appendChild(f)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function AKe(e,t){return n=>new zKe(n,e,t)}function UKe(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function QI(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function WKe(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let O=typeof u=="string"?u:u.name;r.some(d=>d.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(pi);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let O of c.result.options)i(new wI(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new qKe(O):new EKe(O);for(let p of c.result.options)if(d=f.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new wI(p,c.source,m,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,f)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=f.rank)!==null&&m!==void 0?m:1e9)||(d.name<f.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.name])}}let o=[],s=null,l=a.compareCompletions;for(let c of n.sort((u,O)=>O.score-u.score||l(u.completion,O.completion))){let u=c.completion;!s||s.label!=u.label||s.detail!=u.detail||s.type!=null&&u.type!=null&&s.type!=u.type||s.apply!=u.apply||s.boost!=u.boost?o.push(c):QI(c.completion)>QI(s)&&(o[o.length-1]=c),s=c.completion}return o}class $h{constructor(t,n,r,i,a,o){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=o}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new $h(this.options,kI(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(c=>c.isPending))return i.setDisabled();let s=WKe(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(pi).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<s.length;u++)if(s[u].completion==c){l=u;break}}return new $h(s,kI(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:DKe,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new $h(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new $h(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class rS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new rS(ZKe,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(pi),a=(r.override||n.languageDataAt("autocomplete",kd(n)).map(RKe)).map(l=>(this.active.find(u=>u.source==l)||new Zo(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(r9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!YKe(a,this.active)||s?o=$h.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new Zo(l.source,0):l));for(let l of t.effects)l.is(Dfe)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new rS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?GKe:NKe}}function YKe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}const GKe={"aria-autocomplete":"list"},NKe={};function kI(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const ZKe=[];function Ife(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(n9);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Zo{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Ife(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Zo(i.source,0)),r&4&&i.state==0&&(i=new Zo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(nS))i=new Zo(i.source,1,a.value);else if(a.is(b$))i=new Zo(i.source,0);else if(a.is(r9))for(let o of a.value)o.source==i.source&&(i=o);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(kd(t.state))}}class Uh extends Zo{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=kd(t.state);if(s>o||!i||n&2&&(kd(t.startState)==this.from||s<this.limit))return new Zo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return IKe(i.validFor,t.state,a,o)?new Uh(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new t9(t.state,s,!1)))?new Uh(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:kd(t.state)):new Zo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Uh(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Zo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function IKe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Zfe(e,!0).test(i)}const r9=xn.define({map(e,t){return e.map(n=>n.map(t))}}),Dfe=xn.define(),Ta=Aa.define({create(){return rS.start()},update(e,t){return e.update(t)},provide:e=>[Lz.from(e,t=>t.tooltip),vt.contentAttributes.from(e,t=>t.attrs)]});function i9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ta).active.find(i=>i.source==t.source);return r instanceof Uh?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},XKe(e.state,n,r.from,r.to)),{annotations:n9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const DKe=AKe(Ta,i9);function mb(e,t="option"){return n=>{let r=n.state.field(Ta,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(pi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=pfe(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t=="page"?0:o-1:s>=o&&(s=t=="page"?o-1:0),n.dispatch({effects:Dfe.of(s)}),!0}}const VKe=e=>{let t=e.state.field(Ta,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(pi).interactionDelay?!1:i9(e,t.open.options[t.open.selected])},PI=e=>e.state.field(Ta,!1)?(e.dispatch({effects:nS.of(!0)}),!0):!1,MKe=e=>{let t=e.state.field(Ta,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:b$.of(null)}),!0)};class LKe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const FKe=50,BKe=1e3,HKe=oi.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Ta).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ta),n=e.state.facet(pi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ta)==t)return;let r=e.transactions.some(a=>{let o=Ife(a,n);return o&8||(a.selection||a.docChanged)&&!(o&3)});for(let a=0;a<this.running.length;a++){let o=this.running[a];if(r||o.context.abortOnDocChange&&e.docChanged||o.updates.length+e.transactions.length>FKe&&Date.now()-o.time>BKe){for(let s of o.context.abortListeners)try{s()}catch(l){Xa(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(nS)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(o=>o.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of e.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Ta);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=kd(t),r=new t9(t,n,e.explicit,this.view),i=new LKe(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:b$.of(null)}),Xa(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(pi),r=this.view.state.field(Ta);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=kd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Uh(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new Zo(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:r9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ta,!1);if(t&&t.tooltip&&this.view.state.facet(pi).closeOnBlur){let n=t.open&&pfe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:b$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:nS.of(!1)}),20),this.composing=0}}}),KKe=typeof navigator=="object"&&/Win/.test(navigator.platform),JKe=bO.highest(vt.domEventHandlers({keydown(e,t){let n=t.state.field(Ta,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(KKe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&i9(t,r),!1}})),Vfe=vt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class eJe{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class a9{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Pi.TrackDel),r=t.mapPos(this.to,1,Pi.TrackDel);return n==null||r==null?null:new a9(this.field,n,r)}}class o9{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(UQ);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let s=this.fieldPositions.map(l=>new a9(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:s}}static parse(t){let n=[],r=[],i=[],a;for(let o of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let s=a[1]?+a[1]:null,l=a[2]||a[3]||"",c=-1,u=l.replace(/\\[{}]/g,O=>O[1]);for(let O=0;O<n.length;O++)(s!=null?n[O].seq==s:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(s==null||n[O].seq!=null&&n[O].seq<s);)O++;n.splice(O,0,{seq:s,name:u}),c=O;for(let d of i)d.field>=c&&d.field++}i.push(new eJe(c,r.length,a.index,a.index+u.length)),o=o.slice(0,a.index)+l+o.slice(a.index+a[0].length)}o=o.replace(/\\([{}])/g,(s,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(o)}return new o9(r,i)}}let tJe=ln.widget({widget:new class extends eu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),nJe=ln.mark({class:"cm-snippetField"});class cm{constructor(t,n){this.ranges=t,this.active=n,this.deco=ln.set(t.map(r=>(r.from==r.to?tJe:nJe).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new cm(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const Iy=xn.define({map(e,t){return e&&e.map(t)}}),rJe=xn.define(),w$=Aa.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Iy))return n.value;if(n.is(rJe)&&e)return new cm(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>vt.decorations.from(e,t=>t?t.deco:ln.none)});function s9(e,t){return Ye.create(e.filter(n=>n.field==t).map(n=>Ye.range(n.from,n.to)))}function iJe(e){let t=o9.parse(e);return(n,r,i,a)=>{let{text:o,ranges:s}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:Zn.of(o)},scrollIntoView:!0,annotations:r?[n9.of(r),_i.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=s9(s,0)),s.some(u=>u.field>0)){let u=new cm(s,0),O=c.effects=[Iy.of(u)];n.state.field(w$,!1)===void 0&&O.push(xn.appendConfig.of([w$,cJe,uJe,Vfe]))}n.dispatch(n.state.update(c))}}function Mfe(e){return({state:t,dispatch:n})=>{let r=t.field(w$,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(o=>o.field==i+e);return n(t.update({selection:s9(r.ranges,i),effects:Iy.of(a?null:new cm(r.ranges,i)),scrollIntoView:!0})),!0}}const aJe=({state:e,dispatch:t})=>e.field(w$,!1)?(t(e.update({effects:Iy.of(null)})),!0):!1,oJe=Mfe(1),sJe=Mfe(-1),lJe=[{key:"Tab",run:oJe,shift:sJe},{key:"Escape",run:aJe}],TI=Ot.define({combine(e){return e.length?e[0]:lJe}}),cJe=bO.highest(CQ.compute([TI],e=>e.facet(TI)));function dr(e,t){return Object.assign(Object.assign({},t),{apply:iJe(e)})}const uJe=vt.domEventHandlers({mousedown(e,t){let n=t.state.field(w$,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(a=>a.from<=r&&a.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:s9(n.ranges,i.field),effects:Iy.of(n.ranges.some(a=>a.field>i.field)?new cm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),S$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},fd=xn.define({map(e,t){let n=t.mapPos(e,-1,Pi.TrackAfter);return n??void 0}}),l9=new class extends Zd{};l9.startSide=1;l9.endSide=-1;const Lfe=Aa.define({create(){return Sn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(fd)&&(e=e.update({add:[l9.range(n.value,n.value+1)]}));return e}});function aen(){return[dJe,Lfe]}const ET="()[]{}<>«»»«[]{}";function Ffe(e){for(let t=0;t<ET.length;t+=2)if(ET.charCodeAt(t)==e)return ET.charAt(t+1);return ede(e<128?e:e+1)}function Bfe(e,t){return e.languageDataAt("closeBrackets",t)[0]||S$}const OJe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),dJe=vt.inputHandler.of((e,t,n,r)=>{if((OJe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&pc(no(r,0))==1||t!=i.from||n!=i.to)return!1;let a=hJe(e.state,r);return a?(e.dispatch(a),!0):!1}),fJe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Bfe(e,e.selection.main.head).brackets||S$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=pJe(e.doc,o.head);for(let l of r)if(l==s&&NQ(e.doc,o.head)==Ffe(no(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ye.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},oen=[{key:"Backspace",run:fJe}];function hJe(e,t){let n=Bfe(e,e.selection.main.head),r=n.brackets||S$.brackets;for(let i of r){let a=Ffe(no(i,0));if(t==i)return a==i?$Je(e,i,r.indexOf(i+i+i)>-1,n):mJe(e,i,a,n.before||S$.before);if(t==a&&Hfe(e,e.selection.main.from))return gJe(e,i,a)}return null}function Hfe(e,t){let n=!1;return e.field(Lfe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function NQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,pc(no(n,0)))}function pJe(e,t){let n=e.sliceString(t-2,t);return pc(no(n,0))==n.length?n:n.slice(1)}function mJe(e,t,n,r){let i=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:fd.of(o.to+t.length),range:Ye.range(o.anchor+t.length,o.head+t.length)};let s=NQ(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:fd.of(o.head+t.length),range:Ye.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function gJe(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&NQ(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ye.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function $Je(e,t,n,r){let i=r.stringPrefixes||S$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:fd.of(s.to+t.length),range:Ye.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=NQ(e.doc,l),u;if(c==t){if(_I(e,l))return{changes:{insert:t+t,from:l},effects:fd.of(l+t.length),range:Ye.cursor(l+t.length)};if(Hfe(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ye.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=XI(e,l-2*t.length,i))>-1&&_I(e,u))return{changes:{insert:t+t+t+t,from:l},effects:fd.of(l+t.length),range:Ye.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=No.Word&&XI(e,l,i)>-1&&!yJe(e,l,t,i))return{changes:{insert:t+t,from:l},effects:fd.of(l+t.length),range:Ye.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function _I(e,t){let n=In(e).resolveInner(t+1);return n.parent&&n.from==t}function yJe(e,t,n,r){let i=In(e).resolveInner(t,-1),a=r.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function XI(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=No.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=No.Word)return a}return-1}function sen(e={}){return[JKe,Ta,pi.of(e),HKe,bJe,Vfe]}const vJe=[{key:"Ctrl-Space",run:PI},{mac:"Alt-`",run:PI},{key:"Escape",run:MKe},{key:"ArrowDown",run:mb(!0)},{key:"ArrowUp",run:mb(!1)},{key:"PageDown",run:mb(!0,"page")},{key:"PageUp",run:mb(!1,"page")},{key:"Enter",run:VKe}],bJe=bO.highest(CQ.computeN([pi],e=>e.facet(pi).defaultKeymap?[vJe]:[]));class iS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new iS(t,n,r,o,a,[],[])}constructor(t,n,r,i,a,o,s){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=o,this.positions=s,this.hashProp=[[Ut.contextHash,i]]}addChild(t,n){t.prop(Ut.contextHash)!=this.hash&&(t=new hn(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new hn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new hn(Hr.none,i,a,o,this.hashProp)})}}var Ne;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(Ne||(Ne={}));class wJe{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let SJe=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return f0(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}};function RI(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==Ne.OrderedList?O9:u9)(n,t,!1);return r>0&&(e.type!=Ne.BulletList||c9(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const Kfe={[Ne.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push($n(Ne.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(is(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ne.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ne.OrderedList]:RI,[Ne.BulletList]:RI,[Ne.Document](){return!0}};function is(e){return e==32||e==9||e==10||e==13}function f0(e,t=0){for(;t<e.length&&is(e.charCodeAt(t));)t++;return t}function EI(e,t,n){for(;t>n&&is(e.charCodeAt(t-1));)t--;return t}function Jfe(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function ehe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function c9(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!is(a))return-1}return n&&e.next==45&&rhe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(she.SetextHeading)>-1||r<3?-1:1}function the(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function u9(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||is(e.text.charCodeAt(e.pos+1)))&&(!n||the(t,Ne.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function O9(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!is(e.text.charCodeAt(r+1))||n&&!the(t,Ne.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function nhe(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function rhe(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&is(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const Aq=/^[ \t]*$/,ihe=/-->/,ahe=/\?>/,Uq=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ihe],[/^\s*<\?/,ahe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?: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|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Aq],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Aq]];function ohe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=Uq.length-(n?1:0);i<a;i++)if(Uq[i][0].test(r))return i;return-1}function qI(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function ZO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ne.CodeText?e[r].to=n:e.push($n(Ne.CodeText,t,n))}const gb={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(ZO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){ZO(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==Ne.CodeText?ZO(o,c.from,c.to):o.push(c);s=[]}ZO(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&ZO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ne.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ne.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Jfe(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=EI(t.text,t.text.length,o),l=[$n(Ne.CodeMark,r,r+a)];o<s&&l.push($n(Ne.CodeInfo,e.lineStart+o,e.lineStart+s));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=a&&t.skipSpace(u)==t.text.length){for(let O of t.markers)l.push(O);l.push($n(Ne.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||ZO(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&ZO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ne.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=ehe(t);return n<0?!1:(e.startContext(Ne.Blockquote,t.pos),e.addNode(Ne.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(c9(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ne.HorizontalRule,n),!0},BulletList(e,t){let n=u9(t,e,!1);if(n<0)return!1;e.block.type!=Ne.BulletList&&e.startContext(Ne.BulletList,t.basePos,t.next);let r=qI(t,t.pos+1);return e.startContext(Ne.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ne.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=O9(t,e,!1);if(n<0)return!1;e.block.type!=Ne.OrderedList&&e.startContext(Ne.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=qI(t,t.pos+n);return e.startContext(Ne.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ne.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=nhe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=EI(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!is(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ne.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ne.HeaderMark,o-r,a-r);let l=s.finish(Ne.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=ohe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=Uq[n][1],a=[],o=i!=Aq;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let c of t.markers)a.push(c)}o&&e.nextLine();let s=i==ihe?Ne.CommentBlock:i==ahe?Ne.ProcessingInstructionBlock:Ne.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class xJe{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
|
|
788
788
|
`+n.scrub(),a=this.advance(i);return a>-1&&a<i.length?this.complete(t,r,a):!1}finish(t,n){return(this.stage==2||this.stage==3)&&f0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,$n(Ne.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(t){return t?(this.pos=t.to-this.start,this.elts.push(t),this.stage++,!0):(t===!1&&(this.stage=-1),!1)}advance(t){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(mhe(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push($n(Ne.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(hhe(t,f0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=f0(t,this.pos),r=0;if(n>this.pos){let i=phe(t,n,this.start);if(i){let a=qT(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=qT(t,this.pos)),r>0&&r<t.length?r:-1}else return qT(t,this.pos)}}}function qT(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!is(n))return-1}return t}class QJe{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:rhe(n),a=n.next;if(i<0)return!1;let o=$n(Ne.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,$n(a==61?Ne.SetextHeading1:Ne.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const she={LinkReference(e,t){return t.content.charCodeAt(0)==91?new xJe(t):null},SetextHeading(){return new QJe}},kJe=[(e,t)=>nhe(t)>=0,(e,t)=>Jfe(t)>=0,(e,t)=>ehe(t)>=0,(e,t)=>u9(t,e,!0)>=0,(e,t)=>O9(t,e,!0)>=0,(e,t)=>c9(t,e,!0)>=0,(e,t)=>ohe(t,e,!0)>=0],PJe={text:"",end:0};class TJe{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new SJe,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=i[i.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=i[0].from,this.block=iS.create(Ne.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new EJe(r,n):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:t}=this;for(;;){for(let r=0;;){let i=t.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;r<t.markers.length&&(!i||t.markers[r].from<i.end);){let a=t.markers[r++];this.addNode(a.type,a.from,a.to)}if(!i)break;this.finishContext()}if(t.pos<t.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(t.basePos))return null;e:for(;;){for(let r of this.parser.blockParsers)if(r){let i=r(this,t);if(i!=!1){if(i==!0)return null;t.forward();continue e}}break}let n=new wJe(this.lineStart+t.pos,t.text.slice(t.pos));for(let r of this.parser.leafBlockParsers)if(r){let i=r(this,n);i&&n.parsers.push(i)}e:for(;this.nextLine()&&t.pos!=t.text.length;){if(t.indent<t.baseIndent+4){for(let r of this.parser.endLeafBlock)if(r(this,t,n))break e}for(let r of n.parsers)if(r.nextLine(this,t,n))return null;n.content+=`
|
|
789
789
|
`+t.scrub();for(let r of t.markers)n.marks.push(r)}return this.finishLeaf(n),null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}reuseFragment(t){if(!this.fragments.moveTo(this.absoluteLineStart+t,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let n=this.fragments.takeNodes(this);return n?(this.absoluteLineStart+=n,this.lineStart=ghe(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(t=this.depth-1){return this.parser.nodeSet.types[this.stack[t].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(t){let n=PJe;if(n.end=t,t>=this.to)n.text="";else if(n.text=this.lineChunkAt(t),n.end+=n.text.length,this.ranges.length>1){let r=this.absoluteLineStart,i=this.rangeI;for(;this.ranges[i].to<n.end;){i++;let a=this.ranges[i].from,o=this.lineChunkAt(a);n.end=a+o.length,n.text=n.text.slice(0,this.ranges[i-1].to-r)+o,r=n.end-n.text.length}}return n}readLine(){let{line:t}=this,{text:n,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,t.reset(n);t.depth<this.stack.length;t.depth++){let i=this.stack[t.depth],a=this.parser.skipContextMarkup[i.type];if(!a)throw new Error("Unhandled block context "+Ne[i.type]);if(!a(i,this,t))break;t.forward()}}lineChunkAt(t){let n=this.input.chunk(t),r;if(this.input.lineChunks)r=n==`
|
|
790
790
|
`?"":n;else{let i=n.indexOf(`
|
|
@@ -813,13 +813,13 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
813
813
|
`,o.end),l=t.slice(o.end,s===-1?t.length:s);if(VSt.test(l))return _a;const c=l.length-l.replace(MSt,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+vp(e.value).length;return n<O||n>d?{arm:u,typingAt:null,value:""}:{arm:u,typingAt:O,value:e.value}}return a&&n===u.end&&t[n-1]===wk?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const ol=e=>e.typingAt!==null,KSt=e=>e.arm!==null;function Qf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+vp(e.value).length}}function dA(e,t,n,r){const i=Qf(e);if(i===null)return null;const{top:a,bottom:o,inserted:s}=r;if(a>i.end||o<i.start)return null;const l=vp(e.value),c=Gj(a-i.start,0,l.length),u=Gj(o-i.start,0,l.length),O=vp(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),f=a+O.length,p=t.slice(0,a)+Kve.repeat(O.length)+t.slice(f),m=O.length-s.length,g=n>=f?n+m:n;return{buffer:p,caret:g,capture:{...e,value:d}}}function rF(e,t,n,r){const i={capture:e,buffer:t.slice(0,n.start)+r+t.slice(n.end),caret:n.start+r.length},a=ol(e)&&e.value===""&&r.startsWith("-");if(ol(e)&&(a||r.includes(`
|
|
814
814
|
`))){const o=jS(e);return r.includes(`
|
|
815
815
|
`)?{...i,capture:o}:{...i,capture:bh(o,i.buffer,i.caret,"typing")}}return dA(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function jS(e){return ol(e)?{arm:e.arm,typingAt:null,value:""}:e}function JSt(e,t){let n=0;const r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;let i=e.length,a=t.length;for(;i>n&&a>n&&e[i-1]===t[a-1];)i--,a--;return{top:n,bottom:i,inserted:t.slice(n,a)}}function ext(e,t,n,r,i){const a=JSt(t,n),o=Qf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:jS(e),buffer:n,caret:r};else{const l=dA(e,n,r,a);l?s=l:ol(e)&&a.inserted.includes(`
|
|
816
|
-
`)&&(s={capture:jS(e),buffer:n,caret:r})}return{...s,capture:bh(s.capture,s.buffer,s.caret,i)}}function txt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Qf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=sbe(i,t.value),c=l+wk,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:_a,buffer:u,caret:s+c.length,payload:{index:i,key:Obe(a,e.draw),value:t.value,marker:l}}}function nxt(e,t){const n=Qf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=ube(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:_a,buffer:i,caret:n.start+r.length,restored:Yj(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:Yj(r),restoredText:r}}}function iF(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function rxt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Qf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:jS(e),buffer:i,caret:a,payload:null}}function ixt(e){const{capture:t,buffer:n,caret:r,pasted:i}=e;if(t.arm===null)return null;if(t.typingAt!==null&&t.value!==""){if(i==="")return null;const u=dA(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=mn(i);if(!a)return i===""?null:rxt(t,n,e.selection,i);const o=t.arm,s=sbe(e.index,a),l=s+wk,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:_a,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:Obe(e.taken,e.draw),value:a,marker:s}}}const obe=e=>`${Yj(e)} chars`,sbe=(e,t)=>`[Credential #${e}, ${obe(t)}]`;function axt(e){ml.lastIndex=0;const t=ml.exec(e);return ml.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function oxt(e){ml.lastIndex=0;const t=ml.exec(e);if(ml.lastIndex=0,t===null||t[0]!==e)return null;const n=Number.parseInt(t[1],10);return{index:n,label:`#${n}`,chars:Number.parseInt(t[2],10)}}function nv(e,t){if(axt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const J_=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,e2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,t2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,sxt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&Wj.test(t[1])?t[1]:""};function lxt(e,t){if(e.charCodeAt(t)!==91)return null;J_.lastIndex=t;const n=J_.exec(e);if(J_.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};e2.lastIndex=t;const r=e2.exec(e);if(e2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};t2.lastIndex=t;const i=t2.exec(e);return t2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:sxt(i[0])}:null}function Sk(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=lxt(e,r);if(i===null){r++;continue}r>n&&t.push({kind:"text",text:e.slice(n,r)}),t.push(i),r+=i.text.length,n=r}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}function aF(e,t){const n=[];for(const r of t){const i=nv(e,r);i!==null&&n.push({at:i.start,payload:r})}return n.sort((r,i)=>r.at-i.at).map(r=>r.payload)}function cxt(e,t=""){return e==="unconfirmed"?t?`[credential unconfirmed — it may be held as $${t}, so check list_variables before assuming it is missing]`:"[credential unconfirmed — the session may hold it, so check list_variables before assuming it is missing]":e==="unreachable"?"[credential NOT stored — the session could not be reached; try again]":e==="rejected-key"?"[credential NOT stored — the store rejected its name]":"[credential NOT stored — its value did not survive; ask the operator to paste it again]"}const uxt=e=>`[credential ${e.key} (${obe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function Oxt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=nv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of nbe(e,r))i.push({span:o,payload:null});let a=e;for(const{span:o,payload:s}of i.sort((l,c)=>c.span.start-l.span.start)){const l=s===null?"lost":n.get(s.index),c=s===null||l!==void 0?cxt(l??"lost",s?.key):uxt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const dxt=(e,t,n)=>`Removed ${e} (credential #${t}) from this message. Its value is gone — press ${n} to put it back, or paste it again after /credential to reuse it.`,fxt=e=>`Remove credential #${e}`,hxt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,pxt=(e,t,n)=>dxt(e,t,n),mxt="Undo",gxt=e=>`Credential #${e} removed`,$xt=e=>e.unredacted!==null?e.unredacted:e.armed?Qxt:e.cleared!==null?pxt(e.cleared.key,e.cleared.index,e.undoCap):null;function yxt(e){const{buffer:t,payload:n}=e,r=nv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===wk?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function vxt(e){const{buffer:t,cleared:n}=e;return n.removed===""||t!==n.buffer?null:{buffer:t.slice(0,n.caret)+n.removed+t.slice(n.caret),caret:n.caret+n.removed.length}}const oF=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function sF(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be stored (${[...e].sort().join(", ")}); the agent has been told so. Paste the value again after /credential to retry.`}const bxt="store unconfirmed",wxt="Credential store unconfirmed",Sxt=e=>e===""?wxt:`${e} · ${bxt}`,lbe="Paste the value again after /credential to store it again.",xxt=e=>`${e} ${lbe}`;function lF(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be confirmed as stored (${[...e].sort().join(", ")}); the agent has been told to check before using it. ${lbe}`}const Qxt="armed — add a space, then type or paste the secret",kxt="masked as you type — Enter turns it into a pill, Esc cancels",Pxt="masked — Enter opens the credential picker; type or paste the secret into this span",Txt="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",cbe="\0held",_xt=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===cbe?`${e} characters are now PLAIN TEXT in the composer — Enter is held: clear the box to release your words`:`${e} characters are now PLAIN TEXT in the composer — Enter will take them as /${t}'s argument, not send them`;function ube(e,t){const n=Qf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const cF=(e,t)=>e&&e.over===t?e.chars:null,Xxt=e=>{const t=Math.floor(4294967296/e)*e,n=new Uint32Array(1);for(;;)if(globalThis.crypto.getRandomValues(n),n[0]<t)return n[0]%e},Rxt=16,Ext=16;function Obe(e=[],t=Xxt){const n=new Set(e);for(let r=0;r<Rxt;r++){const i=tF+uF(8,t);if(!n.has(i))return i}return tF+uF(Ext,t)}const uF=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=eF[t(eF.length)];return n},dbe=j("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),fbe=j("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),hbe=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>h.jsxs("span",{className:j("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?fbe:dbe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(Tie,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(dje,{"aria-hidden":"true",className:"size-3 shrink-0"}),h.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&h.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&h.jsx("button",{type:"button","aria-label":a,onClick:i,className:"pointer-events-auto -mr-1 flex shrink-0 cursor-pointer items-center rounded-xs p-0.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-offset-1! active:bg-sunken",children:h.jsx(Ri,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),W$="#lo-credential/",qxt=`${W$}unstored`,OF=`${W$}unconfirmed`,jxt=/^\d+$/,pbe=e=>e.kind==="stored"?`${W$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${OF}/${e.key}`:OF:qxt;function Cxt(e){if(!e||!e.startsWith(W$))return null;const t=e.slice(W$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return Wj.test(a)?{kind:"unconfirmed",key:a}:null}const n=t.lastIndexOf("/");if(n===-1)return null;const r=t.slice(0,n),i=t.slice(n+1);return!Wj.test(r)||!jxt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function dF(e,t){const n=Cxt(e);if(n===null)return null;const r=Sk(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return pbe(i)!==e?null:n}const xk=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=Sk(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:pbe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},zxt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?Sxt(e.key):"Credential not stored",Axt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?xxt(t):t,Uxt=({citation:e,title:t})=>h.jsx(hbe,{tone:e.kind==="stored"?"live":"warning",label:zxt(e),chars:e.kind==="stored"?e.chars:null,title:Axt(e,t),className:"align-middle"}),Wxt=(e,t)=>typeof t=="string"?dF(e,t):t==null?dF(e,""):null,Yxt=e=>({href:t,title:n,children:r})=>{const i=Wxt(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(Uxt,{citation:i,title:n})};function Gxt(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:s,mathText:o,mathTextData:s}};function e(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function t(){this.buffer()}function n(){const l=this.resume(),c=this.stack[this.stack.length-1];c.type,c.meta=l}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c;const O=u.data.hChildren[0];O.type,O.tagName,O.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function a(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function o(l){const c=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function s(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}const Nxt={tokenize:Zxt,concrete:!0,name:"mathFlow"},fF={tokenize:Ixt,partial:!0};function Zxt(e,t,n){const r=this,i=r.events[r.events.length-1],a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return s;function s(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),o++,l):o<2?n(v):(e.exit("mathFlowFenceSequence"),sn(e,c,"whitespace")(v))}function c(v){return v===null||$t(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||$t(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(fF,d,g)(v)}function d(v){return e.attempt({tokenize:$,partial:!0},g,f)(v)}function f(v){return(a?sn(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):$t(v)?e.attempt(fF,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||$t(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function $(v,w,x){let b=0;return sn(v,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(R){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(R)}function Q(R){return R===36?(b++,v.consume(R),Q):b<o?x(R):(v.exit("mathFlowFenceSequence"),sn(v,P,"whitespace")(R))}function P(R){return R===null||$t(R)?(v.exit("mathFlowFence"),w(R)):x(R)}}}function Ixt(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Dxt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Vxt,previous:Mxt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):$t(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),f(m))}function f(m){return m===null||m===32||m===36||$t(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),f)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",f(m))}}}function Vxt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Mxt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Lxt(e){return{flow:{36:Nxt},text:{36:Dxt()}}}const wh=36,hF=e=>e!==null&&e<-2,pF=e=>e===null||e===32||e<0,mF=e=>e!==null&&e>=48&&e<=57,mbe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:Fxt,previous:Bxt,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(g){return r.enter("mathText"),r.enter("mathTextSequence"),d(g)}function d(g){return g===wh?(r.consume(g),s++,d):s<2&&!t||s===1&&(pF(g)||mF(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===wh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):hF(g)?(r.enter("lineEnding"),r.consume(g),r.exit("lineEnding"),f):(r.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===wh||hF(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===wh?(r.consume(g),c++,m):c===s?s===1&&(pF(l)||mF(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function Fxt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Bxt(e){return e!==wh||this.events[this.events.length-1][1].type==="characterEscape"}const Hxt=Lxt().flow,Kxt=mbe();function Qk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?Kxt:mbe(e);n.push({flow:Hxt,text:{[wh]:i}}),r.push(Gxt())}const Jxt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),eQt=/\$(?!\d)(.+?)\$/,tQt=/\$\$([\s\S]+?)\$\$/,nQt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,rQt=/\\[a-zA-Z]+(\{[^}]*\})?/,gF=e=>eQt.test(e)||tQt.test(e)||nQt.test(e)?!0:rQt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),iQt=e=>{const t=Sk(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},aQt=e=>Sk(e).filter(t=>t.kind!=="text").length,oQt=e=>{if(!gF(e))return!1;const t=iQt(e);return t===null?!0:gF(t)||t.includes("$")?!1:aQt(e)<2},Kt="var(--color-ink)",Ml="var(--color-ink-muted)",Hs="var(--color-surface)",bu="var(--color-elevated)",Ll="var(--color-sunken)",Ci="var(--color-hairline)",wu="var(--color-control)",eh="var(--color-accent)",Dg="var(--color-accent-wash)",sQt="var(--color-accent-alt-wash)",lQt="var(--color-on-accent)",cQt="var(--color-info)",gbe="var(--color-info-wash)",uQt="var(--color-success)",$be="var(--color-success-wash)",OQt="var(--color-warning)",Nj="var(--color-warning-wash)",dQt="var(--color-warning-border)",n2="var(--color-danger)",Zj="var(--color-danger-wash)",$F=[Dg,sQt,gbe,$be,Nj,Zj],Su=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),fQt=()=>{const e={primaryColor:Su("--color-accent"),secondaryColor:Su("--color-success"),tertiaryColor:Su("--color-info"),mainBkg:Su("--color-elevated"),clusterBkg:Su("--color-sunken"),clusterBorder:Su("--color-hairline"),edgeLabelBackground:Su("--color-surface"),quadrant1Fill:Su("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:Hs,primaryTextColor:Kt,primaryBorderColor:wu,secondaryTextColor:Kt,secondaryBorderColor:Ci,tertiaryTextColor:Kt,tertiaryBorderColor:Ci,lineColor:Ml,arrowheadColor:Ml,textColor:Kt,secondBkg:Ll,border1:wu,border2:Ci,labelColor:Kt,nodeBkg:bu,nodeBorder:wu,nodeTextColor:Kt,defaultLinkColor:Ml,titleColor:Kt,noteBkgColor:Nj,noteBorderColor:dQt,noteTextColor:Kt,actorBkg:bu,actorBorder:wu,actorTextColor:Kt,actorLineColor:Ci,signalColor:Ml,signalTextColor:Kt,labelBoxBkgColor:bu,labelBoxBorderColor:Ci,labelTextColor:Kt,loopTextColor:Kt,activationBkgColor:Dg,activationBorderColor:eh,sequenceNumberColor:Hs,sectionBkgColor:Ll,sectionBkgColor2:Hs,altSectionBkgColor:Ll,excludeBkgColor:Ll,taskBkgColor:Dg,taskBorderColor:wu,taskTextColor:Kt,taskTextLightColor:Kt,taskTextDarkColor:Kt,taskTextOutsideColor:Kt,taskTextClickableColor:eh,activeTaskBkgColor:Dg,activeTaskBorderColor:eh,gridColor:Ci,doneTaskBkgColor:Ll,doneTaskBorderColor:Ci,critBkgColor:Zj,critBorderColor:n2,todayLineColor:eh,transitionColor:Ml,transitionLabelColor:Kt,stateLabelColor:Kt,stateBkg:bu,labelBackgroundColor:Hs,compositeBackground:Ll,altBackground:Ll,compositeTitleBackground:bu,compositeBorder:Ci,innerEndBackground:Kt,specialStateColor:Kt,classText:Kt,attributeBackgroundColorOdd:Hs,attributeBackgroundColorEven:Ll,rowOdd:Hs,rowEven:Ll,errorBkgColor:Zj,errorTextColor:n2,pieTitleTextColor:Kt,pieSectionTextColor:Kt,pieLegendTextColor:Kt,pieStrokeColor:Hs,pieOuterStrokeColor:Ci,requirementBackground:bu,requirementBorderColor:wu,requirementTextColor:Kt,relationColor:Ml,relationLabelBackground:Hs,relationLabelColor:Kt,branchLabelColor:lQt,commitLabelColor:Kt,commitLabelBackground:Hs,tagLabelColor:Kt,tagLabelBackground:Dg,tagLabelBorder:wu,quadrant2Fill:gbe,quadrant3Fill:$be,quadrant4Fill:Nj,quadrant2TextFill:Kt,quadrant3TextFill:Kt,quadrant4TextFill:Kt,quadrantPointFill:eh,archEdgeColor:Ml,archEdgeArrowColor:Ml,archGroupBorderColor:Ci,scaleLabelColor:Kt,packet:{startByteColor:Kt,endByteColor:Kt,labelColor:Kt,titleColor:Kt,blockStrokeColor:wu,blockFillColor:bu},radar:{axisColor:Ml,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Ci,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Hs,titleColor:Kt,xAxisTitleColor:Kt,xAxisLabelColor:Kt,xAxisTickColor:Ci,xAxisLineColor:Ci,yAxisTitleColor:Kt,yAxisLabelColor:Kt,yAxisTickColor:Ci,yAxisLineColor:Ci,plotColorPalette:[eh,cQt,uQt,OQt,n2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=bu,t[`surfacePeer${n}`]=Ci;for(let n=0;n<8;n++)t[`fillType${n}`]=$F[n%$F.length];return{...t,...e}};let r2=null,yF=null;const hQt=async e=>{r2||(r2=de(async()=>{const{default:n}=await import("./mermaid.core-mY1aEGAJ.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,2,3]),import.meta.url).then(({default:n})=>n));const t=await r2;return yF!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:fQt()}),yF=e),t},vF=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:j("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(At,{content:"Zoom in",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(QCe,{})})}),h.jsx(At,{content:"Zoom out",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(PCe,{})})}),h.jsx(At,{content:"Drag the diagram to pan",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(jje,{})})}),h.jsx(At,{content:"Reset view",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(v6,{})})}),h.jsx(At,{content:"Save as SVG",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(lQ,{})})}),h.jsx(At,{content:t?"Copied":"Copy mermaid text",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(m6,{className:j(t&&"text-success")})})}),s]}),Ij=({title:e,children:t})=>h.jsxs(xc,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(b1,{children:e}),h.jsx(w1,{children:t})]});class pQt extends y.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||h.jsxs(Ij,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const mQt=y.memo(({chart:e,id:t})=>{const n=y.useRef(null),r=y.useRef(null),[i,a]=y.useState(null),[o,s]=y.useState(!0),[l,c]=y.useState(""),[u,O]=y.useState(!1),[d,f]=y.useState({scale:1,x:0,y:0}),[p,m]=y.useState({scale:1,x:0,y:0}),[g,$]=y.useState(!1),[v,w]=y.useState({x:0,y:0}),[x,b]=y.useState("idle"),[S,Q]=y.useState("idle"),P=Bn(z=>z.themeName),R=y.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const z=await hQt(P),le=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:L}=await z.render(le,e);if(!L||typeof L!="string"||L.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(L)}catch(z){console.error("Mermaid rendering error:",z);const le=z instanceof Error?z.message:"Failed to render mermaid diagram";a(le),c("")}finally{s(!1)}},[e,t,P]);y.useEffect(()=>{R().catch(z=>{console.error("Error in renderDiagram effect:",z),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const _=y.useCallback(()=>{try{if(!l||!r.current)return 1;const le=r.current.getBoundingClientRect(),L=document.createElement("div");L.innerHTML=l;const Z=L.querySelector("svg");if(!Z)return 1;const ne=Z.getBoundingClientRect?.()?.width||Number.parseFloat(Z.getAttribute("width")||"0")||Z.viewBox?.baseVal?.width||800,te=Z.getBoundingClientRect?.()?.height||Number.parseFloat(Z.getAttribute("height")||"0")||Z.viewBox?.baseVal?.height||600,ie=le.width*.9/ne,$e=le.height*.9/te;return Math.min(ie,$e,1)}catch(z){return console.error("Error calculating fullscreen scale:",z),1}},[l]);y.useEffect(()=>{u&&l&&setTimeout(()=>{try{const z=_();m({scale:z,x:0,y:0})}catch(z){console.error("Error setting fullscreen transform:",z)}},100)},[u,l,_]);const E=y.useCallback((z=!1)=>{try{(z?m:f)(L=>({...L,scale:Math.min(L.scale*1.2,10)}))}catch(le){console.error("Error in zoom in:",le)}},[]),C=y.useCallback((z=!1)=>{try{(z?m:f)(L=>({...L,scale:Math.max(L.scale/1.2,.1)}))}catch(le){console.error("Error in zoom out:",le)}},[]),W=y.useCallback((z=!1)=>{try{const le=z?m:f;if(z){const L=_();le({scale:L,x:0,y:0})}else le({scale:1,x:0,y:0})}catch(le){console.error("Error in reset:",le)}},[_]),U=y.useCallback(()=>{if(l)try{const z=new Blob([l],{type:"image/svg+xml"}),le=URL.createObjectURL(z),L=document.createElement("a");L.href=le,L.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(le)}catch(z){console.error("Failed to save SVG:",z)}},[l]),Y=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(z){console.error("Failed to copy Mermaid chart text:",z)}},[e]),V=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(z){console.error("Failed to copy Mermaid chart text:",z)}},[e]),M=y.useCallback(z=>{try{$(!0),w({x:z.clientX,y:z.clientY}),z.preventDefault()}catch(le){console.error("Error in mouse down:",le)}},[]),B=y.useCallback((z,le=!1)=>{try{if(!g)return;const L=z.clientX-v.x,Z=z.clientY-v.y;(le?m:f)(te=>({...te,x:te.x+L,y:te.y+Z})),w({x:z.clientX,y:z.clientY})}catch(L){console.error("Error in mouse move:",L)}},[g,v]),G=y.useCallback(()=>{try{$(!1)}catch(z){console.error("Error in mouse up:",z)}},[]),A=y.useCallback((z,le=!1)=>{try{z.preventDefault();const L=z.deltaY>0?.9:1.1;(le?m:f)(ne=>({...ne,scale:Math.min(Math.max(ne.scale*L,.1),5)}))}catch(L){console.error("Error in wheel:",L)}},[]),ee=y.useCallback(z=>{try{O(z)}catch(le){console.error("Error toggling fullscreen:",le)}},[]);if(i)return h.jsxs(Ij,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:j("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:j("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(z=!1)=>{try{const le=z?r:n,L=z?p:d;return h.jsx("div",{ref:le,className:j("mermaid flex w-full items-center justify-center",z?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:M,onMouseMove:Z=>B(Z,z),onMouseUp:G,onMouseLeave:G,onWheel:Z=>A(Z,z),children:o?h.jsx("div",{className:j("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:j("flex h-full w-full items-center justify-center"),style:{transform:`translate(${L.x}px, ${L.y}px) scale(${L.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(le){return console.error("Error rendering diagram content:",le),h.jsx(Ij,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:j("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[K(!1),h.jsx(vF,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>C(!1),onReset:()=>W(!1),onSave:U,onCopy:Y,children:h.jsx(At,{content:"Fullscreen",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>ee(!0),children:h.jsx(Qje,{})})})})]}),h.jsx(t$,{open:u,onClose:()=>ee(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:j("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[K(!0),h.jsx(vF,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>C(!0),onReset:()=>W(!0),onSave:U,onCopy:V,children:h.jsx(At,{content:"Close fullscreen",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>ee(!1),children:h.jsx(Ri,{})})})})]})})]})}),gQt=y.memo(e=>h.jsx(pQt,{children:h.jsx(mQt,{...e})}));let ybe=!1,i2=null;const $Qt=()=>(i2||(i2=de(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(ybe=!0,e))),i2),yQt=/language-(\w+)/,vQt=/\n$/,vbe=({href:e,children:t})=>{const n=Xve(e),r=Zve();return!n||n.kind==="other"?h.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):h.jsx("a",{href:n.target,"data-lo-kind":n.kind,"data-lo-target":n.target,draggable:!1,target:n.kind==="url"?"_blank":void 0,rel:n.kind==="url"?"noopener noreferrer":void 0,onClick:n.kind==="file"?i=>SQt(i,r):void 0,children:t})},bQt=e=>Xve(e)?.kind==="file",wQt=Cve,SQt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(jve)??"file",i=n.getAttribute(wQt),a=Hwt({kind:r,hasHighlight:dSt(n),canOpenInCanvas:Gve(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||qS(i)});return}qS(i)}},bbe=(e,t)=>t==="href"&&bQt(e)?e:jce(e),fA={a:vbe,table:Jxt,code:({node:e,className:t,children:n,...r})=>yQt.exec(t??"")?.[1]==="mermaid"?h.jsx(gQt,{chart:String(n).replace(vQt,"")}):h.jsx("code",{className:t,...r,children:n})},xQt={...fA,a:Yxt(vbe)},QQt=[vO],kQt=[vO,Qk],PQt=[vO,$k],TQt=[vO,Qk,$k],_Qt=[vO,xk,yk],XQt=[vO,Qk,xk,yk],RQt=[vO,$k,xk,yk],EQt=[vO,Qk,$k,xk,yk],qQt={"000":QQt,"001":_Qt,"010":PQt,"011":RQt,100:kQt,101:XQt,110:TQt,111:EQt},jQt=[],CQt=[BDe],wbe=e=>y.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Sbe=(e,t,n)=>{const r=y.useMemo(()=>oQt(e),[e]),[i,a]=y.useState(ybe),o=r&&i;return y.useEffect(()=>{if(!r||i)return;let s=!1;return $Qt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:qQt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?CQt:jQt}},xbe=(e,t)=>{const[,n]=y.useState(0);y.useEffect(()=>{if(!t)return;const r=XLe(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=Jwt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return qve(r,window.api?.probeFiles,Jie).then(()=>{i&&r.some(s=>Eve(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},kk=y.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=y.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=Sbe(a,r,i),l=wbe(t);return xbe(a,r),h.jsx("div",{className:j("lo-markdown",n),style:l,children:h.jsx(qce,{remarkPlugins:o,rehypePlugins:s,urlTransform:bbe,components:i?xQt:fA,children:a})})});kk.displayName="MarkdownRenderer";const Qbe=y.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=Sbe(e,!0,!1);return xbe(e,!0),h.jsx(qce,{remarkPlugins:t,rehypePlugins:n,urlTransform:bbe,components:fA,children:e})});Qbe.displayName="StableBlock";const kbe=y.memo(({text:e,animate:t})=>h.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));kbe.displayName="ArrivedText";const Pbe=({content:e,styleProps:t,className:n})=>{const r=y.useRef(null);r.current===null&&(r.current=$St());const i=r.current,a=y.useRef([]),o=y.useRef(0);wSt(i,e);const s=o.current;e.length>s?(s>0&&a.current.push({offset:s,animate:!0}),o.current=e.length):e.length<s&&(a.current=[],o.current=e.length);const{blockStart:l}=i,c=a.current;let u=0;for(;u<c.length&&c[u].offset<=l;)u+=1;u>0&&c.splice(0,u);const O=l+SSt(e.slice(l)),d=[{offset:l,animate:!1}];for(const p of c){if(p.offset>=O)break;d.push(p)}const f=wbe(t);return h.jsxs("div",{className:j("lo-markdown",n),style:f,children:[i.blocks.map((p,m)=>h.jsx(Qbe,{source:p},m)),O>l&&h.jsx("p",{className:"lo-stream-tail",children:d.map((p,m)=>{const g=d[m+1]?.offset??O;return h.jsx(kbe,{text:e.slice(p.offset,g),animate:p.animate},p.offset)})})]})};Pbe.displayName="StreamingMarkdown";const qs=({isUser:e,children:t,className:n})=>e?h.jsx("div",{className:j("flex w-full justify-end",n),children:t}):h.jsx("div",{className:j("group relative w-full",n),children:t}),hA=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},zQt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()+1),Math.max(1,t.getTime()-e)};let pA=hA(Date.now()),Cu=null;const iw=new Set,Tbe=()=>{Cu!==null&&clearTimeout(Cu),Cu=setTimeout(()=>{Cu=null,pA=hA(Date.now());for(const e of iw)e();Tbe()},zQt(Date.now())),Cu.unref?.()},AQt=e=>(iw.add(e),pA=hA(Date.now()),Tbe(),()=>{iw.delete(e),iw.size===0&&Cu!==null&&(clearTimeout(Cu),Cu=null)}),bF=()=>pA,UQt=()=>y.useSyncExternalStore(AQt,bF,bF),WQt=e=>new Date(e+1e3),YQt=()=>WQt(UQt()),pen=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(navigator.language,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},GQt=(e,t=new Date)=>{if(e==null)return"";try{const n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return"";const r=n.toLocaleTimeString(navigator.language,{hour:"numeric",minute:"2-digit",hour12:!0});if(n.toDateString()===t.toDateString())return r;const i=new Date(t);if(i.setDate(t.getDate()-1),n.toDateString()===i.toDateString())return`Yesterday ${r}`;const a=n.toLocaleDateString(navigator.language,{month:"short",day:"numeric"});return n.getFullYear()===t.getFullYear()?`${a}, ${r}`:`${a}, ${n.getFullYear()}, ${r}`}catch(n){return console.error("Error formatting turn timestamp:",n),""}},NQt=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleString(navigator.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},ZQt={turn:"Sent",answer:"Answered",tool:"Ran"},_be=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=YQt();if(Number.isNaN(r.getTime()))return null;const a=NQt(r,{hour12:!0});return h.jsx(At,{content:a,side:"bottom",delayDuration:1200,children:h.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${ZQt[t]} ${a}`,className:j("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:GQt(r,i)})})},mA=({replies:e,onRemoveReply:t})=>h.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[h.jsx(Pje,{size:12,"aria-hidden":"true"}),h.jsx("span",{className:"text-meta",children:"Replying to"})]}),e.map(n=>h.jsxs("div",{className:"flex items-center gap-2 border-hairline border-l-2 py-0.5 pl-2",children:[h.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&h.jsx(Ve,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"aria-label":"Remove reply",children:h.jsx(Ri,{"aria-hidden":"true"})})]},n.id))]}),IQt=({children:e,className:t})=>h.jsx("span",{"aria-hidden":!0,className:j("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),DQt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},VQt=({line:e})=>h.jsx("span",{className:j(DQt[e.kind],"block"),children:e.text}),MQt=({diff:e,className:t})=>{const n=z2e(e);return h.jsxs("div",{className:j("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>h.jsx(VQt,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:A2e(n.hidden)})]})},LQt=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const a=i.slice(0,t),o=a.lastIndexOf(" ");i=`${a.slice(0,o>32?o:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},wF=e=>e.startsWith("file://")?e.slice(7):e,FQt={READ:{verb:"Read",runningVerb:"Reading",icon:h6},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:Goe},EDIT:{verb:"Edited",runningVerb:"Editing",icon:Vje},CODE:{verb:"Ran code",runningVerb:"Running code",icon:qoe},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:sCe},DONE:{verb:"Finished",runningVerb:"Finishing",icon:A7},ASK:{verb:"Asked",runningVerb:"Asking",icon:oQ},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:Zqe}},BQt={verb:"Worked on the request",runningVerb:"Working on the request",icon:qoe},HQt=(e,t,n,r)=>{const i=e?FQt[e]:BQt;let a;if(t)a=wF(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=wF(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?LQt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},SF="min-h-5 py-0",KQt=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>h.jsxs("span",{className:j("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[h.jsx(IQt,{className:j(a?"text-danger":"text-ink-dim",o&&Mse),children:e}),h.jsxs("span",{className:j(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[h.jsxs("span",{...y5,className:j("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?h.jsxs("span",{...y5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?h.jsxs("span",{...y5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),xF=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:a=!1,defaultOpen:o=!1,details:s,className:l,verbOverride:c,object:u,glyph:O,wrap:d,dense:f=!1})=>{const p=HQt(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?Mh:p.icon,$=a||!c||!O?h.jsx(g,{}):O,v=h.jsx(KQt,{icon:$,verb:m,object:c?u:p.object,narration:c?r:p.narration,running:i,failed:a,wrap:d}),w=d?"firstLine":"center";return s?h.jsx(Bo,{summary:v,chevron:"leading",summaryAlign:w,defaultOpen:o,className:l,rowClassName:f?SF:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx(Bo,{disabled:!0,summary:v,summaryAlign:w,className:l,rowClassName:f?SF:void 0})},Xbe=8,JQt="… deeper values not shown",ekt="(empty)";function tkt(e){return`… ${e} more line${e===1?"":"s"}`}const QF=.5;function nkt(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const a of e){if(a.height<=0)continue;const o=Math.max(1,Math.round(a.height/t));for(let s=1;s<=o;s++)a.top+s*t>n+r&&i++}return i}function Rbe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function gA(e){return typeof e=="object"&&e!==null}function Ebe(e,t,n,r){if(n>Xbe){r.push({key:t,value:JQt,depth:n});return}if(gA(e)){for(const[a,o]of Object.entries(e))Ebe(o,t?`${t}.${a}`:a,n+1,r);return}const i=Rbe(e);i!==null&&r.push({key:t,value:i,depth:n})}function qbe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))Ebe(r,n,1,t);return t}const rkt=512;function ikt(e,t){if(t)return!0;if(!e)return!1;let n=rkt;const r=(i,a)=>{if(n--<=0||a>Xbe)return!0;if(!gA(i))return Rbe(i)!==null;for(const o of Object.values(i))if(r(o,a+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function akt(e){if(!e)return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!gA(n))return null;const r=qbe(n);return r.length>0?r:[{key:"",value:ekt,depth:1}]}const okt=8,Dj="max-h-[min(320px,40vh)]",skt=Dj,lkt=({line:e})=>h.jsxs("div",{className:j("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*okt},children:[e.key?h.jsxs("span",{className:j("text-ink-muted"),children:[e.key,": "]}):null,h.jsx("span",{className:j("text-ink-dim"),children:e.value})]}),kF=({lines:e,label:t})=>h.jsx("div",{className:j("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>h.jsx(lkt,{line:n},r))});function PF(e){const[t,n]=y.useState(0),[r,i]=y.useState(!1);return y.useLayoutEffect(()=>{const a=e.current;if(!a)return;const o=a.firstElementChild,s=()=>{const c=o??a,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const O=a.getBoundingClientRect(),d=c.getBoundingClientRect();i(d.height>O.height+QF);const f=c.children.length>0?Array.from(c.children):[c];n(nkt(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,QF))};s(),a.addEventListener("scroll",s,{passive:!0});const l=new ResizeObserver(s);return l.observe(o??a),()=>{a.removeEventListener("scroll",s),l.disconnect()}}),{lines:t,overflowing:r}}const TF=({lines:e,overflowing:t})=>t?h.jsx("span",{className:j("mt-1 block text-ink-dim"),children:e>0?tkt(e):" "}):null,ckt=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=qbe(e),o=akt(t),s=y.useRef(null),l=y.useRef(null),c=PF(s),u=PF(l);return a.length===0&&!t&&!i?null:h.jsxs("div",{className:j("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&h.jsxs("div",{"data-detail-section":"input",children:[h.jsx("div",{ref:s,className:j(Dj,"overflow-auto"),children:h.jsx(kF,{lines:a,label:"input"})}),h.jsx(TF,{lines:c.lines,overflowing:c.overflowing})]}),i&&h.jsx("div",{className:j("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&h.jsxs("div",{className:j(a.length>0&&"mt-3"),"data-detail-section":"output",children:[h.jsx("span",{className:j("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),h.jsx("div",{ref:l,className:j(Dj,"overflow-auto"),children:o?h.jsx(kF,{lines:o,label:"result-json"}):h.jsx("pre",{className:j("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(TF,{lines:u.lines,overflowing:u.overflowing})]})]})},ukt="mcp__",Okt={bash:OCe,read:g6,write:cY,edit:cY,glob:e$,grep:Xy,todo:gje,wake:sQ,list_variables:dY,read_variable:dY,browser:uY,console:y6,project:Aqe,project_delete:fCe,web_search:uY,web_fetch:lQ,task:Sd,agent:Sd,send:Ioe,peer:uje,sessions:Fje};function dkt(e){const t=e.trim().toLowerCase(),n=Okt[t];return n||(t.startsWith(ukt)?Noe:bCe)}const fkt=p6,hkt=Sje,pkt=bje,_F="min-h-5 py-0",XF={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},mkt=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?XF.plain:XF[x2e(t)],gkt=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",$kt=({added:e,removed:t})=>e<=0&&t<=0?null:h.jsxs("span",{className:j("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&h.jsxs("span",{className:j("text-success"),children:["+",e]}),t>0&&h.jsxs("span",{className:j("text-danger"),children:["-",t]})]}),a2={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},ykt=1e3;function vkt(e){const[t,n]=y.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return y.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,ykt);return()=>window.clearInterval(i)},[e]),t}const bkt=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=vkt(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?d2e[t]:void 0,c=s?l??null:o?l??a2[e]:null,O=j("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?p2e[t]??null:null,f=s&&t?f2e[t]:void 0,p=s?t==="mailbox"?hkt:t==="unconfirmed"?pkt:null:e==="interrupted"?fkt:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":uf(a??0):hae(n);return h.jsxs("span",{className:j("flex shrink-0 items-center gap-1.5"),children:[c?h.jsx("span",{className:O,title:f,"aria-hidden":d?!0:void 0,children:c}):null,h.jsxs("span",{className:j("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",m),children:[p?h.jsx(p,{"aria-hidden":!0}):null,!o&&a2[e]?h.jsx("span",{className:j("sr-only"),children:a2[e]}):null,d?h.jsx("span",{className:j("sr-only"),children:d}):null]}),h.jsx("span",{className:j("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:g})]})},_d=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,outcome:o,deliveryState:s=null,durationS:l,startedAt:c=null,added:u=0,removed:O=0,details:d,defaultOpen:f=!1,className:p,media:m})=>{const g=o==="running",$=o==="error",v=dkt(e),w=Ud(e),{verb:x,object:b}=gae(e,r,i,g,t,g2e(s)),S=h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),children:[h.jsx("span",{"aria-hidden":!0,className:j("flex size-3.5 shrink-0 [&_svg]:size-3.5",mkt(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:j("shrink-0 whitespace-nowrap text-body-sm",gkt(o)),title:w,children:x}),h.jsx("span",{className:j("min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:b,children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),h.jsx("span",{className:j("sr-only"),children:"pending"})]}):b}),h.jsx($kt,{added:u,removed:O}),h.jsx(bkt,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?"bg-elevated":$?"bg-danger-wash":"hover:bg-row-hover",P=d?h.jsx(Bo,{summary:S,chevron:"leading",defaultOpen:f,className:j("@container/toolrow",p),rowClassName:_F,triggerClassName:j("-mx-2 rounded-sm px-2",Q),children:d}):h.jsx(Bo,{disabled:!0,summary:S,rowClassName:_F,className:j("@container/toolrow",(g||$)&&j("-mx-2 rounded-sm px-2",Q),p)});return m?h.jsxs("div",{className:j("flex flex-col"),children:[P,m]}):P},wkt=3,jbe=e=>{const t=e.toLowerCase();return t==="read"||t==="grep"||t==="glob"||t==="ls"||t==="list"?"files":t==="search_the_web"||t==="web_search"||t==="search"?"web":t==="bash"||t==="exec"||t==="shell"||t==="run"?"commands":t==="edit"||t==="write"||t==="multiedit"?"edits":t==="task"||t==="delegate"?"delegated":t==="fetch"||t==="web_fetch"||t==="fetch_url"?"searches":null},Cbe=e=>{const t=new Map;let n=0;for(const a of e){const o=jbe(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=Qkt(kkt(e));return{units:a.length===0?[`${e.length} actions`]:a,prose:!1}}const r=["files","searches","web","commands","edits","delegated"],i=[];for(const a of r){const o=t.get(a)??0;o!==0&&(a==="files"&&i.push(`Explored ${o} file${o===1?"":"s"}`),a==="searches"&&i.push(`${o} search${o===1?"":"es"}`),a==="web"&&i.push(`Searched the web ${o} time${o===1?"":"s"}`),a==="commands"&&i.push(`Ran ${o} command${o===1?"":"s"}`),a==="edits"&&i.push(`Edited ${o} file${o===1?"":"s"}`),a==="delegated"&&i.push(`Delegated ${o} task${o===1?"":"s"}`))}return i.length===0?{units:[`${e.length} actions`],prose:!0}:{units:[i.length===1?i[0]:`${i[0]}, ${i[1].charAt(0).toLowerCase()}${i[1].slice(1)}`],prose:!0}},Skt=e=>Cbe(e).units;function xkt(e){return Skt(e).join(" · ")}const RF={agent:{noun:"agent",plural:"agents"},team:{noun:"team",plural:"teams"},team_delete:{noun:"team deletion",plural:"team deletions"},hub:{noun:"subagent",plural:"subagents"},secret:{noun:"secret",plural:"secrets"},project:{noun:"project",plural:"projects"},project_delete:{noun:"project deletion",plural:"project deletions"},wake:{noun:"wake",plural:"wakes"},jobs:{noun:"job",plural:"jobs"},console:{noun:"console",plural:"consoles"},network:{noun:"network call",plural:"network calls"},browser:{noun:"browser action",plural:"browser actions"},todo:{noun:"todo update",plural:"todo updates"},send:{noun:"message",plural:"messages"},ask:{noun:"question",plural:"questions"},wait:{noun:"wait",plural:"waits"},lsp:{noun:"code lookup",plural:"code lookups"},web_read:{noun:"page",plural:"pages"},list_variables:{noun:"variable lookup",plural:"variable lookups"},read_variable:{noun:"variable read",plural:"variable reads"},sessions:{noun:"session",plural:"sessions"}},o2=5,Qkt=e=>{if(e.length<=o2)return e.map(r=>r.label);const t=e.slice(0,o2),n=e.slice(o2).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},kkt=e=>{const t=new Map,n=(s,l)=>{const c=t.get(s);c?c.count+=1:t.set(s,{kind:l,count:1})};for(const s of e){const l=s.name.toLowerCase();if(l==="bash"||l==="exec"||l==="shell"||l==="run"){n("kind:shell",{noun:"shell",plural:null});continue}if(l==="eval"){n("kind:python",{noun:"python",plural:null});continue}const c=jbe(s.name);if(c==="files")n("class:files",{noun:"file",plural:"files"});else if(c==="searches")n("class:searches",{noun:"search",plural:"searches"});else if(c==="web")n("class:web",{noun:"web search",plural:"web searches"});else if(c==="edits")n("class:edits",{noun:"edit",plural:"edits"});else if(c==="delegated")n("class:delegated",{noun:"task",plural:"tasks"});else if(l==="todo")(s.op??"").toLowerCase()==="view"?n("kind:todo:view",{noun:"todo read",plural:"todo reads"}):n("kind:todo",RF.todo);else{const u=RF[l];if(u)n(`kind:${l}`,u);else{const O=Ud(s.name);n(`name:${O}`,{noun:O,plural:null})}}}const r=["class:files","class:searches","class:web","kind:shell","kind:python","class:edits","class:delegated","kind:agent","kind:team","kind:hub"],i=[],a=(s,l)=>`${s} ${s===1||l.plural===null?l.noun:l.plural}`;for(const s of r){const l=t.get(s);l&&i.push({label:a(l.count,l.kind),count:l.count})}const o=[...t.entries()].filter(([s])=>!r.includes(s)).sort(([,s],[,l])=>l.count-s.count||s.kind.noun.localeCompare(l.kind.noun));for(const[,s]of o)i.push({label:a(s.count,s.kind),count:s.count});return i};function Pkt(e){return e.running===!0?typeof e.startedAtMs!="number"?null:{startMs:e.startedAtMs,endMs:null}:typeof e.endedAtMs!="number"||typeof e.durationS!="number"?null:{startMs:e.endedAtMs-e.durationS*1e3,endMs:e.endedAtMs}}function Tkt(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=Pkt(i);a&&(t=t===null?a.startMs:Math.min(t,a.startMs),a.endMs!==null&&(n=n===null?a.endMs:Math.max(n,a.endMs)))}return t===null||n===null&&!r?null:{startedAtMs:t,endedAtMs:n,running:r}}function _kt(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return gae(n.name,n.summary??"",null,!0,n.op)}return null}function Xkt(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.map(o=>{const s={name:t.nameOf(o),failed:t.failedOf(o),durationS:t.durationOf?t.durationOf(o):null,startedAtMs:t.startedAtOf?t.startedAtOf(o):null,endedAtMs:t.endedAtOf?t.endedAtOf(o):null};return t.summaryOf&&(s.summary=t.summaryOf(o)),t.opOf&&(s.op=t.opOf(o)),t.runningOf&&(s.running=t.runningOf(o)),t.executingOf&&(s.executing=t.executingOf(o)),s});if(r.length>=wkt)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:a,summary:Cbe(a),failedCount:a.filter(o=>o.failed).length,span:Tkt(a),live:_kt(a)});else for(const o of r)n.push({kind:"row",row:o});r=[]};for(const a of e){if((a.gap==="turn"||a.gap==="first")&&i(),t.isFoldable(a)){r.push(a);continue}i(),n.push({kind:"row",row:a})}return i(),n}const EF=e=>{const t=[];for(const n of e)n.record.kind==="tool"&&t.push(...n.record.images);return t},aw=5,Rkt=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<aw?{shown:Math.max(e,0),more:0}:{shown:aw-1,more:e-(aw-1)},Ekt=e=>{const t=aw-1;if(e<=0)return[];if(e<=t)return[e];const n=Array.from({length:Math.floor(e/t)},()=>t),r=e%t;return r===1?(n[n.length-1]=t-1,n.push(2)):r>1&&n.push(r),n},CS=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function Vj(e){return e.record.kind==="tool"?e.record.durationS:null}function qkt(e){let t=null;for(const n of e){const r=Vj(n);typeof r=="number"&&(t=(t??0)+r)}return t}function jkt(e,t){const n=new Map,r=t.opensRun??(l=>l.gap==="turn"||l.gap==="first");let i=0,a=0,o=null,s=null;for(const l of e){if(r(l)&&(i=0,a=0,o=null,s=null),t.isAction(l)){i+=1,t.failedOf(l)&&(a+=1,s??=l.record.id);const c=t.durationOf?t.durationOf(l):null;typeof c=="number"&&(o=(o??0)+c)}l.closesTurn&&n.set(l.record.id,{actions:i,failed:a,durationS:o,firstFailedId:s})}return n}const Ckt="min-h-5 py-0",zkt=1e3;function Akt(e){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,zkt);return()=>window.clearInterval(i)},[e]),t}const Ukt=({summary:e,actionCount:t,span:n,live:r,open:i,onOpenChange:a,className:o,condensedMedia:s,mediaCount:l=0,recordIds:c,children:u})=>{const O=Akt(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":hae(d),p=y.useRef(null),m=()=>{p.current?.querySelector("button[aria-expanded]")?.focus(),a(!0)};return h.jsxs("div",{ref:p,className:o,"data-fold-ids":c.join(" "),children:[h.jsx(Bo,{open:i,onOpenChange:a,rowClassName:Ckt,triggerClassName:j("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),children:[r!==null&&!i&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{"data-fold-live":"",className:j("min-w-0 shrink-[100000] truncate"),title:`${r.verb} ${r.object}`,children:[h.jsx("span",{className:j("text-accent"),children:r.verb})," ",h.jsx("span",{className:j("font-mono text-mono-sm text-ink-muted"),children:r.object})]}),h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"})]}),h.jsx("span",{className:j("min-w-0 break-words text-body-sm text-ink-muted"),title:`${t} actions`,"data-fold-summary":"",children:e.units.map((g,$)=>h.jsxs(y.Fragment,{children:[$>0&&h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:j(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),CS(l)!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{className:j("shrink-0 text-ink-muted text-meta"),children:CS(l)})]}),f!==""&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{"data-fold-span":"",className:j("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:f})]})]}),children:h.jsx("div",{className:j("flex flex-col"),children:u})}),!i&&s&&s(m)]})},Wkt="min-h-5 py-0",s2=()=>h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),Ykt=({recordIds:e,segmentIds:t,anchorRecordId:n,className:r,durationS:i,actionCount:a,partial:o=!1,title:s,stampTs:l,label:c=null,completed:u=!1,open:O,onOpenChange:d,children:f,condensedMedia:p,mediaCount:m=0})=>{const g=o?`${a}+ actions`:a===1?"1 action":`${a} actions`,$=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,v=y.useRef(null),w=()=>{v.current?.querySelector("button[aria-expanded]")?.focus(),d(!0)};return h.jsxs("div",{ref:v,className:j("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u?"true":void 0,"data-record-id":n,children:[h.jsx(Bo,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:Wkt,triggerClassName:j("-ml-2 -mr-2 w-[calc(100%+1rem)] rounded-sm pl-2 pr-6","hover:bg-row-hover"),chevronClassName:j("-mr-6","text-ink-muted"),summary:h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&h.jsx(h.Fragment,{children:h.jsx(A7,{"aria-hidden":!0,className:j("size-3.5 shrink-0 text-success")})}),c!==null&&(i!==null||a>0)&&h.jsx(s2,{}),i!==null&&h.jsxs("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:["Took ",uf(i)]}),i!==null&&a>0&&h.jsx(s2,{}),a>0&&h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),title:o?$:void 0,"aria-label":o?$:void 0,children:g}),CS(m)!==null&&h.jsxs(h.Fragment,{children:[h.jsx(s2,{}),h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:CS(m)})]}),u&&h.jsx("span",{className:j("sr-only"),children:"completed"}),l!==null&&h.jsx("span",{className:j("ml-auto"),children:h.jsx(_be,{timestamp:l,scope:"answer"})})]}),children:h.jsx("div",{className:j("flex flex-col"),children:f})}),!O&&p&&h.jsx("div",{className:j("pb-2"),children:p(w)})]})},zbe=e=>{const t=y.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=y.useCallback(()=>window.matchMedia(e).matches,[e]);return y.useSyncExternalStore(t,n,()=>!1)},qF=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],Gkt=80,Nkt=1e3,Zkt=({activity:e,phase:t,startedAt:n,clock:r,className:i})=>{const[a,o]=y.useState(0),[s,l]=y.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),[c,u]=y.useState(!1),O=r!==!1&&!c,d=zbe("(prefers-reduced-motion: reduce)"),f=y.useRef(n??Date.now()),p=y.useRef(t),m=y.useRef(n);if(p.current!==t)p.current=t,m.current=n,f.current=n??Date.now(),c&&u(!1),l(0);else if(m.current!==n){const v=m.current!==void 0&&n===void 0;m.current=n,u(v),v||(f.current=n,l(Math.floor((Date.now()-n)/1e3)))}const g=y.useRef(r!==!1),$=y.useRef(t);return y.useEffect(()=>{const v=r!==!1,w=g.current,x=$.current===t;g.current=v,$.current=t,!w&&v&&x&&l(Math.floor((Date.now()-f.current)/1e3))},[r,t]),y.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-f.current)/1e3)),Nkt):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const w=window.setInterval(()=>o(x=>(x+1)%qF.length),Gkt);return()=>{window.clearInterval(w),v!==null&&window.clearInterval(v)}},[d,O]),h.jsxs("div",{className:j("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[h.jsx("span",{"aria-hidden":!0,className:j("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:qF[a]}),h.jsx("span",{className:j("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),h.jsx("span",{"aria-hidden":!0,className:j("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?uf(s):""})]})},Abe="lo-missing-session-notice",Ikt=/^\s*<reply-to>([\s\S]*?)<\/reply-to>/,$A=e=>{const t=[];let n=e;for(;;){const r=Ikt.exec(n);if(r===null)break;t.push({id:Wo(),text:r[1]}),n=n.slice(r[0].length)}return{replies:t,remainingContent:n.trim()}},Ube=({children:e,className:t,boundary:n="hairline",...r})=>h.jsx("div",{className:j("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm bg-sunken",n==="control"?["border border-transparent","transition-colors duration-fast ease-out-quart","group-hover/tile:border-control group-focus-visible/tile:border-control"]:"border border-hairline",t),...r,children:e}),Dkt="could not be displayed. It may have been moved, renamed, or deleted.",Wbe="could not be displayed. Its stored copy is not available to this reader.",Mj=({name:e,detail:t=Dkt,className:n,compact:r=!1})=>r?h.jsx("div",{className:j("flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken",n),role:"img","aria-label":`${e} ${t}`,title:`${e} ${t}`,children:h.jsx(OY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):h.jsxs("div",{className:j("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[h.jsx(OY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),h.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[h.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),Vkt=({filePath:e,tooltip:t="File actions",icon:n,"aria-label":r="File actions",onShowInCanvas:i})=>{const a=async()=>{if(e)try{await navigator.clipboard.writeText(e),ep("File path copied to clipboard")}catch(s){console.error("Failed to copy file path: ",s),Oo("Failed to copy file path")}},o=()=>{e&&window.api.openFile(e)};return h.jsxs(_ie,{children:[h.jsx(At,{content:t,children:h.jsx(Xie,{asChild:!0,children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:s=>s.stopPropagation(),children:n??h.jsx(Vqe,{"aria-hidden":"true"})})})}),h.jsxs(Rie,{align:"end",className:"min-w-45",onClick:s=>s.stopPropagation(),children:[i&&h.jsxs(hc,{onSelect:i,children:[h.jsx(pje,{"aria-hidden":"true"}),h.jsx("span",{children:"Show in canvas"})]}),h.jsxs(hc,{onSelect:o,children:[h.jsx($6,{"aria-hidden":"true"}),h.jsx("span",{children:"Open file"})]}),h.jsxs(hc,{onSelect:()=>window.api.showItemInFolder(e),children:[h.jsx(e$,{"aria-hidden":"true"}),h.jsx("span",{children:"Open folder"})]}),h.jsxs(hc,{onSelect:a,children:[h.jsx(qqe,{"aria-hidden":"true"}),h.jsx("span",{children:"Copy file path"})]})]})]})},l2="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",Ybe=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a})=>{const[o,s]=y.useState(!1);return q7(n,"image-lightbox"),h.jsx(j7,{open:n,onOpenChange:r,children:h.jsxs(C7,{showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:l=>{const c=i?.current;c&&(l.preventDefault(),c.focus())},className:j("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none",l2,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx(z7,{className:"sr-only",children:t}),o?h.jsx("div",{className:j(l2,"flex min-h-16 min-w-64 items-center justify-center p-6"),children:a}):h.jsx("img",{src:e,alt:t,className:j(l2,"object-contain"),onError:()=>s(!0)}),h.jsx(GPe,{asChild:!0,children:h.jsx(Ve,{variant:"ghost",size:"icon-sm",className:j("fixed top-4 right-4"),"aria-label":"Close image",children:h.jsx(Ri,{"aria-hidden":"true"})})})]})})};Ybe.displayName="ImageLightbox";const Mkt={full:"max-h-[240px] max-w-full object-contain",thumbnail:["h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]"].join(" ")},Lkt=/[/\\]/,jF=e=>{const t=e.split(Lkt);return t[t.length-1]},Gbe=y.memo(({file:e,src:t,conversationId:n,label:r,size:i="full"})=>{const[a,o]=y.useState(!1),[s,l]=y.useState(!1),[c,u]=y.useState(!1),O=y.useRef(null),d=Bn(x=>x.setCanvasOpen),{setViewMode:f}=Od(),p=y.useCallback(async()=>{const x=jF(e),b=R=>{R&&console.error("Error processing file:",R);const _=e.startsWith("file://")?e.substring(7):e;window.api.openFile(_).catch(E=>{console.error("Error opening file:",E)})},{setFiles:S,setOpenTabs:Q,setSelectedTab:P}=Od.getState();if(e.startsWith("data:"))if(zj(x)){const R=e,_={id:R,title:x,path:R,content:e,type:Gw(e)},C=Od.getState().conversations?.[n],W=C?.files??[],U=C?.openTabs??[],Y=(()=>{const B=W.findIndex(G=>G.id===R);return B!==-1?[...W.slice(0,B),_,...W.slice(B+1)]:[...W,_]})();S(n,Y);const M=U.some(B=>B.id===R)?U:[...U,{id:R,title:x}];Q(n,M),P(n,R),d(!0),f(n,"documents")}else d(!0),f(n,"files");else{const R=e.startsWith("file://")?e.substring(7):e;try{const _=await window.api.readFile(R);if(_.success&&zj(x)){const E=R,C={id:E,title:x,path:R,content:_.data,type:Gw(e)},U=Od.getState().conversations?.[n],Y=U?.files??[],V=U?.openTabs??[],M=(()=>{const A=Y.findIndex(ee=>ee.id===E);return A!==-1?[...Y.slice(0,A),C,...Y.slice(A+1)]:[...Y,C]})();S(n,M);const G=V.some(A=>A.id===E)?V:[...V,{id:E,title:x}];Q(n,G),P(n,E),d(!0),f(n,"documents");return}d(!0),f(n,"files")}catch(_){const E=_ instanceof Error?_.message:String(_??"Unknown error reading file");return b(E)}}},[e,d,f,n]),m=()=>{o(!0)},g=!e.startsWith("data:")&&!e.startsWith("blob:")&&!e.startsWith("http"),$=e.startsWith("file://")?e.substring(7):e,v=r??jF(e);if(a)return h.jsx(Mj,{name:v,compact:i==="thumbnail"});const w=h.jsx(Ube,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:j(Mkt[i],s?"opacity-100":"opacity-0"),src:t,alt:v,onLoad:()=>l(!0),onError:m})});return h.jsxs("div",{className:"group relative inline-block",children:[h.jsx("button",{ref:O,type:"button",className:j("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:()=>u(!0),"aria-label":`Expand ${v}`,title:`Click to expand ${v}`,children:w}),g&&h.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 right-1 z-[2] opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",onClick:x=>{x.stopPropagation()},onKeyDown:x=>x.stopPropagation(),children:h.jsx(Vkt,{filePath:$,tooltip:"File actions","aria-label":"File actions",onShowInCanvas:p})}),h.jsx(Ybe,{src:t,label:v,open:c,onOpenChange:u,restoreFocusTo:O,fallback:h.jsx(Mj,{name:v,detail:g?void 0:Wbe})})]})});Gbe.displayName="ImageAttachment";const Xd=new Map;function Fkt(e,t){return URL.createObjectURL(new Blob([e],{type:t}))}function Bkt(e){return Xd.get(e)?.url??null}function CF(e){const t=Xd.get(e);return t?(t.refs+=1,t.revoking=!1,t.url):null}function Hkt(e,t){if(Xd.get(e)){URL.revokeObjectURL(t);return}Xd.set(e,{url:t,refs:0,revoking:!1})}function zF(e){const t=Xd.get(e);t&&(t.refs-=1,!(t.refs>0)&&(t.revoking||(t.revoking=!0,queueMicrotask(()=>{!t.revoking||t.refs>0||(URL.revokeObjectURL(t.url),Xd.get(e)===t&&Xd.delete(e))}))))}const ow=new Map;function Kkt(e,t){const n=ow.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await Kh(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=Fkt(i.data,i.mimeType);return r.holders<=0?(URL.revokeObjectURL(a),null):(Hkt(t,a),a)}catch{return null}finally{ow.delete(t)}})(),ow.set(t,r),r.promise}function Jkt(e){const t=ow.get(e);t&&(t.holders-=1)}function ePt(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=y.useState(()=>e.attachment?Bkt(e.attachment):null),[a,o]=y.useState(!1),s=t?.sessionId??null,l=t?.childId??null;y.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=CF(u);if(d)return i(d),o(!1),()=>{O=!1,zF(u)};i(null),o(!1);let f=!0;return Kkt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(CF(u))}}),()=>{O=!1,f&&Jkt(u),zF(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}const yA=({image:e,scope:t,label:n,size:r})=>{const i=ePt(e,t);if(i.state==="resolving")return h.jsx("div",{className:j("inline-block max-w-full"),"aria-hidden":!0,children:h.jsx(Ube,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""})});if(i.state==="missing")return h.jsx(Mj,{name:n,compact:r==="thumbnail",detail:Wbe});const a=i.url;return h.jsx("div",{className:j("inline-block max-w-full"),children:h.jsx(Gbe,{file:a,src:a,label:n,size:r,conversationId:t?.sessionId??""})})},tPt="Generating name…",nPt={rest:"scale-x-60 bg-ink-dim",preview:"scale-x-90 bg-ink-muted",active:"scale-x-100 bg-ink",unloaded:"scale-x-40 bg-ink-dim opacity-75"};function rPt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function vA(e,t){return`Turn ${e} of ${t}`}const iPt=e=>e.charAt(0).toLowerCase()+e.slice(1);function aPt(e,t){const n=vA(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function oPt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function sPt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function lPt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const cPt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function uPt(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);if(Number.isNaN(t.getTime()))return"";const n=t.getHours(),r=t.getMinutes().toString().padStart(2,"0"),i=n%12===0?12:n%12,a=n<12?"AM":"PM";return`${i}:${r} ${a}`}function OPt(e,t){const n=iPt(vA(e.turn,t));if(e.kind==="user"){const i=uPt(e.ts);return i?`Jump to your message in ${n}, ${i}`:`Jump to your message in ${n}`}const r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`Jump to ${n}, ${r}`:`Jump to ${n}`}function dPt(e,t){const n=e.checkpoints.find(i=>i.id===t);return n?n.kind==="completion"?n.naming?.state??null:e.checkpoints.find(i=>i.kind==="completion"&&i.turn===n.turn)?.naming?.state??null:null}function fPt(e,t){const n=[];for(const r of t)dPt(e,r)==="pending"&&n.push(r);return n}const hPt=120,AF=80,pPt="Turn checkpoints",mPt={complete:Lc,error:Mh,interrupted:p6,open:Pqe},gPt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},$Pt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?mPt[n]:null,i=sPt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:j("text-body-sm font-medium text-ink"),children:[vA(e.turn,t),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:j("font-normal text-ink-muted"),children:a})]})]}),oPt(e)&&h.jsx("p",{className:j("text-ink-dim text-meta"),children:tPt}),i&&h.jsx("p",{className:j("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&h.jsx("div",{className:j("flex items-center gap-1.5 text-ink-dim text-meta"),children:h.jsxs("span",{className:j("flex items-center gap-1",gPt[n]),children:[h.jsx(r,{"aria-hidden":"true",className:j("size-3.5 shrink-0")}),cPt[n]]})})]})},yPt=y.memo(function({checkpoint:t,state:n,label:r,roving:i,registerTick:a,onPreview:o,onPreviewEnd:s,onFocusMark:l,onBlurMark:c,onActivate:u,onKeyMark:O,describedBy:d}){const f=p=>{p.pointerType!=="touch"&&o(t.id)};return h.jsx("button",{ref:p=>a(t.id,p),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":d,tabIndex:i?0:-1,className:j("group pointer-events-auto block h-2.5 w-7"),onPointerMove:f,onPointerLeave:s,onFocus:()=>l(t.id),onBlur:c,onClick:()=>u(t.id),onKeyDown:p=>O(p,t.id),children:h.jsx("span",{"aria-hidden":"true",className:j("ml-auto mr-1.5 block h-0.5 w-5 origin-right rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",nPt[n])})})}),vPt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{const s=y.useId(),[l,c]=y.useState(null),[u,O]=y.useState(null),[d,f]=y.useState(null),p=y.useRef(t);p.current=t;const m=y.useRef(new Map),g=y.useRef(null),$=y.useRef(null),v=y.useRef(null),w=y.useCallback(()=>{$.current!==null&&(clearTimeout($.current),$.current=null),v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),x=y.useCallback((Z,ne)=>{w();const te=()=>{O(Z),f(p.current.find(ie=>ie.id===Z)??null)};if(ne<=0){te();return}$.current=setTimeout(()=>{$.current=null,te()},ne)},[w]),b=y.useCallback(Z=>{if(w(),Z<=0){O(null);return}v.current=setTimeout(()=>{v.current=null,O(null)},Z)},[w]),S=y.useRef(e);y.useEffect(()=>{S.current!==e&&(S.current=e,w(),G.current=null,c(null),O(null),f(null))},[e,w]),y.useEffect(()=>{if(o===null)return;const Z=g.current,ne=m.current.get(o);if(Z===null||ne===void 0)return;const te=Z.getBoundingClientRect(),ie=ne.getBoundingClientRect(),$e=ie.top-te.top+Z.scrollTop,je=$e+ie.height,Oe=24;$e<Z.scrollTop+Oe?Z.scrollTop=Math.max(0,$e-Oe):je>Z.scrollTop+Z.clientHeight-Oe&&(Z.scrollTop=je-Z.clientHeight+Oe)},[o]),y.useEffect(()=>()=>w(),[w]);const Q=y.useRef(r);y.useEffect(()=>{Q.current=r});const P=y.useMemo(()=>lPt(t),[t]),R=y.useMemo(()=>new Map(t.map(Z=>[Z.id,OPt(Z,P)])),[t,P]),_=u&&d?.id===u?d:null,E=u&&m.current.get(u)||null,C=y.useMemo(()=>({current:E}),[E]),W=_!==null&&E!==null;y.useEffect(()=>{Q.current(W&&u?u:null)},[W,u]);const U=y.useCallback((Z,ne)=>{ne?m.current.set(Z,ne):m.current.delete(Z)},[]),[Y,V]=y.useState(null),M=Y&&t.some(Z=>Z.id===Y)?Y:t[0]?.id??null,B=y.useCallback(Z=>{const ne=Math.max(0,Math.min(t.length-1,Z)),te=t[ne];te&&(V(te.id),m.current.get(te.id)?.focus())},[t]),G=y.useRef(null),A=y.useCallback(Z=>{G.current!==Z&&(G.current=Z,c(Z),x(Z,hPt))},[x]),ee=y.useCallback(()=>{G.current=null,c(Z=>Z===null?Z:null),b(AF)},[b]),K=y.useCallback(Z=>{G.current=Z,V(Z),c(ne=>ne===Z?ne:Z),x(Z,0)},[x]),z=y.useCallback(()=>{G.current=null,c(Z=>Z===null?Z:null),b(AF)},[b]),le=y.useCallback(Z=>{b(0),G.current=null,c(null),n(Z)},[b,n]),L=y.useCallback((Z,ne)=>{if(Z.key==="Escape"){b(0);return}const te=t.findIndex(ie=>ie.id===ne);if(!(te<0)){if(Z.key==="ArrowDown"){Z.preventDefault(),Z.stopPropagation(),B(te+1);return}if(Z.key==="ArrowUp"){Z.preventDefault(),Z.stopPropagation(),B(te-1);return}if(Z.key==="Home"){Z.preventDefault(),Z.stopPropagation(),B(0);return}Z.key==="End"&&(Z.preventDefault(),Z.stopPropagation(),B(t.length-1))}},[t,b,B]);return t.length===0&&!i?null:h.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":pPt,className:j("pointer-events-none absolute inset-y-0 right-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[h.jsxs("div",{"data-rail-frame":"",ref:g,className:j("max-h-[min(calc(100%-4rem),420px)] w-7 overflow-y-auto overscroll-contain","[&::-webkit-scrollbar]:hidden","[mask-image:linear-gradient(to_bottom,transparent_0,#000_24px,#000_calc(100%-24px),transparent_100%)]"),children:[i&&h.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:j("ml-auto mr-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),h.jsx("div",{"data-rail-track":"",className:"py-6",children:t.map(Z=>h.jsx(yPt,{checkpoint:Z,state:rPt({id:Z.id,previewId:l,activeId:o,loaded:a?a.has(Z.id):!0}),label:R.get(Z.id)??"",roving:Z.id===M,registerTick:U,onPreview:A,onPreviewEnd:ee,onFocusMark:K,onBlurMark:z,onActivate:le,onKeyMark:L,describedBy:W&&u===Z.id?s:void 0},Z.id))})]}),h.jsxs(NPe,{open:W,onOpenChange:Z=>{Z||b(0)},children:[h.jsx(ZPe,{virtualRef:C}),_&&h.jsx(IPe,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":_.kind==="user"?"Your message":aPt(_,P),onOpenAutoFocus:Z=>Z.preventDefault(),onCloseAutoFocus:Z=>Z.preventDefault(),onFocusOutside:Z=>{const ne=Z.detail?.originalEvent?.target;ne instanceof Element&&ne.closest("[data-lo-checkpoint-rail]")&&Z.preventDefault()},className:j("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:_.kind==="user"?h.jsx("div",{"data-checkpoint-card-text":"",className:j("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:_.text}):h.jsx($Pt,{checkpoint:_,turnCount:P})})]})]})},bPt=y.memo(vPt);function wPt(e,t){if(!t)return e;let n=!1;const r=[];for(const i of e){if(i.kind==="peer"||i.kind==="tool"&&i.toolName==="send"){n=!0;continue}r.push(i)}return n?r:e}const SPt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function xPt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function Nbe(e,t){const n=[["[data-turn-summary]","data-run-ids"],["[data-fold-ids]","data-fold-ids"]];for(const[r,i]of n)for(const a of e.querySelectorAll(r)){const o=a.getAttribute("data-segment-ids");if(o!==null?!o.split(" ").includes(t):!SPt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function QPt(e,t){return xPt(e,t)||Nbe(e,t)!==null}const kPt=3;function PPt(e,t,n){const r=i=>{const a=e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`);if(a){const l=a.querySelector("button[aria-expanded]");l?.getAttribute("aria-expanded")==="false"&&l.click(),n.onRevealed(a);return}if(i>=kPt){n.onMissing();return}const s=Nbe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const UF=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=Rkt(e.length,{uncapped:r}),s=Ekt(a),l=s.length>1,c=new Set;for(let O=0,d=0;d<s.length;d+=1)c.add(O),O+=s[d];const u=e.slice(0,a).map((O,d)=>h.jsx("li",{className:j("flex leading-none",l&&c.has(d)&&"col-start-1"),children:h.jsx(yA,{image:O,scope:t,size:"thumbnail",label:e.length===1?"Image":`Image ${d+1}`})},O.id));return h.jsxs("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-fold-media":"",className:j("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ml-5":"ml-0"),children:[u,o>0&&h.jsx("li",{className:j("flex h-[78px] items-center leading-none"),children:h.jsx(Ve,{variant:"outline",size:"sm",onClick:n,"aria-label":`+${o} more image${o===1?"":"s"}`,title:`+${o} more image${o===1?"":"s"}`,children:`+${o}`})},"fold-media-more")]})};function TPt(e,t){if(t.length===0)return!1;const n=e.find(i=>i.ids[0]===t[0]);return n?n.open:e.find(i=>i.ids.some(a=>t.includes(a)))?.open??!1}function _Pt(e,t,n,r){if(t.length===0)return[...e];const i=t[0],a=[];let o=!1;for(const s of e){if(!(s.ids[0]===i||s.ids.some(c=>t.includes(c)))){a.push(s);continue}o||(a.push({ids:[...t],open:n}),o=!0)}return o||a.push({ids:[...t],open:n}),a.filter(s=>s.ids.some(l=>r.has(l)))}const x0=1e4,Zbe=/\s/,XPt=e=>{for(let t=e.length;t>0;t-=1){const n=e[t-1];if(n===`
|
|
816
|
+
`)&&(s={capture:jS(e),buffer:n,caret:r})}return{...s,capture:bh(s.capture,s.buffer,s.caret,i)}}function txt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Qf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=sbe(i,t.value),c=l+wk,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:_a,buffer:u,caret:s+c.length,payload:{index:i,key:Obe(a,e.draw),value:t.value,marker:l}}}function nxt(e,t){const n=Qf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=ube(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:_a,buffer:i,caret:n.start+r.length,restored:Yj(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:Yj(r),restoredText:r}}}function iF(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function rxt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Qf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:jS(e),buffer:i,caret:a,payload:null}}function ixt(e){const{capture:t,buffer:n,caret:r,pasted:i}=e;if(t.arm===null)return null;if(t.typingAt!==null&&t.value!==""){if(i==="")return null;const u=dA(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=mn(i);if(!a)return i===""?null:rxt(t,n,e.selection,i);const o=t.arm,s=sbe(e.index,a),l=s+wk,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:_a,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:Obe(e.taken,e.draw),value:a,marker:s}}}const obe=e=>`${Yj(e)} chars`,sbe=(e,t)=>`[Credential #${e}, ${obe(t)}]`;function axt(e){ml.lastIndex=0;const t=ml.exec(e);return ml.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function oxt(e){ml.lastIndex=0;const t=ml.exec(e);if(ml.lastIndex=0,t===null||t[0]!==e)return null;const n=Number.parseInt(t[1],10);return{index:n,label:`#${n}`,chars:Number.parseInt(t[2],10)}}function nv(e,t){if(axt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const J_=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,e2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,t2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,sxt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&Wj.test(t[1])?t[1]:""};function lxt(e,t){if(e.charCodeAt(t)!==91)return null;J_.lastIndex=t;const n=J_.exec(e);if(J_.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};e2.lastIndex=t;const r=e2.exec(e);if(e2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};t2.lastIndex=t;const i=t2.exec(e);return t2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:sxt(i[0])}:null}function Sk(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=lxt(e,r);if(i===null){r++;continue}r>n&&t.push({kind:"text",text:e.slice(n,r)}),t.push(i),r+=i.text.length,n=r}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}function aF(e,t){const n=[];for(const r of t){const i=nv(e,r);i!==null&&n.push({at:i.start,payload:r})}return n.sort((r,i)=>r.at-i.at).map(r=>r.payload)}function cxt(e,t=""){return e==="unconfirmed"?t?`[credential unconfirmed — it may be held as $${t}, so check list_variables before assuming it is missing]`:"[credential unconfirmed — the session may hold it, so check list_variables before assuming it is missing]":e==="unreachable"?"[credential NOT stored — the session could not be reached; try again]":e==="rejected-key"?"[credential NOT stored — the store rejected its name]":"[credential NOT stored — its value did not survive; ask the operator to paste it again]"}const uxt=e=>`[credential ${e.key} (${obe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function Oxt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=nv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of nbe(e,r))i.push({span:o,payload:null});let a=e;for(const{span:o,payload:s}of i.sort((l,c)=>c.span.start-l.span.start)){const l=s===null?"lost":n.get(s.index),c=s===null||l!==void 0?cxt(l??"lost",s?.key):uxt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const dxt=(e,t,n)=>`Removed ${e} (credential #${t}) from this message. Its value is gone — press ${n} to put it back, or paste it again after /credential to reuse it.`,fxt=e=>`Remove credential #${e}`,hxt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,pxt=(e,t,n)=>dxt(e,t,n),mxt="Undo",gxt=e=>`Credential #${e} removed`,$xt=e=>e.unredacted!==null?e.unredacted:e.armed?Qxt:e.cleared!==null?pxt(e.cleared.key,e.cleared.index,e.undoCap):null;function yxt(e){const{buffer:t,payload:n}=e,r=nv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===wk?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function vxt(e){const{buffer:t,cleared:n}=e;return n.removed===""||t!==n.buffer?null:{buffer:t.slice(0,n.caret)+n.removed+t.slice(n.caret),caret:n.caret+n.removed.length}}const oF=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function sF(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be stored (${[...e].sort().join(", ")}); the agent has been told so. Paste the value again after /credential to retry.`}const bxt="store unconfirmed",wxt="Credential store unconfirmed",Sxt=e=>e===""?wxt:`${e} · ${bxt}`,lbe="Paste the value again after /credential to store it again.",xxt=e=>`${e} ${lbe}`;function lF(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be confirmed as stored (${[...e].sort().join(", ")}); the agent has been told to check before using it. ${lbe}`}const Qxt="armed — add a space, then type or paste the secret",kxt="masked as you type — Enter turns it into a pill, Esc cancels",Pxt="masked — Enter opens the credential picker; type or paste the secret into this span",Txt="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",cbe="\0held",_xt=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===cbe?`${e} characters are now PLAIN TEXT in the composer — Enter is held: clear the box to release your words`:`${e} characters are now PLAIN TEXT in the composer — Enter will take them as /${t}'s argument, not send them`;function ube(e,t){const n=Qf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const cF=(e,t)=>e&&e.over===t?e.chars:null,Xxt=e=>{const t=Math.floor(4294967296/e)*e,n=new Uint32Array(1);for(;;)if(globalThis.crypto.getRandomValues(n),n[0]<t)return n[0]%e},Rxt=16,Ext=16;function Obe(e=[],t=Xxt){const n=new Set(e);for(let r=0;r<Rxt;r++){const i=tF+uF(8,t);if(!n.has(i))return i}return tF+uF(Ext,t)}const uF=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=eF[t(eF.length)];return n},dbe=j("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),fbe=j("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),hbe=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>h.jsxs("span",{className:j("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?fbe:dbe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(Tie,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(dje,{"aria-hidden":"true",className:"size-3 shrink-0"}),h.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&h.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&h.jsx("button",{type:"button","aria-label":a,onClick:i,className:"pointer-events-auto -mr-1 flex shrink-0 cursor-pointer items-center rounded-xs p-0.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-offset-1! active:bg-sunken",children:h.jsx(Ri,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),W$="#lo-credential/",qxt=`${W$}unstored`,OF=`${W$}unconfirmed`,jxt=/^\d+$/,pbe=e=>e.kind==="stored"?`${W$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${OF}/${e.key}`:OF:qxt;function Cxt(e){if(!e||!e.startsWith(W$))return null;const t=e.slice(W$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return Wj.test(a)?{kind:"unconfirmed",key:a}:null}const n=t.lastIndexOf("/");if(n===-1)return null;const r=t.slice(0,n),i=t.slice(n+1);return!Wj.test(r)||!jxt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function dF(e,t){const n=Cxt(e);if(n===null)return null;const r=Sk(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return pbe(i)!==e?null:n}const xk=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=Sk(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:pbe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},zxt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?Sxt(e.key):"Credential not stored",Axt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?xxt(t):t,Uxt=({citation:e,title:t})=>h.jsx(hbe,{tone:e.kind==="stored"?"live":"warning",label:zxt(e),chars:e.kind==="stored"?e.chars:null,title:Axt(e,t),className:"align-middle"}),Wxt=(e,t)=>typeof t=="string"?dF(e,t):t==null?dF(e,""):null,Yxt=e=>({href:t,title:n,children:r})=>{const i=Wxt(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(Uxt,{citation:i,title:n})};function Gxt(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:s,mathText:o,mathTextData:s}};function e(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function t(){this.buffer()}function n(){const l=this.resume(),c=this.stack[this.stack.length-1];c.type,c.meta=l}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c;const O=u.data.hChildren[0];O.type,O.tagName,O.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function a(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function o(l){const c=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function s(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}const Nxt={tokenize:Zxt,concrete:!0,name:"mathFlow"},fF={tokenize:Ixt,partial:!0};function Zxt(e,t,n){const r=this,i=r.events[r.events.length-1],a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return s;function s(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),o++,l):o<2?n(v):(e.exit("mathFlowFenceSequence"),sn(e,c,"whitespace")(v))}function c(v){return v===null||$t(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||$t(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(fF,d,g)(v)}function d(v){return e.attempt({tokenize:$,partial:!0},g,f)(v)}function f(v){return(a?sn(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):$t(v)?e.attempt(fF,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||$t(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function $(v,w,x){let b=0;return sn(v,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(R){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(R)}function Q(R){return R===36?(b++,v.consume(R),Q):b<o?x(R):(v.exit("mathFlowFenceSequence"),sn(v,P,"whitespace")(R))}function P(R){return R===null||$t(R)?(v.exit("mathFlowFence"),w(R)):x(R)}}}function Ixt(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Dxt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Vxt,previous:Mxt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):$t(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),f(m))}function f(m){return m===null||m===32||m===36||$t(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),f)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",f(m))}}}function Vxt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Mxt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Lxt(e){return{flow:{36:Nxt},text:{36:Dxt()}}}const wh=36,hF=e=>e!==null&&e<-2,pF=e=>e===null||e===32||e<0,mF=e=>e!==null&&e>=48&&e<=57,mbe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:Fxt,previous:Bxt,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(g){return r.enter("mathText"),r.enter("mathTextSequence"),d(g)}function d(g){return g===wh?(r.consume(g),s++,d):s<2&&!t||s===1&&(pF(g)||mF(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===wh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):hF(g)?(r.enter("lineEnding"),r.consume(g),r.exit("lineEnding"),f):(r.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===wh||hF(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===wh?(r.consume(g),c++,m):c===s?s===1&&(pF(l)||mF(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function Fxt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Bxt(e){return e!==wh||this.events[this.events.length-1][1].type==="characterEscape"}const Hxt=Lxt().flow,Kxt=mbe();function Qk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?Kxt:mbe(e);n.push({flow:Hxt,text:{[wh]:i}}),r.push(Gxt())}const Jxt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),eQt=/\$(?!\d)(.+?)\$/,tQt=/\$\$([\s\S]+?)\$\$/,nQt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,rQt=/\\[a-zA-Z]+(\{[^}]*\})?/,gF=e=>eQt.test(e)||tQt.test(e)||nQt.test(e)?!0:rQt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),iQt=e=>{const t=Sk(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},aQt=e=>Sk(e).filter(t=>t.kind!=="text").length,oQt=e=>{if(!gF(e))return!1;const t=iQt(e);return t===null?!0:gF(t)||t.includes("$")?!1:aQt(e)<2},Kt="var(--color-ink)",Ml="var(--color-ink-muted)",Hs="var(--color-surface)",bu="var(--color-elevated)",Ll="var(--color-sunken)",Ci="var(--color-hairline)",wu="var(--color-control)",eh="var(--color-accent)",Dg="var(--color-accent-wash)",sQt="var(--color-accent-alt-wash)",lQt="var(--color-on-accent)",cQt="var(--color-info)",gbe="var(--color-info-wash)",uQt="var(--color-success)",$be="var(--color-success-wash)",OQt="var(--color-warning)",Nj="var(--color-warning-wash)",dQt="var(--color-warning-border)",n2="var(--color-danger)",Zj="var(--color-danger-wash)",$F=[Dg,sQt,gbe,$be,Nj,Zj],Su=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),fQt=()=>{const e={primaryColor:Su("--color-accent"),secondaryColor:Su("--color-success"),tertiaryColor:Su("--color-info"),mainBkg:Su("--color-elevated"),clusterBkg:Su("--color-sunken"),clusterBorder:Su("--color-hairline"),edgeLabelBackground:Su("--color-surface"),quadrant1Fill:Su("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:Hs,primaryTextColor:Kt,primaryBorderColor:wu,secondaryTextColor:Kt,secondaryBorderColor:Ci,tertiaryTextColor:Kt,tertiaryBorderColor:Ci,lineColor:Ml,arrowheadColor:Ml,textColor:Kt,secondBkg:Ll,border1:wu,border2:Ci,labelColor:Kt,nodeBkg:bu,nodeBorder:wu,nodeTextColor:Kt,defaultLinkColor:Ml,titleColor:Kt,noteBkgColor:Nj,noteBorderColor:dQt,noteTextColor:Kt,actorBkg:bu,actorBorder:wu,actorTextColor:Kt,actorLineColor:Ci,signalColor:Ml,signalTextColor:Kt,labelBoxBkgColor:bu,labelBoxBorderColor:Ci,labelTextColor:Kt,loopTextColor:Kt,activationBkgColor:Dg,activationBorderColor:eh,sequenceNumberColor:Hs,sectionBkgColor:Ll,sectionBkgColor2:Hs,altSectionBkgColor:Ll,excludeBkgColor:Ll,taskBkgColor:Dg,taskBorderColor:wu,taskTextColor:Kt,taskTextLightColor:Kt,taskTextDarkColor:Kt,taskTextOutsideColor:Kt,taskTextClickableColor:eh,activeTaskBkgColor:Dg,activeTaskBorderColor:eh,gridColor:Ci,doneTaskBkgColor:Ll,doneTaskBorderColor:Ci,critBkgColor:Zj,critBorderColor:n2,todayLineColor:eh,transitionColor:Ml,transitionLabelColor:Kt,stateLabelColor:Kt,stateBkg:bu,labelBackgroundColor:Hs,compositeBackground:Ll,altBackground:Ll,compositeTitleBackground:bu,compositeBorder:Ci,innerEndBackground:Kt,specialStateColor:Kt,classText:Kt,attributeBackgroundColorOdd:Hs,attributeBackgroundColorEven:Ll,rowOdd:Hs,rowEven:Ll,errorBkgColor:Zj,errorTextColor:n2,pieTitleTextColor:Kt,pieSectionTextColor:Kt,pieLegendTextColor:Kt,pieStrokeColor:Hs,pieOuterStrokeColor:Ci,requirementBackground:bu,requirementBorderColor:wu,requirementTextColor:Kt,relationColor:Ml,relationLabelBackground:Hs,relationLabelColor:Kt,branchLabelColor:lQt,commitLabelColor:Kt,commitLabelBackground:Hs,tagLabelColor:Kt,tagLabelBackground:Dg,tagLabelBorder:wu,quadrant2Fill:gbe,quadrant3Fill:$be,quadrant4Fill:Nj,quadrant2TextFill:Kt,quadrant3TextFill:Kt,quadrant4TextFill:Kt,quadrantPointFill:eh,archEdgeColor:Ml,archEdgeArrowColor:Ml,archGroupBorderColor:Ci,scaleLabelColor:Kt,packet:{startByteColor:Kt,endByteColor:Kt,labelColor:Kt,titleColor:Kt,blockStrokeColor:wu,blockFillColor:bu},radar:{axisColor:Ml,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Ci,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Hs,titleColor:Kt,xAxisTitleColor:Kt,xAxisLabelColor:Kt,xAxisTickColor:Ci,xAxisLineColor:Ci,yAxisTitleColor:Kt,yAxisLabelColor:Kt,yAxisTickColor:Ci,yAxisLineColor:Ci,plotColorPalette:[eh,cQt,uQt,OQt,n2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=bu,t[`surfacePeer${n}`]=Ci;for(let n=0;n<8;n++)t[`fillType${n}`]=$F[n%$F.length];return{...t,...e}};let r2=null,yF=null;const hQt=async e=>{r2||(r2=de(async()=>{const{default:n}=await import("./mermaid.core-Dd6Z4632.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,2,3]),import.meta.url).then(({default:n})=>n));const t=await r2;return yF!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:fQt()}),yF=e),t},vF=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:j("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(At,{content:"Zoom in",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(QCe,{})})}),h.jsx(At,{content:"Zoom out",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(PCe,{})})}),h.jsx(At,{content:"Drag the diagram to pan",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(jje,{})})}),h.jsx(At,{content:"Reset view",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(v6,{})})}),h.jsx(At,{content:"Save as SVG",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(lQ,{})})}),h.jsx(At,{content:t?"Copied":"Copy mermaid text",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(m6,{className:j(t&&"text-success")})})}),s]}),Ij=({title:e,children:t})=>h.jsxs(xc,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(b1,{children:e}),h.jsx(w1,{children:t})]});class pQt extends y.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||h.jsxs(Ij,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const mQt=y.memo(({chart:e,id:t})=>{const n=y.useRef(null),r=y.useRef(null),[i,a]=y.useState(null),[o,s]=y.useState(!0),[l,c]=y.useState(""),[u,O]=y.useState(!1),[d,f]=y.useState({scale:1,x:0,y:0}),[p,m]=y.useState({scale:1,x:0,y:0}),[g,$]=y.useState(!1),[v,w]=y.useState({x:0,y:0}),[x,b]=y.useState("idle"),[S,Q]=y.useState("idle"),P=Bn(z=>z.themeName),R=y.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const z=await hQt(P),le=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:L}=await z.render(le,e);if(!L||typeof L!="string"||L.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(L)}catch(z){console.error("Mermaid rendering error:",z);const le=z instanceof Error?z.message:"Failed to render mermaid diagram";a(le),c("")}finally{s(!1)}},[e,t,P]);y.useEffect(()=>{R().catch(z=>{console.error("Error in renderDiagram effect:",z),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const _=y.useCallback(()=>{try{if(!l||!r.current)return 1;const le=r.current.getBoundingClientRect(),L=document.createElement("div");L.innerHTML=l;const Z=L.querySelector("svg");if(!Z)return 1;const ne=Z.getBoundingClientRect?.()?.width||Number.parseFloat(Z.getAttribute("width")||"0")||Z.viewBox?.baseVal?.width||800,te=Z.getBoundingClientRect?.()?.height||Number.parseFloat(Z.getAttribute("height")||"0")||Z.viewBox?.baseVal?.height||600,ie=le.width*.9/ne,$e=le.height*.9/te;return Math.min(ie,$e,1)}catch(z){return console.error("Error calculating fullscreen scale:",z),1}},[l]);y.useEffect(()=>{u&&l&&setTimeout(()=>{try{const z=_();m({scale:z,x:0,y:0})}catch(z){console.error("Error setting fullscreen transform:",z)}},100)},[u,l,_]);const E=y.useCallback((z=!1)=>{try{(z?m:f)(L=>({...L,scale:Math.min(L.scale*1.2,10)}))}catch(le){console.error("Error in zoom in:",le)}},[]),C=y.useCallback((z=!1)=>{try{(z?m:f)(L=>({...L,scale:Math.max(L.scale/1.2,.1)}))}catch(le){console.error("Error in zoom out:",le)}},[]),W=y.useCallback((z=!1)=>{try{const le=z?m:f;if(z){const L=_();le({scale:L,x:0,y:0})}else le({scale:1,x:0,y:0})}catch(le){console.error("Error in reset:",le)}},[_]),U=y.useCallback(()=>{if(l)try{const z=new Blob([l],{type:"image/svg+xml"}),le=URL.createObjectURL(z),L=document.createElement("a");L.href=le,L.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(le)}catch(z){console.error("Failed to save SVG:",z)}},[l]),Y=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(z){console.error("Failed to copy Mermaid chart text:",z)}},[e]),V=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(z){console.error("Failed to copy Mermaid chart text:",z)}},[e]),M=y.useCallback(z=>{try{$(!0),w({x:z.clientX,y:z.clientY}),z.preventDefault()}catch(le){console.error("Error in mouse down:",le)}},[]),B=y.useCallback((z,le=!1)=>{try{if(!g)return;const L=z.clientX-v.x,Z=z.clientY-v.y;(le?m:f)(te=>({...te,x:te.x+L,y:te.y+Z})),w({x:z.clientX,y:z.clientY})}catch(L){console.error("Error in mouse move:",L)}},[g,v]),G=y.useCallback(()=>{try{$(!1)}catch(z){console.error("Error in mouse up:",z)}},[]),A=y.useCallback((z,le=!1)=>{try{z.preventDefault();const L=z.deltaY>0?.9:1.1;(le?m:f)(ne=>({...ne,scale:Math.min(Math.max(ne.scale*L,.1),5)}))}catch(L){console.error("Error in wheel:",L)}},[]),ee=y.useCallback(z=>{try{O(z)}catch(le){console.error("Error toggling fullscreen:",le)}},[]);if(i)return h.jsxs(Ij,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:j("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:j("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(z=!1)=>{try{const le=z?r:n,L=z?p:d;return h.jsx("div",{ref:le,className:j("mermaid flex w-full items-center justify-center",z?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:M,onMouseMove:Z=>B(Z,z),onMouseUp:G,onMouseLeave:G,onWheel:Z=>A(Z,z),children:o?h.jsx("div",{className:j("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:j("flex h-full w-full items-center justify-center"),style:{transform:`translate(${L.x}px, ${L.y}px) scale(${L.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(le){return console.error("Error rendering diagram content:",le),h.jsx(Ij,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:j("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[K(!1),h.jsx(vF,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>C(!1),onReset:()=>W(!1),onSave:U,onCopy:Y,children:h.jsx(At,{content:"Fullscreen",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>ee(!0),children:h.jsx(Qje,{})})})})]}),h.jsx(t$,{open:u,onClose:()=>ee(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:j("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[K(!0),h.jsx(vF,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>C(!0),onReset:()=>W(!0),onSave:U,onCopy:V,children:h.jsx(At,{content:"Close fullscreen",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>ee(!1),children:h.jsx(Ri,{})})})})]})})]})}),gQt=y.memo(e=>h.jsx(pQt,{children:h.jsx(mQt,{...e})}));let ybe=!1,i2=null;const $Qt=()=>(i2||(i2=de(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(ybe=!0,e))),i2),yQt=/language-(\w+)/,vQt=/\n$/,vbe=({href:e,children:t})=>{const n=Xve(e),r=Zve();return!n||n.kind==="other"?h.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):h.jsx("a",{href:n.target,"data-lo-kind":n.kind,"data-lo-target":n.target,draggable:!1,target:n.kind==="url"?"_blank":void 0,rel:n.kind==="url"?"noopener noreferrer":void 0,onClick:n.kind==="file"?i=>SQt(i,r):void 0,children:t})},bQt=e=>Xve(e)?.kind==="file",wQt=Cve,SQt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(jve)??"file",i=n.getAttribute(wQt),a=Hwt({kind:r,hasHighlight:dSt(n),canOpenInCanvas:Gve(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||qS(i)});return}qS(i)}},bbe=(e,t)=>t==="href"&&bQt(e)?e:jce(e),fA={a:vbe,table:Jxt,code:({node:e,className:t,children:n,...r})=>yQt.exec(t??"")?.[1]==="mermaid"?h.jsx(gQt,{chart:String(n).replace(vQt,"")}):h.jsx("code",{className:t,...r,children:n})},xQt={...fA,a:Yxt(vbe)},QQt=[vO],kQt=[vO,Qk],PQt=[vO,$k],TQt=[vO,Qk,$k],_Qt=[vO,xk,yk],XQt=[vO,Qk,xk,yk],RQt=[vO,$k,xk,yk],EQt=[vO,Qk,$k,xk,yk],qQt={"000":QQt,"001":_Qt,"010":PQt,"011":RQt,100:kQt,101:XQt,110:TQt,111:EQt},jQt=[],CQt=[BDe],wbe=e=>y.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Sbe=(e,t,n)=>{const r=y.useMemo(()=>oQt(e),[e]),[i,a]=y.useState(ybe),o=r&&i;return y.useEffect(()=>{if(!r||i)return;let s=!1;return $Qt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:qQt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?CQt:jQt}},xbe=(e,t)=>{const[,n]=y.useState(0);y.useEffect(()=>{if(!t)return;const r=XLe(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=Jwt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return qve(r,window.api?.probeFiles,Jie).then(()=>{i&&r.some(s=>Eve(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},kk=y.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=y.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=Sbe(a,r,i),l=wbe(t);return xbe(a,r),h.jsx("div",{className:j("lo-markdown",n),style:l,children:h.jsx(qce,{remarkPlugins:o,rehypePlugins:s,urlTransform:bbe,components:i?xQt:fA,children:a})})});kk.displayName="MarkdownRenderer";const Qbe=y.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=Sbe(e,!0,!1);return xbe(e,!0),h.jsx(qce,{remarkPlugins:t,rehypePlugins:n,urlTransform:bbe,components:fA,children:e})});Qbe.displayName="StableBlock";const kbe=y.memo(({text:e,animate:t})=>h.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));kbe.displayName="ArrivedText";const Pbe=({content:e,styleProps:t,className:n})=>{const r=y.useRef(null);r.current===null&&(r.current=$St());const i=r.current,a=y.useRef([]),o=y.useRef(0);wSt(i,e);const s=o.current;e.length>s?(s>0&&a.current.push({offset:s,animate:!0}),o.current=e.length):e.length<s&&(a.current=[],o.current=e.length);const{blockStart:l}=i,c=a.current;let u=0;for(;u<c.length&&c[u].offset<=l;)u+=1;u>0&&c.splice(0,u);const O=l+SSt(e.slice(l)),d=[{offset:l,animate:!1}];for(const p of c){if(p.offset>=O)break;d.push(p)}const f=wbe(t);return h.jsxs("div",{className:j("lo-markdown",n),style:f,children:[i.blocks.map((p,m)=>h.jsx(Qbe,{source:p},m)),O>l&&h.jsx("p",{className:"lo-stream-tail",children:d.map((p,m)=>{const g=d[m+1]?.offset??O;return h.jsx(kbe,{text:e.slice(p.offset,g),animate:p.animate},p.offset)})})]})};Pbe.displayName="StreamingMarkdown";const qs=({isUser:e,children:t,className:n})=>e?h.jsx("div",{className:j("flex w-full justify-end",n),children:t}):h.jsx("div",{className:j("group relative w-full",n),children:t}),hA=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},zQt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()+1),Math.max(1,t.getTime()-e)};let pA=hA(Date.now()),Cu=null;const iw=new Set,Tbe=()=>{Cu!==null&&clearTimeout(Cu),Cu=setTimeout(()=>{Cu=null,pA=hA(Date.now());for(const e of iw)e();Tbe()},zQt(Date.now())),Cu.unref?.()},AQt=e=>(iw.add(e),pA=hA(Date.now()),Tbe(),()=>{iw.delete(e),iw.size===0&&Cu!==null&&(clearTimeout(Cu),Cu=null)}),bF=()=>pA,UQt=()=>y.useSyncExternalStore(AQt,bF,bF),WQt=e=>new Date(e+1e3),YQt=()=>WQt(UQt()),pen=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(navigator.language,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},GQt=(e,t=new Date)=>{if(e==null)return"";try{const n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return"";const r=n.toLocaleTimeString(navigator.language,{hour:"numeric",minute:"2-digit",hour12:!0});if(n.toDateString()===t.toDateString())return r;const i=new Date(t);if(i.setDate(t.getDate()-1),n.toDateString()===i.toDateString())return`Yesterday ${r}`;const a=n.toLocaleDateString(navigator.language,{month:"short",day:"numeric"});return n.getFullYear()===t.getFullYear()?`${a}, ${r}`:`${a}, ${n.getFullYear()}, ${r}`}catch(n){return console.error("Error formatting turn timestamp:",n),""}},NQt=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleString(navigator.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},ZQt={turn:"Sent",answer:"Answered",tool:"Ran"},_be=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=YQt();if(Number.isNaN(r.getTime()))return null;const a=NQt(r,{hour12:!0});return h.jsx(At,{content:a,side:"bottom",delayDuration:1200,children:h.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${ZQt[t]} ${a}`,className:j("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:GQt(r,i)})})},mA=({replies:e,onRemoveReply:t})=>h.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[h.jsx(Pje,{size:12,"aria-hidden":"true"}),h.jsx("span",{className:"text-meta",children:"Replying to"})]}),e.map(n=>h.jsxs("div",{className:"flex items-center gap-2 border-hairline border-l-2 py-0.5 pl-2",children:[h.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&h.jsx(Ve,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"aria-label":"Remove reply",children:h.jsx(Ri,{"aria-hidden":"true"})})]},n.id))]}),IQt=({children:e,className:t})=>h.jsx("span",{"aria-hidden":!0,className:j("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),DQt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},VQt=({line:e})=>h.jsx("span",{className:j(DQt[e.kind],"block"),children:e.text}),MQt=({diff:e,className:t})=>{const n=z2e(e);return h.jsxs("div",{className:j("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>h.jsx(VQt,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:A2e(n.hidden)})]})},LQt=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const a=i.slice(0,t),o=a.lastIndexOf(" ");i=`${a.slice(0,o>32?o:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},wF=e=>e.startsWith("file://")?e.slice(7):e,FQt={READ:{verb:"Read",runningVerb:"Reading",icon:h6},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:Goe},EDIT:{verb:"Edited",runningVerb:"Editing",icon:Vje},CODE:{verb:"Ran code",runningVerb:"Running code",icon:qoe},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:sCe},DONE:{verb:"Finished",runningVerb:"Finishing",icon:A7},ASK:{verb:"Asked",runningVerb:"Asking",icon:oQ},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:Zqe}},BQt={verb:"Worked on the request",runningVerb:"Working on the request",icon:qoe},HQt=(e,t,n,r)=>{const i=e?FQt[e]:BQt;let a;if(t)a=wF(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=wF(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?LQt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},SF="min-h-5 py-0",KQt=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>h.jsxs("span",{className:j("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[h.jsx(IQt,{className:j(a?"text-danger":"text-ink-dim",o&&Mse),children:e}),h.jsxs("span",{className:j(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[h.jsxs("span",{...y5,className:j("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?h.jsxs("span",{...y5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?h.jsxs("span",{...y5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),xF=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:a=!1,defaultOpen:o=!1,details:s,className:l,verbOverride:c,object:u,glyph:O,wrap:d,dense:f=!1})=>{const p=HQt(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?Mh:p.icon,$=a||!c||!O?h.jsx(g,{}):O,v=h.jsx(KQt,{icon:$,verb:m,object:c?u:p.object,narration:c?r:p.narration,running:i,failed:a,wrap:d}),w=d?"firstLine":"center";return s?h.jsx(Bo,{summary:v,chevron:"leading",summaryAlign:w,defaultOpen:o,className:l,rowClassName:f?SF:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx(Bo,{disabled:!0,summary:v,summaryAlign:w,className:l,rowClassName:f?SF:void 0})},Xbe=8,JQt="… deeper values not shown",ekt="(empty)";function tkt(e){return`… ${e} more line${e===1?"":"s"}`}const QF=.5;function nkt(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const a of e){if(a.height<=0)continue;const o=Math.max(1,Math.round(a.height/t));for(let s=1;s<=o;s++)a.top+s*t>n+r&&i++}return i}function Rbe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function gA(e){return typeof e=="object"&&e!==null}function Ebe(e,t,n,r){if(n>Xbe){r.push({key:t,value:JQt,depth:n});return}if(gA(e)){for(const[a,o]of Object.entries(e))Ebe(o,t?`${t}.${a}`:a,n+1,r);return}const i=Rbe(e);i!==null&&r.push({key:t,value:i,depth:n})}function qbe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))Ebe(r,n,1,t);return t}const rkt=512;function ikt(e,t){if(t)return!0;if(!e)return!1;let n=rkt;const r=(i,a)=>{if(n--<=0||a>Xbe)return!0;if(!gA(i))return Rbe(i)!==null;for(const o of Object.values(i))if(r(o,a+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function akt(e){if(!e)return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!gA(n))return null;const r=qbe(n);return r.length>0?r:[{key:"",value:ekt,depth:1}]}const okt=8,Dj="max-h-[min(320px,40vh)]",skt=Dj,lkt=({line:e})=>h.jsxs("div",{className:j("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*okt},children:[e.key?h.jsxs("span",{className:j("text-ink-muted"),children:[e.key,": "]}):null,h.jsx("span",{className:j("text-ink-dim"),children:e.value})]}),kF=({lines:e,label:t})=>h.jsx("div",{className:j("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>h.jsx(lkt,{line:n},r))});function PF(e){const[t,n]=y.useState(0),[r,i]=y.useState(!1);return y.useLayoutEffect(()=>{const a=e.current;if(!a)return;const o=a.firstElementChild,s=()=>{const c=o??a,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const O=a.getBoundingClientRect(),d=c.getBoundingClientRect();i(d.height>O.height+QF);const f=c.children.length>0?Array.from(c.children):[c];n(nkt(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,QF))};s(),a.addEventListener("scroll",s,{passive:!0});const l=new ResizeObserver(s);return l.observe(o??a),()=>{a.removeEventListener("scroll",s),l.disconnect()}}),{lines:t,overflowing:r}}const TF=({lines:e,overflowing:t})=>t?h.jsx("span",{className:j("mt-1 block text-ink-dim"),children:e>0?tkt(e):" "}):null,ckt=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=qbe(e),o=akt(t),s=y.useRef(null),l=y.useRef(null),c=PF(s),u=PF(l);return a.length===0&&!t&&!i?null:h.jsxs("div",{className:j("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&h.jsxs("div",{"data-detail-section":"input",children:[h.jsx("div",{ref:s,className:j(Dj,"overflow-auto"),children:h.jsx(kF,{lines:a,label:"input"})}),h.jsx(TF,{lines:c.lines,overflowing:c.overflowing})]}),i&&h.jsx("div",{className:j("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&h.jsxs("div",{className:j(a.length>0&&"mt-3"),"data-detail-section":"output",children:[h.jsx("span",{className:j("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),h.jsx("div",{ref:l,className:j(Dj,"overflow-auto"),children:o?h.jsx(kF,{lines:o,label:"result-json"}):h.jsx("pre",{className:j("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(TF,{lines:u.lines,overflowing:u.overflowing})]})]})},ukt="mcp__",Okt={bash:OCe,read:g6,write:cY,edit:cY,glob:e$,grep:Xy,todo:gje,wake:sQ,list_variables:dY,read_variable:dY,browser:uY,console:y6,project:Aqe,project_delete:fCe,web_search:uY,web_fetch:lQ,task:Sd,agent:Sd,send:Ioe,peer:uje,sessions:Fje};function dkt(e){const t=e.trim().toLowerCase(),n=Okt[t];return n||(t.startsWith(ukt)?Noe:bCe)}const fkt=p6,hkt=Sje,pkt=bje,_F="min-h-5 py-0",XF={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},mkt=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?XF.plain:XF[x2e(t)],gkt=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",$kt=({added:e,removed:t})=>e<=0&&t<=0?null:h.jsxs("span",{className:j("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&h.jsxs("span",{className:j("text-success"),children:["+",e]}),t>0&&h.jsxs("span",{className:j("text-danger"),children:["-",t]})]}),a2={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},ykt=1e3;function vkt(e){const[t,n]=y.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return y.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,ykt);return()=>window.clearInterval(i)},[e]),t}const bkt=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=vkt(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?d2e[t]:void 0,c=s?l??null:o?l??a2[e]:null,O=j("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?p2e[t]??null:null,f=s&&t?f2e[t]:void 0,p=s?t==="mailbox"?hkt:t==="unconfirmed"?pkt:null:e==="interrupted"?fkt:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":uf(a??0):hae(n);return h.jsxs("span",{className:j("flex shrink-0 items-center gap-1.5"),children:[c?h.jsx("span",{className:O,title:f,"aria-hidden":d?!0:void 0,children:c}):null,h.jsxs("span",{className:j("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",m),children:[p?h.jsx(p,{"aria-hidden":!0}):null,!o&&a2[e]?h.jsx("span",{className:j("sr-only"),children:a2[e]}):null,d?h.jsx("span",{className:j("sr-only"),children:d}):null]}),h.jsx("span",{className:j("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:g})]})},_d=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,outcome:o,deliveryState:s=null,durationS:l,startedAt:c=null,added:u=0,removed:O=0,details:d,defaultOpen:f=!1,className:p,media:m})=>{const g=o==="running",$=o==="error",v=dkt(e),w=Ud(e),{verb:x,object:b}=gae(e,r,i,g,t,g2e(s)),S=h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),children:[h.jsx("span",{"aria-hidden":!0,className:j("flex size-3.5 shrink-0 [&_svg]:size-3.5",mkt(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:j("shrink-0 whitespace-nowrap text-body-sm",gkt(o)),title:w,children:x}),h.jsx("span",{className:j("min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:b,children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),h.jsx("span",{className:j("sr-only"),children:"pending"})]}):b}),h.jsx($kt,{added:u,removed:O}),h.jsx(bkt,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?"bg-elevated":$?"bg-danger-wash":"hover:bg-row-hover",P=d?h.jsx(Bo,{summary:S,chevron:"leading",defaultOpen:f,className:j("@container/toolrow",p),rowClassName:_F,triggerClassName:j("-mx-2 rounded-sm px-2",Q),children:d}):h.jsx(Bo,{disabled:!0,summary:S,rowClassName:_F,className:j("@container/toolrow",(g||$)&&j("-mx-2 rounded-sm px-2",Q),p)});return m?h.jsxs("div",{className:j("flex flex-col"),children:[P,m]}):P},wkt=3,jbe=e=>{const t=e.toLowerCase();return t==="read"||t==="grep"||t==="glob"||t==="ls"||t==="list"?"files":t==="search_the_web"||t==="web_search"||t==="search"?"web":t==="bash"||t==="exec"||t==="shell"||t==="run"?"commands":t==="edit"||t==="write"||t==="multiedit"?"edits":t==="task"||t==="delegate"?"delegated":t==="fetch"||t==="web_fetch"||t==="fetch_url"?"searches":null},Cbe=e=>{const t=new Map;let n=0;for(const a of e){const o=jbe(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=Qkt(kkt(e));return{units:a.length===0?[`${e.length} actions`]:a,prose:!1}}const r=["files","searches","web","commands","edits","delegated"],i=[];for(const a of r){const o=t.get(a)??0;o!==0&&(a==="files"&&i.push(`Explored ${o} file${o===1?"":"s"}`),a==="searches"&&i.push(`${o} search${o===1?"":"es"}`),a==="web"&&i.push(`Searched the web ${o} time${o===1?"":"s"}`),a==="commands"&&i.push(`Ran ${o} command${o===1?"":"s"}`),a==="edits"&&i.push(`Edited ${o} file${o===1?"":"s"}`),a==="delegated"&&i.push(`Delegated ${o} task${o===1?"":"s"}`))}return i.length===0?{units:[`${e.length} actions`],prose:!0}:{units:[i.length===1?i[0]:`${i[0]}, ${i[1].charAt(0).toLowerCase()}${i[1].slice(1)}`],prose:!0}},Skt=e=>Cbe(e).units;function xkt(e){return Skt(e).join(" · ")}const RF={agent:{noun:"agent",plural:"agents"},team:{noun:"team",plural:"teams"},team_delete:{noun:"team deletion",plural:"team deletions"},hub:{noun:"subagent",plural:"subagents"},secret:{noun:"secret",plural:"secrets"},project:{noun:"project",plural:"projects"},project_delete:{noun:"project deletion",plural:"project deletions"},wake:{noun:"wake",plural:"wakes"},jobs:{noun:"job",plural:"jobs"},console:{noun:"console",plural:"consoles"},network:{noun:"network call",plural:"network calls"},browser:{noun:"browser action",plural:"browser actions"},todo:{noun:"todo update",plural:"todo updates"},send:{noun:"message",plural:"messages"},ask:{noun:"question",plural:"questions"},wait:{noun:"wait",plural:"waits"},lsp:{noun:"code lookup",plural:"code lookups"},web_read:{noun:"page",plural:"pages"},list_variables:{noun:"variable lookup",plural:"variable lookups"},read_variable:{noun:"variable read",plural:"variable reads"},sessions:{noun:"session",plural:"sessions"}},o2=5,Qkt=e=>{if(e.length<=o2)return e.map(r=>r.label);const t=e.slice(0,o2),n=e.slice(o2).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},kkt=e=>{const t=new Map,n=(s,l)=>{const c=t.get(s);c?c.count+=1:t.set(s,{kind:l,count:1})};for(const s of e){const l=s.name.toLowerCase();if(l==="bash"||l==="exec"||l==="shell"||l==="run"){n("kind:shell",{noun:"shell",plural:null});continue}if(l==="eval"){n("kind:python",{noun:"python",plural:null});continue}const c=jbe(s.name);if(c==="files")n("class:files",{noun:"file",plural:"files"});else if(c==="searches")n("class:searches",{noun:"search",plural:"searches"});else if(c==="web")n("class:web",{noun:"web search",plural:"web searches"});else if(c==="edits")n("class:edits",{noun:"edit",plural:"edits"});else if(c==="delegated")n("class:delegated",{noun:"task",plural:"tasks"});else if(l==="todo")(s.op??"").toLowerCase()==="view"?n("kind:todo:view",{noun:"todo read",plural:"todo reads"}):n("kind:todo",RF.todo);else{const u=RF[l];if(u)n(`kind:${l}`,u);else{const O=Ud(s.name);n(`name:${O}`,{noun:O,plural:null})}}}const r=["class:files","class:searches","class:web","kind:shell","kind:python","class:edits","class:delegated","kind:agent","kind:team","kind:hub"],i=[],a=(s,l)=>`${s} ${s===1||l.plural===null?l.noun:l.plural}`;for(const s of r){const l=t.get(s);l&&i.push({label:a(l.count,l.kind),count:l.count})}const o=[...t.entries()].filter(([s])=>!r.includes(s)).sort(([,s],[,l])=>l.count-s.count||s.kind.noun.localeCompare(l.kind.noun));for(const[,s]of o)i.push({label:a(s.count,s.kind),count:s.count});return i};function Pkt(e){return e.running===!0?typeof e.startedAtMs!="number"?null:{startMs:e.startedAtMs,endMs:null}:typeof e.endedAtMs!="number"||typeof e.durationS!="number"?null:{startMs:e.endedAtMs-e.durationS*1e3,endMs:e.endedAtMs}}function Tkt(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=Pkt(i);a&&(t=t===null?a.startMs:Math.min(t,a.startMs),a.endMs!==null&&(n=n===null?a.endMs:Math.max(n,a.endMs)))}return t===null||n===null&&!r?null:{startedAtMs:t,endedAtMs:n,running:r}}function _kt(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return gae(n.name,n.summary??"",null,!0,n.op)}return null}function Xkt(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.map(o=>{const s={name:t.nameOf(o),failed:t.failedOf(o),durationS:t.durationOf?t.durationOf(o):null,startedAtMs:t.startedAtOf?t.startedAtOf(o):null,endedAtMs:t.endedAtOf?t.endedAtOf(o):null};return t.summaryOf&&(s.summary=t.summaryOf(o)),t.opOf&&(s.op=t.opOf(o)),t.runningOf&&(s.running=t.runningOf(o)),t.executingOf&&(s.executing=t.executingOf(o)),s});if(r.length>=wkt)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:a,summary:Cbe(a),failedCount:a.filter(o=>o.failed).length,span:Tkt(a),live:_kt(a)});else for(const o of r)n.push({kind:"row",row:o});r=[]};for(const a of e){if((a.gap==="turn"||a.gap==="first")&&i(),t.isFoldable(a)){r.push(a);continue}i(),n.push({kind:"row",row:a})}return i(),n}const EF=e=>{const t=[];for(const n of e)n.record.kind==="tool"&&t.push(...n.record.images);return t},aw=5,Rkt=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<aw?{shown:Math.max(e,0),more:0}:{shown:aw-1,more:e-(aw-1)},Ekt=e=>{const t=aw-1;if(e<=0)return[];if(e<=t)return[e];const n=Array.from({length:Math.floor(e/t)},()=>t),r=e%t;return r===1?(n[n.length-1]=t-1,n.push(2)):r>1&&n.push(r),n},CS=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function Vj(e){return e.record.kind==="tool"?e.record.durationS:null}function qkt(e){let t=null;for(const n of e){const r=Vj(n);typeof r=="number"&&(t=(t??0)+r)}return t}function jkt(e,t){const n=new Map,r=t.opensRun??(l=>l.gap==="turn"||l.gap==="first");let i=0,a=0,o=null,s=null;for(const l of e){if(r(l)&&(i=0,a=0,o=null,s=null),t.isAction(l)){i+=1,t.failedOf(l)&&(a+=1,s??=l.record.id);const c=t.durationOf?t.durationOf(l):null;typeof c=="number"&&(o=(o??0)+c)}l.closesTurn&&n.set(l.record.id,{actions:i,failed:a,durationS:o,firstFailedId:s})}return n}const Ckt="min-h-5 py-0",zkt=1e3;function Akt(e){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,zkt);return()=>window.clearInterval(i)},[e]),t}const Ukt=({summary:e,actionCount:t,span:n,live:r,open:i,onOpenChange:a,className:o,condensedMedia:s,mediaCount:l=0,recordIds:c,children:u})=>{const O=Akt(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":hae(d),p=y.useRef(null),m=()=>{p.current?.querySelector("button[aria-expanded]")?.focus(),a(!0)};return h.jsxs("div",{ref:p,className:o,"data-fold-ids":c.join(" "),children:[h.jsx(Bo,{open:i,onOpenChange:a,rowClassName:Ckt,triggerClassName:j("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),children:[r!==null&&!i&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{"data-fold-live":"",className:j("min-w-0 shrink-[100000] truncate"),title:`${r.verb} ${r.object}`,children:[h.jsx("span",{className:j("text-accent"),children:r.verb})," ",h.jsx("span",{className:j("font-mono text-mono-sm text-ink-muted"),children:r.object})]}),h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"})]}),h.jsx("span",{className:j("min-w-0 break-words text-body-sm text-ink-muted"),title:`${t} actions`,"data-fold-summary":"",children:e.units.map((g,$)=>h.jsxs(y.Fragment,{children:[$>0&&h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:j(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),CS(l)!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{className:j("shrink-0 text-ink-muted text-meta"),children:CS(l)})]}),f!==""&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{"data-fold-span":"",className:j("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:f})]})]}),children:h.jsx("div",{className:j("flex flex-col"),children:u})}),!i&&s&&s(m)]})},Wkt="min-h-5 py-0",s2=()=>h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),Ykt=({recordIds:e,segmentIds:t,anchorRecordId:n,className:r,durationS:i,actionCount:a,partial:o=!1,title:s,stampTs:l,label:c=null,completed:u=!1,open:O,onOpenChange:d,children:f,condensedMedia:p,mediaCount:m=0})=>{const g=o?`${a}+ actions`:a===1?"1 action":`${a} actions`,$=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,v=y.useRef(null),w=()=>{v.current?.querySelector("button[aria-expanded]")?.focus(),d(!0)};return h.jsxs("div",{ref:v,className:j("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u?"true":void 0,"data-record-id":n,children:[h.jsx(Bo,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:Wkt,triggerClassName:j("-ml-2 -mr-2 w-[calc(100%+1rem)] rounded-sm pl-2 pr-6","hover:bg-row-hover"),chevronClassName:j("-mr-6","text-ink-muted"),summary:h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&h.jsx(h.Fragment,{children:h.jsx(A7,{"aria-hidden":!0,className:j("size-3.5 shrink-0 text-success")})}),c!==null&&(i!==null||a>0)&&h.jsx(s2,{}),i!==null&&h.jsxs("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:["Took ",uf(i)]}),i!==null&&a>0&&h.jsx(s2,{}),a>0&&h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),title:o?$:void 0,"aria-label":o?$:void 0,children:g}),CS(m)!==null&&h.jsxs(h.Fragment,{children:[h.jsx(s2,{}),h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:CS(m)})]}),u&&h.jsx("span",{className:j("sr-only"),children:"completed"}),l!==null&&h.jsx("span",{className:j("ml-auto"),children:h.jsx(_be,{timestamp:l,scope:"answer"})})]}),children:h.jsx("div",{className:j("flex flex-col"),children:f})}),!O&&p&&h.jsx("div",{className:j("pb-2"),children:p(w)})]})},zbe=e=>{const t=y.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=y.useCallback(()=>window.matchMedia(e).matches,[e]);return y.useSyncExternalStore(t,n,()=>!1)},qF=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],Gkt=80,Nkt=1e3,Zkt=({activity:e,phase:t,startedAt:n,clock:r,className:i})=>{const[a,o]=y.useState(0),[s,l]=y.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),[c,u]=y.useState(!1),O=r!==!1&&!c,d=zbe("(prefers-reduced-motion: reduce)"),f=y.useRef(n??Date.now()),p=y.useRef(t),m=y.useRef(n);if(p.current!==t)p.current=t,m.current=n,f.current=n??Date.now(),c&&u(!1),l(0);else if(m.current!==n){const v=m.current!==void 0&&n===void 0;m.current=n,u(v),v||(f.current=n,l(Math.floor((Date.now()-n)/1e3)))}const g=y.useRef(r!==!1),$=y.useRef(t);return y.useEffect(()=>{const v=r!==!1,w=g.current,x=$.current===t;g.current=v,$.current=t,!w&&v&&x&&l(Math.floor((Date.now()-f.current)/1e3))},[r,t]),y.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-f.current)/1e3)),Nkt):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const w=window.setInterval(()=>o(x=>(x+1)%qF.length),Gkt);return()=>{window.clearInterval(w),v!==null&&window.clearInterval(v)}},[d,O]),h.jsxs("div",{className:j("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[h.jsx("span",{"aria-hidden":!0,className:j("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:qF[a]}),h.jsx("span",{className:j("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),h.jsx("span",{"aria-hidden":!0,className:j("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?uf(s):""})]})},Abe="lo-missing-session-notice",Ikt=/^\s*<reply-to>([\s\S]*?)<\/reply-to>/,$A=e=>{const t=[];let n=e;for(;;){const r=Ikt.exec(n);if(r===null)break;t.push({id:Wo(),text:r[1]}),n=n.slice(r[0].length)}return{replies:t,remainingContent:n.trim()}},Ube=({children:e,className:t,boundary:n="hairline",...r})=>h.jsx("div",{className:j("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm bg-sunken",n==="control"?["border border-transparent","transition-colors duration-fast ease-out-quart","group-hover/tile:border-control group-focus-visible/tile:border-control"]:"border border-hairline",t),...r,children:e}),Dkt="could not be displayed. It may have been moved, renamed, or deleted.",Wbe="could not be displayed. Its stored copy is not available to this reader.",Mj=({name:e,detail:t=Dkt,className:n,compact:r=!1})=>r?h.jsx("div",{className:j("flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken",n),role:"img","aria-label":`${e} ${t}`,title:`${e} ${t}`,children:h.jsx(OY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):h.jsxs("div",{className:j("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[h.jsx(OY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),h.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[h.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),Vkt=({filePath:e,tooltip:t="File actions",icon:n,"aria-label":r="File actions",onShowInCanvas:i})=>{const a=async()=>{if(e)try{await navigator.clipboard.writeText(e),ep("File path copied to clipboard")}catch(s){console.error("Failed to copy file path: ",s),Oo("Failed to copy file path")}},o=()=>{e&&window.api.openFile(e)};return h.jsxs(_ie,{children:[h.jsx(At,{content:t,children:h.jsx(Xie,{asChild:!0,children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:s=>s.stopPropagation(),children:n??h.jsx(Vqe,{"aria-hidden":"true"})})})}),h.jsxs(Rie,{align:"end",className:"min-w-45",onClick:s=>s.stopPropagation(),children:[i&&h.jsxs(hc,{onSelect:i,children:[h.jsx(pje,{"aria-hidden":"true"}),h.jsx("span",{children:"Show in canvas"})]}),h.jsxs(hc,{onSelect:o,children:[h.jsx($6,{"aria-hidden":"true"}),h.jsx("span",{children:"Open file"})]}),h.jsxs(hc,{onSelect:()=>window.api.showItemInFolder(e),children:[h.jsx(e$,{"aria-hidden":"true"}),h.jsx("span",{children:"Open folder"})]}),h.jsxs(hc,{onSelect:a,children:[h.jsx(qqe,{"aria-hidden":"true"}),h.jsx("span",{children:"Copy file path"})]})]})]})},l2="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",Ybe=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a})=>{const[o,s]=y.useState(!1);return q7(n,"image-lightbox"),h.jsx(j7,{open:n,onOpenChange:r,children:h.jsxs(C7,{showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:l=>{const c=i?.current;c&&(l.preventDefault(),c.focus())},className:j("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none",l2,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx(z7,{className:"sr-only",children:t}),o?h.jsx("div",{className:j(l2,"flex min-h-16 min-w-64 items-center justify-center p-6"),children:a}):h.jsx("img",{src:e,alt:t,className:j(l2,"object-contain"),onError:()=>s(!0)}),h.jsx(GPe,{asChild:!0,children:h.jsx(Ve,{variant:"ghost",size:"icon-sm",className:j("fixed top-4 right-4"),"aria-label":"Close image",children:h.jsx(Ri,{"aria-hidden":"true"})})})]})})};Ybe.displayName="ImageLightbox";const Mkt={full:"max-h-[240px] max-w-full object-contain",thumbnail:["h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]"].join(" ")},Lkt=/[/\\]/,jF=e=>{const t=e.split(Lkt);return t[t.length-1]},Gbe=y.memo(({file:e,src:t,conversationId:n,label:r,size:i="full"})=>{const[a,o]=y.useState(!1),[s,l]=y.useState(!1),[c,u]=y.useState(!1),O=y.useRef(null),d=Bn(x=>x.setCanvasOpen),{setViewMode:f}=Od(),p=y.useCallback(async()=>{const x=jF(e),b=R=>{R&&console.error("Error processing file:",R);const _=e.startsWith("file://")?e.substring(7):e;window.api.openFile(_).catch(E=>{console.error("Error opening file:",E)})},{setFiles:S,setOpenTabs:Q,setSelectedTab:P}=Od.getState();if(e.startsWith("data:"))if(zj(x)){const R=e,_={id:R,title:x,path:R,content:e,type:Gw(e)},C=Od.getState().conversations?.[n],W=C?.files??[],U=C?.openTabs??[],Y=(()=>{const B=W.findIndex(G=>G.id===R);return B!==-1?[...W.slice(0,B),_,...W.slice(B+1)]:[...W,_]})();S(n,Y);const M=U.some(B=>B.id===R)?U:[...U,{id:R,title:x}];Q(n,M),P(n,R),d(!0),f(n,"documents")}else d(!0),f(n,"files");else{const R=e.startsWith("file://")?e.substring(7):e;try{const _=await window.api.readFile(R);if(_.success&&zj(x)){const E=R,C={id:E,title:x,path:R,content:_.data,type:Gw(e)},U=Od.getState().conversations?.[n],Y=U?.files??[],V=U?.openTabs??[],M=(()=>{const A=Y.findIndex(ee=>ee.id===E);return A!==-1?[...Y.slice(0,A),C,...Y.slice(A+1)]:[...Y,C]})();S(n,M);const G=V.some(A=>A.id===E)?V:[...V,{id:E,title:x}];Q(n,G),P(n,E),d(!0),f(n,"documents");return}d(!0),f(n,"files")}catch(_){const E=_ instanceof Error?_.message:String(_??"Unknown error reading file");return b(E)}}},[e,d,f,n]),m=()=>{o(!0)},g=!e.startsWith("data:")&&!e.startsWith("blob:")&&!e.startsWith("http"),$=e.startsWith("file://")?e.substring(7):e,v=r??jF(e);if(a)return h.jsx(Mj,{name:v,compact:i==="thumbnail"});const w=h.jsx(Ube,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:j(Mkt[i],s?"opacity-100":"opacity-0"),src:t,alt:v,onLoad:()=>l(!0),onError:m})});return h.jsxs("div",{className:"group relative inline-block",children:[h.jsx("button",{ref:O,type:"button",className:j("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:()=>u(!0),"aria-label":`Expand ${v}`,title:`Click to expand ${v}`,children:w}),g&&h.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 right-1 z-[2] opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",onClick:x=>{x.stopPropagation()},onKeyDown:x=>x.stopPropagation(),children:h.jsx(Vkt,{filePath:$,tooltip:"File actions","aria-label":"File actions",onShowInCanvas:p})}),h.jsx(Ybe,{src:t,label:v,open:c,onOpenChange:u,restoreFocusTo:O,fallback:h.jsx(Mj,{name:v,detail:g?void 0:Wbe})})]})});Gbe.displayName="ImageAttachment";const Xd=new Map;function Fkt(e,t){return URL.createObjectURL(new Blob([e],{type:t}))}function Bkt(e){return Xd.get(e)?.url??null}function CF(e){const t=Xd.get(e);return t?(t.refs+=1,t.revoking=!1,t.url):null}function Hkt(e,t){if(Xd.get(e)){URL.revokeObjectURL(t);return}Xd.set(e,{url:t,refs:0,revoking:!1})}function zF(e){const t=Xd.get(e);t&&(t.refs-=1,!(t.refs>0)&&(t.revoking||(t.revoking=!0,queueMicrotask(()=>{!t.revoking||t.refs>0||(URL.revokeObjectURL(t.url),Xd.get(e)===t&&Xd.delete(e))}))))}const ow=new Map;function Kkt(e,t){const n=ow.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await Kh(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=Fkt(i.data,i.mimeType);return r.holders<=0?(URL.revokeObjectURL(a),null):(Hkt(t,a),a)}catch{return null}finally{ow.delete(t)}})(),ow.set(t,r),r.promise}function Jkt(e){const t=ow.get(e);t&&(t.holders-=1)}function ePt(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=y.useState(()=>e.attachment?Bkt(e.attachment):null),[a,o]=y.useState(!1),s=t?.sessionId??null,l=t?.childId??null;y.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=CF(u);if(d)return i(d),o(!1),()=>{O=!1,zF(u)};i(null),o(!1);let f=!0;return Kkt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(CF(u))}}),()=>{O=!1,f&&Jkt(u),zF(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}const yA=({image:e,scope:t,label:n,size:r})=>{const i=ePt(e,t);if(i.state==="resolving")return h.jsx("div",{className:j("inline-block max-w-full"),"aria-hidden":!0,children:h.jsx(Ube,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""})});if(i.state==="missing")return h.jsx(Mj,{name:n,compact:r==="thumbnail",detail:Wbe});const a=i.url;return h.jsx("div",{className:j("inline-block max-w-full"),children:h.jsx(Gbe,{file:a,src:a,label:n,size:r,conversationId:t?.sessionId??""})})},tPt="Generating name…",nPt={rest:"scale-x-60 bg-ink-dim",preview:"scale-x-90 bg-ink-muted",active:"scale-x-100 bg-ink",unloaded:"scale-x-40 bg-ink-dim opacity-75"};function rPt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function vA(e,t){return`Turn ${e} of ${t}`}const iPt=e=>e.charAt(0).toLowerCase()+e.slice(1);function aPt(e,t){const n=vA(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function oPt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function sPt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function lPt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const cPt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function uPt(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);if(Number.isNaN(t.getTime()))return"";const n=t.getHours(),r=t.getMinutes().toString().padStart(2,"0"),i=n%12===0?12:n%12,a=n<12?"AM":"PM";return`${i}:${r} ${a}`}function OPt(e,t){const n=iPt(vA(e.turn,t));if(e.kind==="user"){const i=uPt(e.ts);return i?`Jump to your message in ${n}, ${i}`:`Jump to your message in ${n}`}const r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`Jump to ${n}, ${r}`:`Jump to ${n}`}function dPt(e,t){const n=e.checkpoints.find(i=>i.id===t);return n?n.kind==="completion"?n.naming?.state??null:e.checkpoints.find(i=>i.kind==="completion"&&i.turn===n.turn)?.naming?.state??null:null}function fPt(e,t){const n=[];for(const r of t)dPt(e,r)==="pending"&&n.push(r);return n}const hPt=120,AF=80,pPt="Turn checkpoints",mPt={complete:Lc,error:Mh,interrupted:p6,open:Pqe},gPt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},$Pt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?mPt[n]:null,i=sPt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:j("text-body-sm font-medium text-ink"),children:[vA(e.turn,t),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:j("font-normal text-ink-muted"),children:a})]})]}),oPt(e)&&h.jsx("p",{className:j("text-ink-dim text-meta"),children:tPt}),i&&h.jsx("p",{className:j("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&h.jsx("div",{className:j("flex items-center gap-1.5 text-ink-dim text-meta"),children:h.jsxs("span",{className:j("flex items-center gap-1",gPt[n]),children:[h.jsx(r,{"aria-hidden":"true",className:j("size-3.5 shrink-0")}),cPt[n]]})})]})},yPt=y.memo(function({checkpoint:t,state:n,label:r,roving:i,registerTick:a,onPreview:o,onPreviewEnd:s,onFocusMark:l,onBlurMark:c,onActivate:u,onKeyMark:O,describedBy:d}){const f=p=>{p.pointerType!=="touch"&&o(t.id)};return h.jsx("button",{ref:p=>a(t.id,p),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":d,tabIndex:i?0:-1,className:j("group pointer-events-auto block h-2.5 w-7"),onPointerMove:f,onPointerLeave:s,onFocus:()=>l(t.id),onBlur:c,onClick:()=>u(t.id),onKeyDown:p=>O(p,t.id),children:h.jsx("span",{"aria-hidden":"true",className:j("ml-auto mr-1.5 block h-0.5 w-5 origin-right rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",nPt[n])})})}),vPt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{const s=y.useId(),[l,c]=y.useState(null),[u,O]=y.useState(null),[d,f]=y.useState(null),p=y.useRef(t);p.current=t;const m=y.useRef(new Map),g=y.useRef(null),$=y.useRef(null),v=y.useRef(null),w=y.useCallback(()=>{$.current!==null&&(clearTimeout($.current),$.current=null),v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),x=y.useCallback((Z,ne)=>{w();const te=()=>{O(Z),f(p.current.find(ie=>ie.id===Z)??null)};if(ne<=0){te();return}$.current=setTimeout(()=>{$.current=null,te()},ne)},[w]),b=y.useCallback(Z=>{if(w(),Z<=0){O(null);return}v.current=setTimeout(()=>{v.current=null,O(null)},Z)},[w]),S=y.useRef(e);y.useEffect(()=>{S.current!==e&&(S.current=e,w(),G.current=null,c(null),O(null),f(null))},[e,w]),y.useEffect(()=>{if(o===null)return;const Z=g.current,ne=m.current.get(o);if(Z===null||ne===void 0)return;const te=Z.getBoundingClientRect(),ie=ne.getBoundingClientRect(),$e=ie.top-te.top+Z.scrollTop,je=$e+ie.height,Oe=24;$e<Z.scrollTop+Oe?Z.scrollTop=Math.max(0,$e-Oe):je>Z.scrollTop+Z.clientHeight-Oe&&(Z.scrollTop=je-Z.clientHeight+Oe)},[o]),y.useEffect(()=>()=>w(),[w]);const Q=y.useRef(r);y.useEffect(()=>{Q.current=r});const P=y.useMemo(()=>lPt(t),[t]),R=y.useMemo(()=>new Map(t.map(Z=>[Z.id,OPt(Z,P)])),[t,P]),_=u&&d?.id===u?d:null,E=u&&m.current.get(u)||null,C=y.useMemo(()=>({current:E}),[E]),W=_!==null&&E!==null;y.useEffect(()=>{Q.current(W&&u?u:null)},[W,u]);const U=y.useCallback((Z,ne)=>{ne?m.current.set(Z,ne):m.current.delete(Z)},[]),[Y,V]=y.useState(null),M=Y&&t.some(Z=>Z.id===Y)?Y:t[0]?.id??null,B=y.useCallback(Z=>{const ne=Math.max(0,Math.min(t.length-1,Z)),te=t[ne];te&&(V(te.id),m.current.get(te.id)?.focus())},[t]),G=y.useRef(null),A=y.useCallback(Z=>{G.current!==Z&&(G.current=Z,c(Z),x(Z,hPt))},[x]),ee=y.useCallback(()=>{G.current=null,c(Z=>Z===null?Z:null),b(AF)},[b]),K=y.useCallback(Z=>{G.current=Z,V(Z),c(ne=>ne===Z?ne:Z),x(Z,0)},[x]),z=y.useCallback(()=>{G.current=null,c(Z=>Z===null?Z:null),b(AF)},[b]),le=y.useCallback(Z=>{b(0),G.current=null,c(null),n(Z)},[b,n]),L=y.useCallback((Z,ne)=>{if(Z.key==="Escape"){b(0);return}const te=t.findIndex(ie=>ie.id===ne);if(!(te<0)){if(Z.key==="ArrowDown"){Z.preventDefault(),Z.stopPropagation(),B(te+1);return}if(Z.key==="ArrowUp"){Z.preventDefault(),Z.stopPropagation(),B(te-1);return}if(Z.key==="Home"){Z.preventDefault(),Z.stopPropagation(),B(0);return}Z.key==="End"&&(Z.preventDefault(),Z.stopPropagation(),B(t.length-1))}},[t,b,B]);return t.length===0&&!i?null:h.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":pPt,className:j("pointer-events-none absolute inset-y-0 right-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[h.jsxs("div",{"data-rail-frame":"",ref:g,className:j("max-h-[min(calc(100%-4rem),420px)] w-7 overflow-y-auto overscroll-contain","[&::-webkit-scrollbar]:hidden","[mask-image:linear-gradient(to_bottom,transparent_0,#000_24px,#000_calc(100%-24px),transparent_100%)]"),children:[i&&h.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:j("ml-auto mr-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),h.jsx("div",{"data-rail-track":"",className:"py-6",children:t.map(Z=>h.jsx(yPt,{checkpoint:Z,state:rPt({id:Z.id,previewId:l,activeId:o,loaded:a?a.has(Z.id):!0}),label:R.get(Z.id)??"",roving:Z.id===M,registerTick:U,onPreview:A,onPreviewEnd:ee,onFocusMark:K,onBlurMark:z,onActivate:le,onKeyMark:L,describedBy:W&&u===Z.id?s:void 0},Z.id))})]}),h.jsxs(NPe,{open:W,onOpenChange:Z=>{Z||b(0)},children:[h.jsx(ZPe,{virtualRef:C}),_&&h.jsx(IPe,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":_.kind==="user"?"Your message":aPt(_,P),onOpenAutoFocus:Z=>Z.preventDefault(),onCloseAutoFocus:Z=>Z.preventDefault(),onFocusOutside:Z=>{const ne=Z.detail?.originalEvent?.target;ne instanceof Element&&ne.closest("[data-lo-checkpoint-rail]")&&Z.preventDefault()},className:j("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:_.kind==="user"?h.jsx("div",{"data-checkpoint-card-text":"",className:j("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:_.text}):h.jsx($Pt,{checkpoint:_,turnCount:P})})]})]})},bPt=y.memo(vPt);function wPt(e,t){if(!t)return e;let n=!1;const r=[];for(const i of e){if(i.kind==="peer"||i.kind==="tool"&&i.toolName==="send"){n=!0;continue}r.push(i)}return n?r:e}const SPt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function xPt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function Nbe(e,t){const n=[["[data-turn-summary]","data-run-ids"],["[data-fold-ids]","data-fold-ids"]];for(const[r,i]of n)for(const a of e.querySelectorAll(r)){const o=a.getAttribute("data-segment-ids");if(o!==null?!o.split(" ").includes(t):!SPt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function QPt(e,t){return xPt(e,t)||Nbe(e,t)!==null}const kPt=3;function PPt(e,t,n){const r=i=>{const a=e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`);if(a){const l=a.querySelector("button[aria-expanded]");l?.getAttribute("aria-expanded")==="false"&&l.click(),n.onRevealed(a);return}if(i>=kPt){n.onMissing();return}const s=Nbe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const UF=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=Rkt(e.length,{uncapped:r}),s=Ekt(a),l=s.length>1,c=new Set;for(let O=0,d=0;d<s.length;d+=1)c.add(O),O+=s[d];const u=e.slice(0,a).map((O,d)=>h.jsx("li",{className:j("flex leading-none",l&&c.has(d)&&"col-start-1"),children:h.jsx(yA,{image:O,scope:t,size:"thumbnail",label:e.length===1?"Image":`Image ${d+1}`})},O.id));return h.jsxs("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-fold-media":"",className:j("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ml-5":"ml-0"),children:[u,o>0&&h.jsx("li",{className:j("flex h-[78px] items-center leading-none"),children:h.jsx(Ve,{variant:"outline",size:"sm",onClick:n,"aria-label":`+${o} more image${o===1?"":"s"}`,title:`+${o} more image${o===1?"":"s"}`,children:`+${o}`})},"fold-media-more")]})};function TPt(e,t){if(t.length===0)return!1;const n=e.find(i=>i.ids[0]===t[0]);return n?n.open:e.find(i=>i.ids.some(a=>t.includes(a)))?.open??!1}function _Pt(e,t,n,r){if(t.length===0)return[...e];const i=t[0],a=[];let o=!1;for(const s of e){if(!(s.ids[0]===i||s.ids.some(c=>t.includes(c)))){a.push(s);continue}o||(a.push({ids:[...t],open:n}),o=!0)}return o||a.push({ids:[...t],open:n}),a.filter(s=>s.ids.some(l=>r.has(l)))}const x0=1e4,Zbe=/\s/,XPt=e=>{for(let t=e.length;t>0;t-=1){const n=e[t-1];if(n===`
|
|
817
817
|
`)return t;if(n==="."||n==="!"||n==="?"){const r=e[t];if(r===void 0||Zbe.test(r))return t}}return-1},RPt=e=>{for(let t=e.length;t>0;t-=1)if(Zbe.test(e[t-1]))return t;return-1},EPt=/[\uD800-\uDBFF]/,qPt=e=>EPt.test(e[x0-1])?x0-1:x0;function bA(e){if(e.length<=x0)return{text:e,clipped:!1};const t=e.slice(0,x0),n=XPt(t),r=RPt(t),i=n>0?n:r>0?r:qPt(t),a=e.slice(0,i).trimEnd();return{text:a.length>0?a:t,clipped:!0}}const Ibe="[speech]",jPt="Couldn't speak this aloud. Try again.",CPt="Couldn't speak this aloud. Try again.",Dbe="This conversation's agent is no longer available.",zPt=new Set(["Your Radient sign-in has stopped working. Sign in again in Settings.","Your Radient credit balance is too low for speech. Add credits in the Radient Console to continue.","Speech is unavailable right now. Try again in a moment.","Speech is temporarily unavailable. Try again in a moment.","Speech is temporarily unavailable.","Sign in to Radient in Settings to enable speaking aloud.",Dbe,"ElevenLabs refused your API key. Replace it.","Your ElevenLabs credit balance is too low for speech. Add credits with ElevenLabs to continue.","OpenAI refused your API key. Replace it.","Your OpenAI credit balance is too low for speech. Add credits with OpenAI to continue.","Your Radient sign-in has stopped working. Sign in again in the settings page.","Sign in to Radient in the settings page to enable text to speech."]);function APt(e){const t=e instanceof Error?e.message:String(e);return zPt.has(t)?t:(console.error(`${Ibe} ${t}`),jPt)}function UPt(e){return(e instanceof Error?e.message:String(e))===Dbe}function WPt(e){const t=e?.binding?.agent;return typeof t=="string"&&t.length>0?t:null}function YPt(e,t){if(!e)return{state:"unknown"};const n=(t??[]).find(r=>r.name===e);return n?n.agent_id?{state:"agent",agentId:n.agent_id}:{state:"role-without-agent"}:{state:"unknown"}}const GPt=100;function NPt(e,t){if(!e)return null;const n=t?.agents??[],r=t?.total;if(typeof r=="number"&&r>n.length)return n.find(s=>s.name===e||s.id===e)?.id??null;const i=n.find(o=>o.name===e);if(i)return i.id;const a=n.find(o=>o.id===e);return a?a.id:null}async function c2(e){try{return await e()}catch{return null}}async function ZPt(e){if(!e)return null;const t=nm(pO.baseUrl),n=await c2(async()=>{const{profiles:a}=await Xe({op:"profiles.list"});return YPt(e,a)});if(n?.state==="agent")return n.agentId;if(n?.state==="role-without-agent")return null;const r=await c2(async()=>{const a=await t.agents.listAgents(1,GPt,e);return a.status<400?NPt(e,a.result??null):null});return r||await c2(async()=>{const a=await t.agents.getAgent(e);return a.status<400?a.result?.id??null:null})}function wA(e){return sr(t=>e?WPt(t.sessions.find(n=>n.session_id===e)):null)}const IPt=20,Vbe=e=>`msg:${e}`,DPt=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")},zS=(e,t)=>`sel:${e}:${DPt(t)}`,SA=(e,t)=>async()=>{const n=()=>WF.speech.create({input:t}),r=await ZPt(e);return r===null?n():WF.speech.createForAgent(r,{input_text:t}).catch(i=>{if(!UPt(i))throw i;return n()})},WF=nm(pO.baseUrl),VPt=e=>{for(;e.size>IPt;){const t=e.keys().next().value;if(t===void 0)return;e.delete(t)}},u2=new Map,MPt=(e,t)=>{let n=u2.get(e);return n===void 0&&(n=t().finally(()=>{u2.delete(e)}),u2.set(e,n)),n},rv=Ki((e,t)=>({audioCache:new Map,heardKeys:new Set,loadingKey:null,playingKey:null,error:null,audioElement:null,currentUrl:null,generation:0,speak:async(n,r)=>{const i=t().generation+1;t().stopSpeech(),e({loadingKey:n,error:null,generation:i});try{let a=t().audioCache.get(n);if(a){const c=new Map(t().audioCache);c.delete(n),c.set(n,a),e({audioCache:c})}else{const c=await MPt(n,r);if(!c)throw new Error("Speech generation failed, no audio data received.");a=c;const u=new Map(t().audioCache);if(u.set(n,c),VPt(u),e({audioCache:u}),t().generation!==i)return}if(t().generation!==i)return;const o=URL.createObjectURL(a),s=new Audio(o);if(s.onended=()=>{URL.revokeObjectURL(o),e(c=>c.audioElement===s?{playingKey:null,audioElement:null,currentUrl:null}:{})},s.onerror=()=>{URL.revokeObjectURL(o);const c=t().audioElement===s;e(u=>u.audioElement===s?{error:"Error playing audio.",playingKey:null,audioElement:null,currentUrl:null}:{}),c&&(console.error(`${Ibe} playback failed for ${n}`),Oo(CPt))},await s.play(),t().generation!==i){s.pause(),s.onended=null,s.onerror=null,URL.revokeObjectURL(o);return}const l=new Set(t().heardKeys);l.add(n),e({playingKey:n,loadingKey:null,audioElement:s,currentUrl:o,heardKeys:l})}catch(a){if(t().generation!==i)return;const o=a instanceof Error?a.message:"Failed to generate speech";e({error:o,loadingKey:null}),Oo(APt(a))}},stopSpeech:()=>{const{audioElement:n,currentUrl:r}=t();n&&(n.pause(),n.onended=null,n.onerror=null,r&&URL.revokeObjectURL(r)),e({playingKey:null,audioElement:null,currentUrl:null})},dismiss:n=>{const{loadingKey:r,playingKey:i,generation:a}=t();r===n&&e({generation:a+1,loadingKey:null}),i===n&&t().stopSpeech()},playSpeech:async(n,r,i)=>{await t().speak(Vbe(n),SA(r,i))}}));function xA({key:e,getText:t,play:n,available:r=!0}){const{dismiss:i,stopSpeech:a,loadingKey:o,playingKey:s,audioCache:l,heardKeys:c}=rv(),{canUseRadientSpeech:u,speechBlock:O}=QAe(),d=e!==null&&s===e,f=e!==null&&o===e,p=e!==null&&l.has(e),m=p&&e!==null&&c.has(e),g=u?null:ale("speaking-aloud",O),$=!d&&!f&&(!u||!r);return{label:d?"Stop":f?"Loading speech. Press again to cancel.":m?"Replay speech":"Speak aloud",tooltip:d?"Stop":f?"Loading speech. Press again to cancel.":g??(m?"Replay speech":"Speak aloud"),isPlaying:d,isLoading:f,disabled:$,reason:g,active:d||f,press:()=>{if(d){a();return}if(f){e!==null&&i(e);return}if($)return;const b=t();if(b===null||b.trim().length===0)return;const{text:S,clipped:Q}=bA(b);Q&&!p&&Jh(`Reading the first ${S.length.toLocaleString("en-US")} characters. The rest is not read aloud.`),n({text:S})}}}function Mbe(e){y.useEffect(()=>{if(e!==null)return()=>{rv.getState().dismiss(e)}},[e])}const QA=({control:e,side:t="top"})=>{const n=y.useId(),r=e.disabled&&e.reason!==null;return h.jsx(At,{content:e.tooltip,side:t,children:h.jsxs("span",{className:j("flex"),tabIndex:r?0:void 0,"aria-describedby":r?n:void 0,children:[h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":e.label,className:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:e.press,disabled:e.disabled,children:e.isPlaying?h.jsx(k1,{"aria-hidden":"true"}):e.isLoading?h.jsx(Fo,{size:"xs"}):h.jsx(yCe,{"aria-hidden":"true"})}),r&&h.jsx("span",{id:n,className:"sr-only",children:e.reason})]})})},hm="data-lo-quote-toolkit";function Lj(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const YF=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${hm}]`)??null,LPt=e=>e.nodeType===Node.ELEMENT_NODE,FPt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>LPt(r)&&r.hasAttribute(hm));return n===-1?t.length:n},BPt=(e,t)=>Math.abs(e.top-t.top)<.5&&Math.abs(e.left-t.left)<.5&&Math.abs(e.right-t.right)<.5&&Math.abs(e.bottom-t.bottom)<.5,HPt=e=>{const t=Array.from(document.querySelectorAll(`[${hm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>BPt(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function Y$(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(YF(n.startContainer)||YF(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,FPt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:HPt(n)}}const Lbe=8,KPt=.5;function JPt(e,t){const n={top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),bottom:Math.min(e.bottom,t.bottom)};return n.right>n.left&&n.bottom>n.top?n:null}const GF=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function e5t({lines:e,container:t,viewport:n,size:r,gap:i=Lbe,row:a,belowWhenOffFirstLine:o=!1}){if(e.length===0)return null;const s=JPt(t,n);if(!s)return null;const l=e[0],c=e[e.length-1];if(l.bottom<=s.top||l.top>=s.bottom)return null;const u=Math.max(l.bottom-l.top,1),O=a!==void 0&&l.top-a.top>u*KPt,d=l.top-i-r.height>=s.top,f=c.bottom+i+r.height<=s.bottom,m=d&&!(o&&O&&f);return{top:GF(m?l.top-i-r.height:c.bottom+i,s.top,s.bottom-r.height),left:GF(l.left,s.left,s.right-r.width),placement:m?"above":"below"}}const NF="[data-lo-canonical-transcript]",t5t="[data-lo-transcript-content]",ZF=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),n5t=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function Fbe(e){const{turnRef:t,visible:n,lines:r,measureKey:i,belowWhenOffFirstLine:a}=e,o=y.useRef(null),[s,l]=y.useState(null),c=y.useRef(r);c.current=r;const u=y.useCallback(()=>{const O=t.current,d=o.current;if(!O||!d){l(null);return}const f=c.current();if(!f||f.length===0){l(null);return}const p=e5t({lines:f,container:ZF((O.closest(NF)??O).getBoundingClientRect()),viewport:n5t(),size:{width:d.offsetWidth,height:d.offsetHeight},row:ZF(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),m=O.getBoundingClientRect(),g=p?{top:p.top-m.top,left:p.left-m.left,placement:p.placement}:null;l($=>$===g||$&&g&&$.top===g.top&&$.left===g.left&&$.placement===g.placement?$:g)},[t,a]);return y.useLayoutEffect(()=>{if(!n){l(null);return}u();let O=0;const d=()=>{O||(O=requestAnimationFrame(()=>{O=0,u()}))};document.addEventListener("scroll",d,!0),document.addEventListener("selectionchange",d),window.addEventListener("resize",d);const f=t.current?.closest(NF),p=f?.querySelector(t5t),m=new ResizeObserver(d);return f&&m.observe(f),p&&m.observe(p),()=>{O&&cancelAnimationFrame(O),document.removeEventListener("scroll",d,!0),document.removeEventListener("selectionchange",d),window.removeEventListener("resize",d),m.disconnect()}},[n,u,t,i]),{controlRef:o,placement:s}}function Bbe(e){const[t,n]=y.useState(null);y.useEffect(()=>{const i=()=>n(Y$(e.current)?.text??null);return i(),document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[e]);const r=y.useCallback(()=>n(null),[]);return{text:t,clear:r}}const fh="data-lo-link-toolbar",r5t=120,i5t=2;function Hbe(e){const[t,n]=y.useState(null),[r,i]=y.useState(!1),a=y.useRef(null);a.current=t;const o=y.useRef(null),s=y.useRef(null),l=y.useCallback(()=>{const u=e.current;if(!u){o.current=null,n(f=>f===null?f:null),i(f=>f===!1?f:!1);return}const O=nSt(u);if(O){n(f=>f===O?f:O),i(f=>f===!0?f:!0);return}if(i(f=>f===!1?f:!1),Ave()){n(f=>f===null?f:null);return}const d=o.current&&u.contains(o.current)?o.current:null;n(f=>f===d?f:d)},[e]);y.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const d=Q=>{O&&(clearTimeout(O),O=0),o.current=Q,l()},f=Q=>{if(O&&clearTimeout(O),!Q){O=0,o.current=null,l();return}o.current!==Q&&(s.current=null,O=setTimeout(()=>{O=0,o.current=Q,l()},r5t))},p=(Q,P)=>{const R=o.current;if(!R||!u.contains(R))return!1;const _=u.querySelector(`[${fh}]`),E=Lbe+i5t;for(const C of[R,_]){if(!C)continue;const W=C.getBoundingClientRect();if(!(W.width<=0||W.height<=0)&&Q>=W.left-E&&Q<=W.right+E&&P>=W.top-E&&P<=W.bottom+E)return!0}return!1},m=Q=>{const P=Q.target;if(P?.closest(`[${hm}]`))return;const R=P?.closest(dh)??null;!R&&p(Q.clientX,Q.clientY)||f(R)},g=Q=>{const P=Q.relatedTarget;P&&u.contains(P)||p(Q.clientX,Q.clientY)||d(null)},$=Q=>{const P=Q.target?.closest(dh);if(P){if(P===s.current){s.current=null;return}d(P)}},v=Q=>{const P=Q.relatedTarget;P&&u.contains(P)||d(null)},w=()=>Array.from(u.querySelectorAll(`[${fh}] button:not([disabled])`)),x=Q=>{const P=Q.target;if(!P)return!1;if(P.closest(`[${fh}]`)){const C=w(),W=C.indexOf(P);if(W===-1)return!1;if(Q.shiftKey&&W===0){const U=o.current;return U instanceof HTMLElement?(U.focus(),!0):!1}if(!Q.shiftKey&&W===C.length-1){const U=Array.from(u.querySelectorAll(dh)),Y=o.current,V=Y?U.indexOf(Y)+1:-1,M=V>0?U[V]:void 0;return M?(M.focus(),!0):!1}return!1}if(Q.shiftKey)return!1;const _=P.closest(dh);if(!_||!u.contains(_))return!1;o.current!==_&&d(_);const[E]=w();return E?(E.focus(),!0):!1},b=Q=>{if(Q.key==="Tab"&&x(Q)){Q.preventDefault();return}if(!(Q.key==="ContextMenu"||Q.shiftKey&&Q.key==="F10"))return;const R=Q.target?.closest(dh);!R||!u.contains(R)||(Q.preventDefault(),d(R),requestAnimationFrame(()=>{u.querySelector(`[${fh}] button`)?.focus()}))},S=Q=>{const P=Q.target;P&&u.contains(P)||d(null)};return u.addEventListener("pointerover",m),u.addEventListener("pointerout",g),u.addEventListener("focusin",$),u.addEventListener("focusout",v),u.addEventListener("keydown",b),document.addEventListener("pointerdown",S,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",m),u.removeEventListener("pointerout",g),u.removeEventListener("focusin",$),u.removeEventListener("focusout",v),u.removeEventListener("keydown",b),document.removeEventListener("pointerdown",S,!0),document.removeEventListener("selectionchange",l)}},[e,l]);const c=y.useCallback(()=>{s.current=a.current,o.current=null,l()},[l]);return y.useEffect(()=>{if(!t)return;const u=O=>{if(O.key!=="Escape"||O.target?.closest(`[${fh}]`))return;const f=window.getSelection();f&&!f.isCollapsed&&f.removeAllRanges(),c()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,c]),{subject:t,quoteAvailable:r,dismiss:c}}function Kbe(e,t,n){const r=an(i=>i.addReply);return y.useCallback(()=>{const a=Y$(t.current)?.text??(Ave()?null:n?.()??null);a&&(r(e,{id:Wo(),text:a}),window.getSelection()?.removeAllRanges(),Xse())},[r,e,t,n])}const Jbe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(Cve)??"",o=n.getAttribute("data-lo-kind")??"file",s=Zve(),l=y.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=Kbe(e,t,l),{text:u}=Bbe(t),{speak:O}=rv(),d=wA(e),f=u??l(),p=f===null?null:zS(e,bA(f).text);Mbe(p);const m=xA({key:p,getText:()=>Y$(t.current)?.text??l(),play:({text:Y})=>O(zS(e,Y),SA(d,Y))}),[g,$]=y.useState(!1),[v,w]=y.useState(()=>rw(a)??null),{controlRef:x,placement:b}=Fbe({turnRef:t,visible:!0,lines:()=>{const Y=n.getClientRects();return Array.from(Y,V=>({top:V.top,left:V.left,right:V.right,bottom:V.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});y.useEffect(()=>{const Y=rw(a);if(w(Y??null),$(!1),Y!==void 0)return;let V=!0;return Kwt(a,window.api?.probeFiles).then(()=>{V&&w(rw(a)??null)}),()=>{V=!1}},[a]);const S=o==="file"&&Gve(s,a),Q=Yve({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:S}),P=aSt({kind:o,target:a,probe:v,quotable:r,canOpenInCanvas:S});if(!P||!a)return null;const R=async()=>{await Dve(a)&&$(!0)},_=async()=>{if(o==="url"){await KL(o,a);return}s&&Q&&await s.openInCanvas(a)||await KL(o,a)||w(null)},E=async()=>{await qS(a)||w(null)},C=async()=>{await fSt(a)||w(null)},W={quote:h.jsx(Zoe,{}),copy:g?h.jsx(Lc,{}):h.jsx(m6,{}),open:Q?h.jsx(Nje,{}):o==="url"?h.jsx(Lqe,{}):h.jsx($6,{}),"open-default":h.jsx(fqe,{}),"open-folder":h.jsx(e$,{})},U={quote:c,copy:()=>{R()},open:()=>{_()},"open-default":()=>{E()},"open-folder":()=>{C()}};return h.jsxs("div",{[hm]:"",[fh]:"",ref:x,role:"toolbar","aria-label":P.label,className:j("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!b&&"invisible"),style:b?{top:b.top,left:b.left}:void 0,onMouseDown:Y=>Y.preventDefault(),onKeyDown:Y=>{if(Y.key!=="Escape")return;window.getSelection()?.removeAllRanges();const V=n;Y.preventDefault(),i(),V.focus?.()},children:[P.actions.map(Y=>h.jsxs(y.Fragment,{children:[h.jsx(At,{content:Y.id==="copy"&&g?"Copied":Y.label,side:b?.placement==="below"?"bottom":"top",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":Y.id==="copy"&&g?"Copied":Y.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:U[Y.id],children:W[Y.id]})}),Y.id==="quote"&&h.jsx(QA,{control:m,side:b?.placement==="below"?"bottom":"top"})]},Y.id)),P.note&&h.jsx("span",{className:"max-w-56 truncate pl-1 text-ink-dim text-meta",title:P.noteTitle??P.note,children:P.note})]})};function a5t({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:["copy","speak",...n]}function e1e(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const IF=96;function o5t(e){const t=e.replace(/\s+/g," ").trim();return t.length<=IF?t:`${t.slice(0,IF-1).trimEnd()}…`}const s5t="Answer actions",l5t="Your message actions",c5t="pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100";function u5t(e){return e?"opacity-100":c5t}const O5t=2e3,d5t=1e4;function men(e){const{request:t}=e;return t?e.now-t.requestedAt>d5t?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let DF=0,Fb=0;const f5t=Ki(e=>({request:null,requestPanel:(t,n,r,i)=>{DF+=1,e({request:{destination:t,nonce:DF,requestedAt:Date.now(),invoker:n??null,...r?{sessionId:r}:{},...i?.id?{entryId:i.id}:{},...i?.id&&i.excerpt?{entryExcerpt:i.excerpt}:{}}})},consumePanel:t=>e(n=>n.request?.nonce===t?{request:null}:n),presenterClaimed:!1,claimPresenter:()=>{Fb+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Fb=Math.max(0,Fb-1),Fb===0&&e({presenterClaimed:!1}))}}})),h5t=(e,t)=>{let n=e;for(;n!==null;){if(n.matches(":hover"))return!0;if(n===t)break;n=n.parentElement}const r=e.ownerDocument.activeElement;return r!==null&&t.contains(r)},p5t=9e4,VF=new Set,m5t=2600,t1e=y.memo(function({bodyText:t,kind:n="answer",agentId:r,speechId:i,revealId:a,revealAt:o,conversationId:s,entryId:l}){const[c,u]=y.useState(!1),[O,d]=y.useState(!1),f=y.useRef(null),p=y.useRef(null),m=y.useRef(null),g=y.useRef(null),{playSpeech:$}=rv(),v=wA(r??null),w=xA({key:i?Vbe(i):null,getText:()=>t,play:({text:E})=>{i&&$(i,v,E)}}),x=f5t(E=>E.requestPanel),S=a5t({role:n,forkable:!!(s&&l)}),Q=c||w.active;y.useEffect(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]),y.useEffect(()=>{if(!a||o===void 0||VF.has(a)||(VF.add(a),Date.now()-o>p5t))return;const E=p.current;if(E===null)return;const C=E.closest(".group")??E;if(h5t(E,C))return;d(!0);const W=()=>{d(!1),C.removeEventListener("pointerenter",W),C.removeEventListener("focusin",W)};return C.addEventListener("pointerenter",W),C.addEventListener("focusin",W),()=>{C.removeEventListener("pointerenter",W),C.removeEventListener("focusin",W)}},[a,o]),y.useEffect(()=>{if(O)return g.current=setTimeout(()=>{g.current=null,d(!1)},m5t),()=>{g.current!==null&&clearTimeout(g.current)}},[O]);const P=async()=>{await Dve(t)&&(u(!0),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,u(!1)},O5t))},R=()=>{!s||!l||x("session.fork",m.current,s,{id:l,excerpt:o5t(t)})},_={copy:h.jsx(At,{content:c?"Copied":"Copy",side:"bottom",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":c?"Copied":"Copy",className:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:P,children:c?h.jsx(Lc,{"aria-hidden":"true"}):h.jsx(m6,{"aria-hidden":"true"})})}),speak:h.jsx(QA,{control:w,side:"bottom"}),fork:h.jsx(At,{content:"Fork from this message",side:"bottom",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Fork from this message",ref:m,className:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:R,children:h.jsx(rje,{"aria-hidden":"true"})})})};return h.jsx("div",{role:"toolbar","aria-label":n==="user"?l5t:s5t,ref:p,onAnimationEnd:E=>{E.target===E.currentTarget&&d(!1)},...O?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:{"data-lo-answer-actions":""},className:j("flex shrink-0 items-center gap-1",u5t(Q)),children:S.map(E=>h.jsx(y.Fragment,{children:_[E]},E))})}),g5t="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Bb="@min-[260px]/olderhistory:hidden",Hb="@max-[260px]/olderhistory:hidden",n1e="lo-older-history-hint",$5t=({state:e,transportDown:t=!1,onLoadOlder:n,onRetryHydration:r})=>{const i=e==="loading"?"Loading earlier messages":e==="failed"?t?"Earlier messages did not load":"Could not load earlier messages":e==="unproven"?"Earlier history not loaded":null,a=e==="loading";return h.jsxs("div",{className:g5t,children:[h.jsx("output",{className:"sr-only","aria-live":"polite",children:i}),e==="failed"&&t?h.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:[h.jsx("span",{className:Bb,children:"Not loaded"}),h.jsx("span",{className:Hb,children:"Earlier messages did not load"})]}):e==="failed"?h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"min-w-0 truncate text-danger text-meta",title:"Could not load earlier messages",children:[h.jsx("span",{className:Bb,children:"Did not load"}),h.jsx("span",{className:Hb,children:"Could not load earlier messages"})]}),h.jsx(Ve,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:"Try again"})]}):a?h.jsxs(Ve,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[h.jsx(Fo,{size:"sm"}),"Loading earlier messages"]}):e==="idle"?h.jsx(Ve,{variant:"ghost",size:"sm",onClick:n,children:"Load earlier messages"}):e==="windowed"?h.jsxs("span",{id:n1e,className:"min-w-0 truncate text-ink-dim text-meta",title:t?"Earlier history above":"Earlier history above — scroll up to load",children:[h.jsx("span",{className:Bb,children:t?"Earlier history above":"Scroll up for earlier"}),h.jsxs("span",{className:Hb,children:["Earlier history above",t?"":" — scroll up to load"]})]}):e==="unproven"?h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",title:"Earlier history not loaded",children:[h.jsx("span",{className:Bb,children:"Earlier not loaded"}),h.jsx("span",{className:Hb,children:"Earlier history not loaded"})]}),!t&&r&&h.jsx(Ve,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:"Try again"})]}):h.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:"Start of conversation"})]})},y5t="/settings?section=providers",MF="/settings?section=providers&provider=radient",v5t="/settings?section=radient",LF=/sign in to radient/i,b5t=[/insufficient credits/i,/credit balance is too low/i],w5t=[/rate limit or quota/i];function S5t(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function FF(e){const t=(e.provider??"").split("/")[0]?.trim().toLowerCase()==="radient"||LF.test(e.text);let n=S5t(e.category);return n===null&&(e.category==null||e.category==="unknown")&&(LF.test(e.text)?n="sign-in":b5t.some(r=>r.test(e.text))?n="billing":w5t.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:"Sign in to Radient",to:MF}:n==="billing"&&t?{label:"Open Radient account",to:v5t}:{label:"Open provider settings",to:t?MF:y5t}}const r1e=({conversationId:e,turnRef:t})=>{const{text:n,clear:r}=Bbe(t),i=n!==null,a=Kbe(e,t),{controlRef:o,placement:s}=Fbe({turnRef:t,visible:i,lines:()=>Y$(t.current)?.lines??null}),{speak:l}=rv(),c=wA(e),u=n===null?null:zS(e,bA(n).text);Mbe(u);const O=xA({key:u,getText:()=>Y$(t.current)?.text??null,play:({text:d})=>l(zS(e,d),SA(c,d))});return y.useEffect(()=>{if(!i)return;const d=f=>{f.key!=="Escape"||f.defaultPrevented||(window.getSelection()?.removeAllRanges(),r())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[i,r]),i?h.jsxs("div",{[hm]:"",ref:o,className:j("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!s&&"invisible"),style:s?{top:s.top,left:s.left}:void 0,onMouseDown:d=>d.preventDefault(),children:[h.jsx(At,{content:"Quote",side:s?.placement==="below"?"bottom":"top",children:h.jsx(Ve,{variant:"ghost",size:"icon-sm","aria-label":"Quote",className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:a,children:h.jsx(Zoe,{})})}),h.jsx(QA,{control:O,side:s?.placement==="below"?"bottom":"top"})]}):null},O2=(e,t,n="normal",r=0)=>{const a=e.scrollTop+t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-r;e.scrollTop=n==="reversed"?Math.min(0,a):Math.max(0,a)},i1e=24,a1e=6,Fj=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),BF=async e=>{for(let t=0;t<a1e;t+=1){if(e())return;await Fj()}},o1e=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},x5t=e=>{const t=o1e(e.loadOlder),n=()=>BF(()=>e.reachable()||e.rowDistance()!==null);return{loadOne:t,loadThrough:async i=>{const a=e.hasHeadroom??(()=>!0);let o=0;for(;;){if(e.reachable())return"landed";const s=e.rowDistance();if(s!==null){if(i.maxRows!==void 0&&s>i.maxRows)return"over-budget";if(!a()&&o<i.maxPages&&(o+=1,await t())){await n();continue}return e.mount(s),await BF(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},Vg="data-jump-highlight",Q5t=1400,k5t=12,P5t=1200,T5t=a1e,_5t=T5t+2,X5t=2,R5t=30,HF=1,pg=i1e;let th=0;async function E5t(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await x5t({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:k5t,maxRows:P5t})==="landed"}async function q5t(e,t){th+=1;const n=th;O2(e,t,"reversed",pg);const r=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);let i=!1;const a=()=>{i=!0},o=s=>{r.has(s.key)&&(i=!0)};e.addEventListener("wheel",a,{passive:!0,once:!0}),e.addEventListener("pointerdown",a,{passive:!0,once:!0}),e.addEventListener("touchstart",a,{passive:!0,once:!0}),window.addEventListener("keydown",o);try{let s=0,l=!1;for(let c=0;c<_5t&&(await Fj(),!(i||n!==th));c+=1){const u=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-pg;if(Math.abs(u)<=HF){if(s+=1,s>=X5t){l=!0;break}continue}s=0,O2(e,t,"reversed",pg)}if(l&&!i&&n===th){const c=e,u=t,O=()=>{i=!0};c.addEventListener("wheel",O,{passive:!0,once:!0}),c.addEventListener("pointerdown",O,{passive:!0,once:!0}),c.addEventListener("touchstart",O,{passive:!0,once:!0}),window.addEventListener("keydown",o),(async()=>{try{for(let d=0;d<R5t;d+=1){if(await Fj(),i||n!==th||!c.isConnected||!u.isConnected)return;const f=u.getBoundingClientRect().top-c.getBoundingClientRect().top-c.clientTop-pg;if(Math.abs(f)<=HF)continue;O2(c,u,"reversed",pg);const p=c.ownerDocument?.defaultView;p!=null&&c.dispatchEvent(new p.Event("scroll"))}}finally{c.removeEventListener("wheel",O),c.removeEventListener("pointerdown",O),c.removeEventListener("touchstart",O),window.removeEventListener("keydown",o)}})()}}finally{e.removeEventListener("wheel",a),e.removeEventListener("pointerdown",a),e.removeEventListener("touchstart",a),window.removeEventListener("keydown",o)}if(!i&&n===th){const s=e.ownerDocument?.defaultView;s!=null&&e.dispatchEvent(new s.Event("scroll"))}}function s1e(e,t,n){return new Promise(r=>{PPt(e,n,{onRevealed:i=>{KF(i),q5t(t,i).then(()=>{i.isConnected&&!i.hasAttribute(Vg)&&KF(i),r("landed")})},onMissing:()=>{r("missing")}})})}const d2=new WeakMap;function KF(e){const t=d2.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(Vg);e.removeAttribute(Vg),n&&e.offsetHeight,e.setAttribute(Vg,""),d2.set(e,window.setTimeout(()=>{d2.delete(e),e.removeAttribute(Vg)},Q5t))}const Sh=120,Kb=400,j5t=.5,C5t=320,z5t=900,A5t=64,kA=2,f2=24,h2=3,U5t=4,G$=12,W5t=G$,Y5t=120,G5t=.35,JF=12,N5t=8,Z5t=G$,I5t=.5,eB=()=>({armed:!1,deliberate:!1,retained:!1,busy:!1,continuation:!1,clampLatched:!1,actFetchSpent:!1,travelledSinceLatch:!1,pageWidenOwed:!1,turnedAround:!1,lastInputAt:Number.NEGATIVE_INFINITY,failures:0,chainFetch:0,chainWiden:0,chainInvisible:0,actAsks:0,revealsThisAct:0}),l1e=e=>Math.min(z5t,Math.max(C5t,Math.round(e*j5t))),D5t=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=Kb?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=Kb?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=Kb?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=Kb,r={...e,actFetchSpent:n?!1:e.actFetchSpent,actAsks:n?0:e.actAsks,revealsThisAct:n?0:e.revealsThisAct,travelledSinceLatch:n?!1:e.travelledSinceLatch,continuation:!1,turnedAround:!1,chainFetch:0,chainInvisible:0,chainWiden:0,lastInputAt:t.at};return t.deliberate?{...r,clampLatched:!1,failures:0,deliberate:!0,actFetchSpent:!1,actAsks:0,revealsThisAct:0,...e.busy?{retained:!0}:{armed:!0}}:t.atHardTop&&t.continuous&&e.clampLatched&&!n?t.travelledPx>=A5t&&!e.travelledSinceLatch?{...r,armed:!0,clampLatched:!1,travelledSinceLatch:!0}:{...e,lastInputAt:t.at}:e.busy?{...r,retained:!0}:{...r,armed:!0}},Jb=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=kA,pageWidenOwed:e.pageWidenOwed&&t!=="widen",actFetchSpent:t==="fetch"?!0:e.actFetchSpent,chainWiden:t==="widen"?e.chainWiden+1:e.chainWiden,chainFetch:t==="fetch"?e.chainFetch+1:e.chainFetch,actAsks:t==="fetch"?e.actAsks+1:e.actAsks,revealsThisAct:e.revealsThisAct+1,chainInvisible:e.chainInvisible}});function c1e(e,t=l1e(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const V5t=(e,t,n)=>{if(e.busy)return{action:"none",state:e};const r=t.hiddenRows>0?"widen":t.hasMore?"fetch":"none";if(r==="none")return{action:"none",state:e.armed||e.continuation?{...e,armed:!1,deliberate:!1,continuation:!1}:e};if(t.followingTail&&t.scrollable)return e.armed?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e};const i=l1e(t.clientHeight),{inZone:a}=c1e(t,i),o=n-e.lastInputAt>=Sh||t.distanceFromTopPx<=kA,s=e.revealsThisAct<Z5t;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<JF&&s)return o?Jb({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed)return e.deliberate?Jb(e,r,t):r==="fetch"&&e.failures>=h2?{action:"none",state:{...e,armed:!1}}:o?a?r==="fetch"&&e.actFetchSpent?{action:"none",state:{...e,armed:!1}}:Jb(e,r,t):{action:"none",state:{...e,armed:!1}}:{action:"none",state:e};if(e.continuation){const l=e.actAsks<W5t,c=l&&e.chainInvisible>0&&e.chainInvisible<G$;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<JF:(c||l&&e.chainFetch<U5t)&&e.failures<h2)?Jb({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},tB=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<N5t,l=r===null&&t&&i!==null&&i<Math.max(Y5t,G5t*a),c=s||t&&o===0||l;return{...e,busy:!1,failures:t?0:e.failures,armed:e.retained,deliberate:e.retained?e.deliberate:!1,retained:!1,turnedAround:!1,pageWidenOwed:t&&n>0,actFetchSpent:c?!1:e.actFetchSpent,chainInvisible:c?Math.min(e.chainInvisible+1,G$):0,continuation:t&&n>0||c&&e.chainInvisible+1<G$||!e.retained&&!e.turnedAround}},M5t=e=>({...e,busy:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),L5t=e=>({...e,busy:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),F5t=(e,t,n,r)=>n===r?u1e(e,t):null,u1e=(e,t)=>{if(!e||!t||e.id!==t.id||e.extent===t.extent)return 0;const n=t.viewportOffset-e.viewportOffset;return Math.abs(n)<I5t?0:n};function B5t(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const H5t=e=>e?"⌘F":"Ctrl+F";function K5t(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function J5t(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function eTt(e,t){return t>=0&&t<e.length?e[t]:null}function tTt(e,t){const n=[];let r=0;for(const[i,a]of t){const o=Math.max(r,Math.min(e.length,i)),s=Math.max(o,Math.min(e.length,a));s<=o||(o>r&&n.push({text:e.slice(r,o),matched:!1}),n.push({text:e.slice(o,s),matched:!0}),r=s)}return r<e.length&&n.push({text:e.slice(r),matched:!1}),n}const nTt={user:"You",agent:"Agent"},rTt="related match",nB="Search this conversation",iTt="Search results",aTt="Close search";function oTt(e){const t=e.filter(r=>r.tier==="exact").length,n=e.length-t;return n===0?e.length===1?"1 match":`${e.length} matches`:t===0?n===1?"1 related match":`${n} related matches`:`${t} exact · ${n} related`}const sTt="No messages match this search.",lTt="Still indexing this conversation.",cTt="Results appear as the index catches up.",uTt="Newer messages may be missing while the index catches up.",OTt="This conversation lives on another device, so it cannot be searched here.",dTt="This conversation could not be searched.",fTt="Try again",hTt="Check again",pTt="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",mTt="Updating — the list below is the previous search's.",gTt="Going to that message…";function $Tt(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function yTt(e){return e.state==="building"}async function vTt(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await s1e(n,e,t)==="landed"?"revealed":"not-mounted"}async function bTt(e){const t=e.query.trim().slice(0,G7);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??Iie,1),Die);return Xe({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const wTt=200,STt=1500;function xTt({sessionId:e,enabled:t}){const[n,r]=y.useState(""),[i,a]=y.useState("idle"),[o,s]=y.useState([]),[l,c]=y.useState(!1),[u,O]=y.useState(!1),[d,f]=y.useState(-1),p=y.useRef(0),m=y.useRef(0),g=y.useRef(0),$=y.useRef(""),v=y.useRef(null),w=y.useRef(null),x=y.useRef(new Set),b=y.useRef(e);b.current=e;const S=y.useCallback(()=>{w.current!==null&&(clearTimeout(w.current),w.current=null)},[]),Q=y.useCallback((U,Y)=>{x.current.has(U)||(x.current.add(U),console.warn(U,Y))},[]),P=y.useCallback(()=>{p.current+=1,S(),v.current=null,g.current=0,a("idle"),s(U=>U.length===0?U:[]),c(!1),O(!1),f(-1)},[S]),R=y.useRef(()=>{}),_=y.useCallback((U,Y)=>{const V=K5t(Y.state);a(V);const M=V==="ready"||V==="building",B=M?Y.hits:[];if(g.current=B.length,s(B),c(M&&Y.truncated),O(V==="building"&&Y.partial),f(B.length>0?0:-1),V==="building"&&yTt(Y)){if(v.current!==U){v.current=U;const G=p.current;w.current=setTimeout(()=>{w.current=null,p.current===G&&R.current(U,"follow-up")},STt)}}else S()},[S]),E=y.useCallback((U,Y)=>{const V=b.current;if(!V)return;const M=p.current,B=++m.current;Y==="fresh"&&(S(),v.current=null,a("loading")),bTt({sessionId:V,query:U}).then(G=>{B!==m.current||p.current!==M||_(U,G)}).catch(G=>{B!==m.current||p.current!==M||(Q("thread search could not be answered:",G),S(),v.current=null,g.current=0,s([]),c(!1),O(!1),f(-1),a("error"))})},[_,S,Q]);R.current=E,y.useEffect(()=>{const U=`${t?"1":"0"}:${e??""}`;if($.current!==U&&($.current=U,x.current=new Set,P(),r(B=>B===""?B:""),!t||!e))return;if(!t||!e){P();return}const Y=n.trim();if(Y.length===0){P();return}const V=p.current,M=setTimeout(()=>{p.current===V&&R.current(Y,"fresh")},wTt);return()=>clearTimeout(M)},[n,t,e,P]),y.useEffect(()=>()=>S(),[S]);const C=y.useCallback(U=>{f(Y=>J5t(Y,U,g.current))},[]),W=y.useCallback(()=>{const U=n.trim();!t||!e||U.length===0||R.current(U,"fresh")},[t,e,n]);return{query:n,setQuery:r,state:i,hits:o,truncated:l,partial:u,cursor:d,moveCursor:C,activeHit:eTt(o,d),refresh:W}}const QTt=j("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),kTt="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",PTt=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,TTt=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=tTt(e.snippet,e.ranges);return h.jsxs("li",{id:n,role:"option","aria-selected":t,onMouseDown:a=>a.preventDefault(),onClick:()=>r(e),className:j("relative flex cursor-pointer flex-col gap-0.5 px-3 py-2",t?QTt:"hover:bg-accent-wash"),children:[h.jsxs("span",{className:"flex items-center gap-1.5 text-ink-muted text-meta",children:[h.jsx("span",{children:nTt[e.role]}),e.tier==="soft"&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:"·"}),h.jsx("span",{className:"text-ink-dim",children:rTt})]})]}),h.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?h.jsx("mark",{className:kTt,children:a.text},o):h.jsx("span",{children:a.text},o))})]})},_Tt=({query:e,onQueryChange:t,state:n,hits:r,cursor:i,truncated:a,partial:o,onMoveCursor:s,onNavigate:l,onRetry:c,onClose:u,isMac:O,jumping:d=!1})=>{const f=y.useId(),p=`${f}-list`,m=y.useCallback(b=>`${f}-opt-${b}`,[f]),g=y.useRef(null),$=i>=0&&i<r.length?r[i]:null,v=r.length>0,w=n==="error"||n==="building";y.useEffect(()=>{g.current?.focus(),g.current?.select()},[]),y.useEffect(()=>{i<0||document.getElementById(m(i))?.scrollIntoView({block:"nearest"})},[i,m]);const x=b=>{if(b.key==="ArrowDown"){b.preventDefault(),s(1);return}if(b.key==="ArrowUp"){b.preventDefault(),s(-1);return}if(b.key==="Enter"){b.preventDefault(),$!==null?l($):w&&c();return}};return h.jsxs("div",{"data-lo-thread-search":"",role:"presentation",onKeyDown:b=>{b.defaultPrevented||b.key==="Escape"&&(b.preventDefault(),u())},className:"pointer-events-auto w-[26rem] max-w-full rounded-md border border-hairline bg-elevated text-body-sm text-ink shadow-overlay",children:[h.jsx("div",{className:"p-2",children:h.jsxs("div",{className:j("flex items-center gap-2 rounded-sm border border-control bg-surface px-2","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[h.jsx(Xy,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-ink-dim"}),h.jsx("input",{ref:g,type:"text",value:e,onChange:b=>t(b.target.value),onKeyDown:x,maxLength:G7,placeholder:nB,"aria-label":nB,role:"combobox","aria-expanded":v,"aria-controls":v?p:void 0,"aria-activedescendant":$!==null?m(i):void 0,"aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 border-0 bg-transparent text-body-sm text-ink outline-none placeholder:text-ink-dim"}),h.jsx(Ve,{type:"button",variant:"ghost",size:"icon-sm","aria-label":aTt,onClick:u,children:h.jsx(Ri,{"aria-hidden":"true"})})]})}),h.jsxs("div",{className:"flex items-start gap-2 px-3 pb-2",children:[h.jsxs("p",{className:"min-w-0 flex-1 text-ink-muted text-meta",children:[n==="loading"&&(v?mTt:"Searching…"),n==="ready"&&(r.length>0?oTt(r):sTt),n==="building"&&(o?uTt:lTt),n==="unsupported"&&OTt,n==="error"&&dTt,n==="ready"&&a&&v&&h.jsxs("span",{className:"text-ink-dim",children:[" ",$Tt(r.length)]}),n==="building"&&!o&&h.jsxs("span",{className:"text-ink-dim",children:[" ",cTt]})]}),w&&h.jsx(Ve,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?hTt:fTt})]}),v&&h.jsx("ul",{id:p,role:"listbox","aria-label":iTt,"aria-busy":n==="loading",className:j("max-h-80 overflow-y-auto border-t border-hairline py-1",n==="loading"&&"opacity-60"),children:r.map((b,S)=>h.jsx(TTt,{hit:b,active:S===i,optionId:m(S),onNavigate:l},b.id))}),d&&h.jsx("output",{className:"block border-t border-hairline px-3 py-1.5 text-ink-muted text-meta",children:gTt}),h.jsxs("div",{className:"flex items-center gap-3 border-t border-hairline px-3 py-1.5",children:[h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(ud,{shortcut:"↑"}),h.jsx(ud,{shortcut:"↓"}),h.jsx("span",{children:"browse"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(ud,{shortcut:"↵"}),h.jsx("span",{children:"jump"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(ud,{shortcut:"esc"}),h.jsx("span",{children:"close"})]}),h.jsx("span",{className:"ml-auto text-ink-dim text-meta",children:H5t(O)})]})]})},XTt=({sessionId:e,containerRef:t,onReveal:n})=>{const[r,i]=y.useState(!1),[a,o]=y.useState(!1),s=y.useRef(null),l=y.useRef(null),c=xTt({sessionId:e,enabled:r}),u=y.useCallback(()=>{const f=document.activeElement;l.current=f instanceof HTMLElement?f:null,i(!0)},[]),O=y.useCallback(()=>{i(!1);const f=l.current;l.current=null,f?.isConnected&&f.focus()},[]);y.useEffect(()=>{const f=p=>{if(p.defaultPrevented||!B5t(p))return;const m=p.target;if(!(!(s.current!==null&&m!==null&&s.current.contains(m))&&(n$(p.target)||rse(p.target)===null))){if(p.preventDefault(),r){const $=s.current?.querySelector("input");$?.focus(),$?.select();return}u()}};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[r,u]);const d=y.useCallback(async f=>{o(!0);try{if(n){await n(f.id);return}await vTt(t.current,f.id)}finally{o(!1)}},[t,n]);return r?h.jsx("div",{ref:s,className:"pointer-events-none absolute top-3 right-6 z-20 max-w-[calc(100%-1.5rem)]",children:h.jsx(_Tt,{query:c.query,onQueryChange:c.setQuery,state:c.state,hits:c.hits,cursor:c.cursor,truncated:c.truncated,partial:c.partial,onMoveCursor:c.moveCursor,onNavigate:d,onRetry:c.refresh,onClose:O,isMac:PTt(),jumping:a})}):null},RTt='button, a, input, textarea, [role="button"], [contenteditable]',ETt='[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]',qTt=4,jTt=200,rB=e=>{const t=e;return typeof t?.closest!="function"?!0:t.closest(RTt)!==null},CTt=e=>e.querySelector(ETt)!==null,zTt=(e,t)=>t-e<jTt,ATt=e=>e.controlPress?"control":e.modalOpen?"modal":e.pressHadSelection||e.selectionNotCollapsed||e.shiftExtends?"selection":e.dragged?"drag":e.scrolledRecently?"scroll":"focus";function O1e(e){return e.status==="reconnecting"||e.status==="unavailable"&&!!e.failure||!!e.missing}function d1e(e){return O1e(e)||!!e.stale}function UTt(e){return e.status==="reconnecting"?!1:d1e(e)}function f1e(e){return e.awaitingHydration&&!e.admittedSend&&!O1e(e)&&(e.recordCount===0||e.stale===!0)}function WTt(e){return e.recordCount===0&&!e.admittedSend&&!f1e(e)&&!d1e(e)}const YTt=({isSmallView:e=!1})=>h.jsxs("output",{"aria-label":"Loading conversation",className:j("flex items-center gap-2",e&&"gap-1.5"),children:[h.jsx("span",{"aria-hidden":"true",className:"size-2 shrink-0 rounded-full bg-elevated animate-pulse-visible"}),h.jsx("span",{className:"text-ink-dim text-meta",children:"Loading conversation…"})]}),GTt="display.turn_answer_rail";function NTt(e){return e?.find(t=>t.key===GTt)?.value===!0}function ZTt(e,t){return e&&t?"-ml-[13px] border-hairline border-l pl-3":"w-full"}function ITt(e){return A6(e)!==null}function DTt(e){return!(e.kind!=="tool"||e.isError!==!0||I7(e.delivery)||e.neverSent===!0||e.notRunReason!==null&&e.notRunReason!==void 0||e.stopped===!0||B0(e.notRunKind))}function h1e(e,t){const n=U6(e),r=t.focusHold??null,i=t.openRuns??VTt;return{runs:n.map((a,o)=>s_t(e,a,o===n.length-1&&t.live,r,i,t.mode))}}const VTt=new Set,MTt=new Set(["output","args","intent","diff","frame","truncated"]),iB=new WeakMap;let p2=0;const LTt=e=>{const t=iB.get(e);return t!==void 0?`@${t}`:(p2+=1,iB.set(e,p2),`@${p2}`)},aB=new WeakMap;function FTt(e){const t=aB.get(e);if(t!==void 0)return t;const n=e,r={};for(const a of Object.keys(n)){if(MTt.has(a))continue;const o=n[a];if(a==="text"){r[a]=o?1:0;continue}if(a==="images"){r[a]=Array.isArray(o)?LTt(o):o??null;continue}r[a]=o}const i=JSON.stringify(r)??"null";return aB.set(e,i),i}function BTt(e){const t=[];for(const n of e)t.push(`${n.gap}${n.closesTurn?"+":"-"}`),t.push(FTt(n.record));return t.join("\0")}function HTt(e){const t=[e.live?"live":"settled",e.mode??"",e.focusHold??""];if(e.openRuns)for(const n of[...e.openRuns].sort())t.push(`open:${n}`);return t.join("\0")}function KTt(e,t){return`${e}${HTt(t)}`}const m2=720;function PA(e,t,n,r=0,i=!1,a=p1e(e,t)){const o=e.length;if(o<=t)return t;const s=o-t;if(a===null)return t;const l=s-a.openingIndex,c=a.opensWithUserRow&&!i?Math.max(n,r):a.opensWithUserRow?n:0;return l<=0||l>c?t:t+l}function p1e(e,t){const n=e.length;if(n<=t)return null;const r=n-t;return U6(e).find(i=>i.openingIndex<=r&&r<=i.endIndex)??null}function JTt(e,t){return e.runs.find(r=>!r.run.opensWithUserRow&&r.segments.some(i=>i.collapsed&&!t?.has(i.key)))?.key??null}function e_t(e,t,n){const r=JTt(e,n);return r===null?null:t===null||!t.opensWithUserRow&&t.key===r?r:null}function m1e(e,t,n){const r=e.length,i=PA(e,t,n.snapMaxExtra,n.completedRunMaxExtra,n.live??!1),a=r>i?e.slice(r-i):e,o=h1e(a,{live:n.live??!1,openRuns:n.openRuns,mode:n.mode});let s=0;for(const l of o.runs)for(const c of l.segments)c.collapsed&&!n.openRuns?.has(c.key)&&(s+=c.rows.length);return a.length-s}const t_t=12;function n_t(e,t,n){const r=e.length,i=n.minVisibleRows??8,a=Math.min(r,n.maxRows??r),{step:o}=n,s=(()=>{const u=new Map;return O=>{const d=PA(e,O,n.snapMaxExtra,n.completedRunMaxExtra,n.live??!1),f=u.get(d);if(f!==void 0)return f;const p=m1e(e,O,n);return u.set(d,p),p}})(),l=s(t);let c=Math.min(a,t+o);for(;c<a&&s(c)-l<i;)c=Math.min(a,c+o);return c}const g1e=12;function r_t(e,t){return e>=g1e||t.halted||t.loadingOlder||!t.hasMore||!t.headCut||!t.mayWalk?{fetch:!1,spent:e}:{fetch:!0,spent:e+1}}const oB=()=>({key:null,spent:0,halted:!1});function i_t(e,t){return t===null||t===e.key?e:{key:t,spent:0,halted:!1}}function a_t(e,t){return t&&e.gap==="trace"?"item":e.gap}function sB(e,t){const n=[];let r=0,i=null;for(const o of e){if(o.record.kind!=="tool")continue;const s=DTt(o.record);n.push({name:Ple(o.record),failed:s}),s&&(r+=1,i??=o.record.id)}const a=qkt(e);return{durationS:t.headLoaded&&a!==null&&a>=1?a:null,actions:n.length,partial:t.partial,failed:r,firstFailedId:i,title:n.length>0?xkt(n):null}}function o_t(e,t){let n=-1;for(let r=t.length-1;r>=0;r-=1){const i=e[t[r].closeIndex];if(!(i.kind==="assistant"&&i.stopReason==="toolUse")){n=t[r].closeIndex;break}}for(let r=e.length-1;r>n;r-=1){const i=e[r];if(pQ(i)||Fu(i)&&wle(i))return r}return n}function s_t(e,t,n,r,i,a){const o=e.slice(t.openingIndex,t.endIndex+1),s=o.map(w=>w.record),l=t.opensWithUserRow?1:0,c=Y8e(s,{from:l,paints:Fu,isStatement:v3,pinned:ITt,mode:a}),u=c.answer?.closeIndex??null,O=u===null?null:s[u].id;let d=-1;c.segments.forEach((w,x)=>{(u===null||w.to<u)&&(d=x)});const f=c.segments.filter(w=>u===null||w.to<u).length,p=c.segments.length>0&&(t.opensWithUserRow||t.closingAnswerId!==null),m=n?o_t(s,c.cycles)+1:-1,g=c.segments.map((w,x)=>{const b=o.slice(w.from,w.to+1),S=u!==null&&w.from>u,Q=`seg:${S?b[0].record.id:(o[w.to+1]??b[b.length-1]).record.id}`,P=!(w.from===0&&!t.opensWithUserRow),R=G8e(s,c.cycles,w),_=p&&(m<0||w.to<m)&&!(r!==null&&!i.has(Q)&&b.some(E=>E.record.id===r));return{key:Q,rows:b,firstId:b[0].record.id,segmentIds:b.map(E=>E.record.id),gap:a_t(b[0],w.from>l),afterAnswer:S,label:R,completed:N8e(s,c.cycles,w,u,R!==null),collapsed:_,stampTs:x===d&&u!==null&&f===1?s[u].ts:null,facts:sB(b,{partial:!P,headLoaded:P})}}),$=u===null?o:o.slice(0,u+1),v=g.flatMap(w=>w.rows);return{key:t.key,run:t,collapses:g.some(w=>w.collapsed),recordIds:o.map(w=>w.record.id),hidden:v,gap:g[0]?.gap??"item",facts:sB($,{partial:!t.opensWithUserRow,headLoaded:t.opensWithUserRow}),answerId:O,stampTs:u===null?null:s[u].ts,segments:g}}const l_t=160,lB=2,c_t=(e,t,n)=>{const[r,i]=y.useState(null),a=y.useMemo(()=>`${t.length}\0${t[0]?.record.id??""}\0${t[t.length-1]?.record.id??""}`,[t]),o=y.useMemo(()=>new Set(t.map(u=>u.record.id)),[a]),s=y.useMemo(()=>n.filter(u=>o.has(u.id)),[n,o]),l=y.useCallback(()=>{const u=e.current;if(u===null)return;const O=u.getBoundingClientRect().top;let d=null,f=Number.NEGATIVE_INFINITY,p=null,m=null;for(const w of s){const x=u.querySelector(`[data-record-id="${CSS.escape(w.id)}"]`);if(x===null)continue;p===null&&(p=w.id),m=w.id;const b=x.getBoundingClientRect().top;b<=O+i1e+1&&b>f&&(f=b,d=w.id)}const g=u.scrollHeight-u.clientHeight,$=Math.abs(u.scrollTop)<=lB,v=Math.abs(u.scrollTop+g)<=lB;$?d=m:v&&(d=p),i(w=>w===d?w:d)},[e,s]),c=y.useRef(l);return c.current=l,y.useEffect(()=>{const u=e.current;if(u===null)return;let O=0,d=0;const f=()=>{O===0&&(O=window.requestAnimationFrame(()=>{O=0,c.current()})),window.clearTimeout(d),d=window.setTimeout(()=>{d=0,c.current()},l_t)};return u.addEventListener("scroll",f,{passive:!0}),()=>{u.removeEventListener("scroll",f),O!==0&&window.cancelAnimationFrame(O),window.clearTimeout(d)}},[e]),y.useEffect(()=>{l()},[l]),{activeId:r,loadedIds:o}},u_t=1500,O_t=45e3,d_t=[];function f_t(e){const[t,n]=y.useState("idle"),[r,i]=y.useState(null),a=y.useRef(e),o=y.useRef(0),s=y.useRef(null),l=y.useRef(new Set),c=y.useRef(null),u=y.useRef(null),O=y.useRef(new Set),d=y.useCallback(()=>{c.current!==null&&(clearTimeout(c.current),c.current=null),u.current=null},[]),f=y.useCallback((b,S)=>{O.current.has(b)||(O.current.add(b),console.warn(b,S))},[]),p=y.useRef(async()=>{}),m=y.useRef(()=>{}),g=y.useCallback(async(b,S)=>{if(b===o.current&&s.current!==b){s.current=b;try{const Q=await Xe({op:"sessions.checkpoints",sessionId:a.current});if(b!==o.current)return;i(Q),n("ready"),l.current.size>0&&(l.current=new Set(fPt(Q,l.current))),l.current.size>0&&m.current(b)}catch(Q){if(b!==o.current)return;f("checkpoints are unavailable for this conversation; the rail stays hidden:",Q),d(),S==="initial"&&(i(null),n("error"))}finally{s.current===b&&(s.current=null)}}},[f,d]);p.current=g;const $=y.useCallback(b=>{if(b!==o.current||c.current!==null)return;const S=u.current??Date.now()+O_t;u.current=S,c.current=setTimeout(()=>{if(c.current=null,b===o.current){if(l.current.size===0){u.current=null;return}if(Date.now()>=S){l.current=new Set,u.current=null;return}p.current(b,"refresh").then(()=>{b===o.current&&l.current.size>0&&m.current(b)})}},u_t)},[]);m.current=$;const v=y.useCallback(()=>{a.current&&g(o.current,"refresh")},[g]),w=y.useCallback(b=>{const S=a.current;if(!S)return;const Q=o.current,P=b&&b.length>0?{op:"sessions.checkpoints.warm",sessionId:S,ids:b.slice(0,XE)}:{op:"sessions.checkpoints.warm",sessionId:S};(async()=>{try{const R=await Xe(P);if(Q!==o.current)return;for(const _ of R.pending)l.current.add(_);l.current.size>0&&m.current(Q)}catch(R){if(Q!==o.current)return;f("checkpoint naming is unavailable; the cards keep their fallback text:",R)}})()},[f]);y.useEffect(()=>{a.current=e,o.current+=1;const b=o.current;if(s.current=null,l.current=new Set,d(),O.current=new Set,i(null),!e){n("idle");return}return n("loading"),g(b,"initial"),()=>{o.current+=1,d()}},[e,g,d]);const x=r!==null&&(r.index.state==="building"||r.index.state==="stale");return{state:t,building:x,checkpoints:r?.checkpoints??d_t,warm:w,refresh:v}}function $1e(){const[e,t]=y.useState(void 0);return y.useEffect(()=>{const n=window.api?.backend;if(!n?.getStatus){t(null);return}let r=!0;const i=async()=>{try{const o=await n.getStatus();if(!r)return;const s=o?.pairing;t(s&&!s.available?s.cause??"unpaired":null)}catch{}};i();const a=n.onStatusChange?.(()=>void i());return()=>{r=!1,a?.()}},[]),e}const h_t={hosting:"core",model_name:"core",model_effort:"core","providers.openai.use_max_context_window":"advanced","providers.openai.api":"advanced","providers.anthropic.cache_ttl_1h_min_context_tokens":"advanced","providers.openrouter.provider_affinity":"advanced","providers.openrouter.sort":"advanced","providers.openrouter.order":"advanced","providers.openrouter.only":"advanced","providers.openrouter.ignore":"advanced","providers.openrouter.allow_fallbacks":"advanced","providers.openrouter.require_parameters":"advanced","providers.openrouter.data_collection":"advanced","providers.openrouter.zdr":"advanced","providers.openrouter.enforce_distillable_text":"advanced","providers.openrouter.quantizations":"advanced","providers.openrouter.max_price":"advanced","providers.openrouter.preferred_min_throughput":"advanced","providers.openrouter.preferred_max_latency":"advanced","retry.enabled":"core","retry.maxRetries":"advanced","retry.baseDelayMs":"advanced","retry.connectivityMaxRetries":"advanced","retry.connectivityBackoffCapMs":"advanced","retry.modelFallback":"advanced","retry.usageAwareFallback":"advanced","retry.usageAwareAccountPick":"advanced","retry.usageReservePercent":"advanced","retry.fallbackChains":"advanced","tui.theme":"advanced","display.shimmer":"advanced","display.comfortable_rows":"advanced","display.nerd_icons":"advanced","display.heading_markers":"advanced","display.terminal_title":"advanced","display.images":"advanced","display.notifications":"core","display.notification_session_name":"advanced","display.time_format":"advanced","display.dock":"advanced","display.hide_cross_session":"advanced","display.turn_answer_rail":"advanced","tui.sidebar_visible":"advanced","tui.sidebar_position":"advanced","keymap.new_session":"advanced","keymap.resume":"advanced","keymap.quick_send":"core",tool_approval_mode:"core",auto_save_conversation:"core","session.cleanup.enabled":"core","session.cleanup.max_sessions":"advanced","session.cleanup.max_inactive_days":"advanced","session.cleanup.max_total_bytes":"advanced","session.cleanup.remove_empty":"advanced","runtime.background_on_resume":"advanced","runtime.unattended_gate_timeout":"advanced","subagents.max_running":"advanced","subagents.model_choice":"advanced","subagents.models.lo":"advanced","subagents.models.med":"advanced","subagents.models.hi":"advanced","fork.mode":"core","fork.cmux_placement":"advanced","compaction.enabled":"core","compaction.strategy":"advanced","compaction.threshold_percent":"advanced","compaction.threshold_tokens":"advanced","compaction.keep_recent_tokens":"advanced","compaction.auto_continue":"advanced","compaction.mid_turn_enabled":"advanced","compaction.wire_bytes_budget":"advanced","compaction.wire_bytes_trigger":"advanced","web_search.enabled":"core","web_fetch.enabled":"core","web_search.strategy":"advanced","web_search.providers":"advanced","web_search.timeout_seconds":"advanced","web_search.searxng_endpoint":"advanced","web_search.deepseek_evidence":"advanced","web_search.read_enabled":"advanced","web_fetch.timeout_seconds":"advanced","web_fetch.max_bytes":"advanced","web_fetch.max_redirects":"advanced","web_fetch.cache_ttl_seconds":"advanced","web_fetch.allow_private":"advanced","web_fetch.render_backend":"advanced","web_fetch.enrich":"advanced","web_fetch.max_attempts":"advanced","web_fetch.blocked_retry":"advanced","bash.shell":"advanced","providers.lmstudio.base_url":"advanced","providers.lmstudio.models":"advanced","providers.ollama.base_url":"advanced","providers.ollama.models":"advanced","providers.vllm.base_url":"advanced","providers.vllm.models":"advanced","providers.llamacpp.base_url":"advanced","providers.llamacpp.models":"advanced","providers.openai-compatible.base_url":"advanced","providers.openai-compatible.models":"advanced",conversation_length:"advanced",detail_length:"advanced",max_learnings_history:"advanced","desktop.launch_command":"advanced","speech.voice.gender":"advanced","speech.voice.tone":"advanced","speech.voice.expressiveness":"advanced","speech.voice.pace":"advanced","speech.voice.language":"advanced","speech.voice.accent":"advanced","speech.voice.instructions":"advanced"},p_t={model:"core",approvals:"core",web_tools:"core",desktop:"advanced"};function rd(e){return e.tier==="core"||e.tier==="advanced"?e.tier:h_t[e.key]??p_t[e.section]??"advanced"}function m_t(e){return e.length===0?!1:e.filter(n=>rd(n)==="core").length*2>=e.length}function g_t(e,t,n){return t?{layout:null,filter:e?[]:[...n]}:{layout:{opened:e?[...n]:[],closed:e?[]:[...n]},filter:[]}}const y1e="__cascade__";function bp(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Fl(e){return{value:e.kind==="list"?(e.value??[]).join(`
|
|
818
818
|
`):e.kind==="cascade"?y1e:bp(e.value),cascadeBase:null}}function sw(e,t){return t.cascadeBase!==null?!0:e.kind==="cascade"?t.value!==y1e:e.kind==="list"?t.value!==e.value?.join(`
|
|
819
819
|
`):t.value!==bp(e.value)}function $_t(e,t){let n=null,r;switch(e.kind){case"bool":n=t.value==="true";break;case"int":{const i=Number.parseInt(t.value,10);if(Number.isNaN(i))return{ok:!1,error:"Enter a whole number."};n=i;break}case"float":{const i=Number.parseFloat(t.value);if(!Number.isFinite(i))return{ok:!1,error:"Enter a finite number."};n=i;break}case"enum":{const i=e.choices.find(a=>bp(a.value)===t.value);n=i?i.value:t.value;break}case"list":n=t.value.split(`
|
|
820
820
|
`).map(i=>i.trim()).filter(Boolean);break;case"cascade":{if(!t.cascadeBase)return{ok:!1,error:"Nothing has been edited yet."};const i={};for(const[a,o]of Object.entries(t.cascadeBase))i[a]=o;n=i,r=e.value??void 0;break}default:e.empty_unsets&&t.value.trim()===""?n="":n=t.value}return{ok:!0,request:{op:"settings.edit",key:e.key,value:n,...r?{base:r}:{}}}}function y_t(e){const t=e?.errors;return!t||typeof t!="object"?[]:Object.keys(t)}function v1e(e,t,n,r){if(t.isError)return(e?.models??[]).length>0?{loadError:null,notice:v_t(r),noticeDetail:n(t.error)}:{loadError:n(t.error),notice:null,noticeDetail:null};const i=y_t(e);return i.length===0?{loadError:null,notice:null,noticeDetail:null}:{loadError:null,notice:`Some providers did not answer (${i.length}). The rows below are the ones that did.`,noticeDetail:i.join(", ")}}const v_t=e=>`The provider listing failed. The rows below are ${e?"the shipped models":"the last listing that answered"}; Refresh from providers tries again.`,b_t={hosting:"provider",model_name:"model","subagents.models.lo":"provider-model","subagents.models.med":"provider-model","subagents.models.hi":"provider-model"};function w_t(e){return b_t[e]??null}const S_t={provider:"Search providers",model:"Search models","provider-model":"Search models"},cB=1500;function b1e(e){return e==="succeeded"||e==="failed"||e==="cancelled"||e==="expired"}function x_t(e,t,n={}){let r=!1,i=null;const a=n.read??(s=>Xe({op:"auth.status",id:s})),o=async()=>{if(!r)try{const s=await a(e);if(r||(t(s),r))return;b1e(s.state)||(i=setTimeout(o,cB))}catch(s){if(r)return;if(n.onGone&&s instanceof Nt&&s.status===404){r=!0,n.onGone();return}i=setTimeout(o,cB*2)}};return o(),()=>{r=!0,i&&clearTimeout(i)}}const uB=6e4,TA="radient",w1e=[...ca.accounts,"session-issue"];function S1e({retryOnMount:e=!0}={}){const t=ga(),{client:n,provided:r}=Cl(),i=r&&gi(t.data,"tunnel"),a=Yt({queryKey:w1e,queryFn:()=>Xe({op:"accounts.list"}),enabled:i,staleTime:uB,refetchInterval:uB,refetchOnWindowFocus:!0,retry:!1,retryOnMount:e},n);return{status:a,enabled:i,settling:t.isPending&&!t.isFetched||i&&a.isPending&&!a.isFetched}}function gen(e={}){const{status:t,enabled:n,settling:r}=S1e(e);return{data:n?t.data?.radient_login??null:null,isPending:r}}function Q_t(){const{client:e}=Cl(),{status:t,enabled:n}=S1e(),[r,i]=y.useState({kind:"idle"}),a=y.useRef(null),o=y.useRef(null),s=y.useRef(!1);y.useEffect(()=>()=>{o.current?.()},[]);const l=y.useCallback(async()=>{await e.invalidateQueries({queryKey:w1e})},[e]),c=y.useCallback(async m=>{if(m.state==="input_required"){i({kind:"input-required",message:m.message});return}if(!b1e(m.state)){if(m.auth_url&&!s.current){s.current=!0;try{await z_e(m.id)}catch(g){o.current?.(),i({kind:"settled",message:mo(g,"The sign-in page could not be opened. Try again."),canRetry:!0})}}return}if(m.state==="succeeded"){i({kind:"settling"}),a.current=null,vAe(e),await l(),i({kind:"idle"});return}a.current=null,i({kind:"settled",message:m.message,canRetry:!0})},[l,e]),u=y.useCallback(()=>{r.kind==="starting"||r.kind==="running"||(i({kind:"starting"}),s.current=!1,o.current?.(),(async()=>{try{const m=await Xe({op:"auth.start",provider:TA});a.current=m.id,i({kind:"running"}),o.current=x_t(m.id,g=>{c(g)})}catch(m){const g=k_t(m);i({kind:"settled",message:mo(m,"The sign-in could not be started. Try again."),canRetry:g===null,refusal:g??void 0})}})())},[c,r.kind]),O=y.useCallback(()=>{const m=a.current;if(o.current?.(),o.current=null,a.current=null,!m){i({kind:"idle"});return}(async()=>{try{await Xe({op:"auth.cancel",id:m})}catch{}i({kind:"idle"})})()},[]),d=y.useCallback(()=>{i({kind:"idle"})},[]),f=t.data?.radient_login??null;return{issue:r.kind==="starting"||r.kind==="running"||r.kind==="settling"?{kind:"signing-in"}:r.kind==="input-required"?{kind:"input-required",message:r.message}:n?f?.state!=="login_required"?{kind:"hidden"}:r.kind==="settled"?{kind:"settled",message:r.message,canRetry:r.canRetry,refusal:r.refusal}:{kind:"needs-sign-in",remedy:t.data?.tunnel_remedy??null}:{kind:"hidden"},start:u,cancel:O,dismiss:d}}function k_t(e){const t=e?.status;return t===409?"sign-in-active":t===422?"no-browser-flow":null}function $en(e){return e.find(t=>t.kind==="browser")??e.find(t=>t.kind==="device")??e.find(t=>t.kind==="api_key")??null}const P_t="Radient no longer accepts the sign-in stored on this machine",T_t="This app could not confirm the sign-in stored on this machine";function __t(e,t,n){if(e!==TA)return"working";const r=x1e(t);return r!==null?r:!n.unavailable&&n.accountRead==="refused"?"refused":!n.unavailable&&n.accountRead==="signed-out"?"unverified":"working"}function x1e(e){return e?.state==="login_required"?"refused":e?.state==="ok"?"working":e?.state==="unknown"&&e.credential_id!==null?"unverified":null}function yen(e,t,n){return e!==TA?"working":t.isPending?!n.unavailable&&n.accountRead==="refused"?"refused":null:x1e(t.data)===null&&!n.unavailable&&n.accountRead==="checking"?null:__t(e,t.data,n)}function Q1e(e,t="working"){return e.local||e.credential_optional?{label:"No key needed",detail:"No key needed - needs a running server",tone:"neutral",group:"Needs a running server"}:t==="refused"?e.has_credential||e.configured?{label:"Needs re-authentication",detail:P_t,tone:"attention",group:"Needs sign-in"}:{label:"Needs re-authentication",tone:"attention",group:"Needs sign-in"}:t==="unverified"?e.has_credential||e.configured?{label:"Needs sign-in",detail:T_t,tone:"neutral",group:"Needs sign-in"}:{label:"Needs sign-in",tone:"neutral",group:"Needs sign-in"}:e.has_credential||e.configured?{label:"Signed in",tone:"success",group:"Ready to use"}:{label:"Needs sign-in",tone:"neutral",group:"Needs sign-in"}}function X_t(e){return Q1e(e).group!=="Needs sign-in"}function R_t(e){return new Set(e.filter(t=>X_t(t)).map(t=>t.id))}function ven(e){return e.data?{status:"ready",providers:e.data}:e.isError?{status:"failed"}:{status:"loading"}}function ben(e,t){if(t.status==="loading")return e;if(t.status==="failed")return[];const n=R_t(t.providers);return e.filter(r=>n.has(r.id))}function wen(e){return E_t(e)}function E_t(e){return cQ("Providers could not be loaded.",e)}const q_t="Sign-in state unknown",j_t="Current value",C_t="Signed in",z_t="Needs sign-in",_A=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),OB=["Ready to use","Needs a running server","Needs sign-in"];function A_t(e){const t=new Map(OB.map(n=>[n,[]]));for(const n of e){const r=Q1e(n),i=t.get(r.group);i&&i.push({id:n.id,name:n.name,description:r.label,group:r.group})}return OB.flatMap(n=>t.get(n)??[])}function dB(e,t,n){if(e.connected!==t.connected)return e.connected?-1:1;const r=n!==""&&e.provider===n,i=n!==""&&t.provider===n;return r!==i?r?-1:1:0}function U_t(e,t){const n=new Map;for(const r of e){const i=t(r),a=n.get(i);a?a.push(r):n.set(i,[r])}return n}function W_t(e,t){const n=[...e?.models??[]];if(t.kind!=="model")return n;const r=t.hosting.trim();if(!r)return n;const i=n.filter(a=>a.provider===r);return i.length>0?i:n}function Y_t(e,t){const n=e?.credentials_known!==!1,r=W_t(e,t),i=l=>n?l.connected?C_t:z_t:q_t,a=l=>t.kind==="provider-model"?l.provider:i(l),o=t.kind==="provider-model"?r:[...r].sort((l,c)=>dB(l,c,t.hosting)),s=[];for(const[,l]of U_t(o,a)){const c=t.kind==="provider-model"?[...l].sort((u,O)=>dB(u,O,t.hosting)):l;for(const u of c)s.push({id:t.kind==="model"?u.model_id:u.selector,name:u.selector,description:t.kind==="provider-model"?n?u.connected?"Signed in":"Needs sign-in":void 0:`${t.providerNames?.[u.provider]??_A(u.provider)}${u.aggregated?", aggregated":""}${n&&!u.connected?", no credential":""}`,group:a(u)})}return s.push(...N_t(r,e,t)),s}function G_t(e,t){if(e.kind!=="model")return null;const n=e.hosting.trim();if(!n)return null;const r=t?.models??[];if(r.length===0)return null;const i=e.hostingLabel??_A(n);return r.some(o=>o.provider===n)?`Models for ${i}`:`No models listed for ${i}. Showing all models.`}function N_t(e,t,n){const r=n.current.trim();if(!r)return[];const i=o=>n.kind==="model"?o.model_id:o.selector;if(e.some(o=>i(o)===r))return[];const a=(t?.models??[]).find(o=>i(o)===r);return[{id:r,name:a?.selector??r,description:a?`${n.providerNames?.[a.provider]??_A(a.provider)}${t?.credentials_known===!1?"":a.connected?", signed in":", no credential"}`:n.kind==="model"?"Custom model":"Custom value",group:j_t}]}function Z_t(e,t,n){const r=t.trim();if(!r)return null;const i=e.filter(a=>a.id===r);if(n){const a=i.find(o=>o.name===n);if(a)return a}return i[0]??{id:r,name:r}}const fB=e=>`setting-help-${e}`,I_t=({setting:e,kind:t,value:n,disabled:r=!1,onValueChange:i,effectiveHosting:a,helpId:o})=>{const s=ga(),l=gi(s.data,"auth"),c=ile(l),u=t!=="provider"&&gi(s.data,"catalogues"),[O,d]=y.useState(!1),[f,p]=y.useState(void 0),m=Yt({queryKey:[...ca.catalogue,!1],queryFn:()=>Xe({op:"models.catalogue",live:!1}),enabled:u&&O,staleTime:6e4}),g=y.useMemo(()=>Object.fromEntries((c.data??[]).map(P=>[P.id,P.name])),[c.data]),$=y.useMemo(()=>t==="provider"?c.data?A_t(c.data):[]:Y_t(m.data,{kind:t,hosting:t==="model"?a:"",current:n,providerNames:g}),[t,c.data,m.data,a,n,g]),v=v1e(m.data,m,P=>cQ("Could not list models.",P),!1),w=v.loadError?h.jsx("span",{className:"text-danger",children:v.loadError}):v.notice,x=v.noticeDetail?{title:v.noticeDetail}:{},b=Z_t($,n,f),S=y.useMemo(()=>t==="provider"?null:G_t({kind:t,hosting:t==="model"?a:"",hostingLabel:c.data?.find(P=>P.id===a)?.name},m.data),[t,a,c.data,m.data]),Q=y.useMemo(()=>t==="provider"?c.isError?"Could not list providers":l?"No providers":"Provider list unavailable":v.loadError?"Could not list models":u?"Nothing matches that model":"Model list unavailable",[t,c.isError,l,v.loadError,u]);return h.jsx(DPe,{showLabel:!1,ariaLabel:e.label,ariaDescribedBy:o,label:e.label,placeholder:S_t[t],options:$,selected:b,disabled:r,busy:t==="provider"?c.isFetching:m.isFetching,busyLabel:t==="provider"?"Loading providers":"Loading models",onOpenChange:P=>{P&&d(!0)},onSelect:P=>{p(P.name),i(P.id)},onCustomSubmit:P=>i(P),customRowLabel:P=>`Use "${P}"`,listNotice:S,onClear:()=>i(""),emptyText:Q,helperText:w?h.jsx("span",{...x,children:w}):void 0})},D_t="primary+alt+shift+space",V_t=/^f([1-9]|1[0-9]|2[0-4])$/;function k1e(e){return V_t.test(e)}function XA(e,t){const n=M_t(e,t);return t==="mac"?n.join(""):n.join("+")}function M_t(e,t){const r=t==="mac"?{primary:"⌘",meta:"⌘",ctrl:"⌃",alt:"⌥",shift:"⇧"}:{primary:"Ctrl",meta:t==="win"?"Win":"Super",ctrl:"Ctrl",alt:"Alt",shift:"Shift"},i={space:"Space",backspace:"Backspace",delete:"Delete",insert:"Insert",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",up:"Up",down:"Down",left:"Left",right:"Right"};return e.split("+").map(a=>a.trim().toLowerCase()).filter(a=>a.length>0).map(a=>a in r?r[a]:a in i?i[a]:k1e(a)||a.length===1?a.toUpperCase():a)}const Sen={seatLabel:e=>`To: ${e}`,placeholder:e=>`Message ${e}`,sent:"Sent",hint:"Enter sends, Shift+Enter adds a line, Esc hides",recording:"Recording. Press the stop button when you're done.",seatMissing:e=>`This build doesn't have a ${e} seat.`,seatOpenFailed:e=>`Couldn't open the ${e} conversation.`,seatUnreachable:e=>`Couldn't reach ${e}.`,keepText:"Your message is still here.",postAdmission:e=>`That didn't reach ${e} — check the conversation.`,sheetModel:"Model for this conversation",sheetEffort:"Reasoning effort",sheetLoading:"Reading the list…",sheetFailed:"Couldn't read the list. Press to try again.",sheetUnavailable:"This backend can't switch that here.",switchFailed:"That didn't switch:",contextLine:(e,t,n)=>`Context: ${e}${t?` of ${t}`:""} tokens${n?" (estimated)":""}.`,contextLineNoReading:"Context: no reading yet.",controlUnavailable:"That control isn't available in quick send.",cwdReadOnly:"Quick send follows the conversation's directory."};function xen(e){const t=typeof e=="string"?e.trim():"";return t===""?"Aida":t}const L_t="If the chord does nothing, another app or the system owns it — choose another.",F_t="Works even when the app isn't focused.",B_t="A global shortcut needs a modifier — it would otherwise fire while you type.";function H_t(e){const t=n=>XA(n,e);return`Try ${t("primary+shift+space")} or ${t("primary+f8")} if that one is taken.`}function K_t(e,t){const n=i=>XA(i,t);switch(e.split("+").map(i=>i.trim().toLowerCase()).filter(Boolean).sort().join("+")){case"alt+primary+space":return J_t(t,"Fantastical and Things Quick Entry use Control+Option+Space; both let you rebind it.","Some capture apps reserve their own chord in this family; the settings inside them can rebind it.");case"primary+shift+space":return`Some editors use ${n("primary+shift+space")} for parameter hints, and word processors for a non-breaking space.`;default:return null}}function J_t(e,t,n){return e==="mac"?t:n}function e2t(e,t){switch(e){case"registered":return`Registered ${t}`;case"taken":return`Couldn't register ${t} — another app may already use it. Choose another shortcut.`;case"invalid":return"This key can't be used as a global shortcut on this system.";case"unavailable":return"Global shortcuts aren't supported on this system."}}function P1e(){try{return window.api?.windowChrome?.facts?.().platform??"linux"}catch{return"linux"}}const hB={bool:"w-9",int:"w-28",float:"w-28",enum:"w-64",text:"w-96",hotkey:"w-56",list:"w-full min-w-0",cascade:"w-full min-w-0",readonly:"w-40"};function t2t(e){return hB[e]??hB.text}const n2t={" ":"space",Spacebar:"space",Escape:"escape",Esc:"escape",Enter:"enter",Tab:"tab",Backspace:"backspace",Delete:"delete",ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",Home:"home",End:"end",PageUp:"pageup",PageDown:"pagedown"},r2t=new Set(["Control","Shift","Alt","Meta","AltGraph"]),i2t=new Set(["Escape","Esc","Enter"]);function a2t(e){if(r2t.has(e.key)||e.nativeEvent.isComposing)return"";const t=[];e.ctrlKey&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.metaKey&&t.push("meta");const n=n2t[e.key]??e.key.toLowerCase();return n?[...t,n].join("+"):""}function o2t(e){const t=e.split("+"),n=t.at(-1)??"";return t.length>1?!0:k1e(n)}const s2t=()=>{const[e,t]=y.useState(null),n=y.useMemo(P1e,[]);y.useEffect(()=>{const i=window.api?.miniView;if(!i)return;let a=!1;i.getRegistration().then(s=>{a||t(s)}).catch(()=>{});const o=i.onRegistration(s=>{a||t(s)});return()=>{a=!0,o()}},[]);const r=XA(e?.value??D_t,n);return h.jsxs("span",{className:"flex flex-col gap-0.5","data-tour-tag":"quick-send-registration",children:[h.jsx("span",{className:"text-meta text-ink-dim",children:F_t}),e?h.jsx("output",{className:j("text-meta",e.status==="registered"?"text-ink-muted":"text-danger"),children:e2t(e.status,r)}):null,n==="mac"&&e?.status==="registered"?h.jsx("span",{className:"text-meta text-ink-dim",children:L_t}):null,h.jsx("span",{className:"text-meta text-ink-dim",children:H_t(n)})]})},l2t=({value:e,label:t,disabled:n,desktop:r=!1,onChange:i})=>{const[a,o]=y.useState(null),s=y.useMemo(P1e,[]),l=r?K_t(e,s):null;return h.jsxs("span",{className:"flex w-full flex-col gap-0.5",children:[h.jsx(po,{readOnly:!0,value:e,disabled:n,"aria-label":`${t}: press the key you want`,className:"font-mono text-body-sm",onKeyDown:c=>{if(i2t.has(c.key)){c.currentTarget.blur();return}const u=a2t(c);if(u){if(c.preventDefault(),r&&!o2t(u)){o(B_t);return}o(null),i(u)}}}),h.jsx("span",{className:"text-meta text-ink-dim",children:"Press the keys you want; Esc cancels."}),a?h.jsx("output",{className:"text-meta text-danger",children:a}):null,l?h.jsx("span",{className:"text-meta text-ink-muted",children:l}):null,r?h.jsx(s2t,{}):null]})},c2t=({setting:e,value:t,chains:n,disabled:r=!1,onValueChange:i,onChainsChange:a,effectiveHosting:o="",helpId:s})=>{const l=w_t(e.key);if(l)return h.jsx(I_t,{setting:e,kind:l,value:t,disabled:r,onValueChange:i,effectiveHosting:o,helpId:s});switch(e.kind){case"bool":return h.jsx(HPe,{checked:t==="true",disabled:r,onCheckedChange:c=>i(c?"true":"false"),"aria-label":e.label});case"enum":return h.jsxs(VPe,{value:t,disabled:r,onValueChange:i,children:[h.jsx(MPe,{"aria-label":e.label,className:"w-full",children:h.jsx(LPe,{})}),h.jsx(FPe,{children:e.choices.map(c=>h.jsx(BPe,{value:bp(c.value),title:c.description||void 0,children:c.label},bp(c.value)))})]});case"int":case"float":return h.jsx(po,{type:"number",value:t,disabled:r,min:e.minimum??void 0,max:e.maximum??void 0,step:e.kind==="int"?1:"any",onChange:c=>i(c.target.value),"aria-label":e.label});case"hotkey":return h.jsx(l2t,{value:t,label:e.label,disabled:r,desktop:e.hotkey_scope==="desktop",onChange:i});case"list":return h.jsx(Lh,{value:t,disabled:r,rows:Math.min(6,e.members.length+2),onChange:c=>i(c.target.value),"aria-label":e.label,placeholder:e.placeholder,className:"font-mono text-body-sm"});case"cascade":{const c=n??e.value??{};return h.jsxs("div",{className:"flex flex-col gap-3",children:[Object.entries(c).map(([u,O])=>h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"font-mono text-meta text-ink-dim",children:u}),h.jsx(Lh,{value:O.join(`
|
|
821
821
|
`),disabled:r,rows:Math.max(2,O.length+1),onChange:d=>a?.({...c,[u]:d.target.value.split(`
|
|
822
|
-
`).map(f=>f.trim()).filter(Boolean)}),"aria-label":`${e.label}: ${u}`,className:"font-mono text-body-sm"})]},u)),h.jsx("p",{className:"text-meta text-ink-dim",children:"One hop per line, as provider/model (effort). An empty chain moves to the next provider."})]})}default:return h.jsx(po,{value:t,disabled:r,onChange:c=>i(c.target.value),"aria-label":e.label,placeholder:e.placeholder})}},T1e=({className:e})=>h.jsx("span",{role:"img","aria-label":"Changed from the default",title:"Changed from the default",className:j("size-1.5 shrink-0 rounded-full bg-accent",e)}),u2t=({title:e,rowCount:t,advancedCount:n,scope:r,modified:i,onOpenChange:a,defaultOpen:o=!1})=>h.jsx("div",{"data-section-header":e,className:"flex w-full flex-col",children:h.jsx(Bo,{defaultOpen:o,onOpenChange:a,triggerClassName:"text-ink hover:bg-row-hover hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-10 py-0",className:"w-full",summary:h.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[h.jsx("span",{className:"truncate text-heading text-ink",children:e}),t>0&&h.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:t===1?"1 setting":`${t} settings`}),r&&h.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:r}),n>0&&h.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[n," advanced"]})]}),i&&h.jsx(T1e,{className:"ml-auto"})]})})}),O2t="size-3.5 shrink-0",d2t=({setting:e,draft:t,tier:n,gate:r,saving:i,error:a,onDraftChange:o,onSave:s,onReset:l,effectiveHosting:c=""})=>{const u=!!(r&&!r.on),O=sw(e,t),d=i||u,f=e.kind==="list"||e.kind==="cascade",p=h.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[h.jsx("span",{className:"truncate text-body-sm text-ink",children:e.label}),e.kind==="readonly"&&h.jsx("span",{className:"text-meta text-ink-dim",children:"Read-only"}),e.warning&&h.jsx("span",{className:"text-meta text-danger",children:e.warning})]}),m=u&&r&&h.jsxs("p",{className:"text-meta text-ink-dim",children:["Needs ",r.label," on. Nothing here is saved while it is off."]});return h.jsx("div",{"data-setting-key":e.key,"data-tier":n,className:"border-b border-hairline",children:h.jsxs("div",{className:"flex flex-wrap items-start gap-x-4 gap-y-1 px-1 py-2.5",children:[h.jsxs("div",{className:j("flex min-w-44 flex-col gap-0.5",f?"shrink-0 basis-2/5":"flex-1"),children:[n==="advanced"&&e.help?h.jsx(Bo,{summary:p,triggerClassName:"min-h-5 py-0 px-0 text-body-sm text-ink hover:text-ink",chevronClassName:"text-ink-dim",summaryAlign:"firstLine",rowClassName:"min-h-5 py-0",className:"w-full",children:h.jsx("span",{className:"text-meta text-ink-dim",children:e.help})}):h.jsxs("span",{className:"flex min-h-5 items-center gap-1.5",children:[h.jsx("span",{"aria-hidden":!0,className:O2t}),p]}),n==="core"&&e.help&&h.jsx("p",{id:fB(e.key),className:"ml-5 text-meta text-ink-dim",children:e.help}),m]}),h.jsxs("div",{className:j("flex shrink-0 items-center gap-2 self-center",f&&"min-w-0 flex-1 items-start"),children:[(!e.is_default||O)&&h.jsx(T1e,{}),!e.is_default&&e.kind!=="readonly"&&h.jsxs(Ve,{variant:"ghost",size:"sm",disabled:d,onClick:l,"aria-label":`Use default for ${e.label}`,children:[h.jsx(pCe,{"aria-hidden":"true"}),"Use default"]}),O&&h.jsx(Ve,{variant:"primary",size:"sm",disabled:d,onClick:s,children:i?"Saving":"Save"}),h.jsx("div",{className:t2t(e.kind),"data-setting-control":"",children:e.redacted?h.jsx("span",{className:"text-meta text-ink-dim",children:"Set in the credential manager: this value carries inline credentials or query parameters."}):e.kind==="readonly"?h.jsx("span",{className:"text-body-sm text-ink-muted",children:bp(e.value)||"Not set"}):h.jsx(c2t,{setting:e,value:t.value,chains:t.cascadeBase??void 0,disabled:d,effectiveHosting:c,helpId:n==="core"&&e.help?fB(e.key):void 0,onValueChange:g=>o({...t,value:g}),onChainsChange:g=>o({...t,cascadeBase:g})})})]}),a&&h.jsx(xc,{variant:"danger",role:"alert",className:"w-full",children:h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{children:a}),h.jsxs(Ve,{variant:"secondary",size:"sm",disabled:i,onClick:s,children:[h.jsx(v6,{"aria-hidden":"true"}),"Retry"]})]})})]})})},f2t="w-full max-w-[400px]",h2t=({query:e,onQueryChange:t,matchCount:n,matchSections:r,coreCount:i,advancedCount:a,modifiedCount:o,modifiedOnly:s,onModifiedOnlyChange:l,showAdvanced:c,onShowAdvancedChange:u,onExpandAll:O,onCollapseAll:d,unsavedCount:f,savingAll:p,onSaveAll:m,onDiscardAll:g})=>h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[h.jsxs("div",{className:j("relative",f2t),children:[h.jsx(Xy,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),h.jsx(po,{value:e,onChange:$=>t($.target.value),onKeyDown:$=>{$.key==="Escape"&&e&&t("")},placeholder:"Search settings by name, description or key","aria-label":"Search settings",className:"pl-9"}),e&&h.jsx(Ve,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>t(""),"aria-label":"Clear search",children:h.jsx(Ri,{"aria-hidden":"true"})})]}),h.jsxs("fieldset",{className:"m-0 border-0 p-0",children:[h.jsx("legend",{className:"sr-only",children:"Settings filters"}),h.jsxs("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:[h.jsxs(Ve,{variant:"ghost",size:"sm","aria-pressed":s,onClick:()=>l(!s),className:j(s&&"bg-surface text-ink hover:bg-surface"),children:["Modified",h.jsx(vd,{variant:"neutral",children:o})]}),h.jsx(Ve,{variant:"ghost",size:"sm","aria-pressed":c,onClick:()=>u(!c),className:j(c&&"bg-surface text-ink hover:bg-surface"),children:"Show advanced"})]})]}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[f>0&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-meta text-ink-dim",children:f===1?"1 unsaved change":`${f} unsaved changes`}),h.jsx(Ve,{variant:"primary",size:"sm",disabled:p,onClick:m,children:p?"Saving":"Save all"}),h.jsx(Ve,{variant:"ghost",size:"sm",disabled:p,onClick:g,children:"Discard all"})]}),h.jsx(Ve,{variant:"ghost",size:"sm",onClick:O,children:"Expand all"}),h.jsx(Ve,{variant:"ghost",size:"sm",onClick:d,children:"Collapse all"})]})]}),h.jsx("p",{className:"text-meta text-ink-dim","aria-live":"polite",children:n!==null?`${n} ${n===1?"result":"results"} in ${r} ${r===1?"section":"sections"}`:s?`${o} modified ${o===1?"setting":"settings"}`:c?`${a} advanced settings shown — Expand all to see them`:`${i} core settings, ${a} advanced`})]}),RA={all:["desktop","settings"]},p2t={live:"Takes effect immediately","new launch":"Takes effect the next time the app starts","new sessions":"Takes effect for new conversations"},m2t=40,nh=e=>e.toLowerCase().replace(/[-_.]/g," "),Qen=({focusKey:e,initialFilter:t=""})=>{const n=ga(),r=$1e(),i=gi(n.data,"settings"),[a,o]=y.useState(t),[s,l]=y.useState(!1),[c,u]=y.useState(!1),[O,d]=y.useState({}),[f,p]=y.useState({}),[m,g]=y.useState({}),[$,v]=y.useState(!1),[w,x]=y.useState(new Set),[b,S]=y.useState(new Set),[Q,P]=y.useState(new Set),R=y.useRef(null),_=y.useRef(null),E=Yt({queryKey:RA.all,queryFn:()=>Xe({op:"settings.list"}),enabled:i,staleTime:1e4}),C=E.data;y.useEffect(()=>{C&&d(ae=>{let fe=!1;const Te={...ae};for(const _e of C.settings){const ut=ae[_e.key];if(!ut){Te[_e.key]=Fl(_e),fe=!0;continue}if(sw(_e,ut))continue;const St=Fl(_e);(St.value!==ut.value||St.cascadeBase!==ut.cascadeBase)&&(Te[_e.key]=St,fe=!0)}return fe?Te:ae})},[C]);const W=y.useCallback(ae=>!ae.is_default||sw(ae,O[ae.key]??Fl(ae)),[O]),U=y.useMemo(()=>{const ae=(C?.settings??[]).find(fe=>fe.key==="hosting");return ae?(O.hosting??Fl(ae)).value:""},[C,O]),Y=y.useMemo(()=>{if(!C)return[];const ae=nh(a.trim()),fe=ae.length>0||c;return C.settings.filter(Te=>!fe&&rd(Te)==="advanced"&&!s||c&&!W(Te)?!1:ae?nh([Te.label,Te.help,Te.key,Te.section,Te.warning??""].join(" ")).includes(ae):!0)},[C,a,s,c,W]),V=a.trim().length>0||c,M=y.useMemo(()=>C?.sections??[],[C]),B=y.useCallback(ae=>(C?.settings??[]).filter(fe=>fe.section===ae),[C]),G=ae=>Y.filter(fe=>fe.section===ae),A=ae=>w.has(ae)?!0:b.has(ae)?!1:m_t(B(ae)),ee=(ae,fe)=>{x(Te=>{const _e=new Set(Te);return fe?_e.add(ae):_e.delete(ae),_e}),S(Te=>{const _e=new Set(Te);return fe?_e.delete(ae):_e.add(ae),_e})},K=(ae,fe)=>{P(Te=>{const _e=new Set(Te);return fe?_e.delete(ae):_e.add(ae),_e})},z=ae=>{const fe=M.filter(_e=>ae||G(_e.name).length>0).map(_e=>_e.name),Te=g_t(ae,V,fe);Te.layout&&(x(new Set(Te.layout.opened)),S(new Set(Te.layout.closed))),P(new Set(Te.filter))};y.useEffect(()=>{a.trim()||P(new Set)},[a]);const le=y.useCallback(ae=>{const fe=ae.gated_by;if(!fe||!C)return null;const Te=C.settings.find(_e=>_e.key===fe);return{key:fe,label:Te?.label??fe,on:Te?.value===!0||Te?.value==="true"}},[C]),L=y.useCallback((ae,fe)=>p(Te=>({...Te,[ae]:fe})),[]),Z=y.useCallback((ae,fe)=>g(Te=>({...Te,[ae]:fe})),[]),ne=y.useCallback(async ae=>{const fe=O[ae.key];if(!fe)return!1;const Te=$_t(ae,fe);if(!Te.ok)return Z(ae.key,Te.error),!1;L(ae.key,!0),Z(ae.key,null);try{await Xe(Te.request),L(ae.key,!1);const ut=(await E.refetch()).data?.settings.find(St=>St.key===ae.key);return ut&&d(St=>{const bt=St[ae.key];return bt&&bt.value===fe.value&&bt.cascadeBase===fe.cascadeBase?{...St,[ae.key]:Fl(ut)}:St}),!0}catch(_e){return L(ae.key,!1),Z(ae.key,_e instanceof Error?_e.message:"The setting could not be saved."),!1}},[O,E,L,Z]),te=y.useCallback(async ae=>{L(ae.key,!0),Z(ae.key,null);try{await Xe({op:"settings.reset",key:ae.key}),d(fe=>({...fe,[ae.key]:Fl({...ae,value:ae.default,is_default:!0})})),L(ae.key,!1),await E.refetch()}catch(fe){L(ae.key,!1),Z(ae.key,fe instanceof Error?fe.message:"The setting could not be reset.")}},[E,L,Z]),ie=y.useMemo(()=>(C?.settings??[]).filter(ae=>sw(ae,O[ae.key]??Fl(ae))),[C,O]),$e=async()=>{v(!0);for(const ae of ie)await ne(ae);v(!1)},je=()=>{C&&(d(ae=>{const fe={...ae};for(const Te of C.settings)fe[Te.key]=Fl(Te);return fe}),g({}))};y.useEffect(()=>{if(!e||!C||R.current===e)return;const ae=C.settings.find(_e=>_e.key===e);if(!ae)return;R.current=e,rd(ae)==="advanced"&&l(!0);const fe=nh(a.trim());!fe||nh([ae.label,ae.help,ae.key,ae.section].join(" ")).includes(fe)||o(""),u(!1),x(_e=>new Set(_e).add(ae.section)),S(_e=>{const ut=new Set(_e);return ut.delete(ae.section),ut})},[e,C,a]);const Oe=y.useMemo(()=>{if(!e||!C)return!1;const ae=C.settings.find(Te=>Te.key===e);if(!ae||rd(ae)==="advanced"&&!s)return!1;const fe=nh(a.trim());return fe?nh([ae.label,ae.help,ae.key,ae.section].join(" ")).includes(fe):!0},[e,C,a,s]);if(y.useEffect(()=>{if(!Oe||!e||_.current===e)return;let ae=0,fe=0;const Te=()=>{const _e=document.querySelector(`[data-setting-key="${CSS.escape(e)}"]`),ut=_e?.querySelector('[data-setting-control] :is(input, textarea, select, button[role="switch"], button)')??_e;if(ut){ut===_e&&(ut.tabIndex=-1),ut.focus(),ut.scrollIntoView({block:"center"}),_.current=e;return}fe+=1,fe<m2t&&(ae=requestAnimationFrame(Te))};return ae=requestAnimationFrame(Te),()=>cancelAnimationFrame(ae)},[Oe,e]),n.data&&!i)return h.jsx(xc,{variant:"warning",children:"Searchable settings need a newer Local Operator server. Update the server and restart the app to manage these settings here."});if(E.isLoading||n.isLoading)return h.jsx("div",{className:"flex h-40 items-center justify-center",children:h.jsx(Fo,{size:"lg",label:"Loading settings"})});const Fe=(n.data?null:n.error)??E.error;if(Fe||!C){const ae=n.isFetching||E.isFetching,{sentence:fe,remedy:Te}=_7e(r??null,"Your settings could not be loaded.",Fe);return h.jsx(xc,{variant:"warning",children:h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{children:fe}),Te&&h.jsx(Ve,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{n.isError?n.refetch():E.refetch()},disabled:ae,children:ae?"Retrying":"Retry"})]})})}const ze=C.settings.reduce((ae,fe)=>(ae[rd(fe)]+=1,ae),{core:0,advanced:0}),ft=new Set(Y.map(ae=>ae.section)).size;return h.jsxs("div",{className:"flex flex-col gap-4",children:[h.jsx(h2t,{query:a,onQueryChange:o,matchCount:a.trim()?Y.length:null,matchSections:ft,coreCount:ze.core,advancedCount:ze.advanced,modifiedCount:C.settings.filter(W).length,modifiedOnly:c,onModifiedOnlyChange:u,showAdvanced:s,onShowAdvancedChange:l,onExpandAll:()=>z(!0),onCollapseAll:()=>z(!1),unsavedCount:ie.length,savingAll:$,onSaveAll:()=>void $e(),onDiscardAll:je}),V&&Y.length===0&&h.jsx("div",{className:"flex flex-col items-center py-6 text-center",children:h.jsx("p",{className:"text-body-sm text-ink-muted",children:"No settings match this search. Clear the search field to see every setting again."})}),h.jsx("div",{className:"flex flex-col gap-1",children:M.map(ae=>{const fe=G(ae.name),Te=B(ae.name),_e=V?0:Te.filter(St=>rd(St)==="advanced").length;if(V&&fe.length===0)return null;const ut=V?fe.length>0&&!Q.has(ae.name):A(ae.name);return h.jsxs("section",{"data-settings-section":ae.name,"data-open":ut,className:"flex flex-col",children:[h.jsx(u2t,{title:ae.title,rowCount:fe.length,advancedCount:_e,scope:p2t[ae.scope],modified:Te.some(W),defaultOpen:ut,onOpenChange:St=>V?K(ae.name,St):ee(ae.name,St)},`${ae.name}:${ut?"open":"closed"}`),h.jsxs("div",{hidden:!ut,className:"flex flex-col pb-3",children:[ae.description&&h.jsx("p",{className:"px-1 pb-1 text-meta text-ink-dim",children:ae.description}),fe.length===0?h.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[h.jsx("p",{className:"text-body-sm text-ink-muted",children:_e>0?"Advanced settings are hidden here.":"Nothing in this section matches."}),_e>0&&h.jsxs(Ve,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:["Show ",_e," advanced"]})]}):fe.map(St=>h.jsx(d2t,{setting:St,draft:O[St.key]??Fl(St),tier:rd(St),gate:le(St),effectiveHosting:U,saving:!!f[St.key],error:m[St.key]??null,onDraftChange:bt=>d(he=>({...he,[St.key]:bt})),onSave:()=>void ne(St),onReset:()=>void te(St)},St.key))]})]},ae.name)})})]})},g2t="display.hide_cross_session";function $2t(){const e=ga(),t=gi(e.data,"settings");return Yt({queryKey:RA.all,queryFn:()=>Xe({op:"settings.list"}),enabled:t,staleTime:1e4}).data?.settings.find(i=>i.key===g2t)?.value===!0}const y2t=1200,v2t=120,pB=8,mB=(e,t)=>e===null||!t?null:Math.max(0,t()-e);function b2t({containerRef:e,sessionKey:t,hiddenRows:n,hasMore:r,hydrationProven:i,historyReadPending:a,onWiden:o,onLoadOlder:s,onLoadOlderOutcome:l,olderFailed:c=!1,loadingOlder:u,contentKey:O,rowCount:d,paintedRows:f}){const p=y.useRef(eB()),m=y.useRef(0),[g,$]=y.useState(!1),[v,w]=y.useState(!1),x=y.useRef({hiddenRows:n,hasMore:r,onWiden:o,onLoadOlder:s,onLoadOlderOutcome:l,paintedRows:f});x.current={hiddenRows:n,hasMore:r,onWiden:o,onLoadOlder:s,onLoadOlderOutcome:l,paintedRows:f};const b=y.useRef({sample:null,until:0,inputRevision:0}),S=y.useRef(null),Q=y.useCallback((L,Z)=>{Z!==L&&(S.current=Z)},[]),P=y.useRef({fromTail:0,at:0,extent:0,clamped:!1,revision:0}),R=y.useRef(0),_=y.useRef(0),E=y.useRef(0),C=y.useCallback(()=>{const L=e.current;if(!L)return null;const{scrollTop:Z,scrollHeight:ne,clientHeight:te}=L,ie=Math.abs(Z);return{distanceFromTopPx:Math.max(0,ne-te-ie),clientHeight:te,hiddenRows:x.current.hiddenRows,hasMore:x.current.hasMore,scrollable:ne-te>1,followingTail:ie<=f2}},[e]),W=y.useCallback(()=>{const L=e.current;if(!L)return null;const Z=L.getBoundingClientRect().top;for(const ne of L.querySelectorAll("[data-record-id]")){const te=ne.getBoundingClientRect();if(te.bottom>Z){const ie=ne.dataset.recordId;if(!ie)continue;return{id:ie,viewportOffset:te.top-Z,extent:L.scrollHeight}}}return null},[e]),U=y.useCallback(L=>{const Z=e.current;if(!Z)return null;const ne=Z.querySelector(`[data-record-id="${CSS.escape(L)}"]`);return ne?{id:L,viewportOffset:ne.getBoundingClientRect().top-Z.getBoundingClientRect().top,extent:Z.scrollHeight}:null},[e]),Y=y.useCallback(()=>{const L=e.current;if(!L||b.current.sample!==null&&Number.isFinite(b.current.until)&&performance.now()<=b.current.until)return;if(Math.abs(L.scrollTop)<=f2){b.current={sample:null,until:0,inputRevision:0};return}const Z=W();Z&&(b.current={sample:Z,until:Number.POSITIVE_INFINITY,inputRevision:P.current.revision})},[e,W]),V=y.useCallback(()=>{const L=e.current,Z=b.current.sample;if(!L||!Z)return;if(Math.abs(L.scrollTop)<=f2){b.current={sample:null,until:0,inputRevision:0};return}const ne=F5t(Z,U(Z.id),b.current.inputRevision,P.current.revision);if(ne===null){b.current.sample=null;return}const te=performance.now()>b.current.until;if(ne!==0&&(L.scrollTop+=ne,S.current=L.scrollTop),te){Y();return}ne!==0&&(b.current.sample={...Z,extent:L.scrollHeight})},[e,U,Y]),M=y.useCallback(()=>{b.current={sample:W(),until:performance.now()+y2t,inputRevision:P.current.revision}},[W]),B=y.useCallback(L=>(L.chainInvisible===0&&w(!0),L),[]),G=y.useCallback(()=>{R.current||(R.current=requestAnimationFrame(()=>{R.current=0;const L=C();if(!L)return;const{action:Z,state:ne}=V5t(p.current,L,performance.now());p.current=ne;const te=c1e(L);if($(Z!=="none"||ne.busy||ne.pageWidenOwed||ne.armed&&te.inZone),Z==="none"){(ne.armed||ne.pageWidenOwed)&&!_.current&&(_.current=window.setTimeout(()=>{_.current=0,G()},Sh));return}if(M(),Z==="widen"){const Fe=x.current.hiddenRows,ze=x.current.paintedRows?.()??null;x.current.onWiden();const ft=m.current;let ae=0;const fe=()=>{if(m.current===ft){if(x.current.hiddenRows!==Fe||ae>=pB){p.current=B(tB(p.current,{network:!1,hiddenRowsAfter:x.current.hiddenRows,paintedDelta:mB(ze,x.current.paintedRows)})),G();return}ae+=1,requestAnimationFrame(fe)}};requestAnimationFrame(fe);return}const ie=x.current.paintedRows?.()??null,$e=W(),je=async()=>{try{return x.current.onLoadOlderOutcome?await x.current.onLoadOlderOutcome():await x.current.onLoadOlder()?{kind:"applied",newRecords:0,exhausted:!1}:{kind:"failed",reason:"request"}}catch(Fe){return console.warn("older history load was rejected:",Fe),{kind:"failed",reason:"request"}}},Oe=m.current;je().then(Fe=>{if(m.current!==Oe)return;if(Fe.kind==="failed"){p.current=M5t(p.current),w(!1),requestAnimationFrame(G);return}if(Fe.kind!=="applied"){p.current=L5t(p.current),requestAnimationFrame(G);return}const ze=m.current;let ft=0;const ae=()=>{if(m.current!==ze)return;const fe=x.current.hiddenRows;if(fe>0||ft>=pB){const Te=e.current,_e=$e===null?null:U($e.id);p.current=B(tB(p.current,{hiddenRowsAfter:fe,paintedDelta:mB(ie,x.current.paintedRows),growthPx:$e===null?null:Math.max(0,u1e($e,_e)),clientHeight:Te?.clientHeight??0,newRecords:Fe.newRecords})),G();return}ft+=1,requestAnimationFrame(ae)};requestAnimationFrame(ae)})}))},[M,C,W,U,B]),A=y.useCallback((L,Z,ne=!1)=>{const te=e.current,ie=performance.now(),je=(C()?.distanceFromTopPx??Number.POSITIVE_INFINITY)<=kA,Oe=P.current,Fe=Oe.at===0,ze=te?Math.abs(te.scrollTop):Oe.fromTail,ft=te?te.scrollHeight:Oe.extent,ae=Oe.clamped&&ft>Oe.extent?ft-Oe.extent:0,fe=Fe?0:ze-Oe.fromTail-ae;P.current={fromTail:ze,at:ie,extent:ft,clamped:je,revision:Oe.revision},p.current=D5t(p.current,{direction:L,continuous:Z,deliberate:ne,atHardTop:je,at:ie,travelledPx:Math.max(0,fe)}),P.current={...P.current,revision:P.current.revision+1},ne&&M(),ne||(b.current.sample=null,b.current.until=0),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(Y,Sh),G()},[e,M,C,Y,G]),ee=y.useCallback(()=>{A("up",!1,!0)},[A]);y.useEffect(()=>{p.current=eB(),m.current+=1,b.current={sample:null,until:0,inputRevision:P.current.revision},P.current={fromTail:0,at:0,extent:0,clamped:!1,revision:P.current.revision+1},$(!1),w(!1),p.current={...p.current,continuation:!0},G()},[t]),y.useEffect(()=>{c&&w(!1)},[c]),y.useEffect(()=>{const L=e.current;if(!L)return;let Z=0,ne=Math.abs(L.scrollTop);const te=ze=>{ze.deltaY!==0&&A(ze.deltaY<0?"up":"down",!0)},ie=()=>{const ze=Math.abs(L.scrollTop);ze!==ne&&(A(ze>ne?"up":"down",!0),ne=ze)},$e=ze=>{if(!ze.defaultPrevented)switch(ze.key){case"Home":A("up",!1,!0);break;case"ArrowUp":case"PageUp":A("up",!1);break;case"ArrowDown":case"PageDown":case"End":A("down",!1);break}},je=()=>{Z=Number.POSITIVE_INFINITY},Oe=()=>{Z===Number.POSITIVE_INFINITY&&(Z=performance.now()+v2t)},Fe=()=>{const ze=Math.abs(L.scrollTop),ft=ze-ne;if(ne=ze,S.current!==null){const ae=Math.abs(L.scrollTop-S.current)<=1;if(S.current=null,ae)return}if(E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(Y,Sh),ft!==0&&performance.now()<=Z){A(ft>0?"up":"down",!0);return}G()};return L.addEventListener("wheel",te,{passive:!0}),L.addEventListener("touchmove",ie,{passive:!0}),L.addEventListener("keydown",$e),L.addEventListener("scroll",Fe,{passive:!0}),L.addEventListener("pointerdown",je),window.addEventListener("pointerup",Oe),()=>{L.removeEventListener("wheel",te),L.removeEventListener("touchmove",ie),L.removeEventListener("keydown",$e),L.removeEventListener("scroll",Fe),L.removeEventListener("pointerdown",je),window.removeEventListener("pointerup",Oe),R.current&&cancelAnimationFrame(R.current),R.current=0,_.current&&clearTimeout(_.current),_.current=0,E.current&&clearTimeout(E.current),E.current=0}},[e,A,Y,G]),y.useEffect(()=>{const L=e.current,Z=L?.querySelector("[data-lo-transcript-content]");if(!L||!Z)return;const ne=new ResizeObserver(()=>{V(),G()});return ne.observe(Z),ne.observe(L),()=>ne.disconnect()},[e,V,G,O]),y.useEffect(()=>{G()},[G,n,r]),y.useLayoutEffect(()=>{V()});const K=u||g?"loading":c&&!v?"failed":n>0?"windowed":r?"idle":i?"exhausted":a?"loading":"unproven",z=y.useCallback(()=>performance.now()-p.current.lastInputAt<Sh?!1:C()?.followingTail===!0,[C]),le=y.useCallback(()=>C()?.followingTail===!0,[C]);return{slotState:K,requestOlder:ee,mayAutoWalk:z,followingTail:le,acknowledgeOwnWrite:Q}}function w2t(){const e=ga(),t=gi(e.data,"settings"),n=Yt({queryKey:RA.all,queryFn:()=>Xe({op:"settings.list"}),enabled:t,staleTime:1e4});return t?NTt(n.data?.settings):!1}const gB=60,$B=60,g2=300;function S2t(e){const t=[];e.facts.durationS!==null&&t.push(`took ${uf(e.facts.durationS)}`),e.facts.actions>0&&t.push(e.facts.actions===1?"1 action":`${e.facts.actions} actions`);const n=e.label??"Turn condensed";return t.length===0?`${n}.`:`${n}: ${t.join(", ")}.`}function x2t(e){const t=new Set;for(const n of e)for(const r of n.recordIds)t.add(r);return t}const Q2t=y.memo(function({record:t,isSmallView:n,scope:r,conversationId:i,undelivered:a=null}){const o=y.useRef(null),s=Hbe(o),{replies:l,remainingContent:c}=y.useMemo(()=>$A(t.text),[t.text]),[u,O]=y.useState(!1),[d,f]=y.useState(!1),p=y.useRef(null);return y.useLayoutEffect(()=>{if(u)return;const m=p.current;m&&f(m.scrollHeight>m.clientHeight+1)},[u,c]),h.jsx(qs,{isUser:!0,isSmallView:n,children:h.jsxs("div",{className:j("group flex w-full flex-col items-end gap-1"),children:[h.jsxs("div",{ref:o,className:"group relative flex w-full justify-end",children:[h.jsx("div",{className:j("relative rounded-frame bg-message-surface text-ink break-words",a!==null&&"border-l border-danger",n?"max-w-[92%] px-3 py-2.5":"max-w-[85%] px-3 py-2.5"),children:h.jsxs("div",{ref:p,className:j("relative",!u&&d?"max-h-[174px] overflow-hidden":""),children:[l.length>0&&h.jsx(mA,{replies:l}),h.jsx(kk,{content:c,credentialCitations:!0}),d&&h.jsx("button",{type:"button",onClick:()=>O(m=>!m),"aria-expanded":u,className:j("mt-1 h-[30px] w-full text-center text-ink-muted text-meta","hover:text-ink"),children:u?"Show less":"Show more"}),t.images.length>0&&h.jsx("div",{className:j("mt-2 flex flex-col gap-2"),children:t.images.map((m,g)=>h.jsx(yA,{image:m,scope:r,label:t.images.length===1?"Attached image":`Attached image ${g+1}`},m.id))})]})}),i&&Lj(t,c)&&!s.quoteAvailable&&h.jsx(r1e,{conversationId:i,turnRef:o}),i&&s.subject&&h.jsx(Jbe,{conversationId:i,turnRef:o,subject:s.subject,quoteAvailable:s.quoteAvailable,onDismiss:s.dismiss})]}),Lj(t,c)&&h.jsx(t1e,{kind:"user",bodyText:c,revealId:t.id,revealAt:t.ts,conversationId:i,entryId:e1e(t)??void 0}),a!==null&&h.jsxs("div",{"data-undelivered":!0,className:j("flex w-full items-center justify-end gap-3 text-danger text-meta"),children:[h.jsxs("span",{className:j("flex items-center gap-1"),children:[h.jsx(Mh,{"aria-hidden":"true",className:j("size-3.5 shrink-0")}),a.message??"Not delivered"]}),a.retry!==!1&&h.jsx("button",{type:"button","aria-disabled":a.retryDisabled||void 0,className:j(a.retryDisabled?"text-ink-muted":"cursor-pointer underline"),onClick:m=>{if(a.retryDisabled){m.preventDefault();return}a.onSendAgain()},children:"Send again"}),h.jsx("button",{type:"button",className:j("cursor-pointer underline"),onClick:a.onEdit,children:"Edit"})]})]})})}),k2t=y.memo(function({record:t,isSmallView:n,closesTurn:r,answerRail:i,foot:a=null,closingLineSuppressed:o=!1,conversationId:s}){const l=y.useRef(null),c=Hbe(l),{replies:u,remainingContent:O}=y.useMemo(()=>$A(t.text),[t.text]);if(!Fu(t))return null;const d=t.stopReason==="refusal"||t.error,f=Lj(t,O);return h.jsxs(qs,{isUser:!1,isSmallView:n,children:[h.jsxs("div",{ref:l,className:j("relative break-words text-ink",ZTt(r,i)),"data-turn-answer":r||void 0,"aria-busy":t.streaming||void 0,"data-lo-streaming":t.streaming||void 0,"data-lo-truncated":t.truncated||void 0,children:[u.length>0&&h.jsx(mA,{replies:u}),t.truncated&&h.jsx("p",{className:j("mb-1 text-ink-dim text-meta"),children:t.truncated==="prefix"?"Earlier text of this answer is not on screen":"Part of this answer may be missing"}),t.streaming?h.jsx(Pbe,{content:O,className:j(d&&"[--md-ink:var(--lo-danger)]"),styleProps:{fontSize:n?"var(--text-body-sm)":"var(--text-body)",lineHeight:1.6}}):h.jsx(kk,{content:O,className:j(d&&"[--md-ink:var(--lo-danger)]"),styleProps:{fontSize:n?"var(--text-body-sm)":"var(--text-body)",lineHeight:1.6},linkify:!0}),t.stopReason==="aborted"&&h.jsx("p",{className:"mt-1 text-ink-dim text-meta",children:"Stopped before finishing"}),s&&f&&!c.quoteAvailable&&h.jsx(r1e,{conversationId:s,turnRef:l}),s&&c.subject&&h.jsx(Jbe,{conversationId:s,turnRef:l,subject:c.subject,quoteAvailable:c.quoteAvailable,onDismiss:c.dismiss})]}),r&&h.jsxs("div",{className:j("mt-1 flex items-center gap-2 text-meta"),children:[!o&&a&&a.actions>0&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:j("text-ink-dim"),children:a.durationS!==null?`Worked for ${uf(a.durationS)}`:"Worked"}),h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim"),children:"·"}),h.jsx("span",{className:j("text-ink-dim"),children:a.actions===1?"1 action":`${a.actions} actions`})]}),f&&h.jsx("span",{className:j("ml-auto flex shrink-0"),children:h.jsx(t1e,{bodyText:O,agentId:s,speechId:t.id,revealId:t.id,revealAt:t.ts,conversationId:s,entryId:e1e(t)??void 0})}),!o&&h.jsx("span",{className:j(!f&&"ml-auto"),children:h.jsx(_be,{timestamp:t.ts,scope:"answer"})})]})]})});function _1e(e){const t=e.phase==="composing",n=e.phase==="queued";return e.neverSent===!0||!!e.notRunReason?`never sent · ${e.argumentBytes?`${VP(e.argumentBytes)} composed`:"nothing composed"}`:t?`composing${e.argumentBytes?` · ${VP(e.argumentBytes)}`:""}`:n?`queued${e.argumentBytes?` · ${VP(e.argumentBytes)}`:""}`:v2e(e.toolName,e.args)}function P2t({state:e}){const t=h2e[e];return t?h.jsx("span",{"data-delivery-note":e,children:t}):null}const T2t=y.memo(function({record:t,isSmallView:n,scope:r,labelPending:i=!1,labelHoldLate:a=!1,labelMarked:o=!1}){const s=t.phase!=="done",l=t.phase==="composing",c=!!t.notRunReason,u=c&&B0(t.notRunKind),O=m2e(t.delivery)==="partial",d=_1e(t),f=!l&&fae(d,t.toolName)?S2e(t.output,i):null,p=c?h.jsxs("div",{className:j("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),"data-detail-section":"not-run",children:[h.jsx("span",{className:j("mb-1 block text-meta",u?"text-ink-dim":"text-danger"),children:u?"Interrupted":"Not run"}),h.jsx("div",{className:j(skt,"overflow-auto"),children:h.jsx("pre",{className:j("whitespace-pre font-mono",u?"text-ink":"text-danger"),children:t.notRunReason})})]}):X2e(t)?h.jsx(MQt,{diff:t.diff}):ikt(t.args,t.output)?h.jsx(ckt,{args:t.args,output:t.output,isError:CE(t.isError,t.delivery),interrupted:t.stopped===!0,note:t.delivery?h.jsx(P2t,{state:t.delivery}):void 0}):void 0,m=p?h.jsx(h.Fragment,{children:p}):void 0,g=t.images.length>0?h.jsx("div",{className:j("mt-1 ml-5 flex flex-col gap-2"),children:t.images.map(($,v)=>h.jsx(yA,{image:$,scope:r,label:t.images.length===1?"Image":`Image ${v+1}`},$.id))}):void 0;return h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:t.toolName,op:D7(t.args),summary:d,summaryFallback:f,summaryHold:o===!0||i===!0&&a===!0,outcome:c?B0(t.notRunKind)?"interrupted":"not-run":s?"running":O?"partial":t.isError?"error":t.stopped?"interrupted":"success",deliveryState:t.delivery,durationS:t.durationS,startedAt:t.startedAt,added:t.added,removed:t.removed,details:m,media:g})})}),yB=({action:e})=>h.jsx("div",{className:"mt-1 pl-6",children:h.jsx(Ve,{variant:"secondary",size:"sm",asChild:!0,children:h.jsx(lqe,{to:e.to,children:e.label})})}),_2t=y.memo(function({record:t,isSmallView:n}){if(t.kind==="custom"){const l=t.level==="error"?Mh:_je,c=FF({text:t.text,category:t.category,provider:t.provider});return h.jsxs(qs,{isUser:!1,isSmallView:n,children:[h.jsx(xF,{dense:!0,verbOverride:t.category??t.customType.replace(/_/g," "),object:t.provider??void 0,narration:t.headline,failed:t.level==="error",wrap:!0,glyph:h.jsx(l,{}),details:t.detail?h.jsx("p",{className:"whitespace-pre-wrap break-words text-body-sm text-ink-muted",children:t.detail}):void 0}),c?h.jsx(yB,{action:c}):null]})}const r=t.kind==="notice"?t.level:"info",i=r==="error"?Mh:r==="warning"?Tie:U7,{headline:a,rest:o}=Z8e(t.text),s=FF({text:t.text});return h.jsxs(qs,{isUser:!1,isSmallView:n,children:[h.jsx(xF,{dense:!o,verbOverride:a,failed:r==="error",wrap:!0,glyph:h.jsx(i,{}),details:o?h.jsx("p",{className:"whitespace-pre-wrap break-words text-body-sm text-ink-muted",children:o}):void 0}),Ile.test(t.text)?h.jsx("div",{className:"mt-1 pl-6",children:h.jsx(Ve,{variant:"secondary",size:"sm",onClick:()=>mQ.getState().openConnect(),children:"Connect a provider"})}):null,s?h.jsx(yB,{action:s}):null]})}),X2t=y.memo(function({record:t,isSmallView:n}){return D_e(t.sender,t.body)?h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"peer",summary:rW(t.sender,t.body),outcome:"receipt",durationS:null,details:h.jsxs("div",{className:j("flex flex-col gap-2 px-3"),children:[h.jsx("p",{className:j("text-body-sm text-ink-muted"),children:uae(t.sender)}),t.body?h.jsx("p",{className:j("whitespace-pre-wrap break-words text-body-sm text-ink"),children:t.body}):null]})})}):h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"peer",summary:rW(t.sender,t.body),outcome:"receipt",durationS:null})})}),R2t=y.memo(function({record:t,isSmallView:n}){if(t.kind==="ask_timeout")return h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"ask",verbless:!0,summary:Ize(t),outcome:"receipt",durationS:null})});const r=Zze(t);return t.questions.length===0?h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"ask",verbless:!0,summary:r,outcome:"receipt",durationS:null})}):h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"ask",verbless:!0,summary:r,outcome:"receipt",durationS:null,details:h.jsxs("div",{className:j("flex flex-col gap-2 px-3"),children:[t.secretLost?h.jsx("p",{className:j("text-body-sm text-warning"),children:"The session no longer holds the credential this answer named."}):null,t.questions.map(i=>h.jsxs("div",{className:j("flex flex-col gap-0.5"),children:[h.jsx("p",{className:j("text-body-sm text-ink-muted"),children:i.question}),h.jsx("p",{className:j("whitespace-pre-wrap break-words text-body-sm text-ink"),children:(t.answers[i.id]??[]).length>0?(t.answers[i.id]??[]).join(", "):"No answer given"})]},i.id))]})})})}),E2t=y.memo(function({record:t,isSmallView:n}){const r=t2e(t.text);return h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"wake",summary:e2e(t.text),outcome:"receipt",durationS:null,details:r?h.jsx("p",{className:j("whitespace-pre-wrap break-words px-3 text-body-sm text-ink-dim"),children:r}):void 0})})}),vB=new WeakMap,X1e=e=>{if(e.gap==="trace")return e;let t=vB.get(e);return t||(t={...e,gap:"trace"},vB.set(e,t)),t},e1=new WeakMap,q2t=e=>{if(e.kind==="row"){const n=X1e(e.row);if(n===e.row)return e;let r=e1.get(e);return r||(r={...e,row:n},e1.set(e,r)),r}if(e.gap==="trace")return e;let t=e1.get(e);return t||(t={...e,gap:"trace"},e1.set(e,t)),t},t1=new WeakMap,j2t=e=>{if(e.kind==="row"){if(e.row.gap!=="trace")return e;let n=t1.get(e);return n||(n={...e,row:{...e.row,gap:"item"}},t1.set(e,n)),n}if(e.gap!=="trace")return e;let t=t1.get(e);return t||(t={...e,gap:"item"},t1.set(e,t)),t},bB=y.memo(function({row:t,isSmallView:n,scope:r,conversationId:i,answerRail:a=!1,foot:o=null,closingLineSuppressed:s=!1,labelPending:l=!1,undelivered:c=null,labelHoldLate:u=!1,labelMarked:O=!1}){const{record:d}=t;let f;switch(d.kind){case"user":f=h.jsx(Q2t,{record:d,isSmallView:n,scope:r,conversationId:i,undelivered:c?.recordId===d.id?c:null});break;case"assistant":f=h.jsx(k2t,{record:d,isSmallView:n,closesTurn:t.closesTurn,answerRail:a,foot:o,closingLineSuppressed:s,conversationId:i});break;case"tool":f=h.jsx(T2t,{record:d,isSmallView:n,scope:r,labelPending:l,labelHoldLate:u,labelMarked:O});break;case"peer":f=h.jsx(X2t,{record:d,isSmallView:n});break;case"ask_response":case"ask_timeout":f=h.jsx(R2t,{record:d,isSmallView:n});break;case"wake":f=h.jsx(E2t,{record:d,isSmallView:n});break;default:f=h.jsx(_2t,{record:d,isSmallView:n})}return f===null?null:h.jsx("div",{"data-record-id":d.id,"data-record-kind":d.kind,"data-completion-anchor":d.id,"data-completion-complete":"complete"in d&&d.complete===!0&&(d.kind!=="assistant"||!d.streaming&&d.text)?"true":void 0,className:j(_1[t.gap][n?1:0]),children:f})}),C2t=6e4,z2t="Could not reach that turn. It is further back than the loaded history — scroll up in the transcript to load more.",ken=({frontend:e,transcript:t,gate:n,waiting:r,starting:i,startingAfterId:a,startingSession:o,startingSince:s,stopping:l,idleDisputed:c,workingLine:u,loadingOlder:O,onLoadOlder:d,onLoadOlderOutcome:f,olderFailed:p,onRetryHydration:m,olderTransportDown:g,containerRef:$,isSmallView:v,status:w,failure:x,awaitingHydration:b,hydrationProven:S=!0,historyReadPending:Q=!1,stale:P=!1,missing:R=!1,attachmentScope:_,conversationId:E,labelPending:C,undelivered:W=null,labelHoldLate:U,labelMarked:Y,measureHandle:V=!1,onReconnect:M})=>{const B=y.useRef({session:null,anchors:new Set}),G=e?.session_id??null,A=_??(G?{sessionId:G,childId:null}:null);B.current.session!==G&&(B.current={session:G,anchors:new Set});const ee=y.useMemo(()=>IXe(t,e?.attention,!!e?.streaming,B.current.anchors),[t,e?.attention,e?.streaming]),K=$2t(),z=w2t(),le=y.useMemo(()=>wPt(ee.records,K),[ee.records,K]);dWe(e,w==="live"&&!r,$);const L=f_t(G??""),Z=y.useRef([]),ne=y.useMemo(()=>{const me=D8e(le,Z.current);return Z.current=me,me},[le]),te=y.useRef(ne);te.current=ne;const[ie,$e]=y.useState(G),[je,Oe]=y.useState(gB),Fe=y.useRef(oB()),ze=y.useRef(null);ie!==G&&($e(G),Oe(gB),Fe.current=oB(),ze.current=null);const ft=y.useRef(G);G!==null&&(ft.current=G);const[ae,fe]=y.useState(()=>({session:ft.current,entries:[]}));ae.session!==ft.current&&fe({session:ft.current,entries:[]});const Te=(me,Se)=>{const cn=new Set(t.records.map(Et=>Et.id));fe(Et=>({session:ft.current,entries:_Pt(Et.session===ft.current?Et.entries:[],me,Se,cn)}))},_e=y.useRef({live:!1,openRuns:void 0,mode:Qie,mounted:0}),[ut,St]=y.useState(()=>xW(G)),[bt,he]=y.useState(G);bt!==G&&(he(G),St(xW(G)));const Re=y.useCallback((me,Se)=>{St(pRe(G,me,Se))},[G]),Ue=y.useRef(null),oe=y.useCallback(me=>{const Se=$.current?.querySelectorAll("[data-turn-summary]");for(const cn of Se??[])if(cn.getAttribute("data-record-id")===me)return cn;return null},[$]),pe=y.useCallback((me,Se,cn)=>{const Et=oe(Se);Et&&(Ue.current={id:Se,top:Et.getBoundingClientRect().top}),Re(me,cn)},[oe,Re]),Ge=ne.length,ot=y.useMemo(()=>_le(tUe({waiting:r,compacting:t.compacting,compactingSince:t.compactingSince,foldedPhase:e?.activity_phase,foldedPhaseStartedAt:e?.activity_phase_started_at,starting:i,startingAfterId:a,startingSession:o,startingSince:s,stopping:l===!0,idleDisputed:c===!0,gate:n,unavailable:UTt({status:w,failure:x,missing:R,stale:P}),records:le})),[r,t.compacting,t.compactingSince,e?.activity_phase,e?.activity_phase_started_at,i,a,o,s,l,c,n,w,x,R,P,le]),et=(u===void 0?ot:u)!==null||n!==null,ve=y.useMemo(()=>p1e(ne,je),[ne,je]),st=y.useMemo(()=>PA(ne,je,g2,m2,et,ve),[ne,je,et,ve]),wt=y.useMemo(()=>Ge>st?ne.slice(Ge-st):ne,[ne,Ge,st]),Lt=Ge-wt.length,bn=y.useMemo(()=>BTt(wt),[wt]),{activeId:en,loadedIds:Dn}=c_t($,ne,L.checkpoints),Rn=y.useMemo(()=>o1e(d),[d]),rr=y.useMemo(()=>Xkt(wt,{nameOf:Se=>Ple(Se.record),failedOf:Se=>Se.record.kind==="tool"&&CE(Se.record.isError,Se.record.delivery),durationOf:Vj,summaryOf:Se=>Se.record.kind==="tool"?_1e(Se.record):"",opOf:Se=>Se.record.kind==="tool"?D7(Se.record.args):"",runningOf:Se=>Se.record.kind==="tool"&&Se.record.phase!=="done",executingOf:Se=>Se.record.kind==="tool"&&Se.record.phase==="running",startedAtOf:Se=>Se.record.kind==="tool"?Se.record.startedAt:null,endedAtOf:Se=>Se.record.kind==="tool"?Se.record.endedAt:null,isFoldable:Se=>Se.record.kind==="tool"}).map(Se=>Se.kind==="run"?{...Se,images:EF(Se.rows)}:Se),[wt]),Ei=y.useMemo(()=>{const me=new Set(U6(wt).map(Se=>wt[Se.openingIndex].record.id));return jkt(wt,{failedOf:Se=>Se.record.kind==="tool"&&CE(Se.record.isError,Se.record.delivery),durationOf:Vj,isAction:Se=>Se.record.kind==="tool",opensRun:Se=>me.has(Se.record.id)})},[bn]),vi={status:w,failure:x,awaitingHydration:b,recordCount:t.records.length,admittedSend:i,missing:R,stale:P},xe=f1e(vi),ye=WTt(vi),ke=y.useRef(null);y.useLayoutEffect(()=>{if(wt.length===0)return;const me=G??"";if(ke.current===me)return;ke.current=me,performance.mark("lop:open:first-row");const Se=performance.getEntriesByName("lop:open:requested","mark").at(-1);Se&&performance.now()-Se.startTime<=C2t&&performance.measure("lop:open:to-first-row","lop:open:requested","lop:open:first-row"),performance.clearMarks("lop:open:requested")},[wt.length,G]);const ht=y.useCallback(()=>{Oe(()=>Math.min(Ge,n_t(te.current,_e.current.mounted,{step:$B,live:_e.current.live,openRuns:_e.current.openRuns,mode:_e.current.mode,snapMaxExtra:g2,completedRunMaxExtra:m2,maxRows:Math.min(Ge,_e.current.mounted+t_t*$B)})))},[Ge]),Ft=y.useCallback(()=>m1e(te.current,_e.current.mounted,{live:_e.current.live,openRuns:_e.current.openRuns,mode:_e.current.mode,snapMaxExtra:g2,completedRunMaxExtra:m2}),[]),{slotState:it,requestOlder:Gr,mayAutoWalk:Je,followingTail:rn,acknowledgeOwnWrite:ea}=b2t({containerRef:$,sessionKey:G,hiddenRows:Lt,hasMore:!!t.hasMore,hydrationProven:S,historyReadPending:Q,onWiden:ht,paintedRows:Ft,onLoadOlder:d,onLoadOlderOutcome:f,olderFailed:p,loadingOlder:O,contentKey:ye?"empty":"filled",rowCount:wt.length});y.useLayoutEffect(()=>{const me=Ue.current;if(me===null)return;Ue.current=null;const Se=$.current,cn=oe(me.id);if(!Se||!cn)return;const Et=cn.getBoundingClientRect().top-me.top;if(Math.abs(Et)<1)return;const ir=Se.scrollTop;Se.scrollTop+=Et,ea(ir,Se.scrollTop)});const zt=y.useCallback(async(me,Se)=>{const cn=$.current,Et=cn?.querySelector("[data-lo-transcript-content]")??null;if(!cn||!Et)return;if(!await E5t({isReachable:()=>QPt(Et,me),rowDistance:()=>{const we=te.current.findIndex(En=>En.record.id===me);return we===-1?null:te.current.length-we},mount:we=>{Oe(En=>En>=we?En:we)},loadOlder:Rn})){Jh(Se);return}await s1e(Et,cn,me)==="missing"&&Jh(Se)},[$,Rn]),hr=y.useCallback(me=>void zt(me,z2t),[zt]),os=y.useCallback(me=>zt(me,pTt),[zt]),br=y.useCallback(me=>{me&&L.warm([me])},[L.warm]),au=y.useRef(0),[Zt,Nr]=y.useState(""),qr=Bn(me=>me.chatMeasureWidth),Ya=Bn(me=>me.setChatMeasureWidth),Ef=Bn(me=>me.restoreDefaultChatMeasureWidth),km=Bn(me=>me.transcriptDisplayMode),qf=y.useMemo(()=>xPe(),[]),Tr=qr??qf;y.useLayoutEffect(()=>{au.current+=1,performance.mark("lop:transcript:render",{detail:{rows:wt.length,commit:au.current}})}),y.useEffect(()=>{},[wt.length]);const ss=u===void 0?ot:u;_e.current={live:et,openRuns:ut,mode:SU(km),mounted:st};const[dv,Pm]=y.useState(null),ou=y.useCallback(me=>{const Se=me.target.closest("[data-record-id]");Pm(Se===null||Se.closest("[data-turn-summary]")!==null?null:Se.getAttribute("data-record-id"))},[]),Tm=y.useCallback(me=>{const Se=me.relatedTarget;(Se===null||!me.currentTarget.contains(Se))&&Pm(null)},[]),Gl=y.useRef(null),ya=y.useRef(Number.NEGATIVE_INFINITY),ls=y.useCallback(()=>{const me=window.getSelection(),Se=$.current;if(!me||me.isCollapsed||!Se)return!1;const cn=me.anchorNode??me.focusNode;return cn!==null&&Se.contains(cn)},[$]),_m=y.useCallback(me=>{if(me.button!==0){Gl.current=null;return}Gl.current={x:me.clientX,y:me.clientY,hadSelection:ls(),onControl:rB(me.target)}},[ls]),su=y.useCallback(()=>{ya.current=performance.now()},[]),jf=y.useCallback(me=>{const Se=Gl.current;if(Gl.current=null,me.defaultPrevented)return;ATt({controlPress:rB(me.target)||Se?.onControl===!0,modalOpen:CTt(document),pressHadSelection:Se?.hadSelection===!0,selectionNotCollapsed:ls(),shiftExtends:me.shiftKey,dragged:Se!==null&&Math.hypot(me.clientX-Se.x,me.clientY-Se.y)>qTt,scrolledRecently:zTt(ya.current,performance.now())})==="focus"&&Xse()},[ls]),Xm=y.useMemo(()=>({live:ss!==null||n!==null,focusHold:dv,openRuns:ut,mode:SU(km)}),[dv,n,ut,km,ss]),yP=y.useMemo(()=>KTt(bn,Xm),[Xm,bn]),cs=y.useMemo(()=>h1e(wt,Xm),[yP]),Rm=y.useMemo(()=>e_t(cs,ve,ut),[cs,ve,ut]),[Ga,Em]=y.useState(0);y.useEffect(()=>{const me=i_t(Fe.current,Rm),Se=Je(),cn=r_t(me.spent,{hasMore:!!t.hasMore,loadingOlder:O,headCut:me.key!==null,mayWalk:Se,halted:me.halted});if(Fe.current={...me,spent:cn.spent},!cn.fetch){if(!(me.key!==null&&!!t.hasMore&&!O&&!me.halted&&!Se&&rn()&&Fe.current.spent<g1e))return;const va=window.setTimeout(()=>Em(we=>we+1),Sh);return()=>window.clearTimeout(va)}const Et=me.key;Rn().then(ir=>{!ir&&Fe.current.key===Et&&(Fe.current={...Fe.current,halted:!0})})},[Rm,O,t.hasMore,Rn,Je,rn,Ga]);const[fv,qm]=y.useState("");y.useEffect(()=>{const me=cs.runs.flatMap(ir=>ir.segments.filter(va=>va.collapsed)),Se=x2t(cs.runs),cn=ze.current;if(cn===null){cs.runs.length>0&&(ze.current={keys:new Set(me.map(ir=>ir.key)),rowIds:Se});return}const Et=me.filter(ir=>!cn.keys.has(ir.key)&&ir.segmentIds.some(va=>cn.rowIds.has(va)));ze.current={keys:new Set([...cn.keys,...me.map(ir=>ir.key)]),rowIds:Se},Et.length!==0&&qm(Et.map(S2t).join(" "))},[cs]);const Cf=y.useMemo(()=>{const me=new Map;wt.forEach((Et,ir)=>me.set(Et.record.id,ir));const Se=[];let cn=0;for(const Et of cs.runs){const ir=[];for(;cn<rr.length;){const Zr=rr[cn],Un=me.get(Zr.kind==="run"?Zr.id:Zr.row.record.id);if(Un===void 0||Un>Et.run.endIndex)break;ir.push(Zr),cn+=1}if(!Et.collapses){for(const Zr of ir)Se.push({kind:"group",group:Zr,suppressClosingLine:!1});continue}const va=new Map;Et.segments.forEach((Zr,Un)=>{for(const lu of Zr.segmentIds)va.set(lu,Un)});const we=Et.segments.some(Zr=>Zr.collapsed&&Zr.stampTs!==null),En=new Map;let jm=!1;for(const Zr of ir){const Un=Zr.kind==="run"?Zr.rows:[Zr.row],lu=va.get(Un[0].record.id),cu=Un.every(Ln=>va.get(Ln.record.id)===lu)?lu:void 0,Nl=cu===void 0?null:Et.segments[cu];if(Nl!==null&&cu!==void 0&&Nl.collapsed){let Ln=En.get(cu);Ln===void 0&&(Ln=[],En.set(cu,Ln),Se.push({kind:"bar",segment:Nl,runIds:Et.recordIds,children:Ln,images:EF(Nl.rows)}),jm=!0),Ln.push(Zr);continue}Se.push({kind:"group",group:Zr,suppressClosingLine:we&&Nl===null,afterBar:jm})}}return Se},[wt,rr,cs]),RO=(me,Se,cn=!1)=>me.kind==="run"?h.jsx(Ukt,{className:_1[me.gap][v?1:0],recordIds:me.rows.map(Et=>Et.record.id),summary:me.summary,actionCount:me.rows.length,span:me.span,live:me.live,open:TPt(ae.entries,me.rows.map(Et=>Et.record.id)),onOpenChange:Et=>Te(me.rows.map(ir=>ir.record.id),Et),condensedMedia:me.images.length>0?Et=>h.jsx(UF,{images:me.images,scope:A,onRevealMore:Et,uncapped:cn}):void 0,mediaCount:cn?0:me.images.length,children:me.rows.map((Et,ir)=>h.jsx(bB,{row:ir===0?X1e(Et):Et,isSmallView:v,scope:A,conversationId:E,labelPending:Et.record.kind==="tool"&&C?.has(Et.record.toolCallId)===!0,labelHoldLate:U===!0,labelMarked:Et.record.kind==="tool"&&Y?.has(Et.record.toolCallId)===!0,foot:Se?null:Ei.get(Et.record.id)??null,closingLineSuppressed:Se,undelivered:W,answerRail:z},Et.record.id))},me.id):h.jsx(bB,{row:me.row,isSmallView:v,scope:A,conversationId:E,labelPending:me.row.record.kind==="tool"&&C?.has(me.row.record.toolCallId)===!0,labelHoldLate:U===!0,labelMarked:me.row.record.kind==="tool"&&Y?.has(me.row.record.toolCallId)===!0,foot:Se?null:Ei.get(me.row.record.id)??null,closingLineSuppressed:Se,undelivered:W,answerRail:z},me.row.record.id);return h.jsxs("div",{className:j(kie,ye?"relative h-0 grow-0 overflow-hidden":"relative flex min-h-0 grow flex-col"),children:[P&&!xe&&h.jsx("p",{className:j("shrink-0 px-4 pt-4 text-ink-dim text-meta",Ai),children:"Showing the last saved view — checking for newer messages."}),h.jsxs("div",{className:j("relative flex min-h-0 grow flex-col"),children:[h.jsx(bPt,{sessionId:G??"",checkpoints:L.checkpoints,building:L.building,loadedIds:Dn,activeId:en,onJump:hr,onHover:br}),h.jsxs("div",{ref:$,"data-lo-canonical-transcript":!0,"data-chat-region":"transcript","data-region-entry":!0,tabIndex:t.records.length===0||xe?-1:0,role:"log","aria-label":nse.transcript,"aria-describedby":it==="windowed"?n1e:void 0,onFocus:ou,onBlur:Tm,onPointerDown:_m,onWheel:su,onClick:jf,className:j("relative flex w-full flex-col-reverse [scrollbar-gutter:stable_both-edges] will-change-[scroll-position] [overflow-anchor:auto] [transform:translateZ(0)]",ye?"h-0 grow-0 overflow-hidden p-0":"min-h-0 grow overflow-auto p-4"),children:[Zt&&h.jsx("span",{"data-lo-perf":!0,className:"sr-only","aria-hidden":"true",children:Zt}),h.jsx("output",{"data-condense-announcement":"",className:"sr-only","aria-live":"polite",children:fv}),h.jsxs("div",{"data-lo-transcript-content":!0,className:j("mb-auto relative flex flex-col",Ai),children:[V&&Tr!==null&&h.jsxs(h.Fragment,{children:[h.jsx(bG,{edge:"left",width:Tr,onWidthChange:Ya,onReset:Ef,label:"Widen or narrow the conversation column (left edge). Arrow keys adjust the width; Home and End go to the limits; Enter restores the default."}),h.jsx(bG,{edge:"right",width:Tr,onWidthChange:Ya,onReset:Ef,label:"Widen or narrow the conversation column (right edge). Arrow keys adjust the width; Home and End go to the limits; Enter restores the default."})]}),xe&&h.jsx(YTt,{isSmallView:v}),t.records.length>0&&!P&&!R&&h.jsx($5t,{state:it,transportDown:g??w!=="live",onLoadOlder:Gr,onRetryHydration:m}),R?h.jsxs("div",{className:"mb-4 flex flex-col gap-2",children:[h.jsx("p",{id:Abe,className:"text-body-sm text-ink",children:"This conversation is no longer on this machine."}),h.jsx("p",{className:"text-ink-dim text-meta",children:"It was deleted, or it belongs to a machine this app is not connected to."}),h.jsx(Ve,{variant:"outline",size:"sm",className:"self-start",onClick:()=>{sr.getState().setActiveSession(null)},children:"Start a new chat"})]}):null,w==="unavailable"&&x&&h.jsxs("div",{"data-lo-session-failure":!0,className:"mb-1 flex flex-wrap items-center gap-3",children:[h.jsx("p",{className:"text-body-sm text-danger",children:x.statement}),x.action==="reconnect"&&h.jsx(Ve,{variant:"outline",size:"sm",onClick:M,children:"Reconnect"})]}),w==="reconnecting"&&h.jsx("p",{className:"mb-4 text-body-sm text-ink-dim",children:"Reconnecting"}),!R&&!xe&&h.jsx(OSt,{conversationId:E,children:Cf.map(me=>me.kind==="bar"?h.jsx(Ykt,{recordIds:me.runIds,segmentIds:me.segment.segmentIds,anchorRecordId:me.segment.firstId,className:_1[me.segment.gap][v?1:0],durationS:me.segment.facts.durationS,actionCount:me.segment.facts.actions,partial:me.segment.facts.partial,title:me.segment.facts.title,stampTs:me.segment.stampTs,label:me.segment.label,completed:me.segment.completed,open:ut.has(me.segment.key),onOpenChange:Se=>pe(me.segment.key,me.segment.firstId,Se),condensedMedia:me.images.length>0?Se=>h.jsx(UF,{images:me.images,scope:A,onRevealMore:Se,indent:"flush"}):void 0,mediaCount:me.images.length,children:me.children.map((Se,cn)=>RO(cn===0?q2t(Se):Se,!0,Se.kind==="run"&&me.images.length>0&&Se.images.length===me.images.length))},`turn-summary:${me.segment.key}`):RO(me.afterBar?j2t(me.group):me.group,me.suppressClosingLine))}),t.records.length>0&&!P&&!R&&h.jsx("div",{"data-lo-transcript-foot":!0,className:j(_1.item[v?1:0],"min-h-[1lh] font-mono text-mono-sm"),children:ss&&h.jsx(Zkt,{activity:ss.activity,phase:ss.phase,startedAt:ss.startedAt,clock:ss.clock})})]})]})]}),G!==null&&h.jsx(XTt,{sessionId:G,containerRef:$,onReveal:os})]})},A2t=({visible:e,onClick:t,className:n,hasNewActivity:r=!1})=>{const i=y.useCallback(()=>{t()},[t]);return h.jsx("div",{"data-lo-scroll-to-bottom":"",className:j("pointer-events-none absolute right-3 bottom-full z-40 mb-3 flex items-center justify-end","transition-opacity duration-base ease-out-quart",e?"opacity-100":"opacity-0",n),"aria-hidden":!e,children:h.jsxs(Ve,{variant:"secondary",size:r?"sm":"icon",className:j("rounded-full shadow-overlay",e?"pointer-events-auto":"pointer-events-none"),"aria-label":r?"New activity, scroll to bottom":"Scroll to bottom",onClick:i,tabIndex:e?0:-1,children:[h.jsx(mqe,{"aria-hidden":"true"}),r?"New activity":null]})})},U2t={running:yje,queued:sQ,paused:Xqe,interrupted:v6,done:Lc,cancelled:p6,gone:Qqe,unknown:oQ,failed:Ri},W2t={running:"text-ink-muted",queued:"text-ink-dim",paused:"text-ink-muted",interrupted:"text-ink-muted",done:"text-ink-dim",cancelled:"text-ink-dim",gone:"text-ink-dim",unknown:"text-ink-dim",failed:"text-danger"},Bj=({status:e})=>{const t=U2t[e];return h.jsx("span",{"aria-hidden":!0,className:j("flex size-4 shrink-0 items-center justify-center",W2t[e]),children:h.jsx(t,{className:j("size-4",e==="running"&&"motion-safe:animate-spin")})})},Pen=({row:e})=>e.errorLine?h.jsx("span",{className:j("line-clamp-2 font-mono text-ink-muted text-mono-sm leading-4"),title:e.errorLine,children:e.errorLine}):e.activity?h.jsx("span",{className:j("truncate text-ink-muted text-meta leading-4"),title:e.activity,children:e.activity}):null,Ten=({row:e,detail:t=null,trailing:n=null})=>h.jsxs(h.Fragment,{children:[h.jsx("span",{className:j("pt-0.5"),children:h.jsx(Bj,{status:e.status})}),h.jsxs("div",{className:j("flex min-w-0 flex-1 flex-col"),children:[h.jsxs("div",{className:j("flex items-baseline gap-2"),children:[h.jsx("span",{className:j("min-w-0 flex-1 truncate text-body-sm text-ink leading-5"),title:e.label,children:e.label}),h.jsx("span",{className:j("sr-only"),children:pze(e)}),h.jsx(Y2t,{row:e}),n]}),t]})]}),Y2t=({row:e,includeModel:t=!1})=>{const n=[];return e.role&&n.push({key:"role",text:e.role}),e.elapsedLabel&&n.push({key:"elapsed",text:e.elapsedLabel,tabular:!0}),e.contextLabel&&n.push({key:"context",text:e.contextLabel,tabular:!0}),e.costLabel&&n.push({key:"cost",text:e.costLabel,tabular:!0}),t&&e.modelLabel&&n.push({key:"model",text:e.modelLabel}),n.length===0?null:h.jsx("span",{className:j("flex min-w-0 shrink-0 items-baseline gap-1 text-meta text-ink-muted"),children:n.map((r,i)=>h.jsxs("span",{className:j("flex items-baseline gap-1"),children:[i>0&&h.jsx("span",{className:j("text-ink-dim"),children:"·"}),h.jsx("span",{className:j(r.tabular&&"tabular-nums",r.key==="model"&&"max-w-32 truncate"),title:r.key==="model"?r.text:void 0,children:r.text})]},r.key))})},uc={list:e=>["desktop","mcp",e]},R1e=async e=>(await Xe({op:"mcp.list",sessionId:e})).data,E1e=async(e,t)=>(await Xe({op:"mcp.control",sessionId:e,control:{action:"probe",name:t}})).data,G2t={probe:"This server's sign-in method could not be checked",grant:"The sign-in could not be started",reconnect:"The server could not be reconnected",reload:"This server's configuration could not be re-read",add:"The server could not be added",key:"The keys were not saved",cancel:"The cancellation could not be confirmed",status:"The sign-in status could not be refreshed",disconnect:"The server could not be disconnected",remove:"The server could not be removed",test:"The connection test could not be started"},N2t=[M0.noCredential,M0.transportFailed],Z2t="Session owner is unavailable.";function Hj(e,t,n){const r=G2t[e];if(t instanceof jc)return{message:t.message,detail:null,cause:"unknown",phase:e};if(!(t instanceof Nt))return{message:`${r}.`,detail:null,cause:"unknown",phase:e};const i=t.message.trim();return L0(t.code)?{message:`${r}. ${Fx[t.code]}`,detail:null,cause:"server",phase:e}:t.status===409?n?{message:`${r}: a sign-in is already running for this conversation, and only one can run at a time. Wait for it to finish, or cancel it from the server's row.`,detail:null,cause:"busy",phase:e}:{message:`${r}: the server refused it without giving a reason, and nothing was changed.`,detail:null,cause:"refused",phase:e}:t.status===503&&!L0(t.code)&&!N2t.includes(i)?{message:`${r} because this conversation's session is not running. Trying again restarts it and repeats this request.`,cause:"session",phase:e,detail:i.startsWith(Z2t)?null:i}:{message:cQ(`${r}.`,t),detail:null,cause:"server",phase:e}}const wB=e=>`/settings?section=integrations&mcp=${encodeURIComponent(e)}`,EA="Open this server in Settings",SB=()=>[{kind:"reload",label:qg.reload},{kind:"settings",label:EA}];function xB(e){if(e.cause==="server")return[];const t=[],n=e.row.remedy,r={kind:"grant",label:qg.grant};return n?.kind==="grant"&&e.phase!=="grant"&&t.push(r),n?.kind==="key"&&e.phase!=="key"&&e.keyEntryAvailable&&e.row.keyNames.length>0&&t.push({kind:"key",label:qg.key}),n?.kind==="reconnect"&&e.phase!=="reconnect"&&t.push({kind:"reconnect",label:qg.reconnect}),e.phase!=="reload"&&t.push({kind:"reload",label:qg.reload}),t.push({kind:"settings",label:EA}),t}const QB=e=>`mcp-key-${e}`,I2t=({open:e,target:t,saving:n,failure:r,onCancel:i,onOpenSettings:a,onSave:o})=>{const[s,l]=y.useState({}),[c,u]=y.useState(!1),O=t?.keyNames??[];y.useEffect(()=>{l({}),u(!1)},[e,t?.name]);const d=O.every(f=>(s[f]??"").trim().length>0);return h.jsx(t$,{open:e,onClose:i,maxWidth:"sm",title:O.length===1?`Enter the key for ${t?.name??""}`:`Enter the credentials for ${t?.name??""}`,actions:h.jsxs(h.Fragment,{children:[h.jsx(nl,{onClick:i,children:"Cancel"}),h.jsx(ph,{onClick:()=>o(s,c?[...O]:[]),disabled:!d||n,children:n?"Saving…":"Save and reconnect"})]}),children:h.jsx(QE,{asChild:!0,children:h.jsxs("div",{className:j("flex flex-col gap-3 p-1.5 text-body text-ink-muted"),children:[h.jsx("p",{children:"Saved to the encrypted secret store, then this server is reconnected. These keys may be shared by other servers and sessions."}),O.map(f=>h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx(Eie,{htmlFor:QB(f),className:"font-mono text-meta",children:f}),h.jsx(po,{id:QB(f),type:"password",autoComplete:"off",value:s[f]??"",onChange:p=>l(m=>({...m,[f]:p.target.value}))})]},f)),h.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-body-sm",children:[h.jsx("input",{type:"checkbox",checked:c,onChange:f=>u(f.target.checked)}),"Replace existing values for these shared keys."]}),r?h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:r.message}),r.detail?h.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:r.detail,children:r.detail}):null,h.jsx(Ve,{variant:"link",size:"sm",className:"self-start","data-mcp-failure-action":"settings",onClick:a,children:EA})]}):null]})})})};function D2t({row:e,action:t="login",remedy:n,onClose:r}){const[i]=y.useState(e),a=_y(),o=ga(),s=gi(o.data,"mcp_auth"),[l,c]=y.useState({kind:"probing"}),[u,O]=y.useState(0),d=n.sessionId,f=Yt({queryKey:uc.list(d??""),queryFn:()=>R1e(d??""),enabled:!!d&&l.kind==="running",refetchInterval:l.kind==="running"?1e3:!1});if(y.useEffect(()=>{if(!d||o.isLoading)return;let P=!0;return c({kind:"probing"}),n.clearFailure(i.name),E1e(d,i.name).then(R=>{if(!P)return;if(R.transport_oauth_supported===!0){c({kind:"grant"});return}const _=[...new Set((R.secret_refs??[]).map(E=>E.id))];if(_.length&&s&&R.key_submission_supported===!0){c({kind:"key",row:{...i,keyNames:_,remedy:{kind:"key"}}});return}c({kind:"notice",severity:"warning",failure:{cause:"unknown",phase:"probe",detail:null,message:s?R.transport_oauth_supported===!1?"This server does not use OAuth and declares no secret references. Add explicit ${NAME} references to its MCP environment or headers, then retry.":"Could not determine this server's sign-in method. Check its connection and MCP setup, then retry.":"Update the backend for secure MCP key entry. OAuth and the server list remain available."},actions:SB()})}).catch(R=>{if(!P)return;const _=Hj("probe",R,l3(f.data?.operations));c({kind:"notice",severity:"danger",failure:_,actions:xB({row:i,phase:"probe",cause:_.cause,keyEntryAvailable:s})})}),()=>{P=!1}},[d,i,o.isLoading,s,u]),!d)return h.jsx(t$,{open:!0,onClose:r,maxWidth:"sm",title:"Sign in to an MCP server",actions:h.jsx(nl,{onClick:r,children:"Close"}),children:h.jsx("p",{className:"p-1.5 text-body text-ink-muted",role:"alert",children:"Open a conversation to sign in to this server."})});if(l.kind==="key")return h.jsx(I2t,{open:!0,target:l.row,saving:n.pendingName===i.name,failure:n.failureFor(i.name),onCancel:r,onOpenSettings:()=>a(wB(l.row.name)),onSave:(P,R)=>{n.pressKey(l.row,P,R).then(_=>{_&&r()})}});const m=[...f.data?.operations?.filter(P=>P.name===i.name)??[]].sort((P,R)=>R.created_at-P.created_at)[0],g=l.kind==="running"&&(!m||m.status==="running"),$=m?.status==="complete",v=n.failureFor(i.name),w=f.error?Hj("status",f.error,!1):null,x=P=>{if(P.kind==="settings"){r(),a(wB(i.name));return}if(P.kind==="key"){c({kind:"key",row:{...i,remedy:{kind:"key"}}});return}if(P.kind==="reload"){n.reload(i).then(R=>{R&&O(_=>_+1)});return}if(P.kind==="reconnect"){n.press({...i,remedy:{kind:"reconnect"}});return}n.press({...i,remedy:{kind:"grant"}},t),c({kind:"running"})},b=l.kind==="notice"&&!v?l:null,S=b?.actions??[],Q=v?xB({row:i,phase:v.phase,cause:v.cause,keyEntryAvailable:s}):[];return h.jsx(t$,{open:!0,onClose:r,maxWidth:"sm",title:`Sign in to ${i.name}`,actions:h.jsxs(h.Fragment,{children:[h.jsx(nl,{onClick:r,children:"Close"}),l.kind==="grant"?h.jsx(ph,{onClick:()=>{n.press({...i,remedy:{kind:"grant"}},t),c({kind:"running"})},children:t==="reauth"?"Replace grant and sign in":"Continue in browser"}):null,l.kind==="notice"||v||l.kind==="running"&&!g&&!$?h.jsx(nl,{onClick:()=>O(P=>P+1),children:"Try again"}):null,m?.status==="running"?h.jsx(nl,{onClick:()=>n.cancel(m.id),children:"Cancel sign-in"}):null]}),children:h.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted",children:[l.kind==="probing"?h.jsx("p",{children:"Checking this server's sign-in method…"}):null,b?h.jsxs(h.Fragment,{children:[h.jsx(xc,{variant:b.severity,children:h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("p",{role:"alert",children:b.failure.message}),b.failure.detail?h.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:b.failure.detail,children:b.failure.detail}):null]})}),S.length>0?h.jsx("div",{className:"flex flex-wrap items-center gap-2",children:S.map((P,R)=>R===0?h.jsx(ph,{disabled:n.pendingName===i.name,"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind):h.jsx(nl,{disabled:n.pendingName===i.name,"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind))}):null]}):null,l.kind==="grant"?h.jsxs("p",{children:["Your browser opens to approve access.",t==="reauth"?" This replaces the existing grant for this server.":""]}):null,l.kind==="running"&&!v?h.jsx("p",{children:m?.message||(g?"Waiting for backend sign-in status…":`Sign-in ${m?.status??"status unavailable"}.`)}):null,w?h.jsxs(h.Fragment,{children:[h.jsx(xc,{variant:"danger",children:h.jsx("p",{role:"alert",children:w.message})}),h.jsx("div",{className:"flex flex-wrap items-center gap-2",children:SB().map((P,R)=>R===0?h.jsx(ph,{"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind):h.jsx(nl,{"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind))})]}):null,v?h.jsxs(h.Fragment,{children:[h.jsx(xc,{variant:"danger",children:h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("p",{role:"alert",children:v.message}),v.detail?h.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:v.detail,children:v.detail}):null]})}),Q.length>0?h.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Q.map((P,R)=>R===0?h.jsx(ph,{disabled:n.pendingName===i.name,"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind):h.jsx(nl,{disabled:n.pendingName===i.name,"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind))}):null]}):null]})})}const V2t=y.createContext(null),M2t="bg-row-selected text-accent hover:bg-row-selected hover:text-accent active:bg-row-selected active:text-accent before:absolute before:inset-y-1 before:-left-[6.5px] before:w-0.5 before:rounded-full before:bg-accent",L2t="text-ink-muted hover:bg-row-hover hover:text-ink active:bg-row-hover active:text-ink",F2t=y.forwardRef(({id:e,label:t,ariaLabel:n,pressed:r,children:i,className:a,...o},s)=>{const l=y.useContext(V2t),c=l?.register;y.useLayoutEffect(()=>c?.(e),[c,e]);const[u,O]=y.useState(!1),d=y.useRef(null);return KPe(u,"panel-rail-tooltip",()=>{const f=d.current?.getAttribute("aria-describedby");return f?document.getElementById(f):null}),h.jsx(At,{content:t,side:"left",onOpenChange:O,children:h.jsx(Ve,{ref:f=>{d.current=f,typeof s=="function"?s(f):s&&(s.current=f)},variant:"ghost",size:"icon","data-panel-rail-item":e,"data-titlebar-no-drag":"","aria-label":n,"aria-pressed":r,tabIndex:l?l.roving===e?0:-1:void 0,className:j("relative focus-visible:outline-offset-1!",r?M2t:L2t,a),...o,children:i})})});F2t.displayName="PanelRailItem";const $2=e=>[e.name,e.transport??"",String(e.oauthSupported),e.keyNames.join(",")].join("\0");function B2t({sessionId:e}){const t=Fc(),[n,r]=y.useState(null),[i,a]=y.useState({}),[o,s]=y.useState({}),l=y.useCallback(async($,v)=>{const w=uc.list(e??""),x=t.getQueryData(w);if(!(v.status!==409||l3(x?.operations)))try{const b=await E1e(e,$.name);a(S=>({...S,[$2($)]:b.transport_oauth_supported===!1?"not-oauth":"refused"}))}catch{}},[t,e]),c=y.useCallback(($,v,w)=>{const x=t.getQueryData(uc.list(e??""));s(b=>({...b,[$]:Hj(v,w,l3(x?.operations))}))},[t,e]),u=y.useCallback(($,v="reauth")=>{if(!e||!$.remedy||$.remedy.kind!=="grant"&&$.remedy.kind!=="reconnect")return;const w=uc.list(e);r($.name),a(x=>{const{[$2($)]:b,...S}=x;return S}),s(x=>{const{[$.name]:b,...S}=x;return S}),(async()=>{try{if($.remedy?.kind==="reconnect"){const x=await Xe({op:"mcp.control",sessionId:e,control:{action:"connect",name:$.name}});x?.data?t.setQueryData(w,x.data):t.invalidateQueries({queryKey:w});return}await Xe({op:"mcp.control",sessionId:e,control:{action:v,name:$.name,confirmed:!0}}),t.invalidateQueries({queryKey:w})}catch(x){c($.name,$.remedy?.kind==="reconnect"?"reconnect":"grant",x),x instanceof Nt&&await l($,x)}finally{r(null)}})()},[l,t,c,e]),O=y.useCallback($=>{e&&(async()=>{try{await Xe({op:"mcp.control",sessionId:e,control:{action:"cancel",operation_id:$}}),t.invalidateQueries({queryKey:uc.list(e)})}catch(v){const x=t.getQueryData(uc.list(e))?.operations?.find(b=>b.id===$)?.name;x&&c(x,"cancel",v)}})()},[t,c,e]),d=y.useCallback(async($,v,w=[])=>{if(!e)return!1;r($.name),s(b=>{const{[$.name]:S,...Q}=b;return Q});const x=uc.list(e);try{const b=await Xe({op:"mcp.credentials.store",sessionId:e,name:$.name,values:v,confirmedReplace:w});if(b.data?.code!=="saved"){const S=b.data,Q=S?.code==="replace_confirmation_required"?"Confirm replacement of the existing shared keys before saving.":`Not saved: ${(S?.failed_ids??Object.keys(v)).join(", ")}. Unlock or repair the encrypted store, then retry.`;return s(P=>({...P,[$.name]:{cause:"unknown",phase:"key",detail:null,message:Q+(S?.saved_ids.length?` Saved: ${S.saved_ids.join(", ")}.`:"")}})),r(null),!1}}catch(b){return c($.name,"key",b),r(null),!1}try{const b=await Xe({op:"mcp.control",sessionId:e,control:{action:"connect",name:$.name}});if(b?.data){if(t.setQueryData(x,b.data),b.data.servers?.find(Q=>Q.name===$.name)?.status==="connected")return!0}else t.invalidateQueries({queryKey:x});return s(S=>({...S,[$.name]:{cause:"unknown",phase:"reconnect",detail:null,message:"The keys were saved, but this server is not connected. Check the credentials and server setup, then retry."}})),!1}catch(b){return c($.name,"reconnect",b),!1}finally{r(null)}},[t,c,e]),f=y.useCallback(async $=>{if(!e)return!1;r($.name),s(v=>{const{[$.name]:w,...x}=v;return x});try{const v=await Xe({op:"mcp.control",sessionId:e,control:{action:"reload",name:$.name}}),w=uc.list(e);return v?.data?t.setQueryData(w,v.data):t.invalidateQueries({queryKey:w}),!0}catch(v){return c($.name,"reload",v),!1}finally{r(null)}},[t,c,e]),p=y.useCallback($=>i[$2($)]??null,[i]),m=y.useCallback($=>o[$]??null,[o]),g=y.useCallback($=>{s(v=>{if(!($ in v))return v;const{[$]:w,...x}=v;return x})},[]);return{sessionId:e,press:u,pressKey:d,cancel:O,reload:f,pendingName:n,failureFor:m,clearFailure:g,refusalFor:p}}const H2t="Goal:",K2t="the session goal",J2t="Open the plan in run details",eXt="Open the subagents in run details",tXt="Open the jobs in run details",nXt="Open the wakes in run details",rXt="Open the monitors in run details",iXt="Loop:",q1e="Clear goal",aXt="Stop loop",oXt="Clear loop",sXt="Done",lXt="Dismiss",cXt="Could not mark the goal done",uXt="Could not dismiss the goal",OXt="Goal done",dXt="— done",fXt="goal stalled: judge could not decide — send a message to continue",hXt="goal stalled: reached the continuation limit — send a message to continue",pXt=e=>`goal stalled: stopped after ${e} continuations — send a message to continue`,mXt="goal stalled: auto-continuation stopped — send a message to continue",gXt="judge could not decide",kB="stopped after ",PB=" continuations",$Xt=/^\d+$/,yXt=e=>{const t=(e??"").trim();if(t===gXt)return fXt;if(t.startsWith(kB)&&t.endsWith(PB)){const n=t.slice(kB.length,t.length-PB.length);return $Xt.test(n)?pXt(n):hXt}return mXt},vXt="Could not clear the goal",bXt="Could not stop the loop",wXt="Could not clear the loop",SXt="Could not restore the goal",xXt="Goal cleared",QXt="Undo",TB=28,kXt=e=>{const t=j1e(e);return`${xXt} · ${t}`},PXt=e=>`${OXt} · ${j1e(e)} — it stays in the goal history; /goal <text> sets it again`,j1e=e=>{const t=e.trim().replace(/\s+/g," ");if(t.length<=TB)return t;const n=t.slice(0,TB),r=n.lastIndexOf(" ");return`${(r>0?n.slice(0,r):n).trimEnd()}…`},AS=new Map,TXt=(e,t)=>{AS.set(e,t)},_Xt=e=>{AS.delete(e)},XXt=e=>AS.has(e)?AS.get(e):null,Kj="line-clamp-4",C1e=j("disabled:text-ink-disabled disabled:cursor-default","disabled:hover:bg-transparent disabled:hover:text-ink-disabled"),RXt=e=>[e.status,e.completed,e.iterations??"",e.goal??""].join("|"),z1e=j("pointer-events-none opacity-0","group-hover:pointer-events-auto group-hover:opacity-100","group-focus-within:pointer-events-auto group-focus-within:opacity-100"),A1e="opacity-100",U1e="@max-[240px]/chatcol:hidden",W1e=U1e,EXt="@max-[241px]/chatcol:hidden",qXt="@max-[341px]/chatcol:hidden",jXt="@max-[270px]/chatcol:hidden",CXt="@max-[213px]/chatcol:hidden",zXt="@min-[270px]/chatcol:hidden",xu="-ml-1.5",AXt="@max-[240px]/chatcol:w-full @max-[240px]/chatcol:flex-none",UXt=(e,t,n="")=>`${t?"Collapse":"Expand"} ${K2t}${fa}${n?`${n}, `:""}${e}`,WXt=e=>`${J2t}${fa}${_6(e)}`,YXt=e=>`${eXt}${fa}${P6(e)}${Pse(e)}`,GXt=e=>`${tXt}${fa}${T6(e)}${Pse(e)}`,Y1e=(e,t)=>e!==null&&!e.isConnected&&!t,NXt=e=>`${nXt}${fa}${gse(e)}`,ZXt=e=>`${rXt}${fa}${$se(e)}`,IXt=e=>`${q1e}${fa}${e}`,DXt=e=>`Mark the goal done${fa}${e}`,VXt=e=>`Dismiss the finished goal${fa}it stays in the goal history${fa}${e}`,G1e=e=>`${N1e(e)}${Z1e(e)}`,N1e=e=>e.status,Z1e=e=>e.status!=="running"?"":e.iterations?`, ${e.completed} of ${e.iterations} turns`:`, ${e.completed} ${e.completed===1?"turn":"turns"}`,I1e=e=>W6(e.status)?{text:aXt,args:Cle,failure:bXt}:{text:oXt,args:null,failure:wXt},MXt=e=>`${I1e(e).text}${fa}${G1e(e)}`;function y2({kind:e,label:t,word:n,icon:r,busy:i,onPress:a}){return h.jsx(At,{content:t,side:"top",className:j(Kj),children:h.jsxs("button",{type:"button","data-status-goal-done":e==="done"?"":void 0,"data-status-goal-dismiss":e==="done"?void 0:"","aria-label":t,disabled:i,onClick:a,className:j(ic,z1e,i?A1e:void 0,C1e),children:[r,h.jsx("span",{className:j(W1e),children:n})]})})}const LXt=({frontend:e,runDetails:t,isSmallView:n=!1,askExpanded:r,onAskToggle:i,askOutcomes:a,onFocusComposer:o,onNote:s,nowMs:l})=>{const[c,u]=y.useState(!1),O=r??c,d=ke=>{u(ke),i?.(ke)},f=Bn(ke=>ke.revealRunPanelSection),p=ua(e?.session_id??""),m=ua(e?.session_id??""),g=ua(e?.session_id??""),$=ua(e?.session_id??""),[v,w]=y.useState(!1),x=e?.goal?.trim()??"",b=nae(e),S=e?.goal_status,Q=e?.goal_judge??null,P=S==="done",R=tae(e),_=jle(S,Q?.state),E=_==="stalled",C=y.useRef(E),W=Q?.reason;y.useEffect(()=>{if(!E){C.current=!1;return}C.current||(C.current=!0,s?.(yXt(W)))},[E,W,s]);const U=!!(t&&t.totalTodos>0),Y=t?.wakes??[],V=Y.length>0,M=t?.monitors??[],B=M.length>0,G=fQ(e,a),A=Dse(G.waiting>0,l),ee=i!==void 0&&(G.rows.length>0||G.open>0),K=G.waiting>0,z=e?.loop??null,le=z!==null&&z.status!=="idle"&&!W6(z.status)?RXt(z):null,[L,Z]=y.useState(null);y.useEffect(()=>{le===null&&Z(null)},[le]);const ne=z!==null&&z.status!=="idle"&&!(le!==null&&le===L),te=z===null?"":G1e(z),ie=y.useRef([]);y.useEffect(()=>{const ke=e?.session_id??"";return TXt(ke,x),()=>_Xt(ke)},[e?.session_id,x]),y.useEffect(()=>{if(!(x.length===0||ie.current.length===0)){for(const ke of ie.current)t0(ke);ie.current=[]}},[x]),y.useEffect(()=>{b||w(!1)},[b]);const $e=t?_w(t.subagents):null,je=t?_w(t.jobs):null,Oe=y.useRef(null),Fe=y.useRef(null);y.useEffect(()=>{const ke=document.activeElement,ht=ke instanceof HTMLElement&&Oe.current?.contains(ke)===!0?ke:null;Y1e(Fe.current,ht!==null)&&o?.(),Fe.current=ht});const[ze,ft]=y.useState(!0),ae=y.useRef(null),fe=y.useRef(0),Te=y.useRef(null);if(y.useLayoutEffect(()=>{const ke=Oe.current,ht=ae.current;if(!ke||!ht)return;const Ft=()=>{const Je=getComputedStyle(ke),rn=ea=>Number.parseFloat(ea)||0;return ke.clientWidth-rn(Je.paddingLeft)-rn(Je.paddingRight)},it=()=>{ze&&(fe.current=ht.scrollWidth,Te.current=te),ft(Ft()>=fe.current)};if(Te.current!==te&&(Te.current=te,fe.current=0,!ze)){ft(!0);return}if(it(),typeof ResizeObserver>"u")return;const Gr=new ResizeObserver(it);return Gr.observe(ke),()=>Gr.disconnect()},[ze,te]),!b&&!ne&&!U&&!ee&&!V&&!B&&!$e&&!je)return null;const _e=UXt(x,v,_),ut=t?WXt(t):"",St=V?NXt(Y.length):"",bt=B?ZXt(M.length):"",he=ee?zze(G,O,A):"",Re=ee?jse(G,A):null,Ue=ee?jze(G,A):null,oe=ee?Cse(G):"",pe=$e?YXt($e):"",Ge=je?GXt(je):"",ot=b?IXt(x):"",et=b&&R?DXt(x):"",ve=b&&R?VXt(x):"",st=ne&&z?I1e(z):null,wt=ne&&z?MXt(z):"",Lt=!b,bn=!b&&!ne,en=bn&&!U,Dn=en&&!ee,Rn=Dn&&!V,rr=Rn&&!B,Ei=rr&&!$e,vi=async ke=>{const ht=e?.session_id??"";if(XXt(ht)!==""){for(const it of ie.current)t0(it);ie.current=[];return}const Ft=await p.run(qu,ke,SXt);Ft.result.tone==="error"&&Oo(Ft.result.text)},xe=ke=>{if(ke.args===null){Z(le);return}ye($,b3,ke.args,ke.failure)},ye=async(ke,ht,Ft,it,Gr="cleared")=>{const Je=await ke.run(ht,Ft,it);if(Je.result.tone==="error"){Oo(Je.result.text);return}if(ht!==qu)return;const rn=x;if(Gr!=="dismissed"){if(Gr==="done"){Jh(PXt(rn));return}ie.current.push(Jh(kXt(rn),{action:{label:QXt,onClick:()=>void vi(rn)}}))}};return h.jsxs("div",{ref:Oe,"data-composer-status-row":"",className:j(Ai,"flex flex-wrap items-start gap-x-2 gap-y-0.5",n?"px-2 pb-1":"px-4 pb-2","@max-[240px]/chatcol:flex-col @max-[240px]/chatcol:flex-nowrap"),children:[b&&h.jsx("div",{"data-status-goal":"",className:j("flex min-w-[140px] flex-1 items-center",AXt),children:h.jsx(Bo,{className:j("min-w-0 flex-1"),rowClassName:j("h-6 rounded-sm px-1.5 py-0"),triggerClassName:j("w-fit max-w-full min-w-0 text-ink-muted hover:bg-accent-wash hover:text-ink focus-visible:outline-offset-1!",xu),triggerLabel:_e,triggerTooltip:_e,tooltipClassName:j(Kj),onOpenChange:w,trailing:h.jsxs(h.Fragment,{children:[R&&!P&&h.jsx(y2,{kind:"done",label:et,word:sXt,icon:h.jsx(Lc,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),busy:m.busy,onPress:()=>void ye(m,qu,qle,cXt,"done")}),P?h.jsx(y2,{kind:"dismiss",label:ve,word:lXt,icon:h.jsx(A7,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),busy:g.busy,onPress:()=>void ye(g,qu,bUe,uXt,"dismissed")}):h.jsx(y2,{kind:"clear",label:ot,word:q1e,icon:h.jsx(Ri,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),busy:p.busy,onPress:()=>void ye(p,qu,Ele,vXt)})]}),summary:h.jsxs("span",{className:j("flex min-w-0 items-center gap-1"),children:[h.jsx("span",{className:j("shrink-0",E&&"text-ink"),children:H2t}),h.jsx("span",{className:j("min-w-0 truncate",P&&"line-through text-ink-dim"),children:x}),P&&h.jsx("span",{className:j("shrink-0 text-meta text-ink-dim",EXt),children:dXt})]}),children:h.jsx("div",{role:"group","aria-label":"Session goal",tabIndex:0,"data-status-goal-body":"",className:j("font-sans text-body-sm text-ink-muted whitespace-pre-wrap break-words",QPe),children:x})})}),ne&&z&&st&&h.jsxs("div",{ref:ae,"data-status-loop-item":"",className:j("group flex shrink-0 items-center"),children:[h.jsxs("span",{"data-status-loop":"",className:j(Q3,Lt?xu:void 0),children:[h.jsx(Jje,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),h.jsxs("span",{children:[`${iXt} ${N1e(z)}`,ze&&h.jsx("span",{className:j(U1e),children:Z1e(z)})]})]}),h.jsx(At,{content:wt,side:"top",className:j(Kj),children:h.jsxs("button",{type:"button","data-status-loop-dismiss":"","aria-label":wt,disabled:$.busy,onClick:()=>xe(st),className:j(ic,z1e,$.busy?A1e:void 0,C1e),children:[h.jsx(Ri,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),h.jsx("span",{className:j(W1e),children:st.text})]})})]}),(U||ee||V||B||$e||je)&&h.jsxs("div",{className:j("flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5"),children:[U&&t&&h.jsx(At,{content:ut,side:"top",children:h.jsxs("button",{type:"button","data-status-plan":"","aria-label":ut,onClick:()=>f("todos"),className:j(ic,bn?xu:void 0),children:[h.jsx(U7,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),_6(t)]})}),ee&&h.jsx(At,{content:he,side:"top",children:h.jsxs("button",{type:"button","aria-expanded":O,"aria-label":he,"data-status-asks":"","data-lo-ask-item":O?"expanded":"minimized","data-lo-ask-item-toggle":"",onClick:()=>d(!O),className:j(ic,"[flex-shrink:1]!",K?"text-ink":void 0,en?xu:void 0),children:[h.jsx(oQ,{"aria-hidden":!0,className:j("size-3.5 shrink-0",G.urgent?"text-warning":K?"text-accent":void 0)}),h.jsx("span",{className:"shrink-0 whitespace-nowrap",children:X6(G)}),Re===null?null:h.jsxs("span",{className:j("min-w-0 shrink overflow-hidden text-ellipsis whitespace-nowrap",jXt),children:[" · ",oe===""?null:h.jsx("span",{className:qXt,children:`${oe} `}),Re]}),Ue===null?null:h.jsxs("span",{className:j("min-w-0 shrink overflow-hidden text-ellipsis whitespace-nowrap",zXt,CXt),children:[" · ",Ue]})]})}),V&&h.jsx(At,{content:St,side:"top",children:h.jsxs("button",{type:"button","data-status-wakes":"","aria-label":St,onClick:()=>f("wakes"),className:j(ic,Dn?xu:void 0),children:[h.jsx(Oqe,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),gse(Y.length)]})}),B&&h.jsx(At,{content:bt,side:"top",children:h.jsxs("button",{type:"button","data-status-monitors":"","aria-label":bt,onClick:()=>f("monitors"),className:j(ic,Rn?xu:void 0),children:[h.jsx(nCe,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),$se(M.length)]})}),$e&&h.jsx(At,{content:pe,side:"top",children:h.jsxs("button",{type:"button","data-status-subagents":"","aria-label":pe,onClick:()=>f("subagents"),className:j(ic,rr?xu:void 0),children:[h.jsx(Bj,{status:$e.mark}),P6($e)]})}),je&&h.jsx(At,{content:Ge,side:"top",children:h.jsxs("button",{type:"button","data-status-jobs":"","aria-label":Ge,onClick:()=>f("jobs"),className:j(ic,Ei?xu:void 0),children:[h.jsx(Bj,{status:je.mark}),T6(je)]})})]})]})},FXt=500;function BXt({previousActive:e,currentActive:t,heldUntil:n,now:r,graceMs:i=FXt}){return t?{held:!0,heldUntil:null}:e?{held:!0,heldUntil:r+i}:n!==null&&r<n?{held:!0,heldUntil:n}:{held:!1,heldUntil:null}}function HXt(e){const[t,n]=y.useState({held:!1,heldUntil:null}),r=y.useRef(!1),i=y.useRef(null);return y.useEffect(()=>{const a=Date.now(),o=BXt({previousActive:r.current,currentActive:e,heldUntil:t.heldUntil,now:a});r.current=e,!(o.held===t.held&&o.heldUntil===t.heldUntil)&&(i.current!==null&&(clearTimeout(i.current),i.current=null),n(o),o.heldUntil!==null&&(i.current=setTimeout(()=>{i.current=null,n({held:!1,heldUntil:null})},o.heldUntil-a)))},[e,t]),y.useEffect(()=>()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},[]),t}const D1e="This backend cannot move a live session. Start a new chat to use a different folder, or update the backend.",_en="This session is still starting. Its working directory can be moved as soon as it is live.";function KXt(e){return gi(e,"session_move",2)&&gi(e,"frontend_replace")}const JXt="The working directory was not changed.",eRt=15e3;async function tRt(e){try{const t=await Xe({op:"sessions.move",sessionId:e.sessionId,requestId:e.requestId,cwd:e.cwd}),n=nRt(t,e.evalUsed);return e.note(n),{kind:"settled",receipt:t,sentence:n}}catch(t){const n=mo(t,JXt);return e.note(n,!0),{kind:"refused",sentence:n}}}function nRt(e,t){return e.outcome==="unchanged"?`already in ${e.label}`:e.outcome==="cold"?`moved to ${e.label}`:t?`moved to ${e.label} — this session's runtime is restarting there, so everything you set up in eval was lost`:`moved to ${e.label} — this session's runtime is restarting there`}async function rRt(e){const t=await e.moveTo(e.cwd);t.kind==="in-flight"?e.note("A working-directory move is already in progress.",!0):t.kind==="unavailable"&&e.note(D1e,!0)}function iRt(e){return e.some(t=>t.kind==="tool"&&t.toolName==="eval")}function aRt(e,t){const n=y.useRef(oRt),[,r]=y.useState(0),i=t.transcript.records;return y.useEffect(()=>{const a=sRt(n.current,e,i);a!==n.current&&(n.current=a,r(o=>o+1))},[i,e]),lRt(n.current,e)}const oRt=new Set;function sRt(e,t,n){return!t||e.has(t)||!iRt(n)?e:new Set(e).add(t)}function lRt(e,t){return!!(t&&e.has(t))}function mg(e,t,n){const r=e.get(t)??null,i=n(r);if(i===r)return e;const a=new Map(e);return i?a.set(t,i):a.delete(t),a}function cRt(e,t,n){return{sessionId:e,requestId:t,path:n,target:null}}function _B(e,t){return e?.requestId===t?null:e}function uRt(e,t,n,r=Date.now()){return!e||e.requestId!==t?e:{...e,target:n,settleBy:e.settleBy??r+eRt}}function ORt(e,t,n){return!e||e.sessionId!==t?e:e.target!==null&&n===e.target?null:e}function Xen(e){const{sessionId:t,canonical:n}=e,[r,i]=y.useState(new Map),a=t?r.get(t)??null:null,o=KXt(e.capabilities),s=n.addNote,l=aRt(t,n),c=n.frontend?.cwd,u=y.useRef(r);y.useEffect(()=>{u.current=r},[r]);const O=y.useCallback((p,m=!1)=>{s(p,m?"error":"info")},[s]),d=y.useCallback(async p=>{if(!o||!t)return{kind:"unavailable"};if(u.current.get(t))return{kind:"in-flight"};const g=Wo(),$=cRt(t,g,p);u.current=mg(u.current,t,()=>$),i(w=>{const x=mg(w,t,()=>$);return u.current=x,x});const v=await tRt({sessionId:t,cwd:p,requestId:g,note:O,evalUsed:l});return i(w=>mg(w,t,x=>v.kind==="settled"?uRt(x,g,v.receipt.cwd):_B(x,g))),v},[o,t,O,l]);y.useEffect(()=>{!t||!a||i(p=>mg(p,t,m=>ORt(m,t,c)))},[a,t,c]),y.useEffect(()=>{const p=[...r.values()].flatMap(m=>m.settleBy===void 0?[]:[setTimeout(()=>{i(g=>mg(g,m.sessionId,$=>_B($,m.requestId)))},Math.max(0,m.settleBy-Date.now()))]);return()=>{for(const m of p)clearTimeout(m)}},[r]);const f=a&&a.sessionId===t?a:null;return y.useMemo(()=>({cwd:f?.target??f?.path??c,moveTo:d,busy:!!f,accepted:f?.target!=null}),[f,d,c])}const dRt={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},qA={refetchOnWindowFocus:!1},Ren=new voe({defaultOptions:dRt}),fRt=/\s*\([^)]*\)\s*$/,hRt=/\(([^)]+)\)\s*$/,pRt=/[^A-Za-z0-9]+/,mRt=/[A-Z]/,gRt=/Enter code:\s*([A-Za-z0-9-]+)/,$Rt=/^www\./,yRt="radient",Een=["radient","anthropic","openai","deepseek"];function dO(e){const t=e.brand?.trim();if(t)return t;const n=e.id?vRt[e.id]:void 0;return n||e.name.replace(fRt,"").trim()||e.name}const vRt={"alibaba-token-plan":"QwenCloud"};function bRt(e){const t=hRt.exec(e);return t?t[1].trim():null}const wRt={anthropic:"Claude subscription",openai:"ChatGPT subscription","openai-device":"ChatGPT, with a code",radient:"Browser sign-in",kimi:"Moonshot account","xai-oauth":"SuperGrok account","zai-oauth":"Browser sign-in","alibaba-token-plan-oauth":"Token Plan account"};function qen(e){if(e.kind==="api_key")return"API key";const t=wRt[e.method_id];if(t)return t;const n=bRt(e.label);return n||(e.kind==="device"?"Sign in with a code":"Sign in")}const SRt={anthropic:"Use your Claude Pro or Max plan. No extra charge.",openai:"Use your ChatGPT Plus or Pro plan. No extra charge.","openai-device":"Use your ChatGPT plan, signing in with a one-time code. No extra charge.",radient:"One browser sign-in. Nothing to paste."};function jen(e,t){const n=SRt[e.method_id];return n||(e.kind==="device"?`Sign in to your ${dO(t)} account with a one-time code.`:`Sign in with your ${dO(t)} account.`)}function Cen(e){const t=e.split(pRt).filter(Boolean);if(t.length>=2)return`${t[0][0]}${t[1][0]}`.toUpperCase();const n=t[0]??e,r=mRt.exec(n.slice(1));return r?`${n[0]}${r[0]}`.toUpperCase():`${n[0]?.toUpperCase()??""}${n[1]?.toUpperCase()??""}`}const zen={subscription:"Use a subscription",key:"Use an API key",local:"Run models on this computer"};function Pk(e){return e.local?"local":e.auth_methods.some(n=>n.kind==="browser"||n.kind==="device")?"subscription":"key"}function Aen(e){const t=Pk(e);return t==="local"?"Set up":t==="key"?"Add key":"Sign in"}function Uen(e){const t=Pk(e);return t==="local"?`Needs ${dO(e)} running`:t==="key"?"Paste an API key":`Sign in with your ${QRt(e)} account`}const xRt={anthropic:"Claude",openai:"ChatGPT",kimi:"Moonshot",xai:"SuperGrok","xai-oauth":"SuperGrok",zai:"Z.AI",radient:"Radient","alibaba-token-plan":"QwenCloud"};function QRt(e){return xRt[e.id]??dO(e)}function V1e(e,t){return e.local||e.credential_optional?t!==null&&e.id===t:e.has_credential||e.configured}function Wen(e,t){return e.filter(n=>V1e(n,t)).sort((n,r)=>n.id===t?-1:r.id===t?1:dO(n).localeCompare(dO(r)))}function Yen(e,t,n=""){const r=n.trim().toLowerCase(),i={subscription:[],key:[],local:[]};for(const o of e)V1e(o,t)||r&&![o.name,o.id,...o.search_aliases].join(" ").toLowerCase().includes(r)||i[Pk(o)].push(o);const a=i.subscription.findIndex(o=>o.id===yRt);if(a>0){const[o]=i.subscription.splice(a,1);i.subscription.unshift(o)}return i}function Gen(e,t,n="Signed in"){const r=Pk(e);return[r==="local"?"On this computer":r==="key"?"API key saved":n,t].filter(Boolean).join(" · ")||null}function Nen(e,t){if(!t)return null;const n=e?.suggested_model;return n&&n.id===t?n.name:t}function Zen(e){if(e.user_code)return e.user_code;const t=gRt.exec(e.instructions??"");return t?t[1]:null}function Ien(e){if(!e)return null;try{return new URL(e).host.replace($Rt,"")||null}catch{return null}}function Den(e){return e>0?Math.ceil(e/60):null}const kRt="Replaced by a new sign-in.";function Ven(e,t){return e.state==="expired"?e.message==="This sign-in is no longer available. Start again."?"This sign-in is no longer available, so it was stopped.":"The sign-in link expired.":e.state==="cancelled"?e.message===kRt?"A newer sign-in replaced this one.":"You cancelled sign-in.":e.message&&e.message!=="Sign-in failed."?e.message:`${t} didn't confirm the sign-in.`}async function Jj(e,t){await t("hosting",e.provider),await t("model_name",e.model_id)}function eC(e){return e?.provider&&e.model_id?{provider:e.provider,model_id:e.model_id}:null}function PRt(e){return e?.kind==="notice"&&e.style==="info"}function TRt(e,t,n,r){if(e!=="default"||!n||!r)return null;const i=eC(t?{provider:pn(t.provider),model_id:pn(t.model_id)}:null),a=i?.provider??"",o=i?.model_id??"";return{kind:"action",id:"model-default",name:"Set current model as default",description:i?`Save the current model (${a}/${o}) as the default for new sessions.`:"No active session model is available to save.",model:i,clickText:i?"Click does the same.":"A session model is required before this action can save a default.",disabled:i===null}}function M1e(e,t){return!e.disabled}const _Rt=new Set(["theme","title-refresh"]);function XRt(e){return e!==void 0&&_Rt.has(e)}const RRt=new Set(["providers","provider-accounts","mcp"]);function ERt(e){return e!==void 0&&RRt.has(e)}function L1e(e){return e.includes(" ")}const qRt="No servers to choose. Enter runs the command.",jRt={mcp_catalog:2};function XB(e,t){if(!e?.requires)return e;const n=t?.features?.[e.requires]??0,r=jRt[e.requires]??1;if(!(t?.desktop_available!==!0||n<r))return e}const jA=new Set(["title-refresh"]),F1e={"title-refresh":new Set(["refresh","update","retitle","--refresh","--auto","--update","--retitle"])};function B1e(e,t){const n=e?F1e[e]:void 0;if(!n)return!1;const r=mn(t);return!r||r.includes(" ")||r.includes(" ")?!1:n.has(r.toLowerCase())}function CRt(e,t){const n=e?F1e[e]:void 0;if(!n)return!1;const r=mn(t);if(!r||r.includes(" ")||r.includes(" "))return!1;const i=r.toLowerCase();for(const a of n)if(a.startsWith(i))return!0;return!1}function zRt(e){return e===void 0||!jA.has(e)}const ARt={model:"Models",effort:"Effort",approvals:"Approvals",team:"Teams",agent:"Agents",providers:"Providers","provider-accounts":"Accounts",mcp:"Servers",theme:"Themes","title-refresh":"Options"};function URt(e){return e>0?e>=1e6?`${(e/1e6).toFixed(1)}m`.replace(".0m","m"):e>=1e3?`${Math.floor(e/1e3)}k`:String(e):""}const WRt=/0+$/,YRt=/\.$/;function RB(e){if(e===Math.trunc(e))return String(Math.trunc(e));if(e>=10)return e.toFixed(1);const t=Math.floor(Math.log10(Math.abs(e))),n=Math.max(0,2-t);return e.toFixed(n).replace(WRt,"").replace(YRt,"")}function H1e(e,t,n){return n?"usage-based":!(e>=0)||!(t>=0)?"":e===0&&t===0?"free":`$${RB(e)}/${RB(t)}`}const pn=e=>typeof e=="string"?e:"",v2=e=>typeof e=="number"&&Number.isFinite(e)?e:-1,GRt=[{value:"--refresh",name:"--refresh",description:"Re-read the conversation and name it again",detail:"resumes auto-naming",aliases:["refresh","update","retitle","--update","--retitle"]}];function NRt(){return GRt.map(e=>({...e,aliases:e.aliases?[...e.aliases]:void 0}))}function ZRt(e){const t=pn(e.selector)||pn(e.value);if(t)return t;const n=pn(e.provider),r=pn(e.model_id);return n&&r?`${n}/${r}`:""}const EB=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):void 0,IRt={oauth:"oauth",api_key:"api key"},DRt="Stored credential",VRt={logged_in:"logged in",env_key:"env key",needs_login:"needs login",local_ready:"configured server",local_unconfigured:"configure server"},MRt=/[^a-z0-9]+/g;function qB(e){return e.toLowerCase().replace(MRt,"")}function LRt(e,t){const n=t.trim();return n.endsWith(")")&&n.includes("(")?n.slice(n.indexOf("(")+1,-1).trim():n&&qB(n)===qB(e)?"":n}const FRt={oauth:["sign_in","reauth","sign_out"],signed_in:["sign_out"]},jB={connected:"connected",connecting:"connecting",needs_sign_in:"needs sign-in",not_started:"not connected",error:"error"};function BRt(e,t){const n=pn(t.status);return e==="remove"?Oae(pn(t.source?.path)):e==="logout"?n==="connected"?"stored credential · connected":"stored credential":e==="reauth"?n==="connected"?"connected — will re-authorize":jB[n]??"":n==="connected"?"connected — will re-use":jB[n]??""}function nc(e,t,n,r){switch(e){case"model":{const i=n??null,a=i?`${pn(i.provider)}/${pn(i.model_id)}`:"";return t.map(o=>{const s=o,l=ZRt(s),c=[pn(s.provider),s.aggregated?"aggregated":"",s.connected===!1?"no credential":""].filter(Boolean).join(", "),u=[URt(v2(s.context_window)),H1e(v2(s.input_price),v2(s.output_price),s.routed===!0)].filter(Boolean).join(" · ");return{value:l,name:pn(s.label)||pn(s.model_id),description:c,detail:u||void 0,current:!!a&&a===l}})}case"team":case"agent":return t.map(i=>{const a=i,o=pn(a.value)||pn(a.name),s=pn(a.label),l=pn(a.name)||o,c=z6({name:l,label:s});return{value:o,name:c,slug:c!==o?o:void 0,aliases:s?.trim()&&c!==o?[o]:void 0,description:pn(a.description),detail:pn(a.kind)||void 0,current:!!n&&n===o}});case"effort":return t.map(i=>{const a=pn(i.value);return{value:a,name:Rh(a),current:n===a}});case"approvals":return t.map(i=>{const a=pn(i.value);return{value:a,name:a,current:n===a}});case"providers":return t.map(i=>{const a=i,o=pn(a.id),s=VRt[pn(a.state)];return{value:o,name:dO({id:o,name:pn(a.name),brand:pn(a.brand)}),description:LRt(o,pn(a.name)),detail:s||void 0,aliases:EB(a.search_aliases)}});case"provider-accounts":{const i=new Map;for(const o of t){const s=o,l=pn(s.provider);if(!l)continue;const c=i.get(l)??{kinds:[],labels:[]};c.kinds.push(pn(s.type)),c.labels.push(pn(s.identity_label)),i.set(l,c)}const a=new Map((r?.providers??[]).map(o=>[pn(o.id),o]));return[...i.entries()].map(([o,s])=>{const l=new Set(s.kinds.map(d=>IRt[d]??d).filter(Boolean)),c=l.size===1?`remove ${[...l][0]}`:`remove ${s.kinds.length} credentials`,u=s.labels.length===1&&s.labels[0]!==DRt?s.labels[0]:"",O=a.get(o);return{value:o,name:O?dO({id:o,name:pn(O.name),brand:pn(O.brand)}):o,aliases:O?EB(O.search_aliases):void 0,detail:u?`${c} · ${u}`:c,alert:!0}})}case"mcp":{const i=r?.argument??"",a=r?.verbs??[],o=i.indexOf(" ");if(o===-1)return a.map(u=>({value:`${u.verb} `,name:u.verb,description:u.description,alert:u.destructive}));const s=i.slice(0,o).toLowerCase(),l=a.find(u=>u.verb===s);if(!l||l.offers===null)return[];const c=l.offers==="all"?null:FRt[l.offers];return l.offers!=="all"&&!c?[]:t.flatMap(u=>{const O=u,d=Array.isArray(O.actions)?O.actions:[];if(c&&!d.some(p=>c.includes(String(p))))return[];const f=pn(O.name);return[{value:`${l.verb} ${f}`,name:`${l.verb} ${f}`,detail:BRt(l.verb,O),alert:l.destructive}]})}case"theme":return t.map(i=>{const a=i,o=pn(a.value);return{value:o,name:pn(a.name)||o,description:pn(a.description),current:n===o}});case"title-refresh":return NRt()}}function K1e(e){return!e?.provider||!e.model_id?null:`${e.provider}/${e.model_id}`}function HRt(e){if(!e?.provider||!e.model_id)return null;const t=typeof e.reasoning_effort=="string"?e.reasoning_effort.trim():"";return{provider:e.provider,model_id:e.model_id,reasoning_effort:t===""?null:t}}const J1e={cwd:""};function KRt(e){return["desktop","session-preview",e.cwd,e.target?.kind??null,e.target?.name??null,K1e(e.model),e.model?.reasoning_effort??null]}async function JRt(e){return(await Xe({op:"sessions.preview",requestId:crypto.randomUUID(),cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}})).frontend}function e4t(e,t){const n=e.trim();if(!n)return{checked:!0,rung:null,confirmation:i=>`This conversation will run ${i}.`};if(!t.ladderKnown)return{checked:!1,rung:null,refusal:"Nothing was changed, because that model's effort levels could not be read. Try again."};const r=t.ladder.find(i=>i.trim().toLowerCase()===n.toLowerCase());return r?{checked:!0,rung:r,confirmation:i=>`This conversation will run ${i} at ${r} effort.`}:{checked:!0,rung:null,confirmation:i=>t.level?`This conversation will run ${i}. Its effort is now ${t.level}, because ${n} is not one of that model's levels.`:`This conversation will run ${i}. No effort level is set on it, because ${n} is not one of that model's levels.`}}function US(e){return{queryKey:KRt(e),queryFn:()=>JRt(e),placeholderData:iQ,staleTime:3e4,retry:!1}}function t4t(e){return[{value:"on",label:"On",description:"Priority processing. Billed at premium rates where the provider offers it.",current:e==="on"},{value:"off",label:"Off",description:"Standard processing.",current:e==="off"}]}const n4t=/[^0-9a-z]+/g;function ewe(e){return e.toLowerCase().replace(n4t," ").trim()}function r4t(e,t,n){let r=n+1;for(let i=1;i<e.length;i+=1){const a=t.indexOf(e[i],r);if(a<0)return!1;r=a+1}return!0}function i4t(e,t){const n=e[0];for(let r=t.indexOf(n);r!==-1;r=t.indexOf(n,r+1))if(!(r!==0&&t[r-1]!==" ")&&r4t(e,t,r))return!0;return!1}const CB=new WeakMap,zB=e=>e.trim()!=="";function AB(e){const t=CB.get(e);if(t)return t;const n=[e.label,e.value].concat(e.keywords??[]),r=[e.description??"",e.meta??""],i={lowered:n.concat(r).filter(zB).map(a=>a.toLowerCase()),named:n.filter(zB).map(ewe).filter(a=>a!=="")};return CB.set(e,i),i}function a4t(e,t){const n=t.trim();if(!n)return e;const r=ewe(t);if(!r)return[];const i=n.toLowerCase(),a=r.split(" ").filter(Boolean),o=a.length>1&&a.every(l=>l.length>1),s=e.filter(l=>{const{lowered:c,named:u}=AB(l);return c.some(O=>O.includes(i))||u.some(O=>O.includes(r))});return s.length>0?s:e.filter(l=>AB(l).named.some(c=>o&&a.every(u=>c.includes(u))||i4t(r,c)))}const o4t={info:"border-hairline bg-sunken text-ink-muted",success:"border-success-border bg-success-wash text-ink",warning:"border-warning-border bg-warning-wash text-ink",error:"border-danger-border bg-danger-wash text-ink"},s4t="Panel content",twe={hovered:null,picked:null};function l4t(e,t){switch(t.type){case"hover":return e.hovered===t.index?e:{...e,hovered:t.index};case"leave":return e.hovered===null?e:{...e,hovered:null};case"pick":return{...e,picked:t.value};case"settle":return e.picked===null?e:{...e,picked:null};case"reset":return twe}}function c4t(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>[r.label,r.value,r.description??"",r.meta??""].concat(r.keywords??[]).join(" ").toLowerCase().includes(n)):e}function u4t(e){return e.loading?"loading":e.loadError?"error":e.rowCount===0?"empty":"list"}function O4t(e){const{options:t,held:n,active:r,query:i,queryChanged:a,steered:o}=e,s=e.retarget??null;if(t.length===0)return{index:0,held:null,retargeted:null,steered:!1};const l=n===null?-1:t.findIndex(f=>f.value===n),c=Math.max(0,Math.min(r,t.length-1)),u=i?-1:t.findIndex(f=>f.current),O=u>=0?u:c;if(s!==null&&t.some(f=>f.value===s.lost)&&l>=0)return{index:l,held:n,retargeted:null,steered:o};if(l>=0)return{index:l,held:n,retargeted:a?null:void 0,steered:o};const d=t[O];return a?{index:O,held:d?.value??null,retargeted:null,steered:!1}:{index:O,held:d?.value??null,retargeted:o&&n!==null&&d!==void 0?{lost:n,label:d.label}:void 0,steered:o}}function UB(e){return e.busy?e.busyText??"Applying the change…":e.hasList&&e.rowCount>0?e.retargetedLabel?`The row you were on is gone · Enter picks ${e.retargetedLabel}`:e.activeLabel?`Arrows move · Enter picks ${e.activeLabel} · Esc closes`:"Arrows move, Enter picks, Esc closes":"Esc closes"}function d4t(e){return e.busy?"Close":e.result&&(e.result.tone==="success"||e.result.tone==="info")?"Done":"Close"}const nwe=y.memo(({id:e,option:t,index:n,isActive:r,isHovered:i,isPicked:a,onHover:o,onPick:s,busyLabel:l="Applying the change"})=>h.jsxs("div",{id:e,role:"option","aria-selected":r,"aria-disabled":t.disabled||void 0,"data-current":t.current||void 0,"data-hovered":i||void 0,"data-picked":a||void 0,onMouseEnter:()=>o(n),onMouseDown:c=>{c.preventDefault(),s(t,n)},className:j("flex items-start gap-3 rounded-sm px-2 py-1.5",r&&"bg-sunken",i&&!r&&!t.disabled&&"bg-accent-wash",(a||i&&!r&&!t.disabled)&&"outline-solid outline-1 -outline-offset-1 outline-control",t.disabled&&"text-ink-disabled"),children:[h.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx("span",{className:j("truncate text-body-sm",t.disabled?"text-ink-disabled":"text-ink"),children:t.label}),t.current&&h.jsx(Lc,{className:j("size-3.5 shrink-0",t.disabled?"text-warning":"text-accent"),"aria-label":"Current"})]}),t.description&&h.jsx("span",{className:j("truncate text-meta",t.disabled?"text-ink-dim":"text-ink-muted"),title:t.description,children:t.description})]}),a?h.jsx("span",{className:"shrink-0",children:h.jsx(Fo,{size:"sm",label:l})}):t.meta?h.jsx("span",{className:"shrink-0 font-mono text-ink-dim text-mono-sm",children:t.meta}):null]}));nwe.displayName="PickerRow";const cr=({open:e,onClose:t,title:n,description:r,options:i,matcher:a=c4t,loading:o=!1,loadError:s=null,notice:l=null,noticeDetail:c=null,emptyText:u="Nothing matches.",searchPlaceholder:O="Search",onPick:d,form:f,onSubmit:p,submitLabel:m="Apply",submitDisabled:g=!1,actions:$,result:v=null,busy:w=!1,busyText:x,busyLabel:b="Applying the change",wide:S=!1,shell:Q="dialog",bodyLabel:P,toolbar:R,body:_,bodyScrolls:E=!1})=>{const C=y.useId();q7(e,"panel-picker");const[W,U]=y.useState(""),[Y,V]=y.useState(0),M=y.useRef(null),B=y.useRef(!1),G=y.useRef(null),[A,ee]=y.useState(null),[K,z]=y.useReducer(l4t,twe),le=y.useRef(null),L=y.useRef(null),[Z,ne]=y.useState(!1),[te,ie]=y.useState(!1),[$e,je]=y.useState(!0),Oe=y.useRef(null),Fe=y.useRef(null),ze=y.useCallback(ve=>{if(Oe.current?.(),Oe.current=null,!ve){ne(!1),ie(!1);return}const st=()=>{const Lt=ve.scrollHeight-ve.clientHeight;ne(Lt>1),ie(Lt-ve.scrollTop>1)};st(),ve.addEventListener("scroll",st,{passive:!0});let wt;if(typeof ResizeObserver<"u"){wt=new ResizeObserver(st),wt.observe(ve);for(const Lt of ve.children)wt.observe(Lt)}Oe.current=()=>{ve.removeEventListener("scroll",st),wt?.disconnect()}},[_]),ft=y.useCallback(ve=>{Fe.current=ve,ze(ve)},[ze]),ae=y.useRef(null),fe=i!==void 0,Te=y.useMemo(()=>i?a(i,W):[],[i,W,a]),_e=y.useMemo(()=>{const ve=new Map;for(const st of Te){const wt=st.group??"",Lt=ve.get(wt);Lt?Lt.push(st):ve.set(wt,[st])}return[...ve.entries()]},[Te]),ut=y.useMemo(()=>_e.flatMap(([,ve])=>ve),[_e]),St=ut[Y]?.label??null;y.useEffect(()=>{e&&(U(""),V(0),M.current=null,B.current=!1,G.current=null,ee(null),z({type:"reset"}))},[e]),y.useEffect(()=>{w||z({type:"settle"})},[w]),y.useEffect(()=>{const ve=G.current!==W;G.current=W;const st=O4t({options:ut,held:M.current,active:Y,query:W,queryChanged:ve,steered:B.current,retarget:A});M.current=st.held,B.current=st.steered,V(st.index),st.retargeted!==void 0&&ee(st.retargeted)},[ut,W,Y,A]),y.useEffect(()=>{L.current?.scrollTo({top:0})},[W]),y.useEffect(()=>{L.current?.querySelector(`[id="${C}-${Y}"]`)?.scrollIntoView?.({block:"nearest"})},[Y,C]);const bt=y.useCallback(async ve=>{!ve||ve.disabled||w||(z({type:"pick",value:ve.value}),await d?.(ve.value,ve))},[d,w]),he=y.useRef(bt);y.useEffect(()=>{he.current=bt},[bt]);const Re=y.useCallback((ve,st)=>{M.current=ve.value,B.current=!0,ee(null),V(st),he.current(ve)},[]),Ue=y.useCallback(ve=>z(ve===null?{type:"leave"}:{type:"hover",index:ve}),[]),oe=y.useCallback(()=>z({type:"leave"}),[]),pe=y.useCallback(ve=>{if(!ve.nativeEvent.isComposing)if(ve.key==="ArrowDown"&&ut.length>0){ve.preventDefault();const st=(Y+1)%ut.length;M.current=ut[st]?.value??null,B.current=!0,ee(null),V(st)}else if(ve.key==="ArrowUp"&&ut.length>0){ve.preventDefault();const st=(Y-1+ut.length)%ut.length;M.current=ut[st]?.value??null,B.current=!0,ee(null),V(st)}else ve.key==="Enter"&&(ve.preventDefault(),fe&&ut.length>0&&d?bt(ut[Y]):p&&!g&&!w&&p())},[ut,Y,fe,d,p,g,w,bt]),Ge=y.useCallback(ve=>{ve.preventDefault(),p&&!g&&!w&&p()},[p,g,w]),ot=u4t({loading:o,loadError:s,rowCount:Te.length});let et=-1;return h.jsx(j7,{open:e,onOpenChange:ve=>!ve&&t(),children:h.jsxs(C7,{className:j("gap-0 p-0",Q==="panel"?"max-w-5xl":S?"max-w-3xl":"max-w-xl","overflow-hidden rounded-lg"),onOpenAutoFocus:ve=>{if(ve.preventDefault(),Q==="panel"){Fe.current?.focus(),Fe.current||ae.current?.focus();return}le.current?.focus()},children:[h.jsxs("div",{className:"flex flex-col gap-1 px-5 pt-5 pr-12",children:[h.jsx(z7,{className:"text-heading text-ink",children:n}),r?h.jsx(QE,{className:"text-body-sm text-ink-muted",children:r}):h.jsx(QE,{className:"sr-only",children:n})]}),fe&&h.jsx("div",{className:"px-5 pt-4",children:h.jsxs("div",{className:"relative",children:[h.jsx(Xy,{className:"-translate-y-1/2 pointer-events-none absolute top-1/2 left-2.5 size-4 text-ink-dim","aria-hidden":"true"}),h.jsx(po,{ref:le,role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":ut[Y]?`${C}-${Y}`:void 0,"aria-autocomplete":"list",value:W,onChange:ve=>U(ve.target.value),onKeyDown:pe,placeholder:O,className:"pl-8",autoComplete:"off",spellCheck:!1})]})}),!fe&&!_&&h.jsx("input",{ref:le,className:"sr-only","aria-hidden":"true",tabIndex:-1,onKeyDown:pe,readOnly:!0}),R&&h.jsx("div",{className:"px-5 pt-3",children:R}),fe&&h.jsxs("div",{className:"px-3 pt-3",children:[l&&h.jsx(At,{content:c,children:h.jsx("p",{className:"px-2 pb-2 text-body-sm text-warning",children:l})}),ot==="loading"?h.jsx("div",{className:"flex h-24 items-center justify-center",children:h.jsx(Fo,{size:"md",label:"Loading"})}):ot==="error"?h.jsx("p",{className:"px-2 py-3 text-body-sm text-danger",children:s}):ot==="empty"?h.jsx("p",{className:"px-2 py-3 text-body-sm text-ink-dim",children:u}):h.jsx("div",{ref:L,id:C,role:"listbox","aria-label":n,tabIndex:-1,onMouseLeave:oe,className:"max-h-[min(50vh,420px)] overflow-y-auto",children:_e.map(([ve,st])=>h.jsxs("div",{children:[ve&&h.jsx("p",{className:"px-2 pt-2 pb-1 text-ink-dim text-meta",children:ve}),st.map(wt=>{et+=1;const Lt=et;return h.jsx(nwe,{id:`${C}-${Lt}`,option:wt,index:Lt,isActive:Lt===Y,isHovered:Lt===K.hovered,isPicked:K.picked===wt.value,onHover:Ue,onPick:Re,busyLabel:b},wt.value)})]},ve||"ungrouped"))})]}),_&&h.jsx("div",{className:j(Z&&"border-control border-b"),children:h.jsx("div",{ref:ft,role:Q==="panel"?"region":void 0,"aria-label":Q==="panel"?P??s4t:void 0,tabIndex:Q==="panel"?0:void 0,onKeyDown:Q==="panel"&&$e?()=>je(!1):void 0,onPointerDown:Q==="panel"&&$e?()=>je(!1):void 0,"data-panel-body":"",className:j("overflow-y-auto px-5 pt-3",Q==="panel"?"max-h-[min(76vh,760px)] pb-4":"max-h-[min(60vh,520px)]",Q==="panel"&&$e&&"outline-none",(E||Q==="panel")&&"[scrollbar-gutter:stable]",te&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-20px),transparent)]"),children:_})}),f&&h.jsxs("form",{onSubmit:Ge,className:j("flex flex-col gap-3 px-5",fe?"pt-3":"pt-4"),children:[f,h.jsx("button",{type:"submit",className:"sr-only",tabIndex:-1,"aria-hidden":"true"})]}),v&&h.jsx("div",{className:"px-5 pt-3",children:h.jsxs("output",{className:j("block rounded-md border px-3 py-2 text-body-sm",o4t[v.tone]),children:[h.jsx("p",{className:"whitespace-pre-wrap",children:v.text}),v.detail&&h.jsx("div",{className:"mt-2 font-mono text-mono-sm",children:v.detail})]})}),h.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4","data-picker-footer":!0,children:[h.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:w?h.jsxs("span",{className:"flex items-center gap-2 text-ink-muted",children:[h.jsx(Fo,{size:"sm"}),UB({busy:w,hasList:fe,rowCount:Te.length,activeLabel:St,busyText:x,retargetedLabel:A?.label??null})]}):UB({busy:w,hasList:fe,rowCount:Te.length,activeLabel:St,busyText:x,retargetedLabel:A?.label??null})}),h.jsxs("div",{className:"flex items-center gap-2",children:[$,h.jsx(Ve,{ref:ae,variant:"ghost",size:"sm",type:"button",onClick:t,children:d4t({busy:w,result:v})}),p&&h.jsx(Ve,{variant:"primary",size:"sm",type:"button",onClick:()=>void p(),disabled:g||w,children:m})]})]})]})})},El=({label:e,hint:t,children:n,htmlFor:r})=>h.jsxs("label",{className:"flex flex-col gap-1",htmlFor:r,children:[h.jsx("span",{className:"text-ink-muted text-meta",children:e}),n,t&&h.jsx("span",{className:"text-ink-dim text-meta",children:t})]}),n1=({label:e,value:t,mono:n=!0})=>h.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1",children:[h.jsx("span",{className:"text-body-sm text-ink-muted",children:e}),h.jsx("span",{className:j("text-right text-ink",n?"font-mono text-mono-sm":"text-body-sm"),children:t})]}),Zc=({checked:e,onCheckedChange:t,children:n,tone:r="muted"})=>{const i=y.useId();return h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsx(JPe,{className:"mt-0.5",id:i,checked:e,onCheckedChange:a=>t(a===!0)}),h.jsx(Eie,{htmlFor:i,className:j("font-normal text-body-sm",r==="ink"?"text-ink":"text-ink-muted"),children:n})]})};function N$({value:e,onChange:t,options:n,label:r}){const i=y.useId();return h.jsxs("fieldset",{className:"flex items-center gap-1 rounded-md bg-sunken p-1",children:[h.jsx("legend",{className:"sr-only",children:r}),n.map(a=>{const o=`${i}-${a.value}`;return h.jsxs("span",{children:[h.jsx("input",{type:"radio",id:o,name:i,value:a.value,checked:e===a.value,onChange:()=>t(a.value),className:"sr-only"}),h.jsx("label",{htmlFor:o,className:j("block cursor-pointer rounded-sm px-3 py-1 text-body-sm",e===a.value?"bg-surface text-ink":"text-ink-muted hover:text-ink"),children:a.label})]},a.value)})]})}var b2,WB;function Wa(){if(WB)return b2;WB=1;var e=Array.isArray;return b2=e,b2}var w2,YB;function rwe(){if(YB)return w2;YB=1;var e=typeof vv=="object"&&vv&&vv.Object===Object&&vv;return w2=e,w2}var S2,GB;function Yl(){if(GB)return S2;GB=1;var e=rwe(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return S2=n,S2}var x2,NB;function iv(){if(NB)return x2;NB=1;var e=Yl(),t=e.Symbol;return x2=t,x2}var Q2,ZB;function f4t(){if(ZB)return Q2;ZB=1;var e=iv(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function a(o){var s=n.call(o,i),l=o[i];try{o[i]=void 0;var c=!0}catch{}var u=r.call(o);return c&&(s?o[i]=l:delete o[i]),u}return Q2=a,Q2}var k2,IB;function h4t(){if(IB)return k2;IB=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return k2=n,k2}var P2,DB;function tu(){if(DB)return P2;DB=1;var e=iv(),t=f4t(),n=h4t(),r="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function o(s){return s==null?s===void 0?i:r:a&&a in Object(s)?t(s):n(s)}return P2=o,P2}var T2,VB;function nu(){if(VB)return T2;VB=1;function e(t){return t!=null&&typeof t=="object"}return T2=e,T2}var _2,MB;function pm(){if(MB)return _2;MB=1;var e=tu(),t=nu(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return _2=r,_2}var X2,LB;function CA(){if(LB)return X2;LB=1;var e=Wa(),t=pm(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){if(e(a))return!1;var s=typeof a;return s=="number"||s=="symbol"||s=="boolean"||a==null||t(a)?!0:r.test(a)||!n.test(a)||o!=null&&a in Object(o)}return X2=i,X2}var R2,FB;function QO(){if(FB)return R2;FB=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return R2=e,R2}var E2,BB;function zA(){if(BB)return E2;BB=1;var e=tu(),t=QO(),n="[object AsyncFunction]",r="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(s){if(!t(s))return!1;var l=e(s);return l==r||l==i||l==n||l==a}return E2=o,E2}var q2,HB;function p4t(){if(HB)return q2;HB=1;var e=Yl(),t=e["__core-js_shared__"];return q2=t,q2}var j2,KB;function m4t(){if(KB)return j2;KB=1;var e=p4t(),t=function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function n(r){return!!t&&t in r}return j2=n,j2}var C2,JB;function iwe(){if(JB)return C2;JB=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return C2=n,C2}var z2,eH;function g4t(){if(eH)return z2;eH=1;var e=zA(),t=m4t(),n=QO(),r=iwe(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,l=o.toString,c=s.hasOwnProperty,u=RegExp("^"+l.call(c).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function O(d){if(!n(d)||t(d))return!1;var f=e(d)?u:a;return f.test(r(d))}return z2=O,z2}var A2,tH;function $4t(){if(tH)return A2;tH=1;function e(t,n){return t?.[n]}return A2=e,A2}var U2,nH;function kf(){if(nH)return U2;nH=1;var e=g4t(),t=$4t();function n(r,i){var a=t(r,i);return e(a)?a:void 0}return U2=n,U2}var W2,rH;function Tk(){if(rH)return W2;rH=1;var e=kf(),t=e(Object,"create");return W2=t,W2}var Y2,iH;function y4t(){if(iH)return Y2;iH=1;var e=Tk();function t(){this.__data__=e?e(null):{},this.size=0}return Y2=t,Y2}var G2,aH;function v4t(){if(aH)return G2;aH=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return G2=e,G2}var N2,oH;function b4t(){if(oH)return N2;oH=1;var e=Tk(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function i(a){var o=this.__data__;if(e){var s=o[a];return s===t?void 0:s}return r.call(o,a)?o[a]:void 0}return N2=i,N2}var Z2,sH;function w4t(){if(sH)return Z2;sH=1;var e=Tk(),t=Object.prototype,n=t.hasOwnProperty;function r(i){var a=this.__data__;return e?a[i]!==void 0:n.call(a,i)}return Z2=r,Z2}var I2,lH;function S4t(){if(lH)return I2;lH=1;var e=Tk(),t="__lodash_hash_undefined__";function n(r,i){var a=this.__data__;return this.size+=this.has(r)?0:1,a[r]=e&&i===void 0?t:i,this}return I2=n,I2}var D2,cH;function x4t(){if(cH)return D2;cH=1;var e=y4t(),t=v4t(),n=b4t(),r=w4t(),i=S4t();function a(o){var s=-1,l=o==null?0:o.length;for(this.clear();++s<l;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,D2=a,D2}var V2,uH;function Q4t(){if(uH)return V2;uH=1;function e(){this.__data__=[],this.size=0}return V2=e,V2}var M2,OH;function AA(){if(OH)return M2;OH=1;function e(t,n){return t===n||t!==t&&n!==n}return M2=e,M2}var L2,dH;function _k(){if(dH)return L2;dH=1;var e=AA();function t(n,r){for(var i=n.length;i--;)if(e(n[i][0],r))return i;return-1}return L2=t,L2}var F2,fH;function k4t(){if(fH)return F2;fH=1;var e=_k(),t=Array.prototype,n=t.splice;function r(i){var a=this.__data__,o=e(a,i);if(o<0)return!1;var s=a.length-1;return o==s?a.pop():n.call(a,o,1),--this.size,!0}return F2=r,F2}var B2,hH;function P4t(){if(hH)return B2;hH=1;var e=_k();function t(n){var r=this.__data__,i=e(r,n);return i<0?void 0:r[i][1]}return B2=t,B2}var H2,pH;function T4t(){if(pH)return H2;pH=1;var e=_k();function t(n){return e(this.__data__,n)>-1}return H2=t,H2}var K2,mH;function _4t(){if(mH)return K2;mH=1;var e=_k();function t(n,r){var i=this.__data__,a=e(i,n);return a<0?(++this.size,i.push([n,r])):i[a][1]=r,this}return K2=t,K2}var J2,gH;function Xk(){if(gH)return J2;gH=1;var e=Q4t(),t=k4t(),n=P4t(),r=T4t(),i=_4t();function a(o){var s=-1,l=o==null?0:o.length;for(this.clear();++s<l;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,J2=a,J2}var eX,$H;function UA(){if($H)return eX;$H=1;var e=kf(),t=Yl(),n=e(t,"Map");return eX=n,eX}var tX,yH;function X4t(){if(yH)return tX;yH=1;var e=x4t(),t=Xk(),n=UA();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return tX=r,tX}var nX,vH;function R4t(){if(vH)return nX;vH=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return nX=e,nX}var rX,bH;function Rk(){if(bH)return rX;bH=1;var e=R4t();function t(n,r){var i=n.__data__;return e(r)?i[typeof r=="string"?"string":"hash"]:i.map}return rX=t,rX}var iX,wH;function E4t(){if(wH)return iX;wH=1;var e=Rk();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return iX=t,iX}var aX,SH;function q4t(){if(SH)return aX;SH=1;var e=Rk();function t(n){return e(this,n).get(n)}return aX=t,aX}var oX,xH;function j4t(){if(xH)return oX;xH=1;var e=Rk();function t(n){return e(this,n).has(n)}return oX=t,oX}var sX,QH;function C4t(){if(QH)return sX;QH=1;var e=Rk();function t(n,r){var i=e(this,n),a=i.size;return i.set(n,r),this.size+=i.size==a?0:1,this}return sX=t,sX}var lX,kH;function WA(){if(kH)return lX;kH=1;var e=X4t(),t=E4t(),n=q4t(),r=j4t(),i=C4t();function a(o){var s=-1,l=o==null?0:o.length;for(this.clear();++s<l;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,lX=a,lX}var cX,PH;function awe(){if(PH)return cX;PH=1;var e=WA(),t="Expected a function";function n(r,i){if(typeof r!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var a=function(){var o=arguments,s=i?i.apply(this,o):o[0],l=a.cache;if(l.has(s))return l.get(s);var c=r.apply(this,o);return a.cache=l.set(s,c)||l,c};return a.cache=new(n.Cache||e),a}return n.Cache=e,cX=n,cX}var uX,TH;function z4t(){if(TH)return uX;TH=1;var e=awe(),t=500;function n(r){var i=e(r,function(o){return a.size===t&&a.clear(),o}),a=i.cache;return i}return uX=n,uX}var OX,_H;function A4t(){if(_H)return OX;_H=1;var e=z4t(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(t,function(o,s,l,c){a.push(l?c.replace(n,"$1"):s||o)}),a});return OX=r,OX}var dX,XH;function YA(){if(XH)return dX;XH=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,a=Array(i);++r<i;)a[r]=n(t[r],r,t);return a}return dX=e,dX}var fX,RH;function U4t(){if(RH)return fX;RH=1;var e=iv(),t=YA(),n=Wa(),r=pm(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(s){if(typeof s=="string")return s;if(n(s))return t(s,o)+"";if(r(s))return a?a.call(s):"";var l=s+"";return l=="0"&&1/s==-1/0?"-0":l}return fX=o,fX}var hX,EH;function owe(){if(EH)return hX;EH=1;var e=U4t();function t(n){return n==null?"":e(n)}return hX=t,hX}var pX,qH;function swe(){if(qH)return pX;qH=1;var e=Wa(),t=CA(),n=A4t(),r=owe();function i(a,o){return e(a)?a:t(a,o)?[a]:n(r(a))}return pX=i,pX}var mX,jH;function Ek(){if(jH)return mX;jH=1;var e=pm();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return mX=t,mX}var gX,CH;function GA(){if(CH)return gX;CH=1;var e=swe(),t=Ek();function n(r,i){i=e(i,r);for(var a=0,o=i.length;r!=null&&a<o;)r=r[t(i[a++])];return a&&a==o?r:void 0}return gX=n,gX}var $X,zH;function lwe(){if(zH)return $X;zH=1;var e=GA();function t(n,r,i){var a=n==null?void 0:e(n,r);return a===void 0?i:a}return $X=t,$X}var W4t=lwe();const Lo=Vn(W4t);var yX,AH;function Y4t(){if(AH)return yX;AH=1;function e(t){return t==null}return yX=e,yX}var G4t=Y4t();const Gt=Vn(G4t);var vX,UH;function N4t(){if(UH)return vX;UH=1;var e=tu(),t=Wa(),n=nu(),r="[object String]";function i(a){return typeof a=="string"||!t(a)&&n(a)&&e(a)==r}return vX=i,vX}var Z4t=N4t();const tf=Vn(Z4t);var I4t=zA();const Dt=Vn(I4t);var D4t=QO();const mm=Vn(D4t);var bX={exports:{}},Yn={};/**
|
|
822
|
+
`).map(f=>f.trim()).filter(Boolean)}),"aria-label":`${e.label}: ${u}`,className:"font-mono text-body-sm"})]},u)),h.jsx("p",{className:"text-meta text-ink-dim",children:"One hop per line, as provider/model (effort). An empty chain moves to the next provider."})]})}default:return h.jsx(po,{value:t,disabled:r,onChange:c=>i(c.target.value),"aria-label":e.label,placeholder:e.placeholder})}},T1e=({className:e})=>h.jsx("span",{role:"img","aria-label":"Changed from the default",title:"Changed from the default",className:j("size-1.5 shrink-0 rounded-full bg-accent",e)}),u2t=({title:e,rowCount:t,advancedCount:n,scope:r,modified:i,onOpenChange:a,defaultOpen:o=!1})=>h.jsx("div",{"data-section-header":e,className:"flex w-full flex-col",children:h.jsx(Bo,{defaultOpen:o,onOpenChange:a,triggerClassName:"text-ink hover:bg-row-hover hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-10 py-0",className:"w-full",summary:h.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[h.jsx("span",{className:"truncate text-heading text-ink",children:e}),t>0&&h.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:t===1?"1 setting":`${t} settings`}),r&&h.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:r}),n>0&&h.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[n," advanced"]})]}),i&&h.jsx(T1e,{className:"ml-auto"})]})})}),O2t="size-3.5 shrink-0",d2t=({setting:e,draft:t,tier:n,gate:r,saving:i,error:a,onDraftChange:o,onSave:s,onReset:l,effectiveHosting:c=""})=>{const u=!!(r&&!r.on),O=sw(e,t),d=i||u,f=e.kind==="list"||e.kind==="cascade",p=h.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[h.jsx("span",{className:"truncate text-body-sm text-ink",children:e.label}),e.kind==="readonly"&&h.jsx("span",{className:"text-meta text-ink-dim",children:"Read-only"}),e.warning&&h.jsx("span",{className:"text-meta text-danger",children:e.warning})]}),m=u&&r&&h.jsxs("p",{className:"text-meta text-ink-dim",children:["Needs ",r.label," on. Nothing here is saved while it is off."]});return h.jsx("div",{"data-setting-key":e.key,"data-tier":n,className:"border-b border-hairline",children:h.jsxs("div",{className:"flex flex-wrap items-start gap-x-4 gap-y-1 px-1 py-2.5",children:[h.jsxs("div",{className:j("flex min-w-44 flex-col gap-0.5",f?"shrink-0 basis-2/5":"flex-1"),children:[n==="advanced"&&e.help?h.jsx(Bo,{summary:p,triggerClassName:"min-h-5 py-0 px-0 text-body-sm text-ink hover:text-ink",chevronClassName:"text-ink-dim",summaryAlign:"firstLine",rowClassName:"min-h-5 py-0",className:"w-full",children:h.jsx("span",{className:"text-meta text-ink-dim",children:e.help})}):h.jsxs("span",{className:"flex min-h-5 items-center gap-1.5",children:[h.jsx("span",{"aria-hidden":!0,className:O2t}),p]}),n==="core"&&e.help&&h.jsx("p",{id:fB(e.key),className:"ml-5 text-meta text-ink-dim",children:e.help}),m]}),h.jsxs("div",{className:j("flex shrink-0 items-center gap-2 self-center",f&&"min-w-0 flex-1 items-start"),children:[(!e.is_default||O)&&h.jsx(T1e,{}),!e.is_default&&e.kind!=="readonly"&&h.jsxs(Ve,{variant:"ghost",size:"sm",disabled:d,onClick:l,"aria-label":`Use default for ${e.label}`,children:[h.jsx(pCe,{"aria-hidden":"true"}),"Use default"]}),O&&h.jsx(Ve,{variant:"primary",size:"sm",disabled:d,onClick:s,children:i?"Saving":"Save"}),h.jsx("div",{className:t2t(e.kind),"data-setting-control":"",children:e.redacted?h.jsx("span",{className:"text-meta text-ink-dim",children:"Set in the credential manager: this value carries inline credentials or query parameters."}):e.kind==="readonly"?h.jsx("span",{className:"text-body-sm text-ink-muted",children:bp(e.value)||"Not set"}):h.jsx(c2t,{setting:e,value:t.value,chains:t.cascadeBase??void 0,disabled:d,effectiveHosting:c,helpId:n==="core"&&e.help?fB(e.key):void 0,onValueChange:g=>o({...t,value:g}),onChainsChange:g=>o({...t,cascadeBase:g})})})]}),a&&h.jsx(xc,{variant:"danger",role:"alert",className:"w-full",children:h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{children:a}),h.jsxs(Ve,{variant:"secondary",size:"sm",disabled:i,onClick:s,children:[h.jsx(v6,{"aria-hidden":"true"}),"Retry"]})]})})]})})},f2t="w-full max-w-[400px]",h2t=({query:e,onQueryChange:t,matchCount:n,matchSections:r,coreCount:i,advancedCount:a,modifiedCount:o,modifiedOnly:s,onModifiedOnlyChange:l,showAdvanced:c,onShowAdvancedChange:u,onExpandAll:O,onCollapseAll:d,unsavedCount:f,savingAll:p,onSaveAll:m,onDiscardAll:g})=>h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[h.jsxs("div",{className:j("relative",f2t),children:[h.jsx(Xy,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),h.jsx(po,{value:e,onChange:$=>t($.target.value),onKeyDown:$=>{$.key==="Escape"&&e&&t("")},placeholder:"Search settings by name, description or key","aria-label":"Search settings",className:"pl-9"}),e&&h.jsx(Ve,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>t(""),"aria-label":"Clear search",children:h.jsx(Ri,{"aria-hidden":"true"})})]}),h.jsxs("fieldset",{className:"m-0 border-0 p-0",children:[h.jsx("legend",{className:"sr-only",children:"Settings filters"}),h.jsxs("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:[h.jsxs(Ve,{variant:"ghost",size:"sm","aria-pressed":s,onClick:()=>l(!s),className:j(s&&"bg-surface text-ink hover:bg-surface"),children:["Modified",h.jsx(vd,{variant:"neutral",children:o})]}),h.jsx(Ve,{variant:"ghost",size:"sm","aria-pressed":c,onClick:()=>u(!c),className:j(c&&"bg-surface text-ink hover:bg-surface"),children:"Show advanced"})]})]}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[f>0&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-meta text-ink-dim",children:f===1?"1 unsaved change":`${f} unsaved changes`}),h.jsx(Ve,{variant:"primary",size:"sm",disabled:p,onClick:m,children:p?"Saving":"Save all"}),h.jsx(Ve,{variant:"ghost",size:"sm",disabled:p,onClick:g,children:"Discard all"})]}),h.jsx(Ve,{variant:"ghost",size:"sm",onClick:O,children:"Expand all"}),h.jsx(Ve,{variant:"ghost",size:"sm",onClick:d,children:"Collapse all"})]})]}),h.jsx("p",{className:"text-meta text-ink-dim","aria-live":"polite",children:n!==null?`${n} ${n===1?"result":"results"} in ${r} ${r===1?"section":"sections"}`:s?`${o} modified ${o===1?"setting":"settings"}`:c?`${a} advanced settings shown — Expand all to see them`:`${i} core settings, ${a} advanced`})]}),RA={all:["desktop","settings"]},p2t={live:"Takes effect immediately","new launch":"Takes effect the next time the app starts","new sessions":"Takes effect for new conversations"},m2t=40,nh=e=>e.toLowerCase().replace(/[-_.]/g," "),Qen=({focusKey:e,initialFilter:t=""})=>{const n=ga(),r=$1e(),i=gi(n.data,"settings"),[a,o]=y.useState(t),[s,l]=y.useState(!1),[c,u]=y.useState(!1),[O,d]=y.useState({}),[f,p]=y.useState({}),[m,g]=y.useState({}),[$,v]=y.useState(!1),[w,x]=y.useState(new Set),[b,S]=y.useState(new Set),[Q,P]=y.useState(new Set),R=y.useRef(null),_=y.useRef(null),E=Yt({queryKey:RA.all,queryFn:()=>Xe({op:"settings.list"}),enabled:i,staleTime:1e4}),C=E.data;y.useEffect(()=>{C&&d(ae=>{let fe=!1;const Te={...ae};for(const _e of C.settings){const ut=ae[_e.key];if(!ut){Te[_e.key]=Fl(_e),fe=!0;continue}if(sw(_e,ut))continue;const St=Fl(_e);(St.value!==ut.value||St.cascadeBase!==ut.cascadeBase)&&(Te[_e.key]=St,fe=!0)}return fe?Te:ae})},[C]);const W=y.useCallback(ae=>!ae.is_default||sw(ae,O[ae.key]??Fl(ae)),[O]),U=y.useMemo(()=>{const ae=(C?.settings??[]).find(fe=>fe.key==="hosting");return ae?(O.hosting??Fl(ae)).value:""},[C,O]),Y=y.useMemo(()=>{if(!C)return[];const ae=nh(a.trim()),fe=ae.length>0||c;return C.settings.filter(Te=>!fe&&rd(Te)==="advanced"&&!s||c&&!W(Te)?!1:ae?nh([Te.label,Te.help,Te.key,Te.section,Te.warning??""].join(" ")).includes(ae):!0)},[C,a,s,c,W]),V=a.trim().length>0||c,M=y.useMemo(()=>C?.sections??[],[C]),B=y.useCallback(ae=>(C?.settings??[]).filter(fe=>fe.section===ae),[C]),G=ae=>Y.filter(fe=>fe.section===ae),A=ae=>w.has(ae)?!0:b.has(ae)?!1:m_t(B(ae)),ee=(ae,fe)=>{x(Te=>{const _e=new Set(Te);return fe?_e.add(ae):_e.delete(ae),_e}),S(Te=>{const _e=new Set(Te);return fe?_e.delete(ae):_e.add(ae),_e})},K=(ae,fe)=>{P(Te=>{const _e=new Set(Te);return fe?_e.delete(ae):_e.add(ae),_e})},z=ae=>{const fe=M.filter(_e=>ae||G(_e.name).length>0).map(_e=>_e.name),Te=g_t(ae,V,fe);Te.layout&&(x(new Set(Te.layout.opened)),S(new Set(Te.layout.closed))),P(new Set(Te.filter))};y.useEffect(()=>{a.trim()||P(new Set)},[a]);const le=y.useCallback(ae=>{const fe=ae.gated_by;if(!fe||!C)return null;const Te=C.settings.find(_e=>_e.key===fe);return{key:fe,label:Te?.label??fe,on:Te?.value===!0||Te?.value==="true"}},[C]),L=y.useCallback((ae,fe)=>p(Te=>({...Te,[ae]:fe})),[]),Z=y.useCallback((ae,fe)=>g(Te=>({...Te,[ae]:fe})),[]),ne=y.useCallback(async ae=>{const fe=O[ae.key];if(!fe)return!1;const Te=$_t(ae,fe);if(!Te.ok)return Z(ae.key,Te.error),!1;L(ae.key,!0),Z(ae.key,null);try{await Xe(Te.request),L(ae.key,!1);const ut=(await E.refetch()).data?.settings.find(St=>St.key===ae.key);return ut&&d(St=>{const bt=St[ae.key];return bt&&bt.value===fe.value&&bt.cascadeBase===fe.cascadeBase?{...St,[ae.key]:Fl(ut)}:St}),!0}catch(_e){return L(ae.key,!1),Z(ae.key,_e instanceof Error?_e.message:"The setting could not be saved."),!1}},[O,E,L,Z]),te=y.useCallback(async ae=>{L(ae.key,!0),Z(ae.key,null);try{await Xe({op:"settings.reset",key:ae.key}),d(fe=>({...fe,[ae.key]:Fl({...ae,value:ae.default,is_default:!0})})),L(ae.key,!1),await E.refetch()}catch(fe){L(ae.key,!1),Z(ae.key,fe instanceof Error?fe.message:"The setting could not be reset.")}},[E,L,Z]),ie=y.useMemo(()=>(C?.settings??[]).filter(ae=>sw(ae,O[ae.key]??Fl(ae))),[C,O]),$e=async()=>{v(!0);for(const ae of ie)await ne(ae);v(!1)},je=()=>{C&&(d(ae=>{const fe={...ae};for(const Te of C.settings)fe[Te.key]=Fl(Te);return fe}),g({}))};y.useEffect(()=>{if(!e||!C||R.current===e)return;const ae=C.settings.find(_e=>_e.key===e);if(!ae)return;R.current=e,rd(ae)==="advanced"&&l(!0);const fe=nh(a.trim());!fe||nh([ae.label,ae.help,ae.key,ae.section].join(" ")).includes(fe)||o(""),u(!1),x(_e=>new Set(_e).add(ae.section)),S(_e=>{const ut=new Set(_e);return ut.delete(ae.section),ut})},[e,C,a]);const Oe=y.useMemo(()=>{if(!e||!C)return!1;const ae=C.settings.find(Te=>Te.key===e);if(!ae||rd(ae)==="advanced"&&!s)return!1;const fe=nh(a.trim());return fe?nh([ae.label,ae.help,ae.key,ae.section].join(" ")).includes(fe):!0},[e,C,a,s]);if(y.useEffect(()=>{if(!Oe||!e||_.current===e)return;let ae=0,fe=0;const Te=()=>{const _e=document.querySelector(`[data-setting-key="${CSS.escape(e)}"]`),ut=_e?.querySelector('[data-setting-control] :is(input, textarea, select, button[role="switch"], button)')??_e;if(ut){ut===_e&&(ut.tabIndex=-1),ut.focus(),ut.scrollIntoView({block:"center"}),_.current=e;return}fe+=1,fe<m2t&&(ae=requestAnimationFrame(Te))};return ae=requestAnimationFrame(Te),()=>cancelAnimationFrame(ae)},[Oe,e]),n.data&&!i)return h.jsx(xc,{variant:"warning",children:"Searchable settings need a newer Local Operator server. Update the server and restart the app to manage these settings here."});if(E.isLoading||n.isLoading)return h.jsx("div",{className:"flex h-40 items-center justify-center",children:h.jsx(Fo,{size:"lg",label:"Loading settings"})});const Fe=(n.data?null:n.error)??E.error;if(Fe||!C){const ae=n.isFetching||E.isFetching,{sentence:fe,remedy:Te}=_7e(r??null,"Your settings could not be loaded.",Fe);return h.jsx(xc,{variant:"warning",children:h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{children:fe}),Te&&h.jsx(Ve,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{n.isError?n.refetch():E.refetch()},disabled:ae,children:ae?"Retrying":"Retry"})]})})}const ze=C.settings.reduce((ae,fe)=>(ae[rd(fe)]+=1,ae),{core:0,advanced:0}),ft=new Set(Y.map(ae=>ae.section)).size;return h.jsxs("div",{className:"flex flex-col gap-4",children:[h.jsx(h2t,{query:a,onQueryChange:o,matchCount:a.trim()?Y.length:null,matchSections:ft,coreCount:ze.core,advancedCount:ze.advanced,modifiedCount:C.settings.filter(W).length,modifiedOnly:c,onModifiedOnlyChange:u,showAdvanced:s,onShowAdvancedChange:l,onExpandAll:()=>z(!0),onCollapseAll:()=>z(!1),unsavedCount:ie.length,savingAll:$,onSaveAll:()=>void $e(),onDiscardAll:je}),V&&Y.length===0&&h.jsx("div",{className:"flex flex-col items-center py-6 text-center",children:h.jsx("p",{className:"text-body-sm text-ink-muted",children:"No settings match this search. Clear the search field to see every setting again."})}),h.jsx("div",{className:"flex flex-col gap-1",children:M.map(ae=>{const fe=G(ae.name),Te=B(ae.name),_e=V?0:Te.filter(St=>rd(St)==="advanced").length;if(V&&fe.length===0)return null;const ut=V?fe.length>0&&!Q.has(ae.name):A(ae.name);return h.jsxs("section",{"data-settings-section":ae.name,"data-open":ut,className:"flex flex-col",children:[h.jsx(u2t,{title:ae.title,rowCount:fe.length,advancedCount:_e,scope:p2t[ae.scope],modified:Te.some(W),defaultOpen:ut,onOpenChange:St=>V?K(ae.name,St):ee(ae.name,St)},`${ae.name}:${ut?"open":"closed"}`),h.jsxs("div",{hidden:!ut,className:"flex flex-col pb-3",children:[ae.description&&h.jsx("p",{className:"px-1 pb-1 text-meta text-ink-dim",children:ae.description}),fe.length===0?h.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[h.jsx("p",{className:"text-body-sm text-ink-muted",children:_e>0?"Advanced settings are hidden here.":"Nothing in this section matches."}),_e>0&&h.jsxs(Ve,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:["Show ",_e," advanced"]})]}):fe.map(St=>h.jsx(d2t,{setting:St,draft:O[St.key]??Fl(St),tier:rd(St),gate:le(St),effectiveHosting:U,saving:!!f[St.key],error:m[St.key]??null,onDraftChange:bt=>d(he=>({...he,[St.key]:bt})),onSave:()=>void ne(St),onReset:()=>void te(St)},St.key))]})]},ae.name)})})]})},g2t="display.hide_cross_session";function $2t(){const e=ga(),t=gi(e.data,"settings");return Yt({queryKey:RA.all,queryFn:()=>Xe({op:"settings.list"}),enabled:t,staleTime:1e4}).data?.settings.find(i=>i.key===g2t)?.value===!0}const y2t=1200,v2t=120,pB=8,mB=(e,t)=>e===null||!t?null:Math.max(0,t()-e);function b2t({containerRef:e,sessionKey:t,hiddenRows:n,hasMore:r,hydrationProven:i,historyReadPending:a,onWiden:o,onLoadOlder:s,onLoadOlderOutcome:l,olderFailed:c=!1,loadingOlder:u,contentKey:O,rowCount:d,paintedRows:f}){const p=y.useRef(eB()),m=y.useRef(0),[g,$]=y.useState(!1),[v,w]=y.useState(!1),x=y.useRef({hiddenRows:n,hasMore:r,onWiden:o,onLoadOlder:s,onLoadOlderOutcome:l,paintedRows:f});x.current={hiddenRows:n,hasMore:r,onWiden:o,onLoadOlder:s,onLoadOlderOutcome:l,paintedRows:f};const b=y.useRef({sample:null,until:0,inputRevision:0}),S=y.useRef(null),Q=y.useCallback((L,Z)=>{Z!==L&&(S.current=Z)},[]),P=y.useRef({fromTail:0,at:0,extent:0,clamped:!1,revision:0}),R=y.useRef(0),_=y.useRef(0),E=y.useRef(0),C=y.useCallback(()=>{const L=e.current;if(!L)return null;const{scrollTop:Z,scrollHeight:ne,clientHeight:te}=L,ie=Math.abs(Z);return{distanceFromTopPx:Math.max(0,ne-te-ie),clientHeight:te,hiddenRows:x.current.hiddenRows,hasMore:x.current.hasMore,scrollable:ne-te>1,followingTail:ie<=f2}},[e]),W=y.useCallback(()=>{const L=e.current;if(!L)return null;const Z=L.getBoundingClientRect().top;for(const ne of L.querySelectorAll("[data-record-id]")){const te=ne.getBoundingClientRect();if(te.bottom>Z){const ie=ne.dataset.recordId;if(!ie)continue;return{id:ie,viewportOffset:te.top-Z,extent:L.scrollHeight}}}return null},[e]),U=y.useCallback(L=>{const Z=e.current;if(!Z)return null;const ne=Z.querySelector(`[data-record-id="${CSS.escape(L)}"]`);return ne?{id:L,viewportOffset:ne.getBoundingClientRect().top-Z.getBoundingClientRect().top,extent:Z.scrollHeight}:null},[e]),Y=y.useCallback(()=>{const L=e.current;if(!L||b.current.sample!==null&&Number.isFinite(b.current.until)&&performance.now()<=b.current.until)return;if(Math.abs(L.scrollTop)<=f2){b.current={sample:null,until:0,inputRevision:0};return}const Z=W();Z&&(b.current={sample:Z,until:Number.POSITIVE_INFINITY,inputRevision:P.current.revision})},[e,W]),V=y.useCallback(()=>{const L=e.current,Z=b.current.sample;if(!L||!Z)return;if(Math.abs(L.scrollTop)<=f2){b.current={sample:null,until:0,inputRevision:0};return}const ne=F5t(Z,U(Z.id),b.current.inputRevision,P.current.revision);if(ne===null){b.current.sample=null;return}const te=performance.now()>b.current.until;if(ne!==0&&(L.scrollTop+=ne,S.current=L.scrollTop),te){Y();return}ne!==0&&(b.current.sample={...Z,extent:L.scrollHeight})},[e,U,Y]),M=y.useCallback(()=>{b.current={sample:W(),until:performance.now()+y2t,inputRevision:P.current.revision}},[W]),B=y.useCallback(L=>(L.chainInvisible===0&&w(!0),L),[]),G=y.useCallback(()=>{R.current||(R.current=requestAnimationFrame(()=>{R.current=0;const L=C();if(!L)return;const{action:Z,state:ne}=V5t(p.current,L,performance.now());p.current=ne;const te=c1e(L);if($(Z!=="none"||ne.busy||ne.pageWidenOwed||ne.armed&&te.inZone),Z==="none"){(ne.armed||ne.pageWidenOwed)&&!_.current&&(_.current=window.setTimeout(()=>{_.current=0,G()},Sh));return}if(M(),Z==="widen"){const Fe=x.current.hiddenRows,ze=x.current.paintedRows?.()??null;x.current.onWiden();const ft=m.current;let ae=0;const fe=()=>{if(m.current===ft){if(x.current.hiddenRows!==Fe||ae>=pB){p.current=B(tB(p.current,{network:!1,hiddenRowsAfter:x.current.hiddenRows,paintedDelta:mB(ze,x.current.paintedRows)})),G();return}ae+=1,requestAnimationFrame(fe)}};requestAnimationFrame(fe);return}const ie=x.current.paintedRows?.()??null,$e=W(),je=async()=>{try{return x.current.onLoadOlderOutcome?await x.current.onLoadOlderOutcome():await x.current.onLoadOlder()?{kind:"applied",newRecords:0,exhausted:!1}:{kind:"failed",reason:"request"}}catch(Fe){return console.warn("older history load was rejected:",Fe),{kind:"failed",reason:"request"}}},Oe=m.current;je().then(Fe=>{if(m.current!==Oe)return;if(Fe.kind==="failed"){p.current=M5t(p.current),w(!1),requestAnimationFrame(G);return}if(Fe.kind!=="applied"){p.current=L5t(p.current),requestAnimationFrame(G);return}const ze=m.current;let ft=0;const ae=()=>{if(m.current!==ze)return;const fe=x.current.hiddenRows;if(fe>0||ft>=pB){const Te=e.current,_e=$e===null?null:U($e.id);p.current=B(tB(p.current,{hiddenRowsAfter:fe,paintedDelta:mB(ie,x.current.paintedRows),growthPx:$e===null?null:Math.max(0,u1e($e,_e)),clientHeight:Te?.clientHeight??0,newRecords:Fe.newRecords})),G();return}ft+=1,requestAnimationFrame(ae)};requestAnimationFrame(ae)})}))},[M,C,W,U,B]),A=y.useCallback((L,Z,ne=!1)=>{const te=e.current,ie=performance.now(),je=(C()?.distanceFromTopPx??Number.POSITIVE_INFINITY)<=kA,Oe=P.current,Fe=Oe.at===0,ze=te?Math.abs(te.scrollTop):Oe.fromTail,ft=te?te.scrollHeight:Oe.extent,ae=Oe.clamped&&ft>Oe.extent?ft-Oe.extent:0,fe=Fe?0:ze-Oe.fromTail-ae;P.current={fromTail:ze,at:ie,extent:ft,clamped:je,revision:Oe.revision},p.current=D5t(p.current,{direction:L,continuous:Z,deliberate:ne,atHardTop:je,at:ie,travelledPx:Math.max(0,fe)}),P.current={...P.current,revision:P.current.revision+1},ne&&M(),ne||(b.current.sample=null,b.current.until=0),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(Y,Sh),G()},[e,M,C,Y,G]),ee=y.useCallback(()=>{A("up",!1,!0)},[A]);y.useEffect(()=>{p.current=eB(),m.current+=1,b.current={sample:null,until:0,inputRevision:P.current.revision},P.current={fromTail:0,at:0,extent:0,clamped:!1,revision:P.current.revision+1},$(!1),w(!1),p.current={...p.current,continuation:!0},G()},[t]),y.useEffect(()=>{c&&w(!1)},[c]),y.useEffect(()=>{const L=e.current;if(!L)return;let Z=0,ne=Math.abs(L.scrollTop);const te=ze=>{ze.deltaY!==0&&A(ze.deltaY<0?"up":"down",!0)},ie=()=>{const ze=Math.abs(L.scrollTop);ze!==ne&&(A(ze>ne?"up":"down",!0),ne=ze)},$e=ze=>{if(!ze.defaultPrevented)switch(ze.key){case"Home":A("up",!1,!0);break;case"ArrowUp":case"PageUp":A("up",!1);break;case"ArrowDown":case"PageDown":case"End":A("down",!1);break}},je=()=>{Z=Number.POSITIVE_INFINITY},Oe=()=>{Z===Number.POSITIVE_INFINITY&&(Z=performance.now()+v2t)},Fe=()=>{const ze=Math.abs(L.scrollTop),ft=ze-ne;if(ne=ze,S.current!==null){const ae=Math.abs(L.scrollTop-S.current)<=1;if(S.current=null,ae)return}if(E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(Y,Sh),ft!==0&&performance.now()<=Z){A(ft>0?"up":"down",!0);return}G()};return L.addEventListener("wheel",te,{passive:!0}),L.addEventListener("touchmove",ie,{passive:!0}),L.addEventListener("keydown",$e),L.addEventListener("scroll",Fe,{passive:!0}),L.addEventListener("pointerdown",je),window.addEventListener("pointerup",Oe),()=>{L.removeEventListener("wheel",te),L.removeEventListener("touchmove",ie),L.removeEventListener("keydown",$e),L.removeEventListener("scroll",Fe),L.removeEventListener("pointerdown",je),window.removeEventListener("pointerup",Oe),R.current&&cancelAnimationFrame(R.current),R.current=0,_.current&&clearTimeout(_.current),_.current=0,E.current&&clearTimeout(E.current),E.current=0}},[e,A,Y,G]),y.useEffect(()=>{const L=e.current,Z=L?.querySelector("[data-lo-transcript-content]");if(!L||!Z)return;const ne=new ResizeObserver(()=>{V(),G()});return ne.observe(Z),ne.observe(L),()=>ne.disconnect()},[e,V,G,O]),y.useEffect(()=>{G()},[G,n,r]),y.useLayoutEffect(()=>{V()});const K=u||g?"loading":c&&!v?"failed":n>0?"windowed":r?"idle":i?"exhausted":a?"loading":"unproven",z=y.useCallback(()=>performance.now()-p.current.lastInputAt<Sh?!1:C()?.followingTail===!0,[C]),le=y.useCallback(()=>C()?.followingTail===!0,[C]);return{slotState:K,requestOlder:ee,mayAutoWalk:z,followingTail:le,acknowledgeOwnWrite:Q}}function w2t(){const e=ga(),t=gi(e.data,"settings"),n=Yt({queryKey:RA.all,queryFn:()=>Xe({op:"settings.list"}),enabled:t,staleTime:1e4});return t?NTt(n.data?.settings):!1}const gB=60,$B=60,g2=300;function S2t(e){const t=[];e.facts.durationS!==null&&t.push(`took ${uf(e.facts.durationS)}`),e.facts.actions>0&&t.push(e.facts.actions===1?"1 action":`${e.facts.actions} actions`);const n=e.label??"Turn condensed";return t.length===0?`${n}.`:`${n}: ${t.join(", ")}.`}function x2t(e){const t=new Set;for(const n of e)for(const r of n.recordIds)t.add(r);return t}const Q2t=y.memo(function({record:t,isSmallView:n,scope:r,conversationId:i,undelivered:a=null}){const o=y.useRef(null),s=Hbe(o),{replies:l,remainingContent:c}=y.useMemo(()=>$A(t.text),[t.text]),[u,O]=y.useState(!1),[d,f]=y.useState(!1),p=y.useRef(null);return y.useLayoutEffect(()=>{if(u)return;const m=p.current;m&&f(m.scrollHeight>m.clientHeight+1)},[u,c]),h.jsx(qs,{isUser:!0,isSmallView:n,children:h.jsxs("div",{className:j("group flex w-full flex-col items-end gap-1"),children:[h.jsxs("div",{ref:o,className:"group relative flex w-full justify-end",children:[h.jsx("div",{className:j("relative rounded-frame bg-message-surface text-ink break-words",a!==null&&"border-l border-danger",n?"max-w-[92%] px-3 py-2.5":"max-w-[85%] px-3 py-2.5"),children:h.jsxs("div",{ref:p,className:j("relative",!u&&d?"max-h-[174px] overflow-hidden":""),children:[l.length>0&&h.jsx(mA,{replies:l}),h.jsx(kk,{content:c,credentialCitations:!0}),d&&h.jsx("button",{type:"button",onClick:()=>O(m=>!m),"aria-expanded":u,className:j("mt-1 h-[30px] w-full text-center text-ink-muted text-meta","hover:text-ink"),children:u?"Show less":"Show more"}),t.images.length>0&&h.jsx("div",{className:j("mt-2 flex flex-col gap-2"),children:t.images.map((m,g)=>h.jsx(yA,{image:m,scope:r,label:t.images.length===1?"Attached image":`Attached image ${g+1}`},m.id))})]})}),i&&Lj(t,c)&&!s.quoteAvailable&&h.jsx(r1e,{conversationId:i,turnRef:o}),i&&s.subject&&h.jsx(Jbe,{conversationId:i,turnRef:o,subject:s.subject,quoteAvailable:s.quoteAvailable,onDismiss:s.dismiss})]}),Lj(t,c)&&h.jsx(t1e,{kind:"user",bodyText:c,revealId:t.id,revealAt:t.ts,conversationId:i,entryId:e1e(t)??void 0}),a!==null&&h.jsxs("div",{"data-undelivered":!0,className:j("flex w-full items-center justify-end gap-3 text-danger text-meta"),children:[h.jsxs("span",{className:j("flex items-center gap-1"),children:[h.jsx(Mh,{"aria-hidden":"true",className:j("size-3.5 shrink-0")}),a.message??"Not delivered"]}),a.retry!==!1&&h.jsx("button",{type:"button","aria-disabled":a.retryDisabled||void 0,className:j(a.retryDisabled?"text-ink-muted":"cursor-pointer underline"),onClick:m=>{if(a.retryDisabled){m.preventDefault();return}a.onSendAgain()},children:"Send again"}),h.jsx("button",{type:"button",className:j("cursor-pointer underline"),onClick:a.onEdit,children:"Edit"})]})]})})}),k2t=y.memo(function({record:t,isSmallView:n,closesTurn:r,answerRail:i,foot:a=null,closingLineSuppressed:o=!1,conversationId:s}){const l=y.useRef(null),c=Hbe(l),{replies:u,remainingContent:O}=y.useMemo(()=>$A(t.text),[t.text]);if(!Fu(t))return null;const d=t.stopReason==="refusal"||t.error,f=Lj(t,O);return h.jsxs(qs,{isUser:!1,isSmallView:n,children:[h.jsxs("div",{ref:l,className:j("relative break-words text-ink",ZTt(r,i)),"data-turn-answer":r||void 0,"aria-busy":t.streaming||void 0,"data-lo-streaming":t.streaming||void 0,"data-lo-truncated":t.truncated||void 0,children:[u.length>0&&h.jsx(mA,{replies:u}),t.truncated&&h.jsx("p",{className:j("mb-1 text-ink-dim text-meta"),children:t.truncated==="prefix"?"Earlier text of this answer is not on screen":"Part of this answer may be missing"}),t.streaming?h.jsx(Pbe,{content:O,className:j(d&&"[--md-ink:var(--lo-danger)]"),styleProps:{fontSize:n?"var(--text-body-sm)":"var(--text-body)",lineHeight:1.6}}):h.jsx(kk,{content:O,className:j(d&&"[--md-ink:var(--lo-danger)]"),styleProps:{fontSize:n?"var(--text-body-sm)":"var(--text-body)",lineHeight:1.6},linkify:!0}),t.stopReason==="aborted"&&h.jsx("p",{className:"mt-1 text-ink-dim text-meta",children:"Stopped before finishing"}),s&&f&&!c.quoteAvailable&&h.jsx(r1e,{conversationId:s,turnRef:l}),s&&c.subject&&h.jsx(Jbe,{conversationId:s,turnRef:l,subject:c.subject,quoteAvailable:c.quoteAvailable,onDismiss:c.dismiss})]}),r&&h.jsxs("div",{className:j("mt-1 flex items-center gap-2 text-meta"),children:[!o&&a&&a.actions>0&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:j("text-ink-dim"),children:a.durationS!==null?`Worked for ${uf(a.durationS)}`:"Worked"}),h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim"),children:"·"}),h.jsx("span",{className:j("text-ink-dim"),children:a.actions===1?"1 action":`${a.actions} actions`})]}),f&&h.jsx("span",{className:j("ml-auto flex shrink-0"),children:h.jsx(t1e,{bodyText:O,agentId:s,speechId:t.id,revealId:t.id,revealAt:t.ts,conversationId:s,entryId:e1e(t)??void 0})}),!o&&h.jsx("span",{className:j(!f&&"ml-auto"),children:h.jsx(_be,{timestamp:t.ts,scope:"answer"})})]})]})});function _1e(e){const t=e.phase==="composing",n=e.phase==="queued";return e.neverSent===!0||!!e.notRunReason?`never sent · ${e.argumentBytes?`${VP(e.argumentBytes)} composed`:"nothing composed"}`:t?`composing${e.argumentBytes?` · ${VP(e.argumentBytes)}`:""}`:n?`queued${e.argumentBytes?` · ${VP(e.argumentBytes)}`:""}`:v2e(e.toolName,e.args)}function P2t({state:e}){const t=h2e[e];return t?h.jsx("span",{"data-delivery-note":e,children:t}):null}const T2t=y.memo(function({record:t,isSmallView:n,scope:r,labelPending:i=!1,labelHoldLate:a=!1,labelMarked:o=!1}){const s=t.phase!=="done",l=t.phase==="composing",c=!!t.notRunReason,u=c&&B0(t.notRunKind),O=m2e(t.delivery)==="partial",d=_1e(t),f=!l&&fae(d,t.toolName)?S2e(t.output,i):null,p=c?h.jsxs("div",{className:j("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),"data-detail-section":"not-run",children:[h.jsx("span",{className:j("mb-1 block text-meta",u?"text-ink-dim":"text-danger"),children:u?"Interrupted":"Not run"}),h.jsx("div",{className:j(skt,"overflow-auto"),children:h.jsx("pre",{className:j("whitespace-pre font-mono",u?"text-ink":"text-danger"),children:t.notRunReason})})]}):X2e(t)?h.jsx(MQt,{diff:t.diff}):ikt(t.args,t.output)?h.jsx(ckt,{args:t.args,output:t.output,isError:CE(t.isError,t.delivery),interrupted:t.stopped===!0,note:t.delivery?h.jsx(P2t,{state:t.delivery}):void 0}):void 0,m=p?h.jsx(h.Fragment,{children:p}):void 0,g=t.images.length>0?h.jsx("div",{className:j("mt-1 ml-5 flex flex-col gap-2"),children:t.images.map(($,v)=>h.jsx(yA,{image:$,scope:r,label:t.images.length===1?"Image":`Image ${v+1}`},$.id))}):void 0;return h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:t.toolName,op:D7(t.args),summary:d,summaryFallback:f,summaryHold:o===!0||i===!0&&a===!0,outcome:c?B0(t.notRunKind)?"interrupted":"not-run":s?"running":O?"partial":t.isError?"error":t.stopped?"interrupted":"success",deliveryState:t.delivery,durationS:t.durationS,startedAt:t.startedAt,added:t.added,removed:t.removed,details:m,media:g})})}),yB=({action:e})=>h.jsx("div",{className:"mt-1 pl-6",children:h.jsx(Ve,{variant:"secondary",size:"sm",asChild:!0,children:h.jsx(lqe,{to:e.to,children:e.label})})}),_2t=y.memo(function({record:t,isSmallView:n}){if(t.kind==="custom"){const l=t.level==="error"?Mh:_je,c=FF({text:t.text,category:t.category,provider:t.provider});return h.jsxs(qs,{isUser:!1,isSmallView:n,children:[h.jsx(xF,{dense:!0,verbOverride:t.category??t.customType.replace(/_/g," "),object:t.provider??void 0,narration:t.headline,failed:t.level==="error",wrap:!0,glyph:h.jsx(l,{}),details:t.detail?h.jsx("p",{className:"whitespace-pre-wrap break-words text-body-sm text-ink-muted",children:t.detail}):void 0}),c?h.jsx(yB,{action:c}):null]})}const r=t.kind==="notice"?t.level:"info",i=r==="error"?Mh:r==="warning"?Tie:U7,{headline:a,rest:o}=Z8e(t.text),s=FF({text:t.text});return h.jsxs(qs,{isUser:!1,isSmallView:n,children:[h.jsx(xF,{dense:!o,verbOverride:a,failed:r==="error",wrap:!0,glyph:h.jsx(i,{}),details:o?h.jsx("p",{className:"whitespace-pre-wrap break-words text-body-sm text-ink-muted",children:o}):void 0}),Ile.test(t.text)?h.jsx("div",{className:"mt-1 pl-6",children:h.jsx(Ve,{variant:"secondary",size:"sm",onClick:()=>mQ.getState().openConnect(),children:"Connect a provider"})}):null,s?h.jsx(yB,{action:s}):null]})}),X2t=y.memo(function({record:t,isSmallView:n}){return D_e(t.sender,t.body)?h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"peer",summary:rW(t.sender,t.body),outcome:"receipt",durationS:null,details:h.jsxs("div",{className:j("flex flex-col gap-2 px-3"),children:[h.jsx("p",{className:j("text-body-sm text-ink-muted"),children:uae(t.sender)}),t.body?h.jsx("p",{className:j("whitespace-pre-wrap break-words text-body-sm text-ink"),children:t.body}):null]})})}):h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"peer",summary:rW(t.sender,t.body),outcome:"receipt",durationS:null})})}),R2t=y.memo(function({record:t,isSmallView:n}){if(t.kind==="ask_timeout")return h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"ask",verbless:!0,summary:Ize(t),outcome:"receipt",durationS:null})});const r=Zze(t);return t.questions.length===0?h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"ask",verbless:!0,summary:r,outcome:"receipt",durationS:null})}):h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"ask",verbless:!0,summary:r,outcome:"receipt",durationS:null,details:h.jsxs("div",{className:j("flex flex-col gap-2 px-3"),children:[t.secretLost?h.jsx("p",{className:j("text-body-sm text-warning"),children:"The session no longer holds the credential this answer named."}):null,t.questions.map(i=>h.jsxs("div",{className:j("flex flex-col gap-0.5"),children:[h.jsx("p",{className:j("text-body-sm text-ink-muted"),children:i.question}),h.jsx("p",{className:j("whitespace-pre-wrap break-words text-body-sm text-ink"),children:(t.answers[i.id]??[]).length>0?(t.answers[i.id]??[]).join(", "):"No answer given"})]},i.id))]})})})}),E2t=y.memo(function({record:t,isSmallView:n}){const r=t2e(t.text);return h.jsx(qs,{isUser:!1,isSmallView:n,children:h.jsx(_d,{toolName:"wake",summary:e2e(t.text),outcome:"receipt",durationS:null,details:r?h.jsx("p",{className:j("whitespace-pre-wrap break-words px-3 text-body-sm text-ink-dim"),children:r}):void 0})})}),vB=new WeakMap,X1e=e=>{if(e.gap==="trace")return e;let t=vB.get(e);return t||(t={...e,gap:"trace"},vB.set(e,t)),t},e1=new WeakMap,q2t=e=>{if(e.kind==="row"){const n=X1e(e.row);if(n===e.row)return e;let r=e1.get(e);return r||(r={...e,row:n},e1.set(e,r)),r}if(e.gap==="trace")return e;let t=e1.get(e);return t||(t={...e,gap:"trace"},e1.set(e,t)),t},t1=new WeakMap,j2t=e=>{if(e.kind==="row"){if(e.row.gap!=="trace")return e;let n=t1.get(e);return n||(n={...e,row:{...e.row,gap:"item"}},t1.set(e,n)),n}if(e.gap!=="trace")return e;let t=t1.get(e);return t||(t={...e,gap:"item"},t1.set(e,t)),t},bB=y.memo(function({row:t,isSmallView:n,scope:r,conversationId:i,answerRail:a=!1,foot:o=null,closingLineSuppressed:s=!1,labelPending:l=!1,undelivered:c=null,labelHoldLate:u=!1,labelMarked:O=!1}){const{record:d}=t;let f;switch(d.kind){case"user":f=h.jsx(Q2t,{record:d,isSmallView:n,scope:r,conversationId:i,undelivered:c?.recordId===d.id?c:null});break;case"assistant":f=h.jsx(k2t,{record:d,isSmallView:n,closesTurn:t.closesTurn,answerRail:a,foot:o,closingLineSuppressed:s,conversationId:i});break;case"tool":f=h.jsx(T2t,{record:d,isSmallView:n,scope:r,labelPending:l,labelHoldLate:u,labelMarked:O});break;case"peer":f=h.jsx(X2t,{record:d,isSmallView:n});break;case"ask_response":case"ask_timeout":f=h.jsx(R2t,{record:d,isSmallView:n});break;case"wake":f=h.jsx(E2t,{record:d,isSmallView:n});break;default:f=h.jsx(_2t,{record:d,isSmallView:n})}return f===null?null:h.jsx("div",{"data-record-id":d.id,"data-record-kind":d.kind,"data-completion-anchor":d.id,"data-completion-complete":"complete"in d&&d.complete===!0&&(d.kind!=="assistant"||!d.streaming&&d.text)?"true":void 0,className:j(_1[t.gap][n?1:0]),children:f})}),C2t=6e4,z2t="Could not reach that turn. It is further back than the loaded history — scroll up in the transcript to load more.",ken=({frontend:e,transcript:t,gate:n,waiting:r,starting:i,startingAfterId:a,startingSession:o,startingSince:s,stopping:l,idleDisputed:c,workingLine:u,loadingOlder:O,onLoadOlder:d,onLoadOlderOutcome:f,olderFailed:p,onRetryHydration:m,olderTransportDown:g,containerRef:$,isSmallView:v,status:w,failure:x,awaitingHydration:b,hydrationProven:S=!0,historyReadPending:Q=!1,stale:P=!1,missing:R=!1,attachmentScope:_,conversationId:E,labelPending:C,undelivered:W=null,labelHoldLate:U,labelMarked:Y,measureHandle:V=!1,onReconnect:M})=>{const B=y.useRef({session:null,anchors:new Set}),G=e?.session_id??null,A=_??(G?{sessionId:G,childId:null}:null);B.current.session!==G&&(B.current={session:G,anchors:new Set});const ee=y.useMemo(()=>IXe(t,e?.attention,!!e?.streaming,B.current.anchors),[t,e?.attention,e?.streaming]),K=$2t(),z=w2t(),le=y.useMemo(()=>wPt(ee.records,K),[ee.records,K]);dWe(e,w==="live"&&!r,$);const L=f_t(G??""),Z=y.useRef([]),ne=y.useMemo(()=>{const me=D8e(le,Z.current);return Z.current=me,me},[le]),te=y.useRef(ne);te.current=ne;const[ie,$e]=y.useState(G),[je,Oe]=y.useState(gB),Fe=y.useRef(oB()),ze=y.useRef(null);ie!==G&&($e(G),Oe(gB),Fe.current=oB(),ze.current=null);const ft=y.useRef(G);G!==null&&(ft.current=G);const[ae,fe]=y.useState(()=>({session:ft.current,entries:[]}));ae.session!==ft.current&&fe({session:ft.current,entries:[]});const Te=(me,Se)=>{const cn=new Set(t.records.map(Et=>Et.id));fe(Et=>({session:ft.current,entries:_Pt(Et.session===ft.current?Et.entries:[],me,Se,cn)}))},_e=y.useRef({live:!1,openRuns:void 0,mode:Qie,mounted:0}),[ut,St]=y.useState(()=>xW(G)),[bt,he]=y.useState(G);bt!==G&&(he(G),St(xW(G)));const Re=y.useCallback((me,Se)=>{St(pRe(G,me,Se))},[G]),Ue=y.useRef(null),oe=y.useCallback(me=>{const Se=$.current?.querySelectorAll("[data-turn-summary]");for(const cn of Se??[])if(cn.getAttribute("data-record-id")===me)return cn;return null},[$]),pe=y.useCallback((me,Se,cn)=>{const Et=oe(Se);Et&&(Ue.current={id:Se,top:Et.getBoundingClientRect().top}),Re(me,cn)},[oe,Re]),Ge=ne.length,ot=y.useMemo(()=>_le(tUe({waiting:r,compacting:t.compacting,compactingSince:t.compactingSince,foldedPhase:e?.activity_phase,foldedPhaseStartedAt:e?.activity_phase_started_at,starting:i,startingAfterId:a,startingSession:o,startingSince:s,stopping:l===!0,idleDisputed:c===!0,gate:n,unavailable:UTt({status:w,failure:x,missing:R,stale:P}),records:le})),[r,t.compacting,t.compactingSince,e?.activity_phase,e?.activity_phase_started_at,i,a,o,s,l,c,n,w,x,R,P,le]),et=(u===void 0?ot:u)!==null||n!==null,ve=y.useMemo(()=>p1e(ne,je),[ne,je]),st=y.useMemo(()=>PA(ne,je,g2,m2,et,ve),[ne,je,et,ve]),wt=y.useMemo(()=>Ge>st?ne.slice(Ge-st):ne,[ne,Ge,st]),Lt=Ge-wt.length,bn=y.useMemo(()=>BTt(wt),[wt]),{activeId:en,loadedIds:Dn}=c_t($,ne,L.checkpoints),Rn=y.useMemo(()=>o1e(d),[d]),rr=y.useMemo(()=>Xkt(wt,{nameOf:Se=>Ple(Se.record),failedOf:Se=>Se.record.kind==="tool"&&CE(Se.record.isError,Se.record.delivery),durationOf:Vj,summaryOf:Se=>Se.record.kind==="tool"?_1e(Se.record):"",opOf:Se=>Se.record.kind==="tool"?D7(Se.record.args):"",runningOf:Se=>Se.record.kind==="tool"&&Se.record.phase!=="done",executingOf:Se=>Se.record.kind==="tool"&&Se.record.phase==="running",startedAtOf:Se=>Se.record.kind==="tool"?Se.record.startedAt:null,endedAtOf:Se=>Se.record.kind==="tool"?Se.record.endedAt:null,isFoldable:Se=>Se.record.kind==="tool"}).map(Se=>Se.kind==="run"?{...Se,images:EF(Se.rows)}:Se),[wt]),Ei=y.useMemo(()=>{const me=new Set(U6(wt).map(Se=>wt[Se.openingIndex].record.id));return jkt(wt,{failedOf:Se=>Se.record.kind==="tool"&&CE(Se.record.isError,Se.record.delivery),durationOf:Vj,isAction:Se=>Se.record.kind==="tool",opensRun:Se=>me.has(Se.record.id)})},[bn]),vi={status:w,failure:x,awaitingHydration:b,recordCount:t.records.length,admittedSend:i,missing:R,stale:P},xe=f1e(vi),ye=WTt(vi),ke=y.useRef(null);y.useLayoutEffect(()=>{if(wt.length===0)return;const me=G??"";if(ke.current===me)return;ke.current=me,performance.mark("lop:open:first-row");const Se=performance.getEntriesByName("lop:open:requested","mark").at(-1);Se&&performance.now()-Se.startTime<=C2t&&performance.measure("lop:open:to-first-row","lop:open:requested","lop:open:first-row"),performance.clearMarks("lop:open:requested")},[wt.length,G]);const ht=y.useCallback(()=>{Oe(()=>Math.min(Ge,n_t(te.current,_e.current.mounted,{step:$B,live:_e.current.live,openRuns:_e.current.openRuns,mode:_e.current.mode,snapMaxExtra:g2,completedRunMaxExtra:m2,maxRows:Math.min(Ge,_e.current.mounted+t_t*$B)})))},[Ge]),Ft=y.useCallback(()=>m1e(te.current,_e.current.mounted,{live:_e.current.live,openRuns:_e.current.openRuns,mode:_e.current.mode,snapMaxExtra:g2,completedRunMaxExtra:m2}),[]),{slotState:it,requestOlder:Gr,mayAutoWalk:Je,followingTail:rn,acknowledgeOwnWrite:ea}=b2t({containerRef:$,sessionKey:G,hiddenRows:Lt,hasMore:!!t.hasMore,hydrationProven:S,historyReadPending:Q,onWiden:ht,paintedRows:Ft,onLoadOlder:d,onLoadOlderOutcome:f,olderFailed:p,loadingOlder:O,contentKey:ye?"empty":"filled",rowCount:wt.length});y.useLayoutEffect(()=>{const me=Ue.current;if(me===null)return;Ue.current=null;const Se=$.current,cn=oe(me.id);if(!Se||!cn)return;const Et=cn.getBoundingClientRect().top-me.top;if(Math.abs(Et)<1)return;const ir=Se.scrollTop;Se.scrollTop+=Et,ea(ir,Se.scrollTop)});const zt=y.useCallback(async(me,Se)=>{const cn=$.current,Et=cn?.querySelector("[data-lo-transcript-content]")??null;if(!cn||!Et)return;if(!await E5t({isReachable:()=>QPt(Et,me),rowDistance:()=>{const we=te.current.findIndex(En=>En.record.id===me);return we===-1?null:te.current.length-we},mount:we=>{Oe(En=>En>=we?En:we)},loadOlder:Rn})){Jh(Se);return}await s1e(Et,cn,me)==="missing"&&Jh(Se)},[$,Rn]),hr=y.useCallback(me=>void zt(me,z2t),[zt]),os=y.useCallback(me=>zt(me,pTt),[zt]),br=y.useCallback(me=>{me&&L.warm([me])},[L.warm]),au=y.useRef(0),[Zt,Nr]=y.useState(""),qr=Bn(me=>me.chatMeasureWidth),Ya=Bn(me=>me.setChatMeasureWidth),Ef=Bn(me=>me.restoreDefaultChatMeasureWidth),km=Bn(me=>me.transcriptDisplayMode),qf=y.useMemo(()=>xPe(),[]),Tr=qr??qf;y.useLayoutEffect(()=>{au.current+=1,performance.mark("lop:transcript:render",{detail:{rows:wt.length,commit:au.current}})}),y.useEffect(()=>{},[wt.length]);const ss=u===void 0?ot:u;_e.current={live:et,openRuns:ut,mode:SU(km),mounted:st};const[dv,Pm]=y.useState(null),ou=y.useCallback(me=>{const Se=me.target.closest("[data-record-id]");Pm(Se===null||Se.closest("[data-turn-summary]")!==null?null:Se.getAttribute("data-record-id"))},[]),Tm=y.useCallback(me=>{const Se=me.relatedTarget;(Se===null||!me.currentTarget.contains(Se))&&Pm(null)},[]),Gl=y.useRef(null),ya=y.useRef(Number.NEGATIVE_INFINITY),ls=y.useCallback(()=>{const me=window.getSelection(),Se=$.current;if(!me||me.isCollapsed||!Se)return!1;const cn=me.anchorNode??me.focusNode;return cn!==null&&Se.contains(cn)},[$]),_m=y.useCallback(me=>{if(me.button!==0){Gl.current=null;return}Gl.current={x:me.clientX,y:me.clientY,hadSelection:ls(),onControl:rB(me.target)}},[ls]),su=y.useCallback(()=>{ya.current=performance.now()},[]),jf=y.useCallback(me=>{const Se=Gl.current;if(Gl.current=null,me.defaultPrevented)return;ATt({controlPress:rB(me.target)||Se?.onControl===!0,modalOpen:CTt(document),pressHadSelection:Se?.hadSelection===!0,selectionNotCollapsed:ls(),shiftExtends:me.shiftKey,dragged:Se!==null&&Math.hypot(me.clientX-Se.x,me.clientY-Se.y)>qTt,scrolledRecently:zTt(ya.current,performance.now())})==="focus"&&Xse()},[ls]),Xm=y.useMemo(()=>({live:ss!==null||n!==null,focusHold:dv,openRuns:ut,mode:SU(km)}),[dv,n,ut,km,ss]),yP=y.useMemo(()=>KTt(bn,Xm),[Xm,bn]),cs=y.useMemo(()=>h1e(wt,Xm),[yP]),Rm=y.useMemo(()=>e_t(cs,ve,ut),[cs,ve,ut]),[Ga,Em]=y.useState(0);y.useEffect(()=>{const me=i_t(Fe.current,Rm),Se=Je(),cn=r_t(me.spent,{hasMore:!!t.hasMore,loadingOlder:O,headCut:me.key!==null,mayWalk:Se,halted:me.halted});if(Fe.current={...me,spent:cn.spent},!cn.fetch){if(!(me.key!==null&&!!t.hasMore&&!O&&!me.halted&&!Se&&rn()&&Fe.current.spent<g1e))return;const va=window.setTimeout(()=>Em(we=>we+1),Sh);return()=>window.clearTimeout(va)}const Et=me.key;Rn().then(ir=>{!ir&&Fe.current.key===Et&&(Fe.current={...Fe.current,halted:!0})})},[Rm,O,t.hasMore,Rn,Je,rn,Ga]);const[fv,qm]=y.useState("");y.useEffect(()=>{const me=cs.runs.flatMap(ir=>ir.segments.filter(va=>va.collapsed)),Se=x2t(cs.runs),cn=ze.current;if(cn===null){cs.runs.length>0&&(ze.current={keys:new Set(me.map(ir=>ir.key)),rowIds:Se});return}const Et=me.filter(ir=>!cn.keys.has(ir.key)&&ir.segmentIds.some(va=>cn.rowIds.has(va)));ze.current={keys:new Set([...cn.keys,...me.map(ir=>ir.key)]),rowIds:Se},Et.length!==0&&qm(Et.map(S2t).join(" "))},[cs]);const Cf=y.useMemo(()=>{const me=new Map;wt.forEach((Et,ir)=>me.set(Et.record.id,ir));const Se=[];let cn=0;for(const Et of cs.runs){const ir=[];for(;cn<rr.length;){const Zr=rr[cn],Un=me.get(Zr.kind==="run"?Zr.id:Zr.row.record.id);if(Un===void 0||Un>Et.run.endIndex)break;ir.push(Zr),cn+=1}if(!Et.collapses){for(const Zr of ir)Se.push({kind:"group",group:Zr,suppressClosingLine:!1});continue}const va=new Map;Et.segments.forEach((Zr,Un)=>{for(const lu of Zr.segmentIds)va.set(lu,Un)});const we=Et.segments.some(Zr=>Zr.collapsed&&Zr.stampTs!==null),En=new Map;let jm=!1;for(const Zr of ir){const Un=Zr.kind==="run"?Zr.rows:[Zr.row],lu=va.get(Un[0].record.id),cu=Un.every(Ln=>va.get(Ln.record.id)===lu)?lu:void 0,Nl=cu===void 0?null:Et.segments[cu];if(Nl!==null&&cu!==void 0&&Nl.collapsed){let Ln=En.get(cu);Ln===void 0&&(Ln=[],En.set(cu,Ln),Se.push({kind:"bar",segment:Nl,runIds:Et.recordIds,children:Ln,images:EF(Nl.rows)}),jm=!0),Ln.push(Zr);continue}Se.push({kind:"group",group:Zr,suppressClosingLine:we&&Nl===null,afterBar:jm})}}return Se},[wt,rr,cs]),RO=(me,Se,cn=!1)=>me.kind==="run"?h.jsx(Ukt,{className:_1[me.gap][v?1:0],recordIds:me.rows.map(Et=>Et.record.id),summary:me.summary,actionCount:me.rows.length,span:me.span,live:me.live,open:TPt(ae.entries,me.rows.map(Et=>Et.record.id)),onOpenChange:Et=>Te(me.rows.map(ir=>ir.record.id),Et),condensedMedia:me.images.length>0?Et=>h.jsx(UF,{images:me.images,scope:A,onRevealMore:Et,uncapped:cn}):void 0,mediaCount:cn?0:me.images.length,children:me.rows.map((Et,ir)=>h.jsx(bB,{row:ir===0?X1e(Et):Et,isSmallView:v,scope:A,conversationId:E,labelPending:Et.record.kind==="tool"&&C?.has(Et.record.toolCallId)===!0,labelHoldLate:U===!0,labelMarked:Et.record.kind==="tool"&&Y?.has(Et.record.toolCallId)===!0,foot:Se?null:Ei.get(Et.record.id)??null,closingLineSuppressed:Se,undelivered:W,answerRail:z},Et.record.id))},me.id):h.jsx(bB,{row:me.row,isSmallView:v,scope:A,conversationId:E,labelPending:me.row.record.kind==="tool"&&C?.has(me.row.record.toolCallId)===!0,labelHoldLate:U===!0,labelMarked:me.row.record.kind==="tool"&&Y?.has(me.row.record.toolCallId)===!0,foot:Se?null:Ei.get(me.row.record.id)??null,closingLineSuppressed:Se,undelivered:W,answerRail:z},me.row.record.id);return h.jsxs("div",{className:j(kie,ye?"relative h-0 grow-0 overflow-hidden":"relative flex min-h-0 grow flex-col"),children:[P&&!xe&&h.jsx("p",{className:j("shrink-0 px-4 pt-4 text-ink-dim text-meta",Ai),children:"Showing the last saved view — checking for newer messages."}),h.jsxs("div",{className:j("relative flex min-h-0 grow flex-col"),children:[h.jsx(bPt,{sessionId:G??"",checkpoints:L.checkpoints,building:L.building,loadedIds:Dn,activeId:en,onJump:hr,onHover:br}),h.jsxs("div",{ref:$,"data-lo-canonical-transcript":!0,"data-chat-region":"transcript","data-region-entry":!0,tabIndex:t.records.length===0||xe?-1:0,role:"log","aria-label":nse.transcript,"aria-describedby":it==="windowed"?n1e:void 0,onFocus:ou,onBlur:Tm,onPointerDown:_m,onWheel:su,onClick:jf,className:j("relative flex w-full flex-col-reverse [scrollbar-gutter:stable_both-edges] will-change-[scroll-position] [overflow-anchor:auto] [transform:translateZ(0)]",ye?"h-0 grow-0 overflow-hidden p-0":"min-h-0 grow overflow-auto p-4"),children:[Zt&&h.jsx("span",{"data-lo-perf":!0,className:"sr-only","aria-hidden":"true",children:Zt}),h.jsx("output",{"data-condense-announcement":"",className:"sr-only","aria-live":"polite",children:fv}),h.jsxs("div",{"data-lo-transcript-content":!0,className:j("mb-auto relative flex flex-col",Ai),children:[V&&Tr!==null&&h.jsxs(h.Fragment,{children:[h.jsx(bG,{edge:"left",width:Tr,onWidthChange:Ya,onReset:Ef,label:"Widen or narrow the conversation column (left edge). Arrow keys adjust the width; Home and End go to the limits; Enter restores the default."}),h.jsx(bG,{edge:"right",width:Tr,onWidthChange:Ya,onReset:Ef,label:"Widen or narrow the conversation column (right edge). Arrow keys adjust the width; Home and End go to the limits; Enter restores the default."})]}),xe&&h.jsx(YTt,{isSmallView:v}),t.records.length>0&&!P&&!R&&h.jsx($5t,{state:it,transportDown:g??w!=="live",onLoadOlder:Gr,onRetryHydration:m}),R?h.jsxs("div",{className:"mb-4 flex flex-col gap-2",children:[h.jsx("p",{id:Abe,className:"text-body-sm text-ink",children:"This conversation is no longer on this machine."}),h.jsx("p",{className:"text-ink-dim text-meta",children:"It was deleted, or it belongs to a machine this app is not connected to."}),h.jsx(Ve,{variant:"outline",size:"sm",className:"self-start",onClick:()=>{sr.getState().setActiveSession(null)},children:"Start a new chat"})]}):null,w==="unavailable"&&x&&h.jsxs("div",{"data-lo-session-failure":!0,className:"mb-1 flex flex-wrap items-center gap-3",children:[h.jsx("p",{className:"text-body-sm text-danger",children:x.statement}),x.action==="reconnect"&&h.jsx(Ve,{variant:"outline",size:"sm",onClick:M,children:"Reconnect"})]}),w==="reconnecting"&&h.jsx("p",{className:"mb-4 text-body-sm text-ink-dim",children:"Reconnecting"}),!R&&!xe&&h.jsx(OSt,{conversationId:E,children:Cf.map(me=>me.kind==="bar"?h.jsx(Ykt,{recordIds:me.runIds,segmentIds:me.segment.segmentIds,anchorRecordId:me.segment.firstId,className:_1[me.segment.gap][v?1:0],durationS:me.segment.facts.durationS,actionCount:me.segment.facts.actions,partial:me.segment.facts.partial,title:me.segment.facts.title,stampTs:me.segment.stampTs,label:me.segment.label,completed:me.segment.completed,open:ut.has(me.segment.key),onOpenChange:Se=>pe(me.segment.key,me.segment.firstId,Se),condensedMedia:me.images.length>0?Se=>h.jsx(UF,{images:me.images,scope:A,onRevealMore:Se,indent:"flush"}):void 0,mediaCount:me.images.length,children:me.children.map((Se,cn)=>RO(cn===0?q2t(Se):Se,!0,Se.kind==="run"&&me.images.length>0&&Se.images.length===me.images.length))},`turn-summary:${me.segment.key}`):RO(me.afterBar?j2t(me.group):me.group,me.suppressClosingLine))}),t.records.length>0&&!P&&!R&&h.jsx("div",{"data-lo-transcript-foot":!0,className:j(_1.item[v?1:0],"min-h-[1lh] font-mono text-mono-sm"),children:ss&&h.jsx(Zkt,{activity:ss.activity,phase:ss.phase,startedAt:ss.startedAt,clock:ss.clock})})]})]})]}),G!==null&&h.jsx(XTt,{sessionId:G,containerRef:$,onReveal:os})]})},A2t=({visible:e,onClick:t,className:n,hasNewActivity:r=!1})=>{const i=y.useCallback(()=>{t()},[t]);return h.jsx("div",{"data-lo-scroll-to-bottom":"",className:j("pointer-events-none absolute right-3 bottom-full z-40 mb-3 flex items-center justify-end","transition-opacity duration-base ease-out-quart",e?"opacity-100":"opacity-0",n),"aria-hidden":!e,children:h.jsxs(Ve,{variant:"secondary",size:r?"sm":"icon",className:j("rounded-full shadow-overlay",e?"pointer-events-auto":"pointer-events-none"),"aria-label":r?"New activity, scroll to bottom":"Scroll to bottom",onClick:i,tabIndex:e?0:-1,children:[h.jsx(mqe,{"aria-hidden":"true"}),r?"New activity":null]})})},U2t={running:yje,queued:sQ,paused:Xqe,interrupted:v6,done:Lc,cancelled:p6,gone:Qqe,unknown:oQ,failed:Ri},W2t={running:"text-ink-muted",queued:"text-ink-dim",paused:"text-ink-muted",interrupted:"text-ink-muted",done:"text-ink-dim",cancelled:"text-ink-dim",gone:"text-ink-dim",unknown:"text-ink-dim",failed:"text-danger"},Bj=({status:e})=>{const t=U2t[e];return h.jsx("span",{"aria-hidden":!0,className:j("flex size-4 shrink-0 items-center justify-center",W2t[e]),children:h.jsx(t,{className:j("size-4",e==="running"&&"motion-safe:animate-spin")})})},Pen=({row:e})=>e.errorLine?h.jsx("span",{className:j("line-clamp-2 font-mono text-ink-muted text-mono-sm leading-4"),title:e.errorLine,children:e.errorLine}):e.activity?h.jsx("span",{className:j("truncate text-ink-muted text-meta leading-4"),title:e.activity,children:e.activity}):null,Ten=({row:e,detail:t=null,trailing:n=null})=>h.jsxs(h.Fragment,{children:[h.jsx("span",{className:j("pt-0.5"),children:h.jsx(Bj,{status:e.status})}),h.jsxs("div",{className:j("flex min-w-0 flex-1 flex-col"),children:[h.jsxs("div",{className:j("flex items-baseline gap-2"),children:[h.jsx("span",{className:j("min-w-0 flex-1 truncate text-body-sm text-ink leading-5"),title:e.label,children:e.label}),h.jsx("span",{className:j("sr-only"),children:pze(e)}),h.jsx(Y2t,{row:e}),n]}),t]})]}),Y2t=({row:e,includeModel:t=!1})=>{const n=[];return e.role&&n.push({key:"role",text:e.role}),e.elapsedLabel&&n.push({key:"elapsed",text:e.elapsedLabel,tabular:!0}),e.contextLabel&&n.push({key:"context",text:e.contextLabel,tabular:!0}),e.costLabel&&n.push({key:"cost",text:e.costLabel,tabular:!0}),t&&e.modelLabel&&n.push({key:"model",text:e.modelLabel}),n.length===0?null:h.jsx("span",{className:j("flex min-w-0 shrink-0 items-baseline gap-1 text-meta text-ink-muted"),children:n.map((r,i)=>h.jsxs("span",{className:j("flex items-baseline gap-1"),children:[i>0&&h.jsx("span",{className:j("text-ink-dim"),children:"·"}),h.jsx("span",{className:j(r.tabular&&"tabular-nums",r.key==="model"&&"max-w-32 truncate"),title:r.key==="model"?r.text:void 0,children:r.text})]},r.key))})},uc={list:e=>["desktop","mcp",e]},R1e=async e=>(await Xe({op:"mcp.list",sessionId:e})).data,E1e=async(e,t)=>(await Xe({op:"mcp.control",sessionId:e,control:{action:"probe",name:t}})).data,G2t={probe:"This server's sign-in method could not be checked",grant:"The sign-in could not be started",reconnect:"The server could not be reconnected",reload:"This server's configuration could not be re-read",add:"The server could not be added",key:"The keys were not saved",cancel:"The cancellation could not be confirmed",status:"The sign-in status could not be refreshed",disconnect:"The server could not be disconnected",remove:"The server could not be removed",test:"The connection test could not be started"},N2t=[M0.noCredential,M0.transportFailed],Z2t="Session owner is unavailable.";function Hj(e,t,n){const r=G2t[e];if(t instanceof jc)return{message:t.message,detail:null,cause:"unknown",phase:e};if(!(t instanceof Nt))return{message:`${r}.`,detail:null,cause:"unknown",phase:e};const i=t.message.trim();return L0(t.code)?{message:`${r}. ${Fx[t.code]}`,detail:null,cause:"server",phase:e}:t.status===409?n?{message:`${r}: a sign-in is already running for this conversation, and only one can run at a time. Wait for it to finish, or cancel it from the server's row.`,detail:null,cause:"busy",phase:e}:{message:`${r}: the server refused it without giving a reason, and nothing was changed.`,detail:null,cause:"refused",phase:e}:t.status===503&&!L0(t.code)&&!N2t.includes(i)?{message:`${r} because this conversation's session is not running. Trying again restarts it and repeats this request.`,cause:"session",phase:e,detail:i.startsWith(Z2t)?null:i}:{message:cQ(`${r}.`,t),detail:null,cause:"server",phase:e}}const wB=e=>`/settings?section=integrations&mcp=${encodeURIComponent(e)}`,EA="Open this server in Settings",SB=()=>[{kind:"reload",label:qg.reload},{kind:"settings",label:EA}];function xB(e){if(e.cause==="server")return[];const t=[],n=e.row.remedy,r={kind:"grant",label:qg.grant};return n?.kind==="grant"&&e.phase!=="grant"&&t.push(r),n?.kind==="key"&&e.phase!=="key"&&e.keyEntryAvailable&&e.row.keyNames.length>0&&t.push({kind:"key",label:qg.key}),n?.kind==="reconnect"&&e.phase!=="reconnect"&&t.push({kind:"reconnect",label:qg.reconnect}),e.phase!=="reload"&&t.push({kind:"reload",label:qg.reload}),t.push({kind:"settings",label:EA}),t}const QB=e=>`mcp-key-${e}`,I2t=({open:e,target:t,saving:n,failure:r,onCancel:i,onOpenSettings:a,onSave:o})=>{const[s,l]=y.useState({}),[c,u]=y.useState(!1),O=t?.keyNames??[];y.useEffect(()=>{l({}),u(!1)},[e,t?.name]);const d=O.every(f=>(s[f]??"").trim().length>0);return h.jsx(t$,{open:e,onClose:i,maxWidth:"sm",title:O.length===1?`Enter the key for ${t?.name??""}`:`Enter the credentials for ${t?.name??""}`,actions:h.jsxs(h.Fragment,{children:[h.jsx(nl,{onClick:i,children:"Cancel"}),h.jsx(ph,{onClick:()=>o(s,c?[...O]:[]),disabled:!d||n,children:n?"Saving…":"Save and reconnect"})]}),children:h.jsx(QE,{asChild:!0,children:h.jsxs("div",{className:j("flex flex-col gap-3 p-1.5 text-body text-ink-muted"),children:[h.jsx("p",{children:"Saved to the encrypted secret store, then this server is reconnected. These keys may be shared by other servers and sessions."}),O.map(f=>h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx(Eie,{htmlFor:QB(f),className:"font-mono text-meta",children:f}),h.jsx(po,{id:QB(f),type:"password",autoComplete:"off",value:s[f]??"",onChange:p=>l(m=>({...m,[f]:p.target.value}))})]},f)),h.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-body-sm",children:[h.jsx("input",{type:"checkbox",checked:c,onChange:f=>u(f.target.checked)}),"Replace existing values for these shared keys."]}),r?h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:r.message}),r.detail?h.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:r.detail,children:r.detail}):null,h.jsx(Ve,{variant:"link",size:"sm",className:"self-start","data-mcp-failure-action":"settings",onClick:a,children:EA})]}):null]})})})};function D2t({row:e,action:t="login",remedy:n,onClose:r}){const[i]=y.useState(e),a=_y(),o=ga(),s=gi(o.data,"mcp_auth"),[l,c]=y.useState({kind:"probing"}),[u,O]=y.useState(0),d=n.sessionId,f=Yt({queryKey:uc.list(d??""),queryFn:()=>R1e(d??""),enabled:!!d&&l.kind==="running",refetchInterval:l.kind==="running"?1e3:!1});if(y.useEffect(()=>{if(!d||o.isLoading)return;let P=!0;return c({kind:"probing"}),n.clearFailure(i.name),E1e(d,i.name).then(R=>{if(!P)return;if(R.transport_oauth_supported===!0){c({kind:"grant"});return}const _=[...new Set((R.secret_refs??[]).map(E=>E.id))];if(_.length&&s&&R.key_submission_supported===!0){c({kind:"key",row:{...i,keyNames:_,remedy:{kind:"key"}}});return}c({kind:"notice",severity:"warning",failure:{cause:"unknown",phase:"probe",detail:null,message:s?R.transport_oauth_supported===!1?"This server does not use OAuth and declares no secret references. Add explicit ${NAME} references to its MCP environment or headers, then retry.":"Could not determine this server's sign-in method. Check its connection and MCP setup, then retry.":"Update the backend for secure MCP key entry. OAuth and the server list remain available."},actions:SB()})}).catch(R=>{if(!P)return;const _=Hj("probe",R,l3(f.data?.operations));c({kind:"notice",severity:"danger",failure:_,actions:xB({row:i,phase:"probe",cause:_.cause,keyEntryAvailable:s})})}),()=>{P=!1}},[d,i,o.isLoading,s,u]),!d)return h.jsx(t$,{open:!0,onClose:r,maxWidth:"sm",title:"Sign in to an MCP server",actions:h.jsx(nl,{onClick:r,children:"Close"}),children:h.jsx("p",{className:"p-1.5 text-body text-ink-muted",role:"alert",children:"Open a conversation to sign in to this server."})});if(l.kind==="key")return h.jsx(I2t,{open:!0,target:l.row,saving:n.pendingName===i.name,failure:n.failureFor(i.name),onCancel:r,onOpenSettings:()=>a(wB(l.row.name)),onSave:(P,R)=>{n.pressKey(l.row,P,R).then(_=>{_&&r()})}});const m=[...f.data?.operations?.filter(P=>P.name===i.name)??[]].sort((P,R)=>R.created_at-P.created_at)[0],g=l.kind==="running"&&(!m||m.status==="running"),$=m?.status==="complete",v=n.failureFor(i.name),w=f.error?Hj("status",f.error,!1):null,x=P=>{if(P.kind==="settings"){r(),a(wB(i.name));return}if(P.kind==="key"){c({kind:"key",row:{...i,remedy:{kind:"key"}}});return}if(P.kind==="reload"){n.reload(i).then(R=>{R&&O(_=>_+1)});return}if(P.kind==="reconnect"){n.press({...i,remedy:{kind:"reconnect"}});return}n.press({...i,remedy:{kind:"grant"}},t),c({kind:"running"})},b=l.kind==="notice"&&!v?l:null,S=b?.actions??[],Q=v?xB({row:i,phase:v.phase,cause:v.cause,keyEntryAvailable:s}):[];return h.jsx(t$,{open:!0,onClose:r,maxWidth:"sm",title:`Sign in to ${i.name}`,actions:h.jsxs(h.Fragment,{children:[h.jsx(nl,{onClick:r,children:"Close"}),l.kind==="grant"?h.jsx(ph,{onClick:()=>{n.press({...i,remedy:{kind:"grant"}},t),c({kind:"running"})},children:t==="reauth"?"Replace grant and sign in":"Continue in browser"}):null,l.kind==="notice"||v||l.kind==="running"&&!g&&!$?h.jsx(nl,{onClick:()=>O(P=>P+1),children:"Try again"}):null,m?.status==="running"?h.jsx(nl,{onClick:()=>n.cancel(m.id),children:"Cancel sign-in"}):null]}),children:h.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted",children:[l.kind==="probing"?h.jsx("p",{children:"Checking this server's sign-in method…"}):null,b?h.jsxs(h.Fragment,{children:[h.jsx(xc,{variant:b.severity,children:h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("p",{role:"alert",children:b.failure.message}),b.failure.detail?h.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:b.failure.detail,children:b.failure.detail}):null]})}),S.length>0?h.jsx("div",{className:"flex flex-wrap items-center gap-2",children:S.map((P,R)=>R===0?h.jsx(ph,{disabled:n.pendingName===i.name,"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind):h.jsx(nl,{disabled:n.pendingName===i.name,"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind))}):null]}):null,l.kind==="grant"?h.jsxs("p",{children:["Your browser opens to approve access.",t==="reauth"?" This replaces the existing grant for this server.":""]}):null,l.kind==="running"&&!v?h.jsx("p",{children:m?.message||(g?"Waiting for backend sign-in status…":`Sign-in ${m?.status??"status unavailable"}.`)}):null,w?h.jsxs(h.Fragment,{children:[h.jsx(xc,{variant:"danger",children:h.jsx("p",{role:"alert",children:w.message})}),h.jsx("div",{className:"flex flex-wrap items-center gap-2",children:SB().map((P,R)=>R===0?h.jsx(ph,{"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind):h.jsx(nl,{"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind))})]}):null,v?h.jsxs(h.Fragment,{children:[h.jsx(xc,{variant:"danger",children:h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("p",{role:"alert",children:v.message}),v.detail?h.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:v.detail,children:v.detail}):null]})}),Q.length>0?h.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Q.map((P,R)=>R===0?h.jsx(ph,{disabled:n.pendingName===i.name,"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind):h.jsx(nl,{disabled:n.pendingName===i.name,"data-mcp-failure-action":P.kind,onClick:()=>x(P),children:P.label},P.kind))}):null]}):null]})})}const V2t=y.createContext(null),M2t="bg-row-selected text-accent hover:bg-row-selected hover:text-accent active:bg-row-selected active:text-accent before:absolute before:inset-y-1 before:-left-[6px] before:w-0.5 before:rounded-full before:bg-accent",L2t="text-ink-muted hover:bg-row-hover hover:text-ink active:bg-row-hover active:text-ink",F2t=y.forwardRef(({id:e,label:t,ariaLabel:n,pressed:r,children:i,className:a,...o},s)=>{const l=y.useContext(V2t),c=l?.register;y.useLayoutEffect(()=>c?.(e),[c,e]);const[u,O]=y.useState(!1),d=y.useRef(null);return KPe(u,"panel-rail-tooltip",()=>{const f=d.current?.getAttribute("aria-describedby");return f?document.getElementById(f):null}),h.jsx(At,{content:t,side:"left",onOpenChange:O,children:h.jsx(Ve,{ref:f=>{d.current=f,typeof s=="function"?s(f):s&&(s.current=f)},variant:"ghost",size:"icon","data-panel-rail-item":e,"data-titlebar-no-drag":"","aria-label":n,"aria-pressed":r,tabIndex:l?l.roving===e?0:-1:void 0,className:j("relative focus-visible:outline-offset-1!",r?M2t:L2t,a),...o,children:i})})});F2t.displayName="PanelRailItem";const $2=e=>[e.name,e.transport??"",String(e.oauthSupported),e.keyNames.join(",")].join("\0");function B2t({sessionId:e}){const t=Fc(),[n,r]=y.useState(null),[i,a]=y.useState({}),[o,s]=y.useState({}),l=y.useCallback(async($,v)=>{const w=uc.list(e??""),x=t.getQueryData(w);if(!(v.status!==409||l3(x?.operations)))try{const b=await E1e(e,$.name);a(S=>({...S,[$2($)]:b.transport_oauth_supported===!1?"not-oauth":"refused"}))}catch{}},[t,e]),c=y.useCallback(($,v,w)=>{const x=t.getQueryData(uc.list(e??""));s(b=>({...b,[$]:Hj(v,w,l3(x?.operations))}))},[t,e]),u=y.useCallback(($,v="reauth")=>{if(!e||!$.remedy||$.remedy.kind!=="grant"&&$.remedy.kind!=="reconnect")return;const w=uc.list(e);r($.name),a(x=>{const{[$2($)]:b,...S}=x;return S}),s(x=>{const{[$.name]:b,...S}=x;return S}),(async()=>{try{if($.remedy?.kind==="reconnect"){const x=await Xe({op:"mcp.control",sessionId:e,control:{action:"connect",name:$.name}});x?.data?t.setQueryData(w,x.data):t.invalidateQueries({queryKey:w});return}await Xe({op:"mcp.control",sessionId:e,control:{action:v,name:$.name,confirmed:!0}}),t.invalidateQueries({queryKey:w})}catch(x){c($.name,$.remedy?.kind==="reconnect"?"reconnect":"grant",x),x instanceof Nt&&await l($,x)}finally{r(null)}})()},[l,t,c,e]),O=y.useCallback($=>{e&&(async()=>{try{await Xe({op:"mcp.control",sessionId:e,control:{action:"cancel",operation_id:$}}),t.invalidateQueries({queryKey:uc.list(e)})}catch(v){const x=t.getQueryData(uc.list(e))?.operations?.find(b=>b.id===$)?.name;x&&c(x,"cancel",v)}})()},[t,c,e]),d=y.useCallback(async($,v,w=[])=>{if(!e)return!1;r($.name),s(b=>{const{[$.name]:S,...Q}=b;return Q});const x=uc.list(e);try{const b=await Xe({op:"mcp.credentials.store",sessionId:e,name:$.name,values:v,confirmedReplace:w});if(b.data?.code!=="saved"){const S=b.data,Q=S?.code==="replace_confirmation_required"?"Confirm replacement of the existing shared keys before saving.":`Not saved: ${(S?.failed_ids??Object.keys(v)).join(", ")}. Unlock or repair the encrypted store, then retry.`;return s(P=>({...P,[$.name]:{cause:"unknown",phase:"key",detail:null,message:Q+(S?.saved_ids.length?` Saved: ${S.saved_ids.join(", ")}.`:"")}})),r(null),!1}}catch(b){return c($.name,"key",b),r(null),!1}try{const b=await Xe({op:"mcp.control",sessionId:e,control:{action:"connect",name:$.name}});if(b?.data){if(t.setQueryData(x,b.data),b.data.servers?.find(Q=>Q.name===$.name)?.status==="connected")return!0}else t.invalidateQueries({queryKey:x});return s(S=>({...S,[$.name]:{cause:"unknown",phase:"reconnect",detail:null,message:"The keys were saved, but this server is not connected. Check the credentials and server setup, then retry."}})),!1}catch(b){return c($.name,"reconnect",b),!1}finally{r(null)}},[t,c,e]),f=y.useCallback(async $=>{if(!e)return!1;r($.name),s(v=>{const{[$.name]:w,...x}=v;return x});try{const v=await Xe({op:"mcp.control",sessionId:e,control:{action:"reload",name:$.name}}),w=uc.list(e);return v?.data?t.setQueryData(w,v.data):t.invalidateQueries({queryKey:w}),!0}catch(v){return c($.name,"reload",v),!1}finally{r(null)}},[t,c,e]),p=y.useCallback($=>i[$2($)]??null,[i]),m=y.useCallback($=>o[$]??null,[o]),g=y.useCallback($=>{s(v=>{if(!($ in v))return v;const{[$]:w,...x}=v;return x})},[]);return{sessionId:e,press:u,pressKey:d,cancel:O,reload:f,pendingName:n,failureFor:m,clearFailure:g,refusalFor:p}}const H2t="Goal:",K2t="the session goal",J2t="Open the plan in run details",eXt="Open the subagents in run details",tXt="Open the jobs in run details",nXt="Open the wakes in run details",rXt="Open the monitors in run details",iXt="Loop:",q1e="Clear goal",aXt="Stop loop",oXt="Clear loop",sXt="Done",lXt="Dismiss",cXt="Could not mark the goal done",uXt="Could not dismiss the goal",OXt="Goal done",dXt="— done",fXt="goal stalled: judge could not decide — send a message to continue",hXt="goal stalled: reached the continuation limit — send a message to continue",pXt=e=>`goal stalled: stopped after ${e} continuations — send a message to continue`,mXt="goal stalled: auto-continuation stopped — send a message to continue",gXt="judge could not decide",kB="stopped after ",PB=" continuations",$Xt=/^\d+$/,yXt=e=>{const t=(e??"").trim();if(t===gXt)return fXt;if(t.startsWith(kB)&&t.endsWith(PB)){const n=t.slice(kB.length,t.length-PB.length);return $Xt.test(n)?pXt(n):hXt}return mXt},vXt="Could not clear the goal",bXt="Could not stop the loop",wXt="Could not clear the loop",SXt="Could not restore the goal",xXt="Goal cleared",QXt="Undo",TB=28,kXt=e=>{const t=j1e(e);return`${xXt} · ${t}`},PXt=e=>`${OXt} · ${j1e(e)} — it stays in the goal history; /goal <text> sets it again`,j1e=e=>{const t=e.trim().replace(/\s+/g," ");if(t.length<=TB)return t;const n=t.slice(0,TB),r=n.lastIndexOf(" ");return`${(r>0?n.slice(0,r):n).trimEnd()}…`},AS=new Map,TXt=(e,t)=>{AS.set(e,t)},_Xt=e=>{AS.delete(e)},XXt=e=>AS.has(e)?AS.get(e):null,Kj="line-clamp-4",C1e=j("disabled:text-ink-disabled disabled:cursor-default","disabled:hover:bg-transparent disabled:hover:text-ink-disabled"),RXt=e=>[e.status,e.completed,e.iterations??"",e.goal??""].join("|"),z1e=j("pointer-events-none opacity-0","group-hover:pointer-events-auto group-hover:opacity-100","group-focus-within:pointer-events-auto group-focus-within:opacity-100"),A1e="opacity-100",U1e="@max-[240px]/chatcol:hidden",W1e=U1e,EXt="@max-[241px]/chatcol:hidden",qXt="@max-[341px]/chatcol:hidden",jXt="@max-[270px]/chatcol:hidden",CXt="@max-[213px]/chatcol:hidden",zXt="@min-[270px]/chatcol:hidden",xu="-ml-1.5",AXt="@max-[240px]/chatcol:w-full @max-[240px]/chatcol:flex-none",UXt=(e,t,n="")=>`${t?"Collapse":"Expand"} ${K2t}${fa}${n?`${n}, `:""}${e}`,WXt=e=>`${J2t}${fa}${_6(e)}`,YXt=e=>`${eXt}${fa}${P6(e)}${Pse(e)}`,GXt=e=>`${tXt}${fa}${T6(e)}${Pse(e)}`,Y1e=(e,t)=>e!==null&&!e.isConnected&&!t,NXt=e=>`${nXt}${fa}${gse(e)}`,ZXt=e=>`${rXt}${fa}${$se(e)}`,IXt=e=>`${q1e}${fa}${e}`,DXt=e=>`Mark the goal done${fa}${e}`,VXt=e=>`Dismiss the finished goal${fa}it stays in the goal history${fa}${e}`,G1e=e=>`${N1e(e)}${Z1e(e)}`,N1e=e=>e.status,Z1e=e=>e.status!=="running"?"":e.iterations?`, ${e.completed} of ${e.iterations} turns`:`, ${e.completed} ${e.completed===1?"turn":"turns"}`,I1e=e=>W6(e.status)?{text:aXt,args:Cle,failure:bXt}:{text:oXt,args:null,failure:wXt},MXt=e=>`${I1e(e).text}${fa}${G1e(e)}`;function y2({kind:e,label:t,word:n,icon:r,busy:i,onPress:a}){return h.jsx(At,{content:t,side:"top",className:j(Kj),children:h.jsxs("button",{type:"button","data-status-goal-done":e==="done"?"":void 0,"data-status-goal-dismiss":e==="done"?void 0:"","aria-label":t,disabled:i,onClick:a,className:j(ic,z1e,i?A1e:void 0,C1e),children:[r,h.jsx("span",{className:j(W1e),children:n})]})})}const LXt=({frontend:e,runDetails:t,isSmallView:n=!1,askExpanded:r,onAskToggle:i,askOutcomes:a,onFocusComposer:o,onNote:s,nowMs:l})=>{const[c,u]=y.useState(!1),O=r??c,d=ke=>{u(ke),i?.(ke)},f=Bn(ke=>ke.revealRunPanelSection),p=ua(e?.session_id??""),m=ua(e?.session_id??""),g=ua(e?.session_id??""),$=ua(e?.session_id??""),[v,w]=y.useState(!1),x=e?.goal?.trim()??"",b=nae(e),S=e?.goal_status,Q=e?.goal_judge??null,P=S==="done",R=tae(e),_=jle(S,Q?.state),E=_==="stalled",C=y.useRef(E),W=Q?.reason;y.useEffect(()=>{if(!E){C.current=!1;return}C.current||(C.current=!0,s?.(yXt(W)))},[E,W,s]);const U=!!(t&&t.totalTodos>0),Y=t?.wakes??[],V=Y.length>0,M=t?.monitors??[],B=M.length>0,G=fQ(e,a),A=Dse(G.waiting>0,l),ee=i!==void 0&&(G.rows.length>0||G.open>0),K=G.waiting>0,z=e?.loop??null,le=z!==null&&z.status!=="idle"&&!W6(z.status)?RXt(z):null,[L,Z]=y.useState(null);y.useEffect(()=>{le===null&&Z(null)},[le]);const ne=z!==null&&z.status!=="idle"&&!(le!==null&&le===L),te=z===null?"":G1e(z),ie=y.useRef([]);y.useEffect(()=>{const ke=e?.session_id??"";return TXt(ke,x),()=>_Xt(ke)},[e?.session_id,x]),y.useEffect(()=>{if(!(x.length===0||ie.current.length===0)){for(const ke of ie.current)t0(ke);ie.current=[]}},[x]),y.useEffect(()=>{b||w(!1)},[b]);const $e=t?_w(t.subagents):null,je=t?_w(t.jobs):null,Oe=y.useRef(null),Fe=y.useRef(null);y.useEffect(()=>{const ke=document.activeElement,ht=ke instanceof HTMLElement&&Oe.current?.contains(ke)===!0?ke:null;Y1e(Fe.current,ht!==null)&&o?.(),Fe.current=ht});const[ze,ft]=y.useState(!0),ae=y.useRef(null),fe=y.useRef(0),Te=y.useRef(null);if(y.useLayoutEffect(()=>{const ke=Oe.current,ht=ae.current;if(!ke||!ht)return;const Ft=()=>{const Je=getComputedStyle(ke),rn=ea=>Number.parseFloat(ea)||0;return ke.clientWidth-rn(Je.paddingLeft)-rn(Je.paddingRight)},it=()=>{ze&&(fe.current=ht.scrollWidth,Te.current=te),ft(Ft()>=fe.current)};if(Te.current!==te&&(Te.current=te,fe.current=0,!ze)){ft(!0);return}if(it(),typeof ResizeObserver>"u")return;const Gr=new ResizeObserver(it);return Gr.observe(ke),()=>Gr.disconnect()},[ze,te]),!b&&!ne&&!U&&!ee&&!V&&!B&&!$e&&!je)return null;const _e=UXt(x,v,_),ut=t?WXt(t):"",St=V?NXt(Y.length):"",bt=B?ZXt(M.length):"",he=ee?zze(G,O,A):"",Re=ee?jse(G,A):null,Ue=ee?jze(G,A):null,oe=ee?Cse(G):"",pe=$e?YXt($e):"",Ge=je?GXt(je):"",ot=b?IXt(x):"",et=b&&R?DXt(x):"",ve=b&&R?VXt(x):"",st=ne&&z?I1e(z):null,wt=ne&&z?MXt(z):"",Lt=!b,bn=!b&&!ne,en=bn&&!U,Dn=en&&!ee,Rn=Dn&&!V,rr=Rn&&!B,Ei=rr&&!$e,vi=async ke=>{const ht=e?.session_id??"";if(XXt(ht)!==""){for(const it of ie.current)t0(it);ie.current=[];return}const Ft=await p.run(qu,ke,SXt);Ft.result.tone==="error"&&Oo(Ft.result.text)},xe=ke=>{if(ke.args===null){Z(le);return}ye($,b3,ke.args,ke.failure)},ye=async(ke,ht,Ft,it,Gr="cleared")=>{const Je=await ke.run(ht,Ft,it);if(Je.result.tone==="error"){Oo(Je.result.text);return}if(ht!==qu)return;const rn=x;if(Gr!=="dismissed"){if(Gr==="done"){Jh(PXt(rn));return}ie.current.push(Jh(kXt(rn),{action:{label:QXt,onClick:()=>void vi(rn)}}))}};return h.jsxs("div",{ref:Oe,"data-composer-status-row":"",className:j(Ai,"flex flex-wrap items-start gap-x-2 gap-y-0.5",n?"px-2 pb-1":"px-4 pb-2","@max-[240px]/chatcol:flex-col @max-[240px]/chatcol:flex-nowrap"),children:[b&&h.jsx("div",{"data-status-goal":"",className:j("flex min-w-[140px] flex-1 items-center",AXt),children:h.jsx(Bo,{className:j("min-w-0 flex-1"),rowClassName:j("h-6 rounded-sm px-1.5 py-0"),triggerClassName:j("w-fit max-w-full min-w-0 text-ink-muted hover:bg-accent-wash hover:text-ink focus-visible:outline-offset-1!",xu),triggerLabel:_e,triggerTooltip:_e,tooltipClassName:j(Kj),onOpenChange:w,trailing:h.jsxs(h.Fragment,{children:[R&&!P&&h.jsx(y2,{kind:"done",label:et,word:sXt,icon:h.jsx(Lc,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),busy:m.busy,onPress:()=>void ye(m,qu,qle,cXt,"done")}),P?h.jsx(y2,{kind:"dismiss",label:ve,word:lXt,icon:h.jsx(A7,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),busy:g.busy,onPress:()=>void ye(g,qu,bUe,uXt,"dismissed")}):h.jsx(y2,{kind:"clear",label:ot,word:q1e,icon:h.jsx(Ri,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),busy:p.busy,onPress:()=>void ye(p,qu,Ele,vXt)})]}),summary:h.jsxs("span",{className:j("flex min-w-0 items-center gap-1"),children:[h.jsx("span",{className:j("shrink-0",E&&"text-ink"),children:H2t}),h.jsx("span",{className:j("min-w-0 truncate",P&&"line-through text-ink-dim"),children:x}),P&&h.jsx("span",{className:j("shrink-0 text-meta text-ink-dim",EXt),children:dXt})]}),children:h.jsx("div",{role:"group","aria-label":"Session goal",tabIndex:0,"data-status-goal-body":"",className:j("font-sans text-body-sm text-ink-muted whitespace-pre-wrap break-words",QPe),children:x})})}),ne&&z&&st&&h.jsxs("div",{ref:ae,"data-status-loop-item":"",className:j("group flex shrink-0 items-center"),children:[h.jsxs("span",{"data-status-loop":"",className:j(Q3,Lt?xu:void 0),children:[h.jsx(Jje,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),h.jsxs("span",{children:[`${iXt} ${N1e(z)}`,ze&&h.jsx("span",{className:j(U1e),children:Z1e(z)})]})]}),h.jsx(At,{content:wt,side:"top",className:j(Kj),children:h.jsxs("button",{type:"button","data-status-loop-dismiss":"","aria-label":wt,disabled:$.busy,onClick:()=>xe(st),className:j(ic,z1e,$.busy?A1e:void 0,C1e),children:[h.jsx(Ri,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),h.jsx("span",{className:j(W1e),children:st.text})]})})]}),(U||ee||V||B||$e||je)&&h.jsxs("div",{className:j("flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5"),children:[U&&t&&h.jsx(At,{content:ut,side:"top",children:h.jsxs("button",{type:"button","data-status-plan":"","aria-label":ut,onClick:()=>f("todos"),className:j(ic,bn?xu:void 0),children:[h.jsx(U7,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),_6(t)]})}),ee&&h.jsx(At,{content:he,side:"top",children:h.jsxs("button",{type:"button","aria-expanded":O,"aria-label":he,"data-status-asks":"","data-lo-ask-item":O?"expanded":"minimized","data-lo-ask-item-toggle":"",onClick:()=>d(!O),className:j(ic,"[flex-shrink:1]!",K?"text-ink":void 0,en?xu:void 0),children:[h.jsx(oQ,{"aria-hidden":!0,className:j("size-3.5 shrink-0",G.urgent?"text-warning":K?"text-accent":void 0)}),h.jsx("span",{className:"shrink-0 whitespace-nowrap",children:X6(G)}),Re===null?null:h.jsxs("span",{className:j("min-w-0 shrink overflow-hidden text-ellipsis whitespace-nowrap",jXt),children:[" · ",oe===""?null:h.jsx("span",{className:qXt,children:`${oe} `}),Re]}),Ue===null?null:h.jsxs("span",{className:j("min-w-0 shrink overflow-hidden text-ellipsis whitespace-nowrap",zXt,CXt),children:[" · ",Ue]})]})}),V&&h.jsx(At,{content:St,side:"top",children:h.jsxs("button",{type:"button","data-status-wakes":"","aria-label":St,onClick:()=>f("wakes"),className:j(ic,Dn?xu:void 0),children:[h.jsx(Oqe,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),gse(Y.length)]})}),B&&h.jsx(At,{content:bt,side:"top",children:h.jsxs("button",{type:"button","data-status-monitors":"","aria-label":bt,onClick:()=>f("monitors"),className:j(ic,Rn?xu:void 0),children:[h.jsx(nCe,{"aria-hidden":!0,className:j("size-3.5 shrink-0")}),$se(M.length)]})}),$e&&h.jsx(At,{content:pe,side:"top",children:h.jsxs("button",{type:"button","data-status-subagents":"","aria-label":pe,onClick:()=>f("subagents"),className:j(ic,rr?xu:void 0),children:[h.jsx(Bj,{status:$e.mark}),P6($e)]})}),je&&h.jsx(At,{content:Ge,side:"top",children:h.jsxs("button",{type:"button","data-status-jobs":"","aria-label":Ge,onClick:()=>f("jobs"),className:j(ic,Ei?xu:void 0),children:[h.jsx(Bj,{status:je.mark}),T6(je)]})})]})]})},FXt=500;function BXt({previousActive:e,currentActive:t,heldUntil:n,now:r,graceMs:i=FXt}){return t?{held:!0,heldUntil:null}:e?{held:!0,heldUntil:r+i}:n!==null&&r<n?{held:!0,heldUntil:n}:{held:!1,heldUntil:null}}function HXt(e){const[t,n]=y.useState({held:!1,heldUntil:null}),r=y.useRef(!1),i=y.useRef(null);return y.useEffect(()=>{const a=Date.now(),o=BXt({previousActive:r.current,currentActive:e,heldUntil:t.heldUntil,now:a});r.current=e,!(o.held===t.held&&o.heldUntil===t.heldUntil)&&(i.current!==null&&(clearTimeout(i.current),i.current=null),n(o),o.heldUntil!==null&&(i.current=setTimeout(()=>{i.current=null,n({held:!1,heldUntil:null})},o.heldUntil-a)))},[e,t]),y.useEffect(()=>()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},[]),t}const D1e="This backend cannot move a live session. Start a new chat to use a different folder, or update the backend.",_en="This session is still starting. Its working directory can be moved as soon as it is live.";function KXt(e){return gi(e,"session_move",2)&&gi(e,"frontend_replace")}const JXt="The working directory was not changed.",eRt=15e3;async function tRt(e){try{const t=await Xe({op:"sessions.move",sessionId:e.sessionId,requestId:e.requestId,cwd:e.cwd}),n=nRt(t,e.evalUsed);return e.note(n),{kind:"settled",receipt:t,sentence:n}}catch(t){const n=mo(t,JXt);return e.note(n,!0),{kind:"refused",sentence:n}}}function nRt(e,t){return e.outcome==="unchanged"?`already in ${e.label}`:e.outcome==="cold"?`moved to ${e.label}`:t?`moved to ${e.label} — this session's runtime is restarting there, so everything you set up in eval was lost`:`moved to ${e.label} — this session's runtime is restarting there`}async function rRt(e){const t=await e.moveTo(e.cwd);t.kind==="in-flight"?e.note("A working-directory move is already in progress.",!0):t.kind==="unavailable"&&e.note(D1e,!0)}function iRt(e){return e.some(t=>t.kind==="tool"&&t.toolName==="eval")}function aRt(e,t){const n=y.useRef(oRt),[,r]=y.useState(0),i=t.transcript.records;return y.useEffect(()=>{const a=sRt(n.current,e,i);a!==n.current&&(n.current=a,r(o=>o+1))},[i,e]),lRt(n.current,e)}const oRt=new Set;function sRt(e,t,n){return!t||e.has(t)||!iRt(n)?e:new Set(e).add(t)}function lRt(e,t){return!!(t&&e.has(t))}function mg(e,t,n){const r=e.get(t)??null,i=n(r);if(i===r)return e;const a=new Map(e);return i?a.set(t,i):a.delete(t),a}function cRt(e,t,n){return{sessionId:e,requestId:t,path:n,target:null}}function _B(e,t){return e?.requestId===t?null:e}function uRt(e,t,n,r=Date.now()){return!e||e.requestId!==t?e:{...e,target:n,settleBy:e.settleBy??r+eRt}}function ORt(e,t,n){return!e||e.sessionId!==t?e:e.target!==null&&n===e.target?null:e}function Xen(e){const{sessionId:t,canonical:n}=e,[r,i]=y.useState(new Map),a=t?r.get(t)??null:null,o=KXt(e.capabilities),s=n.addNote,l=aRt(t,n),c=n.frontend?.cwd,u=y.useRef(r);y.useEffect(()=>{u.current=r},[r]);const O=y.useCallback((p,m=!1)=>{s(p,m?"error":"info")},[s]),d=y.useCallback(async p=>{if(!o||!t)return{kind:"unavailable"};if(u.current.get(t))return{kind:"in-flight"};const g=Wo(),$=cRt(t,g,p);u.current=mg(u.current,t,()=>$),i(w=>{const x=mg(w,t,()=>$);return u.current=x,x});const v=await tRt({sessionId:t,cwd:p,requestId:g,note:O,evalUsed:l});return i(w=>mg(w,t,x=>v.kind==="settled"?uRt(x,g,v.receipt.cwd):_B(x,g))),v},[o,t,O,l]);y.useEffect(()=>{!t||!a||i(p=>mg(p,t,m=>ORt(m,t,c)))},[a,t,c]),y.useEffect(()=>{const p=[...r.values()].flatMap(m=>m.settleBy===void 0?[]:[setTimeout(()=>{i(g=>mg(g,m.sessionId,$=>_B($,m.requestId)))},Math.max(0,m.settleBy-Date.now()))]);return()=>{for(const m of p)clearTimeout(m)}},[r]);const f=a&&a.sessionId===t?a:null;return y.useMemo(()=>({cwd:f?.target??f?.path??c,moveTo:d,busy:!!f,accepted:f?.target!=null}),[f,d,c])}const dRt={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},qA={refetchOnWindowFocus:!1},Ren=new voe({defaultOptions:dRt}),fRt=/\s*\([^)]*\)\s*$/,hRt=/\(([^)]+)\)\s*$/,pRt=/[^A-Za-z0-9]+/,mRt=/[A-Z]/,gRt=/Enter code:\s*([A-Za-z0-9-]+)/,$Rt=/^www\./,yRt="radient",Een=["radient","anthropic","openai","deepseek"];function dO(e){const t=e.brand?.trim();if(t)return t;const n=e.id?vRt[e.id]:void 0;return n||e.name.replace(fRt,"").trim()||e.name}const vRt={"alibaba-token-plan":"QwenCloud"};function bRt(e){const t=hRt.exec(e);return t?t[1].trim():null}const wRt={anthropic:"Claude subscription",openai:"ChatGPT subscription","openai-device":"ChatGPT, with a code",radient:"Browser sign-in",kimi:"Moonshot account","xai-oauth":"SuperGrok account","zai-oauth":"Browser sign-in","alibaba-token-plan-oauth":"Token Plan account"};function qen(e){if(e.kind==="api_key")return"API key";const t=wRt[e.method_id];if(t)return t;const n=bRt(e.label);return n||(e.kind==="device"?"Sign in with a code":"Sign in")}const SRt={anthropic:"Use your Claude Pro or Max plan. No extra charge.",openai:"Use your ChatGPT Plus or Pro plan. No extra charge.","openai-device":"Use your ChatGPT plan, signing in with a one-time code. No extra charge.",radient:"One browser sign-in. Nothing to paste."};function jen(e,t){const n=SRt[e.method_id];return n||(e.kind==="device"?`Sign in to your ${dO(t)} account with a one-time code.`:`Sign in with your ${dO(t)} account.`)}function Cen(e){const t=e.split(pRt).filter(Boolean);if(t.length>=2)return`${t[0][0]}${t[1][0]}`.toUpperCase();const n=t[0]??e,r=mRt.exec(n.slice(1));return r?`${n[0]}${r[0]}`.toUpperCase():`${n[0]?.toUpperCase()??""}${n[1]?.toUpperCase()??""}`}const zen={subscription:"Use a subscription",key:"Use an API key",local:"Run models on this computer"};function Pk(e){return e.local?"local":e.auth_methods.some(n=>n.kind==="browser"||n.kind==="device")?"subscription":"key"}function Aen(e){const t=Pk(e);return t==="local"?"Set up":t==="key"?"Add key":"Sign in"}function Uen(e){const t=Pk(e);return t==="local"?`Needs ${dO(e)} running`:t==="key"?"Paste an API key":`Sign in with your ${QRt(e)} account`}const xRt={anthropic:"Claude",openai:"ChatGPT",kimi:"Moonshot",xai:"SuperGrok","xai-oauth":"SuperGrok",zai:"Z.AI",radient:"Radient","alibaba-token-plan":"QwenCloud"};function QRt(e){return xRt[e.id]??dO(e)}function V1e(e,t){return e.local||e.credential_optional?t!==null&&e.id===t:e.has_credential||e.configured}function Wen(e,t){return e.filter(n=>V1e(n,t)).sort((n,r)=>n.id===t?-1:r.id===t?1:dO(n).localeCompare(dO(r)))}function Yen(e,t,n=""){const r=n.trim().toLowerCase(),i={subscription:[],key:[],local:[]};for(const o of e)V1e(o,t)||r&&![o.name,o.id,...o.search_aliases].join(" ").toLowerCase().includes(r)||i[Pk(o)].push(o);const a=i.subscription.findIndex(o=>o.id===yRt);if(a>0){const[o]=i.subscription.splice(a,1);i.subscription.unshift(o)}return i}function Gen(e,t,n="Signed in"){const r=Pk(e);return[r==="local"?"On this computer":r==="key"?"API key saved":n,t].filter(Boolean).join(" · ")||null}function Nen(e,t){if(!t)return null;const n=e?.suggested_model;return n&&n.id===t?n.name:t}function Zen(e){if(e.user_code)return e.user_code;const t=gRt.exec(e.instructions??"");return t?t[1]:null}function Ien(e){if(!e)return null;try{return new URL(e).host.replace($Rt,"")||null}catch{return null}}function Den(e){return e>0?Math.ceil(e/60):null}const kRt="Replaced by a new sign-in.";function Ven(e,t){return e.state==="expired"?e.message==="This sign-in is no longer available. Start again."?"This sign-in is no longer available, so it was stopped.":"The sign-in link expired.":e.state==="cancelled"?e.message===kRt?"A newer sign-in replaced this one.":"You cancelled sign-in.":e.message&&e.message!=="Sign-in failed."?e.message:`${t} didn't confirm the sign-in.`}async function Jj(e,t){await t("hosting",e.provider),await t("model_name",e.model_id)}function eC(e){return e?.provider&&e.model_id?{provider:e.provider,model_id:e.model_id}:null}function PRt(e){return e?.kind==="notice"&&e.style==="info"}function TRt(e,t,n,r){if(e!=="default"||!n||!r)return null;const i=eC(t?{provider:pn(t.provider),model_id:pn(t.model_id)}:null),a=i?.provider??"",o=i?.model_id??"";return{kind:"action",id:"model-default",name:"Set current model as default",description:i?`Save the current model (${a}/${o}) as the default for new sessions.`:"No active session model is available to save.",model:i,clickText:i?"Click does the same.":"A session model is required before this action can save a default.",disabled:i===null}}function M1e(e,t){return!e.disabled}const _Rt=new Set(["theme","title-refresh"]);function XRt(e){return e!==void 0&&_Rt.has(e)}const RRt=new Set(["providers","provider-accounts","mcp"]);function ERt(e){return e!==void 0&&RRt.has(e)}function L1e(e){return e.includes(" ")}const qRt="No servers to choose. Enter runs the command.",jRt={mcp_catalog:2};function XB(e,t){if(!e?.requires)return e;const n=t?.features?.[e.requires]??0,r=jRt[e.requires]??1;if(!(t?.desktop_available!==!0||n<r))return e}const jA=new Set(["title-refresh"]),F1e={"title-refresh":new Set(["refresh","update","retitle","--refresh","--auto","--update","--retitle"])};function B1e(e,t){const n=e?F1e[e]:void 0;if(!n)return!1;const r=mn(t);return!r||r.includes(" ")||r.includes(" ")?!1:n.has(r.toLowerCase())}function CRt(e,t){const n=e?F1e[e]:void 0;if(!n)return!1;const r=mn(t);if(!r||r.includes(" ")||r.includes(" "))return!1;const i=r.toLowerCase();for(const a of n)if(a.startsWith(i))return!0;return!1}function zRt(e){return e===void 0||!jA.has(e)}const ARt={model:"Models",effort:"Effort",approvals:"Approvals",team:"Teams",agent:"Agents",providers:"Providers","provider-accounts":"Accounts",mcp:"Servers",theme:"Themes","title-refresh":"Options"};function URt(e){return e>0?e>=1e6?`${(e/1e6).toFixed(1)}m`.replace(".0m","m"):e>=1e3?`${Math.floor(e/1e3)}k`:String(e):""}const WRt=/0+$/,YRt=/\.$/;function RB(e){if(e===Math.trunc(e))return String(Math.trunc(e));if(e>=10)return e.toFixed(1);const t=Math.floor(Math.log10(Math.abs(e))),n=Math.max(0,2-t);return e.toFixed(n).replace(WRt,"").replace(YRt,"")}function H1e(e,t,n){return n?"usage-based":!(e>=0)||!(t>=0)?"":e===0&&t===0?"free":`$${RB(e)}/${RB(t)}`}const pn=e=>typeof e=="string"?e:"",v2=e=>typeof e=="number"&&Number.isFinite(e)?e:-1,GRt=[{value:"--refresh",name:"--refresh",description:"Re-read the conversation and name it again",detail:"resumes auto-naming",aliases:["refresh","update","retitle","--update","--retitle"]}];function NRt(){return GRt.map(e=>({...e,aliases:e.aliases?[...e.aliases]:void 0}))}function ZRt(e){const t=pn(e.selector)||pn(e.value);if(t)return t;const n=pn(e.provider),r=pn(e.model_id);return n&&r?`${n}/${r}`:""}const EB=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):void 0,IRt={oauth:"oauth",api_key:"api key"},DRt="Stored credential",VRt={logged_in:"logged in",env_key:"env key",needs_login:"needs login",local_ready:"configured server",local_unconfigured:"configure server"},MRt=/[^a-z0-9]+/g;function qB(e){return e.toLowerCase().replace(MRt,"")}function LRt(e,t){const n=t.trim();return n.endsWith(")")&&n.includes("(")?n.slice(n.indexOf("(")+1,-1).trim():n&&qB(n)===qB(e)?"":n}const FRt={oauth:["sign_in","reauth","sign_out"],signed_in:["sign_out"]},jB={connected:"connected",connecting:"connecting",needs_sign_in:"needs sign-in",not_started:"not connected",error:"error"};function BRt(e,t){const n=pn(t.status);return e==="remove"?Oae(pn(t.source?.path)):e==="logout"?n==="connected"?"stored credential · connected":"stored credential":e==="reauth"?n==="connected"?"connected — will re-authorize":jB[n]??"":n==="connected"?"connected — will re-use":jB[n]??""}function nc(e,t,n,r){switch(e){case"model":{const i=n??null,a=i?`${pn(i.provider)}/${pn(i.model_id)}`:"";return t.map(o=>{const s=o,l=ZRt(s),c=[pn(s.provider),s.aggregated?"aggregated":"",s.connected===!1?"no credential":""].filter(Boolean).join(", "),u=[URt(v2(s.context_window)),H1e(v2(s.input_price),v2(s.output_price),s.routed===!0)].filter(Boolean).join(" · ");return{value:l,name:pn(s.label)||pn(s.model_id),description:c,detail:u||void 0,current:!!a&&a===l}})}case"team":case"agent":return t.map(i=>{const a=i,o=pn(a.value)||pn(a.name),s=pn(a.label),l=pn(a.name)||o,c=z6({name:l,label:s});return{value:o,name:c,slug:c!==o?o:void 0,aliases:s?.trim()&&c!==o?[o]:void 0,description:pn(a.description),detail:pn(a.kind)||void 0,current:!!n&&n===o}});case"effort":return t.map(i=>{const a=pn(i.value);return{value:a,name:Rh(a),current:n===a}});case"approvals":return t.map(i=>{const a=pn(i.value);return{value:a,name:a,current:n===a}});case"providers":return t.map(i=>{const a=i,o=pn(a.id),s=VRt[pn(a.state)];return{value:o,name:dO({id:o,name:pn(a.name),brand:pn(a.brand)}),description:LRt(o,pn(a.name)),detail:s||void 0,aliases:EB(a.search_aliases)}});case"provider-accounts":{const i=new Map;for(const o of t){const s=o,l=pn(s.provider);if(!l)continue;const c=i.get(l)??{kinds:[],labels:[]};c.kinds.push(pn(s.type)),c.labels.push(pn(s.identity_label)),i.set(l,c)}const a=new Map((r?.providers??[]).map(o=>[pn(o.id),o]));return[...i.entries()].map(([o,s])=>{const l=new Set(s.kinds.map(d=>IRt[d]??d).filter(Boolean)),c=l.size===1?`remove ${[...l][0]}`:`remove ${s.kinds.length} credentials`,u=s.labels.length===1&&s.labels[0]!==DRt?s.labels[0]:"",O=a.get(o);return{value:o,name:O?dO({id:o,name:pn(O.name),brand:pn(O.brand)}):o,aliases:O?EB(O.search_aliases):void 0,detail:u?`${c} · ${u}`:c,alert:!0}})}case"mcp":{const i=r?.argument??"",a=r?.verbs??[],o=i.indexOf(" ");if(o===-1)return a.map(u=>({value:`${u.verb} `,name:u.verb,description:u.description,alert:u.destructive}));const s=i.slice(0,o).toLowerCase(),l=a.find(u=>u.verb===s);if(!l||l.offers===null)return[];const c=l.offers==="all"?null:FRt[l.offers];return l.offers!=="all"&&!c?[]:t.flatMap(u=>{const O=u,d=Array.isArray(O.actions)?O.actions:[];if(c&&!d.some(p=>c.includes(String(p))))return[];const f=pn(O.name);return[{value:`${l.verb} ${f}`,name:`${l.verb} ${f}`,detail:BRt(l.verb,O),alert:l.destructive}]})}case"theme":return t.map(i=>{const a=i,o=pn(a.value);return{value:o,name:pn(a.name)||o,description:pn(a.description),current:n===o}});case"title-refresh":return NRt()}}function K1e(e){return!e?.provider||!e.model_id?null:`${e.provider}/${e.model_id}`}function HRt(e){if(!e?.provider||!e.model_id)return null;const t=typeof e.reasoning_effort=="string"?e.reasoning_effort.trim():"";return{provider:e.provider,model_id:e.model_id,reasoning_effort:t===""?null:t}}const J1e={cwd:""};function KRt(e){return["desktop","session-preview",e.cwd,e.target?.kind??null,e.target?.name??null,K1e(e.model),e.model?.reasoning_effort??null]}async function JRt(e){return(await Xe({op:"sessions.preview",requestId:crypto.randomUUID(),cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}})).frontend}function e4t(e,t){const n=e.trim();if(!n)return{checked:!0,rung:null,confirmation:i=>`This conversation will run ${i}.`};if(!t.ladderKnown)return{checked:!1,rung:null,refusal:"Nothing was changed, because that model's effort levels could not be read. Try again."};const r=t.ladder.find(i=>i.trim().toLowerCase()===n.toLowerCase());return r?{checked:!0,rung:r,confirmation:i=>`This conversation will run ${i} at ${r} effort.`}:{checked:!0,rung:null,confirmation:i=>t.level?`This conversation will run ${i}. Its effort is now ${t.level}, because ${n} is not one of that model's levels.`:`This conversation will run ${i}. No effort level is set on it, because ${n} is not one of that model's levels.`}}function US(e){return{queryKey:KRt(e),queryFn:()=>JRt(e),placeholderData:iQ,staleTime:3e4,retry:!1}}function t4t(e){return[{value:"on",label:"On",description:"Priority processing. Billed at premium rates where the provider offers it.",current:e==="on"},{value:"off",label:"Off",description:"Standard processing.",current:e==="off"}]}const n4t=/[^0-9a-z]+/g;function ewe(e){return e.toLowerCase().replace(n4t," ").trim()}function r4t(e,t,n){let r=n+1;for(let i=1;i<e.length;i+=1){const a=t.indexOf(e[i],r);if(a<0)return!1;r=a+1}return!0}function i4t(e,t){const n=e[0];for(let r=t.indexOf(n);r!==-1;r=t.indexOf(n,r+1))if(!(r!==0&&t[r-1]!==" ")&&r4t(e,t,r))return!0;return!1}const CB=new WeakMap,zB=e=>e.trim()!=="";function AB(e){const t=CB.get(e);if(t)return t;const n=[e.label,e.value].concat(e.keywords??[]),r=[e.description??"",e.meta??""],i={lowered:n.concat(r).filter(zB).map(a=>a.toLowerCase()),named:n.filter(zB).map(ewe).filter(a=>a!=="")};return CB.set(e,i),i}function a4t(e,t){const n=t.trim();if(!n)return e;const r=ewe(t);if(!r)return[];const i=n.toLowerCase(),a=r.split(" ").filter(Boolean),o=a.length>1&&a.every(l=>l.length>1),s=e.filter(l=>{const{lowered:c,named:u}=AB(l);return c.some(O=>O.includes(i))||u.some(O=>O.includes(r))});return s.length>0?s:e.filter(l=>AB(l).named.some(c=>o&&a.every(u=>c.includes(u))||i4t(r,c)))}const o4t={info:"border-hairline bg-sunken text-ink-muted",success:"border-success-border bg-success-wash text-ink",warning:"border-warning-border bg-warning-wash text-ink",error:"border-danger-border bg-danger-wash text-ink"},s4t="Panel content",twe={hovered:null,picked:null};function l4t(e,t){switch(t.type){case"hover":return e.hovered===t.index?e:{...e,hovered:t.index};case"leave":return e.hovered===null?e:{...e,hovered:null};case"pick":return{...e,picked:t.value};case"settle":return e.picked===null?e:{...e,picked:null};case"reset":return twe}}function c4t(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>[r.label,r.value,r.description??"",r.meta??""].concat(r.keywords??[]).join(" ").toLowerCase().includes(n)):e}function u4t(e){return e.loading?"loading":e.loadError?"error":e.rowCount===0?"empty":"list"}function O4t(e){const{options:t,held:n,active:r,query:i,queryChanged:a,steered:o}=e,s=e.retarget??null;if(t.length===0)return{index:0,held:null,retargeted:null,steered:!1};const l=n===null?-1:t.findIndex(f=>f.value===n),c=Math.max(0,Math.min(r,t.length-1)),u=i?-1:t.findIndex(f=>f.current),O=u>=0?u:c;if(s!==null&&t.some(f=>f.value===s.lost)&&l>=0)return{index:l,held:n,retargeted:null,steered:o};if(l>=0)return{index:l,held:n,retargeted:a?null:void 0,steered:o};const d=t[O];return a?{index:O,held:d?.value??null,retargeted:null,steered:!1}:{index:O,held:d?.value??null,retargeted:o&&n!==null&&d!==void 0?{lost:n,label:d.label}:void 0,steered:o}}function UB(e){return e.busy?e.busyText??"Applying the change…":e.hasList&&e.rowCount>0?e.retargetedLabel?`The row you were on is gone · Enter picks ${e.retargetedLabel}`:e.activeLabel?`Arrows move · Enter picks ${e.activeLabel} · Esc closes`:"Arrows move, Enter picks, Esc closes":"Esc closes"}function d4t(e){return e.busy?"Close":e.result&&(e.result.tone==="success"||e.result.tone==="info")?"Done":"Close"}const nwe=y.memo(({id:e,option:t,index:n,isActive:r,isHovered:i,isPicked:a,onHover:o,onPick:s,busyLabel:l="Applying the change"})=>h.jsxs("div",{id:e,role:"option","aria-selected":r,"aria-disabled":t.disabled||void 0,"data-current":t.current||void 0,"data-hovered":i||void 0,"data-picked":a||void 0,onMouseEnter:()=>o(n),onMouseDown:c=>{c.preventDefault(),s(t,n)},className:j("flex items-start gap-3 rounded-sm px-2 py-1.5",r&&"bg-sunken",i&&!r&&!t.disabled&&"bg-accent-wash",(a||i&&!r&&!t.disabled)&&"outline-solid outline-1 -outline-offset-1 outline-control",t.disabled&&"text-ink-disabled"),children:[h.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx("span",{className:j("truncate text-body-sm",t.disabled?"text-ink-disabled":"text-ink"),children:t.label}),t.current&&h.jsx(Lc,{className:j("size-3.5 shrink-0",t.disabled?"text-warning":"text-accent"),"aria-label":"Current"})]}),t.description&&h.jsx("span",{className:j("truncate text-meta",t.disabled?"text-ink-dim":"text-ink-muted"),title:t.description,children:t.description})]}),a?h.jsx("span",{className:"shrink-0",children:h.jsx(Fo,{size:"sm",label:l})}):t.meta?h.jsx("span",{className:"shrink-0 font-mono text-ink-dim text-mono-sm",children:t.meta}):null]}));nwe.displayName="PickerRow";const cr=({open:e,onClose:t,title:n,description:r,options:i,matcher:a=c4t,loading:o=!1,loadError:s=null,notice:l=null,noticeDetail:c=null,emptyText:u="Nothing matches.",searchPlaceholder:O="Search",onPick:d,form:f,onSubmit:p,submitLabel:m="Apply",submitDisabled:g=!1,actions:$,result:v=null,busy:w=!1,busyText:x,busyLabel:b="Applying the change",wide:S=!1,shell:Q="dialog",bodyLabel:P,toolbar:R,body:_,bodyScrolls:E=!1})=>{const C=y.useId();q7(e,"panel-picker");const[W,U]=y.useState(""),[Y,V]=y.useState(0),M=y.useRef(null),B=y.useRef(!1),G=y.useRef(null),[A,ee]=y.useState(null),[K,z]=y.useReducer(l4t,twe),le=y.useRef(null),L=y.useRef(null),[Z,ne]=y.useState(!1),[te,ie]=y.useState(!1),[$e,je]=y.useState(!0),Oe=y.useRef(null),Fe=y.useRef(null),ze=y.useCallback(ve=>{if(Oe.current?.(),Oe.current=null,!ve){ne(!1),ie(!1);return}const st=()=>{const Lt=ve.scrollHeight-ve.clientHeight;ne(Lt>1),ie(Lt-ve.scrollTop>1)};st(),ve.addEventListener("scroll",st,{passive:!0});let wt;if(typeof ResizeObserver<"u"){wt=new ResizeObserver(st),wt.observe(ve);for(const Lt of ve.children)wt.observe(Lt)}Oe.current=()=>{ve.removeEventListener("scroll",st),wt?.disconnect()}},[_]),ft=y.useCallback(ve=>{Fe.current=ve,ze(ve)},[ze]),ae=y.useRef(null),fe=i!==void 0,Te=y.useMemo(()=>i?a(i,W):[],[i,W,a]),_e=y.useMemo(()=>{const ve=new Map;for(const st of Te){const wt=st.group??"",Lt=ve.get(wt);Lt?Lt.push(st):ve.set(wt,[st])}return[...ve.entries()]},[Te]),ut=y.useMemo(()=>_e.flatMap(([,ve])=>ve),[_e]),St=ut[Y]?.label??null;y.useEffect(()=>{e&&(U(""),V(0),M.current=null,B.current=!1,G.current=null,ee(null),z({type:"reset"}))},[e]),y.useEffect(()=>{w||z({type:"settle"})},[w]),y.useEffect(()=>{const ve=G.current!==W;G.current=W;const st=O4t({options:ut,held:M.current,active:Y,query:W,queryChanged:ve,steered:B.current,retarget:A});M.current=st.held,B.current=st.steered,V(st.index),st.retargeted!==void 0&&ee(st.retargeted)},[ut,W,Y,A]),y.useEffect(()=>{L.current?.scrollTo({top:0})},[W]),y.useEffect(()=>{L.current?.querySelector(`[id="${C}-${Y}"]`)?.scrollIntoView?.({block:"nearest"})},[Y,C]);const bt=y.useCallback(async ve=>{!ve||ve.disabled||w||(z({type:"pick",value:ve.value}),await d?.(ve.value,ve))},[d,w]),he=y.useRef(bt);y.useEffect(()=>{he.current=bt},[bt]);const Re=y.useCallback((ve,st)=>{M.current=ve.value,B.current=!0,ee(null),V(st),he.current(ve)},[]),Ue=y.useCallback(ve=>z(ve===null?{type:"leave"}:{type:"hover",index:ve}),[]),oe=y.useCallback(()=>z({type:"leave"}),[]),pe=y.useCallback(ve=>{if(!ve.nativeEvent.isComposing)if(ve.key==="ArrowDown"&&ut.length>0){ve.preventDefault();const st=(Y+1)%ut.length;M.current=ut[st]?.value??null,B.current=!0,ee(null),V(st)}else if(ve.key==="ArrowUp"&&ut.length>0){ve.preventDefault();const st=(Y-1+ut.length)%ut.length;M.current=ut[st]?.value??null,B.current=!0,ee(null),V(st)}else ve.key==="Enter"&&(ve.preventDefault(),fe&&ut.length>0&&d?bt(ut[Y]):p&&!g&&!w&&p())},[ut,Y,fe,d,p,g,w,bt]),Ge=y.useCallback(ve=>{ve.preventDefault(),p&&!g&&!w&&p()},[p,g,w]),ot=u4t({loading:o,loadError:s,rowCount:Te.length});let et=-1;return h.jsx(j7,{open:e,onOpenChange:ve=>!ve&&t(),children:h.jsxs(C7,{className:j("gap-0 p-0",Q==="panel"?"max-w-5xl":S?"max-w-3xl":"max-w-xl","overflow-hidden rounded-lg"),onOpenAutoFocus:ve=>{if(ve.preventDefault(),Q==="panel"){Fe.current?.focus(),Fe.current||ae.current?.focus();return}le.current?.focus()},children:[h.jsxs("div",{className:"flex flex-col gap-1 px-5 pt-5 pr-12",children:[h.jsx(z7,{className:"text-heading text-ink",children:n}),r?h.jsx(QE,{className:"text-body-sm text-ink-muted",children:r}):h.jsx(QE,{className:"sr-only",children:n})]}),fe&&h.jsx("div",{className:"px-5 pt-4",children:h.jsxs("div",{className:"relative",children:[h.jsx(Xy,{className:"-translate-y-1/2 pointer-events-none absolute top-1/2 left-2.5 size-4 text-ink-dim","aria-hidden":"true"}),h.jsx(po,{ref:le,role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":ut[Y]?`${C}-${Y}`:void 0,"aria-autocomplete":"list",value:W,onChange:ve=>U(ve.target.value),onKeyDown:pe,placeholder:O,className:"pl-8",autoComplete:"off",spellCheck:!1})]})}),!fe&&!_&&h.jsx("input",{ref:le,className:"sr-only","aria-hidden":"true",tabIndex:-1,onKeyDown:pe,readOnly:!0}),R&&h.jsx("div",{className:"px-5 pt-3",children:R}),fe&&h.jsxs("div",{className:"px-3 pt-3",children:[l&&h.jsx(At,{content:c,children:h.jsx("p",{className:"px-2 pb-2 text-body-sm text-warning",children:l})}),ot==="loading"?h.jsx("div",{className:"flex h-24 items-center justify-center",children:h.jsx(Fo,{size:"md",label:"Loading"})}):ot==="error"?h.jsx("p",{className:"px-2 py-3 text-body-sm text-danger",children:s}):ot==="empty"?h.jsx("p",{className:"px-2 py-3 text-body-sm text-ink-dim",children:u}):h.jsx("div",{ref:L,id:C,role:"listbox","aria-label":n,tabIndex:-1,onMouseLeave:oe,className:"max-h-[min(50vh,420px)] overflow-y-auto",children:_e.map(([ve,st])=>h.jsxs("div",{children:[ve&&h.jsx("p",{className:"px-2 pt-2 pb-1 text-ink-dim text-meta",children:ve}),st.map(wt=>{et+=1;const Lt=et;return h.jsx(nwe,{id:`${C}-${Lt}`,option:wt,index:Lt,isActive:Lt===Y,isHovered:Lt===K.hovered,isPicked:K.picked===wt.value,onHover:Ue,onPick:Re,busyLabel:b},wt.value)})]},ve||"ungrouped"))})]}),_&&h.jsx("div",{className:j(Z&&"border-control border-b"),children:h.jsx("div",{ref:ft,role:Q==="panel"?"region":void 0,"aria-label":Q==="panel"?P??s4t:void 0,tabIndex:Q==="panel"?0:void 0,onKeyDown:Q==="panel"&&$e?()=>je(!1):void 0,onPointerDown:Q==="panel"&&$e?()=>je(!1):void 0,"data-panel-body":"",className:j("overflow-y-auto px-5 pt-3",Q==="panel"?"max-h-[min(76vh,760px)] pb-4":"max-h-[min(60vh,520px)]",Q==="panel"&&$e&&"outline-none",(E||Q==="panel")&&"[scrollbar-gutter:stable]",te&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-20px),transparent)]"),children:_})}),f&&h.jsxs("form",{onSubmit:Ge,className:j("flex flex-col gap-3 px-5",fe?"pt-3":"pt-4"),children:[f,h.jsx("button",{type:"submit",className:"sr-only",tabIndex:-1,"aria-hidden":"true"})]}),v&&h.jsx("div",{className:"px-5 pt-3",children:h.jsxs("output",{className:j("block rounded-md border px-3 py-2 text-body-sm",o4t[v.tone]),children:[h.jsx("p",{className:"whitespace-pre-wrap",children:v.text}),v.detail&&h.jsx("div",{className:"mt-2 font-mono text-mono-sm",children:v.detail})]})}),h.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4","data-picker-footer":!0,children:[h.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:w?h.jsxs("span",{className:"flex items-center gap-2 text-ink-muted",children:[h.jsx(Fo,{size:"sm"}),UB({busy:w,hasList:fe,rowCount:Te.length,activeLabel:St,busyText:x,retargetedLabel:A?.label??null})]}):UB({busy:w,hasList:fe,rowCount:Te.length,activeLabel:St,busyText:x,retargetedLabel:A?.label??null})}),h.jsxs("div",{className:"flex items-center gap-2",children:[$,h.jsx(Ve,{ref:ae,variant:"ghost",size:"sm",type:"button",onClick:t,children:d4t({busy:w,result:v})}),p&&h.jsx(Ve,{variant:"primary",size:"sm",type:"button",onClick:()=>void p(),disabled:g||w,children:m})]})]})]})})},El=({label:e,hint:t,children:n,htmlFor:r})=>h.jsxs("label",{className:"flex flex-col gap-1",htmlFor:r,children:[h.jsx("span",{className:"text-ink-muted text-meta",children:e}),n,t&&h.jsx("span",{className:"text-ink-dim text-meta",children:t})]}),n1=({label:e,value:t,mono:n=!0})=>h.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1",children:[h.jsx("span",{className:"text-body-sm text-ink-muted",children:e}),h.jsx("span",{className:j("text-right text-ink",n?"font-mono text-mono-sm":"text-body-sm"),children:t})]}),Zc=({checked:e,onCheckedChange:t,children:n,tone:r="muted"})=>{const i=y.useId();return h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsx(JPe,{className:"mt-0.5",id:i,checked:e,onCheckedChange:a=>t(a===!0)}),h.jsx(Eie,{htmlFor:i,className:j("font-normal text-body-sm",r==="ink"?"text-ink":"text-ink-muted"),children:n})]})};function N$({value:e,onChange:t,options:n,label:r}){const i=y.useId();return h.jsxs("fieldset",{className:"flex items-center gap-1 rounded-md bg-sunken p-1",children:[h.jsx("legend",{className:"sr-only",children:r}),n.map(a=>{const o=`${i}-${a.value}`;return h.jsxs("span",{children:[h.jsx("input",{type:"radio",id:o,name:i,value:a.value,checked:e===a.value,onChange:()=>t(a.value),className:"sr-only"}),h.jsx("label",{htmlFor:o,className:j("block cursor-pointer rounded-sm px-3 py-1 text-body-sm",e===a.value?"bg-surface text-ink":"text-ink-muted hover:text-ink"),children:a.label})]},a.value)})]})}var b2,WB;function Wa(){if(WB)return b2;WB=1;var e=Array.isArray;return b2=e,b2}var w2,YB;function rwe(){if(YB)return w2;YB=1;var e=typeof vv=="object"&&vv&&vv.Object===Object&&vv;return w2=e,w2}var S2,GB;function Yl(){if(GB)return S2;GB=1;var e=rwe(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return S2=n,S2}var x2,NB;function iv(){if(NB)return x2;NB=1;var e=Yl(),t=e.Symbol;return x2=t,x2}var Q2,ZB;function f4t(){if(ZB)return Q2;ZB=1;var e=iv(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function a(o){var s=n.call(o,i),l=o[i];try{o[i]=void 0;var c=!0}catch{}var u=r.call(o);return c&&(s?o[i]=l:delete o[i]),u}return Q2=a,Q2}var k2,IB;function h4t(){if(IB)return k2;IB=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return k2=n,k2}var P2,DB;function tu(){if(DB)return P2;DB=1;var e=iv(),t=f4t(),n=h4t(),r="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function o(s){return s==null?s===void 0?i:r:a&&a in Object(s)?t(s):n(s)}return P2=o,P2}var T2,VB;function nu(){if(VB)return T2;VB=1;function e(t){return t!=null&&typeof t=="object"}return T2=e,T2}var _2,MB;function pm(){if(MB)return _2;MB=1;var e=tu(),t=nu(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return _2=r,_2}var X2,LB;function CA(){if(LB)return X2;LB=1;var e=Wa(),t=pm(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){if(e(a))return!1;var s=typeof a;return s=="number"||s=="symbol"||s=="boolean"||a==null||t(a)?!0:r.test(a)||!n.test(a)||o!=null&&a in Object(o)}return X2=i,X2}var R2,FB;function QO(){if(FB)return R2;FB=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return R2=e,R2}var E2,BB;function zA(){if(BB)return E2;BB=1;var e=tu(),t=QO(),n="[object AsyncFunction]",r="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(s){if(!t(s))return!1;var l=e(s);return l==r||l==i||l==n||l==a}return E2=o,E2}var q2,HB;function p4t(){if(HB)return q2;HB=1;var e=Yl(),t=e["__core-js_shared__"];return q2=t,q2}var j2,KB;function m4t(){if(KB)return j2;KB=1;var e=p4t(),t=function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function n(r){return!!t&&t in r}return j2=n,j2}var C2,JB;function iwe(){if(JB)return C2;JB=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return C2=n,C2}var z2,eH;function g4t(){if(eH)return z2;eH=1;var e=zA(),t=m4t(),n=QO(),r=iwe(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,l=o.toString,c=s.hasOwnProperty,u=RegExp("^"+l.call(c).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function O(d){if(!n(d)||t(d))return!1;var f=e(d)?u:a;return f.test(r(d))}return z2=O,z2}var A2,tH;function $4t(){if(tH)return A2;tH=1;function e(t,n){return t?.[n]}return A2=e,A2}var U2,nH;function kf(){if(nH)return U2;nH=1;var e=g4t(),t=$4t();function n(r,i){var a=t(r,i);return e(a)?a:void 0}return U2=n,U2}var W2,rH;function Tk(){if(rH)return W2;rH=1;var e=kf(),t=e(Object,"create");return W2=t,W2}var Y2,iH;function y4t(){if(iH)return Y2;iH=1;var e=Tk();function t(){this.__data__=e?e(null):{},this.size=0}return Y2=t,Y2}var G2,aH;function v4t(){if(aH)return G2;aH=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return G2=e,G2}var N2,oH;function b4t(){if(oH)return N2;oH=1;var e=Tk(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function i(a){var o=this.__data__;if(e){var s=o[a];return s===t?void 0:s}return r.call(o,a)?o[a]:void 0}return N2=i,N2}var Z2,sH;function w4t(){if(sH)return Z2;sH=1;var e=Tk(),t=Object.prototype,n=t.hasOwnProperty;function r(i){var a=this.__data__;return e?a[i]!==void 0:n.call(a,i)}return Z2=r,Z2}var I2,lH;function S4t(){if(lH)return I2;lH=1;var e=Tk(),t="__lodash_hash_undefined__";function n(r,i){var a=this.__data__;return this.size+=this.has(r)?0:1,a[r]=e&&i===void 0?t:i,this}return I2=n,I2}var D2,cH;function x4t(){if(cH)return D2;cH=1;var e=y4t(),t=v4t(),n=b4t(),r=w4t(),i=S4t();function a(o){var s=-1,l=o==null?0:o.length;for(this.clear();++s<l;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,D2=a,D2}var V2,uH;function Q4t(){if(uH)return V2;uH=1;function e(){this.__data__=[],this.size=0}return V2=e,V2}var M2,OH;function AA(){if(OH)return M2;OH=1;function e(t,n){return t===n||t!==t&&n!==n}return M2=e,M2}var L2,dH;function _k(){if(dH)return L2;dH=1;var e=AA();function t(n,r){for(var i=n.length;i--;)if(e(n[i][0],r))return i;return-1}return L2=t,L2}var F2,fH;function k4t(){if(fH)return F2;fH=1;var e=_k(),t=Array.prototype,n=t.splice;function r(i){var a=this.__data__,o=e(a,i);if(o<0)return!1;var s=a.length-1;return o==s?a.pop():n.call(a,o,1),--this.size,!0}return F2=r,F2}var B2,hH;function P4t(){if(hH)return B2;hH=1;var e=_k();function t(n){var r=this.__data__,i=e(r,n);return i<0?void 0:r[i][1]}return B2=t,B2}var H2,pH;function T4t(){if(pH)return H2;pH=1;var e=_k();function t(n){return e(this.__data__,n)>-1}return H2=t,H2}var K2,mH;function _4t(){if(mH)return K2;mH=1;var e=_k();function t(n,r){var i=this.__data__,a=e(i,n);return a<0?(++this.size,i.push([n,r])):i[a][1]=r,this}return K2=t,K2}var J2,gH;function Xk(){if(gH)return J2;gH=1;var e=Q4t(),t=k4t(),n=P4t(),r=T4t(),i=_4t();function a(o){var s=-1,l=o==null?0:o.length;for(this.clear();++s<l;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,J2=a,J2}var eX,$H;function UA(){if($H)return eX;$H=1;var e=kf(),t=Yl(),n=e(t,"Map");return eX=n,eX}var tX,yH;function X4t(){if(yH)return tX;yH=1;var e=x4t(),t=Xk(),n=UA();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return tX=r,tX}var nX,vH;function R4t(){if(vH)return nX;vH=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return nX=e,nX}var rX,bH;function Rk(){if(bH)return rX;bH=1;var e=R4t();function t(n,r){var i=n.__data__;return e(r)?i[typeof r=="string"?"string":"hash"]:i.map}return rX=t,rX}var iX,wH;function E4t(){if(wH)return iX;wH=1;var e=Rk();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return iX=t,iX}var aX,SH;function q4t(){if(SH)return aX;SH=1;var e=Rk();function t(n){return e(this,n).get(n)}return aX=t,aX}var oX,xH;function j4t(){if(xH)return oX;xH=1;var e=Rk();function t(n){return e(this,n).has(n)}return oX=t,oX}var sX,QH;function C4t(){if(QH)return sX;QH=1;var e=Rk();function t(n,r){var i=e(this,n),a=i.size;return i.set(n,r),this.size+=i.size==a?0:1,this}return sX=t,sX}var lX,kH;function WA(){if(kH)return lX;kH=1;var e=X4t(),t=E4t(),n=q4t(),r=j4t(),i=C4t();function a(o){var s=-1,l=o==null?0:o.length;for(this.clear();++s<l;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,lX=a,lX}var cX,PH;function awe(){if(PH)return cX;PH=1;var e=WA(),t="Expected a function";function n(r,i){if(typeof r!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var a=function(){var o=arguments,s=i?i.apply(this,o):o[0],l=a.cache;if(l.has(s))return l.get(s);var c=r.apply(this,o);return a.cache=l.set(s,c)||l,c};return a.cache=new(n.Cache||e),a}return n.Cache=e,cX=n,cX}var uX,TH;function z4t(){if(TH)return uX;TH=1;var e=awe(),t=500;function n(r){var i=e(r,function(o){return a.size===t&&a.clear(),o}),a=i.cache;return i}return uX=n,uX}var OX,_H;function A4t(){if(_H)return OX;_H=1;var e=z4t(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(t,function(o,s,l,c){a.push(l?c.replace(n,"$1"):s||o)}),a});return OX=r,OX}var dX,XH;function YA(){if(XH)return dX;XH=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,a=Array(i);++r<i;)a[r]=n(t[r],r,t);return a}return dX=e,dX}var fX,RH;function U4t(){if(RH)return fX;RH=1;var e=iv(),t=YA(),n=Wa(),r=pm(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(s){if(typeof s=="string")return s;if(n(s))return t(s,o)+"";if(r(s))return a?a.call(s):"";var l=s+"";return l=="0"&&1/s==-1/0?"-0":l}return fX=o,fX}var hX,EH;function owe(){if(EH)return hX;EH=1;var e=U4t();function t(n){return n==null?"":e(n)}return hX=t,hX}var pX,qH;function swe(){if(qH)return pX;qH=1;var e=Wa(),t=CA(),n=A4t(),r=owe();function i(a,o){return e(a)?a:t(a,o)?[a]:n(r(a))}return pX=i,pX}var mX,jH;function Ek(){if(jH)return mX;jH=1;var e=pm();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return mX=t,mX}var gX,CH;function GA(){if(CH)return gX;CH=1;var e=swe(),t=Ek();function n(r,i){i=e(i,r);for(var a=0,o=i.length;r!=null&&a<o;)r=r[t(i[a++])];return a&&a==o?r:void 0}return gX=n,gX}var $X,zH;function lwe(){if(zH)return $X;zH=1;var e=GA();function t(n,r,i){var a=n==null?void 0:e(n,r);return a===void 0?i:a}return $X=t,$X}var W4t=lwe();const Lo=Vn(W4t);var yX,AH;function Y4t(){if(AH)return yX;AH=1;function e(t){return t==null}return yX=e,yX}var G4t=Y4t();const Gt=Vn(G4t);var vX,UH;function N4t(){if(UH)return vX;UH=1;var e=tu(),t=Wa(),n=nu(),r="[object String]";function i(a){return typeof a=="string"||!t(a)&&n(a)&&e(a)==r}return vX=i,vX}var Z4t=N4t();const tf=Vn(Z4t);var I4t=zA();const Dt=Vn(I4t);var D4t=QO();const mm=Vn(D4t);var bX={exports:{}},Yn={};/**
|
|
823
823
|
* @license React
|
|
824
824
|
* react-is.production.min.js
|
|
825
825
|
*
|