local-operator-ui 0.34.4 → 0.34.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/out/renderer/assets/{_basePickBy-BjWAZQXr.js → _basePickBy-BkKJxyJh.js} +1 -1
  2. package/out/renderer/assets/{_baseUniq-Cu94P5Cs.js → _baseUniq-cNQUuhDm.js} +1 -1
  3. package/out/renderer/assets/{agent-details-page-D3TKoBM2.js → agent-details-page-CDfSseyL.js} +1 -1
  4. package/out/renderer/assets/{agent-hub-page-Dr8NRMne.js → agent-hub-page-DeqtOCyC.js} +1 -1
  5. package/out/renderer/assets/{agents-page-D0nrZ4jK.js → agents-page-DhY6k0Q0.js} +3 -3
  6. package/out/renderer/assets/{arc-BcIG8lly.js → arc-CuqQY6Uu.js} +1 -1
  7. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-B5dBvBjh.js → architectureDiagram-IEHRJDOE-BVKa_PuR.js} +1 -1
  8. package/out/renderer/assets/{blockDiagram-JOT3LUYC-TRgYgrFY.js → blockDiagram-JOT3LUYC-CD1gqc_H.js} +1 -1
  9. package/out/renderer/assets/{book-open-Dyf3Y08h.js → book-open-BkNVD8Xx.js} +1 -1
  10. package/out/renderer/assets/browser-page-D6l5Ptu6.js +1 -0
  11. package/out/renderer/assets/{browser-webauthn-prompt-fFFhfquY.js → browser-webauthn-prompt-B8ng7idq.js} +1 -1
  12. package/out/renderer/assets/{c4Diagram-VJAJSXHY-CLcAkTlp.js → c4Diagram-VJAJSXHY-DyS4ZatX.js} +1 -1
  13. package/out/renderer/assets/channel-CPWmP7Ef.js +1 -0
  14. package/out/renderer/assets/{chunk-4BMEZGHF-_gLVz34x.js → chunk-4BMEZGHF-DQGZQLip.js} +1 -1
  15. package/out/renderer/assets/{chunk-A2AXSNBT-BngMcr_7.js → chunk-A2AXSNBT-Cm9VUqLK.js} +1 -1
  16. package/out/renderer/assets/{chunk-AEK57VVT-DoByA_iy.js → chunk-AEK57VVT-BjRiVniF.js} +1 -1
  17. package/out/renderer/assets/{chunk-D6G4REZN-DN4Bz4cs.js → chunk-D6G4REZN-CZxOC9n0.js} +1 -1
  18. package/out/renderer/assets/{chunk-RZ5BOZE2-C5BBskcd.js → chunk-RZ5BOZE2-Dy1n_qf4.js} +1 -1
  19. package/out/renderer/assets/{chunk-XZIHB7SX-CjOHqhDZ.js → chunk-XZIHB7SX-DmbSj51F.js} +1 -1
  20. package/out/renderer/assets/classDiagram-GIVACNV2-9e-paHIE.js +1 -0
  21. package/out/renderer/assets/classDiagram-v2-COTLJTTW-9e-paHIE.js +1 -0
  22. package/out/renderer/assets/clone-BRJksaRn.js +1 -0
  23. package/out/renderer/assets/{console-mirror-Qv3vqtBV.js → console-mirror-B7AdscIi.js} +1 -1
  24. package/out/renderer/assets/{consoleCapture-Ykfsjjt6.js → consoleCapture-CrogV1iL.js} +1 -1
  25. package/out/renderer/assets/{conversation-input-sync-BBLRif5r.js → conversation-input-sync-PI547jwD.js} +5 -5
  26. package/out/renderer/assets/{dagre-OKDRZEBW-BzF0LS9r.js → dagre-OKDRZEBW-Da9pKfwp.js} +1 -1
  27. package/out/renderer/assets/{diagram-SSKATNLV-DvT7xcD0.js → diagram-SSKATNLV-C07oP0ft.js} +1 -1
  28. package/out/renderer/assets/{diagram-VNBRO52H-OVD00YKh.js → diagram-VNBRO52H-CLn3wcFR.js} +1 -1
  29. package/out/renderer/assets/{erDiagram-Q7BY3M3F-BLbF6fxZ.js → erDiagram-Q7BY3M3F-CrjOf9UL.js} +1 -1
  30. package/out/renderer/assets/{error-boundary-DVehjxso.js → error-boundary-S6g2GwKk.js} +1 -1
  31. package/out/renderer/assets/{flowDiagram-4HSFHLVR-44sKEzZD.js → flowDiagram-4HSFHLVR-DWl0sE_3.js} +1 -1
  32. package/out/renderer/assets/{ganttDiagram-APWFNJXF-t9K-pFb9.js → ganttDiagram-APWFNJXF-B9w9EQt7.js} +1 -1
  33. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BGC4ipwC.js → gitGraphDiagram-7IBYFJ6S-ByM3Fqbh.js} +1 -1
  34. package/out/renderer/assets/{graph-CiaFojPa.js → graph-DZHGAAdt.js} +1 -1
  35. package/out/renderer/assets/{index-CZag_dL3.js → index--uFia_sW.js} +3 -3
  36. package/out/renderer/assets/{index-CoUIFHSn.js → index-BcrGfet8.js} +1 -1
  37. package/out/renderer/assets/{index-UUykMdEe.js → index-D4J50qwi.js} +1 -1
  38. package/out/renderer/assets/{index-CMwkLolk.css → index-UN1QuqvT.css} +1 -1
  39. package/out/renderer/assets/{infoDiagram-PH2N3AL5-DNohsSJa.js → infoDiagram-PH2N3AL5-spdzKWeL.js} +1 -1
  40. package/out/renderer/assets/{installer-CFuVJdYM.js → installer-q9AlWXtv.js} +1 -1
  41. package/out/renderer/assets/{journeyDiagram-U35MCT3I-D16df9pv.js → journeyDiagram-U35MCT3I-LW6IoM86.js} +1 -1
  42. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BUxqanTR.js → kanban-definition-NDS4AKOZ-CVs0gbCf.js} +1 -1
  43. package/out/renderer/assets/{layout-AvXFIlrB.js → layout-BezejTsO.js} +1 -1
  44. package/out/renderer/assets/{legacy-agents-page-CGb0zZeV.js → legacy-agents-page-C319C2ez.js} +1 -1
  45. package/out/renderer/assets/{mermaid.core-SK1P8eeE.js → mermaid.core-CKrFHA95.js} +5 -5
  46. package/out/renderer/assets/{mesh-page-BMwQs-Xo.js → mesh-page-D-ac6NDi.js} +1 -1
  47. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BBKAf4SQ.js → mindmap-definition-ALO5MXBD-D_TRsDdy.js} +1 -1
  48. package/out/renderer/assets/{mini-CnXXLMCg.js → mini-pMqNkw1N.js} +1 -1
  49. package/out/renderer/assets/{org-surface-gate-DINi8ioU.js → org-surface-gate-BptG-6hB.js} +1 -1
  50. package/out/renderer/assets/{page-header-D6O201wP.js → page-header-B3QWXojp.js} +1 -1
  51. package/out/renderer/assets/{pieDiagram-IB7DONF6-BRjQiU5e.js → pieDiagram-IB7DONF6-CTe2KLDS.js} +1 -1
  52. package/out/renderer/assets/{projects-page-C6RproBc.js → projects-page-CrLOnZHl.js} +1 -1
  53. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-Bz4x89NT.js → quadrantDiagram-7GDLP6J5-ykjFhHE3.js} +1 -1
  54. package/out/renderer/assets/{radar-MK3ICKWK-esE1imNv.js → radar-MK3ICKWK-EDGzX3LL.js} +1 -1
  55. package/out/renderer/assets/{radient-auth-buttons-Cz-iUWwT.js → radient-auth-buttons-hXLfGgoK.js} +1 -1
  56. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B2ukWBum.js → requirementDiagram-KVF5MWMF-CjV4O2ll.js} +1 -1
  57. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DHLIRBJK.js → sankeyDiagram-QLVOVGJD-qUS7B85l.js} +1 -1
  58. package/out/renderer/assets/{schedules-page-Dau_b2d-.js → schedules-page-C_lxIxwS.js} +1 -1
  59. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-kJOBG-_k.js → sequenceDiagram-X6HHIX6F-C7Of5ZsK.js} +1 -1
  60. package/out/renderer/assets/{settings-page-oyBL3Ga-.js → settings-page-KcDjOdWI.js} +1 -1
  61. package/out/renderer/assets/{settings-section-Bddb8t_I.js → settings-section-eCy-EDNn.js} +1 -1
  62. package/out/renderer/assets/{stateDiagram-DGXRK772-DpgKSYqd.js → stateDiagram-DGXRK772-Cweo7yv1.js} +1 -1
  63. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BJi4F5xW.js +1 -0
  64. package/out/renderer/assets/{timeline-definition-BDJGKUSR-BxhtiPAH.js → timeline-definition-BDJGKUSR-CcItWt5N.js} +1 -1
  65. package/out/renderer/assets/{ui-preferences-store-_zQDDc0_.js → ui-preferences-store-DXlcXfat.js} +1 -1
  66. package/out/renderer/assets/{use-download-agent-mutation-SbKYFb5k.js → use-download-agent-mutation-CYbyPF1N.js} +1 -1
  67. package/out/renderer/assets/{use-memberships-query-CLAPPcT-.js → use-memberships-query-zYf2lgz3.js} +1 -1
  68. package/out/renderer/assets/{use-session-snapshot-WcN6dbCh.js → use-session-snapshot-CKOVbmbV.js} +1 -1
  69. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-C1jsA1eo.js → xychartDiagram-VJFVF3MP-DoNtv3Ci.js} +1 -1
  70. package/out/renderer/console-capture.html +5 -5
  71. package/out/renderer/index.html +7 -7
  72. package/out/renderer/installer.html +4 -4
  73. package/out/renderer/mini.html +7 -7
  74. package/package.json +1 -1
  75. package/out/renderer/assets/browser-page-D0E3eDLk.js +0 -1
  76. package/out/renderer/assets/channel-D1Ag_ahE.js +0 -1
  77. package/out/renderer/assets/classDiagram-GIVACNV2-BpWf-5SW.js +0 -1
  78. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BpWf-5SW.js +0 -1
  79. package/out/renderer/assets/clone-DXb9-JqD.js +0 -1
  80. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BzuaXA9D.js +0 -1
  81. /package/out/renderer/assets/{index-yIQOKh01.js → index-BkcJ58S7.js} +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CoUIFHSn.js","./ui-preferences-store-_zQDDc0_.js","./index-yIQOKh01.js","./index-CMwkLolk.css","./error-boundary-DVehjxso.js","./index-UUykMdEe.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-SK1P8eeE.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
- import{c as Yi,p as Ys,a8 as xae,u as Ln,a9 as T5e,aa as _5e,ab as X5e,ac as tW,ad as R5e,V as E5e,a1 as q5e,ae as j5e,a4 as C5e,af as z5e,ag as A5e,X as nW,Y as U5e,ah as Qae,a as rW,r as W5e}from"./ui-preferences-store-_zQDDc0_.js";import{r as y,b as L,j as h,f as Y5e,c as q,g as Fn,w as kae,x as bv,e as vn,t as AE}from"./index-yIQOKh01.js";import{a6 as G5e,c as Ve,B as Ae,ak as e6,al as t6,am as n6,an as N5e,ao as r6,ap as Z5e,f as Nt,q as fw,r as I5e,T as Ad,j as wd,C as Jc,X as Wi,a7 as D5e,aC as V5e,aD as M5e,aE as L5e,A as Ql,S as ts,k as Pae,g as Mg,h as Lg,aB as i6,i as Jh,D as Tae,l as _ae,m as Xae,p as $c,aH as F5e,U as B5e,V as H5e,W as K5e,aj as J5e,R as Jx,y as eTe,N as tTe,O as nTe,P as rTe,I as Ya,s as Rae,t as Eae,u as qae,v as jae,w as UE,x as iTe,ai as WE,L as Cae,aI as aTe,Y as oTe,e as oo,z as sTe,F as lTe,G as iW,H as aW,J as cTe,K as oW,aq as uTe,aJ as OTe,a as dTe,n as BP,o as sW,E as lW}from"./error-boundary-DVehjxso.js";var Sn;(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})(Sn||(Sn={}));var YE;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(YE||(YE={}));const nt=Sn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pc=e=>{switch(typeof e){case"undefined":return nt.undefined;case"string":return nt.string;case"number":return isNaN(e)?nt.nan:nt.number;case"boolean":return nt.boolean;case"function":return nt.function;case"bigint":return nt.bigint;case"symbol":return nt.symbol;case"object":return Array.isArray(e)?nt.array:e===null?nt.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?nt.promise:typeof Map<"u"&&e instanceof Map?nt.map:typeof Set<"u"&&e instanceof Set?nt.set:typeof Date<"u"&&e instanceof Date?nt.date:nt.object;default:return nt.unknown}},Ce=Sn.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"]),fTe=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Aa 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 Aa))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Sn.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()}}Aa.create=e=>new Aa(e);const ep=(e,t)=>{let n;switch(e.code){case Ce.invalid_type:e.received===nt.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Ce.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Sn.jsonStringifyReplacer)}`;break;case Ce.unrecognized_keys:n=`Unrecognized key(s) in object: ${Sn.joinValues(e.keys,", ")}`;break;case Ce.invalid_union:n="Invalid input";break;case Ce.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Sn.joinValues(e.options)}`;break;case Ce.invalid_enum_value:n=`Invalid enum value. Expected ${Sn.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}"`:Sn.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,Sn.assertNever(e)}return{message:n}};let zae=ep;function hTe(e){zae=e}function hw(){return zae}const pw=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}},pTe=[];function Be(e,t){const n=hw(),r=pw({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ep?void 0:ep].filter(i=>!!i)});e.common.issues.push(r)}class ra{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 Ut;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 ra.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 Ut;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 Ut=Object.freeze({status:"aborted"}),yh=e=>({status:"dirty",value:e}),Sa=e=>({status:"valid",value:e}),GE=e=>e.status==="aborted",NE=e=>e.status==="dirty",Ud=e=>e.status==="valid",R0=e=>typeof Promise<"u"&&e instanceof Promise;function mw(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 Aae(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 pt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(pt||(pt={}));var Qg,kg;class El{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 cW=(e,t)=>{if(Ud(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 Aa(e.common.issues);return this._error=n,this._error}}};function Ht(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 an{get description(){return this._def.description}_getType(t){return pc(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:pc(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ra,ctx:{common:t.parent.common,data:t.data,parsedType:pc(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(R0(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:pc(t)},a=this._parseSync({data:t,path:i.path,parent:i});return cW(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:pc(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:i});return Ud(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=>Ud(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:pc(t)},i=this._parse({data:t,path:r.path,parent:r}),a=await(R0(i)?i:Promise.resolve(i));return cW(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 zs({schema:this,typeName:zt.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 kl.create(this,this._def)}nullable(){return aO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qs.create(this)}promise(){return np.create(this,this._def)}or(t){return C0.create([this,t],this._def)}and(t){return z0.create(this,t,this._def)}transform(t){return new zs({...Ht(this._def),schema:this,typeName:zt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new G0({...Ht(this._def),innerType:this,defaultValue:n,typeName:zt.ZodDefault})}brand(){return new a6({typeName:zt.ZodBranded,type:this,...Ht(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new N0({...Ht(this._def),innerType:this,catchValue:n,typeName:zt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Qy.create(this,t)}readonly(){return Z0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const mTe=/^c[^\s-]{8,}$/i,gTe=/^[0-9a-z]+$/,$Te=/^[0-9A-HJKMNP-TV-Z]{26}$/i,yTe=/^[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,vTe=/^[a-z0-9_-]{21}$/i,bTe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,wTe=/^[-+]?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)?)??$/,STe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xTe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let HP;const QTe=/^(?:(?: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])$/,kTe=/^(?:(?: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])$/,PTe=/^(([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]))$/,TTe=/^(([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])$/,_Te=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,XTe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Uae="((\\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])))",RTe=new RegExp(`^${Uae}$`);function Wae(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 ETe(e){return new RegExp(`^${Wae(e)}$`)}function Yae(e){let t=`${Uae}T${Wae(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 qTe(e,t){return!!((t==="v4"||!t)&&QTe.test(e)||(t==="v6"||!t)&&PTe.test(e))}function jTe(e,t){if(!bTe.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 CTe(e,t){return!!((t==="v4"||!t)&&kTe.test(e)||(t==="v6"||!t)&&TTe.test(e))}class Rs extends an{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==nt.string){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:nt.string,received:a.parsedType}),Ut}const r=new ra;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")STe.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")HP||(HP=new RegExp(xTe,"u")),HP.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")yTe.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")vTe.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")mTe.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")gTe.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")$Te.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"?Yae(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"?RTe.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?ETe(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"?wTe.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"duration",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?qTe(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"?jTe(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"?CTe(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"?_Te.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"base64",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?XTe.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"base64url",code:Ce.invalid_string,message:a.message}),r.dirty()):Sn.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,...pt.errToObj(r)})}_addCheck(t){return new Rs({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...pt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...pt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...pt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...pt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...pt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...pt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...pt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...pt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...pt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...pt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...pt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...pt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...pt.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,...pt.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,...pt.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...pt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...pt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...pt.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...pt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...pt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...pt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...pt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...pt.errToObj(n)})}nonempty(t){return this.min(1,pt.errToObj(t))}trim(){return new Rs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Rs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Rs({...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}}Rs.create=e=>{var t;return new Rs({checks:[],typeName:zt.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Ht(e)})};function zTe(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 nO extends an{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)!==nt.number){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:nt.number,received:a.parsedType}),Ut}let r;const i=new ra;for(const a of this._def.checks)a.kind==="int"?Sn.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"?zTe(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()):Sn.assertNever(a);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,pt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,pt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,pt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,pt.toString(n))}setLimit(t,n,r,i){return new nO({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:pt.toString(i)}]})}_addCheck(t){return new nO({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:pt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:pt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:pt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:pt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:pt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:pt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:pt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:pt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:pt.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"&&Sn.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)}}nO.create=e=>new nO({checks:[],typeName:zt.ZodNumber,coerce:e?.coerce||!1,...Ht(e)});class rO extends an{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)!==nt.bigint)return this._getInvalidInput(t);let r;const i=new ra;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()):Sn.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Be(n,{code:Ce.invalid_type,expected:nt.bigint,received:n.parsedType}),Ut}gte(t,n){return this.setLimit("min",t,!0,pt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,pt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,pt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,pt.toString(n))}setLimit(t,n,r,i){return new rO({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:pt.toString(i)}]})}_addCheck(t){return new rO({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:pt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:pt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:pt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:pt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:pt.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}}rO.create=e=>{var t;return new rO({checks:[],typeName:zt.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Ht(e)})};class E0 extends an{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==nt.boolean){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.boolean,received:r.parsedType}),Ut}return Sa(t.data)}}E0.create=e=>new E0({typeName:zt.ZodBoolean,coerce:e?.coerce||!1,...Ht(e)});class Wd extends an{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==nt.date){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:nt.date,received:a.parsedType}),Ut}if(isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_date}),Ut}const r=new ra;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()):Sn.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Wd({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:pt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:pt.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}}Wd.create=e=>new Wd({checks:[],coerce:e?.coerce||!1,typeName:zt.ZodDate,...Ht(e)});class gw extends an{_parse(t){if(this._getType(t)!==nt.symbol){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.symbol,received:r.parsedType}),Ut}return Sa(t.data)}}gw.create=e=>new gw({typeName:zt.ZodSymbol,...Ht(e)});class q0 extends an{_parse(t){if(this._getType(t)!==nt.undefined){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.undefined,received:r.parsedType}),Ut}return Sa(t.data)}}q0.create=e=>new q0({typeName:zt.ZodUndefined,...Ht(e)});class j0 extends an{_parse(t){if(this._getType(t)!==nt.null){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.null,received:r.parsedType}),Ut}return Sa(t.data)}}j0.create=e=>new j0({typeName:zt.ZodNull,...Ht(e)});class tp extends an{constructor(){super(...arguments),this._any=!0}_parse(t){return Sa(t.data)}}tp.create=e=>new tp({typeName:zt.ZodAny,...Ht(e)});class Sd extends an{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Sa(t.data)}}Sd.create=e=>new Sd({typeName:zt.ZodUnknown,...Ht(e)});class Ac extends an{_parse(t){const n=this._getOrReturnCtx(t);return Be(n,{code:Ce.invalid_type,expected:nt.never,received:n.parsedType}),Ut}}Ac.create=e=>new Ac({typeName:zt.ZodNever,...Ht(e)});class $w extends an{_parse(t){if(this._getType(t)!==nt.undefined){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.void,received:r.parsedType}),Ut}return Sa(t.data)}}$w.create=e=>new $w({typeName:zt.ZodVoid,...Ht(e)});class qs extends an{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==nt.array)return Be(n,{code:Ce.invalid_type,expected:nt.array,received:n.parsedType}),Ut;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 El(n,o,n.path,s)))).then(o=>ra.mergeArray(r,o));const a=[...n.data].map((o,s)=>i.type._parseSync(new El(n,o,n.path,s)));return ra.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new qs({...this._def,minLength:{value:t,message:pt.toString(n)}})}max(t,n){return new qs({...this._def,maxLength:{value:t,message:pt.toString(n)}})}length(t,n){return new qs({...this._def,exactLength:{value:t,message:pt.toString(n)}})}nonempty(t){return this.min(1,t)}}qs.create=(e,t)=>new qs({type:e,minLength:null,maxLength:null,exactLength:null,typeName:zt.ZodArray,...Ht(t)});function fh(e){if(e instanceof Tr){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=kl.create(fh(r))}return new Tr({...e._def,shape:()=>t})}else return e instanceof qs?new qs({...e._def,type:fh(e.element)}):e instanceof kl?kl.create(fh(e.unwrap())):e instanceof aO?aO.create(fh(e.unwrap())):e instanceof ql?ql.create(e.items.map(t=>fh(t))):e}class Tr extends an{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=Sn.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==nt.object){const c=this._getOrReturnCtx(t);return Be(c,{code:Ce.invalid_type,expected:nt.object,received:c.parsedType}),Ut}const{status:r,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof Ac&&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 El(i,O,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ac){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 El(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=>ra.mergeObjectSync(r,c)):ra.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return pt.errToObj,new Tr({...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=pt.errToObj(t).message)!==null&&s!==void 0?s:l}:{message:l}}}:{}})}strip(){return new Tr({...this._def,unknownKeys:"strip"})}passthrough(){return new Tr({...this._def,unknownKeys:"passthrough"})}extend(t){return new Tr({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Tr({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:zt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Tr({...this._def,catchall:t})}pick(t){const n={};return Sn.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new Tr({...this._def,shape:()=>n})}omit(t){const n={};return Sn.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new Tr({...this._def,shape:()=>n})}deepPartial(){return fh(this)}partial(t){const n={};return Sn.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}),new Tr({...this._def,shape:()=>n})}required(t){const n={};return Sn.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof kl;)a=a._def.innerType;n[r]=a}}),new Tr({...this._def,shape:()=>n})}keyof(){return Gae(Sn.objectKeys(this.shape))}}Tr.create=(e,t)=>new Tr({shape:()=>e,unknownKeys:"strip",catchall:Ac.create(),typeName:zt.ZodObject,...Ht(t)});Tr.strictCreate=(e,t)=>new Tr({shape:()=>e,unknownKeys:"strict",catchall:Ac.create(),typeName:zt.ZodObject,...Ht(t)});Tr.lazycreate=(e,t)=>new Tr({shape:e,unknownKeys:"strip",catchall:Ac.create(),typeName:zt.ZodObject,...Ht(t)});class C0 extends an{_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 Aa(s.ctx.common.issues));return Be(n,{code:Ce.invalid_union,unionErrors:o}),Ut}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 Aa(l));return Be(n,{code:Ce.invalid_union,unionErrors:s}),Ut}}get options(){return this._def.options}}C0.create=(e,t)=>new C0({options:e,typeName:zt.ZodUnion,...Ht(t)});const nc=e=>e instanceof U0?nc(e.schema):e instanceof zs?nc(e.innerType()):e instanceof W0?[e.value]:e instanceof iO?e.options:e instanceof Y0?Sn.objectValues(e.enum):e instanceof G0?nc(e._def.innerType):e instanceof q0?[void 0]:e instanceof j0?[null]:e instanceof kl?[void 0,...nc(e.unwrap())]:e instanceof aO?[null,...nc(e.unwrap())]:e instanceof a6||e instanceof Z0?nc(e.unwrap()):e instanceof N0?nc(e._def.innerType):[];class eQ extends an{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==nt.object)return Be(n,{code:Ce.invalid_type,expected:nt.object,received:n.parsedType}),Ut;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]}),Ut)}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=nc(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 eQ({typeName:zt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Ht(r)})}}function ZE(e,t){const n=pc(e),r=pc(t);if(e===t)return{valid:!0,data:e};if(n===nt.object&&r===nt.object){const i=Sn.objectKeys(t),a=Sn.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(const s of a){const l=ZE(e[s],t[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(n===nt.array&&r===nt.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=ZE(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===nt.date&&r===nt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class z0 extends an{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(a,o)=>{if(GE(a)||GE(o))return Ut;const s=ZE(a.value,o.value);return s.valid?((NE(a)||NE(o))&&n.dirty(),{status:n.value,value:s.data}):(Be(r,{code:Ce.invalid_intersection_types}),Ut)};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}))}}z0.create=(e,t,n)=>new z0({left:e,right:t,typeName:zt.ZodIntersection,...Ht(n)});class ql extends an{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==nt.array)return Be(r,{code:Ce.invalid_type,expected:nt.array,received:r.parsedType}),Ut;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"}),Ut;!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 El(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>ra.mergeArray(n,o)):ra.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new ql({...this._def,rest:t})}}ql.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ql({items:e,typeName:zt.ZodTuple,rest:null,...Ht(t)})};class A0 extends an{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!==nt.object)return Be(r,{code:Ce.invalid_type,expected:nt.object,received:r.parsedType}),Ut;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in r.data)i.push({key:a._parse(new El(r,s,r.path,s)),value:o._parse(new El(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?ra.mergeObjectAsync(n,i):ra.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof an?new A0({keyType:t,valueType:n,typeName:zt.ZodRecord,...Ht(r)}):new A0({keyType:Rs.create(),valueType:t,typeName:zt.ZodRecord,...Ht(n)})}}class yw extends an{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!==nt.map)return Be(r,{code:Ce.invalid_type,expected:nt.map,received:r.parsedType}),Ut;const i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,l],c)=>({key:i._parse(new El(r,s,r.path,[c,"key"])),value:a._parse(new El(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 Ut;(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 Ut;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}}}}yw.create=(e,t,n)=>new yw({valueType:t,keyType:e,typeName:zt.ZodMap,...Ht(n)});class Yd extends an{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==nt.set)return Be(r,{code:Ce.invalid_type,expected:nt.set,received:r.parsedType}),Ut;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 Ut;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 El(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(t,n){return new Yd({...this._def,minSize:{value:t,message:pt.toString(n)}})}max(t,n){return new Yd({...this._def,maxSize:{value:t,message:pt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Yd.create=(e,t)=>new Yd({valueType:e,minSize:null,maxSize:null,typeName:zt.ZodSet,...Ht(t)});class qh extends an{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==nt.function)return Be(n,{code:Ce.invalid_type,expected:nt.function,received:n.parsedType}),Ut;function r(s,l){return pw({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hw(),ep].filter(c=>!!c),issueData:{code:Ce.invalid_arguments,argumentsError:l}})}function i(s,l){return pw({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hw(),ep].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 np){const s=this;return Sa(async function(...l){const c=new Aa([]),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 Sa(function(...l){const c=s._def.args.safeParse(l,a);if(!c.success)throw new Aa([r(l,c.error)]);const u=Reflect.apply(o,this,c.data),O=s._def.returns.safeParse(u,a);if(!O.success)throw new Aa([i(u,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new qh({...this._def,args:ql.create(t).rest(Sd.create())})}returns(t){return new qh({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new qh({args:t||ql.create([]).rest(Sd.create()),returns:n||Sd.create(),typeName:zt.ZodFunction,...Ht(r)})}}class U0 extends an{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})}}U0.create=(e,t)=>new U0({getter:e,typeName:zt.ZodLazy,...Ht(t)});class W0 extends an{_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}),Ut}return{status:"valid",value:t.data}}get value(){return this._def.value}}W0.create=(e,t)=>new W0({value:e,typeName:zt.ZodLiteral,...Ht(t)});function Gae(e,t){return new iO({values:e,typeName:zt.ZodEnum,...Ht(t)})}class iO extends an{constructor(){super(...arguments),Qg.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Be(n,{expected:Sn.joinValues(r),received:n.parsedType,code:Ce.invalid_type}),Ut}if(mw(this,Qg)||Aae(this,Qg,new Set(this._def.values)),!mw(this,Qg).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}),Ut}return Sa(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 iO.create(t,{...this._def,...n})}exclude(t,n=this._def){return iO.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Qg=new WeakMap;iO.create=Gae;class Y0 extends an{constructor(){super(...arguments),kg.set(this,void 0)}_parse(t){const n=Sn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==nt.string&&r.parsedType!==nt.number){const i=Sn.objectValues(n);return Be(r,{expected:Sn.joinValues(i),received:r.parsedType,code:Ce.invalid_type}),Ut}if(mw(this,kg)||Aae(this,kg,new Set(Sn.getValidEnumValues(this._def.values))),!mw(this,kg).has(t.data)){const i=Sn.objectValues(n);return Be(r,{received:r.data,code:Ce.invalid_enum_value,options:i}),Ut}return Sa(t.data)}get enum(){return this._def.values}}kg=new WeakMap;Y0.create=(e,t)=>new Y0({values:e,typeName:zt.ZodNativeEnum,...Ht(t)});class np extends an{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==nt.promise&&n.common.async===!1)return Be(n,{code:Ce.invalid_type,expected:nt.promise,received:n.parsedType}),Ut;const r=n.parsedType===nt.promise?n.data:Promise.resolve(n.data);return Sa(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}np.create=(e,t)=>new np({type:e,typeName:zt.ZodPromise,...Ht(t)});class zs extends an{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zt.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 Ut;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?Ut:l.status==="dirty"||n.value==="dirty"?yh(l.value):l});{if(n.value==="aborted")return Ut;const s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?Ut:s.status==="dirty"||n.value==="dirty"?yh(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"?Ut:(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"?Ut:(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(!Ud(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=>Ud(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):o);Sn.assertNever(i)}}zs.create=(e,t,n)=>new zs({schema:e,typeName:zt.ZodEffects,effect:t,...Ht(n)});zs.createWithPreprocess=(e,t,n)=>new zs({schema:t,effect:{type:"preprocess",transform:e},typeName:zt.ZodEffects,...Ht(n)});class kl extends an{_parse(t){return this._getType(t)===nt.undefined?Sa(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}kl.create=(e,t)=>new kl({innerType:e,typeName:zt.ZodOptional,...Ht(t)});class aO extends an{_parse(t){return this._getType(t)===nt.null?Sa(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}aO.create=(e,t)=>new aO({innerType:e,typeName:zt.ZodNullable,...Ht(t)});class G0 extends an{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===nt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}G0.create=(e,t)=>new G0({innerType:e,typeName:zt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ht(t)});class N0 extends an{_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 R0(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Aa(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Aa(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}N0.create=(e,t)=>new N0({innerType:e,typeName:zt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ht(t)});class vw extends an{_parse(t){if(this._getType(t)!==nt.nan){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.nan,received:r.parsedType}),Ut}return{status:"valid",value:t.data}}}vw.create=e=>new vw({typeName:zt.ZodNaN,...Ht(e)});const ATe=Symbol("zod_brand");class a6 extends an{_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 Qy extends an{_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"?Ut:a.status==="dirty"?(n.dirty(),yh(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"?Ut: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 Qy({in:t,out:n,typeName:zt.ZodPipeline})}}class Z0 extends an{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ud(i)&&(i.value=Object.freeze(i.value)),i);return R0(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Z0.create=(e,t)=>new Z0({innerType:e,typeName:zt.ZodReadonly,...Ht(t)});function uW(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Nae(e,t={},n){return e?tp.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=uW(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=uW(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})}}):tp.create()}const UTe={object:Tr.lazycreate};var zt;(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"})(zt||(zt={}));const WTe=(e,t={message:`Input not instance of ${e.name}`})=>Nae(n=>n instanceof e,t),Zae=Rs.create,Iae=nO.create,YTe=vw.create,GTe=rO.create,Dae=E0.create,NTe=Wd.create,ZTe=gw.create,ITe=q0.create,DTe=j0.create,VTe=tp.create,MTe=Sd.create,LTe=Ac.create,FTe=$w.create,BTe=qs.create,HTe=Tr.create,KTe=Tr.strictCreate,JTe=C0.create,e_e=eQ.create,t_e=z0.create,n_e=ql.create,r_e=A0.create,i_e=yw.create,a_e=Yd.create,o_e=qh.create,s_e=U0.create,l_e=W0.create,c_e=iO.create,u_e=Y0.create,O_e=np.create,OW=zs.create,d_e=kl.create,f_e=aO.create,h_e=zs.createWithPreprocess,p_e=Qy.create,m_e=()=>Zae().optional(),g_e=()=>Iae().optional(),$_e=()=>Dae().optional(),y_e={string:e=>Rs.create({...e,coerce:!0}),number:e=>nO.create({...e,coerce:!0}),boolean:e=>E0.create({...e,coerce:!0}),bigint:e=>rO.create({...e,coerce:!0}),date:e=>Wd.create({...e,coerce:!0})},v_e=Ut;var X=Object.freeze({__proto__:null,defaultErrorMap:ep,setErrorMap:hTe,getErrorMap:hw,makeIssue:pw,EMPTY_PATH:pTe,addIssueToContext:Be,ParseStatus:ra,INVALID:Ut,DIRTY:yh,OK:Sa,isAborted:GE,isDirty:NE,isValid:Ud,isAsync:R0,get util(){return Sn},get objectUtil(){return YE},ZodParsedType:nt,getParsedType:pc,ZodType:an,datetimeRegex:Yae,ZodString:Rs,ZodNumber:nO,ZodBigInt:rO,ZodBoolean:E0,ZodDate:Wd,ZodSymbol:gw,ZodUndefined:q0,ZodNull:j0,ZodAny:tp,ZodUnknown:Sd,ZodNever:Ac,ZodVoid:$w,ZodArray:qs,ZodObject:Tr,ZodUnion:C0,ZodDiscriminatedUnion:eQ,ZodIntersection:z0,ZodTuple:ql,ZodRecord:A0,ZodMap:yw,ZodSet:Yd,ZodFunction:qh,ZodLazy:U0,ZodLiteral:W0,ZodEnum:iO,ZodNativeEnum:Y0,ZodPromise:np,ZodEffects:zs,ZodTransformer:zs,ZodOptional:kl,ZodNullable:aO,ZodDefault:G0,ZodCatch:N0,ZodNaN:vw,BRAND:ATe,ZodBranded:a6,ZodPipeline:Qy,ZodReadonly:Z0,custom:Nae,Schema:an,ZodSchema:an,late:UTe,get ZodFirstPartyTypeKind(){return zt},coerce:y_e,any:VTe,array:BTe,bigint:GTe,boolean:Dae,date:NTe,discriminatedUnion:e_e,effect:OW,enum:c_e,function:o_e,instanceof:WTe,intersection:t_e,lazy:s_e,literal:l_e,map:i_e,nan:YTe,nativeEnum:u_e,never:LTe,null:DTe,nullable:f_e,number:Iae,object:HTe,oboolean:$_e,onumber:g_e,optional:d_e,ostring:m_e,pipeline:p_e,preprocess:h_e,promise:O_e,record:r_e,set:a_e,strictObject:KTe,string:Zae,symbol:ZTe,transformer:OW,tuple:n_e,undefined:ITe,union:JTe,unknown:MTe,void:FTe,NEVER:v_e,ZodIssueCode:Ce,quotelessJson:fTe,ZodError:Aa});const Wt=X.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),wv=X.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),Sv=X.string().min(1).max(32768),o6=/^[a-f0-9]{12}$/,Rt=X.string().regex(o6),b_e=X.string().min(1).max(4096),KP=X.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),xv=X.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),dW=X.string().regex(/^[a-f0-9]{32}$/),Vae=/^(\/|[A-Za-z]:[\\/])/,JP=X.string().min(1).max(4096).regex(Vae),fW=/^[a-f0-9]{32}$/,Jn=X.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Nf=X.string().regex(/^[A-Za-z0-9_-]{1,128}$/),hW=X.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),pW=X.object({data_b64:X.string().min(1).max(1e6),mime_type:X.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),oO=2e5,I0=8,w_e=256,S_e=100,IE=16,s6=256,Mae=100,Lae=200,DE=1e6,Eo=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)),Qv=X.object({kind:X.enum(["agent","team"]),name:Eo}).strict(),e5=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(),mW=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(),gW=X.object({name:X.string().min(1).max(64).optional(),description:X.string().max(8e3).optional(),manager:Eo.optional(),members:X.array(X.object({role:Eo,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(),x_e=X.record(X.array(X.string().max(1024)).max(100)),$W=X.enum(["minutes","hours","days"]);function Q_e(e){return!/^\.+$/.test(e)}const Wen=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(Q_e),yW=X.enum(["str","int","float","bool","list","dict"]),vW=X.string().max(16384),k_e=2e3,bW=X.string().min(1).max(k_e),wW=X.string().min(1).max(64),P_e=X.string().min(1).max(64),SW=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(),T_e=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(),VE=128,xW=2e3,QW=8e3,kW=64,PW=64,tQ=e=>[...e].length,ME=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,__e=e=>e===9||e===10||e===11||e===12||e===13||e===133,X_e=e=>e<=31||e>=127&&e<=159,R_e=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),E_e=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,kv=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},Fae=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&ME(t[n].codePointAt(0)??0);)n++;for(;r>n&&ME(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},q_e=e=>{let t="",n=!1;for(const r of e){if(ME(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function j_e(e){const t=Fae(e);if(!t)return"must not be empty";if(tQ(t)>VE)return`must be at most ${VE} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(kv(t,E_e))return"must not contain Unicode bidirectional override characters";if(kv(t,__e))return"must not contain whitespace";if(kv(t,X_e))return"must not contain control characters";if(kv(t,R_e))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 Yen(e){return q_e(Fae(e).normalize("NFKC").toLowerCase())}function C_e(e){return e.trim()?tQ(e)>xW?`must be at most ${xW} characters`:null:"must not be empty"}function z_e(e){return e.trim()?tQ(e)>QW?`must be at most ${QW} characters`:null:"must not be empty"}function A_e(e){if(e.length>PW)return`must hold at most ${PW} items`;for(const t of e)if(!t.trim()||tQ(t)>kW)return`must hold items of 1 to ${kW} characters`;return null}const U_e=e=>j_e(e)===null,W_e=X.string().refine(U_e,{message:"That is not a name the hub can publish."}),Y_e=X.string().refine(e=>z_e(e)===null,{message:"That instruction body cannot be published."}),G_e=X.string().refine(e=>C_e(e)===null,{message:"That description cannot be published."}),N_e=X.array(X.string()).refine(e=>A_e(e)===null,{message:"That tool list cannot be published."}),TW=X.object({name:W_e,description:G_e,instructions:Y_e,kind:X.enum(["role","specialist"]),when_to_use:X.string(),tools:N_e,effort:X.string(),delegate:X.boolean(),version:X.string(),categories:X.array(X.string()),tags:X.array(X.string())}).partial().strict(),Z_e=X.enum(["team","agent"]),I_e=X.string().min(1).max(64),D_e=X.string().min(1).max(256),Bae=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,t5=X.string().regex(Bae,{message:"Letters, digits, dot, underscore and dash; no spaces."}),V_e=["planning","active","qa","validation","done","paused","archived"],_W=X.enum(V_e),Pv=X.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),XW=X.array(X.string().min(1).max(24)).max(8),gu=X.string().min(1).max(64),M_e=1e3,RW=240,EW=80,L_e=256,F_e=100,B_e=200,H_e=/^[a-z0-9][a-z0-9_-]{0,23}$/;function Gen(e){return e?Bae.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 Nen(e){return H_e.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const Tv=X.enum(["agent","team"]),K_e=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:Eo}).strict(),X.object({op:X.literal("profiles.install"),name:Eo,requestId:Jn}).strict(),X.object({op:X.literal("profiles.create"),name:Eo,requestId:Jn,fields:mW.extend({description:X.string().max(8e3),instructions:X.string().min(1).max(8e3)})}).strict(),X.object({op:X.literal("profiles.update"),name:Eo,requestId:Jn,fields:mW}).strict(),X.object({op:X.literal("hub.updates")}).strict(),X.object({op:X.literal("hub.check"),requestId:Jn,kind:Tv.optional(),name:Eo.optional()}).strict(),X.object({op:X.literal("hub.apply"),requestId:Jn,kind:Tv,name:Eo,prefer:X.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:X.boolean().optional(),dryRun:X.boolean().optional()}).strict(),X.object({op:X.literal("hub.applyAll"),requestId:Jn,kind:Tv.optional()}).strict(),X.object({op:X.literal("hub.retry"),requestId:Jn,kind:Tv,name:Eo}).strict(),X.object({op:X.literal("teams.list")}).strict(),X.object({op:X.literal("teams.get"),name:Eo}).strict(),X.object({op:X.literal("teams.create"),requestId:Jn,fields:gW.extend({name:X.string().min(1).max(64)})}).strict(),X.object({op:X.literal("teams.update"),name:Eo,requestId:Jn,fields:gW}).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:Z_e.optional(),scope_name:I_e.optional(),cursor:D_e.optional(),with_counts:X.boolean().optional()}).strict(),X.object({op:X.literal("delegated_cleanup_notice.ack")}).strict(),X.object({op:X.literal("sessions.search"),q:X.string().min(1).max(w_e),limit:X.number().int().min(1).max(500).optional(),include_archived:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.archive"),sessionId:Rt,archived:X.boolean()}).strict(),X.object({op:X.literal("sessions.delete"),sessionId:Rt,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.create"),requestId:Jn,cwd:X.string().min(1).max(4096).optional(),target:Qv.optional(),purpose:X.literal("agents-config").optional(),model:e5.optional(),draftId:Rt.optional(),peer:Nf.optional()}).strict(),X.object({op:X.literal("sessions.preview"),requestId:Jn,cwd:X.string().min(1).max(4096),target:Qv.optional(),model:e5.optional()}).strict(),X.object({op:X.literal("sessions.draft"),requestId:Jn,cwd:X.string().min(1).max(4096),target:Qv.optional(),model:e5.optional()}).strict(),X.object({op:X.literal("sessions.get"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.history"),sessionId:Rt,beforeId:Wt.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.checkpoints"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.checkpoints.warm"),sessionId:Rt,ids:X.array(Wt).max(IE).optional(),limit:X.number().int().min(1).max(IE).optional()}).strict(),X.object({op:X.literal("sessions.find"),sessionId:Rt,q:X.string().min(1).max(s6),limit:X.number().int().min(1).max(Lae).optional()}).strict(),X.object({op:X.literal("subagents.transcript"),sessionId:Rt,childId:Rt,beforeId:Wt.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.message"),sessionId:Rt,requestId:Jn,text:X.string().max(oO),images:X.array(pW).max(I0).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:Rt,requestId:Jn,command:X.string().regex(/^\/?[A-Za-z]+$/).max(64),args:X.string().max(oO).optional(),images:X.array(pW).max(I0).optional()}).strict(),X.object({op:X.literal("sessions.move"),sessionId:Rt,requestId:Jn,cwd:X.string().min(1).max(4096)}).strict(),X.object({op:X.literal("sessions.answer"),sessionId:Rt,epoch:Wt.optional(),requestId:Wt.optional(),value:X.string().max(32768).optional(),approved:X.boolean().optional(),questionIndex:X.number().int().min(0).optional(),askId:Wt.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:Rt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("attention.seen"),items:X.array(X.object({sessionId:Rt,completionToken:X.string().uuid()}).strict()).min(1).max(500)}).strict(),X.object({op:X.literal("sessions.notified"),sessionId:Rt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("sessions.pin"),sessionId:Rt,pinned:X.boolean()}).strict(),X.object({op:X.literal("sessions.watch"),sessionId:Rt,subscriptionId:X.string().regex(fW),visible:X.boolean(),canNotify:X.boolean()}).strict(),X.object({op:X.literal("sessions.warm"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.interrupt"),sessionId:Rt,requestId:Jn}).strict(),X.object({op:X.literal("sessions.variables.list"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.variables.create"),sessionId:Rt,key:S1,value:vW,type:yW}).strict(),X.object({op:X.literal("sessions.variables.update"),sessionId:Rt,key:S1,value:vW,type:yW}).strict(),X.object({op:X.literal("sessions.variables.delete"),sessionId:Rt,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:Wt}).strict(),X.object({op:X.literal("legacy.agent.upload"),agentId:Wt}).strict(),X.object({op:X.literal("agent.publish"),agentId:Wt,document:TW.optional(),visibility:X.literal("org").optional(),tenantId:Wt.optional()}).strict(),X.object({op:X.literal("agent.republish"),agentId:Wt,hubAgentId:Wt,document:TW.optional(),visibility:X.literal("org").optional(),tenantId:Wt.optional()}).strict(),X.object({op:X.literal("team.pull"),teamId:Wt,tenantId:Wt.optional()}).strict(),X.object({op:X.literal("agent.nameAvailability"),name:X.string().min(1).max(VE)}).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:Wt}).strict(),X.object({op:X.literal("legacy.agent.history"),agentId:Wt,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:Wt.optional(),status:X.string().max(64).optional()}).strict(),X.object({op:X.literal("legacy.job.get"),jobId:Wt}).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:Wt,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:Wt,schedule:SW.extend({prompt:X.string().max(64e3),interval:X.number().int().min(1),unit:$W})}).strict(),X.object({op:X.literal("legacy.schedule.get"),scheduleId:Wt}).strict(),X.object({op:X.literal("legacy.schedule.edit"),scheduleId:Wt,schedule:SW.extend({prompt:X.string().max(64e3).nullish(),interval:X.number().int().min(1).nullish(),unit:$W.nullish()})}).strict(),X.object({op:X.literal("legacy.schedule.remove"),scheduleId:Wt}).strict(),X.object({op:X.literal("legacy.agent.create"),agent:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.update"),agentId:Wt,update:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.delete"),agentId:Wt}).strict(),X.object({op:X.literal("legacy.agent.conversation.clear"),agentId:Wt}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.get"),agentId:Wt}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.update"),agentId:Wt,systemPrompt:X.string().max(DE)}).strict(),X.object({op:X.literal("legacy.agent.download"),agentId:Wt}).strict(),X.object({op:X.literal("legacy.job.cancel"),jobId:Wt}).strict(),X.object({op:X.literal("commands.list")}).strict(),X.object({op:X.literal("commands.entities"),sessionId:Rt,command:Wt,name:X.string().max(128).optional()}).strict(),X.object({op:X.literal("models.catalogue"),live:X.boolean().optional(),scope:X.enum(["usable","all"]).optional()}).strict(),X.object({op:X.literal("usage.get"),provider:Wt.optional(),live:X.boolean().optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("quota.notice"),provider:Wt.optional(),model:X.string().min(1).max(200).optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("analytics.get"),sessionId:Rt.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:Rt.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:Rt,recentLimit:X.number().int().min(0).max(50).optional()}).strict(),X.object({op:X.literal("skills.list"),sessionId:Rt.optional(),cwd:b_e.optional(),name:Wt.optional()}).strict(),X.object({op:X.literal("sessions.failovers"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.credential"),sessionId:Rt,action:X.enum(["list","store","forget"]),key:wv.optional(),value:Sv.optional(),confirmed:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.fork"),sessionId:Rt,requestId:Jn,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:Jn,targets:X.array(Rt).min(1).max(100),confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside"),sessionId:Rt,requestId:Jn,text:X.string().min(1).max(32768),asideId:Jn.optional(),subscriptionId:X.string().regex(fW).optional()}).strict(),X.object({op:X.literal("sessions.adopt"),sessionId:Rt,requestId:Jn,asideId:Jn,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside.get"),sessionId:Rt,asideId:Jn}).strict(),X.object({op:X.literal("sessions.aside.close"),sessionId:Rt,asideId:Jn}).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:Jn,sessionId:Rt.optional(),cwd:X.string().min(1).max(4096).optional(),target:Qv.optional(),message:bW,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:Rt,wakeId:wW,message:bW.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:Rt,wakeId:wW}).strict(),X.object({op:X.literal("monitors.cancel"),sessionId:Rt,monitorId:P_e}).strict(),X.object({op:X.literal("mcp.list"),sessionId:Rt}).strict(),X.object({op:X.literal("mcp.credentials.store"),sessionId:Rt,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:Rt,control:X.object({action:X.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:KP.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(xv).optional(),url:X.string().max(4096).optional(),headers:X.record(xv).optional(),oauth:X.boolean().optional(),confirmed:X.boolean().optional(),operation_id:dW.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog"),cwd:JP.optional(),sessionId:Rt.optional()}).strict(),X.object({op:X.literal("mcp.catalog.control"),cwd:JP.optional(),control:X.object({action:X.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:KP.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(xv).optional(),url:X.string().max(4096).optional(),headers:X.record(xv).optional(),confirmed:X.boolean().optional(),operation_id:dW.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog.credentials"),header:X.string().min(1).max(128).optional(),cwd:JP.optional(),name:KP,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","signup.resend"]),request_id:Jn.optional(),tenant_id:Wt.optional(),account_id:Wt.optional(),agent_id:Wt.optional(),comment_id:Wt.optional(),team_id:Wt.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:Wt}).strict(),X.object({op:X.literal("auth.status"),id:Wt}).strict(),X.object({op:X.literal("auth.input"),id:Wt,promptId:Wt,value:Sv}).strict(),X.object({op:X.literal("auth.cancel"),id:Wt}).strict(),X.object({op:X.literal("auth.key"),provider:Wt,value:Sv}).strict(),X.object({op:X.literal("auth.logout"),provider:Wt}).strict(),X.object({op:X.literal("settings.list")}).strict(),X.object({op:X.literal("settings.edit"),key:wv,value:X.unknown().refine(e=>e!==void 0,"A setting value is required."),base:x_e.optional()}).strict(),X.object({op:X.literal("settings.reset"),key:wv}).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:T_e}).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:wv,value:Sv}).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:Nf,role:X.enum(["read","drive","admin"]),deviceId:Nf.optional()}).strict(),X.object({op:X.literal("networks.member.remove"),networkId:Nf,deviceId:Nf,confirm:X.string().min(1).max(256)}).strict(),X.object({op:X.literal("sessions.transfer"),sessionId:Rt,to:X.union([X.literal("local"),Nf]),keep:X.boolean().optional(),waitS:X.number().min(0).max(300).optional(),requestId:Jn.optional()}).strict(),X.object({op:X.literal("approvals.list")}).strict(),X.object({op:X.literal("approvals.approve"),approvalId:hW}).strict(),X.object({op:X.literal("approvals.deny"),approvalId:hW}).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:gu}).strict(),X.object({op:X.literal("projects.create"),name:t5,description:X.string().max(RW).optional(),status:_W.optional(),tags:XW.optional()}).strict(),X.object({op:X.literal("projects.update"),key:gu,fields:X.object({name:t5.optional(),title:X.string().max(80).optional(),owner:X.string().max(80).optional(),team:X.string().max(80).optional(),description:X.string().max(RW).optional(),status:_W.optional(),progress:X.string().max(M_e).optional(),tags:XW.optional(),start_date:Pv.optional(),target_date:Pv.optional(),completed_at:Pv.optional(),estimate:X.number().positive().max(1e3).optional(),estimate_unit:X.enum(["points","days"]).optional()}).strict(),force_done:X.boolean().optional()}).strict(),X.object({op:X.literal("projects.delete"),key:gu,confirmed_name:t5}).strict(),X.object({op:X.literal("projects.link"),key:gu,sessionId:Rt}).strict(),X.object({op:X.literal("projects.unlink"),key:gu,sessionId:Rt}).strict(),X.object({op:X.literal("projects.milestone"),key:gu,name:X.string().min(1).max(EW),targetDate:Pv.optional(),completed:X.boolean().optional()}).strict(),X.object({op:X.literal("projects.milestone.remove"),key:gu,name:X.string().min(1).max(EW)}).strict(),X.object({op:X.literal("projects.request_update"),key:gu}).strict(),X.object({op:X.literal("projects.search"),q:X.string().min(1).max(L_e),limit:X.number().int().min(1).max(B_e).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(),X.object({op:X.literal("code_requests.list"),sessionId:Rt}).strict(),X.object({op:X.literal("code_requests.refresh"),sessionId:Rt,keys:X.array(X.string().min(1).max(512)).max(256).optional(),force:X.boolean().optional()}).strict()]);K_e.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 ho={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},l6={runtimeUnreachable:"runtime_unreachable"},nm="runtime_busy",Hae="runtime_retiring",nQ={[ho.noCredential]:"This app is not paired with the running Local Operator server, so this control is unavailable.",[ho.refused]:"This app's credential for the running Local Operator server was refused, so this control is unavailable.",[ho.planeClosed]:"The running Local Operator server does not accept this app's desktop controls.",[ho.transportFailed]:"The Local Operator server did not answer this request."},D0={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 V0(e){return e!==void 0&&Object.values(ho).includes(e)}function J_e(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return ho.refused;if(t===503)return ho.planeClosed}}const e2e=88e4,t2e=11e5,n2e=2e4,r2e=9e4,i2e=new Set(["analytics.get","analytics.models","sessions.report"]),a2e=new Set(["usage.get"]),o2e=new Set(["networks.list","peers.list"]),s2e=new Set([...i2e,...a2e,...o2e]),l2e=90,c2e=30,u2e=300,O2e=10,Kae=15,d2e=1e4;function f2e(e){const n=e.to==="local"||e.keep?u2e:c2e,r=Math.max(0,e.waitS??0);return(l2e+n+O2e+Kae)*1e3+r*1e3}const h2e=18e4,p2e=h2e+15e3,m2e=120,Jae=(m2e+30+Kae)*1e3,g2e=6e4,$2e=5*Jae,y2e=new Set(["hub.apply","hub.retry","hub.check","hub.applyAll"]);function v2e(e){switch(e){case"hub.apply":case"hub.retry":return Jae;case"hub.check":return g2e;case"hub.applyAll":return $2e;default:return null}}function b2e(e){if(typeof e!="string"&&e.op==="sessions.transfer")return f2e(e)+d2e;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return p2e;const n=v2e(t);return n!==null?n:s2e.has(t)?r2e:n2e}const w2e=5e3;function c6(e){return b2e(e)+w2e}const rQ="deadline_exceeded",eoe="foreground_required",toe="View these completions in the foreground before marking them read.",S2e=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","quota.notice","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"]),x2e=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function Q2e(e,t){const n=Math.round(t/1e3),r=rQ;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.`}:y2e.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:S2e.has(e)?{code:r,message:x2e.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 iQ=e2e,k2e=t2e;X.object({state:X.enum(["ok","depleted","limit_reached","unverified","unknown","not_applicable"]),provider:X.string(),kind:X.enum(["balance","subscription","radient","none"]),model_free:X.boolean(),title:X.string(),body:X.string(),actions:X.array(X.object({id:X.enum(["open_url","resend_verification","refresh"]),label:X.string(),url:X.string().nullable().optional()})),resets_at_ms:X.number().int().nullable().optional(),checked_at_ms:X.number().int(),age_ms:X.number().int().nullable().optional(),source:X.enum(["cached","live"])});function P2e(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function qW(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 jW(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 aQ(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"delegated_cleanup_notice.ack":return{path:"/v1/desktop/delegated-cleanup-notice/ack",method:"POST"};case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??S_e)});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??Mae)});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":{jW(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":{jW(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,...P2e(e),message:e.message,...qW(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...qW(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":{const t=e.scope?`&scope=${e.scope}`:"";return{path:`/v1/desktop/models?live=${e.live??!1}${t}`,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"quota.notice":{const t=new URLSearchParams({refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),{path:`/v1/desktop/quota-notice?${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,...e.force_done===!0?{force_done:!0}:{}}};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??F_e)})}`,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}};case"code_requests.list":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests`,method:"GET"};case"code_requests.refresh":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests/refresh`,method:"POST",body:{...e.keys!==void 0?{keys:e.keys}:{},...e.force!==void 0?{force:e.force}:{}}}}}const noe=64,CW=64*1024*1024,T2e="superseded_completion_token",_2e="store_busy",X2e="session_is_remote",R2e="owner_build_behind";function E2e(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 ud(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 roe(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const ioe=e=>typeof e?.goal_status=="string",aoe=e=>(e?.goal??"").trim().length>0;function q2e(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 Fg={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."},zW={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},j2e={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},C2e={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},z2e={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},A2e={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function AW(e){return e?e===Fg.notPaired?C2e:e===Fg.serverDown?j2e:e===Fg.frameBudget?A2e:zW:zW}const U2e=(e,t)=>e!==null&&e.message===t.message&&e.removed===t.removed&&e.max_age_hours===t.max_age_hours&&e.in_progress===t.in_progress&&e.first_removal_at===t.first_removal_at&&e.freed_bytes_estimate===t.freed_bytes_estimate&&e.record===t.record;function W2e(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.message!="string"||t.message.trim()==="")return null;const n=(r,i)=>typeof r=="number"&&Number.isFinite(r)?r:i;return{message:t.message,removed:n(t.removed,0),max_age_hours:n(t.max_age_hours,48),in_progress:t.in_progress===!0,first_removal_at:typeof t.first_removal_at=="string"?t.first_removal_at:"",freed_bytes_estimate:typeof t.freed_bytes_estimate=="number"&&Number.isFinite(t.freed_bytes_estimate)?t.freed_bytes_estimate:null,record:typeof t.record=="string"?t.record:""}}const ooe=Yi()(Ys(e=>({notice:null,receive:t=>e(n=>U2e(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:xae(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));async function soe(e){if(window.api?.desktop)try{return await Y2e(window.api.desktop.request(e),e)}catch(n){throw n instanceof Yt?n:V2e(n)?new Uc(toe,eoe):new Yt(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 Yt(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Yt(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function Y2e(e,t){const n=c6(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=Q2e(t.op,n);a(new Yt(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const loe="This server did not answer the request for its desktop controls.";class Yt 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 Uc extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function vo(e,t){return e instanceof Yt||e instanceof Uc?V0(e.code)?nQ[e.code]:e.message:t}function G2e(e,t,n,r){return typeof r=="string"?r:n===D0.noCredential?ho.noCredential:n===D0.transportFailed?ho.transportFailed:J_e(aQ(e).path,t)}async function Se(e){const t=await soe(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 Yt(t.status,r??loe,void 0,G2e(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 e.op==="sessions.list"&&N2e(n?.result),n?.result}function N2e(e){if(typeof e!="object"||e===null)return;const t=W2e(e.delegated_cleanup_notice);t&&ooe.getState().receive(t)}async function Z2e(){try{await Se({op:"delegated_cleanup_notice.ack"})}catch{}}async function Zen(){ooe.getState().dismiss(),await Z2e()}function coe(e){return e instanceof Yt&&e.code===rQ}function I2e(e){if(!(e instanceof Yt))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===R2e:e.code===X2e}function D2e(e){return e instanceof Uc&&e.code===eoe}function V2e(e){return e instanceof Error&&e.message.includes(toe)}async function En(e){const t=await soe(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function M2e(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Se({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 L2e(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:Fg.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function rp(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===D0.noCredential?ho.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 M0(e){return e.kind==="error"?V0(e.code)?new Uc(nQ[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const uoe=/\s+/,F2e=/[\\/]+$/,B2e=/[\\/]/,Ooe=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-BcrGfet8.js","./ui-preferences-store-DXlcXfat.js","./index-BkcJ58S7.js","./index-UN1QuqvT.css","./error-boundary-S6g2GwKk.js","./index-D4J50qwi.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-CKrFHA95.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
+ import{c as Yi,p as Ys,a8 as xae,u as Ln,a9 as T5e,aa as _5e,ab as X5e,ac as tW,ad as R5e,V as E5e,a1 as q5e,ae as j5e,a4 as C5e,af as z5e,ag as A5e,X as nW,Y as U5e,ah as Qae,a as rW,r as W5e}from"./ui-preferences-store-DXlcXfat.js";import{r as y,b as L,j as h,f as Y5e,c as q,g as Fn,w as kae,x as bv,e as vn,t as AE}from"./index-BkcJ58S7.js";import{a6 as G5e,c as Ve,B as Ae,ak as e6,al as t6,am as n6,an as N5e,ao as r6,ap as Z5e,f as Nt,q as fw,r as I5e,T as Ad,j as wd,C as Jc,X as Wi,a7 as D5e,aC as V5e,aD as M5e,aE as L5e,A as Ql,S as ts,k as Pae,g as Mg,h as Lg,aB as i6,i as Jh,D as Tae,l as _ae,m as Xae,p as $c,aH as F5e,U as B5e,V as H5e,W as K5e,aj as J5e,R as Jx,y as eTe,N as tTe,O as nTe,P as rTe,I as Ya,s as Rae,t as Eae,u as qae,v as jae,w as UE,x as iTe,ai as WE,L as Cae,aI as aTe,Y as oTe,e as oo,z as sTe,F as lTe,G as iW,H as aW,J as cTe,K as oW,aq as uTe,aJ as OTe,a as dTe,n as BP,o as sW,E as lW}from"./error-boundary-S6g2GwKk.js";var Sn;(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})(Sn||(Sn={}));var YE;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(YE||(YE={}));const nt=Sn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pc=e=>{switch(typeof e){case"undefined":return nt.undefined;case"string":return nt.string;case"number":return isNaN(e)?nt.nan:nt.number;case"boolean":return nt.boolean;case"function":return nt.function;case"bigint":return nt.bigint;case"symbol":return nt.symbol;case"object":return Array.isArray(e)?nt.array:e===null?nt.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?nt.promise:typeof Map<"u"&&e instanceof Map?nt.map:typeof Set<"u"&&e instanceof Set?nt.set:typeof Date<"u"&&e instanceof Date?nt.date:nt.object;default:return nt.unknown}},Ce=Sn.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"]),fTe=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Aa 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 Aa))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Sn.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()}}Aa.create=e=>new Aa(e);const ep=(e,t)=>{let n;switch(e.code){case Ce.invalid_type:e.received===nt.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Ce.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Sn.jsonStringifyReplacer)}`;break;case Ce.unrecognized_keys:n=`Unrecognized key(s) in object: ${Sn.joinValues(e.keys,", ")}`;break;case Ce.invalid_union:n="Invalid input";break;case Ce.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Sn.joinValues(e.options)}`;break;case Ce.invalid_enum_value:n=`Invalid enum value. Expected ${Sn.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}"`:Sn.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,Sn.assertNever(e)}return{message:n}};let zae=ep;function hTe(e){zae=e}function hw(){return zae}const pw=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}},pTe=[];function Be(e,t){const n=hw(),r=pw({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ep?void 0:ep].filter(i=>!!i)});e.common.issues.push(r)}class ra{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 Ut;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 ra.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 Ut;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 Ut=Object.freeze({status:"aborted"}),yh=e=>({status:"dirty",value:e}),Sa=e=>({status:"valid",value:e}),GE=e=>e.status==="aborted",NE=e=>e.status==="dirty",Ud=e=>e.status==="valid",R0=e=>typeof Promise<"u"&&e instanceof Promise;function mw(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 Aae(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 pt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(pt||(pt={}));var Qg,kg;class El{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 cW=(e,t)=>{if(Ud(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 Aa(e.common.issues);return this._error=n,this._error}}};function Ht(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 an{get description(){return this._def.description}_getType(t){return pc(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:pc(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ra,ctx:{common:t.parent.common,data:t.data,parsedType:pc(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(R0(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:pc(t)},a=this._parseSync({data:t,path:i.path,parent:i});return cW(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:pc(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:i});return Ud(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=>Ud(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:pc(t)},i=this._parse({data:t,path:r.path,parent:r}),a=await(R0(i)?i:Promise.resolve(i));return cW(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 zs({schema:this,typeName:zt.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 kl.create(this,this._def)}nullable(){return aO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qs.create(this)}promise(){return np.create(this,this._def)}or(t){return C0.create([this,t],this._def)}and(t){return z0.create(this,t,this._def)}transform(t){return new zs({...Ht(this._def),schema:this,typeName:zt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new G0({...Ht(this._def),innerType:this,defaultValue:n,typeName:zt.ZodDefault})}brand(){return new a6({typeName:zt.ZodBranded,type:this,...Ht(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new N0({...Ht(this._def),innerType:this,catchValue:n,typeName:zt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Qy.create(this,t)}readonly(){return Z0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const mTe=/^c[^\s-]{8,}$/i,gTe=/^[0-9a-z]+$/,$Te=/^[0-9A-HJKMNP-TV-Z]{26}$/i,yTe=/^[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,vTe=/^[a-z0-9_-]{21}$/i,bTe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,wTe=/^[-+]?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)?)??$/,STe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xTe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let HP;const QTe=/^(?:(?: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])$/,kTe=/^(?:(?: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])$/,PTe=/^(([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]))$/,TTe=/^(([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])$/,_Te=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,XTe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Uae="((\\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])))",RTe=new RegExp(`^${Uae}$`);function Wae(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 ETe(e){return new RegExp(`^${Wae(e)}$`)}function Yae(e){let t=`${Uae}T${Wae(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 qTe(e,t){return!!((t==="v4"||!t)&&QTe.test(e)||(t==="v6"||!t)&&PTe.test(e))}function jTe(e,t){if(!bTe.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 CTe(e,t){return!!((t==="v4"||!t)&&kTe.test(e)||(t==="v6"||!t)&&TTe.test(e))}class Rs extends an{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==nt.string){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:nt.string,received:a.parsedType}),Ut}const r=new ra;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")STe.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")HP||(HP=new RegExp(xTe,"u")),HP.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")yTe.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")vTe.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")mTe.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")gTe.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")$Te.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"?Yae(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"?RTe.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{code:Ce.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?ETe(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"?wTe.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"duration",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?qTe(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"?jTe(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"?CTe(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"?_Te.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"base64",code:Ce.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?XTe.test(t.data)||(i=this._getOrReturnCtx(t,i),Be(i,{validation:"base64url",code:Ce.invalid_string,message:a.message}),r.dirty()):Sn.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,...pt.errToObj(r)})}_addCheck(t){return new Rs({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...pt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...pt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...pt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...pt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...pt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...pt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...pt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...pt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...pt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...pt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...pt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...pt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...pt.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,...pt.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,...pt.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...pt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...pt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...pt.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...pt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...pt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...pt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...pt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...pt.errToObj(n)})}nonempty(t){return this.min(1,pt.errToObj(t))}trim(){return new Rs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Rs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Rs({...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}}Rs.create=e=>{var t;return new Rs({checks:[],typeName:zt.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Ht(e)})};function zTe(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 nO extends an{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)!==nt.number){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:nt.number,received:a.parsedType}),Ut}let r;const i=new ra;for(const a of this._def.checks)a.kind==="int"?Sn.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"?zTe(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()):Sn.assertNever(a);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,pt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,pt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,pt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,pt.toString(n))}setLimit(t,n,r,i){return new nO({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:pt.toString(i)}]})}_addCheck(t){return new nO({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:pt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:pt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:pt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:pt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:pt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:pt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:pt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:pt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:pt.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"&&Sn.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)}}nO.create=e=>new nO({checks:[],typeName:zt.ZodNumber,coerce:e?.coerce||!1,...Ht(e)});class rO extends an{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)!==nt.bigint)return this._getInvalidInput(t);let r;const i=new ra;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()):Sn.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Be(n,{code:Ce.invalid_type,expected:nt.bigint,received:n.parsedType}),Ut}gte(t,n){return this.setLimit("min",t,!0,pt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,pt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,pt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,pt.toString(n))}setLimit(t,n,r,i){return new rO({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:pt.toString(i)}]})}_addCheck(t){return new rO({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:pt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:pt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:pt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:pt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:pt.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}}rO.create=e=>{var t;return new rO({checks:[],typeName:zt.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Ht(e)})};class E0 extends an{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==nt.boolean){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.boolean,received:r.parsedType}),Ut}return Sa(t.data)}}E0.create=e=>new E0({typeName:zt.ZodBoolean,coerce:e?.coerce||!1,...Ht(e)});class Wd extends an{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==nt.date){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_type,expected:nt.date,received:a.parsedType}),Ut}if(isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return Be(a,{code:Ce.invalid_date}),Ut}const r=new ra;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()):Sn.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Wd({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:pt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:pt.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}}Wd.create=e=>new Wd({checks:[],coerce:e?.coerce||!1,typeName:zt.ZodDate,...Ht(e)});class gw extends an{_parse(t){if(this._getType(t)!==nt.symbol){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.symbol,received:r.parsedType}),Ut}return Sa(t.data)}}gw.create=e=>new gw({typeName:zt.ZodSymbol,...Ht(e)});class q0 extends an{_parse(t){if(this._getType(t)!==nt.undefined){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.undefined,received:r.parsedType}),Ut}return Sa(t.data)}}q0.create=e=>new q0({typeName:zt.ZodUndefined,...Ht(e)});class j0 extends an{_parse(t){if(this._getType(t)!==nt.null){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.null,received:r.parsedType}),Ut}return Sa(t.data)}}j0.create=e=>new j0({typeName:zt.ZodNull,...Ht(e)});class tp extends an{constructor(){super(...arguments),this._any=!0}_parse(t){return Sa(t.data)}}tp.create=e=>new tp({typeName:zt.ZodAny,...Ht(e)});class Sd extends an{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Sa(t.data)}}Sd.create=e=>new Sd({typeName:zt.ZodUnknown,...Ht(e)});class Ac extends an{_parse(t){const n=this._getOrReturnCtx(t);return Be(n,{code:Ce.invalid_type,expected:nt.never,received:n.parsedType}),Ut}}Ac.create=e=>new Ac({typeName:zt.ZodNever,...Ht(e)});class $w extends an{_parse(t){if(this._getType(t)!==nt.undefined){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.void,received:r.parsedType}),Ut}return Sa(t.data)}}$w.create=e=>new $w({typeName:zt.ZodVoid,...Ht(e)});class qs extends an{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==nt.array)return Be(n,{code:Ce.invalid_type,expected:nt.array,received:n.parsedType}),Ut;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 El(n,o,n.path,s)))).then(o=>ra.mergeArray(r,o));const a=[...n.data].map((o,s)=>i.type._parseSync(new El(n,o,n.path,s)));return ra.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new qs({...this._def,minLength:{value:t,message:pt.toString(n)}})}max(t,n){return new qs({...this._def,maxLength:{value:t,message:pt.toString(n)}})}length(t,n){return new qs({...this._def,exactLength:{value:t,message:pt.toString(n)}})}nonempty(t){return this.min(1,t)}}qs.create=(e,t)=>new qs({type:e,minLength:null,maxLength:null,exactLength:null,typeName:zt.ZodArray,...Ht(t)});function fh(e){if(e instanceof Tr){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=kl.create(fh(r))}return new Tr({...e._def,shape:()=>t})}else return e instanceof qs?new qs({...e._def,type:fh(e.element)}):e instanceof kl?kl.create(fh(e.unwrap())):e instanceof aO?aO.create(fh(e.unwrap())):e instanceof ql?ql.create(e.items.map(t=>fh(t))):e}class Tr extends an{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=Sn.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==nt.object){const c=this._getOrReturnCtx(t);return Be(c,{code:Ce.invalid_type,expected:nt.object,received:c.parsedType}),Ut}const{status:r,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof Ac&&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 El(i,O,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ac){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 El(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=>ra.mergeObjectSync(r,c)):ra.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return pt.errToObj,new Tr({...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=pt.errToObj(t).message)!==null&&s!==void 0?s:l}:{message:l}}}:{}})}strip(){return new Tr({...this._def,unknownKeys:"strip"})}passthrough(){return new Tr({...this._def,unknownKeys:"passthrough"})}extend(t){return new Tr({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Tr({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:zt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Tr({...this._def,catchall:t})}pick(t){const n={};return Sn.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new Tr({...this._def,shape:()=>n})}omit(t){const n={};return Sn.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new Tr({...this._def,shape:()=>n})}deepPartial(){return fh(this)}partial(t){const n={};return Sn.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}),new Tr({...this._def,shape:()=>n})}required(t){const n={};return Sn.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof kl;)a=a._def.innerType;n[r]=a}}),new Tr({...this._def,shape:()=>n})}keyof(){return Gae(Sn.objectKeys(this.shape))}}Tr.create=(e,t)=>new Tr({shape:()=>e,unknownKeys:"strip",catchall:Ac.create(),typeName:zt.ZodObject,...Ht(t)});Tr.strictCreate=(e,t)=>new Tr({shape:()=>e,unknownKeys:"strict",catchall:Ac.create(),typeName:zt.ZodObject,...Ht(t)});Tr.lazycreate=(e,t)=>new Tr({shape:e,unknownKeys:"strip",catchall:Ac.create(),typeName:zt.ZodObject,...Ht(t)});class C0 extends an{_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 Aa(s.ctx.common.issues));return Be(n,{code:Ce.invalid_union,unionErrors:o}),Ut}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 Aa(l));return Be(n,{code:Ce.invalid_union,unionErrors:s}),Ut}}get options(){return this._def.options}}C0.create=(e,t)=>new C0({options:e,typeName:zt.ZodUnion,...Ht(t)});const nc=e=>e instanceof U0?nc(e.schema):e instanceof zs?nc(e.innerType()):e instanceof W0?[e.value]:e instanceof iO?e.options:e instanceof Y0?Sn.objectValues(e.enum):e instanceof G0?nc(e._def.innerType):e instanceof q0?[void 0]:e instanceof j0?[null]:e instanceof kl?[void 0,...nc(e.unwrap())]:e instanceof aO?[null,...nc(e.unwrap())]:e instanceof a6||e instanceof Z0?nc(e.unwrap()):e instanceof N0?nc(e._def.innerType):[];class eQ extends an{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==nt.object)return Be(n,{code:Ce.invalid_type,expected:nt.object,received:n.parsedType}),Ut;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]}),Ut)}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=nc(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 eQ({typeName:zt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Ht(r)})}}function ZE(e,t){const n=pc(e),r=pc(t);if(e===t)return{valid:!0,data:e};if(n===nt.object&&r===nt.object){const i=Sn.objectKeys(t),a=Sn.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(const s of a){const l=ZE(e[s],t[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(n===nt.array&&r===nt.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=ZE(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===nt.date&&r===nt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class z0 extends an{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(a,o)=>{if(GE(a)||GE(o))return Ut;const s=ZE(a.value,o.value);return s.valid?((NE(a)||NE(o))&&n.dirty(),{status:n.value,value:s.data}):(Be(r,{code:Ce.invalid_intersection_types}),Ut)};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}))}}z0.create=(e,t,n)=>new z0({left:e,right:t,typeName:zt.ZodIntersection,...Ht(n)});class ql extends an{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==nt.array)return Be(r,{code:Ce.invalid_type,expected:nt.array,received:r.parsedType}),Ut;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"}),Ut;!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 El(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>ra.mergeArray(n,o)):ra.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new ql({...this._def,rest:t})}}ql.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ql({items:e,typeName:zt.ZodTuple,rest:null,...Ht(t)})};class A0 extends an{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!==nt.object)return Be(r,{code:Ce.invalid_type,expected:nt.object,received:r.parsedType}),Ut;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in r.data)i.push({key:a._parse(new El(r,s,r.path,s)),value:o._parse(new El(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?ra.mergeObjectAsync(n,i):ra.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof an?new A0({keyType:t,valueType:n,typeName:zt.ZodRecord,...Ht(r)}):new A0({keyType:Rs.create(),valueType:t,typeName:zt.ZodRecord,...Ht(n)})}}class yw extends an{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!==nt.map)return Be(r,{code:Ce.invalid_type,expected:nt.map,received:r.parsedType}),Ut;const i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,l],c)=>({key:i._parse(new El(r,s,r.path,[c,"key"])),value:a._parse(new El(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 Ut;(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 Ut;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}}}}yw.create=(e,t,n)=>new yw({valueType:t,keyType:e,typeName:zt.ZodMap,...Ht(n)});class Yd extends an{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==nt.set)return Be(r,{code:Ce.invalid_type,expected:nt.set,received:r.parsedType}),Ut;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 Ut;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 El(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(t,n){return new Yd({...this._def,minSize:{value:t,message:pt.toString(n)}})}max(t,n){return new Yd({...this._def,maxSize:{value:t,message:pt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Yd.create=(e,t)=>new Yd({valueType:e,minSize:null,maxSize:null,typeName:zt.ZodSet,...Ht(t)});class qh extends an{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==nt.function)return Be(n,{code:Ce.invalid_type,expected:nt.function,received:n.parsedType}),Ut;function r(s,l){return pw({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hw(),ep].filter(c=>!!c),issueData:{code:Ce.invalid_arguments,argumentsError:l}})}function i(s,l){return pw({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hw(),ep].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 np){const s=this;return Sa(async function(...l){const c=new Aa([]),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 Sa(function(...l){const c=s._def.args.safeParse(l,a);if(!c.success)throw new Aa([r(l,c.error)]);const u=Reflect.apply(o,this,c.data),O=s._def.returns.safeParse(u,a);if(!O.success)throw new Aa([i(u,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new qh({...this._def,args:ql.create(t).rest(Sd.create())})}returns(t){return new qh({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new qh({args:t||ql.create([]).rest(Sd.create()),returns:n||Sd.create(),typeName:zt.ZodFunction,...Ht(r)})}}class U0 extends an{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})}}U0.create=(e,t)=>new U0({getter:e,typeName:zt.ZodLazy,...Ht(t)});class W0 extends an{_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}),Ut}return{status:"valid",value:t.data}}get value(){return this._def.value}}W0.create=(e,t)=>new W0({value:e,typeName:zt.ZodLiteral,...Ht(t)});function Gae(e,t){return new iO({values:e,typeName:zt.ZodEnum,...Ht(t)})}class iO extends an{constructor(){super(...arguments),Qg.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Be(n,{expected:Sn.joinValues(r),received:n.parsedType,code:Ce.invalid_type}),Ut}if(mw(this,Qg)||Aae(this,Qg,new Set(this._def.values)),!mw(this,Qg).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}),Ut}return Sa(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 iO.create(t,{...this._def,...n})}exclude(t,n=this._def){return iO.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Qg=new WeakMap;iO.create=Gae;class Y0 extends an{constructor(){super(...arguments),kg.set(this,void 0)}_parse(t){const n=Sn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==nt.string&&r.parsedType!==nt.number){const i=Sn.objectValues(n);return Be(r,{expected:Sn.joinValues(i),received:r.parsedType,code:Ce.invalid_type}),Ut}if(mw(this,kg)||Aae(this,kg,new Set(Sn.getValidEnumValues(this._def.values))),!mw(this,kg).has(t.data)){const i=Sn.objectValues(n);return Be(r,{received:r.data,code:Ce.invalid_enum_value,options:i}),Ut}return Sa(t.data)}get enum(){return this._def.values}}kg=new WeakMap;Y0.create=(e,t)=>new Y0({values:e,typeName:zt.ZodNativeEnum,...Ht(t)});class np extends an{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==nt.promise&&n.common.async===!1)return Be(n,{code:Ce.invalid_type,expected:nt.promise,received:n.parsedType}),Ut;const r=n.parsedType===nt.promise?n.data:Promise.resolve(n.data);return Sa(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}np.create=(e,t)=>new np({type:e,typeName:zt.ZodPromise,...Ht(t)});class zs extends an{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zt.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 Ut;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?Ut:l.status==="dirty"||n.value==="dirty"?yh(l.value):l});{if(n.value==="aborted")return Ut;const s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?Ut:s.status==="dirty"||n.value==="dirty"?yh(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"?Ut:(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"?Ut:(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(!Ud(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=>Ud(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):o);Sn.assertNever(i)}}zs.create=(e,t,n)=>new zs({schema:e,typeName:zt.ZodEffects,effect:t,...Ht(n)});zs.createWithPreprocess=(e,t,n)=>new zs({schema:t,effect:{type:"preprocess",transform:e},typeName:zt.ZodEffects,...Ht(n)});class kl extends an{_parse(t){return this._getType(t)===nt.undefined?Sa(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}kl.create=(e,t)=>new kl({innerType:e,typeName:zt.ZodOptional,...Ht(t)});class aO extends an{_parse(t){return this._getType(t)===nt.null?Sa(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}aO.create=(e,t)=>new aO({innerType:e,typeName:zt.ZodNullable,...Ht(t)});class G0 extends an{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===nt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}G0.create=(e,t)=>new G0({innerType:e,typeName:zt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ht(t)});class N0 extends an{_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 R0(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Aa(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Aa(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}N0.create=(e,t)=>new N0({innerType:e,typeName:zt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ht(t)});class vw extends an{_parse(t){if(this._getType(t)!==nt.nan){const r=this._getOrReturnCtx(t);return Be(r,{code:Ce.invalid_type,expected:nt.nan,received:r.parsedType}),Ut}return{status:"valid",value:t.data}}}vw.create=e=>new vw({typeName:zt.ZodNaN,...Ht(e)});const ATe=Symbol("zod_brand");class a6 extends an{_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 Qy extends an{_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"?Ut:a.status==="dirty"?(n.dirty(),yh(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"?Ut: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 Qy({in:t,out:n,typeName:zt.ZodPipeline})}}class Z0 extends an{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ud(i)&&(i.value=Object.freeze(i.value)),i);return R0(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Z0.create=(e,t)=>new Z0({innerType:e,typeName:zt.ZodReadonly,...Ht(t)});function uW(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Nae(e,t={},n){return e?tp.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=uW(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=uW(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})}}):tp.create()}const UTe={object:Tr.lazycreate};var zt;(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"})(zt||(zt={}));const WTe=(e,t={message:`Input not instance of ${e.name}`})=>Nae(n=>n instanceof e,t),Zae=Rs.create,Iae=nO.create,YTe=vw.create,GTe=rO.create,Dae=E0.create,NTe=Wd.create,ZTe=gw.create,ITe=q0.create,DTe=j0.create,VTe=tp.create,MTe=Sd.create,LTe=Ac.create,FTe=$w.create,BTe=qs.create,HTe=Tr.create,KTe=Tr.strictCreate,JTe=C0.create,e_e=eQ.create,t_e=z0.create,n_e=ql.create,r_e=A0.create,i_e=yw.create,a_e=Yd.create,o_e=qh.create,s_e=U0.create,l_e=W0.create,c_e=iO.create,u_e=Y0.create,O_e=np.create,OW=zs.create,d_e=kl.create,f_e=aO.create,h_e=zs.createWithPreprocess,p_e=Qy.create,m_e=()=>Zae().optional(),g_e=()=>Iae().optional(),$_e=()=>Dae().optional(),y_e={string:e=>Rs.create({...e,coerce:!0}),number:e=>nO.create({...e,coerce:!0}),boolean:e=>E0.create({...e,coerce:!0}),bigint:e=>rO.create({...e,coerce:!0}),date:e=>Wd.create({...e,coerce:!0})},v_e=Ut;var X=Object.freeze({__proto__:null,defaultErrorMap:ep,setErrorMap:hTe,getErrorMap:hw,makeIssue:pw,EMPTY_PATH:pTe,addIssueToContext:Be,ParseStatus:ra,INVALID:Ut,DIRTY:yh,OK:Sa,isAborted:GE,isDirty:NE,isValid:Ud,isAsync:R0,get util(){return Sn},get objectUtil(){return YE},ZodParsedType:nt,getParsedType:pc,ZodType:an,datetimeRegex:Yae,ZodString:Rs,ZodNumber:nO,ZodBigInt:rO,ZodBoolean:E0,ZodDate:Wd,ZodSymbol:gw,ZodUndefined:q0,ZodNull:j0,ZodAny:tp,ZodUnknown:Sd,ZodNever:Ac,ZodVoid:$w,ZodArray:qs,ZodObject:Tr,ZodUnion:C0,ZodDiscriminatedUnion:eQ,ZodIntersection:z0,ZodTuple:ql,ZodRecord:A0,ZodMap:yw,ZodSet:Yd,ZodFunction:qh,ZodLazy:U0,ZodLiteral:W0,ZodEnum:iO,ZodNativeEnum:Y0,ZodPromise:np,ZodEffects:zs,ZodTransformer:zs,ZodOptional:kl,ZodNullable:aO,ZodDefault:G0,ZodCatch:N0,ZodNaN:vw,BRAND:ATe,ZodBranded:a6,ZodPipeline:Qy,ZodReadonly:Z0,custom:Nae,Schema:an,ZodSchema:an,late:UTe,get ZodFirstPartyTypeKind(){return zt},coerce:y_e,any:VTe,array:BTe,bigint:GTe,boolean:Dae,date:NTe,discriminatedUnion:e_e,effect:OW,enum:c_e,function:o_e,instanceof:WTe,intersection:t_e,lazy:s_e,literal:l_e,map:i_e,nan:YTe,nativeEnum:u_e,never:LTe,null:DTe,nullable:f_e,number:Iae,object:HTe,oboolean:$_e,onumber:g_e,optional:d_e,ostring:m_e,pipeline:p_e,preprocess:h_e,promise:O_e,record:r_e,set:a_e,strictObject:KTe,string:Zae,symbol:ZTe,transformer:OW,tuple:n_e,undefined:ITe,union:JTe,unknown:MTe,void:FTe,NEVER:v_e,ZodIssueCode:Ce,quotelessJson:fTe,ZodError:Aa});const Wt=X.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),wv=X.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),Sv=X.string().min(1).max(32768),o6=/^[a-f0-9]{12}$/,Rt=X.string().regex(o6),b_e=X.string().min(1).max(4096),KP=X.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),xv=X.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),dW=X.string().regex(/^[a-f0-9]{32}$/),Vae=/^(\/|[A-Za-z]:[\\/])/,JP=X.string().min(1).max(4096).regex(Vae),fW=/^[a-f0-9]{32}$/,Jn=X.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Nf=X.string().regex(/^[A-Za-z0-9_-]{1,128}$/),hW=X.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),pW=X.object({data_b64:X.string().min(1).max(1e6),mime_type:X.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),oO=2e5,I0=8,w_e=256,S_e=100,IE=16,s6=256,Mae=100,Lae=200,DE=1e6,Eo=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)),Qv=X.object({kind:X.enum(["agent","team"]),name:Eo}).strict(),e5=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(),mW=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(),gW=X.object({name:X.string().min(1).max(64).optional(),description:X.string().max(8e3).optional(),manager:Eo.optional(),members:X.array(X.object({role:Eo,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(),x_e=X.record(X.array(X.string().max(1024)).max(100)),$W=X.enum(["minutes","hours","days"]);function Q_e(e){return!/^\.+$/.test(e)}const Wen=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(Q_e),yW=X.enum(["str","int","float","bool","list","dict"]),vW=X.string().max(16384),k_e=2e3,bW=X.string().min(1).max(k_e),wW=X.string().min(1).max(64),P_e=X.string().min(1).max(64),SW=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(),T_e=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(),VE=128,xW=2e3,QW=8e3,kW=64,PW=64,tQ=e=>[...e].length,ME=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,__e=e=>e===9||e===10||e===11||e===12||e===13||e===133,X_e=e=>e<=31||e>=127&&e<=159,R_e=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),E_e=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,kv=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},Fae=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&ME(t[n].codePointAt(0)??0);)n++;for(;r>n&&ME(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},q_e=e=>{let t="",n=!1;for(const r of e){if(ME(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function j_e(e){const t=Fae(e);if(!t)return"must not be empty";if(tQ(t)>VE)return`must be at most ${VE} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(kv(t,E_e))return"must not contain Unicode bidirectional override characters";if(kv(t,__e))return"must not contain whitespace";if(kv(t,X_e))return"must not contain control characters";if(kv(t,R_e))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 Yen(e){return q_e(Fae(e).normalize("NFKC").toLowerCase())}function C_e(e){return e.trim()?tQ(e)>xW?`must be at most ${xW} characters`:null:"must not be empty"}function z_e(e){return e.trim()?tQ(e)>QW?`must be at most ${QW} characters`:null:"must not be empty"}function A_e(e){if(e.length>PW)return`must hold at most ${PW} items`;for(const t of e)if(!t.trim()||tQ(t)>kW)return`must hold items of 1 to ${kW} characters`;return null}const U_e=e=>j_e(e)===null,W_e=X.string().refine(U_e,{message:"That is not a name the hub can publish."}),Y_e=X.string().refine(e=>z_e(e)===null,{message:"That instruction body cannot be published."}),G_e=X.string().refine(e=>C_e(e)===null,{message:"That description cannot be published."}),N_e=X.array(X.string()).refine(e=>A_e(e)===null,{message:"That tool list cannot be published."}),TW=X.object({name:W_e,description:G_e,instructions:Y_e,kind:X.enum(["role","specialist"]),when_to_use:X.string(),tools:N_e,effort:X.string(),delegate:X.boolean(),version:X.string(),categories:X.array(X.string()),tags:X.array(X.string())}).partial().strict(),Z_e=X.enum(["team","agent"]),I_e=X.string().min(1).max(64),D_e=X.string().min(1).max(256),Bae=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,t5=X.string().regex(Bae,{message:"Letters, digits, dot, underscore and dash; no spaces."}),V_e=["planning","active","qa","validation","done","paused","archived"],_W=X.enum(V_e),Pv=X.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),XW=X.array(X.string().min(1).max(24)).max(8),gu=X.string().min(1).max(64),M_e=1e3,RW=240,EW=80,L_e=256,F_e=100,B_e=200,H_e=/^[a-z0-9][a-z0-9_-]{0,23}$/;function Gen(e){return e?Bae.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 Nen(e){return H_e.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const Tv=X.enum(["agent","team"]),K_e=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:Eo}).strict(),X.object({op:X.literal("profiles.install"),name:Eo,requestId:Jn}).strict(),X.object({op:X.literal("profiles.create"),name:Eo,requestId:Jn,fields:mW.extend({description:X.string().max(8e3),instructions:X.string().min(1).max(8e3)})}).strict(),X.object({op:X.literal("profiles.update"),name:Eo,requestId:Jn,fields:mW}).strict(),X.object({op:X.literal("hub.updates")}).strict(),X.object({op:X.literal("hub.check"),requestId:Jn,kind:Tv.optional(),name:Eo.optional()}).strict(),X.object({op:X.literal("hub.apply"),requestId:Jn,kind:Tv,name:Eo,prefer:X.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:X.boolean().optional(),dryRun:X.boolean().optional()}).strict(),X.object({op:X.literal("hub.applyAll"),requestId:Jn,kind:Tv.optional()}).strict(),X.object({op:X.literal("hub.retry"),requestId:Jn,kind:Tv,name:Eo}).strict(),X.object({op:X.literal("teams.list")}).strict(),X.object({op:X.literal("teams.get"),name:Eo}).strict(),X.object({op:X.literal("teams.create"),requestId:Jn,fields:gW.extend({name:X.string().min(1).max(64)})}).strict(),X.object({op:X.literal("teams.update"),name:Eo,requestId:Jn,fields:gW}).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:Z_e.optional(),scope_name:I_e.optional(),cursor:D_e.optional(),with_counts:X.boolean().optional()}).strict(),X.object({op:X.literal("delegated_cleanup_notice.ack")}).strict(),X.object({op:X.literal("sessions.search"),q:X.string().min(1).max(w_e),limit:X.number().int().min(1).max(500).optional(),include_archived:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.archive"),sessionId:Rt,archived:X.boolean()}).strict(),X.object({op:X.literal("sessions.delete"),sessionId:Rt,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.create"),requestId:Jn,cwd:X.string().min(1).max(4096).optional(),target:Qv.optional(),purpose:X.literal("agents-config").optional(),model:e5.optional(),draftId:Rt.optional(),peer:Nf.optional()}).strict(),X.object({op:X.literal("sessions.preview"),requestId:Jn,cwd:X.string().min(1).max(4096),target:Qv.optional(),model:e5.optional()}).strict(),X.object({op:X.literal("sessions.draft"),requestId:Jn,cwd:X.string().min(1).max(4096),target:Qv.optional(),model:e5.optional()}).strict(),X.object({op:X.literal("sessions.get"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.history"),sessionId:Rt,beforeId:Wt.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.checkpoints"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.checkpoints.warm"),sessionId:Rt,ids:X.array(Wt).max(IE).optional(),limit:X.number().int().min(1).max(IE).optional()}).strict(),X.object({op:X.literal("sessions.find"),sessionId:Rt,q:X.string().min(1).max(s6),limit:X.number().int().min(1).max(Lae).optional()}).strict(),X.object({op:X.literal("subagents.transcript"),sessionId:Rt,childId:Rt,beforeId:Wt.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.message"),sessionId:Rt,requestId:Jn,text:X.string().max(oO),images:X.array(pW).max(I0).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:Rt,requestId:Jn,command:X.string().regex(/^\/?[A-Za-z]+$/).max(64),args:X.string().max(oO).optional(),images:X.array(pW).max(I0).optional()}).strict(),X.object({op:X.literal("sessions.move"),sessionId:Rt,requestId:Jn,cwd:X.string().min(1).max(4096)}).strict(),X.object({op:X.literal("sessions.answer"),sessionId:Rt,epoch:Wt.optional(),requestId:Wt.optional(),value:X.string().max(32768).optional(),approved:X.boolean().optional(),questionIndex:X.number().int().min(0).optional(),askId:Wt.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:Rt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("attention.seen"),items:X.array(X.object({sessionId:Rt,completionToken:X.string().uuid()}).strict()).min(1).max(500)}).strict(),X.object({op:X.literal("sessions.notified"),sessionId:Rt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("sessions.pin"),sessionId:Rt,pinned:X.boolean()}).strict(),X.object({op:X.literal("sessions.watch"),sessionId:Rt,subscriptionId:X.string().regex(fW),visible:X.boolean(),canNotify:X.boolean()}).strict(),X.object({op:X.literal("sessions.warm"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.interrupt"),sessionId:Rt,requestId:Jn}).strict(),X.object({op:X.literal("sessions.variables.list"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.variables.create"),sessionId:Rt,key:S1,value:vW,type:yW}).strict(),X.object({op:X.literal("sessions.variables.update"),sessionId:Rt,key:S1,value:vW,type:yW}).strict(),X.object({op:X.literal("sessions.variables.delete"),sessionId:Rt,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:Wt}).strict(),X.object({op:X.literal("legacy.agent.upload"),agentId:Wt}).strict(),X.object({op:X.literal("agent.publish"),agentId:Wt,document:TW.optional(),visibility:X.literal("org").optional(),tenantId:Wt.optional()}).strict(),X.object({op:X.literal("agent.republish"),agentId:Wt,hubAgentId:Wt,document:TW.optional(),visibility:X.literal("org").optional(),tenantId:Wt.optional()}).strict(),X.object({op:X.literal("team.pull"),teamId:Wt,tenantId:Wt.optional()}).strict(),X.object({op:X.literal("agent.nameAvailability"),name:X.string().min(1).max(VE)}).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:Wt}).strict(),X.object({op:X.literal("legacy.agent.history"),agentId:Wt,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:Wt.optional(),status:X.string().max(64).optional()}).strict(),X.object({op:X.literal("legacy.job.get"),jobId:Wt}).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:Wt,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:Wt,schedule:SW.extend({prompt:X.string().max(64e3),interval:X.number().int().min(1),unit:$W})}).strict(),X.object({op:X.literal("legacy.schedule.get"),scheduleId:Wt}).strict(),X.object({op:X.literal("legacy.schedule.edit"),scheduleId:Wt,schedule:SW.extend({prompt:X.string().max(64e3).nullish(),interval:X.number().int().min(1).nullish(),unit:$W.nullish()})}).strict(),X.object({op:X.literal("legacy.schedule.remove"),scheduleId:Wt}).strict(),X.object({op:X.literal("legacy.agent.create"),agent:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.update"),agentId:Wt,update:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.delete"),agentId:Wt}).strict(),X.object({op:X.literal("legacy.agent.conversation.clear"),agentId:Wt}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.get"),agentId:Wt}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.update"),agentId:Wt,systemPrompt:X.string().max(DE)}).strict(),X.object({op:X.literal("legacy.agent.download"),agentId:Wt}).strict(),X.object({op:X.literal("legacy.job.cancel"),jobId:Wt}).strict(),X.object({op:X.literal("commands.list")}).strict(),X.object({op:X.literal("commands.entities"),sessionId:Rt,command:Wt,name:X.string().max(128).optional()}).strict(),X.object({op:X.literal("models.catalogue"),live:X.boolean().optional(),scope:X.enum(["usable","all"]).optional()}).strict(),X.object({op:X.literal("usage.get"),provider:Wt.optional(),live:X.boolean().optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("quota.notice"),provider:Wt.optional(),model:X.string().min(1).max(200).optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("analytics.get"),sessionId:Rt.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:Rt.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:Rt,recentLimit:X.number().int().min(0).max(50).optional()}).strict(),X.object({op:X.literal("skills.list"),sessionId:Rt.optional(),cwd:b_e.optional(),name:Wt.optional()}).strict(),X.object({op:X.literal("sessions.failovers"),sessionId:Rt}).strict(),X.object({op:X.literal("sessions.credential"),sessionId:Rt,action:X.enum(["list","store","forget"]),key:wv.optional(),value:Sv.optional(),confirmed:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.fork"),sessionId:Rt,requestId:Jn,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:Jn,targets:X.array(Rt).min(1).max(100),confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside"),sessionId:Rt,requestId:Jn,text:X.string().min(1).max(32768),asideId:Jn.optional(),subscriptionId:X.string().regex(fW).optional()}).strict(),X.object({op:X.literal("sessions.adopt"),sessionId:Rt,requestId:Jn,asideId:Jn,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside.get"),sessionId:Rt,asideId:Jn}).strict(),X.object({op:X.literal("sessions.aside.close"),sessionId:Rt,asideId:Jn}).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:Jn,sessionId:Rt.optional(),cwd:X.string().min(1).max(4096).optional(),target:Qv.optional(),message:bW,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:Rt,wakeId:wW,message:bW.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:Rt,wakeId:wW}).strict(),X.object({op:X.literal("monitors.cancel"),sessionId:Rt,monitorId:P_e}).strict(),X.object({op:X.literal("mcp.list"),sessionId:Rt}).strict(),X.object({op:X.literal("mcp.credentials.store"),sessionId:Rt,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:Rt,control:X.object({action:X.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:KP.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(xv).optional(),url:X.string().max(4096).optional(),headers:X.record(xv).optional(),oauth:X.boolean().optional(),confirmed:X.boolean().optional(),operation_id:dW.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog"),cwd:JP.optional(),sessionId:Rt.optional()}).strict(),X.object({op:X.literal("mcp.catalog.control"),cwd:JP.optional(),control:X.object({action:X.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:KP.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(xv).optional(),url:X.string().max(4096).optional(),headers:X.record(xv).optional(),confirmed:X.boolean().optional(),operation_id:dW.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog.credentials"),header:X.string().min(1).max(128).optional(),cwd:JP.optional(),name:KP,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","signup.resend"]),request_id:Jn.optional(),tenant_id:Wt.optional(),account_id:Wt.optional(),agent_id:Wt.optional(),comment_id:Wt.optional(),team_id:Wt.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:Wt}).strict(),X.object({op:X.literal("auth.status"),id:Wt}).strict(),X.object({op:X.literal("auth.input"),id:Wt,promptId:Wt,value:Sv}).strict(),X.object({op:X.literal("auth.cancel"),id:Wt}).strict(),X.object({op:X.literal("auth.key"),provider:Wt,value:Sv}).strict(),X.object({op:X.literal("auth.logout"),provider:Wt}).strict(),X.object({op:X.literal("settings.list")}).strict(),X.object({op:X.literal("settings.edit"),key:wv,value:X.unknown().refine(e=>e!==void 0,"A setting value is required."),base:x_e.optional()}).strict(),X.object({op:X.literal("settings.reset"),key:wv}).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:T_e}).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:wv,value:Sv}).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:Nf,role:X.enum(["read","drive","admin"]),deviceId:Nf.optional()}).strict(),X.object({op:X.literal("networks.member.remove"),networkId:Nf,deviceId:Nf,confirm:X.string().min(1).max(256)}).strict(),X.object({op:X.literal("sessions.transfer"),sessionId:Rt,to:X.union([X.literal("local"),Nf]),keep:X.boolean().optional(),waitS:X.number().min(0).max(300).optional(),requestId:Jn.optional()}).strict(),X.object({op:X.literal("approvals.list")}).strict(),X.object({op:X.literal("approvals.approve"),approvalId:hW}).strict(),X.object({op:X.literal("approvals.deny"),approvalId:hW}).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:gu}).strict(),X.object({op:X.literal("projects.create"),name:t5,description:X.string().max(RW).optional(),status:_W.optional(),tags:XW.optional()}).strict(),X.object({op:X.literal("projects.update"),key:gu,fields:X.object({name:t5.optional(),title:X.string().max(80).optional(),owner:X.string().max(80).optional(),team:X.string().max(80).optional(),description:X.string().max(RW).optional(),status:_W.optional(),progress:X.string().max(M_e).optional(),tags:XW.optional(),start_date:Pv.optional(),target_date:Pv.optional(),completed_at:Pv.optional(),estimate:X.number().positive().max(1e3).optional(),estimate_unit:X.enum(["points","days"]).optional()}).strict(),force_done:X.boolean().optional()}).strict(),X.object({op:X.literal("projects.delete"),key:gu,confirmed_name:t5}).strict(),X.object({op:X.literal("projects.link"),key:gu,sessionId:Rt}).strict(),X.object({op:X.literal("projects.unlink"),key:gu,sessionId:Rt}).strict(),X.object({op:X.literal("projects.milestone"),key:gu,name:X.string().min(1).max(EW),targetDate:Pv.optional(),completed:X.boolean().optional()}).strict(),X.object({op:X.literal("projects.milestone.remove"),key:gu,name:X.string().min(1).max(EW)}).strict(),X.object({op:X.literal("projects.request_update"),key:gu}).strict(),X.object({op:X.literal("projects.search"),q:X.string().min(1).max(L_e),limit:X.number().int().min(1).max(B_e).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(),X.object({op:X.literal("code_requests.list"),sessionId:Rt}).strict(),X.object({op:X.literal("code_requests.refresh"),sessionId:Rt,keys:X.array(X.string().min(1).max(512)).max(256).optional(),force:X.boolean().optional()}).strict()]);K_e.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 ho={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},l6={runtimeUnreachable:"runtime_unreachable"},nm="runtime_busy",Hae="runtime_retiring",nQ={[ho.noCredential]:"This app is not paired with the running Local Operator server, so this control is unavailable.",[ho.refused]:"This app's credential for the running Local Operator server was refused, so this control is unavailable.",[ho.planeClosed]:"The running Local Operator server does not accept this app's desktop controls.",[ho.transportFailed]:"The Local Operator server did not answer this request."},D0={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 V0(e){return e!==void 0&&Object.values(ho).includes(e)}function J_e(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return ho.refused;if(t===503)return ho.planeClosed}}const e2e=88e4,t2e=11e5,n2e=2e4,r2e=9e4,i2e=new Set(["analytics.get","analytics.models","sessions.report"]),a2e=new Set(["usage.get"]),o2e=new Set(["networks.list","peers.list"]),s2e=new Set([...i2e,...a2e,...o2e]),l2e=90,c2e=30,u2e=300,O2e=10,Kae=15,d2e=1e4;function f2e(e){const n=e.to==="local"||e.keep?u2e:c2e,r=Math.max(0,e.waitS??0);return(l2e+n+O2e+Kae)*1e3+r*1e3}const h2e=18e4,p2e=h2e+15e3,m2e=120,Jae=(m2e+30+Kae)*1e3,g2e=6e4,$2e=5*Jae,y2e=new Set(["hub.apply","hub.retry","hub.check","hub.applyAll"]);function v2e(e){switch(e){case"hub.apply":case"hub.retry":return Jae;case"hub.check":return g2e;case"hub.applyAll":return $2e;default:return null}}function b2e(e){if(typeof e!="string"&&e.op==="sessions.transfer")return f2e(e)+d2e;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return p2e;const n=v2e(t);return n!==null?n:s2e.has(t)?r2e:n2e}const w2e=5e3;function c6(e){return b2e(e)+w2e}const rQ="deadline_exceeded",eoe="foreground_required",toe="View these completions in the foreground before marking them read.",S2e=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","quota.notice","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"]),x2e=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function Q2e(e,t){const n=Math.round(t/1e3),r=rQ;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.`}:y2e.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:S2e.has(e)?{code:r,message:x2e.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 iQ=e2e,k2e=t2e;X.object({state:X.enum(["ok","depleted","limit_reached","unverified","unknown","not_applicable"]),provider:X.string(),kind:X.enum(["balance","subscription","radient","none"]),model_free:X.boolean(),title:X.string(),body:X.string(),actions:X.array(X.object({id:X.enum(["open_url","resend_verification","refresh"]),label:X.string(),url:X.string().nullable().optional()})),resets_at_ms:X.number().int().nullable().optional(),checked_at_ms:X.number().int(),age_ms:X.number().int().nullable().optional(),source:X.enum(["cached","live"])});function P2e(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function qW(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 jW(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 aQ(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"delegated_cleanup_notice.ack":return{path:"/v1/desktop/delegated-cleanup-notice/ack",method:"POST"};case"sessions.search":{const t=new URLSearchParams({q:e.q,limit:String(e.limit??S_e)});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??Mae)});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":{jW(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":{jW(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,...P2e(e),message:e.message,...qW(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...qW(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":{const t=e.scope?`&scope=${e.scope}`:"";return{path:`/v1/desktop/models?live=${e.live??!1}${t}`,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"quota.notice":{const t=new URLSearchParams({refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),e.model&&t.set("model",e.model),{path:`/v1/desktop/quota-notice?${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,...e.force_done===!0?{force_done:!0}:{}}};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??F_e)})}`,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}};case"code_requests.list":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests`,method:"GET"};case"code_requests.refresh":return{path:`/v1/desktop/sessions/${e.sessionId}/code-requests/refresh`,method:"POST",body:{...e.keys!==void 0?{keys:e.keys}:{},...e.force!==void 0?{force:e.force}:{}}}}}const noe=64,CW=64*1024*1024,T2e="superseded_completion_token",_2e="store_busy",X2e="session_is_remote",R2e="owner_build_behind";function E2e(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 ud(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 roe(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const ioe=e=>typeof e?.goal_status=="string",aoe=e=>(e?.goal??"").trim().length>0;function q2e(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 Fg={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."},zW={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},j2e={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},C2e={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},z2e={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},A2e={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function AW(e){return e?e===Fg.notPaired?C2e:e===Fg.serverDown?j2e:e===Fg.frameBudget?A2e:zW:zW}const U2e=(e,t)=>e!==null&&e.message===t.message&&e.removed===t.removed&&e.max_age_hours===t.max_age_hours&&e.in_progress===t.in_progress&&e.first_removal_at===t.first_removal_at&&e.freed_bytes_estimate===t.freed_bytes_estimate&&e.record===t.record;function W2e(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.message!="string"||t.message.trim()==="")return null;const n=(r,i)=>typeof r=="number"&&Number.isFinite(r)?r:i;return{message:t.message,removed:n(t.removed,0),max_age_hours:n(t.max_age_hours,48),in_progress:t.in_progress===!0,first_removal_at:typeof t.first_removal_at=="string"?t.first_removal_at:"",freed_bytes_estimate:typeof t.freed_bytes_estimate=="number"&&Number.isFinite(t.freed_bytes_estimate)?t.freed_bytes_estimate:null,record:typeof t.record=="string"?t.record:""}}const ooe=Yi()(Ys(e=>({notice:null,receive:t=>e(n=>U2e(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:xae(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));async function soe(e){if(window.api?.desktop)try{return await Y2e(window.api.desktop.request(e),e)}catch(n){throw n instanceof Yt?n:V2e(n)?new Uc(toe,eoe):new Yt(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 Yt(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Yt(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function Y2e(e,t){const n=c6(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=Q2e(t.op,n);a(new Yt(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const loe="This server did not answer the request for its desktop controls.";class Yt 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 Uc extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function vo(e,t){return e instanceof Yt||e instanceof Uc?V0(e.code)?nQ[e.code]:e.message:t}function G2e(e,t,n,r){return typeof r=="string"?r:n===D0.noCredential?ho.noCredential:n===D0.transportFailed?ho.transportFailed:J_e(aQ(e).path,t)}async function Se(e){const t=await soe(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 Yt(t.status,r??loe,void 0,G2e(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 e.op==="sessions.list"&&N2e(n?.result),n?.result}function N2e(e){if(typeof e!="object"||e===null)return;const t=W2e(e.delegated_cleanup_notice);t&&ooe.getState().receive(t)}async function Z2e(){try{await Se({op:"delegated_cleanup_notice.ack"})}catch{}}async function Zen(){ooe.getState().dismiss(),await Z2e()}function coe(e){return e instanceof Yt&&e.code===rQ}function I2e(e){if(!(e instanceof Yt))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===R2e:e.code===X2e}function D2e(e){return e instanceof Uc&&e.code===eoe}function V2e(e){return e instanceof Error&&e.message.includes(toe)}async function En(e){const t=await soe(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function M2e(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Se({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 L2e(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:Fg.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function rp(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===D0.noCredential?ho.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 M0(e){return e.kind==="error"?V0(e.code)?new Uc(nQ[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const uoe=/\s+/,F2e=/[\\/]+$/,B2e=/[\\/]/,Ooe=`
3
3
 
4
4
  `,H2e=" — cancel with wake(",K2e=120,J2e=/(?:\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,eXe=new RegExp("\\p{Cf}","gu"),tXe=4096;function LE(e){return e==null?"":(typeof e=="string"?e:String(e)).replace(J2e,"").replace(eXe,"").split(uoe).filter(Boolean).join(" ").slice(0,K2e)}function doe(e){if(e.conversationName)return{name:e.conversationName,quoted:!0};const t=e.cwd.replace(F2e,"");if(t){const n=t.split(B2e).pop()??"";if(n)return{name:`${n}/`,quoted:!1}}return e.sessionId?{name:e.sessionId.slice(0,8),quoted:!1}:{name:"",quoted:!1}}function foe(e){const{name:t,quoted:n}=doe(e);return t?n?`"${t}"`:t:e.pid?`pid ${e.pid}`:"another session"}function hoe(e){const{name:t,quoted:n}=doe(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 nXe(e,t){return t.trim()?!0:hoe(e)!==foe(e)}function rXe(e){for(const t of e.slice(0,tXe).split(`
5
5
  `)){const n=LE(t);if(n)return n}return""}function UW(e,t){const n=foe(e),r=rXe(t);return r?`${n} · ${r}`:n}function iXe(e,t){return e.pid===t.pid&&e.conversationName===t.conversationName&&e.cwd===t.cwd&&e.sessionId===t.sessionId&&e.modelLabel===t.modelLabel}const aXe=/^<peer-session-message\s+((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/peer-session-message>\s*$/,oXe=/<\/?peer-session-message(?:[^>"']|"[^"]*"|'[^']*')*>/g,sXe=/^<peer-session-message[^>]*>/,lXe=/([a-zA-Z_]+)\s*=\s*(?:'([^']*)'|"([^"]*)"|([^\s>]+))/g;function cXe(e){const t=String(e.text??e.detail??""),n=aXe.exec(t.trim()),r={};if(n)for(const c of n[1].matchAll(lXe))r[c[1]]=c[2]??c[3]??c[4]??"";const i=n?n[2]:"",o=(String(e.body??"").trim()||i||(n?"":t.trim().replace(sXe,""))).replace(oXe,"").trim(),s=e.sender??{},l=(c,u)=>LE(c)||LE(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 uXe(e){return!!e.wake_catchup}function OXe(e){return e.hidden===!0}function dXe(e){let t=e.split(Ooe)[0]??"";t=t.split(uoe).filter(Boolean).join(" "),t=t.split(H2e)[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 fXe(e){const t=e.indexOf(Ooe);return t===-1?"":e.slice(t+2).trim()}const hXe=new Set(["command","path","file_path","url","pattern","query","name","target","message","milestone"]),pXe=new Set(["true","yes","y","t","on","1"]),mXe={hub:{steps:e=>{const t=jh(e);return t!==null&&Number.isInteger(t)&&t>=0?`${t} ${t===1?"step":"steps"}`:""}},wait:{wait_ms:e=>{const t=jh(e);return t!==null&&t>0?`· ${gO(t/1e3)}`:""}}};function jh(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 WW="mcp__",gXe=/^\/(?:Users|home)\/[^/]+\//,$Xe=/\s+/;function poe(e){return!e.startsWith("/")||e.includes(" ")?e:e.replace(gXe,"~/")}function po(e){return typeof e=="string"?poe(e.trim()).replace(/\n/g," ").trim():typeof e=="number"||typeof e=="boolean"?String(e):""}function yXe(e){return e.now?"now":e.wake===!1?"quiet":"wake"}function vXe(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($Xe).filter(Boolean).join(" ")||"?"}function bXe(e){return[yXe(e),po(vXe(e))||"?",po(e.message)].filter(Boolean).join(" · ")}const wXe=new Set(["delivered","mailbox","unconfirmed","failed"]);function SXe(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"&&wXe.has(n)?n:null}function moe(e,t){return!e||typeof e!="object"?t??null:SXe(e)}function xXe(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;return!("stage"in t)&&!("error_type"in t)?null:t}const QXe=["stage","queue_position","progress_fraction","log_lines","error","error_type"];function kXe(e,t){if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],i=t[n];if(!(!!r&&typeof r=="object")||!(!!i&&typeof i=="object")){if(r!==i)return!1;continue}const s=r,l=i;if(s.message!==l.message||s.timestamp!==l.timestamp)return!1}return!0}function PXe(e,t){for(const n of QXe){const r=e[n],i=t[n];if(n==="log_lines"){if(!kXe(r,i))return!1;continue}if(r!==i)return!1}return!0}function FE(e,t){const n=xXe(e);return n?t&&PXe(n,t)?t:n:t??null}const TXe={mailbox:"wake unconfirmed",unconfirmed:"delivery unconfirmed",failed:"not delivered"},_Xe={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."},XXe={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."},RXe={mailbox:"delivered, wake unconfirmed",unconfirmed:"delivery unconfirmed — it may still arrive, so check before resending"};function u6(e){return e==="mailbox"||e==="unconfirmed"}function EXe(e){return u6(e)?"partial":null}function qXe(e){return e==="failed"?"Attempted":null}function BE(e,t){return e!==!0?!1:!u6(t)}function YW(e){const t=jh(e.pid);return t!==null&&Number.isInteger(t)?`pid ${t}`:po(e.session)||po(e.target)||"?"}function jXe(e){const t=po(e.query);if(t){const o=jh(e.steps);return o!==null&&Number.isInteger(o)&&o>=0?`search ${t} · ${o} around`:`search ${t}`}const n=jh(e.steps);if(n!==null&&Number.isInteger(n)&&n>=0)return`last ${n}`;const r=jh(e.head);if(r!==null&&Number.isInteger(r)&&r>=0)return`first ${r}`;if(e.digest===!0)return"digest";const i=po(e.before_id);if(i)return`before ${i}`;const a=po(e.around_id);return a?`around ${a}`:""}function CXe(e){const t=d6(e);if(t==="spawn"){const n=po(e.visibility)||"workstream",r=po(e.name)||po(e.prompt);return[n,r].filter(Boolean).join(" · ")}if(t==="stop"||t==="resume"||t==="info")return YW(e);if(t==="peek")return[YW(e),jXe(e)].filter(Boolean).join(" · ");if(t==="list"){const n=[];e.include_stored===!0&&n.push("stored");const r=po(e.query);return r&&n.push(r),n.join(" · ")}return null}function zXe(e,t){const n=e.trim();if(!t)return n;if(n==="send")return bXe(t)||n;if(n.toLowerCase()==="sessions"){const a=CXe(t);if(a!==null)return a||n}const r=GXe(n)?Object.entries(t).filter(([a])=>!$oe.has(a)):Object.entries(t);let i=r.filter(([a])=>hXe.has(a)).map(([,a])=>po(a)).filter(Boolean);if(i.length===0){const a=mXe[n.toLowerCase()];i=r.map(([o,s])=>a?.[o]?.(s)||po(s)).filter(Boolean)}return i.slice(0,2).join(" ")||n}function Gd(e){const t=e.trim();if(!t.toLowerCase().startsWith(WW))return t;const n=t.slice(WW.length),r=n.indexOf("_");return r<=0?n||t:n.slice(r+1)||n}function goe(e,t){return e===t||e===Gd(t)}const AXe=/^(?:exit code:?\s*-?\d*|\(empty\)|--- (?:stdout|stderr) ---)$/,UXe="… ";function WXe(e,t=!1){if(!e||t)return null;for(const n of e.split(`
@@ -489,7 +489,7 @@ ${t}`)}throw new Error(`Failed to load configuration: ${e instanceof Error?e.mes
489
489
  }
490
490
  }`,iue=({isRecording:e})=>{const t=y.useRef(null),n=y.useRef(),r=y.useRef(null),i=y.useRef(null),a=y.useRef(null),o=y.useRef(null),s=y.useRef(Array(Y5).fill(UO)),l=y.useRef(HG),c=y.useRef(0);return y.useEffect(()=>{if(!e)return;const u=t.current;if(!u)return;const O=u.getContext("2d");if(!O)return;const d=()=>{const{width:m,height:g}=u.getBoundingClientRect(),$=window.devicePixelRatio||1,v=Math.max(1,Math.round(m*$)),w=Math.max(1,Math.round(g*$));(u.width!==v||u.height!==w)&&(u.width=v,u.height=w,O.scale($,$))};s.current=Array(Y5).fill(UO),l.current=HG,c.current=0;const f=()=>{d();const{width:m,height:g}=u.getBoundingClientRect(),$=getComputedStyle(u).color;O.clearRect(0,0,m,g);const v=m/Y5,w=.4,x=v*w,b=v*(1-w),S=b/2;s.current.forEach((Q,P)=>{const R=P*v+x/2,_=g/2,E=Q,C=_-E/2,z=Q<=UO+dYe;O.fillStyle=z?`color-mix(in srgb, ${$} 30%, transparent)`:$,O.beginPath(),O.roundRect(R,C,b,E,S),O.fill()})},p=()=>{if(a.current&&o.current){a.current.getFloatTimeDomainData(o.current);let m=0;const g=o.current;for(let v=0;v<g.length;v++)m+=g[v]*g[v];const $=g.length?Math.sqrt(m/g.length):0;if(c.current+=1,c.current>JG){const v=OYe(l.current,$);l.current=v.state;const w=UO+v.level*(KG-UO);s.current.shift(),s.current.push(w),c.current=0,f()}}n.current=requestAnimationFrame(p)};return(async()=>{try{const m=await navigator.mediaDevices.getUserMedia({audio:!0});r.current=m;const g=window.AudioContext||window.webkitAudioContext,$=new g;i.current=$;const v=$.createAnalyser();v.fftSize=1024,a.current=v,$.createMediaStreamSource(m).connect(v),o.current=new Float32Array(v.fftSize),p()}catch(m){console.warn("Could not access microphone for waveform visualization:",m);const g=()=>{const $=.15+Math.random()*.75,v=UO+$*(KG-UO);c.current+=1,c.current>JG&&(s.current.shift(),s.current.push(v),c.current=0,f()),n.current=requestAnimationFrame(g)};g()}})(),()=>{if(n.current&&cancelAnimationFrame(n.current),r.current){for(const m of r.current.getTracks())m.stop();r.current=null}i.current&&i.current.state!=="closed"&&(i.current.close().catch(console.error),i.current=null)}},[e]),e?h.jsxs("div",{"data-recording-indicator":"",className:"mt-2 flex w-full min-w-0 flex-col gap-2 px-2 text-accent",children:[h.jsx("style",{children:hYe}),h.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[h.jsxs("span",{className:"relative block size-2 shrink-0","aria-hidden":"true",children:[h.jsx("span",{className:"absolute inset-0 rounded-full border border-accent opacity-0 animate-[recording-ping_1.6s_ease-out_infinite]"}),h.jsx("span",{className:"block size-2 rounded-full bg-accent"})]}),h.jsx("span",{className:"shrink-0 font-medium text-body-sm text-accent",children:"Recording"}),h.jsxs("span",{className:"ml-auto flex min-w-0 items-center gap-1.5 text-body-sm text-ink-dim",children:[h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(dd,{shortcut:"Enter"}),"confirms"]}),h.jsx("span",{"aria-hidden":"true",children:"·"}),h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(dd,{shortcut:"Esc"}),"cancels"]})]})]}),h.jsx("div",{"aria-hidden":"true",children:h.jsx("canvas",{ref:t,className:fYe})})]}):null};iue.displayName="AudioRecordingIndicator";const eN=["agent","design","qa","ux"];function pYe(e){switch(e){case"agent":return"Code";case"design":return"Design";case"qa":return"QA";case"ux":return"UX";default:return e}}const mYe={findings_open:"findings open",remediation_posted:"remediation posted",clean:"clean",terminal:"terminal",unstated:"reviewed — verdict not stated"};function gYe(e){if(e.state==="awaiting_review")return"No agent review yet";const t=mYe[e.state]??e.state.trim(),n=e.state==="remediation_posted"?`${t} · awaiting re-review`:t,r=e.round;return typeof r=="number"&&Number.isFinite(r)?`Round ${r} · ${n}`:n}function $Ye(e,t){if(e.freshness!=="stale")return null;const n=e.reviewed_head?.slice(0,7)??"",r=t?.slice(0,7)??"";return n&&r?`stale — reviewed ${n}, head ${r}`:n?`stale — reviewed ${n}`:"stale"}function yYe(e){switch(e){case"findings_open":return"warning";case"remediation_posted":return"muted";case"clean":case"terminal":return"success";default:return"outline"}}function vYe(e){const t=e.summary?.state??null,n=[...e.lanes??[]].sort((a,o)=>tN(a.lane)-tN(o.lane));return(!n.some(a=>a.lane==="agent")&&(t==="open"||t==="draft")?[{lane:"agent",round:null,state:"awaiting_review",freshness:"unknown"},...n]:n).map((a,o)=>{const s=pYe(a.lane),l=$Ye(a,e.summary?.head_sha),c=[gYe(a),l].filter(Boolean).join(" · ");return{key:`${a.lane}-${o}`,name:s,segments:bYe(a),clause:c,title:`${s} — ${c}`}})}const tN=e=>{const t=eN.indexOf(e);return t===-1?eN.length:t};function bYe(e){const t=e.round;if(typeof t!="number"||!Number.isFinite(t)||t<1)return[];const n=Math.floor(t),r=yYe(e.state),i=e.freshness==="stale"&&r==="success";return Array.from({length:n},(a,o)=>({key:`${e.lane}-round-${o}`,tone:o===n-1?i?"muted":r:"muted"}))}function wYe(e){const t=[...e].sort((n,r)=>{const i=nN(n)-nN(r);if(i!==0)return i;const a=r.acted.length-n.acted.length;return a!==0?a:(r.mention.last_at??0)-(n.mention.last_at??0)});return{opened:t.filter(n=>n.relation!=="mentioned"),mentioned:t.filter(n=>n.relation==="mentioned")}}const nN=e=>{switch(e.relation){case"opened":return 0;case"unknown":return 1;case"inherited":return 2;default:return 3}};function SYe(e){const t=e.summary;if(!t)return null;if(t.draft)return{label:"Draft",variant:"outline"};switch(t.state){case"open":return{label:"Open",variant:"info"};case"merged":return{label:"Merged",variant:"success"};case"closed":return{label:"Closed",variant:"neutral"};default:return{label:t.state.trim()===""?"Unknown":t.state.trim(),variant:"neutral"}}}function Knn(e){if(!e)return null;const t=bh(e.failed),n=bh(e.pending),r=bh(e.passed),i=bh(e.total);return t!==null&&t>0?{text:`${t} failing`,tone:"danger"}:e.status==="failure"?{text:"CI failing",tone:"danger"}:e.status==="none"||i!==null&&i===0?{text:"No checks yet",tone:"muted"}:n!==null&&n>0?{text:"CI running",tone:"muted"}:e.status==="pending"?{text:"CI pending",tone:"muted"}:e.status==="unknown"?{text:"No checks yet",tone:"muted"}:i!==null&&i>0&&r!==null?{text:`${r}/${i} passed`,tone:"plain"}:e.status==="success"?{text:"CI passed",tone:"plain"}:null}const bh=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function xYe(e){const t=e.summary?.ci;return t?(bh(t.pending)??0)>0||t.status==="pending":!1}function Jnn(e){return e==null||e<=0?null:e===1?"1 comment":`${e} comments`}function ern(e,t){const n=Math.max(0,Math.floor(t/1e3-e));if(n<60)return"updated just now";const r=Math.floor(n/60);if(r<60)return`updated ${r} min ago`;const i=Math.floor(r/60);return i<24?`updated ${i} h ago`:`updated ${Math.floor(i/24)} d ago`}function trn(e){switch(e.relation){case"opened":return e.via?rN(e.via):null;case"mentioned":return null;case"unknown":return rN(e.via)??"unknown — possibly opened";case"inherited":return"inherited";default:return null}}function rN(e){if(!e)return null;if(iN(e).length>0)return`via subagent ${iN(e).join(" › ")}`;const t=e.agent_role??e.label;return t?`via subagent ${t}`:"via subagent"}function iN(e){if(Array.isArray(e.path)&&e.path.length>0)return e.path.filter(n=>typeof n=="string"&&n!=="");const t=e.agent_role??e.label;return t?[t]:[]}function nrn(e){return e.acted.length===0?null:`you ${e.acted.map(kYe).join(", ")}`}const QYe={comment:"commented",merge:"merged",review:"reviewed",push:"pushed",edit:"edited",close:"closed",ready:"marked ready"},kYe=e=>QYe[e]??e;function PYe(e){const t=e.filter(a=>a.relation==="opened"),n=t.some(a=>(a.lanes??[]).some(o=>o.state==="findings_open")),r=t.some(a=>{const o=a.summary?.ci;return o?o.status==="failure"||(bh(o.failed)??0)>0:!1}),i=[n?"findings open":null,r?"checks failing":null].filter(a=>a!==null);return i.length>0?i.join(" · "):null}function TYe(e){return e.refresh_error?`Couldn't refresh: ${e.refresh_error}`:null}function rrn(e){return e.link_only?e.reason??oue(e):e.refresh_error?TYe(e):e.reason??null}function irn(e,t){return e?Object.entries(e).filter(([,n])=>n*1e3>t).map(([n,r])=>{const i=new Date(r*1e3),a=`${String(i.getHours()).padStart(2,"0")}:${String(i.getMinutes()).padStart(2,"0")}`;return`${_Ye(n)} rate-limited until ${a}.`}):[]}function _Ye(e){return e.startsWith("github")?"GitHub":e.startsWith("gitlab")?"GitLab":e}function aue(e){return e===1?"1 code request":`${e} code requests`}function XYe(e,t,n,r,i=!1){const a=[t>0?`${t} opened`:null,n>0?`${n} mentioned`:null].filter(c=>c!==null),o=a.length>0?`, ${a.join(" · ")}`:"",s=r?`, ${r}`:"";return`${i?"Code review is showing":"Open code review"} — ${aue(e)}${o}${s}`}function oue(e){const t=e.link_only_hint?.trim();return t&&t!==""?t:"Link only"}function arn(e,t){return`${e}${t?"+":""} more seen in tool output`}function RYe(e){return e.forge==="gitlab"?"!":"#"}function EYe(e){return`${e.project} ${RYe(e)}${e.number}`}function orn(e){const t=e.summary?.title??e.url,n=[`${EYe(e)}: ${t}`],r=SYe(e);r&&n.push(r.label.toLowerCase());const i=vYe(e).map(a=>a.clause);return i.length>0?n.push(i.join("; ")):e.link_only&&n.push(oue(e)),n.push("opens in your browser"),n.join(", ")}const fz={session:e=>["desktop","code-requests",e]},qYe=5e3;function jYe(e,t){if(!t.visible)return!1;if(e?.scan_state==="refreshing")return qYe;const n=e?.rows??[];return t.sessionLive||n.some(xYe)?6e4:!1}function CYe(e){return!!e.sessionId&&e.capable&&e.pollEnabled&&e.provided}function zYe(e,t,n){return!t||!n||t.sessionId!==n||e&&e.sessionId===t.sessionId&&e.revision===t.revision?e:t}function AYe(e,t){const{client:n,provided:r}=Ga(),i=pi(),a=Dr(i.data,"code_requests");return UYe(e,r),_t({queryKey:fz.session(e??""),enabled:CYe({sessionId:e,capable:a,pollEnabled:t.enabled??!0,provided:r}),queryFn:()=>Se({op:"code_requests.list",sessionId:e??""}),retry:ya,staleTime:1e4,refetchInterval:o=>jYe(o.state.data,t),refetchIntervalInBackground:!1},n)}function UYe(e,t){const{codeRequestsRevision:n}=gce(),{client:r}=Ga(),i=y.useRef(null);y.useEffect(()=>{if(!t)return;const a=zYe(i.current,n,e);a!==i.current&&(i.current=a,e&&r.invalidateQueries({queryKey:fz.session(e)}))},[n,e,r,t])}function srn(e){const{client:t,provided:n}=Ga();return hq({mutationFn:async()=>Se({op:"code_requests.refresh",sessionId:e??"",force:!0}),onSuccess:()=>{n&&e&&t.invalidateQueries({queryKey:fz.session(e)})}},t)}function WYe(e,t=!1){const n=Ln(i=>i.rightSlotRoute.mounted),r=AYe(e,{visible:!1,sessionLive:!1,enabled:n});return YYe(n,r.data?.rows??[],t)}function YYe(e,t,n=!1){const r=wYe(t),i=PYe(t);return{show:e&&t.length>0,count:t.length,opened:r.opened.length,mentioned:r.mentioned.length,attention:i!==null,cause:i,label:XYe(t.length,r.opened.length,r.mentioned.length,i,n)}}const zu="goal",Yq="loop",sue="clear",lue="done",GYe="dismiss",cue=(e,t)=>e==="done"?"done":t==="stalled"?"stalled":t==="judging"||t==="continuing"?"working":"",uue="stop",hz=e=>e==="running"||e==="judging";function r$(e){return e.kind==="native_action"}function Oue(e){if(r$(e))return{tone:"info",text:`The backend needs more input for ${e.destination}.`};const t=e.style,n=e.kind==="error"||t==="error"?"error":t==="warning"?"warning":e.kind==="notice"?"success":"info";let r=e.text;if(!r&&e.kind==="block"){const i=e.data;if(Array.isArray(i.items))r=[i.title,...i.items.map(([a,o])=>`${a}: ${o}`)].filter(Boolean).join(`
491
491
  `);else if(e.data.type==="loop"){const a=e.data;r=`Loop ${a.status??"started"}: ${a.completed??0}${a.iterations?` of ${a.iterations}`:""} turns`}else r=JSON.stringify(e.data,null,2)}return{tone:n,text:r||e.kind}}function Xr(e){return e instanceof Error?e.message:"the backend refused it"}function ma(e){const[t,n]=y.useState(!1),[r,i]=y.useState(null),[a,o]=y.useState(null);return{run:y.useCallback(async(l,c,u)=>{n(!0),i(null);try{const O=await Se({op:"sessions.command",sessionId:e,requestId:Io(),command:l,args:c});o(O.result);const d=Oue(O.result);return i(d),{outcome:O.result,result:d}}catch(O){const d={tone:"error",text:`${u??`/${l} did not run`}: ${Xr(O)}`};return i(d),{outcome:null,result:d}}finally{n(!1)}},[e]),busy:t,result:r,outcome:a,setResult:i}}function NYe(e,t,n){return`${e}: ${t}${n?`
492
- ${n}`:""}`}function nu(){const[e,t]=y.useState(!1),[n,r]=y.useState(null);return{perform:y.useCallback(async(a,o,s,l)=>{t(!0),r(null);try{const c=await a();return r(o(c)),c}catch(c){return r({tone:"error",text:NYe(s,Xr(c),l)}),null}finally{t(!1)}},[]),busy:e,result:n,setResult:r}}const ZYe={signal:"stroke-info",label:"stroke-warning",danger:"stroke-danger"},bs=14,Gq=1.75,Nq=bs/2-Gq/2,aN=2*Math.PI*Nq,IYe=.06,DYe=({reading:e,className:t})=>{const n=e.fraction,r=n!==null&&n>0,i=r?Math.max(n,IYe):0;return h.jsxs("svg",{width:bs,height:bs,viewBox:`0 0 ${bs} ${bs}`,className:q("shrink-0",t),"aria-hidden":"true",focusable:"false",children:[h.jsx("circle",{cx:bs/2,cy:bs/2,r:Nq,fill:"none",strokeWidth:Gq,className:q(r?"stroke-sunken":"stroke-hairline")}),r&&h.jsx("circle",{cx:bs/2,cy:bs/2,r:Nq,fill:"none",strokeWidth:Gq,strokeLinecap:"round",strokeDasharray:aN,strokeDashoffset:aN*(1-i),transform:`rotate(-90 ${bs/2} ${bs/2})`,className:q(ZYe[e.rung])})]})},VYe=0x7ffn,MYe=0xfffffffffffffn,LYe=1075,FYe=-1074;function BYe(e){const t=new DataView(new ArrayBuffer(8));t.setFloat64(0,e);const n=BigInt(t.getUint32(0))<<32n|BigInt(t.getUint32(4)),r=(n>>63n&1n)===1n,i=Number(n>>52n&VYe),a=n&MYe,o=i===0?a:a|1n<<52n,s=i===0?FYe:i-LYe;return s>=0?{negative:r,num:o<<BigInt(s),scale:0}:{negative:r,num:o*5n**BigInt(-s),scale:-s}}function oN(e,t){let n=e.toString();if(t===0)return n;for(;n.length<=t;)n=`0${n}`;return`${n.slice(0,n.length-t)}.${n.slice(n.length-t)}`}function gl(e,t){if(!Number.isFinite(e))return"";const{negative:n,num:r,scale:i}=BYe(e);if(t>=i)return(n?"-":"")+oN(r*10n**BigInt(t-i),t);const a=10n**BigInt(i-t),o=r/a,s=r%a,l=a/2n,c=s>l||s===l&&(o&1n)===1n?o+1n:o;return(n?"-":"")+oN(c,t)}const sN=["danger","label","signal"],due="signal",HYe=[[5e5,"danger"],[2e5,"label"]],KYe=[[.8,"danger"],[.55,"label"]];function JYe(e,t=0){let n=due;for(const[r,i]of HYe)if(e>r){n=i;break}if(t>0){for(const[r,i]of KYe)if(e>t*r){sN.indexOf(i)<sN.indexOf(n)&&(n=i);break}}return n}function fue(e){return e>=1e6?`${gl(e/1e6,1)}m`:e>=1e3?`${gl(e/1e3,1)}k`:String(e)}function zw(e){if(e>=1e6){const t=e/1e6;return t===Math.trunc(t)?`${gl(t,0)}M`:`${gl(t,1)}M`}if(e>=1e3){const t=e/1e3;return t===Math.trunc(t)?`${gl(t,0)}k`:`${gl(t,1)}k`}return String(e)}function lN(e,t){if(e<=0)return"";if(t<=0)return`${fue(e)}/—`;const n=e/t*100;return n<.05?`<0.1%/${zw(t)}`:`${gl(n,1)}%/${zw(t)}`}function eGe(e){const t=e.context_tokens,n=typeof t=="number"&&Number.isFinite(t)&&t>0?t:null,r=e.context_window,i=typeof r=="number"&&Number.isFinite(r)&&r>0?r:null,a=JYe(n??0,i??0);return n===null?{status:"no-reading",tokens:null,window:i,fraction:null,rung:due,spelling:""}:i===null?{status:"window-unknown",tokens:n,window:null,fraction:null,rung:a,spelling:lN(n,0)}:{status:e.context_is_estimate?"estimate":"measured",tokens:n,window:i,fraction:Math.min(n/i,1),rung:a,spelling:lN(n,i)}}function tGe(e,t){if(e.status==="no-reading")return["Context","No reading yet. The first turn reports what the request carried."];const n=[];if(e.status==="window-unknown")return n.push(e.spelling),n.push(`${fue(e.tokens??0)} tokens in use. The window this model allows is not known, so there is no percentage to show.`),n;const r=e.tokens??0,i=e.window??0;return n.push(e.spelling),n.push(`${r.toLocaleString()} of ${i.toLocaleString()} tokens (${zw(i)} window)`),typeof t=="number"&&t>0&&t!==i&&n.push(`Model maximum: ${zw(t)}`),e.status==="estimate"&&n.push("estimate - counted by the app, not reported by the provider yet"),n}const nGe="≥",hue="$—";function pue(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function rGe(e){if(e.subagent_cost_knowledge!=null)return pue(e.subagent_cost);const t=e.child_costs;if(!t)return null;const n=Object.values(t).filter(r=>typeof r=="number"&&Number.isFinite(r));return n.length>0?n.reduce((r,i)=>r+i,0):null}function iGe(e){return e==="floor"||e==="partial"}function aGe(e){return e==="exact"||e==="partial"||e==="floor"?e:"unknown"}function Zq(e){return e<.01?`$${gl(e,4)}`:e<1?`$${gl(e,3)}`:`$${gl(e,2)}`}function oGe(e){const t=aGe(e.cost_knowledge);if(t==="partial"||t==="floor")return t;const n=e.subagent_cost_knowledge;return n==="partial"||n==="unknown"&&e.child_costs&&Object.keys(e.child_costs).length>0?"partial":t}function sGe(e,t){const n=pue(e.cumulative_parent_cost),r=rGe(e),i=oGe(e),a=iGe(i),o=n===null&&r===null?null:(n??0)+(r??0);if(o===null){const s=!!(t&&((t.input_tokens??0)||(t.output_tokens??0)));return{total:null,knowledge:i,isFloor:a,text:s?hue:""}}return o?{total:o,knowledge:i,isFloor:a,text:`${a?nGe:""}${Zq(o)}`}:{total:o,knowledge:i,isFloor:a,text:""}}function cN(e){if(e.total===null)return e.text===hue?"This session billed tokens on a model with no published price, so the spend cannot be calculated.":"Nothing has been spent in this session yet.";if(!e.total)return"Nothing has been spent in this session yet.";const t=`Session spend so far: ${Zq(e.total)}.`;return e.isFloor?`Session spend is at least ${Zq(e.total)}. Part of this conversation ran before the app was tracking it, or a subagent's spend is not fully known.`:t}const Uv=60,Wv=3600,G5=86400;function N5(e){const t=Math.trunc(Number.isFinite(e)&&e>0?e:0);if(t<Uv)return`${t}s`;if(t<Wv){const i=Math.trunc(t/Uv),a=t%Uv;return a?`${i}m${a}s`:`${i}m`}if(t<G5){const i=Math.trunc(t/Wv),a=Math.trunc(t%Wv/Uv);return a?`${i}h${a}m`:`${i}h`}const n=Math.trunc(t/G5);if(n>99)return"100d+";const r=Math.trunc(t%G5/Wv);return r?`${n}d${r}h`:`${n}d`}function lGe(e,t){const n=typeof e=="number"&&Number.isFinite(e)?Math.max(0,e):0,r=typeof t=="number"&&Number.isFinite(t)?t:null;return n<=0&&r===null?null:{banked:n,startedAt:r===null?null:r*1e3}}const cGe="Time the agent has spent working in this conversation. Time waiting between turns is not counted.",uGe="Time spent working; waiting is not counted.",mue="inline-flex h-6 min-w-0 shrink-0 items-center gap-1.5 rounded-sm px-1.5 text-meta",al=q(mue,"cursor-pointer text-ink-muted transition-colors duration-fast ease-out-quart","hover:bg-accent-wash hover:text-ink","focus-visible:outline-offset-1!"),Iq=q(mue,"cursor-default text-ink-dim"),OGe={cumulative_parent_cost:null,child_costs:null,subagent_cost:null,subagent_cost_knowledge:null,cost_knowledge:"unknown"},dGe=1e3;function fGe(e,t){const n=()=>t===null?e:e+Math.max(0,(Date.now()-t)/1e3),[r,i]=y.useState(n);return y.useEffect(()=>{if(t===null){i(e);return}const a=()=>i(e+Math.max(0,(Date.now()-t)/1e3));a();const o=window.setInterval(a,dGe);return()=>window.clearInterval(o)},[e,t]),r}const gue="Last reading from before the reconnect.",hGe="Readings dropped when the connection was lost.",pGe="Fast mode on",WO=({tooltip:e,label:t,onOpen:n,readout:r=!1,held:i=!1,children:a,className:o})=>{const s=t,l=i?h.jsxs("span",{className:"flex flex-col gap-0.5",children:[e,h.jsx("span",{className:"text-ink-muted",children:gue})]}):e;return n?h.jsx(Nt,{content:l,children:h.jsx("button",{type:"button",onClick:n,"aria-label":s,className:q(al,o),children:a})}):r?h.jsx(Nt,{content:l,children:h.jsx("span",{tabIndex:0,"aria-label":s,className:q(Iq,o),children:a})}):h.jsx(Nt,{content:l,children:h.jsx("button",{type:"button","aria-disabled":"true","aria-label":s,className:q(Iq,o),children:a})})},YO=({lines:e,mono:t=!0})=>h.jsx("span",{className:"flex flex-col gap-0.5",children:e.map((n,r)=>h.jsx("span",{className:q(r===0?"text-ink":"text-ink-muted",t&&r===0&&e.length>1&&"font-mono text-mono-sm"),children:n},n))});function Z5(e,t,n=!1){return t?n?e==="measured"||e==="estimate"?"Click for the full breakdown, which estimates your next request.":"Click for the full breakdown.":e==="measured"?"Measured now; click for the full breakdown, which estimates your next request":e==="estimate"?"Estimated now; click for the full breakdown, which estimates your next request":"Click for the full breakdown":pz}const pz="Slash commands are off on this server, so this reading cannot be opened from here.";function uN(e,t){return t?e?"Click to choose a different model. It applies to this conversation.":"Click to choose a different model":e?"This conversation will use it. Change it once the conversation starts.":pz}function mGe(e,t,n){return t?n?e?"Change it. It applies to this conversation.":"Change it.":e?$ue:pz:null}const gGe="Nothing measured yet. The window fills as the conversation runs.",$Ge=["Context",gGe],yGe="Context: nothing measured yet. The window fills as the conversation runs.",$ue="Set once the conversation starts.",vGe=({frontend:e,onCommand:t,effortEntities:n,pendingModel:r=null,draft:i=!1,held:a=!1,onOpenDraftPicker:o,draftResolution:s,readingsDropped:l=!1,controlsThirdBox:c=!1,className:u})=>{if(!e&&!(i&&s))return l&&!i?h.jsx("p",{"data-lo-readings-dropped":!0,role:"status",className:q("order-2 -mx-1.5 min-w-0 text-meta text-ink-dim",u),children:hGe}):null;const O=i?void 0:t,d=i?o:void 0,f=r!==null,p=sQ(e,r),m=p.identity,g=f4e(m),$=v6(m)==="on",v=m4e(p4e(p.effort),n),w=eGe({context_tokens:e?.context_tokens,context_window:e?.context_window,context_is_estimate:e?.context_is_estimate}),x=sGe(e??OGe,e?.last_usage),b=lGe(e?.active_duration_s??0,e?.activity_started_at??null),S=fGe(b?.banked??0,b?.startedAt??null),Q=O?()=>O({name:"model",args:""}):d?()=>d("session.model"):void 0,P=v?.adjustable&&O?()=>O({name:"effort",args:""}):v?.adjustable&&v.knownLadder&&d?()=>d("session.effort"):void 0,R=!g&&!!d&&!s;return!g&&!v&&w.status==="no-reading"&&!x.text&&!R&&!s?null:h.jsxs("div",{className:q("-mx-1.5 flex min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5","order-2 flex-nowrap",u),"data-lo-session-strip":!0,"data-lo-session-strip-draft":i?!0:void 0,"data-lo-session-strip-held":a?!0:void 0,role:"group","aria-label":a?`Session readings. ${gue}`:void 0,children:[a&&h.jsx("span",{className:"shrink-0 text-meta text-ink-dim @max-[750px]/chatcol:hidden",children:"Last reading"}),g&&h.jsxs(WO,{label:f?`Model: ${g.selector}${$?", fast mode on":""}. Switching; waiting for the session to confirm it.`:`Model: ${g.selector}${$?", fast mode on":""}. ${uN(i,!!Q)}`,tooltip:h.jsx(YO,{lines:f?[g.selector,"Switching the model; waiting for the session to confirm it"]:[g.selector,...$?[pGe]:[],uN(i,!!Q)]}),onOpen:Q,held:a,className:q("min-w-14 max-w-full shrink",f&&"text-ink-dim"),children:[$&&h.jsx(Z7e,{"aria-hidden":"true",className:"size-3.5 shrink-0",fill:"currentColor",stroke:"none"}),h.jsx("span",{className:"truncate",children:g.name}),f&&h.jsx(ts,{size:"xs",label:"Switching the model"})]}),R&&h.jsx(WO,{label:"Model: none resolved yet. Choose the model this conversation will run on.",tooltip:h.jsx(YO,{lines:["No model resolved yet","Choose the model this conversation will run on"]}),onOpen:Q,className:"shrink-0",children:h.jsx("span",{className:"truncate",children:"Choose a model"})}),s&&!g&&h.jsxs(WO,{label:s.status==="failed"?"Model: this conversation's model was not resolved. Retry.":"Model: resolving the model this conversation will run on.",tooltip:h.jsx(YO,{lines:s.status==="failed"?["This conversation's model was not resolved","No model is set for it yet","Retry"]:["Resolving","Working out which model this conversation will run on"]}),onOpen:s.status==="failed"?s.retry:void 0,className:q("shrink-0",s.status==="pending"&&"text-ink-dim"),children:[h.jsx("span",{className:"truncate",children:s.status==="failed"?"Retry":"Resolving the model"}),s.status==="pending"&&h.jsx(ts,{size:"xs",label:"Resolving the model this conversation will run on"})]}),v&&(!i||v.levelKnown)&&h.jsx(WO,{label:[`Reasoning effort: ${Ah(v.label)}.`,mGe(i,v.adjustable,!!P)].filter(Boolean).join(" "),tooltip:h.jsx(YO,{lines:[Ah(v.label),...i&&v.adjustable&&!P?[$ue]:[v.detail]]}),onOpen:P,held:a,children:h.jsx("span",{className:"font-mono text-mono-sm",children:Ah(v.label)})}),h.jsxs(WO,{label:i?yGe:w.status==="no-reading"?`Context: no reading yet. ${Z5("no-reading",!!O,a)}`:`Context: ${w.spelling}${w.status==="estimate"?", estimated":""}. ${Z5(w.status,!!O,a)}`,tooltip:h.jsx(YO,{mono:w.status!=="no-reading",lines:i?$Ge:[...tGe(w,typeof m?.max_context_window=="number"?m.max_context_window:null),Z5(w.status,!!O,a)]}),onOpen:O?()=>O({name:"context",args:""}):void 0,held:a,children:[h.jsx(DYe,{reading:w}),w.spelling&&h.jsxs("span",{className:"font-mono text-mono-sm",children:[w.spelling,w.status==="estimate"&&h.jsx("span",{className:"ml-1 text-ink-dim",children:"estimate"})]})]}),x.text&&h.jsx(WO,{label:cN(x),tooltip:h.jsx(YO,{lines:[x.text,cN(x)]}),readout:!0,held:a,children:h.jsx("span",{className:"font-mono text-mono-sm",children:x.text})}),b&&h.jsx(WO,{label:`Active time: ${N5(S)}. ${uGe}`,tooltip:h.jsx(YO,{lines:[N5(S),cGe]}),readout:!0,held:a,className:c?"hidden":"@min-[750px]/chatcol:@max-[860px]/chatcol:hidden",children:h.jsx("span",{className:"font-mono text-mono-sm tabular-nums",children:N5(S)})})]})},Ju=Yi()(e=>({open:!1,focusGroup:null,providerId:null,openConnect:t=>e({open:!0,focusGroup:t?.group??null,providerId:t?.providerId??null}),closeConnect:()=>e({open:!1,focusGroup:null,providerId:null})})),yue=/No model provider is configured yet/,vue=500,bue=3,bGe=6e4,wGe=5,SGe=5e3,xGe=1e3,QGe=e=>typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.min(e,SGe)):xGe,kGe=e=>Math.min(bGe,vue*2**(e-bue+1)),PGe=2e3,TGe=6e4,_Ge=e=>e instanceof Yt&&e.code===_2e,XGe=e=>e instanceof Yt&&e.code===T2e,RGe=(e,t,n)=>n?ud(e,t,n):e;function EGe(e,t,n){const r=e?.attention,i=e?.session_id,a=cr(l=>l.sessions.find(c=>c.session_id===i)?.attention),o=RGe(r,a,i),s=y.useRef({subject:o,streaming:e?.streaming===!0,ready:t});s.current={subject:o,streaming:e?.streaming===!0,ready:t},y.useEffect(()=>{if(!i||!o?.unseen)return;const l=cr.getState().applyAttention,c=cr.getState().publishReadAckNotice,u=cr.getState().clearReadAckNotice;let O=o.completion_token,d=!1,f=!1,p=!1,m=0,g=0,$=0,v=!1,w=cr.getState().readAckRearm?.revision??0;const x=E=>{if(m+=1,m>=bue){if($=Date.now()+kGe(m),v)return;v=!0,console.warn(`[attention] ${i} receipt unresolved after ${m} attempts; backing off`,E),c(i,"unsettled",E);return}c(i,"pending")};let b=0;const S=()=>{b&&(clearInterval(b),b=0)},Q=()=>{if(d||f||p)return;const E=cr.getState().readAckRearm;if(E&&E.sessionId===i&&E.revision!==w&&(w=E.revision,m=0,g=0,$=0,v=!1),!s.current.ready||s.current.streaming)return;const C=s.current.subject;if(C?.supported!==!0||C.conversation_id!==`session/${i}`)return;const z=C.completion_token,W=C.anchor_id;if(!z||!W||(z!==O&&(O=z,m=0,g=0,$=0,v=!1),cr.getState().activeSessionId!==i)||document.visibilityState!=="visible"||!document.hasFocus()||Date.now()<$)return;const N=n.current?.querySelector(`[data-completion-anchor="${CSS.escape(W)}"][data-completion-complete="true"]`);if(!N){c(i,"offscreen");return}const D=N.getBoundingClientRect(),M=D.bottom-2;if(D.width<=0||D.height<=0||M<0||M>=innerHeight){c(i,"offscreen");return}const B=Y=>{if(Y<0||Y>=innerWidth)return!0;const A=document.elementFromPoint(Y,M);return!A||!N.contains(A)};[.25,.5,.75].every(Y=>B(D.left+D.width*Y))||(f=!0,Se({op:"sessions.seen",sessionId:i,completionToken:z}).then(Y=>{if(!d){if(!E2e(Y,i,z)){x("answer did not settle the rendered completion");return}p=!0,S(),u(i),l(i,Y)}}).catch(Y=>{if(!d){if(_Ge(Y)&&g<wGe){g+=1,$=Date.now()+QGe(Y.retryAfterMs),c(i,"pending");return}if(XGe(Y)){S(),u(i);return}if(D2e(Y)){$=Date.now()+PGe;return}if(I2e(Y)){$=Date.now()+TGe,c(i,"remote",Y);return}x(Y)}}).finally(()=>{f=!1}))},P=requestAnimationFrame(Q);b=window.setInterval(Q,vue);const R=()=>{$=0,Q()},_=()=>{document.visibilityState==="visible"&&R()};return window.addEventListener("focus",R),document.addEventListener("visibilitychange",_),()=>{d=!0,cancelAnimationFrame(P),S(),window.removeEventListener("focus",R),document.removeEventListener("visibilitychange",_),u(i)}},[i,o?.completion_token,o?.unseen,n])}function lrn(){}function ON(e){const t=[],n=String(e||"");let r=n.indexOf(","),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);const o=n.slice(i,r).trim();(o||!a)&&t.push(o),i=r+1,r=n.indexOf(",",i)}return t}function qGe(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const jGe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,CGe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zGe={};function dN(e,t){return(zGe.jsx?CGe:jGe).test(e)}const AGe=/[ \t\n\f\r]/g;function UGe(e){return typeof e=="object"?e.type==="text"?fN(e.value):!1:fN(e)}function fN(e){return e.replace(AGe,"")===""}let Xy=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Xy.prototype.normal={};Xy.prototype.property={};Xy.prototype.space=void 0;function wue(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Xy(n,r,t)}function i$(e){return e.toLowerCase()}class Na{constructor(t,n){this.attribute=n,this.property=t}}Na.prototype.attribute="";Na.prototype.booleanish=!1;Na.prototype.boolean=!1;Na.prototype.commaOrSpaceSeparated=!1;Na.prototype.commaSeparated=!1;Na.prototype.defined=!1;Na.prototype.mustUseProperty=!1;Na.prototype.number=!1;Na.prototype.overloadedBoolean=!1;Na.prototype.property="";Na.prototype.spaceSeparated=!1;Na.prototype.space=void 0;let WGe=0;const Bt=gf(),Lr=gf(),Sue=gf(),Ue=gf(),sr=gf(),Wh=gf(),to=gf();function gf(){return 2**++WGe}const Dq=Object.freeze(Object.defineProperty({__proto__:null,boolean:Bt,booleanish:Lr,commaOrSpaceSeparated:to,commaSeparated:Wh,number:Ue,overloadedBoolean:Sue,spaceSeparated:sr},Symbol.toStringTag,{value:"Module"})),I5=Object.keys(Dq);class mz extends Na{constructor(t,n,r,i){let a=-1;if(super(t,n),hN(this,"space",i),typeof r=="number")for(;++a<I5.length;){const o=I5[a];hN(this,I5[a],(r&Dq[o])===Dq[o])}}}mz.prototype.defined=!0;function hN(e,t,n){n&&(e[t]=n)}function om(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const a=new mz(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[i$(r)]=r,n[i$(a.attribute)]=r}return new Xy(t,n,e.space)}const xue=om({properties:{ariaActiveDescendant:null,ariaAtomic:Lr,ariaAutoComplete:null,ariaBusy:Lr,ariaChecked:Lr,ariaColCount:Ue,ariaColIndex:Ue,ariaColSpan:Ue,ariaControls:sr,ariaCurrent:null,ariaDescribedBy:sr,ariaDetails:null,ariaDisabled:Lr,ariaDropEffect:sr,ariaErrorMessage:null,ariaExpanded:Lr,ariaFlowTo:sr,ariaGrabbed:Lr,ariaHasPopup:null,ariaHidden:Lr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:sr,ariaLevel:Ue,ariaLive:null,ariaModal:Lr,ariaMultiLine:Lr,ariaMultiSelectable:Lr,ariaOrientation:null,ariaOwns:sr,ariaPlaceholder:null,ariaPosInSet:Ue,ariaPressed:Lr,ariaReadOnly:Lr,ariaRelevant:null,ariaRequired:Lr,ariaRoleDescription:sr,ariaRowCount:Ue,ariaRowIndex:Ue,ariaRowSpan:Ue,ariaSelected:Lr,ariaSetSize:Ue,ariaSort:null,ariaValueMax:Ue,ariaValueMin:Ue,ariaValueNow:Ue,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Que(e,t){return t in e?e[t]:t}function kue(e,t){return Que(e,t.toLowerCase())}const YGe=om({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Wh,acceptCharset:sr,accessKey:sr,action:null,allow:null,allowFullScreen:Bt,allowPaymentRequest:Bt,allowUserMedia:Bt,alt:null,as:null,async:Bt,autoCapitalize:null,autoComplete:sr,autoFocus:Bt,autoPlay:Bt,blocking:sr,capture:null,charSet:null,checked:Bt,cite:null,className:sr,cols:Ue,colSpan:null,content:null,contentEditable:Lr,controls:Bt,controlsList:sr,coords:Ue|Wh,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Bt,defer:Bt,dir:null,dirName:null,disabled:Bt,download:Sue,draggable:Lr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Bt,formTarget:null,headers:sr,height:Ue,hidden:Bt,high:Ue,href:null,hrefLang:null,htmlFor:sr,httpEquiv:sr,id:null,imageSizes:null,imageSrcSet:null,inert:Bt,inputMode:null,integrity:null,is:null,isMap:Bt,itemId:null,itemProp:sr,itemRef:sr,itemScope:Bt,itemType:sr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Bt,low:Ue,manifest:null,max:null,maxLength:Ue,media:null,method:null,min:null,minLength:Ue,multiple:Bt,muted:Bt,name:null,nonce:null,noModule:Bt,noValidate:Bt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Bt,optimum:Ue,pattern:null,ping:sr,placeholder:null,playsInline:Bt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Bt,referrerPolicy:null,rel:sr,required:Bt,reversed:Bt,rows:Ue,rowSpan:Ue,sandbox:sr,scope:null,scoped:Bt,seamless:Bt,selected:Bt,shadowRootClonable:Bt,shadowRootDelegatesFocus:Bt,shadowRootMode:null,shape:null,size:Ue,sizes:null,slot:null,span:Ue,spellCheck:Lr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ue,step:null,style:null,tabIndex:Ue,target:null,title:null,translate:null,type:null,typeMustMatch:Bt,useMap:null,value:Lr,width:Ue,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:sr,axis:null,background:null,bgColor:null,border:Ue,borderColor:null,bottomMargin:Ue,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Bt,declare:Bt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ue,leftMargin:Ue,link:null,longDesc:null,lowSrc:null,marginHeight:Ue,marginWidth:Ue,noResize:Bt,noHref:Bt,noShade:Bt,noWrap:Bt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ue,rules:null,scheme:null,scrolling:Lr,standby:null,summary:null,text:null,topMargin:Ue,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ue,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Bt,disableRemotePlayback:Bt,prefix:null,property:null,results:Ue,security:null,unselectable:null},space:"html",transform:kue}),GGe=om({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:to,accentHeight:Ue,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ue,amplitude:Ue,arabicForm:null,ascent:Ue,attributeName:null,attributeType:null,azimuth:Ue,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ue,by:null,calcMode:null,capHeight:Ue,className:sr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ue,diffuseConstant:Ue,direction:null,display:null,dur:null,divisor:Ue,dominantBaseline:null,download:Bt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ue,enableBackground:null,end:null,event:null,exponent:Ue,externalResourcesRequired:null,fill:null,fillOpacity:Ue,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Wh,g2:Wh,glyphName:Wh,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ue,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ue,horizOriginX:Ue,horizOriginY:Ue,id:null,ideographic:Ue,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ue,k:Ue,k1:Ue,k2:Ue,k3:Ue,k4:Ue,kernelMatrix:to,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ue,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ue,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ue,overlineThickness:Ue,paintOrder:null,panose1:null,path:null,pathLength:Ue,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:sr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ue,pointsAtY:Ue,pointsAtZ:Ue,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:to,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:to,rev:to,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:to,requiredFeatures:to,requiredFonts:to,requiredFormats:to,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ue,specularExponent:Ue,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ue,strikethroughThickness:Ue,string:null,stroke:null,strokeDashArray:to,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ue,strokeOpacity:Ue,strokeWidth:null,style:null,surfaceScale:Ue,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:to,tabIndex:Ue,tableValues:null,target:null,targetX:Ue,targetY:Ue,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:to,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ue,underlineThickness:Ue,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ue,values:null,vAlphabetic:Ue,vMathematical:Ue,vectorEffect:null,vHanging:Ue,vIdeographic:Ue,version:null,vertAdvY:Ue,vertOriginX:Ue,vertOriginY:Ue,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ue,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Que}),Pue=om({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Tue=om({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:kue}),_ue=om({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),NGe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},ZGe=/[A-Z]/g,pN=/-[a-z]/g,IGe=/^data[-\w.:]+$/i;function Xue(e,t){const n=i$(t);let r=t,i=Na;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&IGe.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(pN,VGe);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!pN.test(a)){let o=a.replace(ZGe,DGe);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=mz}return new i(r,t)}function DGe(e){return"-"+e.toLowerCase()}function VGe(e){return e.charAt(1).toUpperCase()}const Rue=wue([xue,YGe,Pue,Tue,_ue],"html"),xQ=wue([xue,GGe,Pue,Tue,_ue],"svg");function mN(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function MGe(e){return e.join(" ").trim()}var LGe=fce();const FGe=Fn(LGe),Eue=que("end"),gz=que("start");function que(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function BGe(e){const t=gz(e),n=Eue(e);if(t&&n)return{start:t,end:n}}function t0(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?gN(e.position):"start"in e||"end"in e?gN(e):"line"in e||"column"in e?Vq(e):""}function Vq(e){return $N(e&&e.line)+":"+$N(e&&e.column)}function gN(e){return Vq(e&&e.start)+"-"+Vq(e&&e.end)}function $N(e){return e&&typeof e=="number"?e:1}class aa extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?a.ruleId=r:(a.source=r.slice(0,l),a.ruleId=r.slice(l+1))}if(!a.place&&a.ancestors&&a.ancestors){const l=a.ancestors[a.ancestors.length-1];l&&(a.place=l.position)}const s=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=s?s.line:void 0,this.name=t0(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual,this.expected,this.note,this.url}}aa.prototype.file="";aa.prototype.name="";aa.prototype.reason="";aa.prototype.message="";aa.prototype.stack="";aa.prototype.column=void 0;aa.prototype.line=void 0;aa.prototype.ancestors=void 0;aa.prototype.cause=void 0;aa.prototype.fatal=void 0;aa.prototype.place=void 0;aa.prototype.ruleId=void 0;aa.prototype.source=void 0;const $z={}.hasOwnProperty,HGe=new Map,KGe=/[A-Z]/g,JGe=new Set(["table","tbody","thead","tfoot","tr"]),eNe=new Set(["td","th"]),jue="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tNe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=cNe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=lNe(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?xQ:Rue,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Cue(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Cue(e,t,n){if(t.type==="element")return nNe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return rNe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return aNe(e,t,n);if(t.type==="mdxjsEsm")return iNe(e,t);if(t.type==="root")return oNe(e,t,n);if(t.type==="text")return sNe(e,t)}function nNe(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=xQ,e.schema=i),e.ancestors.push(t);const a=Aue(e,t.tagName,!1),o=uNe(e,t);let s=vz(e,t);return JGe.has(t.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!UGe(l):!0})),zue(e,o,a,t),yz(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function rNe(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}a$(e,t.position)}function iNe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);a$(e,t.position)}function aNe(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=xQ,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:Aue(e,t.name,!0),o=ONe(e,t),s=vz(e,t);return zue(e,o,a,t),yz(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function oNe(e,t,n){const r={};return yz(r,vz(e,t)),e.create(t,e.Fragment,r,n)}function sNe(e,t){return t.value}function zue(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function yz(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function lNe(e,t,n){return r;function r(i,a,o,s){const c=Array.isArray(o.children)?n:t;return s?c(a,o,s):c(a,o)}}function cNe(e,t){return n;function n(r,i,a,o){const s=Array.isArray(a.children),l=gz(r);return t(i,a,o,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function uNe(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&$z.call(t.properties,i)){const a=dNe(e,i,t.properties[i]);if(a){const[o,s]=a;e.tableCellAlignToStyle&&o==="align"&&typeof s=="string"&&eNe.has(t.tagName)?r=s:n[o]=s}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ONe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const s=o.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else a$(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,a=e.evaluater.evaluateExpression(s.expression)}else a$(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function vz(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:HGe;for(;++r<t.children.length;){const a=t.children[r];let o;if(e.passKeys){const l=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const s=Cue(e,a,o);s!==void 0&&n.push(s)}return n}function dNe(e,t,n){const r=Xue(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?qGe(n):MGe(n)),r.property==="style"){let i=typeof n=="object"?n:fNe(e,String(n));return e.stylePropertyNameCase==="css"&&(i=hNe(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?NGe[r.property]||r.property:r.attribute,n]}}function fNe(e,t){try{return FGe(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new aa("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=jue+"#cannot-parse-style-attribute",i}}function Aue(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let a=-1,o;for(;++a<i.length;){const s=dN(i[a])?{type:"Identifier",name:i[a]}:{type:"Literal",value:i[a]};o=o?{type:"MemberExpression",object:o,property:s,computed:!!(a&&s.type==="Literal"),optional:!1}:s}r=o}else r=dN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return $z.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);a$(e)}function a$(e,t){const n=new aa("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=jue+"#cannot-handle-mdx-estrees-without-createevaluater",n}function hNe(e){const t={};let n;for(n in e)$z.call(e,n)&&(t[pNe(n)]=e[n]);return t}function pNe(e){let t=e.replace(KGe,mNe);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function mNe(e){return"-"+e.toLowerCase()}const D5={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},gNe={};function bz(e,t){const n=gNe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Uue(e,r,i)}function Uue(e,t,n){if($Ne(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return yN(e.children,t,n)}return Array.isArray(e)?yN(e,t,n):""}function yN(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Uue(e[i],t,n);return r.join("")}function $Ne(e){return!!(e&&typeof e=="object")}const vN=document.createElement("i");function wz(e){const t="&"+e+";";vN.innerHTML=t;const n=vN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function $o(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Wo(e,t){return e.length>0?($o(e,e.length,0,t),e):t}const bN={}.hasOwnProperty;function Wue(e){const t={};let n=-1;for(;++n<e.length;)yNe(t,e[n]);return t}function yNe(e,t){let n;for(n in t){const i=(bN.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){bN.call(i,o)||(i[o]=[]);const s=a[o];vNe(i[o],Array.isArray(s)?s:s?[s]:[])}}}function vNe(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);$o(e,0,0,r)}function Yue(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function js(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const pa=vO(/[A-Za-z]/),ea=vO(/[\dA-Za-z]/),bNe=vO(/[#-'*+\--9=?A-Z^-~]/);function Aw(e){return e!==null&&(e<32||e===127)}const Mq=vO(/\d/),wNe=vO(/[\dA-Fa-f]/),SNe=vO(/[!-/:-@[-`{-~]/);function yt(e){return e!==null&&e<-2}function ir(e){return e!==null&&(e<0||e===32)}function pn(e){return e===-2||e===-1||e===32}const QQ=vO(new RegExp("\\p{P}|\\p{S}","u")),Dd=vO(/\s/);function vO(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function sm(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o="";if(a===37&&ea(e.charCodeAt(n+1))&&ea(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const s=e.charCodeAt(n+1);a<56320&&s>56319&&s<57344?(o=String.fromCharCode(a,s),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ln(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(l){return pn(l)?(e.enter(n),s(l)):t(l)}function s(l){return pn(l)&&a++<i?(e.consume(l),s):(e.exit(n),t(l))}}const xNe={tokenize:QNe};function QNe(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),ln(e,t,"linePrefix")}function i(s){return e.enter("paragraph"),a(s)}function a(s){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(s)}function o(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return yt(s)?(e.consume(s),e.exit("chunkText"),a):(e.consume(s),o)}}const kNe={tokenize:PNe},wN={tokenize:TNe};function PNe(e){const t=this,n=[];let r=0,i,a,o;return s;function s(w){if(r<n.length){const x=n[r];return t.containerState=x[1],e.attempt(x[0].continuation,l,c)(w)}return c(w)}function l(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const x=t.events.length;let b=x,S;for(;b--;)if(t.events[b][0]==="exit"&&t.events[b][1].type==="chunkFlow"){S=t.events[b][1].end;break}$(r);let Q=x;for(;Q<t.events.length;)t.events[Q][1].end={...S},Q++;return $o(t.events,b+1,0,t.events.slice(x)),t.events.length=Q,c(w)}return s(w)}function c(w){if(r===n.length){if(!i)return d(w);if(i.currentConstruct&&i.currentConstruct.concrete)return p(w);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(wN,u,O)(w)}function u(w){return i&&v(),$(r),d(w)}function O(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(w)}function d(w){return t.containerState={},e.attempt(wN,f,p)(w)}function f(w){return r++,n.push([t.currentConstruct,t.containerState]),d(w)}function p(w){if(w===null){i&&v(),$(0),e.consume(w);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),m(w)}function m(w){if(w===null){g(e.exit("chunkFlow"),!0),$(0),e.consume(w);return}return yt(w)?(e.consume(w),g(e.exit("chunkFlow")),r=0,t.interrupt=void 0,s):(e.consume(w),m)}function g(w,x){const b=t.sliceStream(w);if(x&&b.push(null),w.previous=a,a&&(a.next=w),a=w,i.defineSkip(w.start),i.write(b),t.parser.lazy[w.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<o&&(!i.events[S][1].end||i.events[S][1].end.offset>o))return;const Q=t.events.length;let P=Q,R,_;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){if(R){_=t.events[P][1].end;break}R=!0}for($(r),S=Q;S<t.events.length;)t.events[S][1].end={..._},S++;$o(t.events,P+1,0,t.events.slice(Q)),t.events.length=S}}function $(w){let x=n.length;for(;x-- >w;){const b=n[x];t.containerState=b[1],b[0].exit.call(t,e)}n.length=w}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function TNe(e,t,n){return ln(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function op(e){if(e===null||ir(e)||Dd(e))return 1;if(QQ(e))return 2}function kQ(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Lq={name:"attention",resolveAll:_Ne,tokenize:XNe};function _Ne(e,t){let n=-1,r,i,a,o,s,l,c,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const O={...e[r][1].end},d={...e[n][1].start};SN(O,-l),SN(d,l),o={type:l>1?"strongSequence":"emphasisSequence",start:O,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:d},a={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Wo(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Wo(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),c=Wo(c,kQ(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Wo(c,[["exit",a,t],["enter",s,t],["exit",s,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=Wo(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,$o(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function XNe(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=op(r);let a;return o;function o(l){return a=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===a)return e.consume(l),s;const c=e.exit("attentionSequence"),u=op(l),O=!u||u===2&&i||n.includes(l),d=!i||i===2&&u||n.includes(r);return c._open=!!(a===42?O:O&&(i||!d)),c._close=!!(a===42?d:d&&(u||!O)),t(l)}}function SN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const RNe={name:"autolink",tokenize:ENe};function ENe(e,t,n){let r=0;return i;function i(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a}function a(f){return pa(f)?(e.consume(f),o):f===64?n(f):c(f)}function o(f){return f===43||f===45||f===46||ea(f)?(r=1,s(f)):c(f)}function s(f){return f===58?(e.consume(f),r=0,l):(f===43||f===45||f===46||ea(f))&&r++<32?(e.consume(f),s):(r=0,c(f))}function l(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Aw(f)?n(f):(e.consume(f),l)}function c(f){return f===64?(e.consume(f),u):bNe(f)?(e.consume(f),c):n(f)}function u(f){return ea(f)?O(f):n(f)}function O(f){return f===46?(e.consume(f),r=0,u):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):d(f)}function d(f){if((f===45||ea(f))&&r++<63){const p=f===45?d:O;return e.consume(f),p}return n(f)}}const Ry={partial:!0,tokenize:qNe};function qNe(e,t,n){return r;function r(a){return pn(a)?ln(e,i,"linePrefix")(a):i(a)}function i(a){return a===null||yt(a)?t(a):n(a)}}const Gue={continuation:{tokenize:CNe},exit:zNe,name:"blockQuote",tokenize:jNe};function jNe(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),a}return n(o)}function a(o){return pn(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function CNe(e,t,n){const r=this;return i;function i(o){return pn(o)?ln(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):a(o)}function a(o){return e.attempt(Gue,t,n)(o)}}function zNe(e){e.exit("blockQuote")}const Nue={name:"characterEscape",tokenize:ANe};function ANe(e,t,n){return r;function r(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),i}function i(a){return SNe(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const Zue={name:"characterReference",tokenize:UNe};function UNe(e,t,n){const r=this;let i=0,a,o;return s;function s(O){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(O),e.exit("characterReferenceMarker"),l}function l(O){return O===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(O),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),a=31,o=ea,u(O))}function c(O){return O===88||O===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(O),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,o=wNe,u):(e.enter("characterReferenceValue"),a=7,o=Mq,u(O))}function u(O){if(O===59&&i){const d=e.exit("characterReferenceValue");return o===ea&&!wz(r.sliceSerialize(d))?n(O):(e.enter("characterReferenceMarker"),e.consume(O),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(O)&&i++<a?(e.consume(O),u):n(O)}}const xN={partial:!0,tokenize:YNe},QN={concrete:!0,name:"codeFenced",tokenize:WNe};function WNe(e,t,n){const r=this,i={partial:!0,tokenize:b};let a=0,o=0,s;return l;function l(S){return c(S)}function c(S){const Q=r.events[r.events.length-1];return a=Q&&Q[1].type==="linePrefix"?Q[2].sliceSerialize(Q[1],!0).length:0,s=S,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(S)}function u(S){return S===s?(o++,e.consume(S),u):o<3?n(S):(e.exit("codeFencedFenceSequence"),pn(S)?ln(e,O,"whitespace")(S):O(S))}function O(S){return S===null||yt(S)?(e.exit("codeFencedFence"),r.interrupt?t(S):e.check(xN,m,x)(S)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(S))}function d(S){return S===null||yt(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),O(S)):pn(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ln(e,f,"whitespace")(S)):S===96&&S===s?n(S):(e.consume(S),d)}function f(S){return S===null||yt(S)?O(S):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||yt(S)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),O(S)):S===96&&S===s?n(S):(e.consume(S),p)}function m(S){return e.attempt(i,x,g)(S)}function g(S){return e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),$}function $(S){return a>0&&pn(S)?ln(e,v,"linePrefix",a+1)(S):v(S)}function v(S){return S===null||yt(S)?e.check(xN,m,x)(S):(e.enter("codeFlowValue"),w(S))}function w(S){return S===null||yt(S)?(e.exit("codeFlowValue"),v(S)):(e.consume(S),w)}function x(S){return e.exit("codeFenced"),t(S)}function b(S,Q,P){let R=0;return _;function _(N){return S.enter("lineEnding"),S.consume(N),S.exit("lineEnding"),E}function E(N){return S.enter("codeFencedFence"),pn(N)?ln(S,C,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):C(N)}function C(N){return N===s?(S.enter("codeFencedFenceSequence"),z(N)):P(N)}function z(N){return N===s?(R++,S.consume(N),z):R>=o?(S.exit("codeFencedFenceSequence"),pn(N)?ln(S,W,"whitespace")(N):W(N)):P(N)}function W(N){return N===null||yt(N)?(S.exit("codeFencedFence"),Q(N)):P(N)}}}function YNe(e,t,n){const r=this;return i;function i(o){return o===null?n(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)}}const V5={name:"codeIndented",tokenize:NNe},GNe={partial:!0,tokenize:ZNe};function NNe(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),ln(e,a,"linePrefix",5)(c)}function a(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):yt(c)?e.attempt(GNe,o,l)(c):(e.enter("codeFlowValue"),s(c))}function s(c){return c===null||yt(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),s)}function l(c){return e.exit("codeIndented"),t(c)}}function ZNe(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):yt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):ln(e,a,"linePrefix",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):yt(o)?i(o):n(o)}}const INe={name:"codeText",previous:VNe,resolve:DNe,tokenize:MNe};function DNe(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==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",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="codeTextData",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 VNe(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function MNe(e,t,n){let r=0,i,a;return o;function o(O){return e.enter("codeText"),e.enter("codeTextSequence"),s(O)}function s(O){return O===96?(e.consume(O),r++,s):(e.exit("codeTextSequence"),l(O))}function l(O){return O===null?n(O):O===32?(e.enter("space"),e.consume(O),e.exit("space"),l):O===96?(a=e.enter("codeTextSequence"),i=0,u(O)):yt(O)?(e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(O))}function c(O){return O===null||O===32||O===96||yt(O)?(e.exit("codeTextData"),l(O)):(e.consume(O),c)}function u(O){return O===96?(e.consume(O),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(O)):(a.type="codeTextData",c(O))}}class LNe{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Nm(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Nm(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Nm(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Nm(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Nm(this.left,n.reverse())}}}function Nm(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Iue(e){const t={};let n=-1,r,i,a,o,s,l,c;const u=new LNe(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,a=0,a<l.length&&l[a][1].type==="lineEndingBlank"&&(a+=2),a<l.length&&l[a][1].type==="content"))for(;++a<l.length&&l[a][1].type!=="content";)l[a][1].type==="chunkText"&&(l[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,FNe(u,n)),n=t[n],c=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=a);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return $o(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function FNe(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,l=[],c={};let u,O,d=-1,f=n,p=0,m=0;const g=[m];for(;f;){for(;e.get(++i)[1]!==f;);a.push(i),f._tokenizer||(u=r.sliceStream(f),f.next||u.push(null),O&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),O=f,f=f.next}for(f=n;++d<s.length;)s[d][0]==="exit"&&s[d-1][0]==="enter"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(m=d+1,g.push(m),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):g.pop(),d=g.length;d--;){const $=s.slice(g[d],g[d+1]),v=a.pop();l.push([v,v+$.length-1]),e.splice(v,2,$)}for(l.reverse(),d=-1;++d<l.length;)c[p+l[d][0]]=p+l[d][1],p+=l[d][1]-l[d][0]-1;return c}const BNe={resolve:KNe,tokenize:JNe},HNe={partial:!0,tokenize:eZe};function KNe(e){return Iue(e),e}function JNe(e,t){let n;return r;function r(s){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(s)}function i(s){return s===null?a(s):yt(s)?e.check(HNe,o,a)(s):(e.consume(s),i)}function a(s){return e.exit("chunkContent"),e.exit("content"),t(s)}function o(s){return e.consume(s),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function eZe(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ln(e,a,"linePrefix")}function a(o){if(o===null||yt(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Due(e,t,n,r,i,a,o,s,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return O;function O($){return $===60?(e.enter(r),e.enter(i),e.enter(a),e.consume($),e.exit(a),d):$===null||$===32||$===41||Aw($)?n($):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),m($))}function d($){return $===62?(e.enter(a),e.consume($),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),f($))}function f($){return $===62?(e.exit("chunkString"),e.exit(s),d($)):$===null||$===60||yt($)?n($):(e.consume($),$===92?p:f)}function p($){return $===60||$===62||$===92?(e.consume($),f):f($)}function m($){return!u&&($===null||$===41||ir($))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t($)):u<c&&$===40?(e.consume($),u++,m):$===41?(e.consume($),u--,m):$===null||$===32||$===40||Aw($)?n($):(e.consume($),$===92?g:m)}function g($){return $===40||$===41||$===92?(e.consume($),m):m($)}}function Vue(e,t,n,r,i,a){const o=this;let s=0,l;return c;function c(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(a),u}function u(f){return s>999||f===null||f===91||f===93&&!l||f===94&&!s&&"_hiddenFootnoteSupport"in o.parser.constructs?n(f):f===93?(e.exit(a),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):yt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),O(f))}function O(f){return f===null||f===91||f===93||yt(f)||s++>999?(e.exit("chunkString"),u(f)):(e.consume(f),l||(l=!pn(f)),f===92?d:O)}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,O):O(f)}}function Mue(e,t,n,r,i,a){let o;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,l):n(d)}function l(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),c(d))}function c(d){return d===o?(e.exit(a),l(o)):d===null?n(d):yt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),ln(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(d){return d===o||d===null||yt(d)?(e.exit("chunkString"),c(d)):(e.consume(d),d===92?O:u)}function O(d){return d===o||d===92?(e.consume(d),u):u(d)}}function n0(e,t){let n;return r;function r(i){return yt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):pn(i)?ln(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const tZe={name:"definition",tokenize:rZe},nZe={partial:!0,tokenize:iZe};function rZe(e,t,n){const r=this;let i;return a;function a(f){return e.enter("definition"),o(f)}function o(f){return Vue.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function s(f){return i=js(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),l):n(f)}function l(f){return ir(f)?n0(e,c)(f):c(f)}function c(f){return Due(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function u(f){return e.attempt(nZe,O,O)(f)}function O(f){return pn(f)?ln(e,d,"whitespace")(f):d(f)}function d(f){return f===null||yt(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function iZe(e,t,n){return r;function r(s){return ir(s)?n0(e,i)(s):n(s)}function i(s){return Mue(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function a(s){return pn(s)?ln(e,o,"whitespace")(s):o(s)}function o(s){return s===null||yt(s)?t(s):n(s)}}const aZe={name:"hardBreakEscape",tokenize:oZe};function oZe(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return yt(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const sZe={name:"headingAtx",resolve:lZe,tokenize:cZe};function lZe(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$o(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function cZe(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),a(u)}function a(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ir(u)?(e.exit("atxHeadingSequence"),s(u)):n(u)}function s(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||yt(u)?(e.exit("atxHeading"),t(u)):pn(u)?ln(e,s,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),s(u))}function c(u){return u===null||u===35||ir(u)?(e.exit("atxHeadingText"),s(u)):(e.consume(u),c)}}const uZe=["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","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],kN=["pre","script","style","textarea"],OZe={concrete:!0,name:"htmlFlow",resolveTo:hZe,tokenize:pZe},dZe={partial:!0,tokenize:gZe},fZe={partial:!0,tokenize:mZe};function hZe(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function pZe(e,t,n){const r=this;let i,a,o,s,l;return c;function c(U){return u(U)}function u(U){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(U),O}function O(U){return U===33?(e.consume(U),d):U===47?(e.consume(U),a=!0,m):U===63?(e.consume(U),i=3,r.interrupt?t:A):pa(U)?(e.consume(U),o=String.fromCharCode(U),g):n(U)}function d(U){return U===45?(e.consume(U),i=2,f):U===91?(e.consume(U),i=5,s=0,p):pa(U)?(e.consume(U),i=4,r.interrupt?t:A):n(U)}function f(U){return U===45?(e.consume(U),r.interrupt?t:A):n(U)}function p(U){const le="CDATA[";return U===le.charCodeAt(s++)?(e.consume(U),s===le.length?r.interrupt?t:C:p):n(U)}function m(U){return pa(U)?(e.consume(U),o=String.fromCharCode(U),g):n(U)}function g(U){if(U===null||U===47||U===62||ir(U)){const le=U===47,F=o.toLowerCase();return!le&&!a&&kN.includes(F)?(i=1,r.interrupt?t(U):C(U)):uZe.includes(o.toLowerCase())?(i=6,le?(e.consume(U),$):r.interrupt?t(U):C(U)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(U):a?v(U):w(U))}return U===45||ea(U)?(e.consume(U),o+=String.fromCharCode(U),g):n(U)}function $(U){return U===62?(e.consume(U),r.interrupt?t:C):n(U)}function v(U){return pn(U)?(e.consume(U),v):_(U)}function w(U){return U===47?(e.consume(U),_):U===58||U===95||pa(U)?(e.consume(U),x):pn(U)?(e.consume(U),w):_(U)}function x(U){return U===45||U===46||U===58||U===95||ea(U)?(e.consume(U),x):b(U)}function b(U){return U===61?(e.consume(U),S):pn(U)?(e.consume(U),b):w(U)}function S(U){return U===null||U===60||U===61||U===62||U===96?n(U):U===34||U===39?(e.consume(U),l=U,Q):pn(U)?(e.consume(U),S):P(U)}function Q(U){return U===l?(e.consume(U),l=null,R):U===null||yt(U)?n(U):(e.consume(U),Q)}function P(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||ir(U)?b(U):(e.consume(U),P)}function R(U){return U===47||U===62||pn(U)?w(U):n(U)}function _(U){return U===62?(e.consume(U),E):n(U)}function E(U){return U===null||yt(U)?C(U):pn(U)?(e.consume(U),E):n(U)}function C(U){return U===45&&i===2?(e.consume(U),D):U===60&&i===1?(e.consume(U),M):U===62&&i===4?(e.consume(U),J):U===63&&i===3?(e.consume(U),A):U===93&&i===5?(e.consume(U),Y):yt(U)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(dZe,K,z)(U)):U===null||yt(U)?(e.exit("htmlFlowData"),z(U)):(e.consume(U),C)}function z(U){return e.check(fZe,W,K)(U)}function W(U){return e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),N}function N(U){return U===null||yt(U)?z(U):(e.enter("htmlFlowData"),C(U))}function D(U){return U===45?(e.consume(U),A):C(U)}function M(U){return U===47?(e.consume(U),o="",B):C(U)}function B(U){if(U===62){const le=o.toLowerCase();return kN.includes(le)?(e.consume(U),J):C(U)}return pa(U)&&o.length<8?(e.consume(U),o+=String.fromCharCode(U),B):C(U)}function Y(U){return U===93?(e.consume(U),A):C(U)}function A(U){return U===62?(e.consume(U),J):U===45&&i===2?(e.consume(U),A):C(U)}function J(U){return U===null||yt(U)?(e.exit("htmlFlowData"),K(U)):(e.consume(U),J)}function K(U){return e.exit("htmlFlow"),t(U)}}function mZe(e,t,n){const r=this;return i;function i(o){return yt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function gZe(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ry,t,n)}}const $Ze={name:"htmlText",tokenize:yZe};function yZe(e,t,n){const r=this;let i,a,o;return s;function s(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),l}function l(A){return A===33?(e.consume(A),c):A===47?(e.consume(A),b):A===63?(e.consume(A),w):pa(A)?(e.consume(A),P):n(A)}function c(A){return A===45?(e.consume(A),u):A===91?(e.consume(A),a=0,p):pa(A)?(e.consume(A),v):n(A)}function u(A){return A===45?(e.consume(A),f):n(A)}function O(A){return A===null?n(A):A===45?(e.consume(A),d):yt(A)?(o=O,M(A)):(e.consume(A),O)}function d(A){return A===45?(e.consume(A),f):O(A)}function f(A){return A===62?D(A):A===45?d(A):O(A)}function p(A){const J="CDATA[";return A===J.charCodeAt(a++)?(e.consume(A),a===J.length?m:p):n(A)}function m(A){return A===null?n(A):A===93?(e.consume(A),g):yt(A)?(o=m,M(A)):(e.consume(A),m)}function g(A){return A===93?(e.consume(A),$):m(A)}function $(A){return A===62?D(A):A===93?(e.consume(A),$):m(A)}function v(A){return A===null||A===62?D(A):yt(A)?(o=v,M(A)):(e.consume(A),v)}function w(A){return A===null?n(A):A===63?(e.consume(A),x):yt(A)?(o=w,M(A)):(e.consume(A),w)}function x(A){return A===62?D(A):w(A)}function b(A){return pa(A)?(e.consume(A),S):n(A)}function S(A){return A===45||ea(A)?(e.consume(A),S):Q(A)}function Q(A){return yt(A)?(o=Q,M(A)):pn(A)?(e.consume(A),Q):D(A)}function P(A){return A===45||ea(A)?(e.consume(A),P):A===47||A===62||ir(A)?R(A):n(A)}function R(A){return A===47?(e.consume(A),D):A===58||A===95||pa(A)?(e.consume(A),_):yt(A)?(o=R,M(A)):pn(A)?(e.consume(A),R):D(A)}function _(A){return A===45||A===46||A===58||A===95||ea(A)?(e.consume(A),_):E(A)}function E(A){return A===61?(e.consume(A),C):yt(A)?(o=E,M(A)):pn(A)?(e.consume(A),E):R(A)}function C(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),i=A,z):yt(A)?(o=C,M(A)):pn(A)?(e.consume(A),C):(e.consume(A),W)}function z(A){return A===i?(e.consume(A),i=void 0,N):A===null?n(A):yt(A)?(o=z,M(A)):(e.consume(A),z)}function W(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||ir(A)?R(A):(e.consume(A),W)}function N(A){return A===47||A===62||ir(A)?R(A):n(A)}function D(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function M(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),B}function B(A){return pn(A)?ln(e,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):Y(A)}function Y(A){return e.enter("htmlTextData"),o(A)}}const Sz={name:"labelEnd",resolveAll:SZe,resolveTo:xZe,tokenize:QZe},vZe={tokenize:kZe},bZe={tokenize:PZe},wZe={tokenize:TZe};function SZe(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&$o(e,0,e.length,n),e}function xZe(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(a=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[a][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=Wo(s,e.slice(a+1,a+r+3)),s=Wo(s,[["enter",u,t]]),s=Wo(s,kQ(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Wo(s,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),s=Wo(s,e.slice(o+1)),s=Wo(s,[["exit",l,t]]),$o(e,a,e.length,s),e}function QZe(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(d){return a?a._inactive?O(d):(o=r.parser.defined.includes(js(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),l):n(d)}function l(d){return d===40?e.attempt(vZe,u,o?u:O)(d):d===91?e.attempt(bZe,u,o?c:O)(d):o?u(d):O(d)}function c(d){return e.attempt(wZe,u,O)(d)}function u(d){return t(d)}function O(d){return a._balanced=!0,n(d)}}function kZe(e,t,n){return r;function r(O){return e.enter("resource"),e.enter("resourceMarker"),e.consume(O),e.exit("resourceMarker"),i}function i(O){return ir(O)?n0(e,a)(O):a(O)}function a(O){return O===41?u(O):Due(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(O)}function o(O){return ir(O)?n0(e,l)(O):u(O)}function s(O){return n(O)}function l(O){return O===34||O===39||O===40?Mue(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(O):u(O)}function c(O){return ir(O)?n0(e,u)(O):u(O)}function u(O){return O===41?(e.enter("resourceMarker"),e.consume(O),e.exit("resourceMarker"),e.exit("resource"),t):n(O)}}function PZe(e,t,n){const r=this;return i;function i(s){return Vue.call(r,e,a,o,"reference","referenceMarker","referenceString")(s)}function a(s){return r.parser.defined.includes(js(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function TZe(e,t,n){return r;function r(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),i}function i(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const _Ze={name:"labelStartImage",resolveAll:Sz.resolveAll,tokenize:XZe};function XZe(e,t,n){const r=this;return i;function i(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),a}function a(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),o):n(s)}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}const RZe={name:"labelStartLink",resolveAll:Sz.resolveAll,tokenize:EZe};function EZe(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),a}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const M5={name:"lineEnding",tokenize:qZe};function qZe(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ln(e,t,"linePrefix")}}const R1={name:"thematicBreak",tokenize:jZe};function jZe(e,t,n){let r=0,i;return a;function a(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,s(c)}function s(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||yt(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),pn(c)?ln(e,s,"whitespace")(c):s(c))}}const ka={continuation:{tokenize:UZe},exit:YZe,name:"list",tokenize:AZe},CZe={partial:!0,tokenize:GZe},zZe={partial:!0,tokenize:WZe};function AZe(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(f){const p=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:Mq(f)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(R1,n,c)(f):c(f);if(!r.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(f)}return n(f)}function l(f){return Mq(f)&&++o<10?(e.consume(f),l):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),c(f)):n(f)}function c(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,e.check(Ry,r.interrupt?n:u,e.attempt(CZe,d,O))}function u(f){return r.containerState.initialBlankLine=!0,a++,d(f)}function O(f){return pn(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),d):n(f)}function d(f){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function UZe(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ry,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ln(e,t,"listItemIndent",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!pn(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(zZe,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,ln(e,e.attempt(ka,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function WZe(e,t,n){const r=this;return ln(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function YZe(e){e.exit(this.containerState.type)}function GZe(e,t,n){const r=this;return ln(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!pn(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const PN={name:"setextUnderline",resolveTo:NZe,tokenize:ZZe};function NZe(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function ZZe(e,t,n){const r=this;let i;return a;function a(c){let u=r.events.length,O;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){O=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||O)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===i?(e.consume(c),s):(e.exit("setextHeadingLineSequence"),pn(c)?ln(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||yt(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const IZe={tokenize:DZe};function DZe(e){const t=this,n=e.attempt(Ry,r,e.attempt(this.parser.constructs.flowInitial,i,ln(e,e.attempt(this.parser.constructs.flow,i,e.attempt(BNe,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const VZe={resolveAll:Fue()},MZe=Lue("string"),LZe=Lue("text");function Lue(e){return{resolveAll:Fue(e==="text"?FZe:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(u){return c(u)?a(u):s(u)}function s(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),a(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const O=i[u];let d=-1;if(O)for(;++d<O.length;){const f=O[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Fue(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type==="data"&&(a=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function FZe(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,l;for(;a--;){const c=i[a];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(c===-2)l=!0,s++;else if(c!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const c={type:n===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const BZe={42:ka,43:ka,45:ka,48:ka,49:ka,50:ka,51:ka,52:ka,53:ka,54:ka,55:ka,56:ka,57:ka,62:Gue},HZe={91:tZe},KZe={[-2]:V5,[-1]:V5,32:V5},JZe={35:sZe,42:R1,45:[PN,R1],60:OZe,61:PN,95:R1,96:QN,126:QN},eIe={38:Zue,92:Nue},tIe={[-5]:M5,[-4]:M5,[-3]:M5,33:_Ze,38:Zue,42:Lq,60:[RNe,$Ze],91:RZe,92:[aZe,Nue],93:Sz,95:Lq,96:INe},nIe={null:[Lq,VZe]},rIe={null:[42,95]},iIe={null:[]},aIe=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:rIe,contentInitial:HZe,disable:iIe,document:BZe,flow:JZe,flowInitial:KZe,insideSpan:nIe,string:eIe,text:tIe},Symbol.toStringTag,{value:"Module"}));function oIe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const l={attempt:Q(b),check:Q(S),consume:v,enter:w,exit:x,interrupt:Q(S,{interrupt:!0})},c={code:null,containerState:{},defineSkip:m,events:[],now:p,parser:e,previous:null,sliceSerialize:d,sliceStream:f,write:O};let u=t.tokenize.call(c,l);return t.resolveAll&&a.push(t),c;function O(E){return o=Wo(o,E),g(),o[o.length-1]!==null?[]:(P(t,0),c.events=kQ(a,c.events,c),c.events)}function d(E,C){return lIe(f(E),C)}function f(E){return sIe(o,E)}function p(){const{_bufferIndex:E,_index:C,line:z,column:W,offset:N}=r;return{_bufferIndex:E,_index:C,line:z,column:W,offset:N}}function m(E){i[E.line]=E.column,_()}function g(){let E;for(;r._index<o.length;){const C=o[r._index];if(typeof C=="string")for(E=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===E&&r._bufferIndex<C.length;)$(C.charCodeAt(r._bufferIndex));else $(C)}}function $(E){u=u(E)}function v(E){yt(E)?(r.line++,r.column=1,r.offset+=E===-3?2:1,_()):E!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=E}function w(E,C){const z=C||{};return z.type=E,z.start=p(),c.events.push(["enter",z,c]),s.push(z),z}function x(E){const C=s.pop();return C.end=p(),c.events.push(["exit",C,c]),C}function b(E,C){P(E,C.from)}function S(E,C){C.restore()}function Q(E,C){return z;function z(W,N,D){let M,B,Y,A;return Array.isArray(W)?K(W):"tokenize"in W?K([W]):J(W);function J(Z){return ne;function ne(H){const re=H!==null&&Z[H],he=H!==null&&Z.null,we=[...Array.isArray(re)?re:re?[re]:[],...Array.isArray(he)?he:he?[he]:[]];return K(we)(H)}}function K(Z){return M=Z,B=0,Z.length===0?D:U(Z[B])}function U(Z){return ne;function ne(H){return A=R(),Y=Z,Z.partial||(c.currentConstruct=Z),Z.name&&c.parser.constructs.disable.null.includes(Z.name)?F():Z.tokenize.call(C?Object.assign(Object.create(c),C):c,l,le,F)(H)}}function le(Z){return E(Y,A),N}function F(Z){return A.restore(),++B<M.length?U(M[B]):D}}}function P(E,C){E.resolveAll&&!a.includes(E)&&a.push(E),E.resolve&&$o(c.events,C,c.events.length-C,E.resolve(c.events.slice(C),c)),E.resolveTo&&(c.events=E.resolveTo(c.events,c))}function R(){const E=p(),C=c.previous,z=c.currentConstruct,W=c.events.length,N=Array.from(s);return{from:W,restore:D};function D(){r=E,c.previous=C,c.currentConstruct=z,c.events.length=W,s=N,_()}}function _(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function sIe(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const s=o[0];typeof s=="string"?o[0]=s.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function lIe(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a=="string")o=a;else switch(a){case-5:{o="\r";break}case-4:{o=`
492
+ ${n}`:""}`}function nu(){const[e,t]=y.useState(!1),[n,r]=y.useState(null);return{perform:y.useCallback(async(a,o,s,l)=>{t(!0),r(null);try{const c=await a();return r(o(c)),c}catch(c){return r({tone:"error",text:NYe(s,Xr(c),l)}),null}finally{t(!1)}},[]),busy:e,result:n,setResult:r}}const ZYe={signal:"stroke-info",label:"stroke-warning",danger:"stroke-danger"},bs=14,Gq=1.75,Nq=bs/2-Gq/2,aN=2*Math.PI*Nq,IYe=.06,DYe=({reading:e,className:t})=>{const n=e.fraction,r=n!==null&&n>0,i=r?Math.max(n,IYe):0;return h.jsxs("svg",{width:bs,height:bs,viewBox:`0 0 ${bs} ${bs}`,className:q("shrink-0",t),"aria-hidden":"true",focusable:"false",children:[h.jsx("circle",{cx:bs/2,cy:bs/2,r:Nq,fill:"none",strokeWidth:Gq,className:q(r?"stroke-sunken":"stroke-hairline")}),r&&h.jsx("circle",{cx:bs/2,cy:bs/2,r:Nq,fill:"none",strokeWidth:Gq,strokeLinecap:"round",strokeDasharray:aN,strokeDashoffset:aN*(1-i),transform:`rotate(-90 ${bs/2} ${bs/2})`,className:q(ZYe[e.rung])})]})},VYe=0x7ffn,MYe=0xfffffffffffffn,LYe=1075,FYe=-1074;function BYe(e){const t=new DataView(new ArrayBuffer(8));t.setFloat64(0,e);const n=BigInt(t.getUint32(0))<<32n|BigInt(t.getUint32(4)),r=(n>>63n&1n)===1n,i=Number(n>>52n&VYe),a=n&MYe,o=i===0?a:a|1n<<52n,s=i===0?FYe:i-LYe;return s>=0?{negative:r,num:o<<BigInt(s),scale:0}:{negative:r,num:o*5n**BigInt(-s),scale:-s}}function oN(e,t){let n=e.toString();if(t===0)return n;for(;n.length<=t;)n=`0${n}`;return`${n.slice(0,n.length-t)}.${n.slice(n.length-t)}`}function gl(e,t){if(!Number.isFinite(e))return"";const{negative:n,num:r,scale:i}=BYe(e);if(t>=i)return(n?"-":"")+oN(r*10n**BigInt(t-i),t);const a=10n**BigInt(i-t),o=r/a,s=r%a,l=a/2n,c=s>l||s===l&&(o&1n)===1n?o+1n:o;return(n?"-":"")+oN(c,t)}const sN=["danger","label","signal"],due="signal",HYe=[[5e5,"danger"],[2e5,"label"]],KYe=[[.8,"danger"],[.55,"label"]];function JYe(e,t=0){let n=due;for(const[r,i]of HYe)if(e>r){n=i;break}if(t>0){for(const[r,i]of KYe)if(e>t*r){sN.indexOf(i)<sN.indexOf(n)&&(n=i);break}}return n}function fue(e){return e>=1e6?`${gl(e/1e6,1)}m`:e>=1e3?`${gl(e/1e3,1)}k`:String(e)}function zw(e){if(e>=1e6){const t=e/1e6;return t===Math.trunc(t)?`${gl(t,0)}M`:`${gl(t,1)}M`}if(e>=1e3){const t=e/1e3;return t===Math.trunc(t)?`${gl(t,0)}k`:`${gl(t,1)}k`}return String(e)}function lN(e,t){if(e<=0)return"";if(t<=0)return`${fue(e)}/—`;const n=e/t*100;return n<.05?`<0.1%/${zw(t)}`:`${gl(n,1)}%/${zw(t)}`}function eGe(e){const t=e.context_tokens,n=typeof t=="number"&&Number.isFinite(t)&&t>0?t:null,r=e.context_window,i=typeof r=="number"&&Number.isFinite(r)&&r>0?r:null,a=JYe(n??0,i??0);return n===null?{status:"no-reading",tokens:null,window:i,fraction:null,rung:due,spelling:""}:i===null?{status:"window-unknown",tokens:n,window:null,fraction:null,rung:a,spelling:lN(n,0)}:{status:e.context_is_estimate?"estimate":"measured",tokens:n,window:i,fraction:Math.min(n/i,1),rung:a,spelling:lN(n,i)}}function tGe(e,t){if(e.status==="no-reading")return["Context","No reading yet. The first turn reports what the request carried."];const n=[];if(e.status==="window-unknown")return n.push(e.spelling),n.push(`${fue(e.tokens??0)} tokens in use. The window this model allows is not known, so there is no percentage to show.`),n;const r=e.tokens??0,i=e.window??0;return n.push(e.spelling),n.push(`${r.toLocaleString()} of ${i.toLocaleString()} tokens (${zw(i)} window)`),typeof t=="number"&&t>0&&t!==i&&n.push(`Model maximum: ${zw(t)}`),e.status==="estimate"&&n.push("estimate - counted by the app, not reported by the provider yet"),n}const nGe="≥",hue="$—";function pue(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function rGe(e){if(e.subagent_cost_knowledge!=null)return pue(e.subagent_cost);const t=e.child_costs;if(!t)return null;const n=Object.values(t).filter(r=>typeof r=="number"&&Number.isFinite(r));return n.length>0?n.reduce((r,i)=>r+i,0):null}function iGe(e){return e==="floor"||e==="partial"}function aGe(e){return e==="exact"||e==="partial"||e==="floor"?e:"unknown"}function Zq(e){return e<.01?`$${gl(e,4)}`:e<1?`$${gl(e,3)}`:`$${gl(e,2)}`}function oGe(e){const t=aGe(e.cost_knowledge);if(t==="partial"||t==="floor")return t;const n=e.subagent_cost_knowledge;return n==="partial"||n==="unknown"&&e.child_costs&&Object.keys(e.child_costs).length>0?"partial":t}function sGe(e,t){const n=pue(e.cumulative_parent_cost),r=rGe(e),i=oGe(e),a=iGe(i),o=n===null&&r===null?null:(n??0)+(r??0);if(o===null){const s=!!(t&&((t.input_tokens??0)||(t.output_tokens??0)));return{total:null,knowledge:i,isFloor:a,text:s?hue:""}}return o?{total:o,knowledge:i,isFloor:a,text:`${a?nGe:""}${Zq(o)}`}:{total:o,knowledge:i,isFloor:a,text:""}}function cN(e){if(e.total===null)return e.text===hue?"This session billed tokens on a model with no published price, so the spend cannot be calculated.":"Nothing has been spent in this session yet.";if(!e.total)return"Nothing has been spent in this session yet.";const t=`Session spend so far: ${Zq(e.total)}.`;return e.isFloor?`Session spend is at least ${Zq(e.total)}. Part of this conversation ran before the app was tracking it, or a subagent's spend is not fully known.`:t}const Uv=60,Wv=3600,G5=86400;function N5(e){const t=Math.trunc(Number.isFinite(e)&&e>0?e:0);if(t<Uv)return`${t}s`;if(t<Wv){const i=Math.trunc(t/Uv),a=t%Uv;return a?`${i}m${a}s`:`${i}m`}if(t<G5){const i=Math.trunc(t/Wv),a=Math.trunc(t%Wv/Uv);return a?`${i}h${a}m`:`${i}h`}const n=Math.trunc(t/G5);if(n>99)return"100d+";const r=Math.trunc(t%G5/Wv);return r?`${n}d${r}h`:`${n}d`}function lGe(e,t){const n=typeof e=="number"&&Number.isFinite(e)?Math.max(0,e):0,r=typeof t=="number"&&Number.isFinite(t)?t:null;return n<=0&&r===null?null:{banked:n,startedAt:r===null?null:r*1e3}}const cGe="Time the agent has spent working in this conversation. Time waiting between turns is not counted.",uGe="Time spent working; waiting is not counted.",mue="inline-flex h-6 min-w-0 shrink-0 items-center gap-1.5 rounded-sm px-1.5 text-meta",al=q(mue,"cursor-pointer text-ink-muted transition-colors duration-fast ease-out-quart","hover:bg-accent-wash hover:text-ink","focus-visible:outline-offset-1!"),Iq=q(mue,"cursor-default text-ink-dim"),OGe={cumulative_parent_cost:null,child_costs:null,subagent_cost:null,subagent_cost_knowledge:null,cost_knowledge:"unknown"},dGe=1e3;function fGe(e,t){const n=()=>t===null?e:e+Math.max(0,(Date.now()-t)/1e3),[r,i]=y.useState(n);return y.useEffect(()=>{if(t===null){i(e);return}const a=()=>i(e+Math.max(0,(Date.now()-t)/1e3));a();const o=window.setInterval(a,dGe);return()=>window.clearInterval(o)},[e,t]),r}const gue="Last reading from before the reconnect.",hGe="Readings dropped when the connection was lost.",pGe="Fast mode on",WO=({tooltip:e,label:t,onOpen:n,readout:r=!1,held:i=!1,children:a,className:o})=>{const s=t,l=i?h.jsxs("span",{className:"flex flex-col gap-0.5",children:[e,h.jsx("span",{className:"text-ink-muted",children:gue})]}):e;return n?h.jsx(Nt,{content:l,children:h.jsx("button",{type:"button",onClick:n,"aria-label":s,className:q(al,o),children:a})}):r?h.jsx(Nt,{content:l,children:h.jsx("span",{tabIndex:0,"aria-label":s,className:q(Iq,o),children:a})}):h.jsx(Nt,{content:l,children:h.jsx("button",{type:"button","aria-disabled":"true","aria-label":s,className:q(Iq,o),children:a})})},YO=({lines:e,mono:t=!0})=>h.jsx("span",{className:"flex flex-col gap-0.5",children:e.map((n,r)=>h.jsx("span",{className:q(r===0?"text-ink":"text-ink-muted",t&&r===0&&e.length>1&&"font-mono text-mono-sm"),children:n},n))});function Z5(e,t,n=!1){return t?n?e==="measured"||e==="estimate"?"Click for the full breakdown, which estimates your next request.":"Click for the full breakdown.":e==="measured"?"Measured now; click for the full breakdown, which estimates your next request":e==="estimate"?"Estimated now; click for the full breakdown, which estimates your next request":"Click for the full breakdown":pz}const pz="Slash commands are off on this server, so this reading cannot be opened from here.";function uN(e,t){return t?e?"Click to choose a different model. It applies to this conversation.":"Click to choose a different model":e?"This conversation will use it. Change it once the conversation starts.":pz}function mGe(e,t,n){return t?n?e?"Change it. It applies to this conversation.":"Change it.":e?$ue:pz:null}const gGe="Nothing measured yet. The window fills as the conversation runs.",$Ge=["Context",gGe],yGe="Context: nothing measured yet. The window fills as the conversation runs.",$ue="Set once the conversation starts.",vGe=({frontend:e,onCommand:t,effortEntities:n,pendingModel:r=null,draft:i=!1,held:a=!1,onOpenDraftPicker:o,draftResolution:s,readingsDropped:l=!1,controlsThirdBox:c=!1,className:u})=>{if(!e&&!(i&&s))return l&&!i?h.jsx("p",{"data-lo-readings-dropped":!0,role:"status",className:q("order-2 -mx-1.5 min-w-0 text-meta text-ink-dim",u),children:hGe}):null;const O=i?void 0:t,d=i?o:void 0,f=r!==null,p=sQ(e,r),m=p.identity,g=f4e(m),$=v6(m)==="on",v=m4e(p4e(p.effort),n),w=eGe({context_tokens:e?.context_tokens,context_window:e?.context_window,context_is_estimate:e?.context_is_estimate}),x=sGe(e??OGe,e?.last_usage),b=lGe(e?.active_duration_s??0,e?.activity_started_at??null),S=fGe(b?.banked??0,b?.startedAt??null),Q=O?()=>O({name:"model",args:""}):d?()=>d("session.model"):void 0,P=v?.adjustable&&O?()=>O({name:"effort",args:""}):v?.adjustable&&v.knownLadder&&d?()=>d("session.effort"):void 0,R=!g&&!!d&&!s;return!g&&!v&&w.status==="no-reading"&&!x.text&&!R&&!s?null:h.jsxs("div",{className:q("-mx-1.5 flex min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5","order-2 flex-nowrap",u),"data-lo-session-strip":!0,"data-lo-session-strip-draft":i?!0:void 0,"data-lo-session-strip-held":a?!0:void 0,role:"group","aria-label":a?`Session readings. ${gue}`:void 0,children:[a&&h.jsx("span",{className:"shrink-0 text-meta text-ink-dim @max-[750px]/chatcol:hidden",children:"Last reading"}),g&&h.jsxs(WO,{label:f?`Model: ${g.selector}${$?", fast mode on":""}. Switching; waiting for the session to confirm it.`:`Model: ${g.selector}${$?", fast mode on":""}. ${uN(i,!!Q)}`,tooltip:h.jsx(YO,{lines:f?[g.selector,"Switching the model; waiting for the session to confirm it"]:[g.selector,...$?[pGe]:[],uN(i,!!Q)]}),onOpen:Q,held:a,className:q("min-w-14 max-w-full shrink",f&&"text-ink-dim"),children:[$&&h.jsx(Z7e,{"aria-hidden":"true",className:"size-3.5 shrink-0",fill:"currentColor",stroke:"none"}),h.jsx("span",{className:"truncate",children:g.name}),f&&h.jsx(ts,{size:"xs",label:"Switching the model"})]}),R&&h.jsx(WO,{label:"Model: none resolved yet. Choose the model this conversation will run on.",tooltip:h.jsx(YO,{lines:["No model resolved yet","Choose the model this conversation will run on"]}),onOpen:Q,className:"shrink-0",children:h.jsx("span",{className:"truncate",children:"Choose a model"})}),s&&!g&&h.jsxs(WO,{label:s.status==="failed"?"Model: this conversation's model was not resolved. Retry.":"Model: resolving the model this conversation will run on.",tooltip:h.jsx(YO,{lines:s.status==="failed"?["This conversation's model was not resolved","No model is set for it yet","Retry"]:["Resolving","Working out which model this conversation will run on"]}),onOpen:s.status==="failed"?s.retry:void 0,className:q("shrink-0",s.status==="pending"&&"text-ink-dim"),children:[h.jsx("span",{className:"truncate",children:s.status==="failed"?"Retry":"Resolving the model"}),s.status==="pending"&&h.jsx(ts,{size:"xs",label:"Resolving the model this conversation will run on"})]}),v&&(!i||v.levelKnown)&&h.jsx(WO,{label:[`Reasoning effort: ${Ah(v.label)}.`,mGe(i,v.adjustable,!!P)].filter(Boolean).join(" "),tooltip:h.jsx(YO,{lines:[Ah(v.label),...i&&v.adjustable&&!P?[$ue]:[v.detail]]}),onOpen:P,held:a,className:c?"@max-[780px]/chatcol:hidden":"@max-[750px]/chatcol:hidden",children:h.jsx("span",{className:"font-mono text-mono-sm",children:Ah(v.label)})}),h.jsxs(WO,{label:i?yGe:w.status==="no-reading"?`Context: no reading yet. ${Z5("no-reading",!!O,a)}`:`Context: ${w.spelling}${w.status==="estimate"?", estimated":""}. ${Z5(w.status,!!O,a)}`,tooltip:h.jsx(YO,{mono:w.status!=="no-reading",lines:i?$Ge:[...tGe(w,typeof m?.max_context_window=="number"?m.max_context_window:null),Z5(w.status,!!O,a)]}),onOpen:O?()=>O({name:"context",args:""}):void 0,held:a,className:c?"@max-[675px]/chatcol:hidden":"@max-[640px]/chatcol:hidden",children:[h.jsx(DYe,{reading:w}),w.spelling&&h.jsxs("span",{className:"font-mono text-mono-sm",children:[w.spelling,w.status==="estimate"&&h.jsx("span",{className:"ml-1 text-ink-dim",children:"estimate"})]})]}),x.text&&h.jsx(WO,{label:cN(x),tooltip:h.jsx(YO,{lines:[x.text,cN(x)]}),readout:!0,held:a,className:c?"@max-[740px]/chatcol:hidden":"@max-[705px]/chatcol:hidden",children:h.jsx("span",{className:"font-mono text-mono-sm",children:x.text})}),b&&h.jsx(WO,{label:`Active time: ${N5(S)}. ${uGe}`,tooltip:h.jsx(YO,{lines:[N5(S),cGe]}),readout:!0,held:a,className:c?"hidden":"@max-[860px]/chatcol:hidden",children:h.jsx("span",{className:"font-mono text-mono-sm tabular-nums",children:N5(S)})})]})},Ju=Yi()(e=>({open:!1,focusGroup:null,providerId:null,openConnect:t=>e({open:!0,focusGroup:t?.group??null,providerId:t?.providerId??null}),closeConnect:()=>e({open:!1,focusGroup:null,providerId:null})})),yue=/No model provider is configured yet/,vue=500,bue=3,bGe=6e4,wGe=5,SGe=5e3,xGe=1e3,QGe=e=>typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.min(e,SGe)):xGe,kGe=e=>Math.min(bGe,vue*2**(e-bue+1)),PGe=2e3,TGe=6e4,_Ge=e=>e instanceof Yt&&e.code===_2e,XGe=e=>e instanceof Yt&&e.code===T2e,RGe=(e,t,n)=>n?ud(e,t,n):e;function EGe(e,t,n){const r=e?.attention,i=e?.session_id,a=cr(l=>l.sessions.find(c=>c.session_id===i)?.attention),o=RGe(r,a,i),s=y.useRef({subject:o,streaming:e?.streaming===!0,ready:t});s.current={subject:o,streaming:e?.streaming===!0,ready:t},y.useEffect(()=>{if(!i||!o?.unseen)return;const l=cr.getState().applyAttention,c=cr.getState().publishReadAckNotice,u=cr.getState().clearReadAckNotice;let O=o.completion_token,d=!1,f=!1,p=!1,m=0,g=0,$=0,v=!1,w=cr.getState().readAckRearm?.revision??0;const x=E=>{if(m+=1,m>=bue){if($=Date.now()+kGe(m),v)return;v=!0,console.warn(`[attention] ${i} receipt unresolved after ${m} attempts; backing off`,E),c(i,"unsettled",E);return}c(i,"pending")};let b=0;const S=()=>{b&&(clearInterval(b),b=0)},Q=()=>{if(d||f||p)return;const E=cr.getState().readAckRearm;if(E&&E.sessionId===i&&E.revision!==w&&(w=E.revision,m=0,g=0,$=0,v=!1),!s.current.ready||s.current.streaming)return;const C=s.current.subject;if(C?.supported!==!0||C.conversation_id!==`session/${i}`)return;const z=C.completion_token,W=C.anchor_id;if(!z||!W||(z!==O&&(O=z,m=0,g=0,$=0,v=!1),cr.getState().activeSessionId!==i)||document.visibilityState!=="visible"||!document.hasFocus()||Date.now()<$)return;const N=n.current?.querySelector(`[data-completion-anchor="${CSS.escape(W)}"][data-completion-complete="true"]`);if(!N){c(i,"offscreen");return}const D=N.getBoundingClientRect(),M=D.bottom-2;if(D.width<=0||D.height<=0||M<0||M>=innerHeight){c(i,"offscreen");return}const B=Y=>{if(Y<0||Y>=innerWidth)return!0;const A=document.elementFromPoint(Y,M);return!A||!N.contains(A)};[.25,.5,.75].every(Y=>B(D.left+D.width*Y))||(f=!0,Se({op:"sessions.seen",sessionId:i,completionToken:z}).then(Y=>{if(!d){if(!E2e(Y,i,z)){x("answer did not settle the rendered completion");return}p=!0,S(),u(i),l(i,Y)}}).catch(Y=>{if(!d){if(_Ge(Y)&&g<wGe){g+=1,$=Date.now()+QGe(Y.retryAfterMs),c(i,"pending");return}if(XGe(Y)){S(),u(i);return}if(D2e(Y)){$=Date.now()+PGe;return}if(I2e(Y)){$=Date.now()+TGe,c(i,"remote",Y);return}x(Y)}}).finally(()=>{f=!1}))},P=requestAnimationFrame(Q);b=window.setInterval(Q,vue);const R=()=>{$=0,Q()},_=()=>{document.visibilityState==="visible"&&R()};return window.addEventListener("focus",R),document.addEventListener("visibilitychange",_),()=>{d=!0,cancelAnimationFrame(P),S(),window.removeEventListener("focus",R),document.removeEventListener("visibilitychange",_),u(i)}},[i,o?.completion_token,o?.unseen,n])}function lrn(){}function ON(e){const t=[],n=String(e||"");let r=n.indexOf(","),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);const o=n.slice(i,r).trim();(o||!a)&&t.push(o),i=r+1,r=n.indexOf(",",i)}return t}function qGe(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const jGe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,CGe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zGe={};function dN(e,t){return(zGe.jsx?CGe:jGe).test(e)}const AGe=/[ \t\n\f\r]/g;function UGe(e){return typeof e=="object"?e.type==="text"?fN(e.value):!1:fN(e)}function fN(e){return e.replace(AGe,"")===""}let Xy=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Xy.prototype.normal={};Xy.prototype.property={};Xy.prototype.space=void 0;function wue(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Xy(n,r,t)}function i$(e){return e.toLowerCase()}class Na{constructor(t,n){this.attribute=n,this.property=t}}Na.prototype.attribute="";Na.prototype.booleanish=!1;Na.prototype.boolean=!1;Na.prototype.commaOrSpaceSeparated=!1;Na.prototype.commaSeparated=!1;Na.prototype.defined=!1;Na.prototype.mustUseProperty=!1;Na.prototype.number=!1;Na.prototype.overloadedBoolean=!1;Na.prototype.property="";Na.prototype.spaceSeparated=!1;Na.prototype.space=void 0;let WGe=0;const Bt=gf(),Lr=gf(),Sue=gf(),Ue=gf(),sr=gf(),Wh=gf(),to=gf();function gf(){return 2**++WGe}const Dq=Object.freeze(Object.defineProperty({__proto__:null,boolean:Bt,booleanish:Lr,commaOrSpaceSeparated:to,commaSeparated:Wh,number:Ue,overloadedBoolean:Sue,spaceSeparated:sr},Symbol.toStringTag,{value:"Module"})),I5=Object.keys(Dq);class mz extends Na{constructor(t,n,r,i){let a=-1;if(super(t,n),hN(this,"space",i),typeof r=="number")for(;++a<I5.length;){const o=I5[a];hN(this,I5[a],(r&Dq[o])===Dq[o])}}}mz.prototype.defined=!0;function hN(e,t,n){n&&(e[t]=n)}function om(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const a=new mz(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[i$(r)]=r,n[i$(a.attribute)]=r}return new Xy(t,n,e.space)}const xue=om({properties:{ariaActiveDescendant:null,ariaAtomic:Lr,ariaAutoComplete:null,ariaBusy:Lr,ariaChecked:Lr,ariaColCount:Ue,ariaColIndex:Ue,ariaColSpan:Ue,ariaControls:sr,ariaCurrent:null,ariaDescribedBy:sr,ariaDetails:null,ariaDisabled:Lr,ariaDropEffect:sr,ariaErrorMessage:null,ariaExpanded:Lr,ariaFlowTo:sr,ariaGrabbed:Lr,ariaHasPopup:null,ariaHidden:Lr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:sr,ariaLevel:Ue,ariaLive:null,ariaModal:Lr,ariaMultiLine:Lr,ariaMultiSelectable:Lr,ariaOrientation:null,ariaOwns:sr,ariaPlaceholder:null,ariaPosInSet:Ue,ariaPressed:Lr,ariaReadOnly:Lr,ariaRelevant:null,ariaRequired:Lr,ariaRoleDescription:sr,ariaRowCount:Ue,ariaRowIndex:Ue,ariaRowSpan:Ue,ariaSelected:Lr,ariaSetSize:Ue,ariaSort:null,ariaValueMax:Ue,ariaValueMin:Ue,ariaValueNow:Ue,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Que(e,t){return t in e?e[t]:t}function kue(e,t){return Que(e,t.toLowerCase())}const YGe=om({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Wh,acceptCharset:sr,accessKey:sr,action:null,allow:null,allowFullScreen:Bt,allowPaymentRequest:Bt,allowUserMedia:Bt,alt:null,as:null,async:Bt,autoCapitalize:null,autoComplete:sr,autoFocus:Bt,autoPlay:Bt,blocking:sr,capture:null,charSet:null,checked:Bt,cite:null,className:sr,cols:Ue,colSpan:null,content:null,contentEditable:Lr,controls:Bt,controlsList:sr,coords:Ue|Wh,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Bt,defer:Bt,dir:null,dirName:null,disabled:Bt,download:Sue,draggable:Lr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Bt,formTarget:null,headers:sr,height:Ue,hidden:Bt,high:Ue,href:null,hrefLang:null,htmlFor:sr,httpEquiv:sr,id:null,imageSizes:null,imageSrcSet:null,inert:Bt,inputMode:null,integrity:null,is:null,isMap:Bt,itemId:null,itemProp:sr,itemRef:sr,itemScope:Bt,itemType:sr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Bt,low:Ue,manifest:null,max:null,maxLength:Ue,media:null,method:null,min:null,minLength:Ue,multiple:Bt,muted:Bt,name:null,nonce:null,noModule:Bt,noValidate:Bt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Bt,optimum:Ue,pattern:null,ping:sr,placeholder:null,playsInline:Bt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Bt,referrerPolicy:null,rel:sr,required:Bt,reversed:Bt,rows:Ue,rowSpan:Ue,sandbox:sr,scope:null,scoped:Bt,seamless:Bt,selected:Bt,shadowRootClonable:Bt,shadowRootDelegatesFocus:Bt,shadowRootMode:null,shape:null,size:Ue,sizes:null,slot:null,span:Ue,spellCheck:Lr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ue,step:null,style:null,tabIndex:Ue,target:null,title:null,translate:null,type:null,typeMustMatch:Bt,useMap:null,value:Lr,width:Ue,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:sr,axis:null,background:null,bgColor:null,border:Ue,borderColor:null,bottomMargin:Ue,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Bt,declare:Bt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ue,leftMargin:Ue,link:null,longDesc:null,lowSrc:null,marginHeight:Ue,marginWidth:Ue,noResize:Bt,noHref:Bt,noShade:Bt,noWrap:Bt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ue,rules:null,scheme:null,scrolling:Lr,standby:null,summary:null,text:null,topMargin:Ue,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ue,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Bt,disableRemotePlayback:Bt,prefix:null,property:null,results:Ue,security:null,unselectable:null},space:"html",transform:kue}),GGe=om({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:to,accentHeight:Ue,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ue,amplitude:Ue,arabicForm:null,ascent:Ue,attributeName:null,attributeType:null,azimuth:Ue,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ue,by:null,calcMode:null,capHeight:Ue,className:sr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ue,diffuseConstant:Ue,direction:null,display:null,dur:null,divisor:Ue,dominantBaseline:null,download:Bt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ue,enableBackground:null,end:null,event:null,exponent:Ue,externalResourcesRequired:null,fill:null,fillOpacity:Ue,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Wh,g2:Wh,glyphName:Wh,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ue,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ue,horizOriginX:Ue,horizOriginY:Ue,id:null,ideographic:Ue,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ue,k:Ue,k1:Ue,k2:Ue,k3:Ue,k4:Ue,kernelMatrix:to,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ue,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ue,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ue,overlineThickness:Ue,paintOrder:null,panose1:null,path:null,pathLength:Ue,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:sr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ue,pointsAtY:Ue,pointsAtZ:Ue,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:to,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:to,rev:to,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:to,requiredFeatures:to,requiredFonts:to,requiredFormats:to,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ue,specularExponent:Ue,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ue,strikethroughThickness:Ue,string:null,stroke:null,strokeDashArray:to,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ue,strokeOpacity:Ue,strokeWidth:null,style:null,surfaceScale:Ue,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:to,tabIndex:Ue,tableValues:null,target:null,targetX:Ue,targetY:Ue,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:to,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ue,underlineThickness:Ue,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ue,values:null,vAlphabetic:Ue,vMathematical:Ue,vectorEffect:null,vHanging:Ue,vIdeographic:Ue,version:null,vertAdvY:Ue,vertOriginX:Ue,vertOriginY:Ue,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ue,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Que}),Pue=om({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Tue=om({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:kue}),_ue=om({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),NGe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},ZGe=/[A-Z]/g,pN=/-[a-z]/g,IGe=/^data[-\w.:]+$/i;function Xue(e,t){const n=i$(t);let r=t,i=Na;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&IGe.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(pN,VGe);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!pN.test(a)){let o=a.replace(ZGe,DGe);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=mz}return new i(r,t)}function DGe(e){return"-"+e.toLowerCase()}function VGe(e){return e.charAt(1).toUpperCase()}const Rue=wue([xue,YGe,Pue,Tue,_ue],"html"),xQ=wue([xue,GGe,Pue,Tue,_ue],"svg");function mN(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function MGe(e){return e.join(" ").trim()}var LGe=fce();const FGe=Fn(LGe),Eue=que("end"),gz=que("start");function que(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function BGe(e){const t=gz(e),n=Eue(e);if(t&&n)return{start:t,end:n}}function t0(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?gN(e.position):"start"in e||"end"in e?gN(e):"line"in e||"column"in e?Vq(e):""}function Vq(e){return $N(e&&e.line)+":"+$N(e&&e.column)}function gN(e){return Vq(e&&e.start)+"-"+Vq(e&&e.end)}function $N(e){return e&&typeof e=="number"?e:1}class aa extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?a.ruleId=r:(a.source=r.slice(0,l),a.ruleId=r.slice(l+1))}if(!a.place&&a.ancestors&&a.ancestors){const l=a.ancestors[a.ancestors.length-1];l&&(a.place=l.position)}const s=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=s?s.line:void 0,this.name=t0(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual,this.expected,this.note,this.url}}aa.prototype.file="";aa.prototype.name="";aa.prototype.reason="";aa.prototype.message="";aa.prototype.stack="";aa.prototype.column=void 0;aa.prototype.line=void 0;aa.prototype.ancestors=void 0;aa.prototype.cause=void 0;aa.prototype.fatal=void 0;aa.prototype.place=void 0;aa.prototype.ruleId=void 0;aa.prototype.source=void 0;const $z={}.hasOwnProperty,HGe=new Map,KGe=/[A-Z]/g,JGe=new Set(["table","tbody","thead","tfoot","tr"]),eNe=new Set(["td","th"]),jue="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tNe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=cNe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=lNe(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?xQ:Rue,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Cue(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Cue(e,t,n){if(t.type==="element")return nNe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return rNe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return aNe(e,t,n);if(t.type==="mdxjsEsm")return iNe(e,t);if(t.type==="root")return oNe(e,t,n);if(t.type==="text")return sNe(e,t)}function nNe(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=xQ,e.schema=i),e.ancestors.push(t);const a=Aue(e,t.tagName,!1),o=uNe(e,t);let s=vz(e,t);return JGe.has(t.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!UGe(l):!0})),zue(e,o,a,t),yz(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function rNe(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}a$(e,t.position)}function iNe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);a$(e,t.position)}function aNe(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=xQ,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:Aue(e,t.name,!0),o=ONe(e,t),s=vz(e,t);return zue(e,o,a,t),yz(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function oNe(e,t,n){const r={};return yz(r,vz(e,t)),e.create(t,e.Fragment,r,n)}function sNe(e,t){return t.value}function zue(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function yz(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function lNe(e,t,n){return r;function r(i,a,o,s){const c=Array.isArray(o.children)?n:t;return s?c(a,o,s):c(a,o)}}function cNe(e,t){return n;function n(r,i,a,o){const s=Array.isArray(a.children),l=gz(r);return t(i,a,o,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function uNe(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&$z.call(t.properties,i)){const a=dNe(e,i,t.properties[i]);if(a){const[o,s]=a;e.tableCellAlignToStyle&&o==="align"&&typeof s=="string"&&eNe.has(t.tagName)?r=s:n[o]=s}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ONe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const s=o.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else a$(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,a=e.evaluater.evaluateExpression(s.expression)}else a$(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function vz(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:HGe;for(;++r<t.children.length;){const a=t.children[r];let o;if(e.passKeys){const l=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const s=Cue(e,a,o);s!==void 0&&n.push(s)}return n}function dNe(e,t,n){const r=Xue(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?qGe(n):MGe(n)),r.property==="style"){let i=typeof n=="object"?n:fNe(e,String(n));return e.stylePropertyNameCase==="css"&&(i=hNe(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?NGe[r.property]||r.property:r.attribute,n]}}function fNe(e,t){try{return FGe(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new aa("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=jue+"#cannot-parse-style-attribute",i}}function Aue(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let a=-1,o;for(;++a<i.length;){const s=dN(i[a])?{type:"Identifier",name:i[a]}:{type:"Literal",value:i[a]};o=o?{type:"MemberExpression",object:o,property:s,computed:!!(a&&s.type==="Literal"),optional:!1}:s}r=o}else r=dN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return $z.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);a$(e)}function a$(e,t){const n=new aa("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=jue+"#cannot-handle-mdx-estrees-without-createevaluater",n}function hNe(e){const t={};let n;for(n in e)$z.call(e,n)&&(t[pNe(n)]=e[n]);return t}function pNe(e){let t=e.replace(KGe,mNe);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function mNe(e){return"-"+e.toLowerCase()}const D5={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},gNe={};function bz(e,t){const n=gNe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Uue(e,r,i)}function Uue(e,t,n){if($Ne(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return yN(e.children,t,n)}return Array.isArray(e)?yN(e,t,n):""}function yN(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Uue(e[i],t,n);return r.join("")}function $Ne(e){return!!(e&&typeof e=="object")}const vN=document.createElement("i");function wz(e){const t="&"+e+";";vN.innerHTML=t;const n=vN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function $o(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Wo(e,t){return e.length>0?($o(e,e.length,0,t),e):t}const bN={}.hasOwnProperty;function Wue(e){const t={};let n=-1;for(;++n<e.length;)yNe(t,e[n]);return t}function yNe(e,t){let n;for(n in t){const i=(bN.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){bN.call(i,o)||(i[o]=[]);const s=a[o];vNe(i[o],Array.isArray(s)?s:s?[s]:[])}}}function vNe(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);$o(e,0,0,r)}function Yue(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function js(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const pa=vO(/[A-Za-z]/),ea=vO(/[\dA-Za-z]/),bNe=vO(/[#-'*+\--9=?A-Z^-~]/);function Aw(e){return e!==null&&(e<32||e===127)}const Mq=vO(/\d/),wNe=vO(/[\dA-Fa-f]/),SNe=vO(/[!-/:-@[-`{-~]/);function yt(e){return e!==null&&e<-2}function ir(e){return e!==null&&(e<0||e===32)}function pn(e){return e===-2||e===-1||e===32}const QQ=vO(new RegExp("\\p{P}|\\p{S}","u")),Dd=vO(/\s/);function vO(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function sm(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o="";if(a===37&&ea(e.charCodeAt(n+1))&&ea(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const s=e.charCodeAt(n+1);a<56320&&s>56319&&s<57344?(o=String.fromCharCode(a,s),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ln(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(l){return pn(l)?(e.enter(n),s(l)):t(l)}function s(l){return pn(l)&&a++<i?(e.consume(l),s):(e.exit(n),t(l))}}const xNe={tokenize:QNe};function QNe(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),ln(e,t,"linePrefix")}function i(s){return e.enter("paragraph"),a(s)}function a(s){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(s)}function o(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return yt(s)?(e.consume(s),e.exit("chunkText"),a):(e.consume(s),o)}}const kNe={tokenize:PNe},wN={tokenize:TNe};function PNe(e){const t=this,n=[];let r=0,i,a,o;return s;function s(w){if(r<n.length){const x=n[r];return t.containerState=x[1],e.attempt(x[0].continuation,l,c)(w)}return c(w)}function l(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const x=t.events.length;let b=x,S;for(;b--;)if(t.events[b][0]==="exit"&&t.events[b][1].type==="chunkFlow"){S=t.events[b][1].end;break}$(r);let Q=x;for(;Q<t.events.length;)t.events[Q][1].end={...S},Q++;return $o(t.events,b+1,0,t.events.slice(x)),t.events.length=Q,c(w)}return s(w)}function c(w){if(r===n.length){if(!i)return d(w);if(i.currentConstruct&&i.currentConstruct.concrete)return p(w);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(wN,u,O)(w)}function u(w){return i&&v(),$(r),d(w)}function O(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(w)}function d(w){return t.containerState={},e.attempt(wN,f,p)(w)}function f(w){return r++,n.push([t.currentConstruct,t.containerState]),d(w)}function p(w){if(w===null){i&&v(),$(0),e.consume(w);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),m(w)}function m(w){if(w===null){g(e.exit("chunkFlow"),!0),$(0),e.consume(w);return}return yt(w)?(e.consume(w),g(e.exit("chunkFlow")),r=0,t.interrupt=void 0,s):(e.consume(w),m)}function g(w,x){const b=t.sliceStream(w);if(x&&b.push(null),w.previous=a,a&&(a.next=w),a=w,i.defineSkip(w.start),i.write(b),t.parser.lazy[w.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<o&&(!i.events[S][1].end||i.events[S][1].end.offset>o))return;const Q=t.events.length;let P=Q,R,_;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){if(R){_=t.events[P][1].end;break}R=!0}for($(r),S=Q;S<t.events.length;)t.events[S][1].end={..._},S++;$o(t.events,P+1,0,t.events.slice(Q)),t.events.length=S}}function $(w){let x=n.length;for(;x-- >w;){const b=n[x];t.containerState=b[1],b[0].exit.call(t,e)}n.length=w}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function TNe(e,t,n){return ln(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function op(e){if(e===null||ir(e)||Dd(e))return 1;if(QQ(e))return 2}function kQ(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Lq={name:"attention",resolveAll:_Ne,tokenize:XNe};function _Ne(e,t){let n=-1,r,i,a,o,s,l,c,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const O={...e[r][1].end},d={...e[n][1].start};SN(O,-l),SN(d,l),o={type:l>1?"strongSequence":"emphasisSequence",start:O,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:d},a={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Wo(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Wo(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),c=Wo(c,kQ(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Wo(c,[["exit",a,t],["enter",s,t],["exit",s,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=Wo(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,$o(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function XNe(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=op(r);let a;return o;function o(l){return a=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===a)return e.consume(l),s;const c=e.exit("attentionSequence"),u=op(l),O=!u||u===2&&i||n.includes(l),d=!i||i===2&&u||n.includes(r);return c._open=!!(a===42?O:O&&(i||!d)),c._close=!!(a===42?d:d&&(u||!O)),t(l)}}function SN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const RNe={name:"autolink",tokenize:ENe};function ENe(e,t,n){let r=0;return i;function i(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a}function a(f){return pa(f)?(e.consume(f),o):f===64?n(f):c(f)}function o(f){return f===43||f===45||f===46||ea(f)?(r=1,s(f)):c(f)}function s(f){return f===58?(e.consume(f),r=0,l):(f===43||f===45||f===46||ea(f))&&r++<32?(e.consume(f),s):(r=0,c(f))}function l(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Aw(f)?n(f):(e.consume(f),l)}function c(f){return f===64?(e.consume(f),u):bNe(f)?(e.consume(f),c):n(f)}function u(f){return ea(f)?O(f):n(f)}function O(f){return f===46?(e.consume(f),r=0,u):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):d(f)}function d(f){if((f===45||ea(f))&&r++<63){const p=f===45?d:O;return e.consume(f),p}return n(f)}}const Ry={partial:!0,tokenize:qNe};function qNe(e,t,n){return r;function r(a){return pn(a)?ln(e,i,"linePrefix")(a):i(a)}function i(a){return a===null||yt(a)?t(a):n(a)}}const Gue={continuation:{tokenize:CNe},exit:zNe,name:"blockQuote",tokenize:jNe};function jNe(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),a}return n(o)}function a(o){return pn(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function CNe(e,t,n){const r=this;return i;function i(o){return pn(o)?ln(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):a(o)}function a(o){return e.attempt(Gue,t,n)(o)}}function zNe(e){e.exit("blockQuote")}const Nue={name:"characterEscape",tokenize:ANe};function ANe(e,t,n){return r;function r(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),i}function i(a){return SNe(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const Zue={name:"characterReference",tokenize:UNe};function UNe(e,t,n){const r=this;let i=0,a,o;return s;function s(O){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(O),e.exit("characterReferenceMarker"),l}function l(O){return O===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(O),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),a=31,o=ea,u(O))}function c(O){return O===88||O===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(O),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,o=wNe,u):(e.enter("characterReferenceValue"),a=7,o=Mq,u(O))}function u(O){if(O===59&&i){const d=e.exit("characterReferenceValue");return o===ea&&!wz(r.sliceSerialize(d))?n(O):(e.enter("characterReferenceMarker"),e.consume(O),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(O)&&i++<a?(e.consume(O),u):n(O)}}const xN={partial:!0,tokenize:YNe},QN={concrete:!0,name:"codeFenced",tokenize:WNe};function WNe(e,t,n){const r=this,i={partial:!0,tokenize:b};let a=0,o=0,s;return l;function l(S){return c(S)}function c(S){const Q=r.events[r.events.length-1];return a=Q&&Q[1].type==="linePrefix"?Q[2].sliceSerialize(Q[1],!0).length:0,s=S,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(S)}function u(S){return S===s?(o++,e.consume(S),u):o<3?n(S):(e.exit("codeFencedFenceSequence"),pn(S)?ln(e,O,"whitespace")(S):O(S))}function O(S){return S===null||yt(S)?(e.exit("codeFencedFence"),r.interrupt?t(S):e.check(xN,m,x)(S)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(S))}function d(S){return S===null||yt(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),O(S)):pn(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ln(e,f,"whitespace")(S)):S===96&&S===s?n(S):(e.consume(S),d)}function f(S){return S===null||yt(S)?O(S):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||yt(S)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),O(S)):S===96&&S===s?n(S):(e.consume(S),p)}function m(S){return e.attempt(i,x,g)(S)}function g(S){return e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),$}function $(S){return a>0&&pn(S)?ln(e,v,"linePrefix",a+1)(S):v(S)}function v(S){return S===null||yt(S)?e.check(xN,m,x)(S):(e.enter("codeFlowValue"),w(S))}function w(S){return S===null||yt(S)?(e.exit("codeFlowValue"),v(S)):(e.consume(S),w)}function x(S){return e.exit("codeFenced"),t(S)}function b(S,Q,P){let R=0;return _;function _(N){return S.enter("lineEnding"),S.consume(N),S.exit("lineEnding"),E}function E(N){return S.enter("codeFencedFence"),pn(N)?ln(S,C,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):C(N)}function C(N){return N===s?(S.enter("codeFencedFenceSequence"),z(N)):P(N)}function z(N){return N===s?(R++,S.consume(N),z):R>=o?(S.exit("codeFencedFenceSequence"),pn(N)?ln(S,W,"whitespace")(N):W(N)):P(N)}function W(N){return N===null||yt(N)?(S.exit("codeFencedFence"),Q(N)):P(N)}}}function YNe(e,t,n){const r=this;return i;function i(o){return o===null?n(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)}}const V5={name:"codeIndented",tokenize:NNe},GNe={partial:!0,tokenize:ZNe};function NNe(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),ln(e,a,"linePrefix",5)(c)}function a(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):yt(c)?e.attempt(GNe,o,l)(c):(e.enter("codeFlowValue"),s(c))}function s(c){return c===null||yt(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),s)}function l(c){return e.exit("codeIndented"),t(c)}}function ZNe(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):yt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):ln(e,a,"linePrefix",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):yt(o)?i(o):n(o)}}const INe={name:"codeText",previous:VNe,resolve:DNe,tokenize:MNe};function DNe(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==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",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="codeTextData",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 VNe(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function MNe(e,t,n){let r=0,i,a;return o;function o(O){return e.enter("codeText"),e.enter("codeTextSequence"),s(O)}function s(O){return O===96?(e.consume(O),r++,s):(e.exit("codeTextSequence"),l(O))}function l(O){return O===null?n(O):O===32?(e.enter("space"),e.consume(O),e.exit("space"),l):O===96?(a=e.enter("codeTextSequence"),i=0,u(O)):yt(O)?(e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(O))}function c(O){return O===null||O===32||O===96||yt(O)?(e.exit("codeTextData"),l(O)):(e.consume(O),c)}function u(O){return O===96?(e.consume(O),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(O)):(a.type="codeTextData",c(O))}}class LNe{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Nm(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Nm(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Nm(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Nm(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Nm(this.left,n.reverse())}}}function Nm(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Iue(e){const t={};let n=-1,r,i,a,o,s,l,c;const u=new LNe(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,a=0,a<l.length&&l[a][1].type==="lineEndingBlank"&&(a+=2),a<l.length&&l[a][1].type==="content"))for(;++a<l.length&&l[a][1].type!=="content";)l[a][1].type==="chunkText"&&(l[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,FNe(u,n)),n=t[n],c=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=a);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return $o(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function FNe(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,l=[],c={};let u,O,d=-1,f=n,p=0,m=0;const g=[m];for(;f;){for(;e.get(++i)[1]!==f;);a.push(i),f._tokenizer||(u=r.sliceStream(f),f.next||u.push(null),O&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),O=f,f=f.next}for(f=n;++d<s.length;)s[d][0]==="exit"&&s[d-1][0]==="enter"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(m=d+1,g.push(m),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):g.pop(),d=g.length;d--;){const $=s.slice(g[d],g[d+1]),v=a.pop();l.push([v,v+$.length-1]),e.splice(v,2,$)}for(l.reverse(),d=-1;++d<l.length;)c[p+l[d][0]]=p+l[d][1],p+=l[d][1]-l[d][0]-1;return c}const BNe={resolve:KNe,tokenize:JNe},HNe={partial:!0,tokenize:eZe};function KNe(e){return Iue(e),e}function JNe(e,t){let n;return r;function r(s){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(s)}function i(s){return s===null?a(s):yt(s)?e.check(HNe,o,a)(s):(e.consume(s),i)}function a(s){return e.exit("chunkContent"),e.exit("content"),t(s)}function o(s){return e.consume(s),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function eZe(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ln(e,a,"linePrefix")}function a(o){if(o===null||yt(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Due(e,t,n,r,i,a,o,s,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return O;function O($){return $===60?(e.enter(r),e.enter(i),e.enter(a),e.consume($),e.exit(a),d):$===null||$===32||$===41||Aw($)?n($):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),m($))}function d($){return $===62?(e.enter(a),e.consume($),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),f($))}function f($){return $===62?(e.exit("chunkString"),e.exit(s),d($)):$===null||$===60||yt($)?n($):(e.consume($),$===92?p:f)}function p($){return $===60||$===62||$===92?(e.consume($),f):f($)}function m($){return!u&&($===null||$===41||ir($))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t($)):u<c&&$===40?(e.consume($),u++,m):$===41?(e.consume($),u--,m):$===null||$===32||$===40||Aw($)?n($):(e.consume($),$===92?g:m)}function g($){return $===40||$===41||$===92?(e.consume($),m):m($)}}function Vue(e,t,n,r,i,a){const o=this;let s=0,l;return c;function c(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(a),u}function u(f){return s>999||f===null||f===91||f===93&&!l||f===94&&!s&&"_hiddenFootnoteSupport"in o.parser.constructs?n(f):f===93?(e.exit(a),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):yt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),O(f))}function O(f){return f===null||f===91||f===93||yt(f)||s++>999?(e.exit("chunkString"),u(f)):(e.consume(f),l||(l=!pn(f)),f===92?d:O)}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,O):O(f)}}function Mue(e,t,n,r,i,a){let o;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,l):n(d)}function l(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),c(d))}function c(d){return d===o?(e.exit(a),l(o)):d===null?n(d):yt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),ln(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(d){return d===o||d===null||yt(d)?(e.exit("chunkString"),c(d)):(e.consume(d),d===92?O:u)}function O(d){return d===o||d===92?(e.consume(d),u):u(d)}}function n0(e,t){let n;return r;function r(i){return yt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):pn(i)?ln(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const tZe={name:"definition",tokenize:rZe},nZe={partial:!0,tokenize:iZe};function rZe(e,t,n){const r=this;let i;return a;function a(f){return e.enter("definition"),o(f)}function o(f){return Vue.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function s(f){return i=js(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),l):n(f)}function l(f){return ir(f)?n0(e,c)(f):c(f)}function c(f){return Due(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function u(f){return e.attempt(nZe,O,O)(f)}function O(f){return pn(f)?ln(e,d,"whitespace")(f):d(f)}function d(f){return f===null||yt(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function iZe(e,t,n){return r;function r(s){return ir(s)?n0(e,i)(s):n(s)}function i(s){return Mue(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function a(s){return pn(s)?ln(e,o,"whitespace")(s):o(s)}function o(s){return s===null||yt(s)?t(s):n(s)}}const aZe={name:"hardBreakEscape",tokenize:oZe};function oZe(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return yt(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const sZe={name:"headingAtx",resolve:lZe,tokenize:cZe};function lZe(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$o(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function cZe(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),a(u)}function a(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ir(u)?(e.exit("atxHeadingSequence"),s(u)):n(u)}function s(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||yt(u)?(e.exit("atxHeading"),t(u)):pn(u)?ln(e,s,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),s(u))}function c(u){return u===null||u===35||ir(u)?(e.exit("atxHeadingText"),s(u)):(e.consume(u),c)}}const uZe=["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","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],kN=["pre","script","style","textarea"],OZe={concrete:!0,name:"htmlFlow",resolveTo:hZe,tokenize:pZe},dZe={partial:!0,tokenize:gZe},fZe={partial:!0,tokenize:mZe};function hZe(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function pZe(e,t,n){const r=this;let i,a,o,s,l;return c;function c(U){return u(U)}function u(U){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(U),O}function O(U){return U===33?(e.consume(U),d):U===47?(e.consume(U),a=!0,m):U===63?(e.consume(U),i=3,r.interrupt?t:A):pa(U)?(e.consume(U),o=String.fromCharCode(U),g):n(U)}function d(U){return U===45?(e.consume(U),i=2,f):U===91?(e.consume(U),i=5,s=0,p):pa(U)?(e.consume(U),i=4,r.interrupt?t:A):n(U)}function f(U){return U===45?(e.consume(U),r.interrupt?t:A):n(U)}function p(U){const le="CDATA[";return U===le.charCodeAt(s++)?(e.consume(U),s===le.length?r.interrupt?t:C:p):n(U)}function m(U){return pa(U)?(e.consume(U),o=String.fromCharCode(U),g):n(U)}function g(U){if(U===null||U===47||U===62||ir(U)){const le=U===47,F=o.toLowerCase();return!le&&!a&&kN.includes(F)?(i=1,r.interrupt?t(U):C(U)):uZe.includes(o.toLowerCase())?(i=6,le?(e.consume(U),$):r.interrupt?t(U):C(U)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(U):a?v(U):w(U))}return U===45||ea(U)?(e.consume(U),o+=String.fromCharCode(U),g):n(U)}function $(U){return U===62?(e.consume(U),r.interrupt?t:C):n(U)}function v(U){return pn(U)?(e.consume(U),v):_(U)}function w(U){return U===47?(e.consume(U),_):U===58||U===95||pa(U)?(e.consume(U),x):pn(U)?(e.consume(U),w):_(U)}function x(U){return U===45||U===46||U===58||U===95||ea(U)?(e.consume(U),x):b(U)}function b(U){return U===61?(e.consume(U),S):pn(U)?(e.consume(U),b):w(U)}function S(U){return U===null||U===60||U===61||U===62||U===96?n(U):U===34||U===39?(e.consume(U),l=U,Q):pn(U)?(e.consume(U),S):P(U)}function Q(U){return U===l?(e.consume(U),l=null,R):U===null||yt(U)?n(U):(e.consume(U),Q)}function P(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||ir(U)?b(U):(e.consume(U),P)}function R(U){return U===47||U===62||pn(U)?w(U):n(U)}function _(U){return U===62?(e.consume(U),E):n(U)}function E(U){return U===null||yt(U)?C(U):pn(U)?(e.consume(U),E):n(U)}function C(U){return U===45&&i===2?(e.consume(U),D):U===60&&i===1?(e.consume(U),M):U===62&&i===4?(e.consume(U),J):U===63&&i===3?(e.consume(U),A):U===93&&i===5?(e.consume(U),Y):yt(U)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(dZe,K,z)(U)):U===null||yt(U)?(e.exit("htmlFlowData"),z(U)):(e.consume(U),C)}function z(U){return e.check(fZe,W,K)(U)}function W(U){return e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),N}function N(U){return U===null||yt(U)?z(U):(e.enter("htmlFlowData"),C(U))}function D(U){return U===45?(e.consume(U),A):C(U)}function M(U){return U===47?(e.consume(U),o="",B):C(U)}function B(U){if(U===62){const le=o.toLowerCase();return kN.includes(le)?(e.consume(U),J):C(U)}return pa(U)&&o.length<8?(e.consume(U),o+=String.fromCharCode(U),B):C(U)}function Y(U){return U===93?(e.consume(U),A):C(U)}function A(U){return U===62?(e.consume(U),J):U===45&&i===2?(e.consume(U),A):C(U)}function J(U){return U===null||yt(U)?(e.exit("htmlFlowData"),K(U)):(e.consume(U),J)}function K(U){return e.exit("htmlFlow"),t(U)}}function mZe(e,t,n){const r=this;return i;function i(o){return yt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function gZe(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ry,t,n)}}const $Ze={name:"htmlText",tokenize:yZe};function yZe(e,t,n){const r=this;let i,a,o;return s;function s(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),l}function l(A){return A===33?(e.consume(A),c):A===47?(e.consume(A),b):A===63?(e.consume(A),w):pa(A)?(e.consume(A),P):n(A)}function c(A){return A===45?(e.consume(A),u):A===91?(e.consume(A),a=0,p):pa(A)?(e.consume(A),v):n(A)}function u(A){return A===45?(e.consume(A),f):n(A)}function O(A){return A===null?n(A):A===45?(e.consume(A),d):yt(A)?(o=O,M(A)):(e.consume(A),O)}function d(A){return A===45?(e.consume(A),f):O(A)}function f(A){return A===62?D(A):A===45?d(A):O(A)}function p(A){const J="CDATA[";return A===J.charCodeAt(a++)?(e.consume(A),a===J.length?m:p):n(A)}function m(A){return A===null?n(A):A===93?(e.consume(A),g):yt(A)?(o=m,M(A)):(e.consume(A),m)}function g(A){return A===93?(e.consume(A),$):m(A)}function $(A){return A===62?D(A):A===93?(e.consume(A),$):m(A)}function v(A){return A===null||A===62?D(A):yt(A)?(o=v,M(A)):(e.consume(A),v)}function w(A){return A===null?n(A):A===63?(e.consume(A),x):yt(A)?(o=w,M(A)):(e.consume(A),w)}function x(A){return A===62?D(A):w(A)}function b(A){return pa(A)?(e.consume(A),S):n(A)}function S(A){return A===45||ea(A)?(e.consume(A),S):Q(A)}function Q(A){return yt(A)?(o=Q,M(A)):pn(A)?(e.consume(A),Q):D(A)}function P(A){return A===45||ea(A)?(e.consume(A),P):A===47||A===62||ir(A)?R(A):n(A)}function R(A){return A===47?(e.consume(A),D):A===58||A===95||pa(A)?(e.consume(A),_):yt(A)?(o=R,M(A)):pn(A)?(e.consume(A),R):D(A)}function _(A){return A===45||A===46||A===58||A===95||ea(A)?(e.consume(A),_):E(A)}function E(A){return A===61?(e.consume(A),C):yt(A)?(o=E,M(A)):pn(A)?(e.consume(A),E):R(A)}function C(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),i=A,z):yt(A)?(o=C,M(A)):pn(A)?(e.consume(A),C):(e.consume(A),W)}function z(A){return A===i?(e.consume(A),i=void 0,N):A===null?n(A):yt(A)?(o=z,M(A)):(e.consume(A),z)}function W(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||ir(A)?R(A):(e.consume(A),W)}function N(A){return A===47||A===62||ir(A)?R(A):n(A)}function D(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function M(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),B}function B(A){return pn(A)?ln(e,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):Y(A)}function Y(A){return e.enter("htmlTextData"),o(A)}}const Sz={name:"labelEnd",resolveAll:SZe,resolveTo:xZe,tokenize:QZe},vZe={tokenize:kZe},bZe={tokenize:PZe},wZe={tokenize:TZe};function SZe(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&$o(e,0,e.length,n),e}function xZe(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(a=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[a][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=Wo(s,e.slice(a+1,a+r+3)),s=Wo(s,[["enter",u,t]]),s=Wo(s,kQ(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Wo(s,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),s=Wo(s,e.slice(o+1)),s=Wo(s,[["exit",l,t]]),$o(e,a,e.length,s),e}function QZe(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(d){return a?a._inactive?O(d):(o=r.parser.defined.includes(js(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),l):n(d)}function l(d){return d===40?e.attempt(vZe,u,o?u:O)(d):d===91?e.attempt(bZe,u,o?c:O)(d):o?u(d):O(d)}function c(d){return e.attempt(wZe,u,O)(d)}function u(d){return t(d)}function O(d){return a._balanced=!0,n(d)}}function kZe(e,t,n){return r;function r(O){return e.enter("resource"),e.enter("resourceMarker"),e.consume(O),e.exit("resourceMarker"),i}function i(O){return ir(O)?n0(e,a)(O):a(O)}function a(O){return O===41?u(O):Due(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(O)}function o(O){return ir(O)?n0(e,l)(O):u(O)}function s(O){return n(O)}function l(O){return O===34||O===39||O===40?Mue(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(O):u(O)}function c(O){return ir(O)?n0(e,u)(O):u(O)}function u(O){return O===41?(e.enter("resourceMarker"),e.consume(O),e.exit("resourceMarker"),e.exit("resource"),t):n(O)}}function PZe(e,t,n){const r=this;return i;function i(s){return Vue.call(r,e,a,o,"reference","referenceMarker","referenceString")(s)}function a(s){return r.parser.defined.includes(js(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function TZe(e,t,n){return r;function r(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),i}function i(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const _Ze={name:"labelStartImage",resolveAll:Sz.resolveAll,tokenize:XZe};function XZe(e,t,n){const r=this;return i;function i(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),a}function a(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),o):n(s)}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}const RZe={name:"labelStartLink",resolveAll:Sz.resolveAll,tokenize:EZe};function EZe(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),a}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const M5={name:"lineEnding",tokenize:qZe};function qZe(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ln(e,t,"linePrefix")}}const R1={name:"thematicBreak",tokenize:jZe};function jZe(e,t,n){let r=0,i;return a;function a(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,s(c)}function s(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||yt(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),pn(c)?ln(e,s,"whitespace")(c):s(c))}}const ka={continuation:{tokenize:UZe},exit:YZe,name:"list",tokenize:AZe},CZe={partial:!0,tokenize:GZe},zZe={partial:!0,tokenize:WZe};function AZe(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(f){const p=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:Mq(f)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(R1,n,c)(f):c(f);if(!r.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(f)}return n(f)}function l(f){return Mq(f)&&++o<10?(e.consume(f),l):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),c(f)):n(f)}function c(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,e.check(Ry,r.interrupt?n:u,e.attempt(CZe,d,O))}function u(f){return r.containerState.initialBlankLine=!0,a++,d(f)}function O(f){return pn(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),d):n(f)}function d(f){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function UZe(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ry,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ln(e,t,"listItemIndent",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!pn(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(zZe,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,ln(e,e.attempt(ka,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function WZe(e,t,n){const r=this;return ln(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function YZe(e){e.exit(this.containerState.type)}function GZe(e,t,n){const r=this;return ln(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!pn(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const PN={name:"setextUnderline",resolveTo:NZe,tokenize:ZZe};function NZe(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function ZZe(e,t,n){const r=this;let i;return a;function a(c){let u=r.events.length,O;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){O=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||O)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===i?(e.consume(c),s):(e.exit("setextHeadingLineSequence"),pn(c)?ln(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||yt(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const IZe={tokenize:DZe};function DZe(e){const t=this,n=e.attempt(Ry,r,e.attempt(this.parser.constructs.flowInitial,i,ln(e,e.attempt(this.parser.constructs.flow,i,e.attempt(BNe,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const VZe={resolveAll:Fue()},MZe=Lue("string"),LZe=Lue("text");function Lue(e){return{resolveAll:Fue(e==="text"?FZe:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(u){return c(u)?a(u):s(u)}function s(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),a(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const O=i[u];let d=-1;if(O)for(;++d<O.length;){const f=O[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Fue(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type==="data"&&(a=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function FZe(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,l;for(;a--;){const c=i[a];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(c===-2)l=!0,s++;else if(c!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const c={type:n===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const BZe={42:ka,43:ka,45:ka,48:ka,49:ka,50:ka,51:ka,52:ka,53:ka,54:ka,55:ka,56:ka,57:ka,62:Gue},HZe={91:tZe},KZe={[-2]:V5,[-1]:V5,32:V5},JZe={35:sZe,42:R1,45:[PN,R1],60:OZe,61:PN,95:R1,96:QN,126:QN},eIe={38:Zue,92:Nue},tIe={[-5]:M5,[-4]:M5,[-3]:M5,33:_Ze,38:Zue,42:Lq,60:[RNe,$Ze],91:RZe,92:[aZe,Nue],93:Sz,95:Lq,96:INe},nIe={null:[Lq,VZe]},rIe={null:[42,95]},iIe={null:[]},aIe=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:rIe,contentInitial:HZe,disable:iIe,document:BZe,flow:JZe,flowInitial:KZe,insideSpan:nIe,string:eIe,text:tIe},Symbol.toStringTag,{value:"Module"}));function oIe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const l={attempt:Q(b),check:Q(S),consume:v,enter:w,exit:x,interrupt:Q(S,{interrupt:!0})},c={code:null,containerState:{},defineSkip:m,events:[],now:p,parser:e,previous:null,sliceSerialize:d,sliceStream:f,write:O};let u=t.tokenize.call(c,l);return t.resolveAll&&a.push(t),c;function O(E){return o=Wo(o,E),g(),o[o.length-1]!==null?[]:(P(t,0),c.events=kQ(a,c.events,c),c.events)}function d(E,C){return lIe(f(E),C)}function f(E){return sIe(o,E)}function p(){const{_bufferIndex:E,_index:C,line:z,column:W,offset:N}=r;return{_bufferIndex:E,_index:C,line:z,column:W,offset:N}}function m(E){i[E.line]=E.column,_()}function g(){let E;for(;r._index<o.length;){const C=o[r._index];if(typeof C=="string")for(E=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===E&&r._bufferIndex<C.length;)$(C.charCodeAt(r._bufferIndex));else $(C)}}function $(E){u=u(E)}function v(E){yt(E)?(r.line++,r.column=1,r.offset+=E===-3?2:1,_()):E!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=E}function w(E,C){const z=C||{};return z.type=E,z.start=p(),c.events.push(["enter",z,c]),s.push(z),z}function x(E){const C=s.pop();return C.end=p(),c.events.push(["exit",C,c]),C}function b(E,C){P(E,C.from)}function S(E,C){C.restore()}function Q(E,C){return z;function z(W,N,D){let M,B,Y,A;return Array.isArray(W)?K(W):"tokenize"in W?K([W]):J(W);function J(Z){return ne;function ne(H){const re=H!==null&&Z[H],he=H!==null&&Z.null,we=[...Array.isArray(re)?re:re?[re]:[],...Array.isArray(he)?he:he?[he]:[]];return K(we)(H)}}function K(Z){return M=Z,B=0,Z.length===0?D:U(Z[B])}function U(Z){return ne;function ne(H){return A=R(),Y=Z,Z.partial||(c.currentConstruct=Z),Z.name&&c.parser.constructs.disable.null.includes(Z.name)?F():Z.tokenize.call(C?Object.assign(Object.create(c),C):c,l,le,F)(H)}}function le(Z){return E(Y,A),N}function F(Z){return A.restore(),++B<M.length?U(M[B]):D}}}function P(E,C){E.resolveAll&&!a.includes(E)&&a.push(E),E.resolve&&$o(c.events,C,c.events.length-C,E.resolve(c.events.slice(C),c)),E.resolveTo&&(c.events=E.resolveTo(c.events,c))}function R(){const E=p(),C=c.previous,z=c.currentConstruct,W=c.events.length,N=Array.from(s);return{from:W,restore:D};function D(){r=E,c.previous=C,c.currentConstruct=z,c.events.length=W,s=N,_()}}function _(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function sIe(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const s=o[0];typeof s=="string"?o[0]=s.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function lIe(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a=="string")o=a;else switch(a){case-5:{o="\r";break}case-4:{o=`
493
493
  `;break}case-3:{o=`\r
494
494
  `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join("")}function cIe(e){const r={constructs:Wue([aIe,...(e||{}).extensions||[]]),content:i(xNe),defined:[],document:i(kNe),flow:i(IZe),lazy:{},string:i(MZe),text:i(LZe)};return r;function i(a){return o;function o(s){return oIe(r,a,s)}}}function uIe(e){for(;!Iue(e););return e}const TN=/[\0\t\n\r]/g;function OIe(){let e=1,t="",n=!0,r;return i;function i(a,o,s){const l=[];let c,u,O,d,f;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(o||void 0).decode(a)),O=0,t="",n&&(a.charCodeAt(0)===65279&&O++,n=void 0);O<a.length;){if(TN.lastIndex=O,c=TN.exec(a),d=c&&c.index!==void 0?c.index:a.length,f=a.charCodeAt(d),!c){t=a.slice(O);break}if(f===10&&O===d&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),O<d&&(l.push(a.slice(O,d)),e+=d-O),f){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}O=d+1}return s&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const dIe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function fIe(e){return e.replace(dIe,hIe)}function hIe(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),a=i===120||i===88;return Yue(n.slice(a?2:1),a?16:10)}return wz(n)||e}const Bue={}.hasOwnProperty;function pIe(e,t,n){return typeof t!="string"&&(n=t,t=void 0),mIe(n)(uIe(cIe(n).document().write(OIe()(e,t,!0))))}function mIe(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Re),autolinkProtocol:R,autolinkEmail:R,atxHeading:a(Je),blockQuote:a(he),characterEscape:R,characterReference:R,codeFenced:a(we),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(we,o),codeText:a(ce,o),codeTextData:R,data:R,codeFlowValue:R,definition:a(Ye),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(Te),hardBreakEscape:a(ae),hardBreakTrailing:a(ae),htmlFlow:a(fe,o),htmlFlowData:R,htmlText:a(fe,o),htmlTextData:R,image:a(be),label:o,link:a(Re),listItem:a(tt),listItemValue:d,listOrdered:a(mt,O),listUnordered:a(mt),paragraph:a(Qt),reference:U,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(Je),strong:a(me),thematicBreak:a(qe)},exit:{atxHeading:l(),atxHeadingSequence:b,autolink:l(),autolinkEmail:re,autolinkProtocol:H,blockQuote:l(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:F,characterReferenceMarkerNumeric:F,characterReferenceValue:Z,characterReference:ne,codeFenced:l(g),codeFencedFence:m,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:_,codeIndented:l($),codeText:l(N),codeTextData:_,data:_,definition:l(),definitionDestinationString:x,definitionLabelString:v,definitionTitleString:w,emphasis:l(),hardBreakEscape:l(C),hardBreakTrailing:l(C),htmlFlow:l(z),htmlFlowData:_,htmlText:l(W),htmlTextData:_,image:l(M),label:Y,labelText:B,lineEnding:E,link:l(D),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:le,resourceDestinationString:A,resourceTitleString:J,resource:K,setextHeading:l(P),setextHeadingLineSequence:Q,setextHeadingText:S,strong:l(),thematicBreak:l()}};Hue(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(oe){let ge={type:"root",children:[]};const Ge={stack:[ge],tokenStack:[],config:t,enter:s,exit:c,buffer:o,resume:u,data:n},lt=[];let et=-1;for(;++et<oe.length;)if(oe[et][1].type==="listOrdered"||oe[et][1].type==="listUnordered")if(oe[et][0]==="enter")lt.push(et);else{const ft=lt.pop();et=i(oe,ft,et)}for(et=-1;++et<oe.length;){const ft=t[oe[et][0]];Bue.call(ft,oe[et][1].type)&&ft[oe[et][1].type].call(Object.assign({sliceSerialize:oe[et][2].sliceSerialize},Ge),oe[et][1])}if(Ge.tokenStack.length>0){const ft=Ge.tokenStack[Ge.tokenStack.length-1];(ft[1]||_N).call(Ge,void 0,ft[0])}for(ge.position={start:$u(oe.length>0?oe[0][1].start:{line:1,column:1,offset:0}),end:$u(oe.length>0?oe[oe.length-2][1].end:{line:1,column:1,offset:0})},et=-1;++et<t.transforms.length;)ge=t.transforms[et](ge)||ge;return ge}function i(oe,ge,Ge){let lt=ge-1,et=-1,ft=!1,Zt,Gt,Ie,bt;for(;++lt<=Ge;){const Xt=oe[lt];switch(Xt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Xt[0]==="enter"?et++:et--,bt=void 0;break}case"lineEndingBlank":{Xt[0]==="enter"&&(Zt&&!bt&&!et&&!Ie&&(Ie=lt),bt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:bt=void 0}if(!et&&Xt[0]==="enter"&&Xt[1].type==="listItemPrefix"||et===-1&&Xt[0]==="exit"&&(Xt[1].type==="listUnordered"||Xt[1].type==="listOrdered")){if(Zt){let Kt=lt;for(Gt=void 0;Kt--;){const Rn=oe[Kt];if(Rn[1].type==="lineEnding"||Rn[1].type==="lineEndingBlank"){if(Rn[0]==="exit")continue;Gt&&(oe[Gt][1].type="lineEndingBlank",ft=!0),Rn[1].type="lineEnding",Gt=Kt}else if(!(Rn[1].type==="linePrefix"||Rn[1].type==="blockQuotePrefix"||Rn[1].type==="blockQuotePrefixWhitespace"||Rn[1].type==="blockQuoteMarker"||Rn[1].type==="listItemIndent"))break}Ie&&(!Gt||Ie<Gt)&&(Zt._spread=!0),Zt.end=Object.assign({},Gt?oe[Gt][1].start:Xt[1].end),oe.splice(Gt||lt,0,["exit",Zt,Xt[2]]),lt++,Ge++}if(Xt[1].type==="listItemPrefix"){const Kt={type:"listItem",_spread:!1,start:Object.assign({},Xt[1].start),end:void 0};Zt=Kt,oe.splice(lt,0,["enter",Kt,Xt[2]]),lt++,Ge++,Ie=void 0,bt=!0}}}return oe[ge][1]._spread=ft,Ge}function a(oe,ge){return Ge;function Ge(lt){s.call(this,oe(lt),lt),ge&&ge.call(this,lt)}}function o(){this.stack.push({type:"fragment",children:[]})}function s(oe,ge,Ge){this.stack[this.stack.length-1].children.push(oe),this.stack.push(oe),this.tokenStack.push([ge,Ge||void 0]),oe.position={start:$u(ge.start),end:void 0}}function l(oe){return ge;function ge(Ge){oe&&oe.call(this,Ge),c.call(this,Ge)}}function c(oe,ge){const Ge=this.stack.pop(),lt=this.tokenStack.pop();if(lt)lt[0].type!==oe.type&&(ge?ge.call(this,oe,lt[0]):(lt[1]||_N).call(this,oe,lt[0]));else throw new Error("Cannot close `"+oe.type+"` ("+t0({start:oe.start,end:oe.end})+"): it’s not open");Ge.position.end=$u(oe.end)}function u(){return bz(this.stack.pop())}function O(){this.data.expectingFirstListItemValue=!0}function d(oe){if(this.data.expectingFirstListItemValue){const ge=this.stack[this.stack.length-2];ge.start=Number.parseInt(this.sliceSerialize(oe),10),this.data.expectingFirstListItemValue=void 0}}function f(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.lang=oe}function p(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.meta=oe}function m(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function $(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe.replace(/(\r?\n|\r)$/g,"")}function v(oe){const ge=this.resume(),Ge=this.stack[this.stack.length-1];Ge.label=ge,Ge.identifier=js(this.sliceSerialize(oe)).toLowerCase()}function w(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.title=oe}function x(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.url=oe}function b(oe){const ge=this.stack[this.stack.length-1];if(!ge.depth){const Ge=this.sliceSerialize(oe).length;ge.depth=Ge}}function S(){this.data.setextHeadingSlurpLineEnding=!0}function Q(oe){const ge=this.stack[this.stack.length-1];ge.depth=this.sliceSerialize(oe).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function R(oe){const Ge=this.stack[this.stack.length-1].children;let lt=Ge[Ge.length-1];(!lt||lt.type!=="text")&&(lt=Ee(),lt.position={start:$u(oe.start),end:void 0},Ge.push(lt)),this.stack.push(lt)}function _(oe){const ge=this.stack.pop();ge.value+=this.sliceSerialize(oe),ge.position.end=$u(oe.end)}function E(oe){const ge=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ge=ge.children[ge.children.length-1];Ge.position.end=$u(oe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ge.type)&&(R.call(this,oe),_.call(this,oe))}function C(){this.data.atHardBreak=!0}function z(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe}function W(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe}function N(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.value=oe}function D(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const ge=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=ge,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function M(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const ge=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=ge,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function B(oe){const ge=this.sliceSerialize(oe),Ge=this.stack[this.stack.length-2];Ge.label=fIe(ge),Ge.identifier=js(ge).toLowerCase()}function Y(){const oe=this.stack[this.stack.length-1],ge=this.resume(),Ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ge.type==="link"){const lt=oe.children;Ge.children=lt}else Ge.alt=ge}function A(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.url=oe}function J(){const oe=this.resume(),ge=this.stack[this.stack.length-1];ge.title=oe}function K(){this.data.inReference=void 0}function U(){this.data.referenceType="collapsed"}function le(oe){const ge=this.resume(),Ge=this.stack[this.stack.length-1];Ge.label=ge,Ge.identifier=js(this.sliceSerialize(oe)).toLowerCase(),this.data.referenceType="full"}function F(oe){this.data.characterReferenceType=oe.type}function Z(oe){const ge=this.sliceSerialize(oe),Ge=this.data.characterReferenceType;let lt;Ge?(lt=Yue(ge,Ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):lt=wz(ge);const et=this.stack[this.stack.length-1];et.value+=lt}function ne(oe){const ge=this.stack.pop();ge.position.end=$u(oe.end)}function H(oe){_.call(this,oe);const ge=this.stack[this.stack.length-1];ge.url=this.sliceSerialize(oe)}function re(oe){_.call(this,oe);const ge=this.stack[this.stack.length-1];ge.url="mailto:"+this.sliceSerialize(oe)}function he(){return{type:"blockquote",children:[]}}function we(){return{type:"code",lang:null,meta:null,value:""}}function ce(){return{type:"inlineCode",value:""}}function Ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Te(){return{type:"emphasis",children:[]}}function Je(){return{type:"heading",depth:0,children:[]}}function ae(){return{type:"break"}}function fe(){return{type:"html",value:""}}function be(){return{type:"image",title:null,url:"",alt:null}}function Re(){return{type:"link",title:null,url:"",children:[]}}function mt(oe){return{type:"list",ordered:oe.type==="listOrdered",start:null,spread:oe._spread,children:[]}}function tt(oe){return{type:"listItem",spread:oe._spread,checked:null,children:[]}}function Qt(){return{type:"paragraph",children:[]}}function me(){return{type:"strong",children:[]}}function Ee(){return{type:"text",value:""}}function qe(){return{type:"thematicBreak"}}}function $u(e){return{line:e.line,column:e.column,offset:e.offset}}function Hue(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Hue(e,r):gIe(e,r)}}function gIe(e,t){let n;for(n in t)if(Bue.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function _N(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+t0({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+t0({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+t0({start:t.start,end:t.end})+") is still open")}function $Ie(e){const t=this;t.parser=n;function n(r){return pIe(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function yIe(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function vIe(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
495
495
  `}]}function bIe(e,t){const n=t.value?t.value+`
@@ -791,7 +791,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
791
791
  `))};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=We.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:In.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);y9(t,c,We.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(cn.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:Ffe.of(cn.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=p$(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 wt{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||xHe(t.parent)||document,this.viewState=new jI(t.state||An.create(t)),t.scrollTo&&t.scrollTo.is(ib)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(wh).map(i=>new kT(i));for(let i of this.plugins)i.update(this);this.observer=new NKe(this),this.inputState=new OKe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new pI(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 Ai?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(lhe))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=che(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(An.phrases)!=this.state.facet(An.phrases))return this.setState(a);i=Kw.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 Zh(f.empty?f:We.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of d.effects)f.is(ib)&&(O=f.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=eS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(qg)!=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(ub)!=i.state.facet(ub)&&(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(Y3))try{d(i)}catch(f){ja(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!nhe(this,u)&&c.force&&Nh(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 jI(t),this.plugins=t.facet(wh).map(r=>new kT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new pI(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(wh),r=t.state.facet(wh);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new kT(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){ja(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(Sfe(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 ja(this.state,p),UI}}),O=Kw.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]!=UI)try{let p=c[f];p.write&&p.write(u[f],this)}catch(p){ja(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(Y3))s(n)}get themeClasses(){return D3+" "+(this.state.facet(I3)?fhe:dhe)+" "+this.state.facet(ub)}updateAttrs(){let t=WI(this,Bfe,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(vc)?"true":"false",class:"cm-content",style:`${at.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),WI(this,m9,n);let r=this.observer.ignore(()=>{let i=C3(this.contentDOM,this.contentAttrs,n),a=C3(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(wt.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(qg);let t=this.state.facet(wt.cspNonce);dO.mount(this.root,this.styleModules.concat(YKe).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 TT(this,t,vI(this,t,n,r))}moveByGroup(t,n){return TT(this,t,vI(this,t,n,r=>nKe(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 We.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return tKe(this,t,n,r)}moveVertically(t,n,r){return TT(this,t,rKe(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(),the(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[Iu.find(a,t-i.from,-1,n)];return Ay(r,o.dir==br.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(Vfe)||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>DKe)return Ufe(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||Afe(a.isolates,r=hI(this,t))))return a.order;r||(r=hI(this,t));let i=WHe(t.text,n,r);return this.bidiCache.push(new eS(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(()=>{bfe(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 ib.of(new Zh(typeof t=="number"?We.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 ib.of(new Zh(We.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 hi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return hi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=dO.newName(),i=[ub.of(r),qg.of(V3(`.${r}`,t))];return n&&n.dark&&i.push(I3.of(!0)),i}static baseTheme(t){return xO.lowest(qg.of(V3("."+D3,t,hhe)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&nr.get(r)||nr.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}wt.styleModule=qg;wt.inputHandler=Ife;wt.clipboardInputFilter=h9;wt.clipboardOutputFilter=p9;wt.scrollHandler=Lfe;wt.focusChangeEffect=Dfe;wt.perLineTextDirection=Vfe;wt.exceptionSink=Zfe;wt.updateListener=Y3;wt.editable=vc;wt.mouseSelectionStyle=Nfe;wt.dragMovesSelection=Gfe;wt.clickAddsSelectionRange=Yfe;wt.decorations=m$;wt.outerDecorations=Hfe;wt.atomicRanges=g9;wt.bidiIsolatedRanges=Kfe;wt.scrollMargins=Jfe;wt.darkTheme=I3;wt.cspNonce=Ot.define({combine:e=>e.length?e[0]:""});wt.contentAttributes=m9;wt.editorAttributes=Bfe;wt.lineWrapping=wt.contentAttributes.of({class:"cm-lineWrapping"});wt.announce=Pn.define();const DKe=4096,UI={};class eS{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:br.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 eS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function WI(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&&j3(o,n)}return n}const VKe=at.mac?"mac":at.windows?"win":at.linux?"linux":"key";function MKe(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 Ob(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 LKe=xO.default(wt.domEventHandlers({keydown(e,t){return mhe(phe(t.state),e,t,"editor")}})),GQ=Ot.define({enables:LKe}),YI=new WeakMap;function phe(e){let t=e.facet(GQ),n=YI.get(t);return n||YI.set(t,n=BKe(t.reduce((r,i)=>r.concat(i),[]))),n}function yrn(e,t,n){return mhe(phe(e.state),t,e,n)}let Au=null;const FKe=4e3;function BKe(e,t=VKe){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($=>MKe($,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=Au={view:w,prefix:v,scope:o};return setTimeout(()=>{Au==x&&(Au=null)},FKe),!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,M3))}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 M3=null;function mhe(e,t,n,r){M3=t;let i=yHe(t),a=lo(i,0),o=yc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;Au&&Au.view==n&&Au.scope==r&&(s=Au.prefix+" ",ihe.indexOf(t.keyCode)<0&&(c=!0,Au=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+Ob(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(at.windows&&t.ctrlKey&&t.altKey)&&(p=fO[t.keyCode])&&p!=i?(d(f[s+Ob(p,t,!0)])||t.shiftKey&&(m=h$[t.keyCode])!=i&&m!=p&&d(f[s+Ob(m,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(f[s+Ob(i,t,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),M3=null,l}class Yy{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=ghe(t);return[new Yy(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return HKe(t,n,r)}}function ghe(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==br.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function GI(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 HKe(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==br.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=ghe(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=N3(e,r,1),p=N3(e,i,-1),m=f.type==ba.Text?f:null,g=p.type==ba.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=GI(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=GI(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==ba.Text&&(b.bottom=S.top=(b.bottom+S.top)/2),v(b).concat(Q).concat(v(S))}function $(b,S,Q,P){return new Yy(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(W,N,D,M,B){let Y=e.coordsAtPos(W,W==Q.to?-2:2),A=e.coordsAtPos(D,D==Q.from?2:-2);!Y||!A||(P=Math.min(Y.top,A.top,P),R=Math.max(Y.bottom,A.bottom,R),B==br.LTR?_.push(a&&N?O:Y.left,a&&M?d:A.right):_.push(!a&&M?O:A.left,!a&&N?d:Y.right))}let C=b??Q.from,z=S??Q.to;for(let W of e.visibleRanges)if(W.to>C&&W.from<z)for(let N=Math.max(W.from,C),D=Math.min(W.to,z);;){let M=e.state.doc.lineAt(N);for(let B of e.bidiSpans(M)){let Y=B.from+M.from,A=B.to+M.from;if(Y>=D)break;A>N&&E(Math.max(Y,N),b==null&&Y<=C,Math.min(A,D),S==null&&A>=z,B.dir)}if(N=M.to+1,N>=D)break}return _.length==0&&E(C,b==null,z,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 KKe(e,t){return e.constructor==t.constructor&&e.eq(t)}class JKe{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(Y1)!=t.state.facet(Y1)&&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(Y1);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)=>!KKe(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 Y1=Ot.define();function $he(e){return[hi.define(t=>new JKe(t,e)),Y1.of(e)]}const g$=Ot.define({combine(e){return Om(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function vrn(e={}){return[g$.of(e),eJe,tJe,nJe,Mfe.of(!0)]}function yhe(e){return e.startState.facet(g$)!=e.state.facet(g$)}const eJe=$he({above:!0,markers(e){let{state:t}=e,n=t.facet(g$),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:We.cursor(i.head,i.head>i.anchor?-1:1);for(let l of Yy.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=yhe(e);return n&&NI(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){NI(t.state,e)},class:"cm-cursorLayer"});function NI(e,t){t.style.animationDuration=e.facet(g$).cursorBlinkRate+"ms"}const tJe=$he({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:Yy.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||yhe(e)},class:"cm-selectionLayer"}),nJe=xO.highest(wt.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"}}}})),vhe=Pn.define({map(e,t){return e==null?null:t.mapPos(e)}}),zg=Ia.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(vhe)?r.value:n,e)}}),rJe=hi.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(zg);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(zg)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(zg),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(zg)!=e&&this.view.dispatch({effects:vhe.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 brn(){return[zg,rJe]}function ZI(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 iJe(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 aJe{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 Md,r=n.add.bind(n);for(let{from:i,to:a}of iJe(t,this.maxLength))ZI(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 ZI(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 L3=/x/.unicode!=null?"gu":"g",oJe=new RegExp(`[\0-\b
792
792
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,L3),sJe={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 RT=null;function lJe(){var e;if(RT==null&&typeof document<"u"&&document.body){let t=document.body.style;RT=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return RT||!1}const G1=Ot.define({combine(e){let t=Om(e,{render:null,specialChars:oJe,addSpecialChars:null});return(t.replaceTabs=!lJe())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,L3)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,L3)),t}});function wrn(e={}){return[G1.of(e),cJe()]}let II=null;function cJe(){return II||(II=hi.fromClass(class{constructor(e){this.view=e,this.decorations=cn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(G1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new aJe({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=lo(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=OO(o.text,s,r-o.from);return cn.replace({widget:new fJe((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=cn.replace({widget:new dJe(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(G1);e.startState.facet(G1)!=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 uJe="•";function OJe(e){return e>=32?uJe:e==10?"␤":String.fromCharCode(9216+e)}class dJe extends au{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=OJe(this.code),r=t.state.phrase("Control character")+" "+(sJe[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 fJe extends au{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 Srn(){return pJe}const hJe=cn.line({class:"cm-activeLine"}),pJe=hi.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(hJe.range(i.from)),t=i.from)}return cn.set(n)}},{decorations:e=>e.decorations});class mJe extends au{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?cp(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=Ay(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 xrn(e){let t=hi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?cn.set([cn.widget({widget:new mJe(e),side:1}).range(0)]):cn.none}get decorations(){return this.view.state.doc.length?cn.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,wt.contentAttributes.of({"aria-placeholder":e})]:t}const F3=2e3;function gJe(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>F3||n.off>F3||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(We.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=P3(c.text,o,e.tabSize,!0);if(u<0)a.push(We.cursor(c.to));else{let O=P3(c.text,s,e.tabSize);a.push(We.range(c.from+u,c.from+O))}}}return a}function $Je(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function DI(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>F3?-1:i==r.length?$Je(e,t.clientX):OO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function yJe(e,t){let n=DI(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=DI(e,i);if(!s)return r;let l=gJe(e.state,n,s);return l.length?o?We.create(l.concat(r.ranges)):We.create(l):r}}:null}function Qrn(e){let t=n=>n.altKey&&n.button==0;return wt.mouseSelectionStyle.of((n,r)=>t(r)?yJe(n,r):null)}const vJe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},bJe={style:"cursor: crosshair"};function krn(e={}){let[t,n]=vJe[e.key||"Alt"],r=hi.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,wt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?bJe:null})]}const Vm="-10000px";class bhe{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 wJe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const ET=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)||wJe}}}),VI=new WeakMap,w9=hi.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(ET);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 bhe(e,S9,(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(ET);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=Vm,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==Vm&&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=$9(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(ET).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=Vm;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=(t=VI.get(c))!==null&&t!==void 0?t:d.bottom-d.top,$=c.offset||xJe,v=this.view.textDirection==br.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=Vm;continue}VI.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",MI(u,(w-e.parent.left)/i)):(u.style.top=S/a+"px",MI(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=Vm}},{eventObservers:{scroll(){this.maybeMeasure()}}});function MI(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const SJe=wt.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"}}}),xJe={x:0,y:0},S9=Ot.define({enables:[w9,SJe]}),tS=Ot.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class NQ{static create(t){return new NQ(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new bhe(t,tS,(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 QJe=S9.compute([tS],e=>{let t=e.facet(tS);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:NQ.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class kJe{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 Zu)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==br.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=>ja(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(w9),n=t?t.manager.tooltips.findIndex(r=>r.create==NQ.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&&!PJe(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:!TJe(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 db=4;function PJe(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-db&&t.clientX<=r+db&&t.clientY>=i-db&&t.clientY<=a+db}function TJe(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 Prn(e,t={}){let n=Pn.define(),r=Ia.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,Ci.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(_Je)&&(i=[]);return i},provide:i=>tS.from(i)});return{active:r,extension:[r,hi.define(i=>new kJe(i,e,r,n,t.hoverTime||300)),QJe]}}function whe(e,t){let n=e.plugin(w9);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const _Je=Pn.define(),LI=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 Trn(e,t){let n=e.plugin(She),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const She=hi.fromClass(class{constructor(e){this.input=e.state.facet(BI),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(LI);this.top=new fb(e,!0,t.topContainer),this.bottom=new fb(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(LI);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new fb(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new fb(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(BI);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=>wt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class fb{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=FI(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=FI(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 FI(e){let t=e.nextSibling;return e.remove(),t}const BI=Ot.define({enables:She});class Zc extends Vd{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Zc.prototype.elementClass="";Zc.prototype.toDOM=void 0;Zc.prototype.mapMode=Ci.TrackBefore;Zc.prototype.startSide=Zc.prototype.endSide=-1;Zc.prototype.point=!0;const N1=Ot.define(),XJe=Ot.define(),RJe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>kn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},u0=Ot.define();function EJe(e){return[xhe(),u0.of({...RJe,...e})]}const HI=Ot.define({combine:e=>e.some(t=>t)});function xhe(e){return[qJe]}const qJe=hi.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(u0).map(t=>new JI(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(HI),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(HI)!=!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=kn.iter(this.view.state.facet(N1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new jJe(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==ba.Text&&o){B3(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==ba.Text){B3(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(u0),n=e.state.facet(u0),r=e.docChanged||e.heightChanged||e.viewportChanged||!kn.eq(e.startState.facet(N1),e.state.facet(N1),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 JI(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=>wt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==br.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function KI(e){return Array.isArray(e)?e:[e]}function B3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class jJe{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=kn.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 Qhe(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=[];B3(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(XJe)){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 JI{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=KI(n.markers(t)),n.initialSpacer&&(this.spacer=new Qhe(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=KI(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!kn.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 Qhe{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":""),CJe(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 CJe(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 zJe=Ot.define(),AJe=Ot.define(),Sh=Ot.define({combine(e){return Om(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 qT extends Zc{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function jT(e,t){return e.state.facet(Sh).formatNumber(t,e.state)}const UJe=u0.compute([Sh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(zJe)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new qT(jT(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(AJe)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(Sh)!=t.state.facet(Sh),initialSpacer(t){return new qT(jT(t,eD(t.state.doc.lines)))},updateSpacer(t,n){let r=jT(n.view,eD(n.view.state.doc.lines));return r==t.number?t:new qT(r)},domEventHandlers:e.facet(Sh).domEventHandlers}));function _rn(e={}){return[Sh.of(e),xhe(),UJe]}function eD(e){let t=9;for(;t<e;)t=t*10+9;return t}const WJe=new class extends Zc{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},YJe=N1.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(WJe.range(i)))}return kn.of(t)});function Xrn(){return YJe}let GJe=0;class He{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=GJe++}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 nS(t);return r=>r.modified.indexOf(n)>-1?r:nS.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let NJe=0;class nS{constructor(t){this.name=t,this.instances=[],this.id=NJe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&ZJe(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=IJe(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(nS.get(s,l));return a}}function ZJe(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function IJe(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 jn(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 rS(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return khe.add(t)}const khe=new It;let rS=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}};rS.empty=new rS([],2,null);function Phe(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 DJe(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function VJe(e,t,n,r=0,i=e.length){let a=new MJe(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class MJe{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=LJe(t)||rS.empty,O=DJe(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(It.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 LJe(e){let t=e.type.prop(khe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Le=He.define,hb=Le(),Xu=Le(),tD=Le(Xu),nD=Le(Xu),Ru=Le(),pb=Le(Ru),CT=Le(Ru),il=Le(),IO=Le(il),Ks=Le(),Js=Le(),H3=Le(),Mm=Le(H3),mb=Le(),k={comment:hb,lineComment:Le(hb),blockComment:Le(hb),docComment:Le(hb),name:Xu,variableName:Le(Xu),typeName:tD,tagName:Le(tD),propertyName:nD,attributeName:Le(nD),className:Le(Xu),labelName:Le(Xu),namespace:Le(Xu),macroName:Le(Xu),literal:Ru,string:pb,docString:Le(pb),character:Le(pb),attributeValue:Le(pb),number:CT,integer:Le(CT),float:Le(CT),bool:Le(Ru),regexp:Le(Ru),escape:Le(Ru),color:Le(Ru),url:Le(Ru),keyword:Ks,self:Le(Ks),null:Le(Ks),atom:Le(Ks),unit:Le(Ks),modifier:Le(Ks),operatorKeyword:Le(Ks),controlKeyword:Le(Ks),definitionKeyword:Le(Ks),moduleKeyword:Le(Ks),operator:Js,derefOperator:Le(Js),arithmeticOperator:Le(Js),logicOperator:Le(Js),bitwiseOperator:Le(Js),compareOperator:Le(Js),updateOperator:Le(Js),definitionOperator:Le(Js),typeOperator:Le(Js),controlOperator:Le(Js),punctuation:H3,separator:Le(H3),bracket:Mm,angleBracket:Le(Mm),squareBracket:Le(Mm),paren:Le(Mm),brace:Le(Mm),content:il,heading:IO,heading1:Le(IO),heading2:Le(IO),heading3:Le(IO),heading4:Le(IO),heading5:Le(IO),heading6:Le(IO),contentSeparator:Le(il),list:Le(il),quote:Le(il),emphasis:Le(il),strong:Le(il),link:Le(il),monospace:Le(il),strikethrough:Le(il),inserted:Le(),deleted:Le(),changed:Le(),invalid:Le(),meta:mb,documentMeta:Le(mb),annotation:Le(mb),processingInstruction:Le(mb),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)}Phe([{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 zT;const Du=new It;function ZQ(e){return Ot.define({combine:e?t=>t.concat(e):void 0})}const x9=new It;class mo{constructor(t,n,r=[],i=""){this.data=t,this.name=i,An.prototype.hasOwnProperty("tree")||Object.defineProperty(An.prototype,"tree",{get(){return Dn(this)}}),this.parser=n,this.extension=[pO.of(this),An.languageData.of((a,o,s)=>{let l=rD(a,o,s),c=l.type.prop(Du);if(!c)return[];let u=a.facet(c),O=l.type.prop(x9);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 rD(t,n,r).type.prop(Du)==this.data}findRegions(t){let n=t.facet(pO);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(Du)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(It.mounted);if(s){if(s.tree.prop(Du)==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 mn&&i(c,a.positions[l]+o)}};return i(Dn(t),0),r}get allowsNesting(){return!0}}mo.setState=Pn.define();function rD(e,t,n){let r=e.facet(pO),i=Dn(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,tr.ExcludeBuffers))a.type.isTop&&(i=a);return i}class _n extends mo{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=ZQ(t.languageData);return new _n(n,t.parser.configure({props:[Du.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new _n(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Dn(e){let t=e.field(mo.state,!1);return t?t.tree:mn.empty}class FJe{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 Lm=null;class Hd{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 Hd(t,n,[],mn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new FJe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=mn.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(Rc.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(Rc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Lm;Lm=this;try{return t()}finally{Lm=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=iD(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=Rc.applyChanges(r,l),i=mn.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 Hd(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=iD(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 AQ{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=Lm;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 mn(ei.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 Lm}}function iD(e,t,n){return Rc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class fp{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 fp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Hd.create(t.facet(pO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new fp(r)}}mo.state=Ia.define({create:fp.init,update(e,t){for(let n of t.effects)if(n.is(mo.setState))return n.value;return t.startState.facet(pO)!=t.state.facet(pO)?fp.init(t.state):e.apply(t)}});let The=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(The=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const AT=typeof navigator<"u"&&(!((zT=navigator.scheduling)===null||zT===void 0)&&zT.isInputPending)?()=>navigator.scheduling.isInputPending():null,BJe=hi.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(mo.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(mo.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=The(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(mo.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!AT?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>AT&&AT()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:mo.setState.of(new fp(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=>ja(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()}}}),pO=Ot.define({combine(e){return e.length?e[0]:null},enables:e=>[mo.state,BJe,wt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class xn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class Oe{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 Oe(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 HJe=Ot.define(),IQ=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 iS(e){let t=e.facet(IQ);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function KJe(e,t){let n="",r=e.tabSize,i=e.facet(IQ)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function JJe(e,t){e instanceof An&&(e=new _he(e));for(let r of e.state.facet(HJe)){let i=r(e,t);if(i!==void 0)return i}let n=Dn(e.state);return n.length>=t?eet(e,n,t):null}class _he{constructor(t,n={}){this.state=t,this.options=n,this.unit=iS(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 OO(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 Rr=new It;function eet(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 Xhe(r,e,n)}function Xhe(e,t,n){for(let r=e;r;r=r.next){let i=net(r.node);if(i)return i(Q9.create(t,n,r))}return 0}function tet(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function net(e){let t=e.type.prop(Rr);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(It.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>Rhe(o,!0,1,void 0,a&&!tet(o)?i.from:void 0)}return e.parent==null?ret:null}function ret(){return 0}class Q9 extends _he{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 Q9(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(iet(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Xhe(this.context.next,this.base,this.pos)}}function iet(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function aet(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 Ko({closing:e,align:t=!0,units:n=1}){return r=>Rhe(r,t,n,e)}function Rhe(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?aet(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const k9=e=>e.baseIndent;function Ar({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const oet=200;function qrn(){return An.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+oet)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=JJe(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],f=KJe(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 Ehe=Ot.define(),xr=new It;function ia(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 set(e,t,n){let r=Dn(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(xr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!cet(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function cet(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function aS(e,t,n){for(let r of e.facet(Ehe)){let i=r(e,t,n);if(i)return i}return set(e,t,n)}function qhe(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 DQ=Pn.define({map:qhe}),Gy=Pn.define({map:qhe});function jhe(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 Kd=Ia.define({create(){return cn.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(DQ)&&!uet(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Ahe),i=r?cn.replace({widget:new met(r(t.state,n.value))}):aD;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Gy)&&(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=>wt.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(aD.range(r,i))}return cn.set(t,!0)}});function oS(e,t,n){var r;let i=null;return(r=e.field(Kd,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function uet(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function Che(e,t){return e.field(Kd,!1)?t:t.concat(Pn.appendConfig.of(Uhe()))}const Oet=e=>{for(let t of jhe(e)){let n=aS(e.state,t.from,t.to);if(n)return e.dispatch({effects:Che(e.state,[DQ.of(n),zhe(e,n)])}),!0}return!1},det=e=>{if(!e.state.field(Kd,!1))return!1;let t=[];for(let n of jhe(e)){let r=oS(e.state,n.from,n.to);r&&t.push(Gy.of(r),zhe(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function zhe(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return wt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const fet=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=aS(t,i.from,i.to);a&&n.push(DQ.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Che(e.state,n)}),!!n.length},het=e=>{let t=e.state.field(Kd,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(Gy.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},jrn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Oet},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:det},{key:"Ctrl-Alt-[",run:fet},{key:"Ctrl-Alt-]",run:het}],pet={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ahe=Ot.define({combine(e){return Om(e,pet)}});function Uhe(e){return[Kd,$et]}function Whe(e,t){let{state:n}=e,r=n.facet(Ahe),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=oS(e.state,s.from,s.to);l&&e.dispatch({effects:Gy.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 aD=cn.replace({widget:new class extends au{toDOM(e){return Whe(e,null)}}});class met extends au{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Whe(t,this.value)}}const get={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class UT extends Zc{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 Crn(e={}){let t={...get,...e},n=new UT(t,!0),r=new UT(t,!1),i=hi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(pO)!=o.state.facet(pO)||o.startState.field(Kd,!1)!=o.state.field(Kd,!1)||Dn(o.startState)!=Dn(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new Md;for(let l of o.viewportLineBlocks){let c=oS(o.state,l.from,l.to)?r:aS(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,EJe({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||kn.empty},initialSpacer(){return new UT(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=oS(o.state,s.from,s.to);if(c)return o.dispatch({effects:Gy.of(c)}),!0;let u=aS(o.state,s.from,s.to);return u?(o.dispatch({effects:DQ.of(u)}),!0):!1}}}),Uhe()]}const $et=wt.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 VQ{constructor(t,n){this.specs=t;let r;function i(s){let l=dO.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 mo?s=>s.prop(Du)==o.data:o?s=>s==o:void 0,this.style=Phe(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new dO(r):null,this.themeType=n.themeType}static define(t,n){return new VQ(t,n||{})}}const K3=Ot.define(),Yhe=Ot.define({combine(e){return e.length?[e[0]]:null}});function WT(e){let t=e.facet(K3);return t.length?t:e.facet(Yhe)}function zrn(e,t){let n=[vet],r;return e instanceof VQ&&(e.module&&n.push(wt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Yhe.of(e)):r?n.push(K3.computeN([wt.darkTheme],i=>i.facet(wt.darkTheme)==(r=="dark")?[e]:[])):n.push(K3.of(e)),n}class yet{constructor(t){this.markCache=Object.create(null),this.tree=Dn(t.state),this.decorations=this.buildDeco(t,WT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Dn(t.state),r=WT(t.state),i=r!=WT(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 cn.none;let r=new Md;for(let{from:i,to:a}of t.visibleRanges)VJe(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=cn.mark({class:l})))},i,a);return r.finish()}}const vet=xO.high(hi.fromClass(yet,{decorations:e=>e.decorations})),Arn=VQ.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"}]),bet=wt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Ghe=1e4,Nhe="()[]{}",Zhe=Ot.define({combine(e){return Om(e,{afterCursor:!0,brackets:Nhe,maxScanDistance:Ghe,renderMatch:Qet})}}),wet=cn.mark({class:"cm-matchingBracket"}),xet=cn.mark({class:"cm-nonmatchingBracket"});function Qet(e){let t=[],n=e.matched?wet:xet;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 ket=Ia.define({create(){return cn.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Zhe);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=gb(t.state,i.head,-1,r)||i.head>0&&gb(t.state,i.head-1,1,r)||r.afterCursor&&(gb(t.state,i.head,1,r)||i.head<t.state.doc.length&&gb(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return cn.set(n,!0)},provide:e=>wt.decorations.from(e)}),Pet=[ket,bet];function Urn(e={}){return[Zhe.of(e),Pet]}const P9=new It;function J3(e,t,n){let r=e.prop(t<0?It.openedBy:It.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 ej(e){let t=e.type.prop(P9);return t?t(e.node):e}function gb(e,t,n,r={}){let i=r.maxScanDistance||Ghe,a=r.brackets||Nhe,o=Dn(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=J3(l.type,n,a);if(c&&l.from<l.to){let u=ej(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return Tet(e,t,n,l,u,c,a)}}return _et(e,t,n,o,s.type,i,a)}function Tet(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=ej(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(J3(u.type,n,o))c++;else if(J3(u.type,-n,o)){if(c==0){let O=ej(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 _et(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 oD(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 Ihe{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=oD(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:oD(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 Xet(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Ret,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||_9,mergeTokens:e.mergeTokens!==!1}}function Ret(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 sD=new WeakMap;class Xe extends mo{constructor(t){let n=ZQ(t.languageData),r=Xet(t),i,a=new class extends AQ{createParse(o,s,l){return new qet(i,o,s,l)}};super(n,a,[],t.name),this.topNode=zet(n,this),i=this,this.streamParser=r,this.stateAfter=new It({perNode:!0}),this.tokenTable=t.tokenTable?new Lhe(r.tokenTable):Cet}static define(t){return new Xe(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=sD.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=T9(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 Ihe(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Vhe(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&&sD.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function T9(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 mn&&l<i&&T9(e,s,l,r,i);if(c)return c}return null}function Dhe(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 mn){if(!(l=Dhe(e,s,n-o,r-o,i)))break;return i?new mn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function Eet(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&&T9(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Dhe(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?iS(i):4),tree:mn.empty}}let qet=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=Hd.get(),o=i[0].from,{state:s,tree:l}=Eet(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(iS(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=Hd.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==`
793
793
  `&&(n="");else{let r=n.indexOf(`
794
- `);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 Ihe(n,t?t.state.tabSize:4,t?iS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Vhe(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=mn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:jet,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new mn(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 mn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Vhe(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 _9=Object.create(null),$$=[ei.none],jet=new um($$),lD=[],cD=Object.create(null),Mhe=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"]])Mhe[e]=Fhe(_9,t);class Lhe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Mhe)}resolve(t){return t?this.table[t]||(this.table[t]=Fhe(this.extra,t)):0}}const Cet=new Lhe(_9);function YT(e,t){lD.indexOf(e)>-1||(lD.push(e),console.warn(t))}function Fhe(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):YT(c,`Modifier ${c} used at start of tag`):l.length?YT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:YT(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=cD[i];if(a)return a.id;let o=cD[i]=ei.define({id:$$.length,name:r,props:[jn({[r]:n})]});return $$.push(o),o.id}function zet(e,t){let n=ei.define({id:$$.length,name:"Document",props:[Du.add(()=>e),Rr.add(()=>r=>t.getIndent(r))],top:!0});return $$.push(n),n}br.RTL,br.LTR;function ve(e){return new xn(Xe.define(e))}function bu(e){return de(()=>Promise.resolve().then(()=>out),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Aet=[Oe.of({name:"C",extensions:["c","h","ino"],load(){return de(()=>Promise.resolve().then(()=>eM),void 0,import.meta.url).then(e=>e.cpp())}}),Oe.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return de(()=>Promise.resolve().then(()=>eM),void 0,import.meta.url).then(e=>e.cpp())}}),Oe.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return bu("Cassandra")}}),Oe.of({name:"CSS",extensions:["css"],load(){return de(()=>Promise.resolve().then(()=>brt),void 0,import.meta.url).then(e=>e.css())}}),Oe.of({name:"Go",extensions:["go"],load(){return de(()=>import("./index-CoUIFHSn.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),Oe.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return de(()=>Promise.resolve().then(()=>dit),void 0,import.meta.url).then(e=>e.html())}}),Oe.of({name:"Java",extensions:["java"],load(){return de(()=>Promise.resolve().then(()=>uut),void 0,import.meta.url).then(e=>e.java())}}),Oe.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return de(()=>Promise.resolve().then(()=>bb),void 0,import.meta.url).then(e=>e.javascript())}}),Oe.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return de(()=>Promise.resolve().then(()=>gat),void 0,import.meta.url).then(e=>e.json())}}),Oe.of({name:"JSX",extensions:["jsx"],load(){return de(()=>Promise.resolve().then(()=>bb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Oe.of({name:"LESS",extensions:["less"],load(){return de(()=>Promise.resolve().then(()=>qit),void 0,import.meta.url).then(e=>e.less())}}),Oe.of({name:"Liquid",extensions:["liquid"],load(){return de(()=>Promise.resolve().then(()=>Fdt),void 0,import.meta.url).then(e=>e.liquid())}}),Oe.of({name:"MariaDB SQL",load(){return bu("MariaSQL")}}),Oe.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return de(()=>Promise.resolve().then(()=>wit),void 0,import.meta.url).then(e=>e.markdown())}}),Oe.of({name:"MS SQL",load(){return bu("MSSQL")}}),Oe.of({name:"MySQL",load(){return bu("MySQL")}}),Oe.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return de(()=>Promise.resolve().then(()=>kdt),void 0,import.meta.url).then(e=>e.php())}}),Oe.of({name:"PLSQL",extensions:["pls"],load(){return bu("PLSQL")}}),Oe.of({name:"PostgreSQL",load(){return bu("PostgreSQL")}}),Oe.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return de(()=>Promise.resolve().then(()=>Flt),void 0,import.meta.url).then(e=>e.python())}}),Oe.of({name:"Rust",extensions:["rs"],load(){return de(()=>Promise.resolve().then(()=>Xut),void 0,import.meta.url).then(e=>e.rust())}}),Oe.of({name:"Sass",extensions:["sass"],load(){return de(()=>Promise.resolve().then(()=>pV),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),Oe.of({name:"SCSS",extensions:["scss"],load(){return de(()=>Promise.resolve().then(()=>pV),void 0,import.meta.url).then(e=>e.sass())}}),Oe.of({name:"SQL",extensions:["sql"],load(){return bu("StandardSQL")}}),Oe.of({name:"SQLite",load(){return bu("SQLite")}}),Oe.of({name:"TSX",extensions:["tsx"],load(){return de(()=>Promise.resolve().then(()=>bb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Oe.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return de(()=>Promise.resolve().then(()=>bb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Oe.of({name:"WebAssembly",extensions:["wat","wast"],load(){return de(()=>Promise.resolve().then(()=>Kdt),void 0,import.meta.url).then(e=>e.wast())}}),Oe.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return de(()=>Promise.resolve().then(()=>gct),void 0,import.meta.url).then(e=>e.xml())}}),Oe.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return de(()=>import("./index-UUykMdEe.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),Oe.of({name:"APL",extensions:["dyalog","apl"],load(){return de(()=>Promise.resolve().then(()=>Ppt),void 0,import.meta.url).then(e=>ve(e.apl))}}),Oe.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return de(()=>Promise.resolve().then(()=>Tpt),void 0,import.meta.url).then(e=>ve(e.asciiArmor))}}),Oe.of({name:"ASN.1",extensions:["asn","asn1"],load(){return de(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>ve(e.asn1({})))}}),Oe.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return de(()=>Promise.resolve().then(()=>qpt),void 0,import.meta.url).then(e=>ve(e.asterisk))}}),Oe.of({name:"Brainfuck",extensions:["b","bf"],load(){return de(()=>Promise.resolve().then(()=>Cpt),void 0,import.meta.url).then(e=>ve(e.brainfuck))}}),Oe.of({name:"Cobol",extensions:["cob","cpy"],load(){return de(()=>Promise.resolve().then(()=>cmt),void 0,import.meta.url).then(e=>ve(e.cobol))}}),Oe.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.csharp))}}),Oe.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ve(e.clojure))}}),Oe.of({name:"ClojureScript",extensions:["cljs"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ve(e.clojure))}}),Oe.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return de(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>ve(e.gss))}}),Oe.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return de(()=>Promise.resolve().then(()=>emt),void 0,import.meta.url).then(e=>ve(e.cmake))}}),Oe.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return de(()=>Promise.resolve().then(()=>wmt),void 0,import.meta.url).then(e=>ve(e.coffeeScript))}}),Oe.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return de(()=>Promise.resolve().then(()=>Tmt),void 0,import.meta.url).then(e=>ve(e.commonLisp))}}),Oe.of({name:"Cypher",extensions:["cyp","cypher"],load(){return de(()=>Promise.resolve().then(()=>Vmt),void 0,import.meta.url).then(e=>ve(e.cypher))}}),Oe.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return de(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>ve(e.cython))}}),Oe.of({name:"Crystal",extensions:["cr"],load(){return de(()=>Promise.resolve().then(()=>Ymt),void 0,import.meta.url).then(e=>ve(e.crystal))}}),Oe.of({name:"D",extensions:["d"],load(){return de(()=>Promise.resolve().then(()=>Jmt),void 0,import.meta.url).then(e=>ve(e.d))}}),Oe.of({name:"Dart",extensions:["dart"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.dart))}}),Oe.of({name:"diff",extensions:["diff","patch"],load(){return de(()=>Promise.resolve().then(()=>egt),void 0,import.meta.url).then(e=>ve(e.diff))}}),Oe.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return de(()=>Promise.resolve().then(()=>fgt),void 0,import.meta.url).then(e=>ve(e.dockerFile))}}),Oe.of({name:"DTD",extensions:["dtd"],load(){return de(()=>Promise.resolve().then(()=>mgt),void 0,import.meta.url).then(e=>ve(e.dtd))}}),Oe.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return de(()=>Promise.resolve().then(()=>bgt),void 0,import.meta.url).then(e=>ve(e.dylan))}}),Oe.of({name:"EBNF",load(){return de(()=>Promise.resolve().then(()=>wgt),void 0,import.meta.url).then(e=>ve(e.ebnf))}}),Oe.of({name:"ECL",extensions:["ecl"],load(){return de(()=>Promise.resolve().then(()=>Xgt),void 0,import.meta.url).then(e=>ve(e.ecl))}}),Oe.of({name:"edn",extensions:["edn"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ve(e.clojure))}}),Oe.of({name:"Eiffel",extensions:["e"],load(){return de(()=>Promise.resolve().then(()=>zgt),void 0,import.meta.url).then(e=>ve(e.eiffel))}}),Oe.of({name:"Elm",extensions:["elm"],load(){return de(()=>Promise.resolve().then(()=>Mgt),void 0,import.meta.url).then(e=>ve(e.elm))}}),Oe.of({name:"Erlang",extensions:["erl"],load(){return de(()=>Promise.resolve().then(()=>g0t),void 0,import.meta.url).then(e=>ve(e.erlang))}}),Oe.of({name:"Esper",load(){return de(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>ve(e.esper))}}),Oe.of({name:"Factor",extensions:["factor"],load(){return de(()=>Promise.resolve().then(()=>$0t),void 0,import.meta.url).then(e=>ve(e.factor))}}),Oe.of({name:"FCL",load(){return de(()=>Promise.resolve().then(()=>S0t),void 0,import.meta.url).then(e=>ve(e.fcl))}}),Oe.of({name:"Forth",extensions:["forth","fth","4th"],load(){return de(()=>Promise.resolve().then(()=>k0t),void 0,import.meta.url).then(e=>ve(e.forth))}}),Oe.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return de(()=>Promise.resolve().then(()=>q0t),void 0,import.meta.url).then(e=>ve(e.fortran))}}),Oe.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ve(e.fSharp))}}),Oe.of({name:"Gas",extensions:["s"],load(){return de(()=>Promise.resolve().then(()=>C0t),void 0,import.meta.url).then(e=>ve(e.gas))}}),Oe.of({name:"Gherkin",extensions:["feature"],load(){return de(()=>Promise.resolve().then(()=>z0t),void 0,import.meta.url).then(e=>ve(e.gherkin))}}),Oe.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return de(()=>Promise.resolve().then(()=>M0t),void 0,import.meta.url).then(e=>ve(e.groovy))}}),Oe.of({name:"Haskell",extensions:["hs"],load(){return de(()=>Promise.resolve().then(()=>e$t),void 0,import.meta.url).then(e=>ve(e.haskell))}}),Oe.of({name:"Haxe",extensions:["hx"],load(){return de(()=>Promise.resolve().then(()=>SL),void 0,import.meta.url).then(e=>ve(e.haxe))}}),Oe.of({name:"HXML",extensions:["hxml"],load(){return de(()=>Promise.resolve().then(()=>SL),void 0,import.meta.url).then(e=>ve(e.hxml))}}),Oe.of({name:"HTTP",load(){return de(()=>Promise.resolve().then(()=>S$t),void 0,import.meta.url).then(e=>ve(e.http))}}),Oe.of({name:"IDL",extensions:["pro"],load(){return de(()=>Promise.resolve().then(()=>X$t),void 0,import.meta.url).then(e=>ve(e.idl))}}),Oe.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return de(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>ve(e.jsonld))}}),Oe.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return de(()=>Promise.resolve().then(()=>j$t),void 0,import.meta.url).then(e=>ve(e.jinja2))}}),Oe.of({name:"Julia",extensions:["jl"],load(){return de(()=>Promise.resolve().then(()=>ayt),void 0,import.meta.url).then(e=>ve(e.julia))}}),Oe.of({name:"Kotlin",extensions:["kt","kts"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.kotlin))}}),Oe.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return de(()=>Promise.resolve().then(()=>cyt),void 0,import.meta.url).then(e=>ve(e.liveScript))}}),Oe.of({name:"Lua",extensions:["lua"],load(){return de(()=>Promise.resolve().then(()=>gyt),void 0,import.meta.url).then(e=>ve(e.lua))}}),Oe.of({name:"mIRC",extensions:["mrc"],load(){return de(()=>Promise.resolve().then(()=>Yyt),void 0,import.meta.url).then(e=>ve(e.mirc))}}),Oe.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return de(()=>Promise.resolve().then(()=>Qyt),void 0,import.meta.url).then(e=>ve(e.mathematica))}}),Oe.of({name:"Modelica",extensions:["mo"],load(){return de(()=>Promise.resolve().then(()=>Byt),void 0,import.meta.url).then(e=>ve(e.modelica))}}),Oe.of({name:"MUMPS",extensions:["mps"],load(){return de(()=>Promise.resolve().then(()=>dvt),void 0,import.meta.url).then(e=>ve(e.mumps))}}),Oe.of({name:"Mbox",extensions:["mbox"],load(){return de(()=>Promise.resolve().then(()=>Ayt),void 0,import.meta.url).then(e=>ve(e.mbox))}}),Oe.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return de(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>ve(e.nginx))}}),Oe.of({name:"NSIS",extensions:["nsh","nsi"],load(){return de(()=>Promise.resolve().then(()=>$vt),void 0,import.meta.url).then(e=>ve(e.nsis))}}),Oe.of({name:"NTriples",extensions:["nt","nq"],load(){return de(()=>Promise.resolve().then(()=>yvt),void 0,import.meta.url).then(e=>ve(e.ntriples))}}),Oe.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.objectiveC))}}),Oe.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.objectiveCpp))}}),Oe.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ve(e.oCaml))}}),Oe.of({name:"Octave",extensions:["m"],load(){return de(()=>Promise.resolve().then(()=>Xvt),void 0,import.meta.url).then(e=>ve(e.octave))}}),Oe.of({name:"Oz",extensions:["oz"],load(){return de(()=>Promise.resolve().then(()=>Nvt),void 0,import.meta.url).then(e=>ve(e.oz))}}),Oe.of({name:"Pascal",extensions:["p","pas"],load(){return de(()=>Promise.resolve().then(()=>Lvt),void 0,import.meta.url).then(e=>ve(e.pascal))}}),Oe.of({name:"Perl",extensions:["pl","pm"],load(){return de(()=>Promise.resolve().then(()=>Fvt),void 0,import.meta.url).then(e=>ve(e.perl))}}),Oe.of({name:"Pig",extensions:["pig"],load(){return de(()=>Promise.resolve().then(()=>Kvt),void 0,import.meta.url).then(e=>ve(e.pig))}}),Oe.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return de(()=>Promise.resolve().then(()=>hbt),void 0,import.meta.url).then(e=>ve(e.powerShell))}}),Oe.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return de(()=>Promise.resolve().then(()=>pbt),void 0,import.meta.url).then(e=>ve(e.properties))}}),Oe.of({name:"ProtoBuf",extensions:["proto"],load(){return de(()=>Promise.resolve().then(()=>vbt),void 0,import.meta.url).then(e=>ve(e.protobuf))}}),Oe.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return de(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>ve(e.pug))}}),Oe.of({name:"Puppet",extensions:["pp"],load(){return de(()=>Promise.resolve().then(()=>Sbt),void 0,import.meta.url).then(e=>ve(e.puppet))}}),Oe.of({name:"Q",extensions:["q"],load(){return de(()=>Promise.resolve().then(()=>Rbt),void 0,import.meta.url).then(e=>ve(e.q))}}),Oe.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return de(()=>Promise.resolve().then(()=>Ubt),void 0,import.meta.url).then(e=>ve(e.r))}}),Oe.of({name:"RPM Changes",load(){return de(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ve(e.rpmChanges))}}),Oe.of({name:"RPM Spec",extensions:["spec"],load(){return de(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ve(e.rpmSpec))}}),Oe.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return de(()=>Promise.resolve().then(()=>Mbt),void 0,import.meta.url).then(e=>ve(e.ruby))}}),Oe.of({name:"SAS",extensions:["sas"],load(){return de(()=>Promise.resolve().then(()=>Hbt),void 0,import.meta.url).then(e=>ve(e.sas))}}),Oe.of({name:"Scala",extensions:["scala"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.scala))}}),Oe.of({name:"Scheme",extensions:["scm","ss"],load(){return de(()=>Promise.resolve().then(()=>u1t),void 0,import.meta.url).then(e=>ve(e.scheme))}}),Oe.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return de(()=>Promise.resolve().then(()=>h1t),void 0,import.meta.url).then(e=>ve(e.shell))}}),Oe.of({name:"Sieve",extensions:["siv","sieve"],load(){return de(()=>Promise.resolve().then(()=>y1t),void 0,import.meta.url).then(e=>ve(e.sieve))}}),Oe.of({name:"Smalltalk",extensions:["st"],load(){return de(()=>Promise.resolve().then(()=>w1t),void 0,import.meta.url).then(e=>ve(e.smalltalk))}}),Oe.of({name:"Solr",load(){return de(()=>Promise.resolve().then(()=>_1t),void 0,import.meta.url).then(e=>ve(e.solr))}}),Oe.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ve(e.sml))}}),Oe.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return de(()=>Promise.resolve().then(()=>z1t),void 0,import.meta.url).then(e=>ve(e.sparql))}}),Oe.of({name:"Spreadsheet",alias:["excel","formula"],load(){return de(()=>Promise.resolve().then(()=>A1t),void 0,import.meta.url).then(e=>ve(e.spreadsheet))}}),Oe.of({name:"Squirrel",extensions:["nut"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.squirrel))}}),Oe.of({name:"Stylus",extensions:["styl"],load(){return de(()=>Promise.resolve().then(()=>awt),void 0,import.meta.url).then(e=>ve(e.stylus))}}),Oe.of({name:"Swift",extensions:["swift"],load(){return de(()=>Promise.resolve().then(()=>Qwt),void 0,import.meta.url).then(e=>ve(e.swift))}}),Oe.of({name:"sTeX",load(){return de(()=>Promise.resolve().then(()=>hF),void 0,import.meta.url).then(e=>ve(e.stex))}}),Oe.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return de(()=>Promise.resolve().then(()=>hF),void 0,import.meta.url).then(e=>ve(e.stex))}}),Oe.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return de(()=>Promise.resolve().then(()=>jF),void 0,import.meta.url).then(e=>ve(e.verilog))}}),Oe.of({name:"Tcl",extensions:["tcl"],load(){return de(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>ve(e.tcl))}}),Oe.of({name:"Textile",extensions:["textile"],load(){return de(()=>Promise.resolve().then(()=>qwt),void 0,import.meta.url).then(e=>ve(e.textile))}}),Oe.of({name:"TiddlyWiki",load(){return de(()=>Promise.resolve().then(()=>eSt),void 0,import.meta.url).then(e=>ve(e.tiddlyWiki))}}),Oe.of({name:"Tiki wiki",load(){return de(()=>Promise.resolve().then(()=>sSt),void 0,import.meta.url).then(e=>ve(e.tiki))}}),Oe.of({name:"TOML",extensions:["toml"],load(){return de(()=>Promise.resolve().then(()=>lSt),void 0,import.meta.url).then(e=>ve(e.toml))}}),Oe.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return de(()=>Promise.resolve().then(()=>OSt),void 0,import.meta.url).then(e=>ve(e.troff))}}),Oe.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return de(()=>Promise.resolve().then(()=>_St),void 0,import.meta.url).then(e=>ve(e.ttcn))}}),Oe.of({name:"TTCN_CFG",extensions:["cfg"],load(){return de(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>ve(e.ttcnCfg))}}),Oe.of({name:"Turtle",extensions:["ttl"],load(){return de(()=>Promise.resolve().then(()=>ESt),void 0,import.meta.url).then(e=>ve(e.turtle))}}),Oe.of({name:"Web IDL",extensions:["webidl"],load(){return de(()=>Promise.resolve().then(()=>Qxt),void 0,import.meta.url).then(e=>ve(e.webIDL))}}),Oe.of({name:"VB.NET",extensions:["vb"],load(){return de(()=>Promise.resolve().then(()=>MSt),void 0,import.meta.url).then(e=>ve(e.vb))}}),Oe.of({name:"VBScript",extensions:["vbs"],load(){return de(()=>Promise.resolve().then(()=>FSt),void 0,import.meta.url).then(e=>ve(e.vbScript))}}),Oe.of({name:"Velocity",extensions:["vtl"],load(){return de(()=>Promise.resolve().then(()=>KSt),void 0,import.meta.url).then(e=>ve(e.velocity))}}),Oe.of({name:"Verilog",extensions:["v"],load(){return de(()=>Promise.resolve().then(()=>jF),void 0,import.meta.url).then(e=>ve(e.verilog))}}),Oe.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return de(()=>Promise.resolve().then(()=>sxt),void 0,import.meta.url).then(e=>ve(e.vhdl))}}),Oe.of({name:"XQuery",extensions:["xy","xquery"],load(){return de(()=>Promise.resolve().then(()=>Cxt),void 0,import.meta.url).then(e=>ve(e.xQuery))}}),Oe.of({name:"Yacas",extensions:["ys"],load(){return de(()=>Promise.resolve().then(()=>Dxt),void 0,import.meta.url).then(e=>ve(e.yacas))}}),Oe.of({name:"Z80",extensions:["z80"],load(){return de(()=>Promise.resolve().then(()=>Bxt),void 0,import.meta.url).then(e=>ve(e.z80))}}),Oe.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return de(()=>Promise.resolve().then(()=>V_),void 0,import.meta.url).then(e=>ve(e.mscgen))}}),Oe.of({name:"Xù",extensions:["xu"],load(){return de(()=>Promise.resolve().then(()=>V_),void 0,import.meta.url).then(e=>ve(e.xu))}}),Oe.of({name:"MsGenny",extensions:["msgenny"],load(){return de(()=>Promise.resolve().then(()=>V_),void 0,import.meta.url).then(e=>ve(e.msgenny))}}),Oe.of({name:"Vue",extensions:["vue"],load(){return de(()=>Promise.resolve().then(()=>oft),void 0,import.meta.url).then(e=>e.vue())}}),Oe.of({name:"Angular Template",load(){return de(()=>Promise.resolve().then(()=>Qft),void 0,import.meta.url).then(e=>e.angular())}})];class X9{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=Dn(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(Bhe(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 uD(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 Uet(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=uD(t)+uD(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Ny(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Uet(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function MQ(e,t){return n=>{for(let r=Dn(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 OD{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function _d(e){return e.selection.main.from}function Bhe(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 R9=yf.define();function Wet(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:We.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const dD=new WeakMap;function Yet(e){if(!Array.isArray(e))return e;let t=dD.get(e);return t||dD.set(e,t=Ny(e)),t}const sS=Pn.define(),y$=Pn.define();class Get{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=lo(t,n),i=yc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(lo(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=lo(t,0),w=yc(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=lo(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=yc(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=lo(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=sfe(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+=yc(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?yc(lo(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 Net{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 Qi=Ot.define({combine(e){return Om(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:Zet,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=>fD(t(r),n(r)),optionClass:(t,n)=>r=>fD(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function fD(e,t){return e?t?e+" "+t:e:t}function Zet(e,t,n,r,i,a){let o=e.textDirection==br.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 Iet(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 GT(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 Det{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(Qi);this.optionContent=Iet(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=GT(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(Qi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:y$.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=GT(a.length,o,t.state.facet(Qi).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=GT(n.options.length,n.selected,this.view.state.facet(Qi).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=>ja(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&&Met(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(Qi).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 Vet(e,t){return n=>new Det(n,e,t)}function Met(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 hD(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Let(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(Qi);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 OD(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Net(O):new Get(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 OD(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):hD(c.completion)>hD(s)&&(o[o.length-1]=c),s=c.completion}return o}class xh{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 xh(this.options,pD(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=Let(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Qi).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 xh(s,pD(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:ett,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new xh(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 xh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class lS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new lS(Ket,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Qi),a=(r.override||n.languageDataAt("autocomplete",_d(n)).map(Yet)).map(l=>(this.active.find(u=>u.source==l)||new Lo(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(E9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Fet(a,this.active)||s?o=xh.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 Lo(l.source,0):l));for(let l of t.effects)l.is(Khe)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new lS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Bet:Het}}function Fet(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 Bet={"aria-autocomplete":"list"},Het={};function pD(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Ket=[];function Hhe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(R9);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 Lo{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=Hhe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Lo(i.source,0)),r&4&&i.state==0&&(i=new Lo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(sS))i=new Lo(i.source,1,a.value);else if(a.is(y$))i=new Lo(i.source,0);else if(a.is(E9))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(_d(t.state))}}class Ih extends Lo{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=_d(t.state);if(s>o||!i||n&2&&(_d(t.startState)==this.from||s<this.limit))return new Lo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Jet(i.validFor,t.state,a,o)?new Ih(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new X9(t.state,s,!1)))?new Ih(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:_d(t.state)):new Lo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Ih(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Lo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Jet(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Bhe(e,!0).test(i)}const E9=Pn.define({map(e,t){return e.map(n=>n.map(t))}}),Khe=Pn.define(),Ea=Ia.define({create(){return lS.start()},update(e,t){return e.update(t)},provide:e=>[S9.from(e,t=>t.tooltip),wt.contentAttributes.from(e,t=>t.attrs)]});function q9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ea).active.find(i=>i.source==t.source);return r instanceof Ih?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Wet(e.state,n,r.from,r.to)),{annotations:R9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const ett=Vet(Ea,q9);function $b(e,t="option"){return n=>{let r=n.state.field(Ea,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Qi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=whe(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:Khe.of(s)}),!0}}const ttt=e=>{let t=e.state.field(Ea,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Qi).interactionDelay?!1:q9(e,t.open.options[t.open.selected])},mD=e=>e.state.field(Ea,!1)?(e.dispatch({effects:sS.of(!0)}),!0):!1,ntt=e=>{let t=e.state.field(Ea,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:y$.of(null)}),!0)};class rtt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const itt=50,att=1e3,ott=hi.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(Ea).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ea),n=e.state.facet(Qi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ea)==t)return;let r=e.transactions.some(a=>{let o=Hhe(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>itt&&Date.now()-o.time>att){for(let s of o.context.abortListeners)try{s()}catch(l){ja(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(sS)))&&(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(Ea);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(Qi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=_d(t),r=new X9(t,n,e.explicit,this.view),i=new rtt(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:y$.of(null)}),ja(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(Qi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Qi),r=this.view.state.field(Ea);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=_d(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Ih(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 Lo(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:E9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ea,!1);if(t&&t.tooltip&&this.view.state.facet(Qi).closeOnBlur){let n=t.open&&whe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:y$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:sS.of(!1)}),20),this.composing=0}}}),stt=typeof navigator=="object"&&/Win/.test(navigator.platform),ltt=xO.highest(wt.domEventHandlers({keydown(e,t){let n=t.state.field(Ea,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(stt&&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&&q9(t,r),!1}})),Jhe=wt.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 ctt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class j9{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ci.TrackDel),r=t.mapPos(this.to,1,Ci.TrackDel);return n==null||r==null?null:new j9(this.field,n,r)}}class C9{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(IQ);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 j9(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 ctt(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 C9(r,i)}}let utt=cn.widget({widget:new class extends au{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Ott=cn.mark({class:"cm-snippetField"});class dm{constructor(t,n){this.ranges=t,this.active=n,this.deco=cn.set(t.map(r=>(r.from==r.to?utt:Ott).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 dm(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 Zy=Pn.define({map(e,t){return e&&e.map(t)}}),dtt=Pn.define(),v$=Ia.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Zy))return n.value;if(n.is(dtt)&&e)return new dm(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=>wt.decorations.from(e,t=>t?t.deco:cn.none)});function z9(e,t){return We.create(e.filter(n=>n.field==t).map(n=>We.range(n.from,n.to)))}function ftt(e){let t=C9.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:In.of(o)},scrollIntoView:!0,annotations:r?[R9.of(r),Ai.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=z9(s,0)),s.some(u=>u.field>0)){let u=new dm(s,0),O=c.effects=[Zy.of(u)];n.state.field(v$,!1)===void 0&&O.push(Pn.appendConfig.of([v$,$tt,ytt,Jhe]))}n.dispatch(n.state.update(c))}}function epe(e){return({state:t,dispatch:n})=>{let r=t.field(v$,!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:z9(r.ranges,i),effects:Zy.of(a?null:new dm(r.ranges,i)),scrollIntoView:!0})),!0}}const htt=({state:e,dispatch:t})=>e.field(v$,!1)?(t(e.update({effects:Zy.of(null)})),!0):!1,ptt=epe(1),mtt=epe(-1),gtt=[{key:"Tab",run:ptt,shift:mtt},{key:"Escape",run:htt}],gD=Ot.define({combine(e){return e.length?e[0]:gtt}}),$tt=xO.highest(GQ.compute([gD],e=>e.facet(gD)));function hr(e,t){return Object.assign(Object.assign({},t),{apply:ftt(e)})}const ytt=wt.domEventHandlers({mousedown(e,t){let n=t.state.field(v$,!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:z9(n.ranges,i.field),effects:Zy.of(n.ranges.some(a=>a.field>i.field)?new dm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),b$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},pd=Pn.define({map(e,t){let n=t.mapPos(e,-1,Ci.TrackAfter);return n??void 0}}),A9=new class extends Vd{};A9.startSide=1;A9.endSide=-1;const tpe=Ia.define({create(){return kn.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(pd)&&(e=e.update({add:[A9.range(n.value,n.value+1)]}));return e}});function Yrn(){return[btt,tpe]}const NT="()[]{}<>«»»«[]{}";function npe(e){for(let t=0;t<NT.length;t+=2)if(NT.charCodeAt(t)==e)return NT.charAt(t+1);return sfe(e<128?e:e+1)}function rpe(e,t){return e.languageDataAt("closeBrackets",t)[0]||b$}const vtt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),btt=wt.inputHandler.of((e,t,n,r)=>{if((vtt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&yc(lo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Stt(e.state,r);return a?(e.dispatch(a),!0):!1}),wtt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=rpe(e,e.selection.main.head).brackets||b$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=xtt(e.doc,o.head);for(let l of r)if(l==s&&LQ(e.doc,o.head)==npe(lo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:We.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Grn=[{key:"Backspace",run:wtt}];function Stt(e,t){let n=rpe(e,e.selection.main.head),r=n.brackets||b$.brackets;for(let i of r){let a=npe(lo(i,0));if(t==i)return a==i?Ptt(e,i,r.indexOf(i+i+i)>-1,n):Qtt(e,i,a,n.before||b$.before);if(t==a&&ipe(e,e.selection.main.from))return ktt(e,i,a)}return null}function ipe(e,t){let n=!1;return e.field(tpe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function LQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,yc(lo(n,0)))}function xtt(e,t){let n=e.sliceString(t-2,t);return yc(lo(n,0))==n.length?n:n.slice(1)}function Qtt(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:pd.of(o.to+t.length),range:We.range(o.anchor+t.length,o.head+t.length)};let s=LQ(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:pd.of(o.head+t.length),range:We.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function ktt(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&LQ(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:We.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function Ptt(e,t,n,r){let i=r.stringPrefixes||b$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:pd.of(s.to+t.length),range:We.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=LQ(e.doc,l),u;if(c==t){if($D(e,l))return{changes:{insert:t+t,from:l},effects:pd.of(l+t.length),range:We.cursor(l+t.length)};if(ipe(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:We.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=yD(e,l-2*t.length,i))>-1&&$D(e,u))return{changes:{insert:t+t+t+t,from:l},effects:pd.of(l+t.length),range:We.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Mo.Word&&yD(e,l,i)>-1&&!Ttt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:pd.of(l+t.length),range:We.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function $D(e,t){let n=Dn(e).resolveInner(t+1);return n.parent&&n.from==t}function Ttt(e,t,n,r){let i=Dn(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 yD(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Mo.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))!=Mo.Word)return a}return-1}function Nrn(e={}){return[ltt,Ea,Qi.of(e),ott,Xtt,Jhe]}const _tt=[{key:"Ctrl-Space",run:mD},{mac:"Alt-`",run:mD},{key:"Escape",run:ntt},{key:"ArrowDown",run:$b(!0)},{key:"ArrowUp",run:$b(!1)},{key:"PageDown",run:$b(!0,"page")},{key:"PageUp",run:$b(!1,"page")},{key:"Enter",run:ttt}],Xtt=xO.highest(GQ.computeN([Qi],e=>e.facet(Qi).defaultKeymap?[_tt]:[]));class cS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new cS(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=[[It.contextHash,i]]}addChild(t,n){t.prop(It.contextHash)!=this.hash&&(t=new mn(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 mn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new mn(ei.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 Rtt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Ett=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 O0(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 vD(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?Y9:W9)(n,t,!1);return r>0&&(e.type!=Ne.BulletList||U9(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const ape={[Ne.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(wn(Ne.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(us(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]:vD,[Ne.BulletList]:vD,[Ne.Document](){return!0}};function us(e){return e==32||e==9||e==10||e==13}function O0(e,t=0){for(;t<e.length&&us(e.charCodeAt(t));)t++;return t}function bD(e,t,n){for(;t>n&&us(e.charCodeAt(t-1));)t--;return t}function ope(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 spe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function U9(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(!us(a))return-1}return n&&e.next==45&&upe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(hpe.SetextHeading)>-1||r<3?-1:1}function lpe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function W9(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||us(e.text.charCodeAt(e.pos+1)))&&(!n||lpe(t,Ne.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Y9(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&&!us(e.text.charCodeAt(r+1))||n&&!lpe(t,Ne.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function cpe(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 upe(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&&us(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const tj=/^[ \t]*$/,Ope=/-->/,dpe=/\?>/,nj=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Ope],[/^\s*<\?/,dpe],[/^\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,tj],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,tj]];function fpe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=nj.length-(n?1:0);i<a;i++)if(nj[i][0].test(r))return i;return-1}function wD(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 DO(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(wn(Ne.CodeText,t,n))}const yb={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(DO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){DO(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?DO(o,c.from,c.to):o.push(c);s=[]}DO(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&&DO(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=ope(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=bD(t.text,t.text.length,o),l=[wn(Ne.CodeMark,r,r+a)];o<s&&l.push(wn(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(wn(Ne.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||DO(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&&DO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ne.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=spe(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(U9(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=W9(t,e,!1);if(n<0)return!1;e.block.type!=Ne.BulletList&&e.startContext(Ne.BulletList,t.basePos,t.next);let r=wD(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=Y9(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=wD(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=cpe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=bD(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!us(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=fpe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=nj[n][1],a=[],o=i!=tj;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==Ope?Ne.CommentBlock:i==dpe?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 qtt{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+`
794
+ `);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 Ihe(n,t?t.state.tabSize:4,t?iS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Vhe(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=mn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:jet,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new mn(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 mn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Vhe(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 _9=Object.create(null),$$=[ei.none],jet=new um($$),lD=[],cD=Object.create(null),Mhe=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"]])Mhe[e]=Fhe(_9,t);class Lhe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Mhe)}resolve(t){return t?this.table[t]||(this.table[t]=Fhe(this.extra,t)):0}}const Cet=new Lhe(_9);function YT(e,t){lD.indexOf(e)>-1||(lD.push(e),console.warn(t))}function Fhe(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):YT(c,`Modifier ${c} used at start of tag`):l.length?YT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:YT(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=cD[i];if(a)return a.id;let o=cD[i]=ei.define({id:$$.length,name:r,props:[jn({[r]:n})]});return $$.push(o),o.id}function zet(e,t){let n=ei.define({id:$$.length,name:"Document",props:[Du.add(()=>e),Rr.add(()=>r=>t.getIndent(r))],top:!0});return $$.push(n),n}br.RTL,br.LTR;function ve(e){return new xn(Xe.define(e))}function bu(e){return de(()=>Promise.resolve().then(()=>out),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Aet=[Oe.of({name:"C",extensions:["c","h","ino"],load(){return de(()=>Promise.resolve().then(()=>eM),void 0,import.meta.url).then(e=>e.cpp())}}),Oe.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return de(()=>Promise.resolve().then(()=>eM),void 0,import.meta.url).then(e=>e.cpp())}}),Oe.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return bu("Cassandra")}}),Oe.of({name:"CSS",extensions:["css"],load(){return de(()=>Promise.resolve().then(()=>brt),void 0,import.meta.url).then(e=>e.css())}}),Oe.of({name:"Go",extensions:["go"],load(){return de(()=>import("./index-BcrGfet8.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),Oe.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return de(()=>Promise.resolve().then(()=>dit),void 0,import.meta.url).then(e=>e.html())}}),Oe.of({name:"Java",extensions:["java"],load(){return de(()=>Promise.resolve().then(()=>uut),void 0,import.meta.url).then(e=>e.java())}}),Oe.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return de(()=>Promise.resolve().then(()=>bb),void 0,import.meta.url).then(e=>e.javascript())}}),Oe.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return de(()=>Promise.resolve().then(()=>gat),void 0,import.meta.url).then(e=>e.json())}}),Oe.of({name:"JSX",extensions:["jsx"],load(){return de(()=>Promise.resolve().then(()=>bb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Oe.of({name:"LESS",extensions:["less"],load(){return de(()=>Promise.resolve().then(()=>qit),void 0,import.meta.url).then(e=>e.less())}}),Oe.of({name:"Liquid",extensions:["liquid"],load(){return de(()=>Promise.resolve().then(()=>Fdt),void 0,import.meta.url).then(e=>e.liquid())}}),Oe.of({name:"MariaDB SQL",load(){return bu("MariaSQL")}}),Oe.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return de(()=>Promise.resolve().then(()=>wit),void 0,import.meta.url).then(e=>e.markdown())}}),Oe.of({name:"MS SQL",load(){return bu("MSSQL")}}),Oe.of({name:"MySQL",load(){return bu("MySQL")}}),Oe.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return de(()=>Promise.resolve().then(()=>kdt),void 0,import.meta.url).then(e=>e.php())}}),Oe.of({name:"PLSQL",extensions:["pls"],load(){return bu("PLSQL")}}),Oe.of({name:"PostgreSQL",load(){return bu("PostgreSQL")}}),Oe.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return de(()=>Promise.resolve().then(()=>Flt),void 0,import.meta.url).then(e=>e.python())}}),Oe.of({name:"Rust",extensions:["rs"],load(){return de(()=>Promise.resolve().then(()=>Xut),void 0,import.meta.url).then(e=>e.rust())}}),Oe.of({name:"Sass",extensions:["sass"],load(){return de(()=>Promise.resolve().then(()=>pV),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),Oe.of({name:"SCSS",extensions:["scss"],load(){return de(()=>Promise.resolve().then(()=>pV),void 0,import.meta.url).then(e=>e.sass())}}),Oe.of({name:"SQL",extensions:["sql"],load(){return bu("StandardSQL")}}),Oe.of({name:"SQLite",load(){return bu("SQLite")}}),Oe.of({name:"TSX",extensions:["tsx"],load(){return de(()=>Promise.resolve().then(()=>bb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Oe.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return de(()=>Promise.resolve().then(()=>bb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Oe.of({name:"WebAssembly",extensions:["wat","wast"],load(){return de(()=>Promise.resolve().then(()=>Kdt),void 0,import.meta.url).then(e=>e.wast())}}),Oe.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return de(()=>Promise.resolve().then(()=>gct),void 0,import.meta.url).then(e=>e.xml())}}),Oe.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return de(()=>import("./index-D4J50qwi.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),Oe.of({name:"APL",extensions:["dyalog","apl"],load(){return de(()=>Promise.resolve().then(()=>Ppt),void 0,import.meta.url).then(e=>ve(e.apl))}}),Oe.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return de(()=>Promise.resolve().then(()=>Tpt),void 0,import.meta.url).then(e=>ve(e.asciiArmor))}}),Oe.of({name:"ASN.1",extensions:["asn","asn1"],load(){return de(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>ve(e.asn1({})))}}),Oe.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return de(()=>Promise.resolve().then(()=>qpt),void 0,import.meta.url).then(e=>ve(e.asterisk))}}),Oe.of({name:"Brainfuck",extensions:["b","bf"],load(){return de(()=>Promise.resolve().then(()=>Cpt),void 0,import.meta.url).then(e=>ve(e.brainfuck))}}),Oe.of({name:"Cobol",extensions:["cob","cpy"],load(){return de(()=>Promise.resolve().then(()=>cmt),void 0,import.meta.url).then(e=>ve(e.cobol))}}),Oe.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.csharp))}}),Oe.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ve(e.clojure))}}),Oe.of({name:"ClojureScript",extensions:["cljs"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ve(e.clojure))}}),Oe.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return de(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>ve(e.gss))}}),Oe.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return de(()=>Promise.resolve().then(()=>emt),void 0,import.meta.url).then(e=>ve(e.cmake))}}),Oe.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return de(()=>Promise.resolve().then(()=>wmt),void 0,import.meta.url).then(e=>ve(e.coffeeScript))}}),Oe.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return de(()=>Promise.resolve().then(()=>Tmt),void 0,import.meta.url).then(e=>ve(e.commonLisp))}}),Oe.of({name:"Cypher",extensions:["cyp","cypher"],load(){return de(()=>Promise.resolve().then(()=>Vmt),void 0,import.meta.url).then(e=>ve(e.cypher))}}),Oe.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return de(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>ve(e.cython))}}),Oe.of({name:"Crystal",extensions:["cr"],load(){return de(()=>Promise.resolve().then(()=>Ymt),void 0,import.meta.url).then(e=>ve(e.crystal))}}),Oe.of({name:"D",extensions:["d"],load(){return de(()=>Promise.resolve().then(()=>Jmt),void 0,import.meta.url).then(e=>ve(e.d))}}),Oe.of({name:"Dart",extensions:["dart"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.dart))}}),Oe.of({name:"diff",extensions:["diff","patch"],load(){return de(()=>Promise.resolve().then(()=>egt),void 0,import.meta.url).then(e=>ve(e.diff))}}),Oe.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return de(()=>Promise.resolve().then(()=>fgt),void 0,import.meta.url).then(e=>ve(e.dockerFile))}}),Oe.of({name:"DTD",extensions:["dtd"],load(){return de(()=>Promise.resolve().then(()=>mgt),void 0,import.meta.url).then(e=>ve(e.dtd))}}),Oe.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return de(()=>Promise.resolve().then(()=>bgt),void 0,import.meta.url).then(e=>ve(e.dylan))}}),Oe.of({name:"EBNF",load(){return de(()=>Promise.resolve().then(()=>wgt),void 0,import.meta.url).then(e=>ve(e.ebnf))}}),Oe.of({name:"ECL",extensions:["ecl"],load(){return de(()=>Promise.resolve().then(()=>Xgt),void 0,import.meta.url).then(e=>ve(e.ecl))}}),Oe.of({name:"edn",extensions:["edn"],load(){return de(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ve(e.clojure))}}),Oe.of({name:"Eiffel",extensions:["e"],load(){return de(()=>Promise.resolve().then(()=>zgt),void 0,import.meta.url).then(e=>ve(e.eiffel))}}),Oe.of({name:"Elm",extensions:["elm"],load(){return de(()=>Promise.resolve().then(()=>Mgt),void 0,import.meta.url).then(e=>ve(e.elm))}}),Oe.of({name:"Erlang",extensions:["erl"],load(){return de(()=>Promise.resolve().then(()=>g0t),void 0,import.meta.url).then(e=>ve(e.erlang))}}),Oe.of({name:"Esper",load(){return de(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>ve(e.esper))}}),Oe.of({name:"Factor",extensions:["factor"],load(){return de(()=>Promise.resolve().then(()=>$0t),void 0,import.meta.url).then(e=>ve(e.factor))}}),Oe.of({name:"FCL",load(){return de(()=>Promise.resolve().then(()=>S0t),void 0,import.meta.url).then(e=>ve(e.fcl))}}),Oe.of({name:"Forth",extensions:["forth","fth","4th"],load(){return de(()=>Promise.resolve().then(()=>k0t),void 0,import.meta.url).then(e=>ve(e.forth))}}),Oe.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return de(()=>Promise.resolve().then(()=>q0t),void 0,import.meta.url).then(e=>ve(e.fortran))}}),Oe.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ve(e.fSharp))}}),Oe.of({name:"Gas",extensions:["s"],load(){return de(()=>Promise.resolve().then(()=>C0t),void 0,import.meta.url).then(e=>ve(e.gas))}}),Oe.of({name:"Gherkin",extensions:["feature"],load(){return de(()=>Promise.resolve().then(()=>z0t),void 0,import.meta.url).then(e=>ve(e.gherkin))}}),Oe.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return de(()=>Promise.resolve().then(()=>M0t),void 0,import.meta.url).then(e=>ve(e.groovy))}}),Oe.of({name:"Haskell",extensions:["hs"],load(){return de(()=>Promise.resolve().then(()=>e$t),void 0,import.meta.url).then(e=>ve(e.haskell))}}),Oe.of({name:"Haxe",extensions:["hx"],load(){return de(()=>Promise.resolve().then(()=>SL),void 0,import.meta.url).then(e=>ve(e.haxe))}}),Oe.of({name:"HXML",extensions:["hxml"],load(){return de(()=>Promise.resolve().then(()=>SL),void 0,import.meta.url).then(e=>ve(e.hxml))}}),Oe.of({name:"HTTP",load(){return de(()=>Promise.resolve().then(()=>S$t),void 0,import.meta.url).then(e=>ve(e.http))}}),Oe.of({name:"IDL",extensions:["pro"],load(){return de(()=>Promise.resolve().then(()=>X$t),void 0,import.meta.url).then(e=>ve(e.idl))}}),Oe.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return de(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>ve(e.jsonld))}}),Oe.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return de(()=>Promise.resolve().then(()=>j$t),void 0,import.meta.url).then(e=>ve(e.jinja2))}}),Oe.of({name:"Julia",extensions:["jl"],load(){return de(()=>Promise.resolve().then(()=>ayt),void 0,import.meta.url).then(e=>ve(e.julia))}}),Oe.of({name:"Kotlin",extensions:["kt","kts"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.kotlin))}}),Oe.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return de(()=>Promise.resolve().then(()=>cyt),void 0,import.meta.url).then(e=>ve(e.liveScript))}}),Oe.of({name:"Lua",extensions:["lua"],load(){return de(()=>Promise.resolve().then(()=>gyt),void 0,import.meta.url).then(e=>ve(e.lua))}}),Oe.of({name:"mIRC",extensions:["mrc"],load(){return de(()=>Promise.resolve().then(()=>Yyt),void 0,import.meta.url).then(e=>ve(e.mirc))}}),Oe.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return de(()=>Promise.resolve().then(()=>Qyt),void 0,import.meta.url).then(e=>ve(e.mathematica))}}),Oe.of({name:"Modelica",extensions:["mo"],load(){return de(()=>Promise.resolve().then(()=>Byt),void 0,import.meta.url).then(e=>ve(e.modelica))}}),Oe.of({name:"MUMPS",extensions:["mps"],load(){return de(()=>Promise.resolve().then(()=>dvt),void 0,import.meta.url).then(e=>ve(e.mumps))}}),Oe.of({name:"Mbox",extensions:["mbox"],load(){return de(()=>Promise.resolve().then(()=>Ayt),void 0,import.meta.url).then(e=>ve(e.mbox))}}),Oe.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return de(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>ve(e.nginx))}}),Oe.of({name:"NSIS",extensions:["nsh","nsi"],load(){return de(()=>Promise.resolve().then(()=>$vt),void 0,import.meta.url).then(e=>ve(e.nsis))}}),Oe.of({name:"NTriples",extensions:["nt","nq"],load(){return de(()=>Promise.resolve().then(()=>yvt),void 0,import.meta.url).then(e=>ve(e.ntriples))}}),Oe.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.objectiveC))}}),Oe.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.objectiveCpp))}}),Oe.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ve(e.oCaml))}}),Oe.of({name:"Octave",extensions:["m"],load(){return de(()=>Promise.resolve().then(()=>Xvt),void 0,import.meta.url).then(e=>ve(e.octave))}}),Oe.of({name:"Oz",extensions:["oz"],load(){return de(()=>Promise.resolve().then(()=>Nvt),void 0,import.meta.url).then(e=>ve(e.oz))}}),Oe.of({name:"Pascal",extensions:["p","pas"],load(){return de(()=>Promise.resolve().then(()=>Lvt),void 0,import.meta.url).then(e=>ve(e.pascal))}}),Oe.of({name:"Perl",extensions:["pl","pm"],load(){return de(()=>Promise.resolve().then(()=>Fvt),void 0,import.meta.url).then(e=>ve(e.perl))}}),Oe.of({name:"Pig",extensions:["pig"],load(){return de(()=>Promise.resolve().then(()=>Kvt),void 0,import.meta.url).then(e=>ve(e.pig))}}),Oe.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return de(()=>Promise.resolve().then(()=>hbt),void 0,import.meta.url).then(e=>ve(e.powerShell))}}),Oe.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return de(()=>Promise.resolve().then(()=>pbt),void 0,import.meta.url).then(e=>ve(e.properties))}}),Oe.of({name:"ProtoBuf",extensions:["proto"],load(){return de(()=>Promise.resolve().then(()=>vbt),void 0,import.meta.url).then(e=>ve(e.protobuf))}}),Oe.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return de(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>ve(e.pug))}}),Oe.of({name:"Puppet",extensions:["pp"],load(){return de(()=>Promise.resolve().then(()=>Sbt),void 0,import.meta.url).then(e=>ve(e.puppet))}}),Oe.of({name:"Q",extensions:["q"],load(){return de(()=>Promise.resolve().then(()=>Rbt),void 0,import.meta.url).then(e=>ve(e.q))}}),Oe.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return de(()=>Promise.resolve().then(()=>Ubt),void 0,import.meta.url).then(e=>ve(e.r))}}),Oe.of({name:"RPM Changes",load(){return de(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ve(e.rpmChanges))}}),Oe.of({name:"RPM Spec",extensions:["spec"],load(){return de(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ve(e.rpmSpec))}}),Oe.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return de(()=>Promise.resolve().then(()=>Mbt),void 0,import.meta.url).then(e=>ve(e.ruby))}}),Oe.of({name:"SAS",extensions:["sas"],load(){return de(()=>Promise.resolve().then(()=>Hbt),void 0,import.meta.url).then(e=>ve(e.sas))}}),Oe.of({name:"Scala",extensions:["scala"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.scala))}}),Oe.of({name:"Scheme",extensions:["scm","ss"],load(){return de(()=>Promise.resolve().then(()=>u1t),void 0,import.meta.url).then(e=>ve(e.scheme))}}),Oe.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return de(()=>Promise.resolve().then(()=>h1t),void 0,import.meta.url).then(e=>ve(e.shell))}}),Oe.of({name:"Sieve",extensions:["siv","sieve"],load(){return de(()=>Promise.resolve().then(()=>y1t),void 0,import.meta.url).then(e=>ve(e.sieve))}}),Oe.of({name:"Smalltalk",extensions:["st"],load(){return de(()=>Promise.resolve().then(()=>w1t),void 0,import.meta.url).then(e=>ve(e.smalltalk))}}),Oe.of({name:"Solr",load(){return de(()=>Promise.resolve().then(()=>_1t),void 0,import.meta.url).then(e=>ve(e.solr))}}),Oe.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return de(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ve(e.sml))}}),Oe.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return de(()=>Promise.resolve().then(()=>z1t),void 0,import.meta.url).then(e=>ve(e.sparql))}}),Oe.of({name:"Spreadsheet",alias:["excel","formula"],load(){return de(()=>Promise.resolve().then(()=>A1t),void 0,import.meta.url).then(e=>ve(e.spreadsheet))}}),Oe.of({name:"Squirrel",extensions:["nut"],load(){return de(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>ve(e.squirrel))}}),Oe.of({name:"Stylus",extensions:["styl"],load(){return de(()=>Promise.resolve().then(()=>awt),void 0,import.meta.url).then(e=>ve(e.stylus))}}),Oe.of({name:"Swift",extensions:["swift"],load(){return de(()=>Promise.resolve().then(()=>Qwt),void 0,import.meta.url).then(e=>ve(e.swift))}}),Oe.of({name:"sTeX",load(){return de(()=>Promise.resolve().then(()=>hF),void 0,import.meta.url).then(e=>ve(e.stex))}}),Oe.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return de(()=>Promise.resolve().then(()=>hF),void 0,import.meta.url).then(e=>ve(e.stex))}}),Oe.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return de(()=>Promise.resolve().then(()=>jF),void 0,import.meta.url).then(e=>ve(e.verilog))}}),Oe.of({name:"Tcl",extensions:["tcl"],load(){return de(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>ve(e.tcl))}}),Oe.of({name:"Textile",extensions:["textile"],load(){return de(()=>Promise.resolve().then(()=>qwt),void 0,import.meta.url).then(e=>ve(e.textile))}}),Oe.of({name:"TiddlyWiki",load(){return de(()=>Promise.resolve().then(()=>eSt),void 0,import.meta.url).then(e=>ve(e.tiddlyWiki))}}),Oe.of({name:"Tiki wiki",load(){return de(()=>Promise.resolve().then(()=>sSt),void 0,import.meta.url).then(e=>ve(e.tiki))}}),Oe.of({name:"TOML",extensions:["toml"],load(){return de(()=>Promise.resolve().then(()=>lSt),void 0,import.meta.url).then(e=>ve(e.toml))}}),Oe.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return de(()=>Promise.resolve().then(()=>OSt),void 0,import.meta.url).then(e=>ve(e.troff))}}),Oe.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return de(()=>Promise.resolve().then(()=>_St),void 0,import.meta.url).then(e=>ve(e.ttcn))}}),Oe.of({name:"TTCN_CFG",extensions:["cfg"],load(){return de(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>ve(e.ttcnCfg))}}),Oe.of({name:"Turtle",extensions:["ttl"],load(){return de(()=>Promise.resolve().then(()=>ESt),void 0,import.meta.url).then(e=>ve(e.turtle))}}),Oe.of({name:"Web IDL",extensions:["webidl"],load(){return de(()=>Promise.resolve().then(()=>Qxt),void 0,import.meta.url).then(e=>ve(e.webIDL))}}),Oe.of({name:"VB.NET",extensions:["vb"],load(){return de(()=>Promise.resolve().then(()=>MSt),void 0,import.meta.url).then(e=>ve(e.vb))}}),Oe.of({name:"VBScript",extensions:["vbs"],load(){return de(()=>Promise.resolve().then(()=>FSt),void 0,import.meta.url).then(e=>ve(e.vbScript))}}),Oe.of({name:"Velocity",extensions:["vtl"],load(){return de(()=>Promise.resolve().then(()=>KSt),void 0,import.meta.url).then(e=>ve(e.velocity))}}),Oe.of({name:"Verilog",extensions:["v"],load(){return de(()=>Promise.resolve().then(()=>jF),void 0,import.meta.url).then(e=>ve(e.verilog))}}),Oe.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return de(()=>Promise.resolve().then(()=>sxt),void 0,import.meta.url).then(e=>ve(e.vhdl))}}),Oe.of({name:"XQuery",extensions:["xy","xquery"],load(){return de(()=>Promise.resolve().then(()=>Cxt),void 0,import.meta.url).then(e=>ve(e.xQuery))}}),Oe.of({name:"Yacas",extensions:["ys"],load(){return de(()=>Promise.resolve().then(()=>Dxt),void 0,import.meta.url).then(e=>ve(e.yacas))}}),Oe.of({name:"Z80",extensions:["z80"],load(){return de(()=>Promise.resolve().then(()=>Bxt),void 0,import.meta.url).then(e=>ve(e.z80))}}),Oe.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return de(()=>Promise.resolve().then(()=>V_),void 0,import.meta.url).then(e=>ve(e.mscgen))}}),Oe.of({name:"Xù",extensions:["xu"],load(){return de(()=>Promise.resolve().then(()=>V_),void 0,import.meta.url).then(e=>ve(e.xu))}}),Oe.of({name:"MsGenny",extensions:["msgenny"],load(){return de(()=>Promise.resolve().then(()=>V_),void 0,import.meta.url).then(e=>ve(e.msgenny))}}),Oe.of({name:"Vue",extensions:["vue"],load(){return de(()=>Promise.resolve().then(()=>oft),void 0,import.meta.url).then(e=>e.vue())}}),Oe.of({name:"Angular Template",load(){return de(()=>Promise.resolve().then(()=>Qft),void 0,import.meta.url).then(e=>e.angular())}})];class X9{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=Dn(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(Bhe(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 uD(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 Uet(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=uD(t)+uD(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Ny(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Uet(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function MQ(e,t){return n=>{for(let r=Dn(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 OD{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function _d(e){return e.selection.main.from}function Bhe(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 R9=yf.define();function Wet(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:We.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const dD=new WeakMap;function Yet(e){if(!Array.isArray(e))return e;let t=dD.get(e);return t||dD.set(e,t=Ny(e)),t}const sS=Pn.define(),y$=Pn.define();class Get{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=lo(t,n),i=yc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(lo(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=lo(t,0),w=yc(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=lo(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=yc(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=lo(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=sfe(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+=yc(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?yc(lo(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 Net{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 Qi=Ot.define({combine(e){return Om(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:Zet,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=>fD(t(r),n(r)),optionClass:(t,n)=>r=>fD(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function fD(e,t){return e?t?e+" "+t:e:t}function Zet(e,t,n,r,i,a){let o=e.textDirection==br.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 Iet(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 GT(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 Det{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(Qi);this.optionContent=Iet(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=GT(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(Qi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:y$.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=GT(a.length,o,t.state.facet(Qi).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=GT(n.options.length,n.selected,this.view.state.facet(Qi).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=>ja(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&&Met(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(Qi).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 Vet(e,t){return n=>new Det(n,e,t)}function Met(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 hD(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Let(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(Qi);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 OD(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Net(O):new Get(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 OD(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):hD(c.completion)>hD(s)&&(o[o.length-1]=c),s=c.completion}return o}class xh{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 xh(this.options,pD(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=Let(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Qi).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 xh(s,pD(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:ett,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new xh(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 xh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class lS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new lS(Ket,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Qi),a=(r.override||n.languageDataAt("autocomplete",_d(n)).map(Yet)).map(l=>(this.active.find(u=>u.source==l)||new Lo(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(E9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Fet(a,this.active)||s?o=xh.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 Lo(l.source,0):l));for(let l of t.effects)l.is(Khe)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new lS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Bet:Het}}function Fet(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 Bet={"aria-autocomplete":"list"},Het={};function pD(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Ket=[];function Hhe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(R9);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 Lo{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=Hhe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Lo(i.source,0)),r&4&&i.state==0&&(i=new Lo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(sS))i=new Lo(i.source,1,a.value);else if(a.is(y$))i=new Lo(i.source,0);else if(a.is(E9))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(_d(t.state))}}class Ih extends Lo{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=_d(t.state);if(s>o||!i||n&2&&(_d(t.startState)==this.from||s<this.limit))return new Lo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Jet(i.validFor,t.state,a,o)?new Ih(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new X9(t.state,s,!1)))?new Ih(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:_d(t.state)):new Lo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Ih(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Lo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Jet(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Bhe(e,!0).test(i)}const E9=Pn.define({map(e,t){return e.map(n=>n.map(t))}}),Khe=Pn.define(),Ea=Ia.define({create(){return lS.start()},update(e,t){return e.update(t)},provide:e=>[S9.from(e,t=>t.tooltip),wt.contentAttributes.from(e,t=>t.attrs)]});function q9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ea).active.find(i=>i.source==t.source);return r instanceof Ih?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Wet(e.state,n,r.from,r.to)),{annotations:R9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const ett=Vet(Ea,q9);function $b(e,t="option"){return n=>{let r=n.state.field(Ea,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Qi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=whe(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:Khe.of(s)}),!0}}const ttt=e=>{let t=e.state.field(Ea,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Qi).interactionDelay?!1:q9(e,t.open.options[t.open.selected])},mD=e=>e.state.field(Ea,!1)?(e.dispatch({effects:sS.of(!0)}),!0):!1,ntt=e=>{let t=e.state.field(Ea,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:y$.of(null)}),!0)};class rtt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const itt=50,att=1e3,ott=hi.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(Ea).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ea),n=e.state.facet(Qi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ea)==t)return;let r=e.transactions.some(a=>{let o=Hhe(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>itt&&Date.now()-o.time>att){for(let s of o.context.abortListeners)try{s()}catch(l){ja(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(sS)))&&(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(Ea);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(Qi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=_d(t),r=new X9(t,n,e.explicit,this.view),i=new rtt(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:y$.of(null)}),ja(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(Qi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Qi),r=this.view.state.field(Ea);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=_d(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Ih(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 Lo(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:E9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ea,!1);if(t&&t.tooltip&&this.view.state.facet(Qi).closeOnBlur){let n=t.open&&whe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:y$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:sS.of(!1)}),20),this.composing=0}}}),stt=typeof navigator=="object"&&/Win/.test(navigator.platform),ltt=xO.highest(wt.domEventHandlers({keydown(e,t){let n=t.state.field(Ea,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(stt&&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&&q9(t,r),!1}})),Jhe=wt.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 ctt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class j9{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ci.TrackDel),r=t.mapPos(this.to,1,Ci.TrackDel);return n==null||r==null?null:new j9(this.field,n,r)}}class C9{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(IQ);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 j9(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 ctt(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 C9(r,i)}}let utt=cn.widget({widget:new class extends au{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Ott=cn.mark({class:"cm-snippetField"});class dm{constructor(t,n){this.ranges=t,this.active=n,this.deco=cn.set(t.map(r=>(r.from==r.to?utt:Ott).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 dm(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 Zy=Pn.define({map(e,t){return e&&e.map(t)}}),dtt=Pn.define(),v$=Ia.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Zy))return n.value;if(n.is(dtt)&&e)return new dm(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=>wt.decorations.from(e,t=>t?t.deco:cn.none)});function z9(e,t){return We.create(e.filter(n=>n.field==t).map(n=>We.range(n.from,n.to)))}function ftt(e){let t=C9.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:In.of(o)},scrollIntoView:!0,annotations:r?[R9.of(r),Ai.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=z9(s,0)),s.some(u=>u.field>0)){let u=new dm(s,0),O=c.effects=[Zy.of(u)];n.state.field(v$,!1)===void 0&&O.push(Pn.appendConfig.of([v$,$tt,ytt,Jhe]))}n.dispatch(n.state.update(c))}}function epe(e){return({state:t,dispatch:n})=>{let r=t.field(v$,!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:z9(r.ranges,i),effects:Zy.of(a?null:new dm(r.ranges,i)),scrollIntoView:!0})),!0}}const htt=({state:e,dispatch:t})=>e.field(v$,!1)?(t(e.update({effects:Zy.of(null)})),!0):!1,ptt=epe(1),mtt=epe(-1),gtt=[{key:"Tab",run:ptt,shift:mtt},{key:"Escape",run:htt}],gD=Ot.define({combine(e){return e.length?e[0]:gtt}}),$tt=xO.highest(GQ.compute([gD],e=>e.facet(gD)));function hr(e,t){return Object.assign(Object.assign({},t),{apply:ftt(e)})}const ytt=wt.domEventHandlers({mousedown(e,t){let n=t.state.field(v$,!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:z9(n.ranges,i.field),effects:Zy.of(n.ranges.some(a=>a.field>i.field)?new dm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),b$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},pd=Pn.define({map(e,t){let n=t.mapPos(e,-1,Ci.TrackAfter);return n??void 0}}),A9=new class extends Vd{};A9.startSide=1;A9.endSide=-1;const tpe=Ia.define({create(){return kn.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(pd)&&(e=e.update({add:[A9.range(n.value,n.value+1)]}));return e}});function Yrn(){return[btt,tpe]}const NT="()[]{}<>«»»«[]{}";function npe(e){for(let t=0;t<NT.length;t+=2)if(NT.charCodeAt(t)==e)return NT.charAt(t+1);return sfe(e<128?e:e+1)}function rpe(e,t){return e.languageDataAt("closeBrackets",t)[0]||b$}const vtt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),btt=wt.inputHandler.of((e,t,n,r)=>{if((vtt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&yc(lo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Stt(e.state,r);return a?(e.dispatch(a),!0):!1}),wtt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=rpe(e,e.selection.main.head).brackets||b$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=xtt(e.doc,o.head);for(let l of r)if(l==s&&LQ(e.doc,o.head)==npe(lo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:We.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Grn=[{key:"Backspace",run:wtt}];function Stt(e,t){let n=rpe(e,e.selection.main.head),r=n.brackets||b$.brackets;for(let i of r){let a=npe(lo(i,0));if(t==i)return a==i?Ptt(e,i,r.indexOf(i+i+i)>-1,n):Qtt(e,i,a,n.before||b$.before);if(t==a&&ipe(e,e.selection.main.from))return ktt(e,i,a)}return null}function ipe(e,t){let n=!1;return e.field(tpe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function LQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,yc(lo(n,0)))}function xtt(e,t){let n=e.sliceString(t-2,t);return yc(lo(n,0))==n.length?n:n.slice(1)}function Qtt(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:pd.of(o.to+t.length),range:We.range(o.anchor+t.length,o.head+t.length)};let s=LQ(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:pd.of(o.head+t.length),range:We.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function ktt(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&LQ(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:We.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function Ptt(e,t,n,r){let i=r.stringPrefixes||b$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:pd.of(s.to+t.length),range:We.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=LQ(e.doc,l),u;if(c==t){if($D(e,l))return{changes:{insert:t+t,from:l},effects:pd.of(l+t.length),range:We.cursor(l+t.length)};if(ipe(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:We.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=yD(e,l-2*t.length,i))>-1&&$D(e,u))return{changes:{insert:t+t+t+t,from:l},effects:pd.of(l+t.length),range:We.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Mo.Word&&yD(e,l,i)>-1&&!Ttt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:pd.of(l+t.length),range:We.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function $D(e,t){let n=Dn(e).resolveInner(t+1);return n.parent&&n.from==t}function Ttt(e,t,n,r){let i=Dn(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 yD(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Mo.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))!=Mo.Word)return a}return-1}function Nrn(e={}){return[ltt,Ea,Qi.of(e),ott,Xtt,Jhe]}const _tt=[{key:"Ctrl-Space",run:mD},{mac:"Alt-`",run:mD},{key:"Escape",run:ntt},{key:"ArrowDown",run:$b(!0)},{key:"ArrowUp",run:$b(!1)},{key:"PageDown",run:$b(!0,"page")},{key:"PageUp",run:$b(!1,"page")},{key:"Enter",run:ttt}],Xtt=xO.highest(GQ.computeN([Qi],e=>e.facet(Qi).defaultKeymap?[_tt]:[]));class cS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new cS(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=[[It.contextHash,i]]}addChild(t,n){t.prop(It.contextHash)!=this.hash&&(t=new mn(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 mn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new mn(ei.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 Rtt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Ett=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 O0(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 vD(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?Y9:W9)(n,t,!1);return r>0&&(e.type!=Ne.BulletList||U9(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const ape={[Ne.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(wn(Ne.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(us(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]:vD,[Ne.BulletList]:vD,[Ne.Document](){return!0}};function us(e){return e==32||e==9||e==10||e==13}function O0(e,t=0){for(;t<e.length&&us(e.charCodeAt(t));)t++;return t}function bD(e,t,n){for(;t>n&&us(e.charCodeAt(t-1));)t--;return t}function ope(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 spe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function U9(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(!us(a))return-1}return n&&e.next==45&&upe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(hpe.SetextHeading)>-1||r<3?-1:1}function lpe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function W9(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||us(e.text.charCodeAt(e.pos+1)))&&(!n||lpe(t,Ne.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Y9(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&&!us(e.text.charCodeAt(r+1))||n&&!lpe(t,Ne.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function cpe(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 upe(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&&us(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const tj=/^[ \t]*$/,Ope=/-->/,dpe=/\?>/,nj=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Ope],[/^\s*<\?/,dpe],[/^\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,tj],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,tj]];function fpe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=nj.length-(n?1:0);i<a;i++)if(nj[i][0].test(r))return i;return-1}function wD(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 DO(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(wn(Ne.CodeText,t,n))}const yb={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(DO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){DO(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?DO(o,c.from,c.to):o.push(c);s=[]}DO(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&&DO(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=ope(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=bD(t.text,t.text.length,o),l=[wn(Ne.CodeMark,r,r+a)];o<s&&l.push(wn(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(wn(Ne.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||DO(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&&DO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ne.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=spe(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(U9(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=W9(t,e,!1);if(n<0)return!1;e.block.type!=Ne.BulletList&&e.startContext(Ne.BulletList,t.basePos,t.next);let r=wD(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=Y9(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=wD(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=cpe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=bD(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!us(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=fpe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=nj[n][1],a=[],o=i!=tj;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==Ope?Ne.CommentBlock:i==dpe?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 qtt{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+`
795
795
  `+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)&&O0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,wn(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(Spe(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(wn(Ne.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(bpe(t,O0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=O0(t,this.pos),r=0;if(n>this.pos){let i=wpe(t,n,this.start);if(i){let a=ZT(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=ZT(t,this.pos)),r>0&&r<t.length?r:-1}else return ZT(t,this.pos)}}}function ZT(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!us(n))return-1}return t}class jtt{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:upe(n),a=n.next;if(i<0)return!1;let o=wn(Ne.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,wn(a==61?Ne.SetextHeading1:Ne.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const hpe={LinkReference(e,t){return t.content.charCodeAt(0)==91?new qtt(t):null},SetextHeading(){return new jtt}},Ctt=[(e,t)=>cpe(t)>=0,(e,t)=>ope(t)>=0,(e,t)=>spe(t)>=0,(e,t)=>W9(t,e,!0)>=0,(e,t)=>Y9(t,e,!0)>=0,(e,t)=>U9(t,e,!0)>=0,(e,t)=>fpe(t,e,!0)>=0],ztt={text:"",end:0};class Att{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new Ett,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=cS.create(Ne.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new Gtt(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 Rtt(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+=`
796
796
  `+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=xpe(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=ztt;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==`
797
797
  `?"":n;else{let i=n.indexOf(`
@@ -820,7 +820,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
820
820
  `,o.end),l=t.slice(o.end,s===-1?t.length:s);if(KQt.test(l))return qa;const c=l.length-l.replace(JQt,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+xp(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]===Tk?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const dl=e=>e.typingAt!==null,ikt=e=>e.arm!==null;function Tf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+xp(e.value).length}}function GA(e,t,n,r){const i=Tf(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=xp(e.value),c=aC(a-i.start,0,l.length),u=aC(o-i.start,0,l.length),O=xp(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),f=a+O.length,p=t.slice(0,a)+o1e.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 VF(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=dl(e)&&e.value===""&&r.startsWith("-");if(dl(e)&&(a||r.includes(`
821
821
  `))){const o=WS(e);return r.includes(`
822
822
  `)?{...i,capture:o}:{...i,capture:Ph(o,i.buffer,i.caret,"typing")}}return GA(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function WS(e){return dl(e)?{arm:e.arm,typingAt:null,value:""}:e}function akt(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 okt(e,t,n,r,i){const a=akt(t,n),o=Tf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:WS(e),buffer:n,caret:r};else{const l=GA(e,n,r,a);l?s=l:dl(e)&&a.inserted.includes(`
823
- `)&&(s={capture:WS(e),buffer:n,caret:r})}return{...s,capture:Ph(s.capture,s.buffer,s.caret,i)}}function skt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Tf(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=p1e(i,t.value),c=l+Tk,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:qa,buffer:u,caret:s+c.length,payload:{index:i,key:y1e(a,e.draw),value:t.value,marker:l}}}function lkt(e,t){const n=Tf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=$1e(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:qa,buffer:i,caret:n.start+r.length,restored:iC(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:iC(r),restoredText:r}}}function MF(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function ckt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Tf(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:WS(e),buffer:i,caret:a,payload:null}}function ukt(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=GA(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=$n(i);if(!a)return i===""?null:ckt(t,n,e.selection,i);const o=t.arm,s=p1e(e.index,a),l=s+Tk,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:qa,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:y1e(e.taken,e.draw),value:a,marker:s}}}const h1e=e=>`${iC(e)} chars`,p1e=(e,t)=>`[Credential #${e}, ${h1e(t)}]`;function Okt(e){wl.lastIndex=0;const t=wl.exec(e);return wl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function dkt(e){wl.lastIndex=0;const t=wl.exec(e);if(wl.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 tv(e,t){if(Okt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const c2=/\[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,u2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,O2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,fkt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&rC.test(t[1])?t[1]:""};function hkt(e,t){if(e.charCodeAt(t)!==91)return null;c2.lastIndex=t;const n=c2.exec(e);if(c2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};u2.lastIndex=t;const r=u2.exec(e);if(u2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};O2.lastIndex=t;const i=O2.exec(e);return O2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:fkt(i[0])}:null}function _k(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=hkt(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 LF(e,t){const n=[];for(const r of t){const i=tv(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 pkt(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 mkt=e=>`[credential ${e.key} (${h1e(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function gkt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=tv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of u1e(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?pkt(l??"lost",s?.key):mkt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const $kt=(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.`,ykt=e=>`Remove credential #${e}`,vkt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,bkt=(e,t,n)=>$kt(e,t,n),wkt="Undo",Skt=e=>`Credential #${e} removed`,xkt=e=>e.unredacted!==null?e.unredacted:e.armed?Rkt:e.cleared!==null?bkt(e.cleared.key,e.cleared.index,e.undoCap):null;function Qkt(e){const{buffer:t,payload:n}=e,r=tv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===Tk?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 kkt(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 FF=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function BF(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 Pkt="store unconfirmed",Tkt="Credential store unconfirmed",_kt=e=>e===""?Tkt:`${e} · ${Pkt}`,m1e="Paste the value again after /credential to store it again.",Xkt=e=>`${e} ${m1e}`;function HF(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. ${m1e}`}const Rkt="armed — add a space, then type or paste the secret",Ekt="masked as you type — Enter turns it into a pill, Esc cancels",qkt="masked — Enter opens the credential picker; type or paste the secret into this span",jkt="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",g1e="\0held",Ckt=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===g1e?`${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 $1e(e,t){const n=Tf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const KF=(e,t)=>e&&e.over===t?e.chars:null,zkt=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},Akt=16,Ukt=16;function y1e(e=[],t=zkt){const n=new Set(e);for(let r=0;r<Akt;r++){const i=IF+JF(8,t);if(!n.has(i))return i}return IF+JF(Ukt,t)}const JF=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=ZF[t(ZF.length)];return n},v1e=q("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),b1e=q("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),w1e=({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:q("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?b1e:v1e,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(Pae,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(ECe,{"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(Wi,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),A$="#lo-credential/",Wkt=`${A$}unstored`,eB=`${A$}unconfirmed`,Ykt=/^\d+$/,S1e=e=>e.kind==="stored"?`${A$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${eB}/${e.key}`:eB:Wkt;function Gkt(e){if(!e||!e.startsWith(A$))return null;const t=e.slice(A$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return rC.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!rC.test(r)||!Ykt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function tB(e,t){const n=Gkt(e);if(n===null)return null;const r=_k(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return S1e(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=_k(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:S1e(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},Nkt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?_kt(e.key):"Credential not stored",Zkt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?Xkt(t):t,Ikt=({citation:e,title:t})=>h.jsx(w1e,{tone:e.kind==="stored"?"live":"warning",label:Nkt(e),chars:e.kind==="stored"?e.chars:null,title:Zkt(e,t),className:"align-middle"}),Dkt=(e,t)=>typeof t=="string"?tB(e,t):t==null?tB(e,""):null,Vkt=e=>({href:t,title:n,children:r})=>{const i=Dkt(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(Ikt,{citation:i,title:n})};function Mkt(){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 Lkt={tokenize:Fkt,concrete:!0,name:"mathFlow"},nB={tokenize:Bkt,partial:!0};function Fkt(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"),ln(e,c,"whitespace")(v))}function c(v){return v===null||yt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||yt(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(nB,d,g)(v)}function d(v){return e.attempt({tokenize:$,partial:!0},g,f)(v)}function f(v){return(a?ln(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):yt(v)?e.attempt(nB,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||yt(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 ln(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"),ln(v,P,"whitespace")(R))}function P(R){return R===null||yt(R)?(v.exit("mathFlowFence"),w(R)):x(R)}}}function Bkt(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 Hkt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Kkt,previous:Jkt,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):yt(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||yt(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 Kkt(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 Jkt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function ePt(e){return{flow:{36:Lkt},text:{36:Hkt()}}}const Th=36,rB=e=>e!==null&&e<-2,iB=e=>e===null||e===32||e<0,aB=e=>e!==null&&e>=48&&e<=57,x1e=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:tPt,previous:nPt,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===Th?(r.consume(g),s++,d):s<2&&!t||s===1&&(iB(g)||aB(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===Th?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):rB(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===Th||rB(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===Th?(r.consume(g),c++,m):c===s?s===1&&(iB(l)||aB(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function tPt(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 nPt(e){return e!==Th||this.events[this.events.length-1][1].type==="characterEscape"}const rPt=ePt().flow,iPt=x1e();function Rk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?iPt:x1e(e);n.push({flow:rPt,text:{[Th]:i}}),r.push(Mkt())}const aPt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),oPt=/\$(?!\d)(.+?)\$/,sPt=/\$\$([\s\S]+?)\$\$/,lPt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,cPt=/\\[a-zA-Z]+(\{[^}]*\})?/,oB=e=>oPt.test(e)||sPt.test(e)||lPt.test(e)?!0:cPt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),uPt=e=>{const t=_k(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},OPt=e=>_k(e).filter(t=>t.kind!=="text").length,dPt=e=>{if(!oB(e))return!1;const t=uPt(e);return t===null?!0:oB(t)||t.includes("$")?!1:OPt(e)<2},tn="var(--color-ink)",Hl="var(--color-ink-muted)",nl="var(--color-surface)",Qu="var(--color-elevated)",Kl="var(--color-sunken)",Zi="var(--color-hairline)",ku="var(--color-control)",ah="var(--color-accent)",Gg="var(--color-accent-wash)",fPt="var(--color-accent-alt-wash)",hPt="var(--color-on-accent)",pPt="var(--color-info)",Q1e="var(--color-info-wash)",mPt="var(--color-success)",k1e="var(--color-success-wash)",gPt="var(--color-warning)",oC="var(--color-warning-wash)",$Pt="var(--color-warning-border)",d2="var(--color-danger)",sC="var(--color-danger-wash)",sB=[Gg,fPt,Q1e,k1e,oC,sC],Pu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),yPt=()=>{const e={primaryColor:Pu("--color-accent"),secondaryColor:Pu("--color-success"),tertiaryColor:Pu("--color-info"),mainBkg:Pu("--color-elevated"),clusterBkg:Pu("--color-sunken"),clusterBorder:Pu("--color-hairline"),edgeLabelBackground:Pu("--color-surface"),quadrant1Fill:Pu("--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:nl,primaryTextColor:tn,primaryBorderColor:ku,secondaryTextColor:tn,secondaryBorderColor:Zi,tertiaryTextColor:tn,tertiaryBorderColor:Zi,lineColor:Hl,arrowheadColor:Hl,textColor:tn,secondBkg:Kl,border1:ku,border2:Zi,labelColor:tn,nodeBkg:Qu,nodeBorder:ku,nodeTextColor:tn,defaultLinkColor:Hl,titleColor:tn,noteBkgColor:oC,noteBorderColor:$Pt,noteTextColor:tn,actorBkg:Qu,actorBorder:ku,actorTextColor:tn,actorLineColor:Zi,signalColor:Hl,signalTextColor:tn,labelBoxBkgColor:Qu,labelBoxBorderColor:Zi,labelTextColor:tn,loopTextColor:tn,activationBkgColor:Gg,activationBorderColor:ah,sequenceNumberColor:nl,sectionBkgColor:Kl,sectionBkgColor2:nl,altSectionBkgColor:Kl,excludeBkgColor:Kl,taskBkgColor:Gg,taskBorderColor:ku,taskTextColor:tn,taskTextLightColor:tn,taskTextDarkColor:tn,taskTextOutsideColor:tn,taskTextClickableColor:ah,activeTaskBkgColor:Gg,activeTaskBorderColor:ah,gridColor:Zi,doneTaskBkgColor:Kl,doneTaskBorderColor:Zi,critBkgColor:sC,critBorderColor:d2,todayLineColor:ah,transitionColor:Hl,transitionLabelColor:tn,stateLabelColor:tn,stateBkg:Qu,labelBackgroundColor:nl,compositeBackground:Kl,altBackground:Kl,compositeTitleBackground:Qu,compositeBorder:Zi,innerEndBackground:tn,specialStateColor:tn,classText:tn,attributeBackgroundColorOdd:nl,attributeBackgroundColorEven:Kl,rowOdd:nl,rowEven:Kl,errorBkgColor:sC,errorTextColor:d2,pieTitleTextColor:tn,pieSectionTextColor:tn,pieLegendTextColor:tn,pieStrokeColor:nl,pieOuterStrokeColor:Zi,requirementBackground:Qu,requirementBorderColor:ku,requirementTextColor:tn,relationColor:Hl,relationLabelBackground:nl,relationLabelColor:tn,branchLabelColor:hPt,commitLabelColor:tn,commitLabelBackground:nl,tagLabelColor:tn,tagLabelBackground:Gg,tagLabelBorder:ku,quadrant2Fill:Q1e,quadrant3Fill:k1e,quadrant4Fill:oC,quadrant2TextFill:tn,quadrant3TextFill:tn,quadrant4TextFill:tn,quadrantPointFill:ah,archEdgeColor:Hl,archEdgeArrowColor:Hl,archGroupBorderColor:Zi,scaleLabelColor:tn,packet:{startByteColor:tn,endByteColor:tn,labelColor:tn,titleColor:tn,blockStrokeColor:ku,blockFillColor:Qu},radar:{axisColor:Hl,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Zi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:nl,titleColor:tn,xAxisTitleColor:tn,xAxisLabelColor:tn,xAxisTickColor:Zi,xAxisLineColor:Zi,yAxisTitleColor:tn,yAxisLabelColor:tn,yAxisTickColor:Zi,yAxisLineColor:Zi,plotColorPalette:[ah,pPt,mPt,gPt,d2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Qu,t[`surfacePeer${n}`]=Zi;for(let n=0;n<8;n++)t[`fillType${n}`]=sB[n%sB.length];return{...t,...e}};let f2=null,lB=null;const vPt=async e=>{f2||(f2=de(async()=>{const{default:n}=await import("./mermaid.core-SK1P8eeE.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,2,3]),import.meta.url).then(({default:n})=>n));const t=await f2;return lB!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:yPt()}),lB=e),t},cB=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:q("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(Nt,{content:"Zoom in",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(D7e,{})})}),h.jsx(Nt,{content:"Zoom out",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(M7e,{})})}),h.jsx(Nt,{content:"Drag the diagram to pan",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(e7e,{})})}),h.jsx(Nt,{content:"Reset view",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(N6,{})})}),h.jsx(Nt,{content:"Save as SVG",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(pQ,{})})}),h.jsx(Nt,{content:t?"Copied":"Copy mermaid text",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(U6,{className:q(t&&"text-success")})})}),s]}),lC=({title:e,children:t})=>h.jsxs(Ql,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(Mg,{children:e}),h.jsx(Lg,{children:t})]});class bPt 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(lC,{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 wPt=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=Ln(U=>U.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 U=await vPt(P),le=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:F}=await U.render(le,e);if(!F||typeof F!="string"||F.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(F)}catch(U){console.error("Mermaid rendering error:",U);const le=U instanceof Error?U.message:"Failed to render mermaid diagram";a(le),c("")}finally{s(!1)}},[e,t,P]);y.useEffect(()=>{R().catch(U=>{console.error("Error in renderDiagram effect:",U),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const _=y.useCallback(()=>{try{if(!l||!r.current)return 1;const le=r.current.getBoundingClientRect(),F=document.createElement("div");F.innerHTML=l;const Z=F.querySelector("svg");if(!Z)return 1;const ne=Z.getBoundingClientRect?.()?.width||Number.parseFloat(Z.getAttribute("width")||"0")||Z.viewBox?.baseVal?.width||800,H=Z.getBoundingClientRect?.()?.height||Number.parseFloat(Z.getAttribute("height")||"0")||Z.viewBox?.baseVal?.height||600,re=le.width*.9/ne,he=le.height*.9/H;return Math.min(re,he,1)}catch(U){return console.error("Error calculating fullscreen scale:",U),1}},[l]);y.useEffect(()=>{u&&l&&setTimeout(()=>{try{const U=_();m({scale:U,x:0,y:0})}catch(U){console.error("Error setting fullscreen transform:",U)}},100)},[u,l,_]);const E=y.useCallback((U=!1)=>{try{(U?m:f)(F=>({...F,scale:Math.min(F.scale*1.2,10)}))}catch(le){console.error("Error in zoom in:",le)}},[]),C=y.useCallback((U=!1)=>{try{(U?m:f)(F=>({...F,scale:Math.max(F.scale/1.2,.1)}))}catch(le){console.error("Error in zoom out:",le)}},[]),z=y.useCallback((U=!1)=>{try{const le=U?m:f;if(U){const F=_();le({scale:F,x:0,y:0})}else le({scale:1,x:0,y:0})}catch(le){console.error("Error in reset:",le)}},[_]),W=y.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),le=URL.createObjectURL(U),F=document.createElement("a");F.href=le,F.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(le)}catch(U){console.error("Failed to save SVG:",U)}},[l]),N=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),D=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),M=y.useCallback(U=>{try{$(!0),w({x:U.clientX,y:U.clientY}),U.preventDefault()}catch(le){console.error("Error in mouse down:",le)}},[]),B=y.useCallback((U,le=!1)=>{try{if(!g)return;const F=U.clientX-v.x,Z=U.clientY-v.y;(le?m:f)(H=>({...H,x:H.x+F,y:H.y+Z})),w({x:U.clientX,y:U.clientY})}catch(F){console.error("Error in mouse move:",F)}},[g,v]),Y=y.useCallback(()=>{try{$(!1)}catch(U){console.error("Error in mouse up:",U)}},[]),A=y.useCallback((U,le=!1)=>{try{U.preventDefault();const F=U.deltaY>0?.9:1.1;(le?m:f)(ne=>({...ne,scale:Math.min(Math.max(ne.scale*F,.1),5)}))}catch(F){console.error("Error in wheel:",F)}},[]),J=y.useCallback(U=>{try{O(U)}catch(le){console.error("Error toggling fullscreen:",le)}},[]);if(i)return h.jsxs(lC,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:q("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:q("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(U=!1)=>{try{const le=U?r:n,F=U?p:d;return h.jsx("div",{ref:le,className:q("mermaid flex w-full items-center justify-center",U?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:M,onMouseMove:Z=>B(Z,U),onMouseUp:Y,onMouseLeave:Y,onWheel:Z=>A(Z,U),children:o?h.jsx("div",{className:q("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:q("flex h-full w-full items-center justify-center"),style:{transform:`translate(${F.x}px, ${F.y}px) scale(${F.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(le){return console.error("Error rendering diagram content:",le),h.jsx(lC,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:q("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(cB,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>C(!1),onReset:()=>z(!1),onSave:W,onCopy:N,children:h.jsx(Nt,{content:"Fullscreen",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>J(!0),children:h.jsx(DCe,{})})})})]}),h.jsx(J0,{open:u,onClose:()=>J(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:q("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(cB,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>C(!0),onReset:()=>z(!0),onSave:W,onCopy:D,children:h.jsx(Nt,{content:"Close fullscreen",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>J(!1),children:h.jsx(Wi,{})})})})]})})]})}),SPt=y.memo(e=>h.jsx(bPt,{children:h.jsx(wPt,{...e})}));let P1e=!1,h2=null;const xPt=()=>(h2||(h2=de(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(P1e=!0,e))),h2),QPt=/language-(\w+)/,kPt=/\n$/,T1e=({href:e,children:t})=>{const n=Abe(e),r=Bbe();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=>_Pt(i,r):void 0,children:t})},PPt=e=>Abe(e)?.kind==="file",TPt=Nbe,_Pt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(Gbe)??"file",i=n.getAttribute(TPt),a=iQt({kind:r,hasHighlight:yQt(n),canOpenInCanvas:Lbe(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||US(i)});return}US(i)}},_1e=(e,t)=>t==="href"&&PPt(e)?e:sOe(e),NA={a:T1e,table:aPt,code:({node:e,className:t,children:n,...r})=>QPt.exec(t??"")?.[1]==="mermaid"?h.jsx(SPt,{chart:String(n).replace(kPt,"")}):h.jsx("code",{className:t,...r,children:n})},XPt={...NA,a:Vkt(T1e)},RPt=[SO],EPt=[SO,Rk],qPt=[SO,xk],jPt=[SO,Rk,xk],CPt=[SO,Xk,Qk],zPt=[SO,Rk,Xk,Qk],APt=[SO,xk,Xk,Qk],UPt=[SO,Rk,xk,Xk,Qk],WPt={"000":RPt,"001":CPt,"010":qPt,"011":APt,100:EPt,101:zPt,110:jPt,111:UPt},YPt=[],GPt=[cLe],X1e=e=>y.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),R1e=(e,t,n)=>{const r=y.useMemo(()=>dPt(e),[e]),[i,a]=y.useState(P1e),o=r&&i;return y.useEffect(()=>{if(!r||i)return;let s=!1;return xPt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:WPt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?GPt:YPt}},E1e=(e,t)=>{const[,n]=y.useState(0);y.useEffect(()=>{if(!t)return;const r=ABe(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=oQt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return Ybe(r,window.api?.probeFiles,noe).then(()=>{i&&r.some(s=>Wbe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},Ek=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}=R1e(a,r,i),l=X1e(t);return E1e(a,r),h.jsx("div",{className:q("lo-markdown",n),style:l,children:h.jsx(oOe,{remarkPlugins:o,rehypePlugins:s,urlTransform:_1e,components:i?XPt:NA,children:a})})});Ek.displayName="MarkdownRenderer";const q1e=y.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=R1e(e,!0,!1);return E1e(e,!0),h.jsx(oOe,{remarkPlugins:t,rehypePlugins:n,urlTransform:_1e,components:NA,children:e})});q1e.displayName="StableBlock";const j1e=y.memo(({text:e,animate:t})=>h.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));j1e.displayName="ArrivedText";const C1e=({content:e,styleProps:t,className:n})=>{const r=y.useRef(null);r.current===null&&(r.current=xQt());const i=r.current,a=y.useRef([]),o=y.useRef(0);TQt(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+_Qt(e.slice(l)),d=[{offset:l,animate:!1}];for(const p of c){if(p.offset>=O)break;d.push(p)}const f=X1e(t);return h.jsxs("div",{className:q("lo-markdown",n),style:f,children:[i.blocks.map((p,m)=>h.jsx(q1e,{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(j1e,{text:e.slice(p.offset,g),animate:p.animate},p.offset)})})]})};C1e.displayName="StreamingMarkdown";const Jo=({isUser:e,children:t,className:n})=>e?h.jsx("div",{className:q("flex w-full justify-end",n),children:t}):h.jsx("div",{className:q("group relative w-full",n),children:t}),ZA=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},NPt=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 IA=ZA(Date.now()),Uu=null;const aw=new Set,z1e=()=>{Uu!==null&&clearTimeout(Uu),Uu=setTimeout(()=>{Uu=null,IA=ZA(Date.now());for(const e of aw)e();z1e()},NPt(Date.now())),Uu.unref?.()},ZPt=e=>(aw.add(e),IA=ZA(Date.now()),z1e(),()=>{aw.delete(e),aw.size===0&&Uu!==null&&(clearTimeout(Uu),Uu=null)}),uB=()=>IA,IPt=()=>y.useSyncExternalStore(ZPt,uB,uB),DPt=e=>new Date(e+1e3),VPt=()=>DPt(IPt()),Brn=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),""}},MPt=(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),""}},LPt=(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),""}},FPt={turn:"Sent",answer:"Answered",tool:"Ran"},A1e=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=VPt();if(Number.isNaN(r.getTime()))return null;const a=LPt(r,{hour12:!0});return h.jsx(Nt,{content:a,side:"bottom",delayDuration:1200,children:h.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${FPt[t]} ${a}`,className:q("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:MPt(r,i)})})},DA=({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(MCe,{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(Ae,{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(Wi,{"aria-hidden":"true"})})]},n.id))]}),BPt=({children:e,className:t})=>h.jsx("span",{"aria-hidden":!0,className:q("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),HPt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},KPt=({line:e})=>h.jsx("span",{className:q(HPt[e.kind],"block"),children:e.text}),JPt=({diff:e,className:t})=>{const n=KXe(e);return h.jsxs("div",{className:q("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(KPt,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:JXe(n.hidden)})]})},e5t=(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()},OB=e=>e.startsWith("file://")?e.slice(7):e,t5t={READ:{verb:"Read",runningVerb:"Reading",icon:z6},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:Vse},EDIT:{verb:"Edited",runningVerb:"Editing",icon:d7e},CODE:{verb:"Ran code",runningVerb:"Running code",icon:Use},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:P7e},DONE:{verb:"Finished",runningVerb:"Finishing",icon:i6},ASK:{verb:"Asked",runningVerb:"Asking",icon:fQ},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:sCe}},n5t={verb:"Worked on the request",runningVerb:"Working on the request",icon:Use},r5t=(e,t,n,r)=>{const i=e?t5t[e]:n5t;let a;if(t)a=OB(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=OB(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?e5t(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},dB="min-h-5 py-0",i5t=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>h.jsxs("span",{className:q("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[h.jsx(BPt,{className:q(a?"text-danger":"text-ink-dim",o&&Kle),children:e}),h.jsxs("span",{className:q(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[h.jsxs("span",{...R5,className:q("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?h.jsxs("span",{...R5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?h.jsxs("span",{...R5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),fB=({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=r5t(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?Jh:p.icon,$=a||!c||!O?h.jsx(g,{}):O,v=h.jsx(i5t,{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(ns,{summary:v,chevron:"leading",summaryAlign:w,defaultOpen:o,className:l,rowClassName:f?dB:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx(ns,{disabled:!0,summary:v,summaryAlign:w,className:l,rowClassName:f?dB:void 0})},U1e=8,a5t="… deeper values not shown",o5t="(empty)";function s5t(e){return`… ${e} more line${e===1?"":"s"}`}const hB=.5;function l5t(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 W1e(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function VA(e){return typeof e=="object"&&e!==null}function Y1e(e,t,n,r){if(n>U1e){r.push({key:t,value:a5t,depth:n});return}if(VA(e)){for(const[a,o]of Object.entries(e))Y1e(o,t?`${t}.${a}`:a,n+1,r);return}const i=W1e(e);i!==null&&r.push({key:t,value:i,depth:n})}function G1e(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))Y1e(r,n,1,t);return t}const c5t=512;function u5t(e,t){if(t)return!0;if(!e)return!1;let n=c5t;const r=(i,a)=>{if(n--<=0||a>U1e)return!0;if(!VA(i))return W1e(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 O5t(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(!VA(n))return null;const r=G1e(n);return r.length>0?r:[{key:"",value:o5t,depth:1}]}const d5t=8,cC="max-h-[min(320px,40vh)]",f5t=cC,h5t=({line:e})=>h.jsxs("div",{className:q("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*d5t},children:[e.key?h.jsxs("span",{className:q("text-ink-muted"),children:[e.key,": "]}):null,h.jsx("span",{className:q("text-ink-dim"),children:e.value})]}),pB=({lines:e,label:t})=>h.jsx("div",{className:q("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>h.jsx(h5t,{line:n},r))});function mB(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+hB);const f=c.children.length>0?Array.from(c.children):[c];n(l5t(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,hB))};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 gB=({lines:e,overflowing:t})=>t?h.jsx("span",{className:q("mt-1 block text-ink-dim"),children:e>0?s5t(e):" "}):null,p5t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=G1e(e),o=O5t(t),s=y.useRef(null),l=y.useRef(null),c=mB(s),u=mB(l);return a.length===0&&!t&&!i?null:h.jsxs("div",{className:q("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:q(cC,"overflow-auto"),children:h.jsx(pB,{lines:a,label:"input"})}),h.jsx(gB,{lines:c.lines,overflowing:c.overflowing})]}),i&&h.jsx("div",{className:q("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:q(a.length>0&&"mt-3"),"data-detail-section":"output",children:[h.jsx("span",{className:q("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),h.jsx("div",{ref:l,className:q(cC,"overflow-auto"),children:o?h.jsx(pB,{lines:o,label:"result-json"}):h.jsx("pre",{className:q("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(gB,{lines:u.lines,overflowing:u.overflowing})]})]})},m5t="mcp__",g5t={bash:R7e,read:W6,write:IY,edit:IY,glob:K0,grep:Ty,todo:ACe,wake:hQ,list_variables:MY,read_variable:MY,browser:DY,console:G6,project:tCe,project_delete:q7e,web_search:DY,web_fetch:pQ,task:Qd,agent:Qd,send:Fse,peer:XCe,sessions:p7e};function $5t(e){const t=e.trim().toLowerCase(),n=g5t[t];return n||(t.startsWith(m5t)?Mse:G7e)}const y5t=A6,v5t=ZCe,b5t=GCe,$B="min-h-5 py-0",yB={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},w5t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?yB.plain:yB[YXe(t)],S5t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",x5t=({added:e,removed:t})=>e<=0&&t<=0?null:h.jsxs("span",{className:q("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&h.jsxs("span",{className:q("text-success"),children:["+",e]}),t>0&&h.jsxs("span",{className:q("text-danger"),children:["-",t]})]}),p2={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},Q5t=1e3;function k5t(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,Q5t);return()=>window.clearInterval(i)},[e]),t}const P5t=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=k5t(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?TXe[t]:void 0,c=s?l??null:o?l??p2[e]:null,O=q("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?RXe[t]??null:null,f=s&&t?_Xe[t]:void 0,p=s?t==="mailbox"?v5t:t==="unconfirmed"?b5t:null:e==="interrupted"?y5t:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":gO(a??0):O6(n);return h.jsxs("span",{className:q("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:q("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",m),children:[p?h.jsx(p,{"aria-hidden":!0}):null,!o&&p2[e]?h.jsx("span",{className:q("sr-only"),children:p2[e]}):null,d?h.jsx("span",{className:q("sr-only"),children:d}):null]}),h.jsx("span",{className:q("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:g})]})},Ed=({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=$5t(e),w=Gd(e),{verb:x,object:b}=voe(e,r,i,g,t,qXe(s)),S=h.jsxs("span",{className:q("flex min-w-0 flex-1 items-center gap-2"),children:[h.jsx("span",{"aria-hidden":!0,className:q("flex size-3.5 shrink-0 [&_svg]:size-3.5",w5t(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:q("shrink-0 whitespace-nowrap text-body-sm",S5t(o)),title:w,children:x}),h.jsx("span",{className:q("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:q("sr-only"),children:"pending"})]}):b}),h.jsx(x5t,{added:u,removed:O}),h.jsx(P5t,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?"bg-elevated":$?"bg-danger-wash":"hover:bg-row-hover",P=d?h.jsx(ns,{summary:S,chevron:"leading",defaultOpen:f,className:q("@container/toolrow",p),rowClassName:$B,triggerClassName:q("-mx-2 rounded-sm px-2",Q),children:d}):h.jsx(ns,{disabled:!0,summary:S,rowClassName:$B,className:q("@container/toolrow",(g||$)&&q("-mx-2 rounded-sm px-2",Q),p)});return m?h.jsxs("div",{className:q("flex flex-col"),children:[P,m]}):P},T5t=3,N1e=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},Z1e=e=>{const t=new Map;let n=0;for(const a of e){const o=N1e(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=R5t(E5t(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}},_5t=e=>Z1e(e).units;function X5t(e){return _5t(e).join(" · ")}const vB={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"}},m2=5,R5t=e=>{if(e.length<=m2)return e.map(r=>r.label);const t=e.slice(0,m2),n=e.slice(m2).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},E5t=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=N1e(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",vB.todo);else{const u=vB[l];if(u)n(`kind:${l}`,u);else{const O=Gd(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 q5t(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 j5t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=q5t(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 C5t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return voe(n.name,n.summary??"",null,!0,n.op)}return null}function z5t(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>=T5t)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:a,summary:Z1e(a),failedCount:a.filter(o=>o.failed).length,span:j5t(a),live:C5t(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 bB=e=>{const t=[];for(const n of e)n.record.kind==="tool"&&t.push(...n.record.images);return t},ow=5,A5t=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<ow?{shown:Math.max(e,0),more:0}:{shown:ow-1,more:e-(ow-1)},U5t=e=>{const t=ow-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},YS=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function uC(e){return e.record.kind==="tool"?e.record.durationS:null}function W5t(e){let t=null;for(const n of e){const r=uC(n);typeof r=="number"&&(t=(t??0)+r)}return t}function Y5t(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 G5t="min-h-5 py-0",N5t=1e3;function Z5t(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,N5t);return()=>window.clearInterval(i)},[e]),t}const I5t=({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=Z5t(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":O6(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(ns,{open:i,onOpenChange:a,rowClassName:G5t,triggerClassName:q("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:h.jsxs("span",{className:q("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:q("min-w-0 shrink-[100000] truncate"),title:`${r.verb} ${r.object}`,children:[h.jsx("span",{className:q("text-accent"),children:r.verb})," ",h.jsx("span",{className:q("font-mono text-mono-sm text-ink-muted"),children:r.object})]}),h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"})]}),h.jsx("span",{className:q("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:q(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),YS(l)!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{className:q("shrink-0 text-ink-muted text-meta"),children:YS(l)})]}),f!==""&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{"data-fold-span":"",className:q("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:f})]})]}),children:h.jsx("div",{className:q("flex flex-col"),children:u})}),!i&&s&&s(m)]})},D5t="min-h-5 py-0",g2=()=>h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),V5t=({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:q("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(ns,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:D5t,triggerClassName:q("-ml-2 -mr-2 w-[calc(100%+1rem)] rounded-sm pl-2 pr-6","hover:bg-row-hover"),chevronClassName:q("-mr-6","text-ink-muted"),summary:h.jsxs("span",{className:q("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&h.jsx(h.Fragment,{children:h.jsx(i6,{"aria-hidden":!0,className:q("size-3.5 shrink-0 text-success")})}),c!==null&&(i!==null||a>0)&&h.jsx(g2,{}),i!==null&&h.jsxs("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:["Took ",gO(i)]}),i!==null&&a>0&&h.jsx(g2,{}),a>0&&h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),title:o?$:void 0,"aria-label":o?$:void 0,children:g}),YS(m)!==null&&h.jsxs(h.Fragment,{children:[h.jsx(g2,{}),h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:YS(m)})]}),u&&h.jsx("span",{className:q("sr-only"),children:"completed"}),l!==null&&h.jsx("span",{className:q("ml-auto"),children:h.jsx(A1e,{timestamp:l,scope:"answer"})})]}),children:h.jsx("div",{className:q("flex flex-col"),children:f})}),!O&&p&&h.jsx("div",{className:q("pb-2"),children:p(w)})]})},I1e=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)},wB=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],M5t=80,L5t=1e3,F5t=({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=I1e("(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)),L5t):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const w=window.setInterval(()=>o(x=>(x+1)%wB.length),M5t);return()=>{window.clearInterval(w),v!==null&&window.clearInterval(v)}},[d,O]),h.jsxs("div",{className:q("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[h.jsx("span",{"aria-hidden":!0,className:q("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:wB[a]}),h.jsx("span",{className:q("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),h.jsx("span",{"aria-hidden":!0,className:q("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?gO(s):""})]})},D1e="lo-missing-session-notice",B5t=/^\s*<reply-to>([\s\S]*?)<\/reply-to>/,MA=e=>{const t=[];let n=e;for(;;){const r=B5t.exec(n);if(r===null)break;t.push({id:Io(),text:r[1]}),n=n.slice(r[0].length)}return{replies:t,remainingContent:n.trim()}},V1e=({children:e,className:t,boundary:n="hairline",...r})=>h.jsx("div",{className:q("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm",n==="control"?["bg-media-surface","border border-transparent","transition-colors duration-fast ease-out-quart","group-hover/tile:border-control group-focus-visible/tile:border-control"]:["border border-hairline","bg-sunken"],t),...r,children:e}),H5t="could not be displayed. It may have been moved, renamed, or deleted.",M1e="could not be displayed. Its stored copy is not available to this reader.",OC=({name:e,detail:t=H5t,className:n,compact:r=!1})=>r?h.jsx("div",{className:q("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(VY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):h.jsxs("div",{className:q("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(VY,{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}`]})]}),K5t=({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),ap("File path copied to clipboard")}catch(s){console.error("Failed to copy file path: ",s),Ua("Failed to copy file path")}},o=()=>{e&&window.api.openFile(e)};return h.jsxs(Tae,{children:[h.jsx(Nt,{content:t,children:h.jsx(_ae,{asChild:!0,children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:s=>s.stopPropagation(),children:n??h.jsx(uCe,{"aria-hidden":"true"})})})}),h.jsxs(Xae,{align:"end",className:"min-w-45",onClick:s=>s.stopPropagation(),children:[i&&h.jsxs($c,{onSelect:i,children:[h.jsx(CCe,{"aria-hidden":"true"}),h.jsx("span",{children:"Show in canvas"})]}),h.jsxs($c,{onSelect:o,children:[h.jsx(Y6,{"aria-hidden":"true"}),h.jsx("span",{children:"Open file"})]}),h.jsxs($c,{onSelect:()=>window.api.showItemInFolder(e),children:[h.jsx(K0,{"aria-hidden":"true"}),h.jsx("span",{children:"Open folder"})]}),h.jsxs($c,{onSelect:a,children:[h.jsx(Hje,{"aria-hidden":"true"}),h.jsx("span",{children:"Copy file path"})]})]})]})},$2="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",L1e=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a})=>{const[o,s]=y.useState(!1);return e6(n,"image-lightbox"),h.jsx(t6,{open:n,onOpenChange:r,children:h.jsxs(n6,{showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:l=>{const c=i?.current;c&&(l.preventDefault(),c.focus())},className:q("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none",$2,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx(r6,{className:"sr-only",children:t}),o?h.jsx("div",{className:q($2,"flex min-h-16 min-w-64 items-center justify-center p-6"),children:a}):h.jsx("img",{src:e,alt:t,className:q($2,"object-contain"),onError:()=>s(!0)}),h.jsx(F5e,{asChild:!0,children:h.jsx(Ae,{variant:"ghost",size:"icon-sm",className:q("fixed top-4 right-4"),"aria-label":"Close image",children:h.jsx(Wi,{"aria-hidden":"true"})})})]})})};L1e.displayName="ImageLightbox";const J5t={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(" ")},eTt=/[/\\]/,SB=e=>{const t=e.split(eTt);return t[t.length-1]},F1e=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=Ln(x=>x.setCanvasOpen),{setViewMode:f}=fd(),p=y.useCallback(async()=>{const x=SB(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}=fd.getState();if(e.startsWith("data:"))if(eC(x)){const R=e,_={id:R,title:x,path:R,content:e,type:Vw(e)},C=fd.getState().conversations?.[n],z=C?.files??[],W=C?.openTabs??[],N=(()=>{const B=z.findIndex(Y=>Y.id===R);return B!==-1?[...z.slice(0,B),_,...z.slice(B+1)]:[...z,_]})();S(n,N);const M=W.some(B=>B.id===R)?W:[...W,{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&&eC(x)){const E=R,C={id:E,title:x,path:R,content:_.data,type:Vw(e)},W=fd.getState().conversations?.[n],N=W?.files??[],D=W?.openTabs??[],M=(()=>{const A=N.findIndex(J=>J.id===E);return A!==-1?[...N.slice(0,A),C,...N.slice(A+1)]:[...N,C]})();S(n,M);const Y=D.some(A=>A.id===E)?D:[...D,{id:E,title:x}];Q(n,Y),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??SB(e);if(a)return h.jsx(OC,{name:v,compact:i==="thumbnail"});const w=h.jsx(V1e,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:q(J5t[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:q("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(K5t,{filePath:$,tooltip:"File actions","aria-label":"File actions",onShowInCanvas:p})}),h.jsx(L1e,{src:t,label:v,open:c,onOpenChange:u,restoreFocusTo:O,fallback:h.jsx(OC,{name:v,detail:g?void 0:M1e})})]})});F1e.displayName="ImageAttachment";const sw=new Map;function tTt(e,t){const n=sw.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await rp(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=eue(i.data,i.mimeType);return r.holders<=0?(URL.revokeObjectURL(a),null):(nue(t,a),a)}catch{return null}finally{sw.delete(t)}})(),sw.set(t,r),r.promise}function nTt(e){const t=sw.get(e);t&&(t.holders-=1)}function rTt(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=y.useState(()=>e.attachment?tue(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=jw(u);if(d)return i(d),o(!1),()=>{O=!1,Cw(u)};i(null),o(!1);let f=!0;return tTt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(jw(u))}}),()=>{O=!1,f&&nTt(u),Cw(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 qk=({image:e,scope:t,label:n,size:r})=>{const i=rTt(e,t);if(i.state==="resolving")return h.jsx("div",{className:q("inline-block max-w-full"),"aria-hidden":!0,children:h.jsx(V1e,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""})});if(i.state==="missing")return h.jsx(OC,{name:n,compact:r==="thumbnail",detail:M1e});const a=i.url;return h.jsx("div",{className:q("inline-block max-w-full"),children:h.jsx(F1e,{file:a,src:a,label:n,size:r,conversationId:t?.sessionId??""})})},iTt="Generating name…",aTt={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 oTt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function LA(e,t){return`Turn ${e} of ${t}`}const sTt=e=>e.charAt(0).toLowerCase()+e.slice(1);function lTt(e,t){const n=LA(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function cTt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function uTt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function OTt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const dTt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function fTt(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 hTt(e,t){const n=sTt(LA(e.turn,t));if(e.kind==="user"){const i=fTt(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 pTt(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 mTt(e,t){const n=[];for(const r of t)pTt(e,r)==="pending"&&n.push(r);return n}const gTt=120,xB=80,$Tt="Turn checkpoints",yTt={complete:Jc,error:Jh,interrupted:A6,open:Dje},vTt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},bTt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?yTt[n]:null,i=uTt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:q("text-body-sm font-medium text-ink"),children:[LA(e.turn,t),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:q("font-normal text-ink-muted"),children:a})]})]}),cTt(e)&&h.jsx("p",{className:q("text-ink-dim text-meta"),children:iTt}),i&&h.jsx("p",{className:q("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&h.jsx("div",{className:q("flex items-center gap-1.5 text-ink-dim text-meta"),children:h.jsxs("span",{className:q("flex items-center gap-1",vTt[n]),children:[h.jsx(r,{"aria-hidden":"true",className:q("size-3.5 shrink-0")}),dTt[n]]})})]})},wTt=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:q("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:q("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",aTt[n])})})}),STt=({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 H=()=>{O(Z),f(p.current.find(re=>re.id===Z)??null)};if(ne<=0){H();return}$.current=setTimeout(()=>{$.current=null,H()},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(),Y.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 H=Z.getBoundingClientRect(),re=ne.getBoundingClientRect(),he=re.top-H.top+Z.scrollTop,we=he+re.height,ce=24;he<Z.scrollTop+ce?Z.scrollTop=Math.max(0,he-ce):we>Z.scrollTop+Z.clientHeight-ce&&(Z.scrollTop=we-Z.clientHeight+ce)},[o]),y.useEffect(()=>()=>w(),[w]);const Q=y.useRef(r);y.useEffect(()=>{Q.current=r});const P=y.useMemo(()=>OTt(t),[t]),R=y.useMemo(()=>new Map(t.map(Z=>[Z.id,hTt(Z,P)])),[t,P]),_=u&&d?.id===u?d:null,E=u&&m.current.get(u)||null,C=y.useMemo(()=>({current:E}),[E]),z=_!==null&&E!==null;y.useEffect(()=>{Q.current(z&&u?u:null)},[z,u]);const W=y.useCallback((Z,ne)=>{ne?m.current.set(Z,ne):m.current.delete(Z)},[]),[N,D]=y.useState(null),M=N&&t.some(Z=>Z.id===N)?N:t[0]?.id??null,B=y.useCallback(Z=>{const ne=Math.max(0,Math.min(t.length-1,Z)),H=t[ne];H&&(D(H.id),m.current.get(H.id)?.focus())},[t]),Y=y.useRef(null),A=y.useCallback(Z=>{Y.current!==Z&&(Y.current=Z,c(Z),x(Z,gTt))},[x]),J=y.useCallback(()=>{Y.current=null,c(Z=>Z===null?Z:null),b(xB)},[b]),K=y.useCallback(Z=>{Y.current=Z,D(Z),c(ne=>ne===Z?ne:Z),x(Z,0)},[x]),U=y.useCallback(()=>{Y.current=null,c(Z=>Z===null?Z:null),b(xB)},[b]),le=y.useCallback(Z=>{b(0),Y.current=null,c(null),n(Z)},[b,n]),F=y.useCallback((Z,ne)=>{if(Z.key==="Escape"){b(0);return}const H=t.findIndex(re=>re.id===ne);if(!(H<0)){if(Z.key==="ArrowDown"){Z.preventDefault(),Z.stopPropagation(),B(H+1);return}if(Z.key==="ArrowUp"){Z.preventDefault(),Z.stopPropagation(),B(H-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":$Tt,className:q("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:q("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:q("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(wTt,{checkpoint:Z,state:oTt({id:Z.id,previewId:l,activeId:o,loaded:a?a.has(Z.id):!0}),label:R.get(Z.id)??"",roving:Z.id===M,registerTick:W,onPreview:A,onPreviewEnd:J,onFocusMark:K,onBlurMark:U,onActivate:le,onKeyMark:F,describedBy:z&&u===Z.id?s:void 0},Z.id))})]}),h.jsxs(B5e,{open:z,onOpenChange:Z=>{Z||b(0)},children:[h.jsx(H5e,{virtualRef:C}),_&&h.jsx(K5e,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":_.kind==="user"?"Your message":lTt(_,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:q("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:q("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:_.text}):h.jsx(bTt,{checkpoint:_,turnCount:P})})]})]})},xTt=y.memo(STt);function QTt(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 kTt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function PTt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function B1e(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):!kTt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function TTt(e,t){return PTt(e,t)||B1e(e,t)!==null}const _Tt=3;function XTt(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>=_Tt){n.onMissing();return}const s=B1e(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const QB=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=A5t(e.length,{uncapped:r}),s=U5t(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:q("flex leading-none",l&&c.has(d)&&"col-start-1"),children:h.jsx(qk,{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:q("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:q("flex h-[78px] items-center leading-none"),children:h.jsx(Ae,{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 RTt(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 ETt(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 qTt=new Set(["generate_image"]);function jTt(e){return qTt.has(e)}function CTt(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n.message;typeof r=="string"&&r&&t.push(r)}return t}function zTt(e){const t=e??{};return{stage:typeof t.stage=="string"?t.stage:null,fraction:typeof t.progress_fraction=="number"&&Number.isFinite(t.progress_fraction)?t.progress_fraction:null,logs:CTt(t.log_lines),queuePosition:typeof t.queue_position=="number"&&Number.isInteger(t.queue_position)?t.queue_position:null,error:typeof t.error=="string"&&t.error?t.error:null,errorType:typeof t.error_type=="string"&&t.error_type?t.error_type:null}}function kB(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?H1e:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const H1e=Object.freeze({fraction:null,logs:[],queuePosition:null});function ATt(e,{stopping:t=!1}={}){const n=zTt(e.details);if(e.stopped===!0)return{state:"cancelled"};if(e.notRunKind==="skipped"||e.notRunKind==="aborted")return{state:"cancelled"};if(e.notRunReason)return{state:"failed",message:e.notRunReason,errorType:null};if(e.neverSent===!0)return{state:"cancelled"};if(e.isError===!0)return n.errorType==="media_already_completed"?{state:"done",images:e.images??[],durationS:e.durationS??null,receipt:"already-finished"}:n.stage==="cancelled"&&n.errorType===null?{state:"cancelled"}:{state:"failed",message:n.error??e.output,errorType:n.errorType};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,startedAtMs:null,progress:H1e}:{state:"queued",composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:n.queuePosition};case"running":{const r=e.startedAt??null;return t?{state:"cancelling",generating:!0,startedAtMs:r,progress:kB(n)}:{state:"running",startedAtMs:r,progress:kB(n),note:n.error}}case"done":return{state:"done",images:e.images??[],durationS:e.durationS??null,receipt:"generated"}}}function UTt(e,t){const n=[],r=e.state==="queued"||e.state==="running"||e.state==="cancelling";t?.onCancel&&r&&n.push({kind:"cancel",disabled:e.state==="cancelling"});const i=e.state==="failed"||e.state==="cancelled";return t?.onRestart&&i&&n.push({kind:"restart",disabled:!1}),t?.onEditRestart&&i&&n.push({kind:"editRestart",disabled:!1}),n}const WTt=1e3;function YTt(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,WTt);return()=>window.clearInterval(i)},[e]),t}function GTt(){return h.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:q("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:h.jsx("span",{className:q("absolute inset-0","animate-shimmer","bg-gradient-to-r from-transparent via-elevated to-transparent","bg-[length:200%_100%]","bg-[position:-200%_50%]","bg-no-repeat")})})}function NTt({view:e,elapsed:t}){let n,r=null,i=!1;switch(e.state){case"queued":n=e.composing?"Writing the request…":"Queued",r=e.queuePosition!==null?`${e.queuePosition} ahead`:e.argumentBytes>0?x1(e.argumentBytes):null;break;case"running":n="Generating image…",r=t===null?null:gO(t);break;case"cancelling":n="Cancelling…";break;case"done":n=e.receipt==="already-finished"?"Already finished.":"Generated image",r=e.receipt==="already-finished"||e.durationS===null?null:O6(e.durationS);break;case"failed":n=e.message??"The image could not be generated.",i=!0;break;case"cancelled":n="Cancelled";break}return h.jsxs("p",{className:q("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[h.jsx("span",{className:q("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:h.jsxs("span",{className:q("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function ZTt({line:e}){return h.jsx("p",{"data-imagegen-log":"",title:e,className:q("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function ITt({line:e}){return h.jsx("p",{"data-imagegen-note":"",className:q("min-w-0 text-body-sm text-ink-dim"),children:e})}function DTt(e,t){return e==="cancel"?"Cancel":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const VTt=({view:e,scope:t,actions:n})=>{const r=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,i=YTt(r),a=UTt(e,n),o={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},s=e.state==="running"||e.state==="cancelling",l=s&&(e.state==="running"||e.generating),c=s&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return h.jsxs("div",{"data-imagegen-card":e.state,className:q("flex w-full flex-col gap-2"),children:[l?h.jsx(GTt,{}):null,h.jsx(NTt,{view:e,elapsed:i}),e.state==="running"&&typeof e.note=="string"?h.jsx(ITt,{line:e.note}):null,l&&e.progress.fraction!==null?h.jsx(J5e,{"aria-label":"Image generation progress",className:q("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,c===null?null:h.jsx(ZTt,{line:c}),e.state==="done"&&e.images.length>0?h.jsx("div",{className:q("flex flex-col gap-2"),children:e.images.map((u,O)=>h.jsx(qk,{image:u,scope:t,label:e.images.length===1?"Generated image":`Generated image ${O+1}`},u.id))}):null,a.length>0?h.jsx("div",{"data-imagegen-controls":"",className:q("flex items-center gap-2"),children:a.map(u=>h.jsx(Ae,{variant:"secondary",size:"sm",disabled:u.disabled,onClick:o[u.kind],children:DTt(u.kind,e.state)},u.kind))}):null]})},w0=1e4,K1e=/\s/,MTt=e=>{for(let t=e.length;t>0;t-=1){const n=e[t-1];if(n===`
823
+ `)&&(s={capture:WS(e),buffer:n,caret:r})}return{...s,capture:Ph(s.capture,s.buffer,s.caret,i)}}function skt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Tf(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=p1e(i,t.value),c=l+Tk,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:qa,buffer:u,caret:s+c.length,payload:{index:i,key:y1e(a,e.draw),value:t.value,marker:l}}}function lkt(e,t){const n=Tf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=$1e(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:qa,buffer:i,caret:n.start+r.length,restored:iC(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:iC(r),restoredText:r}}}function MF(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function ckt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Tf(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:WS(e),buffer:i,caret:a,payload:null}}function ukt(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=GA(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=$n(i);if(!a)return i===""?null:ckt(t,n,e.selection,i);const o=t.arm,s=p1e(e.index,a),l=s+Tk,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:qa,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:y1e(e.taken,e.draw),value:a,marker:s}}}const h1e=e=>`${iC(e)} chars`,p1e=(e,t)=>`[Credential #${e}, ${h1e(t)}]`;function Okt(e){wl.lastIndex=0;const t=wl.exec(e);return wl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function dkt(e){wl.lastIndex=0;const t=wl.exec(e);if(wl.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 tv(e,t){if(Okt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const c2=/\[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,u2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,O2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,fkt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&rC.test(t[1])?t[1]:""};function hkt(e,t){if(e.charCodeAt(t)!==91)return null;c2.lastIndex=t;const n=c2.exec(e);if(c2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};u2.lastIndex=t;const r=u2.exec(e);if(u2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};O2.lastIndex=t;const i=O2.exec(e);return O2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:fkt(i[0])}:null}function _k(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=hkt(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 LF(e,t){const n=[];for(const r of t){const i=tv(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 pkt(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 mkt=e=>`[credential ${e.key} (${h1e(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function gkt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=tv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of u1e(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?pkt(l??"lost",s?.key):mkt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const $kt=(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.`,ykt=e=>`Remove credential #${e}`,vkt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,bkt=(e,t,n)=>$kt(e,t,n),wkt="Undo",Skt=e=>`Credential #${e} removed`,xkt=e=>e.unredacted!==null?e.unredacted:e.armed?Rkt:e.cleared!==null?bkt(e.cleared.key,e.cleared.index,e.undoCap):null;function Qkt(e){const{buffer:t,payload:n}=e,r=tv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===Tk?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 kkt(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 FF=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function BF(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 Pkt="store unconfirmed",Tkt="Credential store unconfirmed",_kt=e=>e===""?Tkt:`${e} · ${Pkt}`,m1e="Paste the value again after /credential to store it again.",Xkt=e=>`${e} ${m1e}`;function HF(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. ${m1e}`}const Rkt="armed — add a space, then type or paste the secret",Ekt="masked as you type — Enter turns it into a pill, Esc cancels",qkt="masked — Enter opens the credential picker; type or paste the secret into this span",jkt="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",g1e="\0held",Ckt=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===g1e?`${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 $1e(e,t){const n=Tf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const KF=(e,t)=>e&&e.over===t?e.chars:null,zkt=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},Akt=16,Ukt=16;function y1e(e=[],t=zkt){const n=new Set(e);for(let r=0;r<Akt;r++){const i=IF+JF(8,t);if(!n.has(i))return i}return IF+JF(Ukt,t)}const JF=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=ZF[t(ZF.length)];return n},v1e=q("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),b1e=q("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),w1e=({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:q("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?b1e:v1e,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(Pae,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(ECe,{"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(Wi,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),A$="#lo-credential/",Wkt=`${A$}unstored`,eB=`${A$}unconfirmed`,Ykt=/^\d+$/,S1e=e=>e.kind==="stored"?`${A$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${eB}/${e.key}`:eB:Wkt;function Gkt(e){if(!e||!e.startsWith(A$))return null;const t=e.slice(A$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return rC.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!rC.test(r)||!Ykt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function tB(e,t){const n=Gkt(e);if(n===null)return null;const r=_k(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return S1e(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=_k(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:S1e(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},Nkt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?_kt(e.key):"Credential not stored",Zkt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?Xkt(t):t,Ikt=({citation:e,title:t})=>h.jsx(w1e,{tone:e.kind==="stored"?"live":"warning",label:Nkt(e),chars:e.kind==="stored"?e.chars:null,title:Zkt(e,t),className:"align-middle"}),Dkt=(e,t)=>typeof t=="string"?tB(e,t):t==null?tB(e,""):null,Vkt=e=>({href:t,title:n,children:r})=>{const i=Dkt(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(Ikt,{citation:i,title:n})};function Mkt(){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 Lkt={tokenize:Fkt,concrete:!0,name:"mathFlow"},nB={tokenize:Bkt,partial:!0};function Fkt(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"),ln(e,c,"whitespace")(v))}function c(v){return v===null||yt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||yt(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(nB,d,g)(v)}function d(v){return e.attempt({tokenize:$,partial:!0},g,f)(v)}function f(v){return(a?ln(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):yt(v)?e.attempt(nB,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||yt(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 ln(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"),ln(v,P,"whitespace")(R))}function P(R){return R===null||yt(R)?(v.exit("mathFlowFence"),w(R)):x(R)}}}function Bkt(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 Hkt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Kkt,previous:Jkt,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):yt(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||yt(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 Kkt(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 Jkt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function ePt(e){return{flow:{36:Lkt},text:{36:Hkt()}}}const Th=36,rB=e=>e!==null&&e<-2,iB=e=>e===null||e===32||e<0,aB=e=>e!==null&&e>=48&&e<=57,x1e=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:tPt,previous:nPt,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===Th?(r.consume(g),s++,d):s<2&&!t||s===1&&(iB(g)||aB(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===Th?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):rB(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===Th||rB(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===Th?(r.consume(g),c++,m):c===s?s===1&&(iB(l)||aB(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function tPt(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 nPt(e){return e!==Th||this.events[this.events.length-1][1].type==="characterEscape"}const rPt=ePt().flow,iPt=x1e();function Rk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?iPt:x1e(e);n.push({flow:rPt,text:{[Th]:i}}),r.push(Mkt())}const aPt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),oPt=/\$(?!\d)(.+?)\$/,sPt=/\$\$([\s\S]+?)\$\$/,lPt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,cPt=/\\[a-zA-Z]+(\{[^}]*\})?/,oB=e=>oPt.test(e)||sPt.test(e)||lPt.test(e)?!0:cPt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),uPt=e=>{const t=_k(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},OPt=e=>_k(e).filter(t=>t.kind!=="text").length,dPt=e=>{if(!oB(e))return!1;const t=uPt(e);return t===null?!0:oB(t)||t.includes("$")?!1:OPt(e)<2},tn="var(--color-ink)",Hl="var(--color-ink-muted)",nl="var(--color-surface)",Qu="var(--color-elevated)",Kl="var(--color-sunken)",Zi="var(--color-hairline)",ku="var(--color-control)",ah="var(--color-accent)",Gg="var(--color-accent-wash)",fPt="var(--color-accent-alt-wash)",hPt="var(--color-on-accent)",pPt="var(--color-info)",Q1e="var(--color-info-wash)",mPt="var(--color-success)",k1e="var(--color-success-wash)",gPt="var(--color-warning)",oC="var(--color-warning-wash)",$Pt="var(--color-warning-border)",d2="var(--color-danger)",sC="var(--color-danger-wash)",sB=[Gg,fPt,Q1e,k1e,oC,sC],Pu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),yPt=()=>{const e={primaryColor:Pu("--color-accent"),secondaryColor:Pu("--color-success"),tertiaryColor:Pu("--color-info"),mainBkg:Pu("--color-elevated"),clusterBkg:Pu("--color-sunken"),clusterBorder:Pu("--color-hairline"),edgeLabelBackground:Pu("--color-surface"),quadrant1Fill:Pu("--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:nl,primaryTextColor:tn,primaryBorderColor:ku,secondaryTextColor:tn,secondaryBorderColor:Zi,tertiaryTextColor:tn,tertiaryBorderColor:Zi,lineColor:Hl,arrowheadColor:Hl,textColor:tn,secondBkg:Kl,border1:ku,border2:Zi,labelColor:tn,nodeBkg:Qu,nodeBorder:ku,nodeTextColor:tn,defaultLinkColor:Hl,titleColor:tn,noteBkgColor:oC,noteBorderColor:$Pt,noteTextColor:tn,actorBkg:Qu,actorBorder:ku,actorTextColor:tn,actorLineColor:Zi,signalColor:Hl,signalTextColor:tn,labelBoxBkgColor:Qu,labelBoxBorderColor:Zi,labelTextColor:tn,loopTextColor:tn,activationBkgColor:Gg,activationBorderColor:ah,sequenceNumberColor:nl,sectionBkgColor:Kl,sectionBkgColor2:nl,altSectionBkgColor:Kl,excludeBkgColor:Kl,taskBkgColor:Gg,taskBorderColor:ku,taskTextColor:tn,taskTextLightColor:tn,taskTextDarkColor:tn,taskTextOutsideColor:tn,taskTextClickableColor:ah,activeTaskBkgColor:Gg,activeTaskBorderColor:ah,gridColor:Zi,doneTaskBkgColor:Kl,doneTaskBorderColor:Zi,critBkgColor:sC,critBorderColor:d2,todayLineColor:ah,transitionColor:Hl,transitionLabelColor:tn,stateLabelColor:tn,stateBkg:Qu,labelBackgroundColor:nl,compositeBackground:Kl,altBackground:Kl,compositeTitleBackground:Qu,compositeBorder:Zi,innerEndBackground:tn,specialStateColor:tn,classText:tn,attributeBackgroundColorOdd:nl,attributeBackgroundColorEven:Kl,rowOdd:nl,rowEven:Kl,errorBkgColor:sC,errorTextColor:d2,pieTitleTextColor:tn,pieSectionTextColor:tn,pieLegendTextColor:tn,pieStrokeColor:nl,pieOuterStrokeColor:Zi,requirementBackground:Qu,requirementBorderColor:ku,requirementTextColor:tn,relationColor:Hl,relationLabelBackground:nl,relationLabelColor:tn,branchLabelColor:hPt,commitLabelColor:tn,commitLabelBackground:nl,tagLabelColor:tn,tagLabelBackground:Gg,tagLabelBorder:ku,quadrant2Fill:Q1e,quadrant3Fill:k1e,quadrant4Fill:oC,quadrant2TextFill:tn,quadrant3TextFill:tn,quadrant4TextFill:tn,quadrantPointFill:ah,archEdgeColor:Hl,archEdgeArrowColor:Hl,archGroupBorderColor:Zi,scaleLabelColor:tn,packet:{startByteColor:tn,endByteColor:tn,labelColor:tn,titleColor:tn,blockStrokeColor:ku,blockFillColor:Qu},radar:{axisColor:Hl,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Zi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:nl,titleColor:tn,xAxisTitleColor:tn,xAxisLabelColor:tn,xAxisTickColor:Zi,xAxisLineColor:Zi,yAxisTitleColor:tn,yAxisLabelColor:tn,yAxisTickColor:Zi,yAxisLineColor:Zi,plotColorPalette:[ah,pPt,mPt,gPt,d2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Qu,t[`surfacePeer${n}`]=Zi;for(let n=0;n<8;n++)t[`fillType${n}`]=sB[n%sB.length];return{...t,...e}};let f2=null,lB=null;const vPt=async e=>{f2||(f2=de(async()=>{const{default:n}=await import("./mermaid.core-CKrFHA95.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,2,3]),import.meta.url).then(({default:n})=>n));const t=await f2;return lB!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:yPt()}),lB=e),t},cB=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:q("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(Nt,{content:"Zoom in",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(D7e,{})})}),h.jsx(Nt,{content:"Zoom out",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(M7e,{})})}),h.jsx(Nt,{content:"Drag the diagram to pan",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(e7e,{})})}),h.jsx(Nt,{content:"Reset view",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(N6,{})})}),h.jsx(Nt,{content:"Save as SVG",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(pQ,{})})}),h.jsx(Nt,{content:t?"Copied":"Copy mermaid text",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(U6,{className:q(t&&"text-success")})})}),s]}),lC=({title:e,children:t})=>h.jsxs(Ql,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(Mg,{children:e}),h.jsx(Lg,{children:t})]});class bPt 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(lC,{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 wPt=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=Ln(U=>U.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 U=await vPt(P),le=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:F}=await U.render(le,e);if(!F||typeof F!="string"||F.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(F)}catch(U){console.error("Mermaid rendering error:",U);const le=U instanceof Error?U.message:"Failed to render mermaid diagram";a(le),c("")}finally{s(!1)}},[e,t,P]);y.useEffect(()=>{R().catch(U=>{console.error("Error in renderDiagram effect:",U),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const _=y.useCallback(()=>{try{if(!l||!r.current)return 1;const le=r.current.getBoundingClientRect(),F=document.createElement("div");F.innerHTML=l;const Z=F.querySelector("svg");if(!Z)return 1;const ne=Z.getBoundingClientRect?.()?.width||Number.parseFloat(Z.getAttribute("width")||"0")||Z.viewBox?.baseVal?.width||800,H=Z.getBoundingClientRect?.()?.height||Number.parseFloat(Z.getAttribute("height")||"0")||Z.viewBox?.baseVal?.height||600,re=le.width*.9/ne,he=le.height*.9/H;return Math.min(re,he,1)}catch(U){return console.error("Error calculating fullscreen scale:",U),1}},[l]);y.useEffect(()=>{u&&l&&setTimeout(()=>{try{const U=_();m({scale:U,x:0,y:0})}catch(U){console.error("Error setting fullscreen transform:",U)}},100)},[u,l,_]);const E=y.useCallback((U=!1)=>{try{(U?m:f)(F=>({...F,scale:Math.min(F.scale*1.2,10)}))}catch(le){console.error("Error in zoom in:",le)}},[]),C=y.useCallback((U=!1)=>{try{(U?m:f)(F=>({...F,scale:Math.max(F.scale/1.2,.1)}))}catch(le){console.error("Error in zoom out:",le)}},[]),z=y.useCallback((U=!1)=>{try{const le=U?m:f;if(U){const F=_();le({scale:F,x:0,y:0})}else le({scale:1,x:0,y:0})}catch(le){console.error("Error in reset:",le)}},[_]),W=y.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),le=URL.createObjectURL(U),F=document.createElement("a");F.href=le,F.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(le)}catch(U){console.error("Failed to save SVG:",U)}},[l]),N=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),D=y.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),M=y.useCallback(U=>{try{$(!0),w({x:U.clientX,y:U.clientY}),U.preventDefault()}catch(le){console.error("Error in mouse down:",le)}},[]),B=y.useCallback((U,le=!1)=>{try{if(!g)return;const F=U.clientX-v.x,Z=U.clientY-v.y;(le?m:f)(H=>({...H,x:H.x+F,y:H.y+Z})),w({x:U.clientX,y:U.clientY})}catch(F){console.error("Error in mouse move:",F)}},[g,v]),Y=y.useCallback(()=>{try{$(!1)}catch(U){console.error("Error in mouse up:",U)}},[]),A=y.useCallback((U,le=!1)=>{try{U.preventDefault();const F=U.deltaY>0?.9:1.1;(le?m:f)(ne=>({...ne,scale:Math.min(Math.max(ne.scale*F,.1),5)}))}catch(F){console.error("Error in wheel:",F)}},[]),J=y.useCallback(U=>{try{O(U)}catch(le){console.error("Error toggling fullscreen:",le)}},[]);if(i)return h.jsxs(lC,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:q("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:q("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(U=!1)=>{try{const le=U?r:n,F=U?p:d;return h.jsx("div",{ref:le,className:q("mermaid flex w-full items-center justify-center",U?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:M,onMouseMove:Z=>B(Z,U),onMouseUp:Y,onMouseLeave:Y,onWheel:Z=>A(Z,U),children:o?h.jsx("div",{className:q("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:q("flex h-full w-full items-center justify-center"),style:{transform:`translate(${F.x}px, ${F.y}px) scale(${F.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(le){return console.error("Error rendering diagram content:",le),h.jsx(lC,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:q("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(cB,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>C(!1),onReset:()=>z(!1),onSave:W,onCopy:N,children:h.jsx(Nt,{content:"Fullscreen",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>J(!0),children:h.jsx(DCe,{})})})})]}),h.jsx(J0,{open:u,onClose:()=>J(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:q("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(cB,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>C(!0),onReset:()=>z(!0),onSave:W,onCopy:D,children:h.jsx(Nt,{content:"Close fullscreen",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>J(!1),children:h.jsx(Wi,{})})})})]})})]})}),SPt=y.memo(e=>h.jsx(bPt,{children:h.jsx(wPt,{...e})}));let P1e=!1,h2=null;const xPt=()=>(h2||(h2=de(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(P1e=!0,e))),h2),QPt=/language-(\w+)/,kPt=/\n$/,T1e=({href:e,children:t})=>{const n=Abe(e),r=Bbe();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=>_Pt(i,r):void 0,children:t})},PPt=e=>Abe(e)?.kind==="file",TPt=Nbe,_Pt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(Gbe)??"file",i=n.getAttribute(TPt),a=iQt({kind:r,hasHighlight:yQt(n),canOpenInCanvas:Lbe(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||US(i)});return}US(i)}},_1e=(e,t)=>t==="href"&&PPt(e)?e:sOe(e),NA={a:T1e,table:aPt,code:({node:e,className:t,children:n,...r})=>QPt.exec(t??"")?.[1]==="mermaid"?h.jsx(SPt,{chart:String(n).replace(kPt,"")}):h.jsx("code",{className:t,...r,children:n})},XPt={...NA,a:Vkt(T1e)},RPt=[SO],EPt=[SO,Rk],qPt=[SO,xk],jPt=[SO,Rk,xk],CPt=[SO,Xk,Qk],zPt=[SO,Rk,Xk,Qk],APt=[SO,xk,Xk,Qk],UPt=[SO,Rk,xk,Xk,Qk],WPt={"000":RPt,"001":CPt,"010":qPt,"011":APt,100:EPt,101:zPt,110:jPt,111:UPt},YPt=[],GPt=[cLe],X1e=e=>y.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),R1e=(e,t,n)=>{const r=y.useMemo(()=>dPt(e),[e]),[i,a]=y.useState(P1e),o=r&&i;return y.useEffect(()=>{if(!r||i)return;let s=!1;return xPt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:WPt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?GPt:YPt}},E1e=(e,t)=>{const[,n]=y.useState(0);y.useEffect(()=>{if(!t)return;const r=ABe(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=oQt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return Ybe(r,window.api?.probeFiles,noe).then(()=>{i&&r.some(s=>Wbe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},Ek=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}=R1e(a,r,i),l=X1e(t);return E1e(a,r),h.jsx("div",{className:q("lo-markdown",n),style:l,children:h.jsx(oOe,{remarkPlugins:o,rehypePlugins:s,urlTransform:_1e,components:i?XPt:NA,children:a})})});Ek.displayName="MarkdownRenderer";const q1e=y.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=R1e(e,!0,!1);return E1e(e,!0),h.jsx(oOe,{remarkPlugins:t,rehypePlugins:n,urlTransform:_1e,components:NA,children:e})});q1e.displayName="StableBlock";const j1e=y.memo(({text:e,animate:t})=>h.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));j1e.displayName="ArrivedText";const C1e=({content:e,styleProps:t,className:n})=>{const r=y.useRef(null);r.current===null&&(r.current=xQt());const i=r.current,a=y.useRef([]),o=y.useRef(0);TQt(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+_Qt(e.slice(l)),d=[{offset:l,animate:!1}];for(const p of c){if(p.offset>=O)break;d.push(p)}const f=X1e(t);return h.jsxs("div",{className:q("lo-markdown",n),style:f,children:[i.blocks.map((p,m)=>h.jsx(q1e,{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(j1e,{text:e.slice(p.offset,g),animate:p.animate},p.offset)})})]})};C1e.displayName="StreamingMarkdown";const Jo=({isUser:e,children:t,className:n})=>e?h.jsx("div",{className:q("flex w-full justify-end",n),children:t}):h.jsx("div",{className:q("group relative w-full",n),children:t}),ZA=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},NPt=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 IA=ZA(Date.now()),Uu=null;const aw=new Set,z1e=()=>{Uu!==null&&clearTimeout(Uu),Uu=setTimeout(()=>{Uu=null,IA=ZA(Date.now());for(const e of aw)e();z1e()},NPt(Date.now())),Uu.unref?.()},ZPt=e=>(aw.add(e),IA=ZA(Date.now()),z1e(),()=>{aw.delete(e),aw.size===0&&Uu!==null&&(clearTimeout(Uu),Uu=null)}),uB=()=>IA,IPt=()=>y.useSyncExternalStore(ZPt,uB,uB),DPt=e=>new Date(e+1e3),VPt=()=>DPt(IPt()),Brn=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),""}},MPt=(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),""}},LPt=(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),""}},FPt={turn:"Sent",answer:"Answered",tool:"Ran"},A1e=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=VPt();if(Number.isNaN(r.getTime()))return null;const a=LPt(r,{hour12:!0});return h.jsx(Nt,{content:a,side:"bottom",delayDuration:1200,children:h.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${FPt[t]} ${a}`,className:q("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:MPt(r,i)})})},DA=({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(MCe,{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(Ae,{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(Wi,{"aria-hidden":"true"})})]},n.id))]}),BPt=({children:e,className:t})=>h.jsx("span",{"aria-hidden":!0,className:q("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),HPt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},KPt=({line:e})=>h.jsx("span",{className:q(HPt[e.kind],"block"),children:e.text}),JPt=({diff:e,className:t})=>{const n=KXe(e);return h.jsxs("div",{className:q("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(KPt,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:JXe(n.hidden)})]})},e5t=(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()},OB=e=>e.startsWith("file://")?e.slice(7):e,t5t={READ:{verb:"Read",runningVerb:"Reading",icon:z6},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:Vse},EDIT:{verb:"Edited",runningVerb:"Editing",icon:d7e},CODE:{verb:"Ran code",runningVerb:"Running code",icon:Use},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:P7e},DONE:{verb:"Finished",runningVerb:"Finishing",icon:i6},ASK:{verb:"Asked",runningVerb:"Asking",icon:fQ},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:sCe}},n5t={verb:"Worked on the request",runningVerb:"Working on the request",icon:Use},r5t=(e,t,n,r)=>{const i=e?t5t[e]:n5t;let a;if(t)a=OB(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=OB(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?e5t(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},dB="min-h-5 py-0",i5t=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>h.jsxs("span",{className:q("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[h.jsx(BPt,{className:q(a?"text-danger":"text-ink-dim",o&&Kle),children:e}),h.jsxs("span",{className:q(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[h.jsxs("span",{...R5,className:q("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?h.jsxs("span",{...R5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?h.jsxs("span",{...R5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),fB=({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=r5t(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?Jh:p.icon,$=a||!c||!O?h.jsx(g,{}):O,v=h.jsx(i5t,{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(ns,{summary:v,chevron:"leading",summaryAlign:w,defaultOpen:o,className:l,rowClassName:f?dB:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx(ns,{disabled:!0,summary:v,summaryAlign:w,className:l,rowClassName:f?dB:void 0})},U1e=8,a5t="… deeper values not shown",o5t="(empty)";function s5t(e){return`… ${e} more line${e===1?"":"s"}`}const hB=.5;function l5t(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 W1e(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function VA(e){return typeof e=="object"&&e!==null}function Y1e(e,t,n,r){if(n>U1e){r.push({key:t,value:a5t,depth:n});return}if(VA(e)){for(const[a,o]of Object.entries(e))Y1e(o,t?`${t}.${a}`:a,n+1,r);return}const i=W1e(e);i!==null&&r.push({key:t,value:i,depth:n})}function G1e(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))Y1e(r,n,1,t);return t}const c5t=512;function u5t(e,t){if(t)return!0;if(!e)return!1;let n=c5t;const r=(i,a)=>{if(n--<=0||a>U1e)return!0;if(!VA(i))return W1e(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 O5t(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(!VA(n))return null;const r=G1e(n);return r.length>0?r:[{key:"",value:o5t,depth:1}]}const d5t=8,cC="max-h-[min(320px,40vh)]",f5t=cC,h5t=({line:e})=>h.jsxs("div",{className:q("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*d5t},children:[e.key?h.jsxs("span",{className:q("text-ink-muted"),children:[e.key,": "]}):null,h.jsx("span",{className:q("text-ink-dim"),children:e.value})]}),pB=({lines:e,label:t})=>h.jsx("div",{className:q("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>h.jsx(h5t,{line:n},r))});function mB(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+hB);const f=c.children.length>0?Array.from(c.children):[c];n(l5t(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,hB))};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 gB=({lines:e,overflowing:t})=>t?h.jsx("span",{className:q("mt-1 block text-ink-dim"),children:e>0?s5t(e):" "}):null,p5t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=G1e(e),o=O5t(t),s=y.useRef(null),l=y.useRef(null),c=mB(s),u=mB(l);return a.length===0&&!t&&!i?null:h.jsxs("div",{className:q("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:q(cC,"overflow-auto"),children:h.jsx(pB,{lines:a,label:"input"})}),h.jsx(gB,{lines:c.lines,overflowing:c.overflowing})]}),i&&h.jsx("div",{className:q("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:q(a.length>0&&"mt-3"),"data-detail-section":"output",children:[h.jsx("span",{className:q("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),h.jsx("div",{ref:l,className:q(cC,"overflow-auto"),children:o?h.jsx(pB,{lines:o,label:"result-json"}):h.jsx("pre",{className:q("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(gB,{lines:u.lines,overflowing:u.overflowing})]})]})},m5t="mcp__",g5t={bash:R7e,read:W6,write:IY,edit:IY,glob:K0,grep:Ty,todo:ACe,wake:hQ,list_variables:MY,read_variable:MY,browser:DY,console:G6,project:tCe,project_delete:q7e,web_search:DY,web_fetch:pQ,task:Qd,agent:Qd,send:Fse,peer:XCe,sessions:p7e};function $5t(e){const t=e.trim().toLowerCase(),n=g5t[t];return n||(t.startsWith(m5t)?Mse:G7e)}const y5t=A6,v5t=ZCe,b5t=GCe,$B="min-h-5 py-0",yB={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},w5t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?yB.plain:yB[YXe(t)],S5t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",x5t=({added:e,removed:t})=>e<=0&&t<=0?null:h.jsxs("span",{className:q("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&h.jsxs("span",{className:q("text-success"),children:["+",e]}),t>0&&h.jsxs("span",{className:q("text-danger"),children:["-",t]})]}),p2={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},Q5t=1e3;function k5t(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,Q5t);return()=>window.clearInterval(i)},[e]),t}const P5t=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=k5t(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?TXe[t]:void 0,c=s?l??null:o?l??p2[e]:null,O=q("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?RXe[t]??null:null,f=s&&t?_Xe[t]:void 0,p=s?t==="mailbox"?v5t:t==="unconfirmed"?b5t:null:e==="interrupted"?y5t:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":gO(a??0):O6(n);return h.jsxs("span",{className:q("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:q("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",m),children:[p?h.jsx(p,{"aria-hidden":!0}):null,!o&&p2[e]?h.jsx("span",{className:q("sr-only"),children:p2[e]}):null,d?h.jsx("span",{className:q("sr-only"),children:d}):null]}),h.jsx("span",{className:q("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:g})]})},Ed=({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=$5t(e),w=Gd(e),{verb:x,object:b}=voe(e,r,i,g,t,qXe(s)),S=h.jsxs("span",{className:q("flex min-w-0 flex-1 items-center gap-2"),children:[h.jsx("span",{"aria-hidden":!0,className:q("flex size-3.5 shrink-0 [&_svg]:size-3.5",w5t(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:q("shrink-0 whitespace-nowrap text-body-sm",S5t(o)),title:w,children:x}),h.jsx("span",{className:q("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:q("sr-only"),children:"pending"})]}):b}),h.jsx(x5t,{added:u,removed:O}),h.jsx(P5t,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?"bg-elevated":$?"bg-danger-wash":"hover:bg-row-hover",P=d?h.jsx(ns,{summary:S,chevron:"leading",defaultOpen:f,className:q("@container/toolrow",p),rowClassName:$B,triggerClassName:q("-mx-2 rounded-sm px-2",Q),children:d}):h.jsx(ns,{disabled:!0,summary:S,rowClassName:$B,className:q("@container/toolrow",(g||$)&&q("-mx-2 rounded-sm px-2",Q),p)});return m?h.jsxs("div",{className:q("flex flex-col"),children:[P,m]}):P},T5t=3,N1e=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},Z1e=e=>{const t=new Map;let n=0;for(const a of e){const o=N1e(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=R5t(E5t(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}},_5t=e=>Z1e(e).units;function X5t(e){return _5t(e).join(" · ")}const vB={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"}},m2=5,R5t=e=>{if(e.length<=m2)return e.map(r=>r.label);const t=e.slice(0,m2),n=e.slice(m2).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},E5t=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=N1e(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",vB.todo);else{const u=vB[l];if(u)n(`kind:${l}`,u);else{const O=Gd(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 q5t(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 j5t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=q5t(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 C5t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return voe(n.name,n.summary??"",null,!0,n.op)}return null}function z5t(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>=T5t)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:a,summary:Z1e(a),failedCount:a.filter(o=>o.failed).length,span:j5t(a),live:C5t(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 bB=e=>{const t=[];for(const n of e)n.record.kind==="tool"&&t.push(...n.record.images);return t},ow=5,A5t=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<ow?{shown:Math.max(e,0),more:0}:{shown:ow-1,more:e-(ow-1)},U5t=e=>{const t=ow-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},YS=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function uC(e){return e.record.kind==="tool"?e.record.durationS:null}function W5t(e){let t=null;for(const n of e){const r=uC(n);typeof r=="number"&&(t=(t??0)+r)}return t}function Y5t(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 G5t="min-h-5 py-0",N5t=1e3;function Z5t(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,N5t);return()=>window.clearInterval(i)},[e]),t}const I5t=({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=Z5t(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":O6(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(ns,{open:i,onOpenChange:a,rowClassName:G5t,triggerClassName:q("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:h.jsxs("span",{className:q("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:q("min-w-0 shrink-[100000] truncate"),title:`${r.verb} ${r.object}`,children:[h.jsx("span",{className:q("text-accent"),children:r.verb})," ",h.jsx("span",{className:q("font-mono text-mono-sm text-ink-muted"),children:r.object})]}),h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"})]}),h.jsx("span",{className:q("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:q(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),YS(l)!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{className:q("shrink-0 text-ink-muted text-meta"),children:YS(l)})]}),f!==""&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{"data-fold-span":"",className:q("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:f})]})]}),children:h.jsx("div",{className:q("flex flex-col"),children:u})}),!i&&s&&s(m)]})},D5t="min-h-5 py-0",g2=()=>h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),V5t=({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:q("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(ns,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:D5t,triggerClassName:q("-ml-2 -mr-2 w-[calc(100%+1rem)] rounded-sm pl-2 pr-6","hover:bg-row-hover"),chevronClassName:q("-mr-6","text-ink-muted"),summary:h.jsxs("span",{className:q("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&h.jsx(h.Fragment,{children:h.jsx(i6,{"aria-hidden":!0,className:q("size-3.5 shrink-0 text-success")})}),c!==null&&(i!==null||a>0)&&h.jsx(g2,{}),i!==null&&h.jsxs("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:["Took ",gO(i)]}),i!==null&&a>0&&h.jsx(g2,{}),a>0&&h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),title:o?$:void 0,"aria-label":o?$:void 0,children:g}),YS(m)!==null&&h.jsxs(h.Fragment,{children:[h.jsx(g2,{}),h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:YS(m)})]}),u&&h.jsx("span",{className:q("sr-only"),children:"completed"}),l!==null&&h.jsx("span",{className:q("ml-auto"),children:h.jsx(A1e,{timestamp:l,scope:"answer"})})]}),children:h.jsx("div",{className:q("flex flex-col"),children:f})}),!O&&p&&h.jsx("div",{className:q("pb-2"),children:p(w)})]})},I1e=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)},wB=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],M5t=80,L5t=1e3,F5t=({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=I1e("(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)),L5t):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const w=window.setInterval(()=>o(x=>(x+1)%wB.length),M5t);return()=>{window.clearInterval(w),v!==null&&window.clearInterval(v)}},[d,O]),h.jsxs("div",{className:q("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[h.jsx("span",{"aria-hidden":!0,className:q("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:wB[a]}),h.jsx("span",{className:q("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),h.jsx("span",{"aria-hidden":!0,className:q("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?gO(s):""})]})},D1e="lo-missing-session-notice",B5t=/^\s*<reply-to>([\s\S]*?)<\/reply-to>/,MA=e=>{const t=[];let n=e;for(;;){const r=B5t.exec(n);if(r===null)break;t.push({id:Io(),text:r[1]}),n=n.slice(r[0].length)}return{replies:t,remainingContent:n.trim()}},V1e=({children:e,className:t,boundary:n="hairline",...r})=>h.jsx("div",{className:q("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm",n==="control"?["bg-media-surface","border border-transparent","transition-colors duration-fast ease-out-quart","group-hover/tile:border-control group-focus-visible/tile:border-control"]:["border border-hairline","bg-sunken"],t),...r,children:e}),H5t="could not be displayed. It may have been moved, renamed, or deleted.",M1e="could not be displayed. Its stored copy is not available to this reader.",OC=({name:e,detail:t=H5t,className:n,compact:r=!1})=>r?h.jsx("div",{className:q("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(VY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):h.jsxs("div",{className:q("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(VY,{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}`]})]}),K5t=({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),ap("File path copied to clipboard")}catch(s){console.error("Failed to copy file path: ",s),Ua("Failed to copy file path")}},o=()=>{e&&window.api.openFile(e)};return h.jsxs(Tae,{children:[h.jsx(Nt,{content:t,children:h.jsx(_ae,{asChild:!0,children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:s=>s.stopPropagation(),children:n??h.jsx(uCe,{"aria-hidden":"true"})})})}),h.jsxs(Xae,{align:"end",className:"min-w-45",onClick:s=>s.stopPropagation(),children:[i&&h.jsxs($c,{onSelect:i,children:[h.jsx(CCe,{"aria-hidden":"true"}),h.jsx("span",{children:"Show in canvas"})]}),h.jsxs($c,{onSelect:o,children:[h.jsx(Y6,{"aria-hidden":"true"}),h.jsx("span",{children:"Open file"})]}),h.jsxs($c,{onSelect:()=>window.api.showItemInFolder(e),children:[h.jsx(K0,{"aria-hidden":"true"}),h.jsx("span",{children:"Open folder"})]}),h.jsxs($c,{onSelect:a,children:[h.jsx(Hje,{"aria-hidden":"true"}),h.jsx("span",{children:"Copy file path"})]})]})]})},$2="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",L1e=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a})=>{const[o,s]=y.useState(!1);return e6(n,"image-lightbox"),h.jsx(t6,{open:n,onOpenChange:r,children:h.jsxs(n6,{showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:l=>{const c=i?.current;c&&(l.preventDefault(),c.focus())},className:q("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none",$2,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx(r6,{className:"sr-only",children:t}),o?h.jsx("div",{className:q($2,"flex min-h-16 min-w-64 items-center justify-center p-6"),children:a}):h.jsx("img",{src:e,alt:t,className:q($2,"object-contain"),onError:()=>s(!0)}),h.jsx(F5e,{asChild:!0,children:h.jsx(Ae,{variant:"ghost",size:"icon-sm",className:q("fixed top-4 right-4"),"aria-label":"Close image",children:h.jsx(Wi,{"aria-hidden":"true"})})})]})})};L1e.displayName="ImageLightbox";const J5t={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(" ")},eTt=/[/\\]/,SB=e=>{const t=e.split(eTt);return t[t.length-1]},F1e=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=Ln(x=>x.setCanvasOpen),{setViewMode:f}=fd(),p=y.useCallback(async()=>{const x=SB(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}=fd.getState();if(e.startsWith("data:"))if(eC(x)){const R=e,_={id:R,title:x,path:R,content:e,type:Vw(e)},C=fd.getState().conversations?.[n],z=C?.files??[],W=C?.openTabs??[],N=(()=>{const B=z.findIndex(Y=>Y.id===R);return B!==-1?[...z.slice(0,B),_,...z.slice(B+1)]:[...z,_]})();S(n,N);const M=W.some(B=>B.id===R)?W:[...W,{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&&eC(x)){const E=R,C={id:E,title:x,path:R,content:_.data,type:Vw(e)},W=fd.getState().conversations?.[n],N=W?.files??[],D=W?.openTabs??[],M=(()=>{const A=N.findIndex(J=>J.id===E);return A!==-1?[...N.slice(0,A),C,...N.slice(A+1)]:[...N,C]})();S(n,M);const Y=D.some(A=>A.id===E)?D:[...D,{id:E,title:x}];Q(n,Y),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??SB(e);if(a)return h.jsx(OC,{name:v,compact:i==="thumbnail"});const w=h.jsx(V1e,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:q(J5t[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:q("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(K5t,{filePath:$,tooltip:"File actions","aria-label":"File actions",onShowInCanvas:p})}),h.jsx(L1e,{src:t,label:v,open:c,onOpenChange:u,restoreFocusTo:O,fallback:h.jsx(OC,{name:v,detail:g?void 0:M1e})})]})});F1e.displayName="ImageAttachment";const sw=new Map;function tTt(e,t){const n=sw.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await rp(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=eue(i.data,i.mimeType);return r.holders<=0?(URL.revokeObjectURL(a),null):(nue(t,a),a)}catch{return null}finally{sw.delete(t)}})(),sw.set(t,r),r.promise}function nTt(e){const t=sw.get(e);t&&(t.holders-=1)}function rTt(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=y.useState(()=>e.attachment?tue(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=jw(u);if(d)return i(d),o(!1),()=>{O=!1,Cw(u)};i(null),o(!1);let f=!0;return tTt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(jw(u))}}),()=>{O=!1,f&&nTt(u),Cw(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 qk=({image:e,scope:t,label:n,size:r})=>{const i=rTt(e,t);if(i.state==="resolving")return h.jsx("div",{className:q("inline-block max-w-full"),"aria-hidden":!0,children:h.jsx(V1e,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""})});if(i.state==="missing")return h.jsx(OC,{name:n,compact:r==="thumbnail",detail:M1e});const a=i.url;return h.jsx("div",{className:q("inline-block max-w-full"),children:h.jsx(F1e,{file:a,src:a,label:n,size:r,conversationId:t?.sessionId??""})})},iTt="Generating name…",aTt={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 oTt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function LA(e,t){return`Turn ${e} of ${t}`}const sTt=e=>e.charAt(0).toLowerCase()+e.slice(1);function lTt(e,t){const n=LA(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function cTt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function uTt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function OTt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const dTt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function fTt(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 hTt(e,t){const n=sTt(LA(e.turn,t));if(e.kind==="user"){const i=fTt(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 pTt(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 mTt(e,t){const n=[];for(const r of t)pTt(e,r)==="pending"&&n.push(r);return n}const gTt=120,xB=80,$Tt="Turn checkpoints",yTt={complete:Jc,error:Jh,interrupted:A6,open:Dje},vTt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},bTt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?yTt[n]:null,i=uTt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:q("text-body-sm font-medium text-ink"),children:[LA(e.turn,t),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:q("font-normal text-ink-muted"),children:a})]})]}),cTt(e)&&h.jsx("p",{className:q("text-ink-dim text-meta"),children:iTt}),i&&h.jsx("p",{className:q("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&h.jsx("div",{className:q("flex items-center gap-1.5 text-ink-dim text-meta"),children:h.jsxs("span",{className:q("flex items-center gap-1",vTt[n]),children:[h.jsx(r,{"aria-hidden":"true",className:q("size-3.5 shrink-0")}),dTt[n]]})})]})},wTt=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:q("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:q("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",aTt[n])})})}),STt=({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 H=()=>{O(Z),f(p.current.find(re=>re.id===Z)??null)};if(ne<=0){H();return}$.current=setTimeout(()=>{$.current=null,H()},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(),Y.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 H=Z.getBoundingClientRect(),re=ne.getBoundingClientRect(),he=re.top-H.top+Z.scrollTop,we=he+re.height,ce=24;he<Z.scrollTop+ce?Z.scrollTop=Math.max(0,he-ce):we>Z.scrollTop+Z.clientHeight-ce&&(Z.scrollTop=we-Z.clientHeight+ce)},[o]),y.useEffect(()=>()=>w(),[w]);const Q=y.useRef(r);y.useEffect(()=>{Q.current=r});const P=y.useMemo(()=>OTt(t),[t]),R=y.useMemo(()=>new Map(t.map(Z=>[Z.id,hTt(Z,P)])),[t,P]),_=u&&d?.id===u?d:null,E=u&&m.current.get(u)||null,C=y.useMemo(()=>({current:E}),[E]),z=_!==null&&E!==null;y.useEffect(()=>{Q.current(z&&u?u:null)},[z,u]);const W=y.useCallback((Z,ne)=>{ne?m.current.set(Z,ne):m.current.delete(Z)},[]),[N,D]=y.useState(null),M=N&&t.some(Z=>Z.id===N)?N:t[0]?.id??null,B=y.useCallback(Z=>{const ne=Math.max(0,Math.min(t.length-1,Z)),H=t[ne];H&&(D(H.id),m.current.get(H.id)?.focus())},[t]),Y=y.useRef(null),A=y.useCallback(Z=>{Y.current!==Z&&(Y.current=Z,c(Z),x(Z,gTt))},[x]),J=y.useCallback(()=>{Y.current=null,c(Z=>Z===null?Z:null),b(xB)},[b]),K=y.useCallback(Z=>{Y.current=Z,D(Z),c(ne=>ne===Z?ne:Z),x(Z,0)},[x]),U=y.useCallback(()=>{Y.current=null,c(Z=>Z===null?Z:null),b(xB)},[b]),le=y.useCallback(Z=>{b(0),Y.current=null,c(null),n(Z)},[b,n]),F=y.useCallback((Z,ne)=>{if(Z.key==="Escape"){b(0);return}const H=t.findIndex(re=>re.id===ne);if(!(H<0)){if(Z.key==="ArrowDown"){Z.preventDefault(),Z.stopPropagation(),B(H+1);return}if(Z.key==="ArrowUp"){Z.preventDefault(),Z.stopPropagation(),B(H-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":$Tt,className:q("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:q("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:q("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(wTt,{checkpoint:Z,state:oTt({id:Z.id,previewId:l,activeId:o,loaded:a?a.has(Z.id):!0}),label:R.get(Z.id)??"",roving:Z.id===M,registerTick:W,onPreview:A,onPreviewEnd:J,onFocusMark:K,onBlurMark:U,onActivate:le,onKeyMark:F,describedBy:z&&u===Z.id?s:void 0},Z.id))})]}),h.jsxs(B5e,{open:z,onOpenChange:Z=>{Z||b(0)},children:[h.jsx(H5e,{virtualRef:C}),_&&h.jsx(K5e,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":_.kind==="user"?"Your message":lTt(_,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:q("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:q("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:_.text}):h.jsx(bTt,{checkpoint:_,turnCount:P})})]})]})},xTt=y.memo(STt);function QTt(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 kTt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function PTt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function B1e(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):!kTt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function TTt(e,t){return PTt(e,t)||B1e(e,t)!==null}const _Tt=3;function XTt(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>=_Tt){n.onMissing();return}const s=B1e(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const QB=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=A5t(e.length,{uncapped:r}),s=U5t(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:q("flex leading-none",l&&c.has(d)&&"col-start-1"),children:h.jsx(qk,{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:q("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:q("flex h-[78px] items-center leading-none"),children:h.jsx(Ae,{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 RTt(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 ETt(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 qTt=new Set(["generate_image"]);function jTt(e){return qTt.has(e)}function CTt(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n.message;typeof r=="string"&&r&&t.push(r)}return t}function zTt(e){const t=e??{};return{stage:typeof t.stage=="string"?t.stage:null,fraction:typeof t.progress_fraction=="number"&&Number.isFinite(t.progress_fraction)?t.progress_fraction:null,logs:CTt(t.log_lines),queuePosition:typeof t.queue_position=="number"&&Number.isInteger(t.queue_position)?t.queue_position:null,error:typeof t.error=="string"&&t.error?t.error:null,errorType:typeof t.error_type=="string"&&t.error_type?t.error_type:null}}function kB(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?H1e:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const H1e=Object.freeze({fraction:null,logs:[],queuePosition:null});function ATt(e,{stopping:t=!1}={}){const n=zTt(e.details);if(e.stopped===!0)return{state:"cancelled"};if(e.notRunKind==="skipped"||e.notRunKind==="aborted")return{state:"cancelled"};if(e.notRunReason)return{state:"failed",message:e.notRunReason,errorType:null};if(e.neverSent===!0)return{state:"cancelled"};if(e.isError===!0)return n.errorType==="media_already_completed"?{state:"done",images:e.images??[],durationS:e.durationS??null,receipt:"already-finished"}:n.stage==="cancelled"&&n.errorType===null?{state:"cancelled"}:{state:"failed",message:n.error??e.output,errorType:n.errorType};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,startedAtMs:null,progress:H1e}:{state:"queued",composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:n.queuePosition};case"running":{const r=e.startedAt??null;return t?{state:"cancelling",generating:!0,startedAtMs:r,progress:kB(n)}:{state:"running",startedAtMs:r,progress:kB(n),note:n.error}}case"done":return{state:"done",images:e.images??[],durationS:e.durationS??null,receipt:"generated"}}}function UTt(e,t){const n=[],r=e.state==="queued"||e.state==="running"||e.state==="cancelling";t?.onCancel&&r&&n.push({kind:"cancel",disabled:e.state==="cancelling"});const i=e.state==="failed"||e.state==="cancelled";return t?.onRestart&&i&&n.push({kind:"restart",disabled:!1}),t?.onEditRestart&&i&&n.push({kind:"editRestart",disabled:!1}),n}const WTt=1e3;function YTt(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,WTt);return()=>window.clearInterval(i)},[e]),t}function GTt(){return h.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:q("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:h.jsx("span",{className:q("absolute inset-0","animate-shimmer","bg-gradient-to-r from-transparent via-elevated to-transparent","bg-[length:200%_100%]","bg-[position:-200%_50%]","bg-no-repeat")})})}function NTt({view:e,elapsed:t}){let n,r=null,i=!1;switch(e.state){case"queued":n=e.composing?"Writing the request…":"Queued",r=e.queuePosition!==null?`${e.queuePosition} ahead`:e.argumentBytes>0?x1(e.argumentBytes):null;break;case"running":n="Generating image…",r=t===null?null:gO(t);break;case"cancelling":n="Cancelling…";break;case"done":n=e.receipt==="already-finished"?"Already finished.":"Generated image",r=e.receipt==="already-finished"||e.durationS===null?null:O6(e.durationS);break;case"failed":n=e.message??"The image could not be generated.",i=!0;break;case"cancelled":n="Cancelled";break}return h.jsxs("p",{className:q("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[h.jsx("span",{className:q("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:h.jsxs("span",{className:q("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function ZTt({line:e}){return h.jsx("p",{"data-imagegen-log":"",title:e,className:q("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function ITt({line:e}){return h.jsx("p",{"data-imagegen-note":"",className:q("min-w-0 text-body-sm text-ink-dim"),children:e})}function DTt(e,t){return e==="cancel"?"Cancel":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const VTt=({view:e,scope:t,actions:n})=>{const r=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,i=YTt(r),a=UTt(e,n),o={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},s=e.state==="running"||e.state==="cancelling",l=s&&(e.state==="running"||e.generating),c=s&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return h.jsxs("div",{"data-imagegen-card":e.state,className:q("flex w-full flex-col gap-2"),children:[l?h.jsx(GTt,{}):null,h.jsx(NTt,{view:e,elapsed:i}),e.state==="running"&&typeof e.note=="string"?h.jsx(ITt,{line:e.note}):null,l&&e.progress.fraction!==null?h.jsx(J5e,{"aria-label":"Image generation progress",className:q("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,c===null?null:h.jsx(ZTt,{line:c}),e.state==="done"&&e.images.length>0?h.jsx("div",{className:q("flex flex-col gap-2"),children:e.images.map((u,O)=>h.jsx(qk,{image:u,scope:t,label:e.images.length===1?"Generated image":`Generated image ${O+1}`},u.id))}):null,a.length>0?h.jsx("div",{"data-imagegen-controls":"",className:q("flex items-center gap-2"),children:a.map(u=>h.jsx(Ae,{variant:"secondary",size:"sm",disabled:u.disabled,onClick:o[u.kind],children:DTt(u.kind,e.state)},u.kind))}):null]})},w0=1e4,K1e=/\s/,MTt=e=>{for(let t=e.length;t>0;t-=1){const n=e[t-1];if(n===`
824
824
  `)return t;if(n==="."||n==="!"||n==="?"){const r=e[t];if(r===void 0||K1e.test(r))return t}}return-1},LTt=e=>{for(let t=e.length;t>0;t-=1)if(K1e.test(e[t-1]))return t;return-1},FTt=/[\uD800-\uDBFF]/,BTt=e=>FTt.test(e[w0-1])?w0-1:w0;function FA(e){if(e.length<=w0)return{text:e,clipped:!1};const t=e.slice(0,w0),n=MTt(t),r=LTt(t),i=n>0?n:r>0?r:BTt(t),a=e.slice(0,i).trimEnd();return{text:a.length>0?a:t,clipped:!0}}const J1e="[speech]",HTt="Couldn't speak this aloud. Try again.",KTt="Couldn't speak this aloud. Try again.",ewe="This conversation's agent is no longer available.",JTt=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.",ewe,"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 e_t(e){const t=e instanceof Error?e.message:String(e);return JTt.has(t)?t:(console.error(`${J1e} ${t}`),HTt)}function t_t(e){return(e instanceof Error?e.message:String(e))===ewe}function n_t(e){const t=e?.binding?.agent;return typeof t=="string"&&t.length>0?t:null}function r_t(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 i_t=100;function a_t(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 y2(e){try{return await e()}catch{return null}}async function o_t(e){if(!e)return null;const t=_y(pf.baseUrl),n=await y2(async()=>{const{profiles:a}=await Se({op:"profiles.list"});return r_t(e,a)});if(n?.state==="agent")return n.agentId;if(n?.state==="role-without-agent")return null;const r=await y2(async()=>{const a=await t.agents.listAgents(1,i_t,e);return a.status<400?a_t(e,a.result??null):null});return r||await y2(async()=>{const a=await t.agents.getAgent(e);return a.status<400?a.result?.id??null:null})}function BA(e){return cr(t=>e?n_t(t.sessions.find(n=>n.session_id===e)):null)}const s_t=20,twe=e=>`msg:${e}`,l_t=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")},GS=(e,t)=>`sel:${e}:${l_t(t)}`,HA=(e,t)=>async()=>{const n=()=>PB.speech.create({input:t}),r=await o_t(e);return r===null?n():PB.speech.createForAgent(r,{input_text:t}).catch(i=>{if(!t_t(i))throw i;return n()})},PB=_y(pf.baseUrl),c_t=e=>{for(;e.size>s_t;){const t=e.keys().next().value;if(t===void 0)return;e.delete(t)}},v2=new Map,u_t=(e,t)=>{let n=v2.get(e);return n===void 0&&(n=t().finally(()=>{v2.delete(e)}),v2.set(e,n)),n},nv=Yi((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 u_t(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),c_t(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(`${J1e} playback failed for ${n}`),Ua(KTt))},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}),Ua(e_t(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(twe(n),HA(r,i))}}));function KA({key:e,getText:t,play:n,available:r=!0}){const{dismiss:i,stopSpeech:a,loadingKey:o,playingKey:s,audioCache:l,heardKeys:c}=nv(),{canUseRadientSpeech:u,speechBlock:O}=eUe(),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:ace("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}=FA(b);Q&&!p&&ip(`Reading the first ${S.length.toLocaleString("en-US")} characters. The rest is not read aloud.`),n({text:S})}}}function nwe(e){y.useEffect(()=>{if(e!==null)return()=>{nv.getState().dismiss(e)}},[e])}const JA=({control:e,side:t="top"})=>{const n=y.useId(),r=e.disabled&&e.reason!==null;return h.jsx(Nt,{content:e.tooltip,side:t,children:h.jsxs("span",{className:q("flex"),tabIndex:r?0:void 0,"aria-describedby":r?n:void 0,children:[h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":e.label,className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:e.press,disabled:e.disabled,children:e.isPlaying?h.jsx(P1,{"aria-hidden":"true"}):e.isLoading?h.jsx(ts,{size:"xs"}):h.jsx(W7e,{"aria-hidden":"true"})}),r&&h.jsx("span",{id:n,className:"sr-only",children:e.reason})]})})},gm="data-lo-quote-toolkit";function dC(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const TB=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${gm}]`)??null,O_t=e=>e.nodeType===Node.ELEMENT_NODE,d_t=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>O_t(r)&&r.hasAttribute(gm));return n===-1?t.length:n},f_t=(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,h_t=e=>{const t=Array.from(document.querySelectorAll(`[${gm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>f_t(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function U$(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(TB(n.startContainer)||TB(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,d_t(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:h_t(n)}}const rwe=8,p_t=.5;function m_t(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 _B=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function g_t({lines:e,container:t,viewport:n,size:r,gap:i=rwe,row:a,belowWhenOffFirstLine:o=!1}){if(e.length===0)return null;const s=m_t(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*p_t,d=l.top-i-r.height>=s.top,f=c.bottom+i+r.height<=s.bottom,m=d&&!(o&&O&&f);return{top:_B(m?l.top-i-r.height:c.bottom+i,s.top,s.bottom-r.height),left:_B(l.left,s.left,s.right-r.width),placement:m?"above":"below"}}const XB="[data-lo-canonical-transcript]",$_t="[data-lo-transcript-content]",RB=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),y_t=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function iwe(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=g_t({lines:f,container:RB((O.closest(XB)??O).getBoundingClientRect()),viewport:y_t(),size:{width:d.offsetWidth,height:d.offsetHeight},row:RB(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(XB),p=f?.querySelector($_t),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 awe(e){const[t,n]=y.useState(null);y.useEffect(()=>{const i=()=>n(U$(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 $h="data-lo-link-toolbar",v_t=120,b_t=2;function owe(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=cQt(u);if(O){n(f=>f===O?f:O),i(f=>f===!0?f:!0);return}if(i(f=>f===!1?f:!1),Ibe()){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()},v_t))},p=(Q,P)=>{const R=o.current;if(!R||!u.contains(R))return!1;const _=u.querySelector(`[${$h}]`),E=rwe+b_t;for(const C of[R,_]){if(!C)continue;const z=C.getBoundingClientRect();if(!(z.width<=0||z.height<=0)&&Q>=z.left-E&&Q<=z.right+E&&P>=z.top-E&&P<=z.bottom+E)return!0}return!1},m=Q=>{const P=Q.target;if(P?.closest(`[${gm}]`))return;const R=P?.closest(gh)??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(gh);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(`[${$h}] button:not([disabled])`)),x=Q=>{const P=Q.target;if(!P)return!1;if(P.closest(`[${$h}]`)){const C=w(),z=C.indexOf(P);if(z===-1)return!1;if(Q.shiftKey&&z===0){const W=o.current;return W instanceof HTMLElement?(W.focus(),!0):!1}if(!Q.shiftKey&&z===C.length-1){const W=Array.from(u.querySelectorAll(gh)),N=o.current,D=N?W.indexOf(N)+1:-1,M=D>0?W[D]:void 0;return M?(M.focus(),!0):!1}return!1}if(Q.shiftKey)return!1;const _=P.closest(gh);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(gh);!R||!u.contains(R)||(Q.preventDefault(),d(R),requestAnimationFrame(()=>{u.querySelector(`[${$h}] 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(`[${$h}]`))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 swe(e,t,n){const r=on(i=>i.addReply);return y.useCallback(()=>{const a=U$(t.current)?.text??(Ibe()?null:n?.()??null);a&&(r(e,{id:Io(),text:a}),window.getSelection()?.removeAllRanges(),J6())},[r,e,t,n])}const lwe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(Nbe)??"",o=n.getAttribute("data-lo-kind")??"file",s=Bbe(),l=y.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=swe(e,t,l),{text:u}=awe(t),{speak:O}=nv(),d=BA(e),f=u??l(),p=f===null?null:GS(e,FA(f).text);nwe(p);const m=KA({key:p,getText:()=>U$(t.current)?.text??l(),play:({text:N})=>O(GS(e,N),HA(d,N))}),[g,$]=y.useState(!1),[v,w]=y.useState(()=>iw(a)??null),{controlRef:x,placement:b}=iwe({turnRef:t,visible:!0,lines:()=>{const N=n.getClientRects();return Array.from(N,D=>({top:D.top,left:D.left,right:D.right,bottom:D.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});y.useEffect(()=>{const N=iw(a);if(w(N??null),$(!1),N!==void 0)return;let D=!0;return aQt(a,window.api?.probeFiles).then(()=>{D&&w(iw(a)??null)}),()=>{D=!1}},[a]);const S=o==="file"&&Lbe(s,a),Q=Mbe({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:S}),P=dQt({kind:o,target:a,probe:v,quotable:r,canOpenInCanvas:S});if(!P||!a)return null;const R=async()=>{await Jbe(a)&&$(!0)},_=async()=>{if(o==="url"){await GF(o,a);return}s&&Q&&await s.openInCanvas(a)||await GF(o,a)||w(null)},E=async()=>{await US(a)||w(null)},C=async()=>{await vQt(a)||w(null)},z={quote:h.jsx(Lse,{}),copy:g?h.jsx(Jc,{}):h.jsx(U6,{}),open:Q?h.jsx(l7e,{}):o==="url"?h.jsx(dCe,{}):h.jsx(Y6,{}),"open-default":h.jsx(Rje,{}),"open-folder":h.jsx(K0,{})},W={quote:c,copy:()=>{R()},open:()=>{_()},"open-default":()=>{E()},"open-folder":()=>{C()}};return h.jsxs("div",{[gm]:"",[$h]:"",ref:x,role:"toolbar","aria-label":P.label,className:q("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:N=>N.preventDefault(),onKeyDown:N=>{if(N.key!=="Escape")return;window.getSelection()?.removeAllRanges();const D=n;N.preventDefault(),i(),D.focus?.()},children:[P.actions.map(N=>h.jsxs(y.Fragment,{children:[h.jsx(Nt,{content:N.id==="copy"&&g?"Copied":N.label,side:b?.placement==="below"?"bottom":"top",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":N.id==="copy"&&g?"Copied":N.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:W[N.id],children:z[N.id]})}),N.id==="quote"&&h.jsx(JA,{control:m,side:b?.placement==="below"?"bottom":"top"})]},N.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 w_t({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:["copy","speak",...n]}function cwe(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const EB=96;function S_t(e){const t=e.replace(/\s+/g," ").trim();return t.length<=EB?t:`${t.slice(0,EB-1).trimEnd()}…`}const x_t="Answer actions",Q_t="Your message actions",k_t="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 P_t(e){return e?"opacity-100":k_t}const T_t=2e3,__t=1e4;function Hrn(e){const{request:t}=e;return t?e.now-t.requestedAt>__t?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let qB=0,Hb=0;const X_t=Yi(e=>({request:null,requestPanel:(t,n,r,i)=>{qB+=1,e({request:{destination:t,nonce:qB,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:()=>{Hb+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Hb=Math.max(0,Hb-1),Hb===0&&e({presenterClaimed:!1}))}}})),R_t=(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)},E_t=9e4,jB=new Set,q_t=2600,uwe=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:$}=nv(),v=BA(r??null),w=KA({key:i?twe(i):null,getText:()=>t,play:({text:E})=>{i&&$(i,v,E)}}),x=X_t(E=>E.requestPanel),S=w_t({role:n,forkable:!!(s&&l)}),Q=c||w.active;y.useEffect(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]),y.useEffect(()=>{if(!a||o===void 0||jB.has(a)||(jB.add(a),Date.now()-o>E_t))return;const E=p.current;if(E===null)return;const C=E.closest(".group")??E;if(R_t(E,C))return;d(!0);const z=()=>{d(!1),C.removeEventListener("pointerenter",z),C.removeEventListener("focusin",z)};return C.addEventListener("pointerenter",z),C.addEventListener("focusin",z),()=>{C.removeEventListener("pointerenter",z),C.removeEventListener("focusin",z)}},[a,o]),y.useEffect(()=>{if(O)return g.current=setTimeout(()=>{g.current=null,d(!1)},q_t),()=>{g.current!==null&&clearTimeout(g.current)}},[O]);const P=async()=>{await Jbe(t)&&(u(!0),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,u(!1)},T_t))},R=()=>{!s||!l||x("session.fork",m.current,s,{id:l,excerpt:S_t(t)})},_={copy:h.jsx(Nt,{content:c?"Copied":"Copy",side:"bottom",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":c?"Copied":"Copy",className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:P,children:c?h.jsx(Jc,{"aria-hidden":"true"}):h.jsx(U6,{"aria-hidden":"true"})})}),speak:h.jsx(JA,{control:w,side:"bottom"}),fork:h.jsx(Nt,{content:"Fork from this message",side:"bottom",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Fork from this message",ref:m,className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:R,children:h.jsx(bCe,{"aria-hidden":"true"})})})};return h.jsx("div",{role:"toolbar","aria-label":n==="user"?Q_t:x_t,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:q("flex shrink-0 items-center gap-1",P_t(Q)),children:S.map(E=>h.jsx(y.Fragment,{children:_[E]},E))})}),j_t="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Kb="@min-[260px]/olderhistory:hidden",Jb="@max-[260px]/olderhistory:hidden",Owe="lo-older-history-hint",C_t=({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:j_t,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:Kb,children:"Not loaded"}),h.jsx("span",{className:Jb,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:Kb,children:"Did not load"}),h.jsx("span",{className:Jb,children:"Could not load earlier messages"})]}),h.jsx(Ae,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:"Try again"})]}):a?h.jsxs(Ae,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[h.jsx(ts,{size:"sm"}),"Loading earlier messages"]}):e==="idle"?h.jsx(Ae,{variant:"ghost",size:"sm",onClick:n,children:"Load earlier messages"}):e==="windowed"?h.jsxs("span",{id:Owe,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:Kb,children:t?"Earlier history above":"Scroll up for earlier"}),h.jsxs("span",{className:Jb,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:Kb,children:"Earlier not loaded"}),h.jsx("span",{className:Jb,children:"Earlier history not loaded"})]}),!t&&r&&h.jsx(Ae,{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"})]})},z_t="/settings?section=providers",CB="/settings?section=providers&provider=radient",A_t="/settings?section=radient",zB=/sign in to radient/i,U_t=[/insufficient credits/i,/credit balance is too low/i],W_t=[/rate limit or quota/i],Y_t=[/insufficient credits/i,/\bHTTP 402\b/i];function dwe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function e8(e){return dwe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&Y_t.some(n=>n.test(e.text)):!1}function G_t(e){if(!e8(e))return null;const t=/rate limit or quota( exceeded)?\s*/i;if(!t.test(e.headline))return{label:"billing",headline:e.headline};const n=e.headline.replace(t,"").trim(),r=/^\((HTTP \d{3})\):?\s*(.*)$/i.exec(n),i=(r?r[2]:n.replace(/^:\s*/,"")).trim(),a=r?` (${r[1]})`:"";return{label:"billing",headline:i?`Out of credits${a}: ${i}`:`Out of credits${a}: Radient refused the request`}}function N_t(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function AB(e){const t=dwe(e.provider)||zB.test(e.text);let n=N_t(e.category);return e8(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(zB.test(e.text)?n="sign-in":U_t.some(r=>r.test(e.text))?n="billing":W_t.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:"Sign in to Radient",to:CB}:n==="billing"&&t?{label:"Open Radient account",to:A_t}:{label:"Open provider settings",to:t?CB:z_t}}const fwe=({conversationId:e,turnRef:t})=>{const{text:n,clear:r}=awe(t),i=n!==null,a=swe(e,t),{controlRef:o,placement:s}=iwe({turnRef:t,visible:i,lines:()=>U$(t.current)?.lines??null}),{speak:l}=nv(),c=BA(e),u=n===null?null:GS(e,FA(n).text);nwe(u);const O=KA({key:u,getText:()=>U$(t.current)?.text??null,play:({text:d})=>l(GS(e,d),HA(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",{[gm]:"",ref:o,className:q("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(Nt,{content:"Quote",side:s?.placement==="below"?"bottom":"top",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Quote",className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:a,children:h.jsx(Lse,{})})}),h.jsx(JA,{control:O,side:s?.placement==="below"?"bottom":"top"})]}):null},hwe={all:["radient-prices"],prices:()=>[...hwe.all,"prices"]},Z_t=()=>{const e=_t({queryKey:hwe.prices(),queryFn:()=>oz({operation:"prices"}),staleTime:36e5,refetchOnWindowFocus:!1,refetchOnMount:!0,refetchInterval:!1,retry:3});return{prices:e.data,isLoading:e.isLoading,isFetching:e.isFetching,error:e.error,pricesQuery:e}},UB="https://console.radienthq.com/dashboard/verification",WB="https://console.radienthq.com/dashboard/billing",YB="Top up in Radient console";function I_t(e){return!e.email_verified&&e.signup_grant!=="claimed"}const Krn=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,fC=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,D_t=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`${fC(e)} in free credits`;function GB(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function V_t(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const M_t=(e,t)=>e==="pending"?{sentence:`Verify your email to claim ${t}. Check your inbox for the link Radient sent.`,action:"Open verification page"}:e==="expired"?{sentence:`The link to claim ${t} has expired. Request a new one from the verification page.`,action:"Request a new link"}:{sentence:"No signup grant is attached to this account. Open the verification page to check the account.",action:"Open verification page"};function L_t(e,t){if(e===void 0)return{state:"unknown",lines:["You're out of credits. If you haven't verified your email yet, verify it to claim free credits and start using Local Operator for free.","Otherwise, top up in the Radient console."],links:[{label:"Open verification page",url:UB},{label:YB,url:WB}]};if(I_t(e)){const i=GB(e.claim_url,UB),{action:a}=M_t(e.signup_grant,"");return e.signup_grant==="none"?{state:"unverified",lines:["You haven't verified your email yet. Open the verification page to check whether free credits are waiting on your account."],links:[{label:a,url:i}]}:{state:"unverified",lines:[`You haven't verified your email yet. Verify to claim ${D_t(e.grant_amount??t)} and start using Local Operator for free.`,e.signup_grant==="expired"?"The link you were sent has expired. Request a new one on the verification page.":"Check your inbox for the link Radient sent."],links:[{label:a,url:i}]}}const n=e.first_topup,r=["You're out of credits. Top up in the Radient console."];return n!==void 0&&n.bonus_received===!1&&Number.isFinite(n.bonus_amount)&&Number.isFinite(n.minimum_purchase)&&r.push(`Get an extra ${fC(n.bonus_amount)} free on your first top-up of ${fC(n.minimum_purchase)} or more.`),{state:"verified",lines:r,links:[{label:YB,url:GB(n?.topup_url,WB)}]}}const F_t=5*1e3,B_t=({action:e})=>{const{user:t,accountRead:n}=lce({staleTime:F_t,retryOnMount:!1}),r=pi(),{prices:i}=Z_t(),o=r.isPending||n==="checking"?null:L_t(n==="ready"?t?.verification:void 0,i?.default_new_credits);return h.jsxs("div",{className:"mt-1 flex flex-col items-start gap-2 pl-6",children:[o?h.jsxs("div",{"data-radient-credits-state":o.state,className:"flex max-w-[60ch] items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[h.jsx(Jx,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),h.jsx("div",{className:"min-w-0 text-body-sm text-ink",children:o.lines.map(s=>h.jsx("p",{className:"[&:not(:first-child)]:mt-1",children:s},s))})]}):null,h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?.links.map(s=>h.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>V_t(s.url),children:s.label},s.url)),h.jsx(Ae,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx(zse,{to:e.to,children:e.label})})]})]})},b2=(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)},pwe=24,mwe=6,hC=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),NB=async e=>{for(let t=0;t<mwe;t+=1){if(e())return;await hC()}},gwe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},H_t=e=>{const t=gwe(e.loadOlder),n=()=>NB(()=>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 NB(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},Ng="data-jump-highlight",K_t=1400,J_t=12,e2t=1200,t2t=mwe,n2t=t2t+2,r2t=2,i2t=30,ZB=1,Og=pwe;let oh=0;async function a2t(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await H_t({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:J_t,maxRows:e2t})==="landed"}async function o2t(e,t){oh+=1;const n=oh;b2(e,t,"reversed",Og);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<n2t&&(await hC(),!(i||n!==oh));c+=1){const u=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Og;if(Math.abs(u)<=ZB){if(s+=1,s>=r2t){l=!0;break}continue}s=0,b2(e,t,"reversed",Og)}if(l&&!i&&n===oh){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<i2t;d+=1){if(await hC(),i||n!==oh||!c.isConnected||!u.isConnected)return;const f=u.getBoundingClientRect().top-c.getBoundingClientRect().top-c.clientTop-Og;if(Math.abs(f)<=ZB)continue;b2(c,u,"reversed",Og);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===oh){const s=e.ownerDocument?.defaultView;s!=null&&e.dispatchEvent(new s.Event("scroll"))}}function $we(e,t,n){return new Promise(r=>{XTt(e,n,{onRevealed:i=>{IB(i),o2t(t,i).then(()=>{i.isConnected&&!i.hasAttribute(Ng)&&IB(i),r("landed")})},onMissing:()=>{r("missing")}})})}const w2=new WeakMap;function IB(e){const t=w2.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(Ng);e.removeAttribute(Ng),n&&e.offsetHeight,e.setAttribute(Ng,""),w2.set(e,window.setTimeout(()=>{w2.delete(e),e.removeAttribute(Ng)},K_t))}const _h=120,e1=400,s2t=.5,l2t=320,c2t=900,u2t=64,t8=2,S2=24,x2=3,O2t=4,W$=12,d2t=W$,f2t=120,h2t=.35,DB=12,p2t=8,m2t=W$,g2t=.5,VB=()=>({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}),ywe=e=>Math.min(c2t,Math.max(l2t,Math.round(e*s2t))),$2t=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=e1?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=e1?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=e1?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>=e1,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>=u2t&&!e.travelledSinceLatch?{...r,armed:!0,clampLatched:!1,travelledSinceLatch:!0}:{...e,lastInputAt:t.at}:e.busy?{...r,retained:!0}:{...r,armed:!0}},t1=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=t8,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 vwe(e,t=ywe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const y2t=(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=ywe(t.clientHeight),{inZone:a}=vwe(t,i),o=n-e.lastInputAt>=_h||t.distanceFromTopPx<=t8,s=e.revealsThisAct<m2t;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<DB&&s)return o?t1({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed)return e.deliberate?t1(e,r,t):r==="fetch"&&e.failures>=x2?{action:"none",state:{...e,armed:!1}}:o?a?r==="fetch"&&e.actFetchSpent?{action:"none",state:{...e,armed:!1}}:t1(e,r,t):{action:"none",state:{...e,armed:!1}}:{action:"none",state:e};if(e.continuation){const l=e.actAsks<d2t,c=l&&e.chainInvisible>0&&e.chainInvisible<W$;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<DB:(c||l&&e.chainFetch<O2t)&&e.failures<x2)?t1({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},MB=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<p2t,l=r===null&&t&&i!==null&&i<Math.max(f2t,h2t*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,W$):0,continuation:t&&n>0||c&&e.chainInvisible+1<W$||!e.retained&&!e.turnedAround}},v2t=e=>({...e,busy:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),b2t=e=>({...e,busy:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),w2t=(e,t,n,r)=>n===r?bwe(e,t):null,bwe=(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)<g2t?0:n};function S2t(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const x2t=e=>e?"⌘F":"Ctrl+F";function Q2t(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function k2t(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function P2t(e,t){return t>=0&&t<e.length?e[t]:null}function T2t(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 _2t={user:"You",agent:"Agent"},X2t="related match",LB="Search this conversation",R2t="Search results",E2t="Close search";function q2t(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 j2t="No messages match this search.",C2t="Still indexing this conversation.",z2t="Results appear as the index catches up.",A2t="Newer messages may be missing while the index catches up.",U2t="This conversation lives on another device, so it cannot be searched here.",W2t="This conversation could not be searched.",Y2t="Try again",G2t="Check again",N2t="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",Z2t="Updating — the list below is the previous search's.",I2t="Going to that message…";function D2t(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function V2t(e){return e.state==="building"}async function M2t(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await $we(n,e,t)==="landed"?"revealed":"not-mounted"}async function L2t(e){const t=e.query.trim().slice(0,s6);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??Mae,1),Lae);return Se({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const F2t=200,B2t=1500;function H2t({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((W,N)=>{x.current.has(W)||(x.current.add(W),console.warn(W,N))},[]),P=y.useCallback(()=>{p.current+=1,S(),v.current=null,g.current=0,a("idle"),s(W=>W.length===0?W:[]),c(!1),O(!1),f(-1)},[S]),R=y.useRef(()=>{}),_=y.useCallback((W,N)=>{const D=Q2t(N.state);a(D);const M=D==="ready"||D==="building",B=M?N.hits:[];if(g.current=B.length,s(B),c(M&&N.truncated),O(D==="building"&&N.partial),f(B.length>0?0:-1),D==="building"&&V2t(N)){if(v.current!==W){v.current=W;const Y=p.current;w.current=setTimeout(()=>{w.current=null,p.current===Y&&R.current(W,"follow-up")},B2t)}}else S()},[S]),E=y.useCallback((W,N)=>{const D=b.current;if(!D)return;const M=p.current,B=++m.current;N==="fresh"&&(S(),v.current=null,a("loading")),L2t({sessionId:D,query:W}).then(Y=>{B!==m.current||p.current!==M||_(W,Y)}).catch(Y=>{B!==m.current||p.current!==M||(Q("thread search could not be answered:",Y),S(),v.current=null,g.current=0,s([]),c(!1),O(!1),f(-1),a("error"))})},[_,S,Q]);R.current=E,y.useEffect(()=>{const W=`${t?"1":"0"}:${e??""}`;if($.current!==W&&($.current=W,x.current=new Set,P(),r(B=>B===""?B:""),!t||!e))return;if(!t||!e){P();return}const N=n.trim();if(N.length===0){P();return}const D=p.current,M=setTimeout(()=>{p.current===D&&R.current(N,"fresh")},F2t);return()=>clearTimeout(M)},[n,t,e,P]),y.useEffect(()=>()=>S(),[S]);const C=y.useCallback(W=>{f(N=>k2t(N,W,g.current))},[]),z=y.useCallback(()=>{const W=n.trim();!t||!e||W.length===0||R.current(W,"fresh")},[t,e,n]);return{query:n,setQuery:r,state:i,hits:o,truncated:l,partial:u,cursor:d,moveCursor:C,activeHit:P2t(o,d),refresh:z}}const K2t=q("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),J2t="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",eXt=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,tXt=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=T2t(e.snippet,e.ranges);return h.jsxs("li",{id:n,role:"option","aria-selected":t,onMouseDown:a=>a.preventDefault(),onClick:()=>r(e),className:q("relative flex cursor-pointer flex-col gap-0.5 px-3 py-2",t?K2t:"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:_2t[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:X2t})]})]}),h.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?h.jsx("mark",{className:J2t,children:a.text},o):h.jsx("span",{children:a.text},o))})]})},nXt=({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:q("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(Ty,{"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:s6,placeholder:LB,"aria-label":LB,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(Ae,{type:"button",variant:"ghost",size:"icon-sm","aria-label":E2t,onClick:u,children:h.jsx(Wi,{"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?Z2t:"Searching…"),n==="ready"&&(r.length>0?q2t(r):j2t),n==="building"&&(o?A2t:C2t),n==="unsupported"&&U2t,n==="error"&&W2t,n==="ready"&&a&&v&&h.jsxs("span",{className:"text-ink-dim",children:[" ",D2t(r.length)]}),n==="building"&&!o&&h.jsxs("span",{className:"text-ink-dim",children:[" ",z2t]})]}),w&&h.jsx(Ae,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?G2t:Y2t})]}),v&&h.jsx("ul",{id:p,role:"listbox","aria-label":R2t,"aria-busy":n==="loading",className:q("max-h-80 overflow-y-auto border-t border-hairline py-1",n==="loading"&&"opacity-60"),children:r.map((b,S)=>h.jsx(tXt,{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:I2t}),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(dd,{shortcut:"↑"}),h.jsx(dd,{shortcut:"↓"}),h.jsx("span",{children:"browse"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(dd,{shortcut:"↵"}),h.jsx("span",{children:"jump"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(dd,{shortcut:"esc"}),h.jsx("span",{children:"close"})]}),h.jsx("span",{className:"ml-auto text-ink-dim text-meta",children:x2t(O)})]})]})},rXt=({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=H2t({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||!S2t(p))return;const m=p.target;if(!(!(s.current!==null&&m!==null&&s.current.contains(m))&&(e$(p.target)||lle(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 M2t(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(nXt,{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:eXt(),jumping:a})}):null},iXt='button, a, input, textarea, [role="button"], [contenteditable]',aXt='[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]',oXt=4,sXt=200,FB=e=>{const t=e;return typeof t?.closest!="function"?!0:t.closest(iXt)!==null},lXt=e=>e.querySelector(aXt)!==null,cXt=(e,t)=>t-e<sXt,uXt=e=>e.controlPress?"control":e.modalOpen?"modal":e.pressHadSelection||e.selectionNotCollapsed||e.shiftExtends?"selection":e.dragged?"drag":e.scrolledRecently?"scroll":"focus";function wwe(e){return e.status==="reconnecting"||e.status==="unavailable"&&!!e.failure||!!e.missing}function Swe(e){return wwe(e)||!!e.stale}function OXt(e){return e.status==="reconnecting"?!1:Swe(e)}function xwe(e){return e.awaitingHydration&&!e.admittedSend&&!wwe(e)&&(e.recordCount===0||e.stale===!0)}function dXt(e){return e.recordCount===0&&!e.admittedSend&&!xwe(e)&&!Swe(e)}const fXt=({isSmallView:e=!1})=>h.jsxs("output",{"aria-label":"Loading conversation",className:q("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…"})]}),hXt="display.turn_answer_rail";function pXt(e){return e?.find(t=>t.key===hXt)?.value===!0}function mXt(e,t){return e&&t?"-ml-[13px] border-hairline border-l pl-3":"w-full"}function gXt(e){return Oz(e)!==null}function $Xt(e){return!(e.kind!=="tool"||e.isError!==!0||u6(e.delivery)||e.neverSent===!0||e.notRunReason!==null&&e.notRunReason!==void 0||e.stopped===!0||L0(e.notRunKind))}function Qwe(e,t){const n=dz(e),r=t.focusHold??null,i=t.openRuns??yXt;return{runs:n.map((a,o)=>jXt(e,a,o===n.length-1&&t.live,r,i,t.mode))}}const yXt=new Set,vXt=new Set(["output","args","intent","diff","frame","truncated"]),BB=new WeakMap;let Q2=0;const bXt=e=>{const t=BB.get(e);return t!==void 0?`@${t}`:(Q2+=1,BB.set(e,Q2),`@${Q2}`)},HB=new WeakMap;function wXt(e){const t=HB.get(e);if(t!==void 0)return t;const n=e,r={};for(const a of Object.keys(n)){if(vXt.has(a))continue;const o=n[a];if(a==="text"){r[a]=o?1:0;continue}if(a==="images"){r[a]=Array.isArray(o)?bXt(o):o??null;continue}r[a]=o}const i=JSON.stringify(r)??"null";return HB.set(e,i),i}function SXt(e){const t=[];for(const n of e)t.push(`${n.gap}${n.closesTurn?"+":"-"}`),t.push(wXt(n.record));return t.join("\0")}function xXt(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 QXt(e,t){return`${e}${xXt(t)}`}const k2=720;function n8(e,t,n,r=0,i=!1,a=kwe(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 kwe(e,t){const n=e.length;if(n<=t)return null;const r=n-t;return dz(e).find(i=>i.openingIndex<=r&&r<=i.endIndex)??null}function kXt(e,t){return e.runs.find(r=>!r.run.opensWithUserRow&&r.segments.some(i=>i.collapsed&&!t?.has(i.key)))?.key??null}function PXt(e,t,n){const r=kXt(e,n);return r===null?null:t===null||!t.opensWithUserRow&&t.key===r?r:null}function Pwe(e,t,n){const r=e.length,i=n8(e,t,n.snapMaxExtra,n.completedRunMaxExtra,n.live??!1),a=r>i?e.slice(r-i):e,o=Qwe(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 TXt=12;function _Xt(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=n8(e,O,n.snapMaxExtra,n.completedRunMaxExtra,n.live??!1),f=u.get(d);if(f!==void 0)return f;const p=Pwe(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 Twe=12;function XXt(e,t){return e>=Twe||t.halted||t.loadingOlder||!t.hasMore||!t.headCut||!t.mayWalk?{fetch:!1,spent:e}:{fetch:!0,spent:e+1}}const KB=()=>({key:null,spent:0,halted:!1});function RXt(e,t){return t===null||t===e.key?e:{key:t,spent:0,halted:!1}}function EXt(e,t){return t&&e.gap==="trace"?"item":e.gap}function JB(e,t){const n=[];let r=0,i=null;for(const o of e){if(o.record.kind!=="tool")continue;const s=$Xt(o.record);n.push({name:Xce(o.record),failed:s}),s&&(r+=1,i??=o.record.id)}const a=W5t(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?X5t(n):null}}function qXt(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(wQ(i)||Ku(i)&&Qce(i))return r}return n}function jXt(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=pWe(s,{from:l,paints:Ku,isStatement:Wq,pinned:gXt,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?qXt(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=mWe(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:EXt(b[0],w.from>l),afterAnswer:S,label:R,completed:gWe(s,c.cycles,w,u,R!==null),collapsed:_,stampTs:x===d&&u!==null&&f===1?s[u].ts:null,facts:JB(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:JB($,{partial:!t.opensWithUserRow,headLoaded:t.opensWithUserRow}),answerId:O,stampTs:u===null?null:s[u].ts,segments:g}}const CXt=160,eH=2,zXt=(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+pwe+1&&b>f&&(f=b,d=w.id)}const g=u.scrollHeight-u.clientHeight,$=Math.abs(u.scrollTop)<=eH,v=Math.abs(u.scrollTop+g)<=eH;$?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()},CXt)};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}},AXt=1500,UXt=45e3,WXt=[];function YXt(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 Se({op:"sessions.checkpoints",sessionId:a.current});if(b!==o.current)return;i(Q),n("ready"),l.current.size>0&&(l.current=new Set(mTt(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()+UXt;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)})}},AXt)},[]);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,IE)}:{op:"sessions.checkpoints.warm",sessionId:S};(async()=>{try{const R=await Se(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??WXt,warm:w,refresh:v}}function _we(){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 Xwe="session.cleanup.delegated.max_age_hours",GXt="session.cleanup.delegated.enabled",NXt="session_delegated",ZXt=2,IXt=720,Mc=24,pC=30*Mc,r8=72,i8=/^\d+$/,DXt=[2,6,12,24,48,72,168,336,720];function jk(e){if(e.key!==Xwe||e.kind!=="int"||e.unit&&e.unit!=="hours")return null;const t=e.minimum??ZXt,n=e.maximum??IXt;return{min:t,max:n,stops:DXt.filter(r=>r>=t&&r<=n),defaultHours:typeof e.default=="number"&&Number.isInteger(e.default)?e.default:null}}const P2=(e,t,n)=>`${e} ${e===1?t:n}`;function wc(e){return e>0&&e%pC===0?P2(e/pC,"month","months"):e>=r8&&e%Mc===0?P2(e/Mc,"day","days"):P2(e,"hour","hours")}function VXt(e){return e>=r8&&e%Mc===0?`${e/Mc}d`:`${e}h`}function MXt(e){return e>=r8&&e%Mc===0?{text:String(e/Mc),unit:"days"}:{text:String(e),unit:"hours"}}function tH(e){const t=e.text.trim();return i8.test(t)?String(Number(t)*(e.unit==="days"?Mc:1)):t}function LXt(e){const t=e.max%pC===0?`${wc(e.max)} (${e.max/Mc} days)`:wc(e.max);return`between ${wc(e.min)} and ${t}`}function FXt(e,t){return Math.min(t.max,Math.max(t.min,e))}function Rwe(e,t){const n=e.trim();if(!i8.test(n))return{ok:!1,error:"Enter a whole number of hours or days.",nearest:null};const r=Number(n);if(r<t.min||r>t.max){const i=r>t.max;return{ok:!1,error:`${wc(r)} is too ${i?"long":"short"}. Choose a time ${LXt(t)}.`,nearest:FXt(r,t)}}return{ok:!0,hours:r}}const Ewe={[GXt]:{label:"Remove delegated sessions automatically",help:"Applies to subagent runs, agent shells and background runs only.",gateLabel:"automatic removal"},[Xwe]:{label:"Remove after",help:"The retention window: how long a delegated session (a subagent or background run) can sit idle before it is removed."}},BXt={session_delegated:"Delegated work: subagents and background sessions"};function HXt(e){return BXt[e.name]??e.title}function lw(e){const t=Ewe[e.key];return t?{...e,label:t.label,help:t.help}:e}function KXt(e,t){return Ewe[e]?.gateLabel??t}const JXt={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","session.cleanup.delegated.enabled":"core","session.cleanup.delegated.max_age_hours":"core","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"},eRt={model:"core",approvals:"core",web_tools:"core",desktop:"advanced"};function ad(e){return e.tier==="core"||e.tier==="advanced"?e.tier:JXt[e.key]??eRt[e.section]??"advanced"}function tRt(e){return e.length===0?!1:e.filter(n=>ad(n)==="core").length*2>=e.length}function nRt(e,t,n){return t?{layout:null,filter:e?[]:[...n]}:{layout:{opened:e?[...n]:[],closed:e?[]:[...n]},filter:[]}}const qwe="__cascade__";function Qp(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Jl(e){return{value:e.kind==="list"?(e.value??[]).join(`
825
825
  `):e.kind==="cascade"?qwe:Qp(e.value),cascadeBase:null}}function cw(e,t){return t.cascadeBase!==null?!0:e.kind==="cascade"?t.value!==qwe:e.kind==="list"?t.value!==e.value?.join(`
826
826
  `):t.value!==Qp(e.value)}function rRt(e,t){let n=null,r;switch(e.kind){case"bool":n=t.value==="true";break;case"int":{const i=jk(e);if(i){const o=Rwe(t.value,i);if(!o.ok)return{ok:!1,error:o.error};n=o.hours;break}const a=Number.parseInt(t.value,10);if(Number.isNaN(a))return{ok:!1,error:"Enter a whole number."};n=a;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=>Qp(a.value)===t.value);n=i?i.value:t.value;break}case"list":n=t.value.split(`