local-operator-ui 0.34.33 → 0.34.35

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 (83) hide show
  1. package/out/main/index.js +17 -2
  2. package/out/renderer/assets/{_basePickBy-CNMIid3L.js → _basePickBy-Bwy5zLqV.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-BesnMR63.js → _baseUniq-cTSxic4C.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-B1wPZHYw.js → agent-details-page-BuRzC3Fb.js} +1 -1
  5. package/out/renderer/assets/{agent-hub-page-zLDCcJ0-.js → agent-hub-page-BGLl7ubt.js} +1 -1
  6. package/out/renderer/assets/{agents-page-8cT_dI_3.js → agents-page-D7goyV3Y.js} +3 -3
  7. package/out/renderer/assets/{arc-MuuzF-kz.js → arc-CyzDoBjX.js} +1 -1
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-Cla6EwFi.js → architectureDiagram-IEHRJDOE-DS-6g-OW.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-Bja9j7dE.js → blockDiagram-JOT3LUYC-B4FopS7J.js} +1 -1
  10. package/out/renderer/assets/{book-open-CKkVZcBo.js → book-open-Bh7p_5I9.js} +1 -1
  11. package/out/renderer/assets/browser-page-0K3mOwPt.js +1 -0
  12. package/out/renderer/assets/{browser-webauthn-prompt-B3uYCxFo.js → browser-webauthn-prompt-T8tsBOG_.js} +1 -1
  13. package/out/renderer/assets/{c4Diagram-VJAJSXHY-DVoi6Fpy.js → c4Diagram-VJAJSXHY-DztdB5nN.js} +1 -1
  14. package/out/renderer/assets/channel-2vQMOrzA.js +1 -0
  15. package/out/renderer/assets/{chunk-4BMEZGHF-Cih6BNjs.js → chunk-4BMEZGHF-BMIPl0Hr.js} +1 -1
  16. package/out/renderer/assets/{chunk-A2AXSNBT-DJo0efSa.js → chunk-A2AXSNBT-DQQDUi7X.js} +1 -1
  17. package/out/renderer/assets/{chunk-AEK57VVT-DvwXfXNo.js → chunk-AEK57VVT-CH9yc8I0.js} +1 -1
  18. package/out/renderer/assets/{chunk-D6G4REZN-HuVYXeWr.js → chunk-D6G4REZN-CEeaWMuP.js} +1 -1
  19. package/out/renderer/assets/{chunk-RZ5BOZE2-BPLh7jSP.js → chunk-RZ5BOZE2-5lGxDeXh.js} +1 -1
  20. package/out/renderer/assets/{chunk-XZIHB7SX-Di-TZ5J_.js → chunk-XZIHB7SX-AaCWHqRT.js} +1 -1
  21. package/out/renderer/assets/classDiagram-GIVACNV2-DIAAAFkD.js +1 -0
  22. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DIAAAFkD.js +1 -0
  23. package/out/renderer/assets/clone-HLBI7OqQ.js +1 -0
  24. package/out/renderer/assets/{console-mirror-BAq7R11H.js → console-mirror-CsyPW-Tp.js} +1 -1
  25. package/out/renderer/assets/{consoleCapture-CWJ7Wd4s.js → consoleCapture-IHG4rlN0.js} +1 -1
  26. package/out/renderer/assets/{conversation-input-sync-Dvqtl3Fr.js → conversation-input-sync-BCGdxxCd.js} +4 -4
  27. package/out/renderer/assets/{dagre-OKDRZEBW-BRG1M9oi.js → dagre-OKDRZEBW-NFcxlsNk.js} +1 -1
  28. package/out/renderer/assets/{diagram-SSKATNLV-DsHLzFSC.js → diagram-SSKATNLV-olLbR5zQ.js} +1 -1
  29. package/out/renderer/assets/{diagram-VNBRO52H-DuDF21bn.js → diagram-VNBRO52H-DaPr8FBn.js} +1 -1
  30. package/out/renderer/assets/{erDiagram-Q7BY3M3F-BS7Xa-1R.js → erDiagram-Q7BY3M3F-DkUJJ-3j.js} +1 -1
  31. package/out/renderer/assets/{error-boundary-CQILQtMV.js → error-boundary-B6HHd2sY.js} +1 -1
  32. package/out/renderer/assets/{flowDiagram-4HSFHLVR-A_BvmOjq.js → flowDiagram-4HSFHLVR-DcTulfQC.js} +1 -1
  33. package/out/renderer/assets/{ganttDiagram-APWFNJXF-BQX036BE.js → ganttDiagram-APWFNJXF-v8SgVhjD.js} +1 -1
  34. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-YpfcZ3NA.js → gitGraphDiagram-7IBYFJ6S-Divy9FjP.js} +1 -1
  35. package/out/renderer/assets/{graph-lKMrX7qR.js → graph-BmjoSK76.js} +1 -1
  36. package/out/renderer/assets/{index-BEYFd0J9.js → index-BUEX1jrE.js} +34 -34
  37. package/out/renderer/assets/{index-CYvymE2l.js → index-CMv0JWYs.js} +1 -1
  38. package/out/renderer/assets/{index-DGSndO-f.js → index-Cy_LQBkK.js} +1 -1
  39. package/out/renderer/assets/index-D2RbXUt0.css +1 -0
  40. package/out/renderer/assets/{infoDiagram-PH2N3AL5-Dg-ZnTmu.js → infoDiagram-PH2N3AL5-DeKysdbP.js} +1 -1
  41. package/out/renderer/assets/{installer-Cgr6muou.js → installer-CggCtWHG.js} +1 -1
  42. package/out/renderer/assets/{journeyDiagram-U35MCT3I-DRzUPcQU.js → journeyDiagram-U35MCT3I-C9acpo5y.js} +1 -1
  43. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-Q474R71W.js → kanban-definition-NDS4AKOZ-C_opiGpl.js} +1 -1
  44. package/out/renderer/assets/{layout-DTC_hgF6.js → layout-DgIPQ4j2.js} +1 -1
  45. package/out/renderer/assets/{legacy-agents-page-k28FA6cr.js → legacy-agents-page-D_LXae3z.js} +1 -1
  46. package/out/renderer/assets/{mermaid.core-C9rYU-0l.js → mermaid.core-C85gayGw.js} +5 -5
  47. package/out/renderer/assets/{mesh-page-DfZZjDNB.js → mesh-page-B3ggGoWR.js} +1 -1
  48. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Bib16-Jn.js → mindmap-definition-ALO5MXBD-BbcOeMJt.js} +1 -1
  49. package/out/renderer/assets/{mini-BJOZ3ClI.js → mini-C0tKql36.js} +1 -1
  50. package/out/renderer/assets/{notebook-pen-DU0uOGQD.js → notebook-pen-BBuxUGpX.js} +1 -1
  51. package/out/renderer/assets/{org-surface-gate-C3vaLLOm.js → org-surface-gate-CAi0pKui.js} +1 -1
  52. package/out/renderer/assets/{page-header-B0mwcG_m.js → page-header-DIWAXkLX.js} +1 -1
  53. package/out/renderer/assets/{pieDiagram-IB7DONF6-CFKHjx11.js → pieDiagram-IB7DONF6-DhxtIL8B.js} +1 -1
  54. package/out/renderer/assets/{projects-page-BCQMniR-.js → projects-page-CKOwpP4O.js} +1 -1
  55. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-B-9tF5TA.js → quadrantDiagram-7GDLP6J5-tc8ZljCT.js} +1 -1
  56. package/out/renderer/assets/{radar-MK3ICKWK-hPJOSxyO.js → radar-MK3ICKWK-Bmq3UTu6.js} +1 -1
  57. package/out/renderer/assets/{radient-auth-buttons-CGDfKjvU.js → radient-auth-buttons-DrWHCQh4.js} +1 -1
  58. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DapE7E6j.js → requirementDiagram-KVF5MWMF-Bk5CBPW4.js} +1 -1
  59. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-dQnFf6xh.js → sankeyDiagram-QLVOVGJD-EFF61gca.js} +1 -1
  60. package/out/renderer/assets/{schedules-page-CTF8k7kQ.js → schedules-page-Cv0e1NTc.js} +1 -1
  61. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DpQcD4s7.js → sequenceDiagram-X6HHIX6F-COA3TyLJ.js} +1 -1
  62. package/out/renderer/assets/{settings-page-Cjj6lVqM.js → settings-page-CjEQj4ET.js} +1 -1
  63. package/out/renderer/assets/{stateDiagram-DGXRK772-BH86RKPp.js → stateDiagram-DGXRK772-BXT9kYsP.js} +1 -1
  64. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CeqFYR4r.js +1 -0
  65. package/out/renderer/assets/{timeline-definition-BDJGKUSR-I9WIfb3F.js → timeline-definition-BDJGKUSR-HANay5P2.js} +1 -1
  66. package/out/renderer/assets/{ui-preferences-store-BiKpLkJR.js → ui-preferences-store-Djl9-Xtm.js} +1 -1
  67. package/out/renderer/assets/{use-download-agent-mutation-DZKciluh.js → use-download-agent-mutation-C5DpadcR.js} +1 -1
  68. package/out/renderer/assets/{use-memberships-query-CouwB8Jj.js → use-memberships-query-DowRGinK.js} +1 -1
  69. package/out/renderer/assets/{use-session-snapshot-BwZz7qKM.js → use-session-snapshot-B55bjKEZ.js} +1 -1
  70. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-RQXd6xeu.js → xychartDiagram-VJFVF3MP-H7ZS_9JZ.js} +1 -1
  71. package/out/renderer/console-capture.html +5 -5
  72. package/out/renderer/index.html +7 -7
  73. package/out/renderer/installer.html +4 -4
  74. package/out/renderer/mini.html +7 -7
  75. package/package.json +2 -2
  76. package/out/renderer/assets/browser-page-BYjoph3Z.js +0 -1
  77. package/out/renderer/assets/channel-BQiffY-M.js +0 -1
  78. package/out/renderer/assets/classDiagram-GIVACNV2-DDObgTCR.js +0 -1
  79. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DDObgTCR.js +0 -1
  80. package/out/renderer/assets/clone-C0j0lwrL.js +0 -1
  81. package/out/renderer/assets/index-DBAaqMbw.css +0 -1
  82. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CPbeGHOQ.js +0 -1
  83. /package/out/renderer/assets/{index-CtslrM_p.js → index-CNJ5TTOd.js} +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-DGSndO-f.js","./ui-preferences-store-BiKpLkJR.js","./index-CtslrM_p.js","./index-DBAaqMbw.css","./error-boundary-CQILQtMV.js","./index-CYvymE2l.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-C9rYU-0l.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
- import{c as Fi,p as nl,ah as Gse,u as ar,ai as Z2e,aj as D2e,ak as V2e,al as ZN,am as M2e,a0 as L2e,a8 as F2e,an as B2e,ac as H2e,ao as K2e,ap as J2e,a2 as DN,a3 as eRe,aq as Yse,ar as tRe,ae as PA,as as nRe,D as rRe,d as VN,r as iRe}from"./ui-preferences-store-BiKpLkJR.js";import{r as $,b as B,j as h,f as aRe,c as j,g as or,w as Ise,x as cb,e as Qn,t as t3}from"./index-CtslrM_p.js";import{a6 as oRe,c as Ze,B as Ae,ak as _A,al as TA,am as RA,an as sRe,ao as XA,ap as lRe,f as Ut,q as cS,r as Zse,T as rf,j as Yd,C as bu,X as Li,a7 as cRe,aC as uRe,aD as ORe,aE as dRe,A as Yl,S as hs,k as Dse,D as EA,l as jA,m as qA,p as Tl,g as k0,h as P0,aB as CA,i as bp,aH as fRe,U as hRe,V as pRe,W as mRe,aj as gRe,R as JQ,y as $Re,N as yRe,O as vRe,P as bRe,I as La,s as Vse,t as Mse,u as Lse,v as Fse,w as n3,x as wRe,ai as r3,L as Bse,aI as SRe,Y as xRe,e as go,z as QRe,F as kRe,G as MN,H as LN,J as PRe,K as FN,aq as _Re,aJ as TRe,a as RRe,n as J5,o as BN,E as HN}from"./error-boundary-CQILQtMV.js";var _n;(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})(_n||(_n={}));var i3;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(i3||(i3={}));const rt=_n.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ac=e=>{switch(typeof e){case"undefined":return rt.undefined;case"string":return rt.string;case"number":return isNaN(e)?rt.nan:rt.number;case"boolean":return rt.boolean;case"function":return rt.function;case"bigint":return rt.bigint;case"symbol":return rt.symbol;case"object":return Array.isArray(e)?rt.array:e===null?rt.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?rt.promise:typeof Map<"u"&&e instanceof Map?rt.map:typeof Set<"u"&&e instanceof Set?rt.set:typeof Date<"u"&&e instanceof Date?rt.date:rt.object;default:return rt.unknown}},Ue=_n.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"]),XRe=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Va 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 Va))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_n.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()}}Va.create=e=>new Va(e);const wp=(e,t)=>{let n;switch(e.code){case Ue.invalid_type:e.received===rt.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Ue.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,_n.jsonStringifyReplacer)}`;break;case Ue.unrecognized_keys:n=`Unrecognized key(s) in object: ${_n.joinValues(e.keys,", ")}`;break;case Ue.invalid_union:n="Invalid input";break;case Ue.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${_n.joinValues(e.options)}`;break;case Ue.invalid_enum_value:n=`Invalid enum value. Expected ${_n.joinValues(e.options)}, received '${e.received}'`;break;case Ue.invalid_arguments:n="Invalid function arguments";break;case Ue.invalid_return_type:n="Invalid function return type";break;case Ue.invalid_date:n="Invalid date";break;case Ue.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}"`:_n.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Ue.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 Ue.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 Ue.custom:n="Invalid input";break;case Ue.invalid_intersection_types:n="Intersection results could not be merged";break;case Ue.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Ue.not_finite:n="Number must be finite";break;default:n=t.defaultError,_n.assertNever(e)}return{message:n}};let Hse=wp;function ERe(e){Hse=e}function uS(){return Hse}const OS=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}},jRe=[];function Je(e,t){const n=uS(),r=OS({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===wp?void 0:wp].filter(i=>!!i)});e.common.issues.push(r)}class Oa{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 At;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 Oa.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 At;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 At=Object.freeze({status:"aborted"}),Nh=e=>({status:"dirty",value:e}),Xa=e=>({status:"valid",value:e}),a3=e=>e.status==="aborted",o3=e=>e.status==="dirty",af=e=>e.status==="valid",d$=e=>typeof Promise<"u"&&e instanceof Promise;function dS(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 Kse(e,t,n,r,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var mt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(mt||(mt={}));var i0,a0;class Fl{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 KN=(e,t)=>{if(af(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 Va(e.common.issues);return this._error=n,this._error}}};function Kt(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 sn{get description(){return this._def.description}_getType(t){return Ac(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Ac(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Oa,ctx:{common:t.parent.common,data:t.data,parsedType:Ac(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(d$(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:Ac(t)},a=this._parseSync({data:t,path:i.path,parent:i});return KN(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:Ac(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:i});return af(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=>af(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:Ac(t)},i=this._parse({data:t,path:r.path,parent:r}),a=await(d$(i)?i:Promise.resolve(i));return KN(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:Ue.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 Hs({schema:this,typeName:qt.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 Il.create(this,this._def)}nullable(){return QO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ms.create(this)}promise(){return xp.create(this,this._def)}or(t){return m$.create([this,t],this._def)}and(t){return g$.create(this,t,this._def)}transform(t){return new Hs({...Kt(this._def),schema:this,typeName:qt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new w$({...Kt(this._def),innerType:this,defaultValue:n,typeName:qt.ZodDefault})}brand(){return new AA({typeName:qt.ZodBranded,type:this,...Kt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new S$({...Kt(this._def),innerType:this,catchValue:n,typeName:qt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return uv.create(this,t)}readonly(){return x$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const qRe=/^c[^\s-]{8,}$/i,CRe=/^[0-9a-z]+$/,ARe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zRe=/^[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,URe=/^[a-z0-9_-]{21}$/i,WRe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,NRe=/^[-+]?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)?)??$/,GRe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,YRe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let e_;const IRe=/^(?:(?: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])$/,ZRe=/^(?:(?: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])$/,DRe=/^(([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]))$/,VRe=/^(([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])$/,MRe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,LRe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Jse="((\\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])))",FRe=new RegExp(`^${Jse}$`);function ele(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 BRe(e){return new RegExp(`^${ele(e)}$`)}function tle(e){let t=`${Jse}T${ele(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 HRe(e,t){return!!((t==="v4"||!t)&&IRe.test(e)||(t==="v6"||!t)&&DRe.test(e))}function KRe(e,t){if(!WRe.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 JRe(e,t){return!!((t==="v4"||!t)&&ZRe.test(e)||(t==="v6"||!t)&&VRe.test(e))}class Ds extends sn{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==rt.string){const a=this._getOrReturnCtx(t);return Je(a,{code:Ue.invalid_type,expected:rt.string,received:a.parsedType}),At}const r=new Oa;let i;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.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),Je(i,{code:Ue.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?Je(i,{code:Ue.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Je(i,{code:Ue.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")GRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"email",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")e_||(e_=new RegExp(YRe,"u")),e_.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"emoji",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")zRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"uuid",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")URe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"nanoid",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")qRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"cuid",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")CRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"cuid2",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")ARe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"ulid",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Je(i,{validation:"url",code:Ue.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),Je(i,{validation:"regex",code:Ue.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),Je(i,{code:Ue.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),Je(i,{code:Ue.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?tle(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?FRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?BRe(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?NRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"duration",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?HRe(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"ip",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?KRe(t.data,a.alg)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"jwt",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?JRe(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"cidr",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?MRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"base64",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?LRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"base64url",code:Ue.invalid_string,message:a.message}),r.dirty()):_n.assertNever(a);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Ue.invalid_string,...mt.errToObj(r)})}_addCheck(t){return new Ds({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...mt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...mt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...mt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...mt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...mt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...mt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...mt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...mt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...mt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...mt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...mt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...mt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...mt.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...mt.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...mt.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...mt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...mt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...mt.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...mt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...mt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...mt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...mt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...mt.errToObj(n)})}nonempty(t){return this.min(1,mt.errToObj(t))}trim(){return new Ds({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ds({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ds({...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}}Ds.create=e=>{var t;return new Ds({checks:[],typeName:qt.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Kt(e)})};function eXe(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 wO extends sn{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)!==rt.number){const a=this._getOrReturnCtx(t);return Je(a,{code:Ue.invalid_type,expected:rt.number,received:a.parsedType}),At}let r;const i=new Oa;for(const a of this._def.checks)a.kind==="int"?_n.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),Je(r,{code:Ue.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),Je(r,{code:Ue.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),Je(r,{code:Ue.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?eXe(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),Je(r,{code:Ue.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),Je(r,{code:Ue.not_finite,message:a.message}),i.dirty()):_n.assertNever(a);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,mt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,mt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,mt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,mt.toString(n))}setLimit(t,n,r,i){return new wO({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mt.toString(i)}]})}_addCheck(t){return new wO({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:mt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:mt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:mt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:mt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:mt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:mt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:mt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:mt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:mt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&_n.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)}}wO.create=e=>new wO({checks:[],typeName:qt.ZodNumber,coerce:e?.coerce||!1,...Kt(e)});class SO extends sn{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)!==rt.bigint)return this._getInvalidInput(t);let r;const i=new Oa;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),Je(r,{code:Ue.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),Je(r,{code:Ue.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),Je(r,{code:Ue.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):_n.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Je(n,{code:Ue.invalid_type,expected:rt.bigint,received:n.parsedType}),At}gte(t,n){return this.setLimit("min",t,!0,mt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,mt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,mt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,mt.toString(n))}setLimit(t,n,r,i){return new SO({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mt.toString(i)}]})}_addCheck(t){return new SO({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:mt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:mt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:mt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:mt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:mt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}SO.create=e=>{var t;return new SO({checks:[],typeName:qt.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Kt(e)})};class f$ extends sn{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==rt.boolean){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.boolean,received:r.parsedType}),At}return Xa(t.data)}}f$.create=e=>new f$({typeName:qt.ZodBoolean,coerce:e?.coerce||!1,...Kt(e)});class of extends sn{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==rt.date){const a=this._getOrReturnCtx(t);return Je(a,{code:Ue.invalid_type,expected:rt.date,received:a.parsedType}),At}if(isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return Je(a,{code:Ue.invalid_date}),At}const r=new Oa;let i;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.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),Je(i,{code:Ue.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):_n.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new of({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:mt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:mt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}of.create=e=>new of({checks:[],coerce:e?.coerce||!1,typeName:qt.ZodDate,...Kt(e)});class fS extends sn{_parse(t){if(this._getType(t)!==rt.symbol){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.symbol,received:r.parsedType}),At}return Xa(t.data)}}fS.create=e=>new fS({typeName:qt.ZodSymbol,...Kt(e)});class h$ extends sn{_parse(t){if(this._getType(t)!==rt.undefined){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.undefined,received:r.parsedType}),At}return Xa(t.data)}}h$.create=e=>new h$({typeName:qt.ZodUndefined,...Kt(e)});class p$ extends sn{_parse(t){if(this._getType(t)!==rt.null){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.null,received:r.parsedType}),At}return Xa(t.data)}}p$.create=e=>new p$({typeName:qt.ZodNull,...Kt(e)});class Sp extends sn{constructor(){super(...arguments),this._any=!0}_parse(t){return Xa(t.data)}}Sp.create=e=>new Sp({typeName:qt.ZodAny,...Kt(e)});class Id extends sn{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Xa(t.data)}}Id.create=e=>new Id({typeName:qt.ZodUnknown,...Kt(e)});class iu extends sn{_parse(t){const n=this._getOrReturnCtx(t);return Je(n,{code:Ue.invalid_type,expected:rt.never,received:n.parsedType}),At}}iu.create=e=>new iu({typeName:qt.ZodNever,...Kt(e)});class hS extends sn{_parse(t){if(this._getType(t)!==rt.undefined){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.void,received:r.parsedType}),At}return Xa(t.data)}}hS.create=e=>new hS({typeName:qt.ZodVoid,...Kt(e)});class Ms extends sn{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==rt.array)return Je(n,{code:Ue.invalid_type,expected:rt.array,received:n.parsedType}),At;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(o||s)&&(Je(n,{code:o?Ue.too_big:Ue.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&&(Je(n,{code:Ue.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&&(Je(n,{code:Ue.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 Fl(n,o,n.path,s)))).then(o=>Oa.mergeArray(r,o));const a=[...n.data].map((o,s)=>i.type._parseSync(new Fl(n,o,n.path,s)));return Oa.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new Ms({...this._def,minLength:{value:t,message:mt.toString(n)}})}max(t,n){return new Ms({...this._def,maxLength:{value:t,message:mt.toString(n)}})}length(t,n){return new Ms({...this._def,exactLength:{value:t,message:mt.toString(n)}})}nonempty(t){return this.min(1,t)}}Ms.create=(e,t)=>new Ms({type:e,minLength:null,maxLength:null,exactLength:null,typeName:qt.ZodArray,...Kt(t)});function Eh(e){if(e instanceof Ur){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Il.create(Eh(r))}return new Ur({...e._def,shape:()=>t})}else return e instanceof Ms?new Ms({...e._def,type:Eh(e.element)}):e instanceof Il?Il.create(Eh(e.unwrap())):e instanceof QO?QO.create(Eh(e.unwrap())):e instanceof Bl?Bl.create(e.items.map(t=>Eh(t))):e}class Ur extends sn{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=_n.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==rt.object){const c=this._getOrReturnCtx(t);return Je(c,{code:Ue.invalid_type,expected:rt.object,received:c.parsedType}),At}const{status:r,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof iu&&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 Fl(i,O,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof iu){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&&(Je(i,{code:Ue.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 Fl(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=>Oa.mergeObjectSync(r,c)):Oa.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return mt.errToObj,new Ur({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,a,o,s;const l=(o=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(s=mt.errToObj(t).message)!==null&&s!==void 0?s:l}:{message:l}}}:{}})}strip(){return new Ur({...this._def,unknownKeys:"strip"})}passthrough(){return new Ur({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ur({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ur({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:qt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Ur({...this._def,catchall:t})}pick(t){const n={};return _n.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new Ur({...this._def,shape:()=>n})}omit(t){const n={};return _n.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new Ur({...this._def,shape:()=>n})}deepPartial(){return Eh(this)}partial(t){const n={};return _n.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}),new Ur({...this._def,shape:()=>n})}required(t){const n={};return _n.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Il;)a=a._def.innerType;n[r]=a}}),new Ur({...this._def,shape:()=>n})}keyof(){return nle(_n.objectKeys(this.shape))}}Ur.create=(e,t)=>new Ur({shape:()=>e,unknownKeys:"strip",catchall:iu.create(),typeName:qt.ZodObject,...Kt(t)});Ur.strictCreate=(e,t)=>new Ur({shape:()=>e,unknownKeys:"strict",catchall:iu.create(),typeName:qt.ZodObject,...Kt(t)});Ur.lazycreate=(e,t)=>new Ur({shape:e,unknownKeys:"strip",catchall:iu.create(),typeName:qt.ZodObject,...Kt(t)});class m$ extends sn{_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 Va(s.ctx.common.issues));return Je(n,{code:Ue.invalid_union,unionErrors:o}),At}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 Va(l));return Je(n,{code:Ue.invalid_union,unionErrors:s}),At}}get options(){return this._def.options}}m$.create=(e,t)=>new m$({options:e,typeName:qt.ZodUnion,...Kt(t)});const wc=e=>e instanceof y$?wc(e.schema):e instanceof Hs?wc(e.innerType()):e instanceof v$?[e.value]:e instanceof xO?e.options:e instanceof b$?_n.objectValues(e.enum):e instanceof w$?wc(e._def.innerType):e instanceof h$?[void 0]:e instanceof p$?[null]:e instanceof Il?[void 0,...wc(e.unwrap())]:e instanceof QO?[null,...wc(e.unwrap())]:e instanceof AA||e instanceof x$?wc(e.unwrap()):e instanceof S$?wc(e._def.innerType):[];class ek extends sn{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==rt.object)return Je(n,{code:Ue.invalid_type,expected:rt.object,received:n.parsedType}),At;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}):(Je(n,{code:Ue.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),At)}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=wc(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 ek({typeName:qt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Kt(r)})}}function s3(e,t){const n=Ac(e),r=Ac(t);if(e===t)return{valid:!0,data:e};if(n===rt.object&&r===rt.object){const i=_n.objectKeys(t),a=_n.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(const s of a){const l=s3(e[s],t[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(n===rt.array&&r===rt.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=s3(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===rt.date&&r===rt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class g$ extends sn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(a,o)=>{if(a3(a)||a3(o))return At;const s=s3(a.value,o.value);return s.valid?((o3(a)||o3(o))&&n.dirty(),{status:n.value,value:s.data}):(Je(r,{code:Ue.invalid_intersection_types}),At)};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}))}}g$.create=(e,t,n)=>new g$({left:e,right:t,typeName:qt.ZodIntersection,...Kt(n)});class Bl extends sn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==rt.array)return Je(r,{code:Ue.invalid_type,expected:rt.array,received:r.parsedType}),At;if(r.data.length<this._def.items.length)return Je(r,{code:Ue.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),At;!this._def.rest&&r.data.length>this._def.items.length&&(Je(r,{code:Ue.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 Fl(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>Oa.mergeArray(n,o)):Oa.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Bl({...this._def,rest:t})}}Bl.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Bl({items:e,typeName:qt.ZodTuple,rest:null,...Kt(t)})};class $$ extends sn{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!==rt.object)return Je(r,{code:Ue.invalid_type,expected:rt.object,received:r.parsedType}),At;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in r.data)i.push({key:a._parse(new Fl(r,s,r.path,s)),value:o._parse(new Fl(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?Oa.mergeObjectAsync(n,i):Oa.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof sn?new $$({keyType:t,valueType:n,typeName:qt.ZodRecord,...Kt(r)}):new $$({keyType:Ds.create(),valueType:t,typeName:qt.ZodRecord,...Kt(n)})}}class pS extends sn{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!==rt.map)return Je(r,{code:Ue.invalid_type,expected:rt.map,received:r.parsedType}),At;const i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,l],c)=>({key:i._parse(new Fl(r,s,r.path,[c,"key"])),value:a._parse(new Fl(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 At;(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 At;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}}}}pS.create=(e,t,n)=>new pS({valueType:t,keyType:e,typeName:qt.ZodMap,...Kt(n)});class sf extends sn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==rt.set)return Je(r,{code:Ue.invalid_type,expected:rt.set,received:r.parsedType}),At;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Je(r,{code:Ue.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&&(Je(r,{code:Ue.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 At;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 Fl(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(t,n){return new sf({...this._def,minSize:{value:t,message:mt.toString(n)}})}max(t,n){return new sf({...this._def,maxSize:{value:t,message:mt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}sf.create=(e,t)=>new sf({valueType:e,minSize:null,maxSize:null,typeName:qt.ZodSet,...Kt(t)});class tp extends sn{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==rt.function)return Je(n,{code:Ue.invalid_type,expected:rt.function,received:n.parsedType}),At;function r(s,l){return OS({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,uS(),wp].filter(c=>!!c),issueData:{code:Ue.invalid_arguments,argumentsError:l}})}function i(s,l){return OS({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,uS(),wp].filter(c=>!!c),issueData:{code:Ue.invalid_return_type,returnTypeError:l}})}const a={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof xp){const s=this;return Xa(async function(...l){const c=new Va([]),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 Xa(function(...l){const c=s._def.args.safeParse(l,a);if(!c.success)throw new Va([r(l,c.error)]);const u=Reflect.apply(o,this,c.data),O=s._def.returns.safeParse(u,a);if(!O.success)throw new Va([i(u,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new tp({...this._def,args:Bl.create(t).rest(Id.create())})}returns(t){return new tp({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new tp({args:t||Bl.create([]).rest(Id.create()),returns:n||Id.create(),typeName:qt.ZodFunction,...Kt(r)})}}class y$ extends sn{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})}}y$.create=(e,t)=>new y$({getter:e,typeName:qt.ZodLazy,...Kt(t)});class v$ extends sn{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Je(n,{received:n.data,code:Ue.invalid_literal,expected:this._def.value}),At}return{status:"valid",value:t.data}}get value(){return this._def.value}}v$.create=(e,t)=>new v$({value:e,typeName:qt.ZodLiteral,...Kt(t)});function nle(e,t){return new xO({values:e,typeName:qt.ZodEnum,...Kt(t)})}class xO extends sn{constructor(){super(...arguments),i0.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Je(n,{expected:_n.joinValues(r),received:n.parsedType,code:Ue.invalid_type}),At}if(dS(this,i0)||Kse(this,i0,new Set(this._def.values)),!dS(this,i0).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return Je(n,{received:n.data,code:Ue.invalid_enum_value,options:r}),At}return Xa(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 xO.create(t,{...this._def,...n})}exclude(t,n=this._def){return xO.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}i0=new WeakMap;xO.create=nle;class b$ extends sn{constructor(){super(...arguments),a0.set(this,void 0)}_parse(t){const n=_n.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==rt.string&&r.parsedType!==rt.number){const i=_n.objectValues(n);return Je(r,{expected:_n.joinValues(i),received:r.parsedType,code:Ue.invalid_type}),At}if(dS(this,a0)||Kse(this,a0,new Set(_n.getValidEnumValues(this._def.values))),!dS(this,a0).has(t.data)){const i=_n.objectValues(n);return Je(r,{received:r.data,code:Ue.invalid_enum_value,options:i}),At}return Xa(t.data)}get enum(){return this._def.values}}a0=new WeakMap;b$.create=(e,t)=>new b$({values:e,typeName:qt.ZodNativeEnum,...Kt(t)});class xp extends sn{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==rt.promise&&n.common.async===!1)return Je(n,{code:Ue.invalid_type,expected:rt.promise,received:n.parsedType}),At;const r=n.parsedType===rt.promise?n.data:Promise.resolve(n.data);return Xa(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}xp.create=(e,t)=>new xp({type:e,typeName:qt.ZodPromise,...Kt(t)});class Hs extends sn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===qt.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=>{Je(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 At;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?At:l.status==="dirty"||n.value==="dirty"?Nh(l.value):l});{if(n.value==="aborted")return At;const s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?At:s.status==="dirty"||n.value==="dirty"?Nh(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"?At:(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"?At:(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(!af(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=>af(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):o);_n.assertNever(i)}}Hs.create=(e,t,n)=>new Hs({schema:e,typeName:qt.ZodEffects,effect:t,...Kt(n)});Hs.createWithPreprocess=(e,t,n)=>new Hs({schema:t,effect:{type:"preprocess",transform:e},typeName:qt.ZodEffects,...Kt(n)});class Il extends sn{_parse(t){return this._getType(t)===rt.undefined?Xa(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Il.create=(e,t)=>new Il({innerType:e,typeName:qt.ZodOptional,...Kt(t)});class QO extends sn{_parse(t){return this._getType(t)===rt.null?Xa(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}QO.create=(e,t)=>new QO({innerType:e,typeName:qt.ZodNullable,...Kt(t)});class w$ extends sn{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===rt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}w$.create=(e,t)=>new w$({innerType:e,typeName:qt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Kt(t)});class S$ extends sn{_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 d$(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Va(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Va(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}S$.create=(e,t)=>new S$({innerType:e,typeName:qt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Kt(t)});class mS extends sn{_parse(t){if(this._getType(t)!==rt.nan){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.nan,received:r.parsedType}),At}return{status:"valid",value:t.data}}}mS.create=e=>new mS({typeName:qt.ZodNaN,...Kt(e)});const tXe=Symbol("zod_brand");class AA extends sn{_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 uv extends sn{_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"?At:a.status==="dirty"?(n.dirty(),Nh(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"?At: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 uv({in:t,out:n,typeName:qt.ZodPipeline})}}class x$ extends sn{_parse(t){const n=this._def.innerType._parse(t),r=i=>(af(i)&&(i.value=Object.freeze(i.value)),i);return d$(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}x$.create=(e,t)=>new x$({innerType:e,typeName:qt.ZodReadonly,...Kt(t)});function JN(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function rle(e,t={},n){return e?Sp.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=JN(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=JN(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})}}):Sp.create()}const nXe={object:Ur.lazycreate};var qt;(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"})(qt||(qt={}));const rXe=(e,t={message:`Input not instance of ${e.name}`})=>rle(n=>n instanceof e,t),ile=Ds.create,ale=wO.create,iXe=mS.create,aXe=SO.create,ole=f$.create,oXe=of.create,sXe=fS.create,lXe=h$.create,cXe=p$.create,uXe=Sp.create,OXe=Id.create,dXe=iu.create,fXe=hS.create,hXe=Ms.create,pXe=Ur.create,mXe=Ur.strictCreate,gXe=m$.create,$Xe=ek.create,yXe=g$.create,vXe=Bl.create,bXe=$$.create,wXe=pS.create,SXe=sf.create,xXe=tp.create,QXe=y$.create,kXe=v$.create,PXe=xO.create,_Xe=b$.create,TXe=xp.create,eG=Hs.create,RXe=Il.create,XXe=QO.create,EXe=Hs.createWithPreprocess,jXe=uv.create,qXe=()=>ile().optional(),CXe=()=>ale().optional(),AXe=()=>ole().optional(),zXe={string:e=>Ds.create({...e,coerce:!0}),number:e=>wO.create({...e,coerce:!0}),boolean:e=>f$.create({...e,coerce:!0}),bigint:e=>SO.create({...e,coerce:!0}),date:e=>of.create({...e,coerce:!0})},UXe=At;var X=Object.freeze({__proto__:null,defaultErrorMap:wp,setErrorMap:ERe,getErrorMap:uS,makeIssue:OS,EMPTY_PATH:jRe,addIssueToContext:Je,ParseStatus:Oa,INVALID:At,DIRTY:Nh,OK:Xa,isAborted:a3,isDirty:o3,isValid:af,isAsync:d$,get util(){return _n},get objectUtil(){return i3},ZodParsedType:rt,getParsedType:Ac,ZodType:sn,datetimeRegex:tle,ZodString:Ds,ZodNumber:wO,ZodBigInt:SO,ZodBoolean:f$,ZodDate:of,ZodSymbol:fS,ZodUndefined:h$,ZodNull:p$,ZodAny:Sp,ZodUnknown:Id,ZodNever:iu,ZodVoid:hS,ZodArray:Ms,ZodObject:Ur,ZodUnion:m$,ZodDiscriminatedUnion:ek,ZodIntersection:g$,ZodTuple:Bl,ZodRecord:$$,ZodMap:pS,ZodSet:sf,ZodFunction:tp,ZodLazy:y$,ZodLiteral:v$,ZodEnum:xO,ZodNativeEnum:b$,ZodPromise:xp,ZodEffects:Hs,ZodTransformer:Hs,ZodOptional:Il,ZodNullable:QO,ZodDefault:w$,ZodCatch:S$,ZodNaN:mS,BRAND:tXe,ZodBranded:AA,ZodPipeline:uv,ZodReadonly:x$,custom:rle,Schema:sn,ZodSchema:sn,late:nXe,get ZodFirstPartyTypeKind(){return qt},coerce:zXe,any:uXe,array:hXe,bigint:aXe,boolean:ole,date:oXe,discriminatedUnion:$Xe,effect:eG,enum:PXe,function:xXe,instanceof:rXe,intersection:yXe,lazy:QXe,literal:kXe,map:wXe,nan:iXe,nativeEnum:_Xe,never:dXe,null:cXe,nullable:XXe,number:ale,object:pXe,oboolean:AXe,onumber:CXe,optional:RXe,ostring:qXe,pipeline:jXe,preprocess:EXe,promise:TXe,record:bXe,set:SXe,strictObject:mXe,string:ile,symbol:sXe,transformer:eG,tuple:vXe,undefined:lXe,union:gXe,unknown:OXe,void:fXe,NEVER:UXe,ZodIssueCode:Ue,quotelessJson:XRe,ZodError:Va});const WXe=6*1024,NXe=512;function gS(e,t,n){let r=new TextEncoder().encode(`${t}${e.size?`?${e}`:""}`).length;const i=[];for(const a of n){if(i.length===NXe)break;const s=new URLSearchParams({order_ids:a}).toString().length+1;if(r+s>WXe)break;e.append("order_ids",a),i.push(a),r+=s}return i}function GXe(e,t,n){return gS(new URLSearchParams(n),t,e)}const zt=X.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),ub=X.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),Ob=X.string().min(1).max(32768),zA=/^[a-f0-9]{12}$/,wt=X.string().regex(zA),t_=X.string().regex(/^[a-f0-9]{12}$/),n_=X.string().min(1).max(128),YXe=X.string().min(1).max(4096),r_=X.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),db=X.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),tG=X.string().regex(/^[a-f0-9]{32}$/),sle=/^(\/|[A-Za-z]:[\\/])/,i_=X.string().min(1).max(4096).regex(sle),nG=/^[a-f0-9]{32}$/,dr=X.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),sh=X.string().regex(/^[A-Za-z0-9_-]{1,128}$/),rG=X.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),iG=X.object({data_b64:X.string().min(1).max(1e6),mime_type:X.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),kO=2e5,Q$=8,IXe=256,ZXe=100,l3=16,UA=256,lle=100,cle=200,c3=1e6,Vo=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)),fb=X.object({kind:X.enum(["agent","team"]),name:Vo}).strict(),a_=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(),aG=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(),oG=X.object({name:X.string().min(1).max(64).optional(),description:X.string().max(8e3).optional(),manager:Vo.optional(),members:X.array(X.object({role:Vo,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(),DXe=X.record(X.array(X.string().max(1024)).max(100)),sG=X.enum(["minutes","hours","days"]);function VXe(e){return!/^\.+$/.test(e)}const Oln=e=>f1.safeParse(e).success,f1=X.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(VXe),lG=X.enum(["str","int","float","bool","list","dict"]),cG=X.string().max(16384),MXe=2e3,uG=X.string().min(1).max(MXe),OG=X.string().min(1).max(64),LXe=X.string().min(1).max(64),FXe=X.string().min(1).max(64),dG=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(),BXe=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(),u3=128,fG=2e3,hG=8e3,pG=64,mG=64,tk=e=>[...e].length,O3=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,HXe=e=>e===9||e===10||e===11||e===12||e===13||e===133,KXe=e=>e<=31||e>=127&&e<=159,JXe=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),e4e=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,hb=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},ule=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&O3(t[n].codePointAt(0)??0);)n++;for(;r>n&&O3(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},t4e=e=>{let t="",n=!1;for(const r of e){if(O3(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function n4e(e){const t=ule(e);if(!t)return"must not be empty";if(tk(t)>u3)return`must be at most ${u3} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(hb(t,e4e))return"must not contain Unicode bidirectional override characters";if(hb(t,HXe))return"must not contain whitespace";if(hb(t,KXe))return"must not contain control characters";if(hb(t,JXe))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 dln(e){return t4e(ule(e).normalize("NFKC").toLowerCase())}function r4e(e){return e.trim()?tk(e)>fG?`must be at most ${fG} characters`:null:"must not be empty"}function i4e(e){return e.trim()?tk(e)>hG?`must be at most ${hG} characters`:null:"must not be empty"}function a4e(e){if(e.length>mG)return`must hold at most ${mG} items`;for(const t of e)if(!t.trim()||tk(t)>pG)return`must hold items of 1 to ${pG} characters`;return null}const o4e=e=>n4e(e)===null,s4e=X.string().refine(o4e,{message:"That is not a name the hub can publish."}),l4e=X.string().refine(e=>i4e(e)===null,{message:"That instruction body cannot be published."}),c4e=X.string().refine(e=>r4e(e)===null,{message:"That description cannot be published."}),u4e=X.array(X.string()).refine(e=>a4e(e)===null,{message:"That tool list cannot be published."}),gG=X.object({name:s4e,description:c4e,instructions:l4e,kind:X.enum(["role","specialist"]),when_to_use:X.string(),tools:u4e,effort:X.string(),delegate:X.boolean(),version:X.string(),categories:X.array(X.string()),tags:X.array(X.string())}).partial().strict(),O4e=X.enum(["team","agent"]),d4e=X.string().min(1).max(64),f4e=X.string().min(1).max(256),Ole=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,o_=X.string().regex(Ole,{message:"Letters, digits, dot, underscore and dash; no spaces."}),h4e=["planning","active","qa","validation","done","paused","archived"],$G=X.enum(h4e),pb=X.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),yG=X.array(X.string().min(1).max(24)).max(8),Au=X.string().min(1).max(64),p4e=1e3,vG=240,bG=80,m4e=256,g4e=100,$4e=200,y4e=/^[a-z0-9][a-z0-9_-]{0,23}$/;function fln(e){return e?Ole.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 hln(e){return y4e.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const mb=X.enum(["agent","team"]),v4e=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:Vo}).strict(),X.object({op:X.literal("profiles.install"),name:Vo,requestId:dr}).strict(),X.object({op:X.literal("profiles.create"),name:Vo,requestId:dr,fields:aG.extend({description:X.string().max(8e3),instructions:X.string().min(1).max(8e3)})}).strict(),X.object({op:X.literal("profiles.update"),name:Vo,requestId:dr,fields:aG}).strict(),X.object({op:X.literal("hub.updates")}).strict(),X.object({op:X.literal("hub.check"),requestId:dr,kind:mb.optional(),name:Vo.optional()}).strict(),X.object({op:X.literal("hub.apply"),requestId:dr,kind:mb,name:Vo,prefer:X.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:X.boolean().optional(),dryRun:X.boolean().optional()}).strict(),X.object({op:X.literal("hub.applyAll"),requestId:dr,kind:mb.optional()}).strict(),X.object({op:X.literal("hub.retry"),requestId:dr,kind:mb,name:Vo}).strict(),X.object({op:X.literal("teams.list")}).strict(),X.object({op:X.literal("teams.get"),name:Vo}).strict(),X.object({op:X.literal("teams.create"),requestId:dr,fields:oG.extend({name:X.string().min(1).max(64)})}).strict(),X.object({op:X.literal("teams.update"),name:Vo,requestId:dr,fields:oG}).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:O4e.optional(),scope_name:d4e.optional(),cursor:f4e.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(IXe),limit:X.number().int().min(1).max(500).optional(),include_archived:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.archive"),sessionId:wt,archived:X.boolean()}).strict(),X.object({op:X.literal("sessions.delete"),sessionId:wt,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.create"),requestId:dr,cwd:X.string().min(1).max(4096).optional(),target:fb.optional(),purpose:X.literal("agents-config").optional(),model:a_.optional(),draftId:wt.optional(),peer:sh.optional()}).strict(),X.object({op:X.literal("sessions.preview"),requestId:dr,cwd:X.string().min(1).max(4096),target:fb.optional(),model:a_.optional()}).strict(),X.object({op:X.literal("sessions.draft"),requestId:dr,cwd:X.string().min(1).max(4096),target:fb.optional(),model:a_.optional()}).strict(),X.object({op:X.literal("sessions.get"),sessionId:wt,journalOrder:X.boolean().optional(),orderIds:X.array(X.string().min(1).max(128)).max(512).optional()}).strict(),X.object({op:X.literal("sessions.history"),sessionId:wt,beforeId:zt.optional(),limit:X.number().int().min(1).max(500).optional(),openFrame:X.boolean().optional(),journalOrder:X.boolean().optional(),orderIds:X.array(X.string().min(1).max(128)).max(512).optional()}).strict(),X.object({op:X.literal("sessions.checkpoints"),sessionId:wt}).strict(),X.object({op:X.literal("sessions.checkpoints.warm"),sessionId:wt,ids:X.array(zt).max(l3).optional(),limit:X.number().int().min(1).max(l3).optional()}).strict(),X.object({op:X.literal("sessions.find"),sessionId:wt,q:X.string().min(1).max(UA),limit:X.number().int().min(1).max(cle).optional()}).strict(),X.object({op:X.literal("subagents.transcript"),sessionId:wt,childId:wt,beforeId:zt.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.message"),sessionId:wt,requestId:dr,text:X.string().max(kO),images:X.array(iG).max(Q$).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:wt,requestId:dr,command:X.string().regex(/^\/?[A-Za-z]+$/).max(64),args:X.string().max(kO).optional(),images:X.array(iG).max(Q$).optional()}).strict(),X.object({op:X.literal("sessions.move"),sessionId:wt,requestId:dr,cwd:X.string().min(1).max(4096)}).strict(),X.object({op:X.literal("sessions.answer"),sessionId:wt,epoch:zt.optional(),requestId:zt.optional(),value:X.string().max(32768).optional(),approved:X.boolean().optional(),questionIndex:X.number().int().min(0).optional(),askId:zt.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:wt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("attention.seen"),items:X.array(X.object({sessionId:wt,completionToken:X.string().uuid()}).strict()).min(1).max(500)}).strict(),X.object({op:X.literal("sessions.notified"),sessionId:wt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("sessions.pin"),sessionId:wt,pinned:X.boolean()}).strict(),X.object({op:X.literal("sessions.watch"),sessionId:wt,subscriptionId:X.string().regex(nG),visible:X.boolean(),canNotify:X.boolean()}).strict(),X.object({op:X.literal("sessions.warm"),sessionId:wt}).strict(),X.object({op:X.literal("sessions.interrupt"),sessionId:wt,requestId:dr}).strict(),X.object({op:X.literal("supplements.cancel"),sessionId:wt,job:t_,anchor:n_}).strict(),X.object({op:X.literal("supplements.restart"),sessionId:wt,job:t_,anchor:n_}).strict(),X.object({op:X.literal("supplements.steer"),sessionId:wt,job:t_,anchor:n_,text:X.string().min(1).max(500)}).strict(),X.object({op:X.literal("sessions.variables.list"),sessionId:wt}).strict(),X.object({op:X.literal("sessions.variables.create"),sessionId:wt,key:f1,value:cG,type:lG}).strict(),X.object({op:X.literal("sessions.variables.update"),sessionId:wt,key:f1,value:cG,type:lG}).strict(),X.object({op:X.literal("sessions.variables.delete"),sessionId:wt,key:f1}).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:zt}).strict(),X.object({op:X.literal("legacy.agent.upload"),agentId:zt}).strict(),X.object({op:X.literal("agent.publish"),agentId:zt,document:gG.optional(),visibility:X.literal("org").optional(),tenantId:zt.optional()}).strict(),X.object({op:X.literal("agent.republish"),agentId:zt,hubAgentId:zt,document:gG.optional(),visibility:X.literal("org").optional(),tenantId:zt.optional()}).strict(),X.object({op:X.literal("team.pull"),teamId:zt,tenantId:zt.optional()}).strict(),X.object({op:X.literal("agent.nameAvailability"),name:X.string().min(1).max(u3)}).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:zt}).strict(),X.object({op:X.literal("legacy.agent.history"),agentId:zt,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:zt.optional(),status:X.string().max(64).optional()}).strict(),X.object({op:X.literal("legacy.job.get"),jobId:zt}).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:zt,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:zt,schedule:dG.extend({prompt:X.string().max(64e3),interval:X.number().int().min(1),unit:sG})}).strict(),X.object({op:X.literal("legacy.schedule.get"),scheduleId:zt}).strict(),X.object({op:X.literal("legacy.schedule.edit"),scheduleId:zt,schedule:dG.extend({prompt:X.string().max(64e3).nullish(),interval:X.number().int().min(1).nullish(),unit:sG.nullish()})}).strict(),X.object({op:X.literal("legacy.schedule.remove"),scheduleId:zt}).strict(),X.object({op:X.literal("legacy.agent.create"),agent:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.update"),agentId:zt,update:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.delete"),agentId:zt}).strict(),X.object({op:X.literal("legacy.agent.conversation.clear"),agentId:zt}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.get"),agentId:zt}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.update"),agentId:zt,systemPrompt:X.string().max(c3)}).strict(),X.object({op:X.literal("legacy.agent.download"),agentId:zt}).strict(),X.object({op:X.literal("legacy.job.cancel"),jobId:zt}).strict(),X.object({op:X.literal("commands.list")}).strict(),X.object({op:X.literal("commands.entities"),sessionId:wt,command:zt,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:zt.optional(),live:X.boolean().optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("quota.notice"),provider:zt.optional(),model:X.string().min(1).max(200).optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("analytics.get"),sessionId:wt.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:wt.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:wt,recentLimit:X.number().int().min(0).max(50).optional()}).strict(),X.object({op:X.literal("skills.list"),sessionId:wt.optional(),cwd:YXe.optional(),name:zt.optional()}).strict(),X.object({op:X.literal("sessions.failovers"),sessionId:wt}).strict(),X.object({op:X.literal("sessions.credential"),sessionId:wt,action:X.enum(["list","store","forget"]),key:ub.optional(),value:Ob.optional(),confirmed:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.fork"),sessionId:wt,requestId:dr,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:dr,targets:X.array(wt).min(1).max(100),confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside"),sessionId:wt,requestId:dr,text:X.string().min(1).max(32768),asideId:dr.optional(),subscriptionId:X.string().regex(nG).optional()}).strict(),X.object({op:X.literal("sessions.adopt"),sessionId:wt,requestId:dr,asideId:dr,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside.get"),sessionId:wt,asideId:dr}).strict(),X.object({op:X.literal("sessions.aside.close"),sessionId:wt,asideId:dr}).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:dr,sessionId:wt.optional(),cwd:X.string().min(1).max(4096).optional(),target:fb.optional(),message:uG,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:wt,wakeId:OG,message:uG.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:wt,wakeId:OG}).strict(),X.object({op:X.literal("monitors.cancel"),sessionId:wt,monitorId:LXe}).strict(),X.object({op:X.literal("jobs.cancel"),sessionId:wt,jobId:FXe}).strict(),X.object({op:X.literal("mcp.list"),sessionId:wt}).strict(),X.object({op:X.literal("mcp.credentials.store"),sessionId:wt,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:wt,control:X.object({action:X.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:r_.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(db).optional(),url:X.string().max(4096).optional(),headers:X.record(db).optional(),oauth:X.boolean().optional(),confirmed:X.boolean().optional(),operation_id:tG.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog"),cwd:i_.optional(),sessionId:wt.optional()}).strict(),X.object({op:X.literal("mcp.catalog.control"),cwd:i_.optional(),control:X.object({action:X.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:r_.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(db).optional(),url:X.string().max(4096).optional(),headers:X.record(db).optional(),confirmed:X.boolean().optional(),operation_id:tG.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog.credentials"),header:X.string().min(1).max(128).optional(),cwd:i_.optional(),name:r_,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:dr.optional(),tenant_id:zt.optional(),account_id:zt.optional(),agent_id:zt.optional(),comment_id:zt.optional(),team_id:zt.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:zt}).strict(),X.object({op:X.literal("auth.status"),id:zt}).strict(),X.object({op:X.literal("auth.input"),id:zt,promptId:zt,value:Ob}).strict(),X.object({op:X.literal("auth.cancel"),id:zt}).strict(),X.object({op:X.literal("auth.key"),provider:zt,value:Ob}).strict(),X.object({op:X.literal("auth.logout"),provider:zt}).strict(),X.object({op:X.literal("settings.list")}).strict(),X.object({op:X.literal("settings.edit"),key:ub,value:X.unknown().refine(e=>e!==void 0,"A setting value is required."),base:DXe.optional()}).strict(),X.object({op:X.literal("settings.reset"),key:ub}).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:BXe}).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:ub,value:Ob}).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:sh,role:X.enum(["read","drive","admin"]),deviceId:sh.optional()}).strict(),X.object({op:X.literal("networks.member.remove"),networkId:sh,deviceId:sh,confirm:X.string().min(1).max(256)}).strict(),X.object({op:X.literal("sessions.transfer"),sessionId:wt,to:X.union([X.literal("local"),sh]),keep:X.boolean().optional(),waitS:X.number().min(0).max(300).optional(),requestId:dr.optional()}).strict(),X.object({op:X.literal("approvals.list")}).strict(),X.object({op:X.literal("approvals.approve"),approvalId:rG}).strict(),X.object({op:X.literal("approvals.deny"),approvalId:rG}).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:Au}).strict(),X.object({op:X.literal("projects.create"),name:o_,description:X.string().max(vG).optional(),status:$G.optional(),tags:yG.optional()}).strict(),X.object({op:X.literal("projects.update"),key:Au,fields:X.object({name:o_.optional(),title:X.string().max(80).optional(),owner:X.string().max(80).optional(),team:X.string().max(80).optional(),description:X.string().max(vG).optional(),status:$G.optional(),progress:X.string().max(p4e).optional(),tags:yG.optional(),start_date:pb.optional(),target_date:pb.optional(),completed_at:pb.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:Au,confirmed_name:o_}).strict(),X.object({op:X.literal("projects.link"),key:Au,sessionId:wt}).strict(),X.object({op:X.literal("projects.unlink"),key:Au,sessionId:wt}).strict(),X.object({op:X.literal("projects.milestone"),key:Au,name:X.string().min(1).max(bG),targetDate:pb.optional(),completed:X.boolean().optional()}).strict(),X.object({op:X.literal("projects.milestone.remove"),key:Au,name:X.string().min(1).max(bG)}).strict(),X.object({op:X.literal("projects.request_update"),key:Au}).strict(),X.object({op:X.literal("projects.search"),q:X.string().min(1).max(m4e),limit:X.number().int().min(1).max($4e).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:wt}).strict(),X.object({op:X.literal("code_requests.refresh"),sessionId:wt,keys:X.array(X.string().min(1).max(512)).max(256).optional(),force:X.boolean().optional()}).strict(),X.object({op:X.literal("static.sign"),route:X.enum(["images","videos","audio","html"]),path:X.string().min(1),ttlS:X.number().int().min(1).max(3600).optional()}).strict()]);v4e.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 xo={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},WA={runtimeUnreachable:"runtime_unreachable"},Tm="runtime_busy",dle="runtime_retiring",nk={[xo.noCredential]:"This app is not paired with the running Local Operator server, so this control is unavailable.",[xo.refused]:"This app's credential for the running Local Operator server was refused, so this control is unavailable.",[xo.planeClosed]:"The running Local Operator server does not accept this app's desktop controls.",[xo.transportFailed]:"The Local Operator server did not answer this request."},k$={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 Qp(e){return e!==void 0&&Object.values(xo).includes(e)}function b4e(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return xo.refused;if(t===503)return xo.planeClosed}}const w4e=88e4,S4e=11e5,x4e=2e4,Q4e=9e4,k4e=new Set(["analytics.get","analytics.models","sessions.report"]),P4e=new Set(["usage.get"]),_4e=new Set(["networks.list","peers.list"]),T4e=new Set([...k4e,...P4e,..._4e]),R4e=90,X4e=30,E4e=300,j4e=10,fle=15,q4e=1e4;function C4e(e){const n=e.to==="local"||e.keep?E4e:X4e,r=Math.max(0,e.waitS??0);return(R4e+n+j4e+fle)*1e3+r*1e3}const A4e=18e4,z4e=A4e+15e3,U4e=120,hle=(U4e+30+fle)*1e3,W4e=6e4,N4e=5*hle,G4e=new Set(["hub.apply","hub.retry","hub.check","hub.applyAll"]);function Y4e(e){switch(e){case"hub.apply":case"hub.retry":return hle;case"hub.check":return W4e;case"hub.applyAll":return N4e;default:return null}}function I4e(e){if(typeof e!="string"&&e.op==="sessions.transfer")return C4e(e)+q4e;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return z4e;const n=Y4e(t);return n!==null?n:T4e.has(t)?Q4e:x4e}const Z4e=5e3;function NA(e){return I4e(e)+Z4e}const rk="deadline_exceeded",ple="foreground_required",mle="View these completions in the foreground before marking them read.",D4e=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"]),V4e=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function M4e(e,t){const n=Math.round(t/1e3),r=rk;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.`}:G4e.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:D4e.has(e)?{code:r,message:V4e.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 ik=w4e,L4e=S4e;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 F4e(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function wG(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 SG(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 ak(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??ZXe)});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":{const t=new URLSearchParams;return e.journalOrder&&(t.set("journal_order","1"),gS(t,`/v1/desktop/sessions/${e.sessionId}`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}${t.size?`?${t}`:""}`,method:"GET"}}case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.openFrame&&(t.set("open_frame","1"),t.set("supplements","1")),e.journalOrder&&(t.set("journal_order","1"),gS(t,`/v1/desktop/sessions/${e.sessionId}/history`,e.orderIds??[])),{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??lle)});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"supplements.cancel":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/cancel`,method:"POST",body:{anchor:e.anchor}};case"supplements.restart":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/restart`,method:"POST",body:{anchor:e.anchor}};case"supplements.steer":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/steer`,method:"POST",body:{anchor:e.anchor,text:e.text}};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":{SG(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":{SG(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,...F4e(e),message:e.message,...wG(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...wG(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"jobs.cancel":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/jobs/${encodeURIComponent(e.jobId)}/cancel`,method:"POST"};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??g4e)})}`,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}:{}}};case"static.sign":return{path:"/v1/static/sign",method:"POST",body:{route:e.route,path:e.path,ttl_s:e.ttlS}}}}const gle=64,xG=64*1024*1024,B4e="superseded_completion_token",H4e="store_busy",K4e="session_is_remote",J4e="owner_build_behind";function eEe(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 Rd(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 $le(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const yle=e=>typeof e?.goal_status=="string",vle=e=>(e?.goal??"").trim().length>0;function tEe(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 _0={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."},QG={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},nEe={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},rEe={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},iEe={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},aEe={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function kG(e){return e?e===_0.notPaired?rEe:e===_0.serverDown?nEe:e===_0.frameBudget?aEe:QG:QG}const oEe=(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 sEe(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 ble=Fi()(nl(e=>({notice:null,receive:t=>e(n=>oEe(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:Gse(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));async function GA(e){if(window.api?.desktop)try{return await lEe(window.api.desktop.request(e),e)}catch(n){throw n instanceof Wt?n:hEe(n)?new au(mle,ple):new Wt(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 Wt(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Wt(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function lEe(e,t){const n=NA(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=M4e(t.op,n);a(new Wt(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const wle="This server did not answer the request for its desktop controls.";class Wt 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 au extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function Xo(e,t){return e instanceof Wt||e instanceof au?Qp(e.code)?nk[e.code]:e.message:t}function cEe(e,t,n,r){return typeof r=="string"?r:n===k$.noCredential?xo.noCredential:n===k$.transportFailed?xo.transportFailed:b4e(ak(e).path,t)}async function _e(e){const t=await GA(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Wt(t.status,r??wle,void 0,cEe(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"&&uEe(n?.result),n?.result}function uEe(e){if(typeof e!="object"||e===null)return;const t=sEe(e.delegated_cleanup_notice);t&&ble.getState().receive(t)}async function OEe(){try{await _e({op:"delegated_cleanup_notice.ack"})}catch{}}async function pln(){ble.getState().dismiss(),await OEe()}function Sle(e){return e instanceof Wt&&e.code===rk}function dEe(e){if(!(e instanceof Wt))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===J4e:e.code===K4e}function fEe(e){return e instanceof au&&e.code===ple}function hEe(e){return e instanceof Error&&e.message.includes(mle)}async function Un(e){const t=await GA(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function pEe(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await _e({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 mEe(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"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),gS(r,"/__desktop/stream",e.orderIds??[]));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:_0.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function lf(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.",o;if(i.includes("application/json"))try{const l=(await r.json())?.detail;if(typeof l=="string")a=l;else if(typeof l=="object"&&l!==null){const c=l;typeof c.text=="string"&&c.text.trim()?a=c.text:typeof c.message=="string"&&c.message.trim()&&(a=c.message),typeof c.code=="string"&&(o=c.code)}}catch{}return{status:r.status,kind:"error",detail:a,code:o!==void 0&&Qp(o)?o:a===k$.noCredential?xo.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 P$(e){return e.kind==="error"?Qp(e.code)?new au(nk[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const d3=e=>({revision:Zo(e),demand:e.orderDemand}),T0=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function YA(e,t,n,r,i){let a=e;const o=t.journal_generation;if(typeof o!="string"||o.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!a.journalMode?{...a,journalMode:!0}:a;if(r&&t.journal_order_state==="ready"&&i&&a.orderNeedsReconcile&&a.orderDemand===i.demand&&(a={...a,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),o!==a.journalGeneration&&!r)return a.orderNeedsReconcile&&a.orderWantedGeneration===o?a:{...a,orderNeedsReconcile:!0,orderWantedGeneration:o,orderDemand:{generation:o}};let s=a.journalMode?a:{...a,journalMode:!0};o!==a.journalGeneration&&(s={...a,journalMode:!0,journalGeneration:o,orderRevision:(a.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:a.orderNeedsReconcile,orderWantedGeneration:a.orderWantedGeneration,orderDemand:a.orderDemand});let l=s.journalPositions??new Map;const c=l,u=(O,d,f)=>{if(!T0(f))return;const p=l.get(O);p&&p.seq>=f||(l===c&&(l=new Map(l)),l.set(O,{entryId:d,seq:f}))};for(const[O,d]of Object.entries(t.journal_ordinals??{}))u(O,O,d);for(const O of n)typeof O.id=="string"&&(u(O.id,O.id,O.journal_seq),O.role==="tool"&&typeof O.tool_call_id=="string"&&u(`tool:${O.tool_call_id}`,O.id,O.journal_seq),typeof O.anchor=="string"&&u(`supplement:${O.anchor}`,O.id,O.journal_seq));return l!==c&&(s={...s,journalPositions:l}),s}function IA(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map;const r=n;for(const i of t.tool_calls)!i||typeof i.id!="string"||n.get(i.id)===t.id||(n===r&&(n=new Map(n)),n.set(i.id,t.id));return n===r?e:{...e,journalCallOwners:n}}function xle(e,t){if(!e.journalMode)return t;const n=e.journalGeneration,r=e.journalPositions;let i=!1;const a=t.map(O=>{let f=[r?.get(O.sourceEntryId??O.id),r?.get(O.id)].filter(g=>g!==void 0).sort((g,y)=>y.seq-g.seq)[0];if(O.journalGeneration===n&&T0(O.journalSeq)&&(!f||O.journalSeq>f.seq)&&(f={entryId:O.sourceEntryId??O.id,seq:O.journalSeq}),!f||!n||!(O.kind==="user"&&(O.provisional===!0||O.local===!0))&&O.sourceEntryId===f.entryId&&O.journalSeq===f.seq&&O.journalGeneration===n)return O;i=!0;let m={...O,sourceEntryId:f.entryId,journalSeq:f.seq,journalGeneration:n};if(m.kind==="user"){const{provisional:g,local:y,...v}=m;m=v}return m});let o;for(let O=0;O<a.length;O++){const d=a[O];d.kind==="user"&&d.provisional===!0||d.journalGeneration===n&&T0(d.journalSeq)?o=d.id:!d.sourceAdmissionAnchor&&o&&(a[O]={...d,sourceAdmissionAnchor:o},i=!0)}const s=new Map(a.map(O=>[O.id,O])),l=O=>O!==void 0&&O.journalGeneration===n&&T0(O.journalSeq)?O.journalSeq:void 0,c=(O,d)=>{const f=l(O);if(O.kind==="user"&&O.provisional===!0&&f===void 0)return[1,0,0,0,d];const p=O.kind==="supplement"?O.anchor:O.kind==="tool"?e.journalCallOwners?.get(O.toolCallId)??e.argsByCall.get(O.toolCallId)?.anchorId:void 0,m=typeof p=="string"?l(s.get(p)):void 0,g=O.sourceAdmissionAnchor?l(s.get(O.sourceAdmissionAnchor)):void 0,y=m??f??g;return y===void 0?[1,0,0,0,d]:[0,y,m!==void 0?1:f!==void 0?0:2,f??Number.MAX_SAFE_INTEGER,d]},u=a.map((O,d)=>({record:O,index:d,rank:c(O,d)}));return u.sort((O,d)=>{for(let f=0;f<O.rank.length;f++){const p=O.rank[f]-d.rank[f];if(p)return p}return 0}),!i&&u.every((O,d)=>O.index===d)?t:u.map(O=>O.record)}function vl(e){const t=e.records.filter(i=>i.kind==="user"&&i.provisional===!0),n=e.records.filter(i=>i.journalGeneration!==e.journalGeneration||!T0(i.journalSeq)),r=[...t,...n].map(i=>i.sourceEntryId??(i.kind==="tool"||i.kind==="supplement"?null:i.id));return e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),[...new Set(r.filter(i=>typeof i=="string"&&i.length>0&&i.length<=128))]}const Zo=e=>e.orderRevision??0;async function gEe(e){const t=new Set;let n=e.getTranscript().journalGeneration,r=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const i=e.getTranscript(),a=d3(i),o=a.revision,s=GXe(vl(i).filter(O=>!t.has(O)),e.lookupPath,new URLSearchParams({journal_order:"1"})),l=await e.read(s);if(!e.isCurrent()||Zo(e.getTranscript())!==o)return{kind:"stale"};if(e.commit(l,o,a),!e.isCurrent())return{kind:"stale"};const c=e.getTranscript(),u=e.page(l);if(u.journal_order_state==="ready"&&u.journal_generation===c.journalGeneration){u.journal_generation!==n&&(t.clear(),n=u.journal_generation);for(const O of s)t.add(O);if(c.orderNeedsReconcile){if(c.orderDemand===a.demand||r===1)return{kind:"waiting"};r++,t.clear();continue}if(vl(c).some(O=>!t.has(O)))continue;return{kind:"complete",transcript:c}}if(!c.orderNeedsReconcile||c.orderDemand===a.demand||r===1)return{kind:"waiting"};r++,t.clear()}}function Ws(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const i=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof i=="string"&&i?i:e.id}function s_(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function PG(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function mln(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const a of t){if(!a.settled||typeof a.run_key!="string"||a.run_key.length===0)continue;const o=s_(a.action_count);if(o===null)continue;const s={actions:o,workedSeconds:PG(a.worked_seconds),failed:s_(a.failed_count)??0,complete:a.complete!==!1,openingUserId:typeof a.opening_user_id=="string"&&a.opening_user_id.length>0?a.opening_user_id:null,closingAnswerId:typeof a.closing_answer_id=="string"&&a.closing_answer_id.length>0?a.closing_answer_id:null,crossSessionActions:s_(a.cross_session_action_count),crossSessionWorkedSeconds:PG(a.cross_session_worked_seconds)};n.set(a.run_key,s),s.openingUserId!==null&&n.set(s.openingUserId,s),s.closingAnswerId!==null&&n.set(s.closingAnswerId,s)}if(n.size===0)return null;const r=new Set;for(const a of e.entries)r.add(Ws(a));const i=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:i?Ws(i):null}}}function $Ee(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(a=>a.opening_user_id===n.id))return null;const i=Math.round((n.ts??0)*1e3);return i>0?{id:n.id,tsMs:i}:null}function yEe(e,t,n){const r=$Ee(e),i=e?.entries;if(r===null||!i||i.length===0)return!1;const a=Math.round((i[i.length-1].ts??0)*1e3);if(!(a>r.tsMs))return!1;for(const[o,s]of t)if(!n.has(o)&&(s===null||!(s>r.tsMs)||!(s<a)))return!1;return!0}const vEe=new Map([["This changes your instructions. Apply it from now on, and drop work it makes pointless.","steer"],["Answer it now with the `hub` tool — a short, direct reply — then carry on with what you were doing. Do not restructure your work around the question.","ask"],["This is a note, not a question. No reply is needed unless it changes what you should do.","note"]]),bEe=/\blabel=(['"])(.*?)\1/,wEe=/\bjob=(['"])(.*?)\1/,SEe=/^<(parent-message|subagent-message)\b[^>]*>\n([\s\S]*)\n<\/\1>$/;function f3(e){const t=typeof e.text=="string"?e.text:"",n=SEe.exec(t);let r=n?.[2];const i=r?.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-Cy_LQBkK.js","./ui-preferences-store-Djl9-Xtm.js","./index-CNJ5TTOd.js","./index-D2RbXUt0.css","./error-boundary-B6HHd2sY.js","./index-CMv0JWYs.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-C85gayGw.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
+ import{c as Fi,p as nl,ah as Gse,u as ar,ai as Z2e,aj as D2e,ak as V2e,al as ZN,am as M2e,a0 as L2e,a8 as F2e,an as B2e,ac as H2e,ao as K2e,ap as J2e,a2 as DN,a3 as eRe,aq as Yse,ar as tRe,ae as PA,as as nRe,D as rRe,d as VN,r as iRe}from"./ui-preferences-store-Djl9-Xtm.js";import{r as $,b as B,j as h,f as aRe,c as j,g as or,w as Ise,x as cb,e as Qn,t as t3}from"./index-CNJ5TTOd.js";import{a6 as oRe,c as Ze,B as Ae,ak as _A,al as TA,am as RA,an as sRe,ao as XA,ap as lRe,f as Ut,q as cS,r as Zse,T as rf,j as Yd,C as bu,X as Li,a7 as cRe,aC as uRe,aD as ORe,aE as dRe,A as Yl,S as hs,k as Dse,D as EA,l as jA,m as qA,p as Tl,g as k0,h as P0,aB as CA,i as bp,aH as fRe,U as hRe,V as pRe,W as mRe,aj as gRe,R as JQ,y as $Re,N as yRe,O as vRe,P as bRe,I as La,s as Vse,t as Mse,u as Lse,v as Fse,w as n3,x as wRe,ai as r3,L as Bse,aI as SRe,Y as xRe,e as go,z as QRe,F as kRe,G as MN,H as LN,J as PRe,K as FN,aq as _Re,aJ as TRe,a as RRe,n as J5,o as BN,E as HN}from"./error-boundary-B6HHd2sY.js";var _n;(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})(_n||(_n={}));var i3;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(i3||(i3={}));const rt=_n.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ac=e=>{switch(typeof e){case"undefined":return rt.undefined;case"string":return rt.string;case"number":return isNaN(e)?rt.nan:rt.number;case"boolean":return rt.boolean;case"function":return rt.function;case"bigint":return rt.bigint;case"symbol":return rt.symbol;case"object":return Array.isArray(e)?rt.array:e===null?rt.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?rt.promise:typeof Map<"u"&&e instanceof Map?rt.map:typeof Set<"u"&&e instanceof Set?rt.set:typeof Date<"u"&&e instanceof Date?rt.date:rt.object;default:return rt.unknown}},Ue=_n.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"]),XRe=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Va 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 Va))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_n.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()}}Va.create=e=>new Va(e);const wp=(e,t)=>{let n;switch(e.code){case Ue.invalid_type:e.received===rt.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Ue.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,_n.jsonStringifyReplacer)}`;break;case Ue.unrecognized_keys:n=`Unrecognized key(s) in object: ${_n.joinValues(e.keys,", ")}`;break;case Ue.invalid_union:n="Invalid input";break;case Ue.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${_n.joinValues(e.options)}`;break;case Ue.invalid_enum_value:n=`Invalid enum value. Expected ${_n.joinValues(e.options)}, received '${e.received}'`;break;case Ue.invalid_arguments:n="Invalid function arguments";break;case Ue.invalid_return_type:n="Invalid function return type";break;case Ue.invalid_date:n="Invalid date";break;case Ue.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}"`:_n.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Ue.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 Ue.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 Ue.custom:n="Invalid input";break;case Ue.invalid_intersection_types:n="Intersection results could not be merged";break;case Ue.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Ue.not_finite:n="Number must be finite";break;default:n=t.defaultError,_n.assertNever(e)}return{message:n}};let Hse=wp;function ERe(e){Hse=e}function uS(){return Hse}const OS=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}},jRe=[];function Je(e,t){const n=uS(),r=OS({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===wp?void 0:wp].filter(i=>!!i)});e.common.issues.push(r)}class Oa{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 At;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 Oa.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 At;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 At=Object.freeze({status:"aborted"}),Nh=e=>({status:"dirty",value:e}),Xa=e=>({status:"valid",value:e}),a3=e=>e.status==="aborted",o3=e=>e.status==="dirty",af=e=>e.status==="valid",d$=e=>typeof Promise<"u"&&e instanceof Promise;function dS(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 Kse(e,t,n,r,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}var mt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(mt||(mt={}));var i0,a0;class Fl{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 KN=(e,t)=>{if(af(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 Va(e.common.issues);return this._error=n,this._error}}};function Kt(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 sn{get description(){return this._def.description}_getType(t){return Ac(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Ac(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Oa,ctx:{common:t.parent.common,data:t.data,parsedType:Ac(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(d$(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:Ac(t)},a=this._parseSync({data:t,path:i.path,parent:i});return KN(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:Ac(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:i});return af(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=>af(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:Ac(t)},i=this._parse({data:t,path:r.path,parent:r}),a=await(d$(i)?i:Promise.resolve(i));return KN(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:Ue.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 Hs({schema:this,typeName:qt.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 Il.create(this,this._def)}nullable(){return QO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ms.create(this)}promise(){return xp.create(this,this._def)}or(t){return m$.create([this,t],this._def)}and(t){return g$.create(this,t,this._def)}transform(t){return new Hs({...Kt(this._def),schema:this,typeName:qt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new w$({...Kt(this._def),innerType:this,defaultValue:n,typeName:qt.ZodDefault})}brand(){return new AA({typeName:qt.ZodBranded,type:this,...Kt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new S$({...Kt(this._def),innerType:this,catchValue:n,typeName:qt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return uv.create(this,t)}readonly(){return x$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const qRe=/^c[^\s-]{8,}$/i,CRe=/^[0-9a-z]+$/,ARe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zRe=/^[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,URe=/^[a-z0-9_-]{21}$/i,WRe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,NRe=/^[-+]?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)?)??$/,GRe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,YRe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let e_;const IRe=/^(?:(?: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])$/,ZRe=/^(?:(?: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])$/,DRe=/^(([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]))$/,VRe=/^(([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])$/,MRe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,LRe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Jse="((\\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])))",FRe=new RegExp(`^${Jse}$`);function ele(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 BRe(e){return new RegExp(`^${ele(e)}$`)}function tle(e){let t=`${Jse}T${ele(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 HRe(e,t){return!!((t==="v4"||!t)&&IRe.test(e)||(t==="v6"||!t)&&DRe.test(e))}function KRe(e,t){if(!WRe.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 JRe(e,t){return!!((t==="v4"||!t)&&ZRe.test(e)||(t==="v6"||!t)&&VRe.test(e))}class Ds extends sn{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==rt.string){const a=this._getOrReturnCtx(t);return Je(a,{code:Ue.invalid_type,expected:rt.string,received:a.parsedType}),At}const r=new Oa;let i;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.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),Je(i,{code:Ue.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?Je(i,{code:Ue.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Je(i,{code:Ue.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")GRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"email",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")e_||(e_=new RegExp(YRe,"u")),e_.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"emoji",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")zRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"uuid",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")URe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"nanoid",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")qRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"cuid",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")CRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"cuid2",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")ARe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"ulid",code:Ue.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Je(i,{validation:"url",code:Ue.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),Je(i,{validation:"regex",code:Ue.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),Je(i,{code:Ue.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),Je(i,{code:Ue.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?tle(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?FRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?BRe(a).test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?NRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"duration",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?HRe(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"ip",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?KRe(t.data,a.alg)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"jwt",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?JRe(t.data,a.version)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"cidr",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?MRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"base64",code:Ue.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?LRe.test(t.data)||(i=this._getOrReturnCtx(t,i),Je(i,{validation:"base64url",code:Ue.invalid_string,message:a.message}),r.dirty()):_n.assertNever(a);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Ue.invalid_string,...mt.errToObj(r)})}_addCheck(t){return new Ds({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...mt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...mt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...mt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...mt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...mt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...mt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...mt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...mt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...mt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...mt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...mt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...mt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...mt.errToObj(t)})}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(n=t?.offset)!==null&&n!==void 0?n:!1,local:(r=t?.local)!==null&&r!==void 0?r:!1,...mt.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...mt.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...mt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...mt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...mt.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...mt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...mt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...mt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...mt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...mt.errToObj(n)})}nonempty(t){return this.min(1,mt.errToObj(t))}trim(){return new Ds({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ds({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ds({...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}}Ds.create=e=>{var t;return new Ds({checks:[],typeName:qt.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Kt(e)})};function eXe(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 wO extends sn{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)!==rt.number){const a=this._getOrReturnCtx(t);return Je(a,{code:Ue.invalid_type,expected:rt.number,received:a.parsedType}),At}let r;const i=new Oa;for(const a of this._def.checks)a.kind==="int"?_n.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),Je(r,{code:Ue.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),Je(r,{code:Ue.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),Je(r,{code:Ue.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?eXe(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),Je(r,{code:Ue.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),Je(r,{code:Ue.not_finite,message:a.message}),i.dirty()):_n.assertNever(a);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,mt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,mt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,mt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,mt.toString(n))}setLimit(t,n,r,i){return new wO({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mt.toString(i)}]})}_addCheck(t){return new wO({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:mt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:mt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:mt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:mt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:mt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:mt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:mt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:mt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:mt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&_n.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)}}wO.create=e=>new wO({checks:[],typeName:qt.ZodNumber,coerce:e?.coerce||!1,...Kt(e)});class SO extends sn{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)!==rt.bigint)return this._getInvalidInput(t);let r;const i=new Oa;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),Je(r,{code:Ue.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),Je(r,{code:Ue.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),Je(r,{code:Ue.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):_n.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Je(n,{code:Ue.invalid_type,expected:rt.bigint,received:n.parsedType}),At}gte(t,n){return this.setLimit("min",t,!0,mt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,mt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,mt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,mt.toString(n))}setLimit(t,n,r,i){return new SO({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:mt.toString(i)}]})}_addCheck(t){return new SO({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:mt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:mt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:mt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:mt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:mt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}SO.create=e=>{var t;return new SO({checks:[],typeName:qt.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Kt(e)})};class f$ extends sn{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==rt.boolean){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.boolean,received:r.parsedType}),At}return Xa(t.data)}}f$.create=e=>new f$({typeName:qt.ZodBoolean,coerce:e?.coerce||!1,...Kt(e)});class of extends sn{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==rt.date){const a=this._getOrReturnCtx(t);return Je(a,{code:Ue.invalid_type,expected:rt.date,received:a.parsedType}),At}if(isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return Je(a,{code:Ue.invalid_date}),At}const r=new Oa;let i;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),Je(i,{code:Ue.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),Je(i,{code:Ue.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):_n.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new of({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:mt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:mt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}of.create=e=>new of({checks:[],coerce:e?.coerce||!1,typeName:qt.ZodDate,...Kt(e)});class fS extends sn{_parse(t){if(this._getType(t)!==rt.symbol){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.symbol,received:r.parsedType}),At}return Xa(t.data)}}fS.create=e=>new fS({typeName:qt.ZodSymbol,...Kt(e)});class h$ extends sn{_parse(t){if(this._getType(t)!==rt.undefined){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.undefined,received:r.parsedType}),At}return Xa(t.data)}}h$.create=e=>new h$({typeName:qt.ZodUndefined,...Kt(e)});class p$ extends sn{_parse(t){if(this._getType(t)!==rt.null){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.null,received:r.parsedType}),At}return Xa(t.data)}}p$.create=e=>new p$({typeName:qt.ZodNull,...Kt(e)});class Sp extends sn{constructor(){super(...arguments),this._any=!0}_parse(t){return Xa(t.data)}}Sp.create=e=>new Sp({typeName:qt.ZodAny,...Kt(e)});class Id extends sn{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Xa(t.data)}}Id.create=e=>new Id({typeName:qt.ZodUnknown,...Kt(e)});class iu extends sn{_parse(t){const n=this._getOrReturnCtx(t);return Je(n,{code:Ue.invalid_type,expected:rt.never,received:n.parsedType}),At}}iu.create=e=>new iu({typeName:qt.ZodNever,...Kt(e)});class hS extends sn{_parse(t){if(this._getType(t)!==rt.undefined){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.void,received:r.parsedType}),At}return Xa(t.data)}}hS.create=e=>new hS({typeName:qt.ZodVoid,...Kt(e)});class Ms extends sn{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==rt.array)return Je(n,{code:Ue.invalid_type,expected:rt.array,received:n.parsedType}),At;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(o||s)&&(Je(n,{code:o?Ue.too_big:Ue.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&&(Je(n,{code:Ue.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&&(Je(n,{code:Ue.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 Fl(n,o,n.path,s)))).then(o=>Oa.mergeArray(r,o));const a=[...n.data].map((o,s)=>i.type._parseSync(new Fl(n,o,n.path,s)));return Oa.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new Ms({...this._def,minLength:{value:t,message:mt.toString(n)}})}max(t,n){return new Ms({...this._def,maxLength:{value:t,message:mt.toString(n)}})}length(t,n){return new Ms({...this._def,exactLength:{value:t,message:mt.toString(n)}})}nonempty(t){return this.min(1,t)}}Ms.create=(e,t)=>new Ms({type:e,minLength:null,maxLength:null,exactLength:null,typeName:qt.ZodArray,...Kt(t)});function Eh(e){if(e instanceof Ur){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Il.create(Eh(r))}return new Ur({...e._def,shape:()=>t})}else return e instanceof Ms?new Ms({...e._def,type:Eh(e.element)}):e instanceof Il?Il.create(Eh(e.unwrap())):e instanceof QO?QO.create(Eh(e.unwrap())):e instanceof Bl?Bl.create(e.items.map(t=>Eh(t))):e}class Ur extends sn{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=_n.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==rt.object){const c=this._getOrReturnCtx(t);return Je(c,{code:Ue.invalid_type,expected:rt.object,received:c.parsedType}),At}const{status:r,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof iu&&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 Fl(i,O,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof iu){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&&(Je(i,{code:Ue.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 Fl(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=>Oa.mergeObjectSync(r,c)):Oa.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return mt.errToObj,new Ur({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,a,o,s;const l=(o=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(s=mt.errToObj(t).message)!==null&&s!==void 0?s:l}:{message:l}}}:{}})}strip(){return new Ur({...this._def,unknownKeys:"strip"})}passthrough(){return new Ur({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ur({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ur({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:qt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Ur({...this._def,catchall:t})}pick(t){const n={};return _n.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new Ur({...this._def,shape:()=>n})}omit(t){const n={};return _n.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new Ur({...this._def,shape:()=>n})}deepPartial(){return Eh(this)}partial(t){const n={};return _n.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}),new Ur({...this._def,shape:()=>n})}required(t){const n={};return _n.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Il;)a=a._def.innerType;n[r]=a}}),new Ur({...this._def,shape:()=>n})}keyof(){return nle(_n.objectKeys(this.shape))}}Ur.create=(e,t)=>new Ur({shape:()=>e,unknownKeys:"strip",catchall:iu.create(),typeName:qt.ZodObject,...Kt(t)});Ur.strictCreate=(e,t)=>new Ur({shape:()=>e,unknownKeys:"strict",catchall:iu.create(),typeName:qt.ZodObject,...Kt(t)});Ur.lazycreate=(e,t)=>new Ur({shape:e,unknownKeys:"strip",catchall:iu.create(),typeName:qt.ZodObject,...Kt(t)});class m$ extends sn{_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 Va(s.ctx.common.issues));return Je(n,{code:Ue.invalid_union,unionErrors:o}),At}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 Va(l));return Je(n,{code:Ue.invalid_union,unionErrors:s}),At}}get options(){return this._def.options}}m$.create=(e,t)=>new m$({options:e,typeName:qt.ZodUnion,...Kt(t)});const wc=e=>e instanceof y$?wc(e.schema):e instanceof Hs?wc(e.innerType()):e instanceof v$?[e.value]:e instanceof xO?e.options:e instanceof b$?_n.objectValues(e.enum):e instanceof w$?wc(e._def.innerType):e instanceof h$?[void 0]:e instanceof p$?[null]:e instanceof Il?[void 0,...wc(e.unwrap())]:e instanceof QO?[null,...wc(e.unwrap())]:e instanceof AA||e instanceof x$?wc(e.unwrap()):e instanceof S$?wc(e._def.innerType):[];class ek extends sn{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==rt.object)return Je(n,{code:Ue.invalid_type,expected:rt.object,received:n.parsedType}),At;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}):(Je(n,{code:Ue.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),At)}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=wc(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 ek({typeName:qt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Kt(r)})}}function s3(e,t){const n=Ac(e),r=Ac(t);if(e===t)return{valid:!0,data:e};if(n===rt.object&&r===rt.object){const i=_n.objectKeys(t),a=_n.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(const s of a){const l=s3(e[s],t[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(n===rt.array&&r===rt.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=s3(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===rt.date&&r===rt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class g$ extends sn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(a,o)=>{if(a3(a)||a3(o))return At;const s=s3(a.value,o.value);return s.valid?((o3(a)||o3(o))&&n.dirty(),{status:n.value,value:s.data}):(Je(r,{code:Ue.invalid_intersection_types}),At)};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}))}}g$.create=(e,t,n)=>new g$({left:e,right:t,typeName:qt.ZodIntersection,...Kt(n)});class Bl extends sn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==rt.array)return Je(r,{code:Ue.invalid_type,expected:rt.array,received:r.parsedType}),At;if(r.data.length<this._def.items.length)return Je(r,{code:Ue.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),At;!this._def.rest&&r.data.length>this._def.items.length&&(Je(r,{code:Ue.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 Fl(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>Oa.mergeArray(n,o)):Oa.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Bl({...this._def,rest:t})}}Bl.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Bl({items:e,typeName:qt.ZodTuple,rest:null,...Kt(t)})};class $$ extends sn{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!==rt.object)return Je(r,{code:Ue.invalid_type,expected:rt.object,received:r.parsedType}),At;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in r.data)i.push({key:a._parse(new Fl(r,s,r.path,s)),value:o._parse(new Fl(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?Oa.mergeObjectAsync(n,i):Oa.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof sn?new $$({keyType:t,valueType:n,typeName:qt.ZodRecord,...Kt(r)}):new $$({keyType:Ds.create(),valueType:t,typeName:qt.ZodRecord,...Kt(n)})}}class pS extends sn{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!==rt.map)return Je(r,{code:Ue.invalid_type,expected:rt.map,received:r.parsedType}),At;const i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,l],c)=>({key:i._parse(new Fl(r,s,r.path,[c,"key"])),value:a._parse(new Fl(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 At;(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 At;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}}}}pS.create=(e,t,n)=>new pS({valueType:t,keyType:e,typeName:qt.ZodMap,...Kt(n)});class sf extends sn{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==rt.set)return Je(r,{code:Ue.invalid_type,expected:rt.set,received:r.parsedType}),At;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Je(r,{code:Ue.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&&(Je(r,{code:Ue.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 At;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 Fl(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(t,n){return new sf({...this._def,minSize:{value:t,message:mt.toString(n)}})}max(t,n){return new sf({...this._def,maxSize:{value:t,message:mt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}sf.create=(e,t)=>new sf({valueType:e,minSize:null,maxSize:null,typeName:qt.ZodSet,...Kt(t)});class tp extends sn{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==rt.function)return Je(n,{code:Ue.invalid_type,expected:rt.function,received:n.parsedType}),At;function r(s,l){return OS({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,uS(),wp].filter(c=>!!c),issueData:{code:Ue.invalid_arguments,argumentsError:l}})}function i(s,l){return OS({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,uS(),wp].filter(c=>!!c),issueData:{code:Ue.invalid_return_type,returnTypeError:l}})}const a={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof xp){const s=this;return Xa(async function(...l){const c=new Va([]),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 Xa(function(...l){const c=s._def.args.safeParse(l,a);if(!c.success)throw new Va([r(l,c.error)]);const u=Reflect.apply(o,this,c.data),O=s._def.returns.safeParse(u,a);if(!O.success)throw new Va([i(u,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new tp({...this._def,args:Bl.create(t).rest(Id.create())})}returns(t){return new tp({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new tp({args:t||Bl.create([]).rest(Id.create()),returns:n||Id.create(),typeName:qt.ZodFunction,...Kt(r)})}}class y$ extends sn{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})}}y$.create=(e,t)=>new y$({getter:e,typeName:qt.ZodLazy,...Kt(t)});class v$ extends sn{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Je(n,{received:n.data,code:Ue.invalid_literal,expected:this._def.value}),At}return{status:"valid",value:t.data}}get value(){return this._def.value}}v$.create=(e,t)=>new v$({value:e,typeName:qt.ZodLiteral,...Kt(t)});function nle(e,t){return new xO({values:e,typeName:qt.ZodEnum,...Kt(t)})}class xO extends sn{constructor(){super(...arguments),i0.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Je(n,{expected:_n.joinValues(r),received:n.parsedType,code:Ue.invalid_type}),At}if(dS(this,i0)||Kse(this,i0,new Set(this._def.values)),!dS(this,i0).has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return Je(n,{received:n.data,code:Ue.invalid_enum_value,options:r}),At}return Xa(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 xO.create(t,{...this._def,...n})}exclude(t,n=this._def){return xO.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}i0=new WeakMap;xO.create=nle;class b$ extends sn{constructor(){super(...arguments),a0.set(this,void 0)}_parse(t){const n=_n.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==rt.string&&r.parsedType!==rt.number){const i=_n.objectValues(n);return Je(r,{expected:_n.joinValues(i),received:r.parsedType,code:Ue.invalid_type}),At}if(dS(this,a0)||Kse(this,a0,new Set(_n.getValidEnumValues(this._def.values))),!dS(this,a0).has(t.data)){const i=_n.objectValues(n);return Je(r,{received:r.data,code:Ue.invalid_enum_value,options:i}),At}return Xa(t.data)}get enum(){return this._def.values}}a0=new WeakMap;b$.create=(e,t)=>new b$({values:e,typeName:qt.ZodNativeEnum,...Kt(t)});class xp extends sn{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==rt.promise&&n.common.async===!1)return Je(n,{code:Ue.invalid_type,expected:rt.promise,received:n.parsedType}),At;const r=n.parsedType===rt.promise?n.data:Promise.resolve(n.data);return Xa(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}xp.create=(e,t)=>new xp({type:e,typeName:qt.ZodPromise,...Kt(t)});class Hs extends sn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===qt.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=>{Je(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 At;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?At:l.status==="dirty"||n.value==="dirty"?Nh(l.value):l});{if(n.value==="aborted")return At;const s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?At:s.status==="dirty"||n.value==="dirty"?Nh(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"?At:(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"?At:(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(!af(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=>af(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):o);_n.assertNever(i)}}Hs.create=(e,t,n)=>new Hs({schema:e,typeName:qt.ZodEffects,effect:t,...Kt(n)});Hs.createWithPreprocess=(e,t,n)=>new Hs({schema:t,effect:{type:"preprocess",transform:e},typeName:qt.ZodEffects,...Kt(n)});class Il extends sn{_parse(t){return this._getType(t)===rt.undefined?Xa(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Il.create=(e,t)=>new Il({innerType:e,typeName:qt.ZodOptional,...Kt(t)});class QO extends sn{_parse(t){return this._getType(t)===rt.null?Xa(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}QO.create=(e,t)=>new QO({innerType:e,typeName:qt.ZodNullable,...Kt(t)});class w$ extends sn{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===rt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}w$.create=(e,t)=>new w$({innerType:e,typeName:qt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Kt(t)});class S$ extends sn{_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 d$(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Va(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Va(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}S$.create=(e,t)=>new S$({innerType:e,typeName:qt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Kt(t)});class mS extends sn{_parse(t){if(this._getType(t)!==rt.nan){const r=this._getOrReturnCtx(t);return Je(r,{code:Ue.invalid_type,expected:rt.nan,received:r.parsedType}),At}return{status:"valid",value:t.data}}}mS.create=e=>new mS({typeName:qt.ZodNaN,...Kt(e)});const tXe=Symbol("zod_brand");class AA extends sn{_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 uv extends sn{_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"?At:a.status==="dirty"?(n.dirty(),Nh(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"?At: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 uv({in:t,out:n,typeName:qt.ZodPipeline})}}class x$ extends sn{_parse(t){const n=this._def.innerType._parse(t),r=i=>(af(i)&&(i.value=Object.freeze(i.value)),i);return d$(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}x$.create=(e,t)=>new x$({innerType:e,typeName:qt.ZodReadonly,...Kt(t)});function JN(e,t){const n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function rle(e,t={},n){return e?Sp.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=JN(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=JN(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})}}):Sp.create()}const nXe={object:Ur.lazycreate};var qt;(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"})(qt||(qt={}));const rXe=(e,t={message:`Input not instance of ${e.name}`})=>rle(n=>n instanceof e,t),ile=Ds.create,ale=wO.create,iXe=mS.create,aXe=SO.create,ole=f$.create,oXe=of.create,sXe=fS.create,lXe=h$.create,cXe=p$.create,uXe=Sp.create,OXe=Id.create,dXe=iu.create,fXe=hS.create,hXe=Ms.create,pXe=Ur.create,mXe=Ur.strictCreate,gXe=m$.create,$Xe=ek.create,yXe=g$.create,vXe=Bl.create,bXe=$$.create,wXe=pS.create,SXe=sf.create,xXe=tp.create,QXe=y$.create,kXe=v$.create,PXe=xO.create,_Xe=b$.create,TXe=xp.create,eG=Hs.create,RXe=Il.create,XXe=QO.create,EXe=Hs.createWithPreprocess,jXe=uv.create,qXe=()=>ile().optional(),CXe=()=>ale().optional(),AXe=()=>ole().optional(),zXe={string:e=>Ds.create({...e,coerce:!0}),number:e=>wO.create({...e,coerce:!0}),boolean:e=>f$.create({...e,coerce:!0}),bigint:e=>SO.create({...e,coerce:!0}),date:e=>of.create({...e,coerce:!0})},UXe=At;var X=Object.freeze({__proto__:null,defaultErrorMap:wp,setErrorMap:ERe,getErrorMap:uS,makeIssue:OS,EMPTY_PATH:jRe,addIssueToContext:Je,ParseStatus:Oa,INVALID:At,DIRTY:Nh,OK:Xa,isAborted:a3,isDirty:o3,isValid:af,isAsync:d$,get util(){return _n},get objectUtil(){return i3},ZodParsedType:rt,getParsedType:Ac,ZodType:sn,datetimeRegex:tle,ZodString:Ds,ZodNumber:wO,ZodBigInt:SO,ZodBoolean:f$,ZodDate:of,ZodSymbol:fS,ZodUndefined:h$,ZodNull:p$,ZodAny:Sp,ZodUnknown:Id,ZodNever:iu,ZodVoid:hS,ZodArray:Ms,ZodObject:Ur,ZodUnion:m$,ZodDiscriminatedUnion:ek,ZodIntersection:g$,ZodTuple:Bl,ZodRecord:$$,ZodMap:pS,ZodSet:sf,ZodFunction:tp,ZodLazy:y$,ZodLiteral:v$,ZodEnum:xO,ZodNativeEnum:b$,ZodPromise:xp,ZodEffects:Hs,ZodTransformer:Hs,ZodOptional:Il,ZodNullable:QO,ZodDefault:w$,ZodCatch:S$,ZodNaN:mS,BRAND:tXe,ZodBranded:AA,ZodPipeline:uv,ZodReadonly:x$,custom:rle,Schema:sn,ZodSchema:sn,late:nXe,get ZodFirstPartyTypeKind(){return qt},coerce:zXe,any:uXe,array:hXe,bigint:aXe,boolean:ole,date:oXe,discriminatedUnion:$Xe,effect:eG,enum:PXe,function:xXe,instanceof:rXe,intersection:yXe,lazy:QXe,literal:kXe,map:wXe,nan:iXe,nativeEnum:_Xe,never:dXe,null:cXe,nullable:XXe,number:ale,object:pXe,oboolean:AXe,onumber:CXe,optional:RXe,ostring:qXe,pipeline:jXe,preprocess:EXe,promise:TXe,record:bXe,set:SXe,strictObject:mXe,string:ile,symbol:sXe,transformer:eG,tuple:vXe,undefined:lXe,union:gXe,unknown:OXe,void:fXe,NEVER:UXe,ZodIssueCode:Ue,quotelessJson:XRe,ZodError:Va});const WXe=6*1024,NXe=512;function gS(e,t,n){let r=new TextEncoder().encode(`${t}${e.size?`?${e}`:""}`).length;const i=[];for(const a of n){if(i.length===NXe)break;const s=new URLSearchParams({order_ids:a}).toString().length+1;if(r+s>WXe)break;e.append("order_ids",a),i.push(a),r+=s}return i}function GXe(e,t,n){return gS(new URLSearchParams(n),t,e)}const zt=X.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),ub=X.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),Ob=X.string().min(1).max(32768),zA=/^[a-f0-9]{12}$/,wt=X.string().regex(zA),t_=X.string().regex(/^[a-f0-9]{12}$/),n_=X.string().min(1).max(128),YXe=X.string().min(1).max(4096),r_=X.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/),db=X.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/),tG=X.string().regex(/^[a-f0-9]{32}$/),sle=/^(\/|[A-Za-z]:[\\/])/,i_=X.string().min(1).max(4096).regex(sle),nG=/^[a-f0-9]{32}$/,dr=X.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),sh=X.string().regex(/^[A-Za-z0-9_-]{1,128}$/),rG=X.string().regex(/^ap_[0-9a-hjkmnp-tv-z]{1,64}$/),iG=X.object({data_b64:X.string().min(1).max(1e6),mime_type:X.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),kO=2e5,Q$=8,IXe=256,ZXe=100,l3=16,UA=256,lle=100,cle=200,c3=1e6,Vo=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)),fb=X.object({kind:X.enum(["agent","team"]),name:Vo}).strict(),a_=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(),aG=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(),oG=X.object({name:X.string().min(1).max(64).optional(),description:X.string().max(8e3).optional(),manager:Vo.optional(),members:X.array(X.object({role:Vo,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(),DXe=X.record(X.array(X.string().max(1024)).max(100)),sG=X.enum(["minutes","hours","days"]);function VXe(e){return!/^\.+$/.test(e)}const Oln=e=>f1.safeParse(e).success,f1=X.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(VXe),lG=X.enum(["str","int","float","bool","list","dict"]),cG=X.string().max(16384),MXe=2e3,uG=X.string().min(1).max(MXe),OG=X.string().min(1).max(64),LXe=X.string().min(1).max(64),FXe=X.string().min(1).max(64),dG=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(),BXe=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(),u3=128,fG=2e3,hG=8e3,pG=64,mG=64,tk=e=>[...e].length,O3=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,HXe=e=>e===9||e===10||e===11||e===12||e===13||e===133,KXe=e=>e<=31||e>=127&&e<=159,JXe=e=>new RegExp("\\p{Cf}","u").test(String.fromCodePoint(e)),e4e=e=>e>=8234&&e<=8238||e>=8294&&e<=8297,hb=(e,t)=>{for(const n of e)if(t(n.codePointAt(0)??0))return!0;return!1},ule=e=>{const t=[...e];let n=0,r=t.length;for(;n<r&&O3(t[n].codePointAt(0)??0);)n++;for(;r>n&&O3(t[r-1].codePointAt(0)??0);)r--;return t.slice(n,r).join("")},t4e=e=>{let t="",n=!1;for(const r of e){if(O3(r.codePointAt(0)??0)){n=t.length>0;continue}n&&(t+=" ",n=!1),t+=r}return t};function n4e(e){const t=ule(e);if(!t)return"must not be empty";if(tk(t)>u3)return`must be at most ${u3} characters`;if(/[/\\:]/.test(t))return'must not contain "/", "\\" or ":"';if(hb(t,e4e))return"must not contain Unicode bidirectional override characters";if(hb(t,HXe))return"must not contain whitespace";if(hb(t,KXe))return"must not contain control characters";if(hb(t,JXe))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 dln(e){return t4e(ule(e).normalize("NFKC").toLowerCase())}function r4e(e){return e.trim()?tk(e)>fG?`must be at most ${fG} characters`:null:"must not be empty"}function i4e(e){return e.trim()?tk(e)>hG?`must be at most ${hG} characters`:null:"must not be empty"}function a4e(e){if(e.length>mG)return`must hold at most ${mG} items`;for(const t of e)if(!t.trim()||tk(t)>pG)return`must hold items of 1 to ${pG} characters`;return null}const o4e=e=>n4e(e)===null,s4e=X.string().refine(o4e,{message:"That is not a name the hub can publish."}),l4e=X.string().refine(e=>i4e(e)===null,{message:"That instruction body cannot be published."}),c4e=X.string().refine(e=>r4e(e)===null,{message:"That description cannot be published."}),u4e=X.array(X.string()).refine(e=>a4e(e)===null,{message:"That tool list cannot be published."}),gG=X.object({name:s4e,description:c4e,instructions:l4e,kind:X.enum(["role","specialist"]),when_to_use:X.string(),tools:u4e,effort:X.string(),delegate:X.boolean(),version:X.string(),categories:X.array(X.string()),tags:X.array(X.string())}).partial().strict(),O4e=X.enum(["team","agent"]),d4e=X.string().min(1).max(64),f4e=X.string().min(1).max(256),Ole=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,o_=X.string().regex(Ole,{message:"Letters, digits, dot, underscore and dash; no spaces."}),h4e=["planning","active","qa","validation","done","paused","archived"],$G=X.enum(h4e),pb=X.string().regex(/^$|^\d{4}-\d{2}-\d{2}$/,"Dates are YYYY-MM-DD, or empty to clear."),yG=X.array(X.string().min(1).max(24)).max(8),Au=X.string().min(1).max(64),p4e=1e3,vG=240,bG=80,m4e=256,g4e=100,$4e=200,y4e=/^[a-z0-9][a-z0-9_-]{0,23}$/;function fln(e){return e?Ole.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 hln(e){return y4e.test(e)?null:"Tags are 1-24 characters of lowercase letters, digits, underscore or dash."}const mb=X.enum(["agent","team"]),v4e=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:Vo}).strict(),X.object({op:X.literal("profiles.install"),name:Vo,requestId:dr}).strict(),X.object({op:X.literal("profiles.create"),name:Vo,requestId:dr,fields:aG.extend({description:X.string().max(8e3),instructions:X.string().min(1).max(8e3)})}).strict(),X.object({op:X.literal("profiles.update"),name:Vo,requestId:dr,fields:aG}).strict(),X.object({op:X.literal("hub.updates")}).strict(),X.object({op:X.literal("hub.check"),requestId:dr,kind:mb.optional(),name:Vo.optional()}).strict(),X.object({op:X.literal("hub.apply"),requestId:dr,kind:mb,name:Vo,prefer:X.enum(["local","remote"]).optional(),acknowledgeUnknownBaseline:X.boolean().optional(),dryRun:X.boolean().optional()}).strict(),X.object({op:X.literal("hub.applyAll"),requestId:dr,kind:mb.optional()}).strict(),X.object({op:X.literal("hub.retry"),requestId:dr,kind:mb,name:Vo}).strict(),X.object({op:X.literal("teams.list")}).strict(),X.object({op:X.literal("teams.get"),name:Vo}).strict(),X.object({op:X.literal("teams.create"),requestId:dr,fields:oG.extend({name:X.string().min(1).max(64)})}).strict(),X.object({op:X.literal("teams.update"),name:Vo,requestId:dr,fields:oG}).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:O4e.optional(),scope_name:d4e.optional(),cursor:f4e.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(IXe),limit:X.number().int().min(1).max(500).optional(),include_archived:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.archive"),sessionId:wt,archived:X.boolean()}).strict(),X.object({op:X.literal("sessions.delete"),sessionId:wt,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.create"),requestId:dr,cwd:X.string().min(1).max(4096).optional(),target:fb.optional(),purpose:X.literal("agents-config").optional(),model:a_.optional(),draftId:wt.optional(),peer:sh.optional()}).strict(),X.object({op:X.literal("sessions.preview"),requestId:dr,cwd:X.string().min(1).max(4096),target:fb.optional(),model:a_.optional()}).strict(),X.object({op:X.literal("sessions.draft"),requestId:dr,cwd:X.string().min(1).max(4096),target:fb.optional(),model:a_.optional()}).strict(),X.object({op:X.literal("sessions.get"),sessionId:wt,journalOrder:X.boolean().optional(),orderIds:X.array(X.string().min(1).max(128)).max(512).optional()}).strict(),X.object({op:X.literal("sessions.history"),sessionId:wt,beforeId:zt.optional(),limit:X.number().int().min(1).max(500).optional(),openFrame:X.boolean().optional(),journalOrder:X.boolean().optional(),orderIds:X.array(X.string().min(1).max(128)).max(512).optional()}).strict(),X.object({op:X.literal("sessions.checkpoints"),sessionId:wt}).strict(),X.object({op:X.literal("sessions.checkpoints.warm"),sessionId:wt,ids:X.array(zt).max(l3).optional(),limit:X.number().int().min(1).max(l3).optional()}).strict(),X.object({op:X.literal("sessions.find"),sessionId:wt,q:X.string().min(1).max(UA),limit:X.number().int().min(1).max(cle).optional()}).strict(),X.object({op:X.literal("subagents.transcript"),sessionId:wt,childId:wt,beforeId:zt.optional(),limit:X.number().int().min(1).max(500).optional()}).strict(),X.object({op:X.literal("sessions.message"),sessionId:wt,requestId:dr,text:X.string().max(kO),images:X.array(iG).max(Q$).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:wt,requestId:dr,command:X.string().regex(/^\/?[A-Za-z]+$/).max(64),args:X.string().max(kO).optional(),images:X.array(iG).max(Q$).optional()}).strict(),X.object({op:X.literal("sessions.move"),sessionId:wt,requestId:dr,cwd:X.string().min(1).max(4096)}).strict(),X.object({op:X.literal("sessions.answer"),sessionId:wt,epoch:zt.optional(),requestId:zt.optional(),value:X.string().max(32768).optional(),approved:X.boolean().optional(),questionIndex:X.number().int().min(0).optional(),askId:zt.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:wt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("attention.seen"),items:X.array(X.object({sessionId:wt,completionToken:X.string().uuid()}).strict()).min(1).max(500)}).strict(),X.object({op:X.literal("sessions.notified"),sessionId:wt,completionToken:X.string().uuid()}).strict(),X.object({op:X.literal("sessions.pin"),sessionId:wt,pinned:X.boolean()}).strict(),X.object({op:X.literal("sessions.watch"),sessionId:wt,subscriptionId:X.string().regex(nG),visible:X.boolean(),canNotify:X.boolean()}).strict(),X.object({op:X.literal("sessions.warm"),sessionId:wt}).strict(),X.object({op:X.literal("sessions.interrupt"),sessionId:wt,requestId:dr}).strict(),X.object({op:X.literal("supplements.cancel"),sessionId:wt,job:t_,anchor:n_}).strict(),X.object({op:X.literal("supplements.restart"),sessionId:wt,job:t_,anchor:n_}).strict(),X.object({op:X.literal("supplements.steer"),sessionId:wt,job:t_,anchor:n_,text:X.string().min(1).max(500)}).strict(),X.object({op:X.literal("sessions.variables.list"),sessionId:wt}).strict(),X.object({op:X.literal("sessions.variables.create"),sessionId:wt,key:f1,value:cG,type:lG}).strict(),X.object({op:X.literal("sessions.variables.update"),sessionId:wt,key:f1,value:cG,type:lG}).strict(),X.object({op:X.literal("sessions.variables.delete"),sessionId:wt,key:f1}).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:zt}).strict(),X.object({op:X.literal("legacy.agent.upload"),agentId:zt}).strict(),X.object({op:X.literal("agent.publish"),agentId:zt,document:gG.optional(),visibility:X.literal("org").optional(),tenantId:zt.optional()}).strict(),X.object({op:X.literal("agent.republish"),agentId:zt,hubAgentId:zt,document:gG.optional(),visibility:X.literal("org").optional(),tenantId:zt.optional()}).strict(),X.object({op:X.literal("team.pull"),teamId:zt,tenantId:zt.optional()}).strict(),X.object({op:X.literal("agent.nameAvailability"),name:X.string().min(1).max(u3)}).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:zt}).strict(),X.object({op:X.literal("legacy.agent.history"),agentId:zt,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:zt.optional(),status:X.string().max(64).optional()}).strict(),X.object({op:X.literal("legacy.job.get"),jobId:zt}).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:zt,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:zt,schedule:dG.extend({prompt:X.string().max(64e3),interval:X.number().int().min(1),unit:sG})}).strict(),X.object({op:X.literal("legacy.schedule.get"),scheduleId:zt}).strict(),X.object({op:X.literal("legacy.schedule.edit"),scheduleId:zt,schedule:dG.extend({prompt:X.string().max(64e3).nullish(),interval:X.number().int().min(1).nullish(),unit:sG.nullish()})}).strict(),X.object({op:X.literal("legacy.schedule.remove"),scheduleId:zt}).strict(),X.object({op:X.literal("legacy.agent.create"),agent:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.update"),agentId:zt,update:X.record(X.unknown())}).strict(),X.object({op:X.literal("legacy.agent.delete"),agentId:zt}).strict(),X.object({op:X.literal("legacy.agent.conversation.clear"),agentId:zt}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.get"),agentId:zt}).strict(),X.object({op:X.literal("legacy.agent.systemPrompt.update"),agentId:zt,systemPrompt:X.string().max(c3)}).strict(),X.object({op:X.literal("legacy.agent.download"),agentId:zt}).strict(),X.object({op:X.literal("legacy.job.cancel"),jobId:zt}).strict(),X.object({op:X.literal("commands.list")}).strict(),X.object({op:X.literal("commands.entities"),sessionId:wt,command:zt,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:zt.optional(),live:X.boolean().optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("quota.notice"),provider:zt.optional(),model:X.string().min(1).max(200).optional(),refresh:X.boolean().optional()}).strict(),X.object({op:X.literal("analytics.get"),sessionId:wt.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:wt.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:wt,recentLimit:X.number().int().min(0).max(50).optional()}).strict(),X.object({op:X.literal("skills.list"),sessionId:wt.optional(),cwd:YXe.optional(),name:zt.optional()}).strict(),X.object({op:X.literal("sessions.failovers"),sessionId:wt}).strict(),X.object({op:X.literal("sessions.credential"),sessionId:wt,action:X.enum(["list","store","forget"]),key:ub.optional(),value:Ob.optional(),confirmed:X.boolean().optional()}).strict(),X.object({op:X.literal("sessions.fork"),sessionId:wt,requestId:dr,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:dr,targets:X.array(wt).min(1).max(100),confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside"),sessionId:wt,requestId:dr,text:X.string().min(1).max(32768),asideId:dr.optional(),subscriptionId:X.string().regex(nG).optional()}).strict(),X.object({op:X.literal("sessions.adopt"),sessionId:wt,requestId:dr,asideId:dr,confirmed:X.literal(!0)}).strict(),X.object({op:X.literal("sessions.aside.get"),sessionId:wt,asideId:dr}).strict(),X.object({op:X.literal("sessions.aside.close"),sessionId:wt,asideId:dr}).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:dr,sessionId:wt.optional(),cwd:X.string().min(1).max(4096).optional(),target:fb.optional(),message:uG,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:wt,wakeId:OG,message:uG.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:wt,wakeId:OG}).strict(),X.object({op:X.literal("monitors.cancel"),sessionId:wt,monitorId:LXe}).strict(),X.object({op:X.literal("jobs.cancel"),sessionId:wt,jobId:FXe}).strict(),X.object({op:X.literal("mcp.list"),sessionId:wt}).strict(),X.object({op:X.literal("mcp.credentials.store"),sessionId:wt,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:wt,control:X.object({action:X.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:r_.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(db).optional(),url:X.string().max(4096).optional(),headers:X.record(db).optional(),oauth:X.boolean().optional(),confirmed:X.boolean().optional(),operation_id:tG.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog"),cwd:i_.optional(),sessionId:wt.optional()}).strict(),X.object({op:X.literal("mcp.catalog.control"),cwd:i_.optional(),control:X.object({action:X.enum(["add","remove","test","login","reauth","logout","status","cancel"]),name:r_.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(db).optional(),url:X.string().max(4096).optional(),headers:X.record(db).optional(),confirmed:X.boolean().optional(),operation_id:tG.optional()}).strict()}).strict(),X.object({op:X.literal("mcp.catalog.credentials"),header:X.string().min(1).max(128).optional(),cwd:i_.optional(),name:r_,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:dr.optional(),tenant_id:zt.optional(),account_id:zt.optional(),agent_id:zt.optional(),comment_id:zt.optional(),team_id:zt.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:zt}).strict(),X.object({op:X.literal("auth.status"),id:zt}).strict(),X.object({op:X.literal("auth.input"),id:zt,promptId:zt,value:Ob}).strict(),X.object({op:X.literal("auth.cancel"),id:zt}).strict(),X.object({op:X.literal("auth.key"),provider:zt,value:Ob}).strict(),X.object({op:X.literal("auth.logout"),provider:zt}).strict(),X.object({op:X.literal("settings.list")}).strict(),X.object({op:X.literal("settings.edit"),key:ub,value:X.unknown().refine(e=>e!==void 0,"A setting value is required."),base:DXe.optional()}).strict(),X.object({op:X.literal("settings.reset"),key:ub}).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:BXe}).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:ub,value:Ob}).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:sh,role:X.enum(["read","drive","admin"]),deviceId:sh.optional()}).strict(),X.object({op:X.literal("networks.member.remove"),networkId:sh,deviceId:sh,confirm:X.string().min(1).max(256)}).strict(),X.object({op:X.literal("sessions.transfer"),sessionId:wt,to:X.union([X.literal("local"),sh]),keep:X.boolean().optional(),waitS:X.number().min(0).max(300).optional(),requestId:dr.optional()}).strict(),X.object({op:X.literal("approvals.list")}).strict(),X.object({op:X.literal("approvals.approve"),approvalId:rG}).strict(),X.object({op:X.literal("approvals.deny"),approvalId:rG}).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:Au}).strict(),X.object({op:X.literal("projects.create"),name:o_,description:X.string().max(vG).optional(),status:$G.optional(),tags:yG.optional()}).strict(),X.object({op:X.literal("projects.update"),key:Au,fields:X.object({name:o_.optional(),title:X.string().max(80).optional(),owner:X.string().max(80).optional(),team:X.string().max(80).optional(),description:X.string().max(vG).optional(),status:$G.optional(),progress:X.string().max(p4e).optional(),tags:yG.optional(),start_date:pb.optional(),target_date:pb.optional(),completed_at:pb.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:Au,confirmed_name:o_}).strict(),X.object({op:X.literal("projects.link"),key:Au,sessionId:wt}).strict(),X.object({op:X.literal("projects.unlink"),key:Au,sessionId:wt}).strict(),X.object({op:X.literal("projects.milestone"),key:Au,name:X.string().min(1).max(bG),targetDate:pb.optional(),completed:X.boolean().optional()}).strict(),X.object({op:X.literal("projects.milestone.remove"),key:Au,name:X.string().min(1).max(bG)}).strict(),X.object({op:X.literal("projects.request_update"),key:Au}).strict(),X.object({op:X.literal("projects.search"),q:X.string().min(1).max(m4e),limit:X.number().int().min(1).max($4e).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:wt}).strict(),X.object({op:X.literal("code_requests.refresh"),sessionId:wt,keys:X.array(X.string().min(1).max(512)).max(256).optional(),force:X.boolean().optional()}).strict(),X.object({op:X.literal("static.sign"),route:X.enum(["images","videos","audio","html"]),path:X.string().min(1),ttlS:X.number().int().min(1).max(3600).optional()}).strict()]);v4e.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 xo={noCredential:"pairing.no-credential",refused:"pairing.refused",planeClosed:"pairing.plane-closed",transportFailed:"transport.failed"},WA={runtimeUnreachable:"runtime_unreachable"},Tm="runtime_busy",dle="runtime_retiring",nk={[xo.noCredential]:"This app is not paired with the running Local Operator server, so this control is unavailable.",[xo.refused]:"This app's credential for the running Local Operator server was refused, so this control is unavailable.",[xo.planeClosed]:"The running Local Operator server does not accept this app's desktop controls.",[xo.transportFailed]:"The Local Operator server did not answer this request."},k$={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 Qp(e){return e!==void 0&&Object.values(xo).includes(e)}function b4e(e,t){if(e.startsWith("/v1/desktop/")){if(t===401||t===403)return xo.refused;if(t===503)return xo.planeClosed}}const w4e=88e4,S4e=11e5,x4e=2e4,Q4e=9e4,k4e=new Set(["analytics.get","analytics.models","sessions.report"]),P4e=new Set(["usage.get"]),_4e=new Set(["networks.list","peers.list"]),T4e=new Set([...k4e,...P4e,..._4e]),R4e=90,X4e=30,E4e=300,j4e=10,fle=15,q4e=1e4;function C4e(e){const n=e.to==="local"||e.keep?E4e:X4e,r=Math.max(0,e.waitS??0);return(R4e+n+j4e+fle)*1e3+r*1e3}const A4e=18e4,z4e=A4e+15e3,U4e=120,hle=(U4e+30+fle)*1e3,W4e=6e4,N4e=5*hle,G4e=new Set(["hub.apply","hub.retry","hub.check","hub.applyAll"]);function Y4e(e){switch(e){case"hub.apply":case"hub.retry":return hle;case"hub.check":return W4e;case"hub.applyAll":return N4e;default:return null}}function I4e(e){if(typeof e!="string"&&e.op==="sessions.transfer")return C4e(e)+q4e;const t=typeof e=="string"?e:e.op;if(t==="approvals.approve")return z4e;const n=Y4e(t);return n!==null?n:T4e.has(t)?Q4e:x4e}const Z4e=5e3;function NA(e){return I4e(e)+Z4e}const rk="deadline_exceeded",ple="foreground_required",mle="View these completions in the foreground before marking them read.",D4e=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"]),V4e=new Set(["analytics.get","analytics.models","networks.list","peers.list","usage.get","sessions.report","info.get","sessions.failovers"]);function M4e(e,t){const n=Math.round(t/1e3),r=rk;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.`}:G4e.has(e)?{code:r,message:"This is taking longer than expected. It may still finish; the mark will update."}:D4e.has(e)?{code:r,message:V4e.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 ik=w4e,L4e=S4e;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 F4e(e){return e.sessionId?{session_id:e.sessionId}:{...e.cwd?{cwd:e.cwd}:{},...e.target?{target:e.target}:{}}}function wG(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 SG(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 ak(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??ZXe)});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":{const t=new URLSearchParams;return e.journalOrder&&(t.set("journal_order","1"),gS(t,`/v1/desktop/sessions/${e.sessionId}`,e.orderIds??[])),{path:`/v1/desktop/sessions/${e.sessionId}${t.size?`?${t}`:""}`,method:"GET"}}case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),e.openFrame&&(t.set("open_frame","1"),t.set("supplements","1")),e.journalOrder&&(t.set("journal_order","1"),gS(t,`/v1/desktop/sessions/${e.sessionId}/history`,e.orderIds??[])),{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??lle)});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"supplements.cancel":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/cancel`,method:"POST",body:{anchor:e.anchor}};case"supplements.restart":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/restart`,method:"POST",body:{anchor:e.anchor}};case"supplements.steer":return{path:`/v1/desktop/sessions/${e.sessionId}/supplements/${e.job}/steer`,method:"POST",body:{anchor:e.anchor,text:e.text}};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":{SG(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":{SG(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,...F4e(e),message:e.message,...wG(e)}};case"wakes.edit":return{path:`/v1/desktop/wakes/${e.sessionId}/${e.wakeId}`,method:"PATCH",body:{...e.message!==void 0?{message:e.message}:{},...wG(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"jobs.cancel":return{path:`/v1/desktop/sessions/${encodeURIComponent(e.sessionId)}/jobs/${encodeURIComponent(e.jobId)}/cancel`,method:"POST"};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??g4e)})}`,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}:{}}};case"static.sign":return{path:"/v1/static/sign",method:"POST",body:{route:e.route,path:e.path,ttl_s:e.ttlS}}}}const gle=64,xG=64*1024*1024,B4e="superseded_completion_token",H4e="store_busy",K4e="session_is_remote",J4e="owner_build_behind";function eEe(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 Rd(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 $le(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const yle=e=>typeof e?.goal_status=="string",vle=e=>(e?.goal??"").trim().length>0;function tEe(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 _0={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."},QG={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},nEe={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},rEe={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},iEe={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},aEe={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function kG(e){return e?e===_0.notPaired?rEe:e===_0.serverDown?nEe:e===_0.frameBudget?aEe:QG:QG}const oEe=(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 sEe(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 ble=Fi()(nl(e=>({notice:null,receive:t=>e(n=>oEe(n.notice,t)?n:{notice:t}),dismiss:()=>e(t=>t.notice===null?t:{notice:null})}),{name:"delegated-cleanup-notice",storage:Gse(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({notice:e.notice})}));async function GA(e){if(window.api?.desktop)try{return await lEe(window.api.desktop.request(e),e)}catch(n){throw n instanceof Wt?n:hEe(n)?new au(mle,ple):new Wt(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 Wt(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Wt(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function lEe(e,t){const n=NA(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=M4e(t.op,n);a(new Wt(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const wle="This server did not answer the request for its desktop controls.";class Wt 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 au extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function Xo(e,t){return e instanceof Wt||e instanceof au?Qp(e.code)?nk[e.code]:e.message:t}function cEe(e,t,n,r){return typeof r=="string"?r:n===k$.noCredential?xo.noCredential:n===k$.transportFailed?xo.transportFailed:b4e(ak(e).path,t)}async function _e(e){const t=await GA(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Wt(t.status,r??wle,void 0,cEe(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"&&uEe(n?.result),n?.result}function uEe(e){if(typeof e!="object"||e===null)return;const t=sEe(e.delegated_cleanup_notice);t&&ble.getState().receive(t)}async function OEe(){try{await _e({op:"delegated_cleanup_notice.ack"})}catch{}}async function pln(){ble.getState().dismiss(),await OEe()}function Sle(e){return e instanceof Wt&&e.code===rk}function dEe(e){if(!(e instanceof Wt))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===J4e:e.code===K4e}function fEe(e){return e instanceof au&&e.code===ple}function hEe(e){return e instanceof Error&&e.message.includes(mle)}async function Un(e){const t=await GA(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function pEe(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await _e({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 mEe(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"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),gS(r,"/__desktop/stream",e.orderIds??[]));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:_0.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function lf(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.",o;if(i.includes("application/json"))try{const l=(await r.json())?.detail;if(typeof l=="string")a=l;else if(typeof l=="object"&&l!==null){const c=l;typeof c.text=="string"&&c.text.trim()?a=c.text:typeof c.message=="string"&&c.message.trim()&&(a=c.message),typeof c.code=="string"&&(o=c.code)}}catch{}return{status:r.status,kind:"error",detail:a,code:o!==void 0&&Qp(o)?o:a===k$.noCredential?xo.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 P$(e){return e.kind==="error"?Qp(e.code)?new au(nk[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const d3=e=>({revision:Zo(e),demand:e.orderDemand}),T0=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function YA(e,t,n,r,i){let a=e;const o=t.journal_generation;if(typeof o!="string"||o.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!a.journalMode?{...a,journalMode:!0}:a;if(r&&t.journal_order_state==="ready"&&i&&a.orderNeedsReconcile&&a.orderDemand===i.demand&&(a={...a,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),o!==a.journalGeneration&&!r)return a.orderNeedsReconcile&&a.orderWantedGeneration===o?a:{...a,orderNeedsReconcile:!0,orderWantedGeneration:o,orderDemand:{generation:o}};let s=a.journalMode?a:{...a,journalMode:!0};o!==a.journalGeneration&&(s={...a,journalMode:!0,journalGeneration:o,orderRevision:(a.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:a.orderNeedsReconcile,orderWantedGeneration:a.orderWantedGeneration,orderDemand:a.orderDemand});let l=s.journalPositions??new Map;const c=l,u=(O,d,f)=>{if(!T0(f))return;const p=l.get(O);p&&p.seq>=f||(l===c&&(l=new Map(l)),l.set(O,{entryId:d,seq:f}))};for(const[O,d]of Object.entries(t.journal_ordinals??{}))u(O,O,d);for(const O of n)typeof O.id=="string"&&(u(O.id,O.id,O.journal_seq),O.role==="tool"&&typeof O.tool_call_id=="string"&&u(`tool:${O.tool_call_id}`,O.id,O.journal_seq),typeof O.anchor=="string"&&u(`supplement:${O.anchor}`,O.id,O.journal_seq));return l!==c&&(s={...s,journalPositions:l}),s}function IA(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map;const r=n;for(const i of t.tool_calls)!i||typeof i.id!="string"||n.get(i.id)===t.id||(n===r&&(n=new Map(n)),n.set(i.id,t.id));return n===r?e:{...e,journalCallOwners:n}}function xle(e,t){if(!e.journalMode)return t;const n=e.journalGeneration,r=e.journalPositions;let i=!1;const a=t.map(O=>{let f=[r?.get(O.sourceEntryId??O.id),r?.get(O.id)].filter(g=>g!==void 0).sort((g,y)=>y.seq-g.seq)[0];if(O.journalGeneration===n&&T0(O.journalSeq)&&(!f||O.journalSeq>f.seq)&&(f={entryId:O.sourceEntryId??O.id,seq:O.journalSeq}),!f||!n||!(O.kind==="user"&&(O.provisional===!0||O.local===!0))&&O.sourceEntryId===f.entryId&&O.journalSeq===f.seq&&O.journalGeneration===n)return O;i=!0;let m={...O,sourceEntryId:f.entryId,journalSeq:f.seq,journalGeneration:n};if(m.kind==="user"){const{provisional:g,local:y,...v}=m;m=v}return m});let o;for(let O=0;O<a.length;O++){const d=a[O];d.kind==="user"&&d.provisional===!0||d.journalGeneration===n&&T0(d.journalSeq)?o=d.id:!d.sourceAdmissionAnchor&&o&&(a[O]={...d,sourceAdmissionAnchor:o},i=!0)}const s=new Map(a.map(O=>[O.id,O])),l=O=>O!==void 0&&O.journalGeneration===n&&T0(O.journalSeq)?O.journalSeq:void 0,c=(O,d)=>{const f=l(O);if(O.kind==="user"&&O.provisional===!0&&f===void 0)return[1,0,0,0,d];const p=O.kind==="supplement"?O.anchor:O.kind==="tool"?e.journalCallOwners?.get(O.toolCallId)??e.argsByCall.get(O.toolCallId)?.anchorId:void 0,m=typeof p=="string"?l(s.get(p)):void 0,g=O.sourceAdmissionAnchor?l(s.get(O.sourceAdmissionAnchor)):void 0,y=m??f??g;return y===void 0?[1,0,0,0,d]:[0,y,m!==void 0?1:f!==void 0?0:2,f??Number.MAX_SAFE_INTEGER,d]},u=a.map((O,d)=>({record:O,index:d,rank:c(O,d)}));return u.sort((O,d)=>{for(let f=0;f<O.rank.length;f++){const p=O.rank[f]-d.rank[f];if(p)return p}return 0}),!i&&u.every((O,d)=>O.index===d)?t:u.map(O=>O.record)}function vl(e){const t=e.records.filter(i=>i.kind==="user"&&i.provisional===!0),n=e.records.filter(i=>i.journalGeneration!==e.journalGeneration||!T0(i.journalSeq)),r=[...t,...n].map(i=>i.sourceEntryId??(i.kind==="tool"||i.kind==="supplement"?null:i.id));return e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),[...new Set(r.filter(i=>typeof i=="string"&&i.length>0&&i.length<=128))]}const Zo=e=>e.orderRevision??0;async function gEe(e){const t=new Set;let n=e.getTranscript().journalGeneration,r=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const i=e.getTranscript(),a=d3(i),o=a.revision,s=GXe(vl(i).filter(O=>!t.has(O)),e.lookupPath,new URLSearchParams({journal_order:"1"})),l=await e.read(s);if(!e.isCurrent()||Zo(e.getTranscript())!==o)return{kind:"stale"};if(e.commit(l,o,a),!e.isCurrent())return{kind:"stale"};const c=e.getTranscript(),u=e.page(l);if(u.journal_order_state==="ready"&&u.journal_generation===c.journalGeneration){u.journal_generation!==n&&(t.clear(),n=u.journal_generation);for(const O of s)t.add(O);if(c.orderNeedsReconcile){if(c.orderDemand===a.demand||r===1)return{kind:"waiting"};r++,t.clear();continue}if(vl(c).some(O=>!t.has(O)))continue;return{kind:"complete",transcript:c}}if(!c.orderNeedsReconcile||c.orderDemand===a.demand||r===1)return{kind:"waiting"};r++,t.clear()}}function Ws(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const i=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof i=="string"&&i?i:e.id}function s_(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function PG(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function mln(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const a of t){if(!a.settled||typeof a.run_key!="string"||a.run_key.length===0)continue;const o=s_(a.action_count);if(o===null)continue;const s={actions:o,workedSeconds:PG(a.worked_seconds),failed:s_(a.failed_count)??0,complete:a.complete!==!1,openingUserId:typeof a.opening_user_id=="string"&&a.opening_user_id.length>0?a.opening_user_id:null,closingAnswerId:typeof a.closing_answer_id=="string"&&a.closing_answer_id.length>0?a.closing_answer_id:null,crossSessionActions:s_(a.cross_session_action_count),crossSessionWorkedSeconds:PG(a.cross_session_worked_seconds)};n.set(a.run_key,s),s.openingUserId!==null&&n.set(s.openingUserId,s),s.closingAnswerId!==null&&n.set(s.closingAnswerId,s)}if(n.size===0)return null;const r=new Set;for(const a of e.entries)r.add(Ws(a));const i=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:i?Ws(i):null}}}function $Ee(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(a=>a.opening_user_id===n.id))return null;const i=Math.round((n.ts??0)*1e3);return i>0?{id:n.id,tsMs:i}:null}function yEe(e,t,n){const r=$Ee(e),i=e?.entries;if(r===null||!i||i.length===0)return!1;const a=Math.round((i[i.length-1].ts??0)*1e3);if(!(a>r.tsMs))return!1;for(const[o,s]of t)if(!n.has(o)&&(s===null||!(s>r.tsMs)||!(s<a)))return!1;return!0}const vEe=new Map([["This changes your instructions. Apply it from now on, and drop work it makes pointless.","steer"],["Answer it now with the `hub` tool — a short, direct reply — then carry on with what you were doing. Do not restructure your work around the question.","ask"],["This is a note, not a question. No reply is needed unless it changes what you should do.","note"]]),bEe=/\blabel=(['"])(.*?)\1/,wEe=/\bjob=(['"])(.*?)\1/,SEe=/^<(parent-message|subagent-message)\b[^>]*>\n([\s\S]*)\n<\/\1>$/;function f3(e){const t=typeof e.text=="string"?e.text:"",n=SEe.exec(t);let r=n?.[2];const i=r?.indexOf(`
3
3
 
4
4
  `)??-1,o=n?.[1]==="parent-message"&&(e.direction===void 0||e.direction===""||e.direction==="to_child")&&i>=0?vEe.get((r??"").slice(0,i)):void 0;n?.[1]==="parent-message"&&o&&(r=(r??"").slice(i+2));const s=typeof e.direction=="string"?e.direction:n?.[1]==="subagent-message"?"to_parent":o?"to_child":"";return{body:typeof e.body=="string"?e.body:r?.trim()?r:t,envelope:t,direction:s,label:_$(e.label??(n&&bEe.exec(n[0].split(`
5
5
  `,1)[0])?.[2])),jobId:_$(e.job_id??(n&&wEe.exec(n[0].split(`
@@ -815,7 +815,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
815
815
  `))};if(c.from==this.from&&a<this.from?c.from=a:c.to==this.to&&a>this.to&&(c.to=a),c.from==c.to&&!c.insert.length){let u=Ye.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((ot.mac||ot.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:er.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);i8(t,c,Ye.single(this.toEditorPos(r.selectionStart,u),this.toEditorPos(r.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=r=>{let i=[],a=null;for(let o=this.toEditorPos(r.rangeStart),s=this.toEditorPos(r.rangeEnd);o<s;o++){let l=t.coordsForChar(o);a=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||a||new DOMRect,i.push(a)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let a of r.getTextFormats()){let o=a.underlineStyle,s=a.underlineThickness;if(o!="None"&&s!="None"){let l=this.toEditorPos(a.rangeStart),c=this.toEditorPos(a.rangeEnd);if(l<c){let u=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${s=="Thin"?1:2}px`;i.push(On.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:Xme.of(On.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=K$(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 bt{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||_nt(t.parent)||document,this.viewState=new XV(t.state||Zn.create(t)),t.scrollTo&&t.scrollTo.is(Mb)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ih).map(i=>new zT(i));for(let i of this.plugins)i.update(this);this.observer=new Vrt(this),this.inputState=new prt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new dV(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 Di?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(Zme))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Dme(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(Zn.phrases)!=this.state.facet(Zn.phrases))return this.setState(a);i=HS.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 Op(f.empty?f:Ye.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of d.effects)f.is(Mb)&&(O=f.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=JS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(d0)!=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(Jb)!=i.state.facet(Jb)&&(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(sC))try{d(i)}catch(f){Za(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Ume(this,u)&&c.force&&up(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 XV(t),this.plugins=t.facet(Ih).map(r=>new zT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new dV(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(Ih),r=t.state.facet(Ih);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new zT(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){Za(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(ame(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 Za(this.state,p),CV}}),O=HS.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]!=CV)try{let p=c[f];p.write&&p.write(u[f],this)}catch(p){Za(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(sC))s(n)}get themeClasses(){return dC+" "+(this.state.facet(OC)?Fme:Lme)+" "+this.state.facet(Jb)}updateAttrs(){let t=AV(this,Eme,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Nc)?"true":"false",class:"cm-content",style:`${ot.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),AV(this,t8,n);let r=this.observer.ignore(()=>{let i=nC(this.contentDOM,this.contentAttrs,n),a=nC(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(bt.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(d0);let t=this.state.facet(bt.cspNonce);EO.mount(this.root,this.styleModules.concat(Zrt).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 WT(this,t,gV(this,t,n,r))}moveByGroup(t,n){return WT(this,t,gV(this,t,n,r=>ort(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),a=r[n?r.length-1:0];return Ye.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return art(this,t,n,r)}moveVertically(t,n,r){return WT(this,t,srt(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(),zme(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[cO.find(a,t-i.from,-1,n)];return Qv(r,o.dir==Er.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(_me)||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>Frt)return vme(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||yme(a.isolates,r=OV(this,t))))return a.order;r||(r=OV(this,t));let i=Int(t.text,n,r);return this.bidiCache.push(new JS(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ot.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{rme(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 Mb.of(new Op(typeof t=="number"?Ye.cursor(t):t,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return Mb.of(new Op(Ye.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Si.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Si.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=EO.newName(),i=[Jb.of(r),d0.of(fC(`.${r}`,t))];return n&&n.dark&&i.push(OC.of(!0)),i}static baseTheme(t){return IO.lowest(d0.of(fC("."+dC,t,Bme)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&pr.get(r)||pr.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}bt.styleModule=d0;bt.inputHandler=kme;bt.clipboardInputFilter=J9;bt.clipboardOutputFilter=e8;bt.scrollHandler=Rme;bt.focusChangeEffect=Pme;bt.perLineTextDirection=_me;bt.exceptionSink=Qme;bt.updateListener=sC;bt.editable=Nc;bt.mouseSelectionStyle=xme;bt.dragMovesSelection=Sme;bt.clickAddsSelectionRange=wme;bt.decorations=J$;bt.outerDecorations=jme;bt.atomicRanges=n8;bt.bidiIsolatedRanges=qme;bt.scrollMargins=Cme;bt.darkTheme=OC;bt.cspNonce=Ot.define({combine:e=>e.length?e[0]:""});bt.contentAttributes=t8;bt.editorAttributes=Eme;bt.lineWrapping=bt.contentAttributes.of({class:"cm-lineWrapping"});bt.announce=jn.define();const Frt=4096,CV={};class JS{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:Er.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 JS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function AV(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&&tC(o,n)}return n}const Brt=ot.mac?"mac":ot.windows?"win":ot.linux?"linux":"key";function Hrt(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 ew(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 Krt=IO.default(bt.domEventHandlers({keydown(e,t){return Kme(Hme(t.state),e,t,"editor")}})),Dk=Ot.define({enables:Krt}),zV=new WeakMap;function Hme(e){let t=e.facet(Dk),n=zV.get(t);return n||zV.set(t,n=eit(t.reduce((r,i)=>r.concat(i),[]))),n}function Jun(e,t,n){return Kme(Hme(e.state),t,e,n)}let nO=null;const Jrt=4e3;function eit(e,t=Brt){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(y=>Hrt(y,t));for(let y=1;y<p.length;y++){let v=p.slice(0,y).join(" ");i(v,!0),f[v]||(f[v]={preventDefault:!0,stopPropagation:!1,run:[w=>{let x=nO={view:w,prefix:v,scope:o};return setTimeout(()=>{nO==x&&(nO=null)},Jrt),!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,hC))}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 hC=null;function Kme(e,t,n,r){hC=t;let i=Snt(t),a=yo(i,0),o=Wc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;nO&&nO.view==n&&nO.scope==r&&(s=nO.prefix+" ",Nme.indexOf(t.keyCode)<0&&(c=!0,nO=null));let O=new Set,d=g=>{if(g){for(let y of g.run)if(!O.has(y)&&(O.add(y),y(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+ew(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(ot.windows&&t.ctrlKey&&t.altKey)&&(p=jO[t.keyCode])&&p!=i?(d(f[s+ew(p,t,!0)])||t.shiftKey&&(m=H$[t.keyCode])!=i&&m!=p&&d(f[s+ew(m,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(f[s+ew(i,t,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),hC=null,l}class _v{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=Jme(t);return[new _v(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return tit(t,n,r)}}function Jme(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Er.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function UV(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 tit(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==Er.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=Jme(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=cC(e,r,1),p=cC(e,i,-1),m=f.type==Ta.Text?f:null,g=p.type==Ta.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=UV(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=UV(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(y(O,b.bottom,d,S.top)):b.bottom<S.top&&e.elementAtHeight((b.bottom+S.top)/2).type==Ta.Text&&(b.bottom=S.top=(b.bottom+S.top)/2),v(b).concat(Q).concat(v(S))}function y(b,S,Q,P){return new _v(t,b-l.left,S-l.top,Q-b,P-S)}function v({top:b,bottom:S,horizontal:Q}){let P=[];for(let T=0;T<Q.length;T+=2)P.push(y(Q[T],b,Q[T+1],S));return P}function w(b,S,Q){let P=1e9,T=-1e9,_=[];function E(U,N,Z,G,D){let I=e.coordsAtPos(U,U==Q.to?-2:2),W=e.coordsAtPos(Z,Z==Q.from?2:-2);!I||!W||(P=Math.min(I.top,W.top,P),T=Math.max(I.bottom,W.bottom,T),D==Er.LTR?_.push(a&&N?O:I.left,a&&G?d:W.right):_.push(!a&&G?O:W.left,!a&&N?d:I.right))}let C=b??Q.from,A=S??Q.to;for(let U of e.visibleRanges)if(U.to>C&&U.from<A)for(let N=Math.max(U.from,C),Z=Math.min(U.to,A);;){let G=e.state.doc.lineAt(N);for(let D of e.bidiSpans(G)){let I=D.from+G.from,W=D.to+G.from;if(I>=Z)break;W>N&&E(Math.max(I,N),b==null&&I<=C,Math.min(W,Z),S==null&&W>=A,D.dir)}if(N=G.to+1,N>=Z)break}return _.length==0&&E(C,b==null,A,S==null,e.textDirection),{top:P,bottom:T,horizontal:_}}function x(b,S){let Q=s.top+(S?b.top:b.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function nit(e,t){return e.constructor==t.constructor&&e.eq(t)}class rit{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(E1)!=t.state.facet(E1)&&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(E1);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)=>!nit(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 E1=Ot.define();function ege(e){return[Si.define(t=>new rit(t,e)),E1.of(e)]}const ey=Ot.define({combine(e){return Wm(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function eOn(e={}){return[ey.of(e),iit,ait,oit,Tme.of(!0)]}function tge(e){return e.startState.facet(ey)!=e.state.facet(ey)}const iit=ege({above:!0,markers(e){let{state:t}=e,n=t.facet(ey),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor){let o=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",s=i.empty?i:Ye.cursor(i.head,i.head>i.anchor?-1:1);for(let l of _v.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=tge(e);return n&&WV(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){WV(t.state,e)},class:"cm-cursorLayer"});function WV(e,t){t.style.animationDuration=e.facet(ey).cursorBlinkRate+"ms"}const ait=ege({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:_v.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||tge(e)},class:"cm-selectionLayer"}),oit=IO.highest(bt.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"}}}})),nge=jn.define({map(e,t){return e==null?null:t.mapPos(e)}}),p0=Ka.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(nge)?r.value:n,e)}}),sit=Si.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(p0);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(p0)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(p0),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(p0)!=e&&this.view.dispatch({effects:nge.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 tOn(){return[p0,sit]}function NV(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 lit(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 cit{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 gf,r=n.add.bind(n);for(let{from:i,to:a}of lit(t,this.maxLength))NV(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,y)=>d.push(y.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 NV(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 pC=/x/.unicode!=null?"gu":"g",uit=new RegExp(`[\0-\b
816
816
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,pC),Oit={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 YT=null;function dit(){var e;if(YT==null&&typeof document<"u"&&document.body){let t=document.body.style;YT=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return YT||!1}const j1=Ot.define({combine(e){let t=Wm(e,{render:null,specialChars:uit,addSpecialChars:null});return(t.replaceTabs=!dit())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,pC)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,pC)),t}});function nOn(e={}){return[j1.of(e),fit()]}let GV=null;function fit(){return GV||(GV=Si.fromClass(class{constructor(e){this.view=e,this.decorations=On.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(j1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new cit({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=yo(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=XO(o.text,s,r-o.from);return On.replace({widget:new git((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=On.replace({widget:new mit(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(j1);e.startState.facet(j1)!=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 hit="•";function pit(e){return e>=32?hit:e==10?"␤":String.fromCharCode(9216+e)}class mit extends ku{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=pit(this.code),r=t.state.phrase("Control character")+" "+(Oit[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 git extends ku{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 rOn(){return yit}const $it=On.line({class:"cm-activeLine"}),yit=Si.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($it.range(i.from)),t=i.from)}return On.set(n)}},{decorations:e=>e.decorations});class vit extends ku{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=Qv(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 iOn(e){let t=Si.fromClass(class{constructor(n){this.view=n,this.placeholder=e?On.set([On.widget({widget:new vit(e),side:1}).range(0)]):On.none}get decorations(){return this.view.state.doc.length?On.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,bt.contentAttributes.of({"aria-placeholder":e})]:t}const mC=2e3;function bit(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>mC||n.off>mC||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=s&&a.push(Ye.range(c.from+o,c.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=Lq(c.text,o,e.tabSize,!0);if(u<0)a.push(Ye.cursor(c.to));else{let O=Lq(c.text,s,e.tabSize);a.push(Ye.range(c.from+u,c.from+O))}}}return a}function wit(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function YV(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>mC?-1:i==r.length?wit(e,t.clientX):XO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function Sit(e,t){let n=YV(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=YV(e,i);if(!s)return r;let l=bit(e.state,n,s);return l.length?o?Ye.create(l.concat(r.ranges)):Ye.create(l):r}}:null}function aOn(e){let t=n=>n.altKey&&n.button==0;return bt.mouseSelectionStyle.of((n,r)=>t(r)?Sit(n,r):null)}const xit={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Qit={style:"cursor: crosshair"};function oOn(e={}){let[t,n]=xit[e.key||"Alt"],r=Si.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,bt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?Qit:null})]}const wg="-10000px";class rge{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 kit(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const IT=Ot.define({combine:e=>{var t,n,r;return{position:ot.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)||kit}}}),IV=new WeakMap,s8=Si.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(IT);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 rge(e,l8,(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(IT);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=wg,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(ot.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==wg&&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=r8(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(IT).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=wg;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=(t=IV.get(c))!==null&&t!==void 0?t:d.bottom-d.top,y=c.offset||_it,v=this.view.textDirection==Er.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)+y.x,r.right-m)):Math.min(Math.max(r.left,O.left-m+(f?14:0)-y.x),r.right-m),x=this.above[s];!l.strictSide&&(x?O.top-g-p-y.y<r.top:O.bottom+g+p+y.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=wg;continue}IV.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.y:O.bottom+p+y.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",ZV(u,(w-e.parent.left)/i)):(u.style.top=S/a+"px",ZV(u,w/i)),f){let P=O.left+(v?y.x:-y.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=wg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function ZV(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const Pit=bt.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"}}}),_it={x:0,y:0},l8=Ot.define({enables:[s8,Pit]}),ex=Ot.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class Vk{static create(t){return new Vk(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new rge(t,ex,(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 Tit=l8.compute([ex],e=>{let t=e.facet(ex);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:Vk.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class Rit{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 lO)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==Er.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=>Za(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(s8),n=t?t.manager.tooltips.findIndex(r=>r.create==Vk.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&&!Xit(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:!Eit(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 tw=4;function Xit(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-tw&&t.clientX<=r+tw&&t.clientY>=i-tw&&t.clientY<=a+tw}function Eit(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 sOn(e,t={}){let n=jn.define(),r=Ka.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,Ii.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(jit)&&(i=[]);return i},provide:i=>ex.from(i)});return{active:r,extension:[r,Si.define(i=>new Rit(i,e,r,n,t.hoverTime||300)),Tit]}}function ige(e,t){let n=e.plugin(s8);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const jit=jn.define(),DV=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 lOn(e,t){let n=e.plugin(age),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const age=Si.fromClass(class{constructor(e){this.input=e.state.facet(MV),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(DV);this.top=new nw(e,!0,t.topContainer),this.bottom=new nw(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(DV);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new nw(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new nw(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(MV);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=>bt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class nw{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=VV(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=VV(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 VV(e){let t=e.nextSibling;return e.remove(),t}const MV=Ot.define({enables:age});class Ou extends mf{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Ou.prototype.elementClass="";Ou.prototype.toDOM=void 0;Ou.prototype.mapMode=Ii.TrackBefore;Ou.prototype.startSide=Ou.prototype.endSide=-1;Ou.prototype.point=!0;const q1=Ot.define(),qit=Ot.define(),Cit={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>En.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Z0=Ot.define();function Ait(e){return[oge(),Z0.of({...Cit,...e})]}const LV=Ot.define({combine:e=>e.some(t=>t)});function oge(e){return[zit]}const zit=Si.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(Z0).map(t=>new BV(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(LV),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(LV)!=!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=En.iter(this.view.state.facet(q1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Uit(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==Ta.Text&&o){gC(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==Ta.Text){gC(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(Z0),n=e.state.facet(Z0),r=e.docChanged||e.heightChanged||e.viewportChanged||!En.eq(e.startState.facet(q1),e.state.facet(q1),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 BV(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=>bt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==Er.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function FV(e){return Array.isArray(e)?e:[e]}function gC(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Uit{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=En.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 sge(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=[];gC(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(qit)){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 BV{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=FV(n.markers(t)),n.initialSpacer&&(this.spacer=new sge(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=FV(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!En.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 sge{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":""),Wit(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 Wit(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 Nit=Ot.define(),Git=Ot.define(),Zh=Ot.define({combine(e){return Wm(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 ZT extends Ou{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function DT(e,t){return e.state.facet(Zh).formatNumber(t,e.state)}const Yit=Z0.compute([Zh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Nit)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new ZT(DT(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(Git)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(Zh)!=t.state.facet(Zh),initialSpacer(t){return new ZT(DT(t,HV(t.state.doc.lines)))},updateSpacer(t,n){let r=DT(n.view,HV(n.view.state.doc.lines));return r==t.number?t:new ZT(r)},domEventHandlers:e.facet(Zh).domEventHandlers}));function cOn(e={}){return[Zh.of(e),oge(),Yit]}function HV(e){let t=9;for(;t<e;)t=t*10+9;return t}const Iit=new class extends Ou{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Zit=q1.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(Iit.range(i)))}return En.of(t)});function uOn(){return Zit}let Dit=0;class et{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Dit++}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 et&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new et(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 tx(t);return r=>r.modified.indexOf(n)>-1?r:tx.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let Vit=0;class tx{constructor(t){this.name=t,this.instances=[],this.id=Vit++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&Mit(n,s.modified));if(r)return r;let i=[],a=new et(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=Lit(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(tx.get(s,l));return a}}function Mit(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Lit(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 Nn(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 nx(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return lge.add(t)}const lge=new Yt;let nx=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}};nx.empty=new nx([],2,null);function cge(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 Fit(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Bit(e,t,n,r=0,i=e.length){let a=new Hit(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Hit{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=Kit(t)||nx.empty,O=Fit(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(Yt.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,y=s;;g++){let v=g<d.overlay.length?d.overlay[g]:null,w=v?v.from+s:l,x=Math.max(n,y),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;y=v.to+s,y>n&&(this.highlightRange(f.cursor(),Math.max(n,v.from+s),Math.min(r,y),"",p),this.startSpan(Math.min(r,y),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 Kit(e){let t=e.type.prop(lge);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Ke=et.define,rw=Ke(),Fu=Ke(),KV=Ke(Fu),JV=Ke(Fu),Bu=Ke(),iw=Ke(Bu),VT=Ke(Bu),yl=Ke(),ud=Ke(yl),fl=Ke(),hl=Ke(),$C=Ke(),Sg=Ke($C),aw=Ke(),k={comment:rw,lineComment:Ke(rw),blockComment:Ke(rw),docComment:Ke(rw),name:Fu,variableName:Ke(Fu),typeName:KV,tagName:Ke(KV),propertyName:JV,attributeName:Ke(JV),className:Ke(Fu),labelName:Ke(Fu),namespace:Ke(Fu),macroName:Ke(Fu),literal:Bu,string:iw,docString:Ke(iw),character:Ke(iw),attributeValue:Ke(iw),number:VT,integer:Ke(VT),float:Ke(VT),bool:Ke(Bu),regexp:Ke(Bu),escape:Ke(Bu),color:Ke(Bu),url:Ke(Bu),keyword:fl,self:Ke(fl),null:Ke(fl),atom:Ke(fl),unit:Ke(fl),modifier:Ke(fl),operatorKeyword:Ke(fl),controlKeyword:Ke(fl),definitionKeyword:Ke(fl),moduleKeyword:Ke(fl),operator:hl,derefOperator:Ke(hl),arithmeticOperator:Ke(hl),logicOperator:Ke(hl),bitwiseOperator:Ke(hl),compareOperator:Ke(hl),updateOperator:Ke(hl),definitionOperator:Ke(hl),typeOperator:Ke(hl),controlOperator:Ke(hl),punctuation:$C,separator:Ke($C),bracket:Sg,angleBracket:Ke(Sg),squareBracket:Ke(Sg),paren:Ke(Sg),brace:Ke(Sg),content:yl,heading:ud,heading1:Ke(ud),heading2:Ke(ud),heading3:Ke(ud),heading4:Ke(ud),heading5:Ke(ud),heading6:Ke(ud),contentSeparator:Ke(yl),list:Ke(yl),quote:Ke(yl),emphasis:Ke(yl),strong:Ke(yl),link:Ke(yl),monospace:Ke(yl),strikethrough:Ke(yl),inserted:Ke(),deleted:Ke(),changed:Ke(),invalid:Ke(),meta:aw,documentMeta:Ke(aw),annotation:Ke(aw),processingInstruction:Ke(aw),definition:et.defineModifier("definition"),constant:et.defineModifier("constant"),function:et.defineModifier("function"),standard:et.defineModifier("standard"),local:et.defineModifier("local"),special:et.defineModifier("special")};for(let e in k){let t=k[e];t instanceof et&&(t.name=e)}cge([{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 MT;const uO=new Yt;function Mk(e){return Ot.define({combine:e?t=>t.concat(e):void 0})}const c8=new Yt;class ko{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Zn.prototype.hasOwnProperty("tree")||Object.defineProperty(Zn.prototype,"tree",{get(){return tr(this)}}),this.parser=n,this.extension=[CO.of(this),Zn.languageData.of((a,o,s)=>{let l=eM(a,o,s),c=l.type.prop(uO);if(!c)return[];let u=a.facet(c),O=l.type.prop(c8);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 eM(t,n,r).type.prop(uO)==this.data}findRegions(t){let n=t.facet(CO);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(uO)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(Yt.mounted);if(s){if(s.tree.prop(uO)==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 gn&&i(c,a.positions[l]+o)}};return i(tr(t),0),r}get allowsNesting(){return!0}}ko.setState=jn.define();function eM(e,t,n){let r=e.facet(CO),i=tr(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,hr.ExcludeBuffers))a.type.isTop&&(i=a);return i}class Cn extends ko{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=Mk(t.languageData);return new Cn(n,t.parser.configure({props:[uO.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Cn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function tr(e){let t=e.field(ko.state,!1);return t?t.tree:gn.empty}class Jit{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 xg=null;class bf{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 bf(t,n,[],gn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Jit(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=gn.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(Kc.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(Kc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=xg;xg=this;try{return t()}finally{xg=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=tM(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=Kc.applyChanges(r,l),i=gn.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 bf(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=tM(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 Gk{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=xg;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 gn(Oi.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 xg}}function tM(e,t,n){return Kc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Wp{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 Wp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=bf.create(t.facet(CO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Wp(r)}}ko.state=Ka.define({create:Wp.init,update(e,t){for(let n of t.effects)if(n.is(ko.setState))return n.value;return t.startState.facet(CO)!=t.state.facet(CO)?Wp.init(t.state):e.apply(t)}});let uge=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(uge=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const LT=typeof navigator<"u"&&(!((MT=navigator.scheduling)===null||MT===void 0)&&MT.isInputPending)?()=>navigator.scheduling.isInputPending():null,eat=Si.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(ko.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(ko.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=uge(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(ko.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!LT?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>LT&&LT()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:ko.setState.of(new Wp(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=>Za(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()}}}),CO=Ot.define({combine(e){return e.length?e[0]:null},enables:e=>[ko.state,eat,bt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Tn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class de{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 de(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 tat=Ot.define(),Lk=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 rx(e){let t=e.facet(Lk);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function nat(e,t){let n="",r=e.tabSize,i=e.facet(Lk)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function rat(e,t){e instanceof Zn&&(e=new Oge(e));for(let r of e.state.facet(tat)){let i=r(e,t);if(i!==void 0)return i}let n=tr(e.state);return n.length>=t?iat(e,n,t):null}class Oge{constructor(t,n={}){this.state=t,this.options=n,this.unit=rx(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 XO(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 Gr=new Yt;function iat(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 dge(r,e,n)}function dge(e,t,n){for(let r=e;r;r=r.next){let i=oat(r.node);if(i)return i(u8.create(t,n,r))}return 0}function aat(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function oat(e){let t=e.type.prop(Gr);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Yt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>fge(o,!0,1,void 0,a&&!aat(o)?i.from:void 0)}return e.parent==null?sat:null}function sat(){return 0}class u8 extends Oge{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 u8(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(lat(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return dge(this.context.next,this.base,this.pos)}}function lat(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function cat(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 ds({closing:e,align:t=!0,units:n=1}){return r=>fge(r,t,n,e)}function fge(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?cat(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const O8=e=>e.baseIndent;function Vr({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const uat=200;function fOn(){return Zn.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+uat)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=rat(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],f=nat(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 hge=Ot.define(),Cr=new Yt;function da(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 Oat(e,t,n){let r=tr(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(Cr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!dat(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function dat(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function ix(e,t,n){for(let r of e.facet(hge)){let i=r(e,t,n);if(i)return i}return Oat(e,t,n)}function pge(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 Fk=jn.define({map:pge}),Tv=jn.define({map:pge});function mge(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 wf=Ka.define({create(){return On.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Fk)&&!fat(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(yge),i=r?On.replace({widget:new yat(r(t.state,n.value))}):nM;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Tv)&&(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=>bt.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(nM.range(r,i))}return On.set(t,!0)}});function ax(e,t,n){var r;let i=null;return(r=e.field(wf,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function fat(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function gge(e,t){return e.field(wf,!1)?t:t.concat(jn.appendConfig.of(vge()))}const hat=e=>{for(let t of mge(e)){let n=ix(e.state,t.from,t.to);if(n)return e.dispatch({effects:gge(e.state,[Fk.of(n),$ge(e,n)])}),!0}return!1},pat=e=>{if(!e.state.field(wf,!1))return!1;let t=[];for(let n of mge(e)){let r=ax(e.state,n.from,n.to);r&&t.push(Tv.of(r),$ge(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function $ge(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return bt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const mat=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=ix(t,i.from,i.to);a&&n.push(Fk.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:gge(e.state,n)}),!!n.length},gat=e=>{let t=e.state.field(wf,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(Tv.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},hOn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:hat},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:pat},{key:"Ctrl-Alt-[",run:mat},{key:"Ctrl-Alt-]",run:gat}],$at={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},yge=Ot.define({combine(e){return Wm(e,$at)}});function vge(e){return[wf,bat]}function bge(e,t){let{state:n}=e,r=n.facet(yge),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=ax(e.state,s.from,s.to);l&&e.dispatch({effects:Tv.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 nM=On.replace({widget:new class extends ku{toDOM(e){return bge(e,null)}}});class yat extends ku{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return bge(t,this.value)}}const vat={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class FT extends Ou{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 pOn(e={}){let t={...vat,...e},n=new FT(t,!0),r=new FT(t,!1),i=Si.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(CO)!=o.state.facet(CO)||o.startState.field(wf,!1)!=o.state.field(wf,!1)||tr(o.startState)!=tr(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new gf;for(let l of o.viewportLineBlocks){let c=ax(o.state,l.from,l.to)?r:ix(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,Ait({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||En.empty},initialSpacer(){return new FT(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=ax(o.state,s.from,s.to);if(c)return o.dispatch({effects:Tv.of(c)}),!0;let u=ix(o.state,s.from,s.to);return u?(o.dispatch({effects:Fk.of(u)}),!0):!1}}}),vge()]}const bat=bt.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 Bk{constructor(t,n){this.specs=t;let r;function i(s){let l=EO.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 ko?s=>s.prop(uO)==o.data:o?s=>s==o:void 0,this.style=cge(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new EO(r):null,this.themeType=n.themeType}static define(t,n){return new Bk(t,n||{})}}const yC=Ot.define(),wge=Ot.define({combine(e){return e.length?[e[0]]:null}});function BT(e){let t=e.facet(yC);return t.length?t:e.facet(wge)}function mOn(e,t){let n=[Sat],r;return e instanceof Bk&&(e.module&&n.push(bt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(wge.of(e)):r?n.push(yC.computeN([bt.darkTheme],i=>i.facet(bt.darkTheme)==(r=="dark")?[e]:[])):n.push(yC.of(e)),n}class wat{constructor(t){this.markCache=Object.create(null),this.tree=tr(t.state),this.decorations=this.buildDeco(t,BT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=tr(t.state),r=BT(t.state),i=r!=BT(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 On.none;let r=new gf;for(let{from:i,to:a}of t.visibleRanges)Bit(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=On.mark({class:l})))},i,a);return r.finish()}}const Sat=IO.high(Si.fromClass(wat,{decorations:e=>e.decorations})),gOn=Bk.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"}]),xat=bt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Sge=1e4,xge="()[]{}",Qge=Ot.define({combine(e){return Wm(e,{afterCursor:!0,brackets:xge,maxScanDistance:Sge,renderMatch:Pat})}}),Qat=On.mark({class:"cm-matchingBracket"}),kat=On.mark({class:"cm-nonmatchingBracket"});function Pat(e){let t=[],n=e.matched?Qat:kat;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 _at=Ka.define({create(){return On.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Qge);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=ow(t.state,i.head,-1,r)||i.head>0&&ow(t.state,i.head-1,1,r)||r.afterCursor&&(ow(t.state,i.head,1,r)||i.head<t.state.doc.length&&ow(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return On.set(n,!0)},provide:e=>bt.decorations.from(e)}),Tat=[_at,xat];function $On(e={}){return[Qge.of(e),Tat]}const d8=new Yt;function vC(e,t,n){let r=e.prop(t<0?Yt.openedBy:Yt.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 bC(e){let t=e.type.prop(d8);return t?t(e.node):e}function ow(e,t,n,r={}){let i=r.maxScanDistance||Sge,a=r.brackets||xge,o=tr(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=vC(l.type,n,a);if(c&&l.from<l.to){let u=bC(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return Rat(e,t,n,l,u,c,a)}}return Xat(e,t,n,o,s.type,i,a)}function Rat(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=bC(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(vC(u.type,n,o))c++;else if(vC(u.type,-n,o)){if(c==0){let O=bC(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 Xat(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 y=o.indexOf(f[m]);if(!(y<0||r.resolveInner(p+m,1).type!=i))if(y%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==l>>1};O--}}n>0&&(d+=f.length)}return u.done?{start:c,matched:!1}:null}function rM(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 kge{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=rM(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:rM(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 Eat(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||jat,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||h8,mergeTokens:e.mergeTokens!==!1}}function jat(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 iM=new WeakMap;class je extends ko{constructor(t){let n=Mk(t.languageData),r=Eat(t),i,a=new class extends Gk{createParse(o,s,l){return new Cat(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Uat(n,this),i=this,this.streamParser=r,this.stateAfter=new Yt({perNode:!0}),this.tokenTable=t.tokenTable?new Rge(r.tokenTable):zat}static define(t){return new je(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=iM.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=f8(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 kge(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)_ge(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&&iM.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function f8(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 gn&&l<i&&f8(e,s,l,r,i);if(c)return c}return null}function Pge(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 gn){if(!(l=Pge(e,s,n-o,r-o,i)))break;return i?new gn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function qat(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&&f8(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Pge(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?rx(i):4),tree:gn.empty}}let Cat=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=bf.get(),o=i[0].from,{state:s,tree:l}=qat(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(rx(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=bf.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==`
817
817
  `&&(n="");else{let r=n.indexOf(`
818
- `);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 kge(n,t?t.state.tabSize:4,t?rx(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=_ge(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=gn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Aat,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new gn(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 gn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function _ge(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 h8=Object.create(null),ty=[Oi.none],Aat=new Um(ty),aM=[],oM=Object.create(null),Tge=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"]])Tge[e]=Xge(h8,t);class Rge{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Tge)}resolve(t){return t?this.table[t]||(this.table[t]=Xge(this.extra,t)):0}}const zat=new Rge(h8);function HT(e,t){aM.indexOf(e)>-1||(aM.push(e),console.warn(t))}function Xge(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):HT(c,`Modifier ${c} used at start of tag`):l.length?HT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:HT(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=oM[i];if(a)return a.id;let o=oM[i]=Oi.define({id:ty.length,name:r,props:[Nn({[r]:n})]});return ty.push(o),o.id}function Uat(e,t){let n=Oi.define({id:ty.length,name:"Document",props:[uO.add(()=>e),Gr.add(()=>r=>t.getIndent(r))],top:!0});return ty.push(n),n}Er.RTL,Er.LTR;function xe(e){return new Tn(je.define(e))}function Nu(e){return he(()=>Promise.resolve().then(()=>lpt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Wat=[de.of({name:"C",extensions:["c","h","ino"],load(){return he(()=>Promise.resolve().then(()=>HL),void 0,import.meta.url).then(e=>e.cpp())}}),de.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return he(()=>Promise.resolve().then(()=>HL),void 0,import.meta.url).then(e=>e.cpp())}}),de.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Nu("Cassandra")}}),de.of({name:"CSS",extensions:["css"],load(){return he(()=>Promise.resolve().then(()=>Slt),void 0,import.meta.url).then(e=>e.css())}}),de.of({name:"Go",extensions:["go"],load(){return he(()=>import("./index-DGSndO-f.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),de.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return he(()=>Promise.resolve().then(()=>hct),void 0,import.meta.url).then(e=>e.html())}}),de.of({name:"Java",extensions:["java"],load(){return he(()=>Promise.resolve().then(()=>dpt),void 0,import.meta.url).then(e=>e.java())}}),de.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return he(()=>Promise.resolve().then(()=>uw),void 0,import.meta.url).then(e=>e.javascript())}}),de.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return he(()=>Promise.resolve().then(()=>yut),void 0,import.meta.url).then(e=>e.json())}}),de.of({name:"JSX",extensions:["jsx"],load(){return he(()=>Promise.resolve().then(()=>uw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),de.of({name:"LESS",extensions:["less"],load(){return he(()=>Promise.resolve().then(()=>Cct),void 0,import.meta.url).then(e=>e.less())}}),de.of({name:"Liquid",extensions:["liquid"],load(){return he(()=>Promise.resolve().then(()=>Hgt),void 0,import.meta.url).then(e=>e.liquid())}}),de.of({name:"MariaDB SQL",load(){return Nu("MariaSQL")}}),de.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return he(()=>Promise.resolve().then(()=>xct),void 0,import.meta.url).then(e=>e.markdown())}}),de.of({name:"MS SQL",load(){return Nu("MSSQL")}}),de.of({name:"MySQL",load(){return Nu("MySQL")}}),de.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return he(()=>Promise.resolve().then(()=>_gt),void 0,import.meta.url).then(e=>e.php())}}),de.of({name:"PLSQL",extensions:["pls"],load(){return Nu("PLSQL")}}),de.of({name:"PostgreSQL",load(){return Nu("PostgreSQL")}}),de.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return he(()=>Promise.resolve().then(()=>Hft),void 0,import.meta.url).then(e=>e.python())}}),de.of({name:"Rust",extensions:["rs"],load(){return he(()=>Promise.resolve().then(()=>Ept),void 0,import.meta.url).then(e=>e.rust())}}),de.of({name:"Sass",extensions:["sass"],load(){return he(()=>Promise.resolve().then(()=>dL),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),de.of({name:"SCSS",extensions:["scss"],load(){return he(()=>Promise.resolve().then(()=>dL),void 0,import.meta.url).then(e=>e.sass())}}),de.of({name:"SQL",extensions:["sql"],load(){return Nu("StandardSQL")}}),de.of({name:"SQLite",load(){return Nu("SQLite")}}),de.of({name:"TSX",extensions:["tsx"],load(){return he(()=>Promise.resolve().then(()=>uw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),de.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return he(()=>Promise.resolve().then(()=>uw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),de.of({name:"WebAssembly",extensions:["wat","wast"],load(){return he(()=>Promise.resolve().then(()=>e0t),void 0,import.meta.url).then(e=>e.wast())}}),de.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return he(()=>Promise.resolve().then(()=>yht),void 0,import.meta.url).then(e=>e.xml())}}),de.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return he(()=>import("./index-CYvymE2l.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),de.of({name:"APL",extensions:["dyalog","apl"],load(){return he(()=>Promise.resolve().then(()=>Tyt),void 0,import.meta.url).then(e=>xe(e.apl))}}),de.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return he(()=>Promise.resolve().then(()=>Ryt),void 0,import.meta.url).then(e=>xe(e.asciiArmor))}}),de.of({name:"ASN.1",extensions:["asn","asn1"],load(){return he(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>xe(e.asn1({})))}}),de.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return he(()=>Promise.resolve().then(()=>Cyt),void 0,import.meta.url).then(e=>xe(e.asterisk))}}),de.of({name:"Brainfuck",extensions:["b","bf"],load(){return he(()=>Promise.resolve().then(()=>zyt),void 0,import.meta.url).then(e=>xe(e.brainfuck))}}),de.of({name:"Cobol",extensions:["cob","cpy"],load(){return he(()=>Promise.resolve().then(()=>Ovt),void 0,import.meta.url).then(e=>xe(e.cobol))}}),de.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.csharp))}}),de.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return he(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>xe(e.clojure))}}),de.of({name:"ClojureScript",extensions:["cljs"],load(){return he(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>xe(e.clojure))}}),de.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return he(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>xe(e.gss))}}),de.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return he(()=>Promise.resolve().then(()=>nvt),void 0,import.meta.url).then(e=>xe(e.cmake))}}),de.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return he(()=>Promise.resolve().then(()=>xvt),void 0,import.meta.url).then(e=>xe(e.coffeeScript))}}),de.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return he(()=>Promise.resolve().then(()=>Rvt),void 0,import.meta.url).then(e=>xe(e.commonLisp))}}),de.of({name:"Cypher",extensions:["cyp","cypher"],load(){return he(()=>Promise.resolve().then(()=>Lvt),void 0,import.meta.url).then(e=>xe(e.cypher))}}),de.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return he(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>xe(e.cython))}}),de.of({name:"Crystal",extensions:["cr"],load(){return he(()=>Promise.resolve().then(()=>Yvt),void 0,import.meta.url).then(e=>xe(e.crystal))}}),de.of({name:"D",extensions:["d"],load(){return he(()=>Promise.resolve().then(()=>tbt),void 0,import.meta.url).then(e=>xe(e.d))}}),de.of({name:"Dart",extensions:["dart"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.dart))}}),de.of({name:"diff",extensions:["diff","patch"],load(){return he(()=>Promise.resolve().then(()=>nbt),void 0,import.meta.url).then(e=>xe(e.diff))}}),de.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return he(()=>Promise.resolve().then(()=>pbt),void 0,import.meta.url).then(e=>xe(e.dockerFile))}}),de.of({name:"DTD",extensions:["dtd"],load(){return he(()=>Promise.resolve().then(()=>$bt),void 0,import.meta.url).then(e=>xe(e.dtd))}}),de.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return he(()=>Promise.resolve().then(()=>Sbt),void 0,import.meta.url).then(e=>xe(e.dylan))}}),de.of({name:"EBNF",load(){return he(()=>Promise.resolve().then(()=>xbt),void 0,import.meta.url).then(e=>xe(e.ebnf))}}),de.of({name:"ECL",extensions:["ecl"],load(){return he(()=>Promise.resolve().then(()=>Ebt),void 0,import.meta.url).then(e=>xe(e.ecl))}}),de.of({name:"edn",extensions:["edn"],load(){return he(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>xe(e.clojure))}}),de.of({name:"Eiffel",extensions:["e"],load(){return he(()=>Promise.resolve().then(()=>Ubt),void 0,import.meta.url).then(e=>xe(e.eiffel))}}),de.of({name:"Elm",extensions:["elm"],load(){return he(()=>Promise.resolve().then(()=>Fbt),void 0,import.meta.url).then(e=>xe(e.elm))}}),de.of({name:"Erlang",extensions:["erl"],load(){return he(()=>Promise.resolve().then(()=>ywt),void 0,import.meta.url).then(e=>xe(e.erlang))}}),de.of({name:"Esper",load(){return he(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>xe(e.esper))}}),de.of({name:"Factor",extensions:["factor"],load(){return he(()=>Promise.resolve().then(()=>vwt),void 0,import.meta.url).then(e=>xe(e.factor))}}),de.of({name:"FCL",load(){return he(()=>Promise.resolve().then(()=>Qwt),void 0,import.meta.url).then(e=>xe(e.fcl))}}),de.of({name:"Forth",extensions:["forth","fth","4th"],load(){return he(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>xe(e.forth))}}),de.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return he(()=>Promise.resolve().then(()=>Cwt),void 0,import.meta.url).then(e=>xe(e.fortran))}}),de.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return he(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>xe(e.fSharp))}}),de.of({name:"Gas",extensions:["s"],load(){return he(()=>Promise.resolve().then(()=>zwt),void 0,import.meta.url).then(e=>xe(e.gas))}}),de.of({name:"Gherkin",extensions:["feature"],load(){return he(()=>Promise.resolve().then(()=>Uwt),void 0,import.meta.url).then(e=>xe(e.gherkin))}}),de.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return he(()=>Promise.resolve().then(()=>Fwt),void 0,import.meta.url).then(e=>xe(e.groovy))}}),de.of({name:"Haskell",extensions:["hs"],load(){return he(()=>Promise.resolve().then(()=>n1t),void 0,import.meta.url).then(e=>xe(e.haskell))}}),de.of({name:"Haxe",extensions:["hx"],load(){return he(()=>Promise.resolve().then(()=>vB),void 0,import.meta.url).then(e=>xe(e.haxe))}}),de.of({name:"HXML",extensions:["hxml"],load(){return he(()=>Promise.resolve().then(()=>vB),void 0,import.meta.url).then(e=>xe(e.hxml))}}),de.of({name:"HTTP",load(){return he(()=>Promise.resolve().then(()=>Q1t),void 0,import.meta.url).then(e=>xe(e.http))}}),de.of({name:"IDL",extensions:["pro"],load(){return he(()=>Promise.resolve().then(()=>E1t),void 0,import.meta.url).then(e=>xe(e.idl))}}),de.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return he(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>xe(e.jsonld))}}),de.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return he(()=>Promise.resolve().then(()=>A1t),void 0,import.meta.url).then(e=>xe(e.jinja2))}}),de.of({name:"Julia",extensions:["jl"],load(){return he(()=>Promise.resolve().then(()=>sSt),void 0,import.meta.url).then(e=>xe(e.julia))}}),de.of({name:"Kotlin",extensions:["kt","kts"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.kotlin))}}),de.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return he(()=>Promise.resolve().then(()=>OSt),void 0,import.meta.url).then(e=>xe(e.liveScript))}}),de.of({name:"Lua",extensions:["lua"],load(){return he(()=>Promise.resolve().then(()=>ySt),void 0,import.meta.url).then(e=>xe(e.lua))}}),de.of({name:"mIRC",extensions:["mrc"],load(){return he(()=>Promise.resolve().then(()=>YSt),void 0,import.meta.url).then(e=>xe(e.mirc))}}),de.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return he(()=>Promise.resolve().then(()=>PSt),void 0,import.meta.url).then(e=>xe(e.mathematica))}}),de.of({name:"Modelica",extensions:["mo"],load(){return he(()=>Promise.resolve().then(()=>KSt),void 0,import.meta.url).then(e=>xe(e.modelica))}}),de.of({name:"MUMPS",extensions:["mps"],load(){return he(()=>Promise.resolve().then(()=>hxt),void 0,import.meta.url).then(e=>xe(e.mumps))}}),de.of({name:"Mbox",extensions:["mbox"],load(){return he(()=>Promise.resolve().then(()=>WSt),void 0,import.meta.url).then(e=>xe(e.mbox))}}),de.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return he(()=>Promise.resolve().then(()=>yxt),void 0,import.meta.url).then(e=>xe(e.nginx))}}),de.of({name:"NSIS",extensions:["nsh","nsi"],load(){return he(()=>Promise.resolve().then(()=>vxt),void 0,import.meta.url).then(e=>xe(e.nsis))}}),de.of({name:"NTriples",extensions:["nt","nq"],load(){return he(()=>Promise.resolve().then(()=>bxt),void 0,import.meta.url).then(e=>xe(e.ntriples))}}),de.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.objectiveC))}}),de.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.objectiveCpp))}}),de.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return he(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>xe(e.oCaml))}}),de.of({name:"Octave",extensions:["m"],load(){return he(()=>Promise.resolve().then(()=>Ext),void 0,import.meta.url).then(e=>xe(e.octave))}}),de.of({name:"Oz",extensions:["oz"],load(){return he(()=>Promise.resolve().then(()=>Zxt),void 0,import.meta.url).then(e=>xe(e.oz))}}),de.of({name:"Pascal",extensions:["p","pas"],load(){return he(()=>Promise.resolve().then(()=>Bxt),void 0,import.meta.url).then(e=>xe(e.pascal))}}),de.of({name:"Perl",extensions:["pl","pm"],load(){return he(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>xe(e.perl))}}),de.of({name:"Pig",extensions:["pig"],load(){return he(()=>Promise.resolve().then(()=>eQt),void 0,import.meta.url).then(e=>xe(e.pig))}}),de.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return he(()=>Promise.resolve().then(()=>mQt),void 0,import.meta.url).then(e=>xe(e.powerShell))}}),de.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return he(()=>Promise.resolve().then(()=>gQt),void 0,import.meta.url).then(e=>xe(e.properties))}}),de.of({name:"ProtoBuf",extensions:["proto"],load(){return he(()=>Promise.resolve().then(()=>wQt),void 0,import.meta.url).then(e=>xe(e.protobuf))}}),de.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return he(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>xe(e.pug))}}),de.of({name:"Puppet",extensions:["pp"],load(){return he(()=>Promise.resolve().then(()=>QQt),void 0,import.meta.url).then(e=>xe(e.puppet))}}),de.of({name:"Q",extensions:["q"],load(){return he(()=>Promise.resolve().then(()=>jQt),void 0,import.meta.url).then(e=>xe(e.q))}}),de.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return he(()=>Promise.resolve().then(()=>NQt),void 0,import.meta.url).then(e=>xe(e.r))}}),de.of({name:"RPM Changes",load(){return he(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>xe(e.rpmChanges))}}),de.of({name:"RPM Spec",extensions:["spec"],load(){return he(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>xe(e.rpmSpec))}}),de.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return he(()=>Promise.resolve().then(()=>FQt),void 0,import.meta.url).then(e=>xe(e.ruby))}}),de.of({name:"SAS",extensions:["sas"],load(){return he(()=>Promise.resolve().then(()=>JQt),void 0,import.meta.url).then(e=>xe(e.sas))}}),de.of({name:"Scala",extensions:["scala"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.scala))}}),de.of({name:"Scheme",extensions:["scm","ss"],load(){return he(()=>Promise.resolve().then(()=>dkt),void 0,import.meta.url).then(e=>xe(e.scheme))}}),de.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return he(()=>Promise.resolve().then(()=>mkt),void 0,import.meta.url).then(e=>xe(e.shell))}}),de.of({name:"Sieve",extensions:["siv","sieve"],load(){return he(()=>Promise.resolve().then(()=>bkt),void 0,import.meta.url).then(e=>xe(e.sieve))}}),de.of({name:"Smalltalk",extensions:["st"],load(){return he(()=>Promise.resolve().then(()=>xkt),void 0,import.meta.url).then(e=>xe(e.smalltalk))}}),de.of({name:"Solr",load(){return he(()=>Promise.resolve().then(()=>Xkt),void 0,import.meta.url).then(e=>xe(e.solr))}}),de.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return he(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>xe(e.sml))}}),de.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return he(()=>Promise.resolve().then(()=>Ukt),void 0,import.meta.url).then(e=>xe(e.sparql))}}),de.of({name:"Spreadsheet",alias:["excel","formula"],load(){return he(()=>Promise.resolve().then(()=>Wkt),void 0,import.meta.url).then(e=>xe(e.spreadsheet))}}),de.of({name:"Squirrel",extensions:["nut"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.squirrel))}}),de.of({name:"Stylus",extensions:["styl"],load(){return he(()=>Promise.resolve().then(()=>sPt),void 0,import.meta.url).then(e=>xe(e.stylus))}}),de.of({name:"Swift",extensions:["swift"],load(){return he(()=>Promise.resolve().then(()=>PPt),void 0,import.meta.url).then(e=>xe(e.swift))}}),de.of({name:"sTeX",load(){return he(()=>Promise.resolve().then(()=>OH),void 0,import.meta.url).then(e=>xe(e.stex))}}),de.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return he(()=>Promise.resolve().then(()=>OH),void 0,import.meta.url).then(e=>xe(e.stex))}}),de.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return he(()=>Promise.resolve().then(()=>XH),void 0,import.meta.url).then(e=>xe(e.verilog))}}),de.of({name:"Tcl",extensions:["tcl"],load(){return he(()=>Promise.resolve().then(()=>XPt),void 0,import.meta.url).then(e=>xe(e.tcl))}}),de.of({name:"Textile",extensions:["textile"],load(){return he(()=>Promise.resolve().then(()=>CPt),void 0,import.meta.url).then(e=>xe(e.textile))}}),de.of({name:"TiddlyWiki",load(){return he(()=>Promise.resolve().then(()=>n5t),void 0,import.meta.url).then(e=>xe(e.tiddlyWiki))}}),de.of({name:"Tiki wiki",load(){return he(()=>Promise.resolve().then(()=>c5t),void 0,import.meta.url).then(e=>xe(e.tiki))}}),de.of({name:"TOML",extensions:["toml"],load(){return he(()=>Promise.resolve().then(()=>u5t),void 0,import.meta.url).then(e=>xe(e.toml))}}),de.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return he(()=>Promise.resolve().then(()=>f5t),void 0,import.meta.url).then(e=>xe(e.troff))}}),de.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return he(()=>Promise.resolve().then(()=>X5t),void 0,import.meta.url).then(e=>xe(e.ttcn))}}),de.of({name:"TTCN_CFG",extensions:["cfg"],load(){return he(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>xe(e.ttcnCfg))}}),de.of({name:"Turtle",extensions:["ttl"],load(){return he(()=>Promise.resolve().then(()=>q5t),void 0,import.meta.url).then(e=>xe(e.turtle))}}),de.of({name:"Web IDL",extensions:["webidl"],load(){return he(()=>Promise.resolve().then(()=>P_t),void 0,import.meta.url).then(e=>xe(e.webIDL))}}),de.of({name:"VB.NET",extensions:["vb"],load(){return he(()=>Promise.resolve().then(()=>F5t),void 0,import.meta.url).then(e=>xe(e.vb))}}),de.of({name:"VBScript",extensions:["vbs"],load(){return he(()=>Promise.resolve().then(()=>H5t),void 0,import.meta.url).then(e=>xe(e.vbScript))}}),de.of({name:"Velocity",extensions:["vtl"],load(){return he(()=>Promise.resolve().then(()=>e_t),void 0,import.meta.url).then(e=>xe(e.velocity))}}),de.of({name:"Verilog",extensions:["v"],load(){return he(()=>Promise.resolve().then(()=>XH),void 0,import.meta.url).then(e=>xe(e.verilog))}}),de.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return he(()=>Promise.resolve().then(()=>c_t),void 0,import.meta.url).then(e=>xe(e.vhdl))}}),de.of({name:"XQuery",extensions:["xy","xquery"],load(){return he(()=>Promise.resolve().then(()=>z_t),void 0,import.meta.url).then(e=>xe(e.xQuery))}}),de.of({name:"Yacas",extensions:["ys"],load(){return he(()=>Promise.resolve().then(()=>M_t),void 0,import.meta.url).then(e=>xe(e.yacas))}}),de.of({name:"Z80",extensions:["z80"],load(){return he(()=>Promise.resolve().then(()=>K_t),void 0,import.meta.url).then(e=>xe(e.z80))}}),de.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return he(()=>Promise.resolve().then(()=>rR),void 0,import.meta.url).then(e=>xe(e.mscgen))}}),de.of({name:"Xù",extensions:["xu"],load(){return he(()=>Promise.resolve().then(()=>rR),void 0,import.meta.url).then(e=>xe(e.xu))}}),de.of({name:"MsGenny",extensions:["msgenny"],load(){return he(()=>Promise.resolve().then(()=>rR),void 0,import.meta.url).then(e=>xe(e.msgenny))}}),de.of({name:"Vue",extensions:["vue"],load(){return he(()=>Promise.resolve().then(()=>l0t),void 0,import.meta.url).then(e=>e.vue())}}),de.of({name:"Angular Template",load(){return he(()=>Promise.resolve().then(()=>P0t),void 0,import.meta.url).then(e=>e.angular())}})];class p8{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=tr(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(Ege(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 sM(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 Nat(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=sM(t)+sM(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Rv(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Nat(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function Hk(e,t){return n=>{for(let r=tr(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 lM{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Bd(e){return e.selection.main.from}function Ege(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 m8=Yf.define();function Gat(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ye.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const cM=new WeakMap;function Yat(e){if(!Array.isArray(e))return e;let t=cM.get(e);return t||cM.set(e,t=Rv(e)),t}const ox=jn.define(),ny=jn.define();class Iat{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=yo(t,n),i=Wc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(yo(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=yo(t,0),w=Wc(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=yo(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=Wc(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,w=Math.min(t.length,200),x=0;v<w&&O<l;){let b=yo(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=Ipe(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&&(y=!1)),x=Q,v+=Wc(b)}return O==l&&o[0]==0&&y?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+(y?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?Wc(yo(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 Zat{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 Ei=Ot.define({combine(e){return Wm(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:Dat,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=>uM(t(r),n(r)),optionClass:(t,n)=>r=>uM(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function uM(e,t){return e?t?e+" "+t:e:t}function Dat(e,t,n,r,i,a){let o=e.textDirection==Er.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,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Vat(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 KT(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 Mat{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(Ei);this.optionContent=Vat(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=KT(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(Ei).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:ny.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=KT(a.length,o,t.state.facet(Ei).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=KT(n.options.length,n.selected,this.view.state.facet(Ei).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=>Za(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&&Fat(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(Ei).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 Lat(e,t){return n=>new Mat(n,e,t)}function Fat(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 OM(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Bat(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(Ei);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 lM(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Zat(O):new Iat(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 lM(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):OM(c.completion)>OM(s)&&(o[o.length-1]=c),s=c.completion}return o}class Dh{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 Dh(this.options,dM(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=Bat(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ei).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 Dh(s,dM(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:not,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Dh(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 Dh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class sx{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new sx(eot,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ei),a=(r.override||n.languageDataAt("autocomplete",Bd(n)).map(Yat)).map(l=>(this.active.find(u=>u.source==l)||new ls(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(g8));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Hat(a,this.active)||s?o=Dh.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 ls(l.source,0):l));for(let l of t.effects)l.is(qge)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new sx(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kat:Jat}}function Hat(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 Kat={"aria-autocomplete":"list"},Jat={};function dM(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const eot=[];function jge(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(m8);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 ls{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=jge(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ls(i.source,0)),r&4&&i.state==0&&(i=new ls(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(ox))i=new ls(i.source,1,a.value);else if(a.is(ny))i=new ls(i.source,0);else if(a.is(g8))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(Bd(t.state))}}class dp extends ls{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=Bd(t.state);if(s>o||!i||n&2&&(Bd(t.startState)==this.from||s<this.limit))return new ls(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return tot(i.validFor,t.state,a,o)?new dp(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new p8(t.state,s,!1)))?new dp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Bd(t.state)):new ls(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new dp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ls(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function tot(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Ege(e,!0).test(i)}const g8=jn.define({map(e,t){return e.map(n=>n.map(t))}}),qge=jn.define(),Ga=Ka.define({create(){return sx.start()},update(e,t){return e.update(t)},provide:e=>[l8.from(e,t=>t.tooltip),bt.contentAttributes.from(e,t=>t.attrs)]});function $8(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ga).active.find(i=>i.source==t.source);return r instanceof dp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Gat(e.state,n,r.from,r.to)),{annotations:m8.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const not=Lat(Ga,$8);function sw(e,t="option"){return n=>{let r=n.state.field(Ga,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ei).interactionDelay)return!1;let i=1,a;t=="page"&&(a=ige(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:qge.of(s)}),!0}}const rot=e=>{let t=e.state.field(Ga,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ei).interactionDelay?!1:$8(e,t.open.options[t.open.selected])},fM=e=>e.state.field(Ga,!1)?(e.dispatch({effects:ox.of(!0)}),!0):!1,iot=e=>{let t=e.state.field(Ga,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:ny.of(null)}),!0)};class aot{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const oot=50,sot=1e3,lot=Si.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(Ga).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ga),n=e.state.facet(Ei);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ga)==t)return;let r=e.transactions.some(a=>{let o=jge(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>oot&&Date.now()-o.time>sot){for(let s of o.context.abortListeners)try{s()}catch(l){Za(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(ox)))&&(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(Ga);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(Ei).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Bd(t),r=new p8(t,n,e.explicit,this.view),i=new aot(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:ny.of(null)}),Za(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(Ei).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ei),r=this.view.state.field(Ga);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=Bd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new dp(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 ls(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:g8.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ga,!1);if(t&&t.tooltip&&this.view.state.facet(Ei).closeOnBlur){let n=t.open&&ige(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:ny.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ox.of(!1)}),20),this.composing=0}}}),cot=typeof navigator=="object"&&/Win/.test(navigator.platform),uot=IO.highest(bt.domEventHandlers({keydown(e,t){let n=t.state.field(Ga,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(cot&&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&&$8(t,r),!1}})),Cge=bt.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 Oot{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class y8{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ii.TrackDel),r=t.mapPos(this.to,1,Ii.TrackDel);return n==null||r==null?null:new y8(this.field,n,r)}}class v8{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(Lk);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 y8(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 Oot(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 v8(r,i)}}let dot=On.widget({widget:new class extends ku{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),fot=On.mark({class:"cm-snippetField"});class Nm{constructor(t,n){this.ranges=t,this.active=n,this.deco=On.set(t.map(r=>(r.from==r.to?dot:fot).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 Nm(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 Xv=jn.define({map(e,t){return e&&e.map(t)}}),hot=jn.define(),ry=Ka.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Xv))return n.value;if(n.is(hot)&&e)return new Nm(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=>bt.decorations.from(e,t=>t?t.deco:On.none)});function b8(e,t){return Ye.create(e.filter(n=>n.field==t).map(n=>Ye.range(n.from,n.to)))}function pot(e){let t=v8.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:er.of(o)},scrollIntoView:!0,annotations:r?[m8.of(r),Di.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=b8(s,0)),s.some(u=>u.field>0)){let u=new Nm(s,0),O=c.effects=[Xv.of(u)];n.state.field(ry,!1)===void 0&&O.push(jn.appendConfig.of([ry,vot,bot,Cge]))}n.dispatch(n.state.update(c))}}function Age(e){return({state:t,dispatch:n})=>{let r=t.field(ry,!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:b8(r.ranges,i),effects:Xv.of(a?null:new Nm(r.ranges,i)),scrollIntoView:!0})),!0}}const mot=({state:e,dispatch:t})=>e.field(ry,!1)?(t(e.update({effects:Xv.of(null)})),!0):!1,got=Age(1),$ot=Age(-1),yot=[{key:"Tab",run:got,shift:$ot},{key:"Escape",run:mot}],hM=Ot.define({combine(e){return e.length?e[0]:yot}}),vot=IO.highest(Dk.compute([hM],e=>e.facet(hM)));function Qr(e,t){return Object.assign(Object.assign({},t),{apply:pot(e)})}const bot=bt.domEventHandlers({mousedown(e,t){let n=t.state.field(ry,!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:b8(n.ranges,i.field),effects:Xv.of(n.ranges.some(a=>a.field>i.field)?new Nm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),iy={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Cd=jn.define({map(e,t){let n=t.mapPos(e,-1,Ii.TrackAfter);return n??void 0}}),w8=new class extends mf{};w8.startSide=1;w8.endSide=-1;const zge=Ka.define({create(){return En.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(Cd)&&(e=e.update({add:[w8.range(n.value,n.value+1)]}));return e}});function vOn(){return[Sot,zge]}const JT="()[]{}<>«»»«[]{}";function Uge(e){for(let t=0;t<JT.length;t+=2)if(JT.charCodeAt(t)==e)return JT.charAt(t+1);return Ipe(e<128?e:e+1)}function Wge(e,t){return e.languageDataAt("closeBrackets",t)[0]||iy}const wot=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Sot=bt.inputHandler.of((e,t,n,r)=>{if((wot?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Wc(yo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Qot(e.state,r);return a?(e.dispatch(a),!0):!1}),xot=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Wge(e,e.selection.main.head).brackets||iy.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=kot(e.doc,o.head);for(let l of r)if(l==s&&Kk(e.doc,o.head)==Uge(yo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ye.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},bOn=[{key:"Backspace",run:xot}];function Qot(e,t){let n=Wge(e,e.selection.main.head),r=n.brackets||iy.brackets;for(let i of r){let a=Uge(yo(i,0));if(t==i)return a==i?Tot(e,i,r.indexOf(i+i+i)>-1,n):Pot(e,i,a,n.before||iy.before);if(t==a&&Nge(e,e.selection.main.from))return _ot(e,i,a)}return null}function Nge(e,t){let n=!1;return e.field(zge).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function Kk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Wc(yo(n,0)))}function kot(e,t){let n=e.sliceString(t-2,t);return Wc(yo(n,0))==n.length?n:n.slice(1)}function Pot(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:Cd.of(o.to+t.length),range:Ye.range(o.anchor+t.length,o.head+t.length)};let s=Kk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Cd.of(o.head+t.length),range:Ye.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function _ot(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&Kk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ye.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function Tot(e,t,n,r){let i=r.stringPrefixes||iy.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Cd.of(s.to+t.length),range:Ye.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=Kk(e.doc,l),u;if(c==t){if(pM(e,l))return{changes:{insert:t+t,from:l},effects:Cd.of(l+t.length),range:Ye.cursor(l+t.length)};if(Nge(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ye.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=mM(e,l-2*t.length,i))>-1&&pM(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Cd.of(l+t.length),range:Ye.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ss.Word&&mM(e,l,i)>-1&&!Rot(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Cd.of(l+t.length),range:Ye.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function pM(e,t){let n=tr(e).resolveInner(t+1);return n.parent&&n.from==t}function Rot(e,t,n,r){let i=tr(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 mM(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ss.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))!=ss.Word)return a}return-1}function wOn(e={}){return[uot,Ga,Ei.of(e),lot,Eot,Cge]}const Xot=[{key:"Ctrl-Space",run:fM},{mac:"Alt-`",run:fM},{key:"Escape",run:iot},{key:"ArrowDown",run:sw(!0)},{key:"ArrowUp",run:sw(!1)},{key:"PageDown",run:sw(!0,"page")},{key:"PageUp",run:sw(!1,"page")},{key:"Enter",run:rot}],Eot=IO.highest(Dk.computeN([Ei],e=>e.facet(Ei).defaultKeymap?[Xot]:[]));class lx{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new lx(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=[[Yt.contextHash,i]]}addChild(t,n){t.prop(Yt.contextHash)!=this.hash&&(t=new gn(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 gn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new gn(Oi.none,i,a,o,this.hashProp)})}}var Ie;(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"})(Ie||(Ie={}));class jot{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let qot=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 D0(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 gM(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==Ie.OrderedList?Q8:x8)(n,t,!1);return r>0&&(e.type!=Ie.BulletList||S8(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const Gge={[Ie.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(Pn(Ie.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ws(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ie.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ie.OrderedList]:gM,[Ie.BulletList]:gM,[Ie.Document](){return!0}};function ws(e){return e==32||e==9||e==10||e==13}function D0(e,t=0){for(;t<e.length&&ws(e.charCodeAt(t));)t++;return t}function $M(e,t,n){for(;t>n&&ws(e.charCodeAt(t-1));)t--;return t}function Yge(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 Ige(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function S8(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(!ws(a))return-1}return n&&e.next==45&&Vge(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Bge.SetextHeading)>-1||r<3?-1:1}function Zge(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function x8(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ws(e.text.charCodeAt(e.pos+1)))&&(!n||Zge(t,Ie.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Q8(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&&!ws(e.text.charCodeAt(r+1))||n&&!Zge(t,Ie.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Dge(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 Vge(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&&ws(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const wC=/^[ \t]*$/,Mge=/-->/,Lge=/\?>/,SC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Mge],[/^\s*<\?/,Lge],[/^\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,wC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,wC]];function Fge(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=SC.length-(n?1:0);i<a;i++)if(SC[i][0].test(r))return i;return-1}function yM(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 Od(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ie.CodeText?e[r].to=n:e.push(Pn(Ie.CodeText,t,n))}const lw={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(Od(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){Od(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==Ie.CodeText?Od(o,c.from,c.to):o.push(c);s=[]}Od(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&&Od(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ie.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ie.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Yge(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=$M(t.text,t.text.length,o),l=[Pn(Ie.CodeMark,r,r+a)];o<s&&l.push(Pn(Ie.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(Pn(Ie.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||Od(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&&Od(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ie.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Ige(t);return n<0?!1:(e.startContext(Ie.Blockquote,t.pos),e.addNode(Ie.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(S8(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ie.HorizontalRule,n),!0},BulletList(e,t){let n=x8(t,e,!1);if(n<0)return!1;e.block.type!=Ie.BulletList&&e.startContext(Ie.BulletList,t.basePos,t.next);let r=yM(t,t.pos+1);return e.startContext(Ie.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ie.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Q8(t,e,!1);if(n<0)return!1;e.block.type!=Ie.OrderedList&&e.startContext(Ie.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=yM(t,t.pos+n);return e.startContext(Ie.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ie.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Dge(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=$M(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!ws(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ie.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ie.HeaderMark,o-r,a-r);let l=s.finish(Ie.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=Fge(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=SC[n][1],a=[],o=i!=wC;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==Mge?Ie.CommentBlock:i==Lge?Ie.ProcessingInstructionBlock:Ie.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class Cot{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+`
818
+ `);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 kge(n,t?t.state.tabSize:4,t?rx(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=_ge(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=gn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Aat,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new gn(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 gn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function _ge(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 h8=Object.create(null),ty=[Oi.none],Aat=new Um(ty),aM=[],oM=Object.create(null),Tge=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"]])Tge[e]=Xge(h8,t);class Rge{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Tge)}resolve(t){return t?this.table[t]||(this.table[t]=Xge(this.extra,t)):0}}const zat=new Rge(h8);function HT(e,t){aM.indexOf(e)>-1||(aM.push(e),console.warn(t))}function Xge(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):HT(c,`Modifier ${c} used at start of tag`):l.length?HT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:HT(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=oM[i];if(a)return a.id;let o=oM[i]=Oi.define({id:ty.length,name:r,props:[Nn({[r]:n})]});return ty.push(o),o.id}function Uat(e,t){let n=Oi.define({id:ty.length,name:"Document",props:[uO.add(()=>e),Gr.add(()=>r=>t.getIndent(r))],top:!0});return ty.push(n),n}Er.RTL,Er.LTR;function xe(e){return new Tn(je.define(e))}function Nu(e){return he(()=>Promise.resolve().then(()=>lpt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Wat=[de.of({name:"C",extensions:["c","h","ino"],load(){return he(()=>Promise.resolve().then(()=>HL),void 0,import.meta.url).then(e=>e.cpp())}}),de.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return he(()=>Promise.resolve().then(()=>HL),void 0,import.meta.url).then(e=>e.cpp())}}),de.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Nu("Cassandra")}}),de.of({name:"CSS",extensions:["css"],load(){return he(()=>Promise.resolve().then(()=>Slt),void 0,import.meta.url).then(e=>e.css())}}),de.of({name:"Go",extensions:["go"],load(){return he(()=>import("./index-Cy_LQBkK.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),de.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return he(()=>Promise.resolve().then(()=>hct),void 0,import.meta.url).then(e=>e.html())}}),de.of({name:"Java",extensions:["java"],load(){return he(()=>Promise.resolve().then(()=>dpt),void 0,import.meta.url).then(e=>e.java())}}),de.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return he(()=>Promise.resolve().then(()=>uw),void 0,import.meta.url).then(e=>e.javascript())}}),de.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return he(()=>Promise.resolve().then(()=>yut),void 0,import.meta.url).then(e=>e.json())}}),de.of({name:"JSX",extensions:["jsx"],load(){return he(()=>Promise.resolve().then(()=>uw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),de.of({name:"LESS",extensions:["less"],load(){return he(()=>Promise.resolve().then(()=>Cct),void 0,import.meta.url).then(e=>e.less())}}),de.of({name:"Liquid",extensions:["liquid"],load(){return he(()=>Promise.resolve().then(()=>Hgt),void 0,import.meta.url).then(e=>e.liquid())}}),de.of({name:"MariaDB SQL",load(){return Nu("MariaSQL")}}),de.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return he(()=>Promise.resolve().then(()=>xct),void 0,import.meta.url).then(e=>e.markdown())}}),de.of({name:"MS SQL",load(){return Nu("MSSQL")}}),de.of({name:"MySQL",load(){return Nu("MySQL")}}),de.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return he(()=>Promise.resolve().then(()=>_gt),void 0,import.meta.url).then(e=>e.php())}}),de.of({name:"PLSQL",extensions:["pls"],load(){return Nu("PLSQL")}}),de.of({name:"PostgreSQL",load(){return Nu("PostgreSQL")}}),de.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return he(()=>Promise.resolve().then(()=>Hft),void 0,import.meta.url).then(e=>e.python())}}),de.of({name:"Rust",extensions:["rs"],load(){return he(()=>Promise.resolve().then(()=>Ept),void 0,import.meta.url).then(e=>e.rust())}}),de.of({name:"Sass",extensions:["sass"],load(){return he(()=>Promise.resolve().then(()=>dL),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),de.of({name:"SCSS",extensions:["scss"],load(){return he(()=>Promise.resolve().then(()=>dL),void 0,import.meta.url).then(e=>e.sass())}}),de.of({name:"SQL",extensions:["sql"],load(){return Nu("StandardSQL")}}),de.of({name:"SQLite",load(){return Nu("SQLite")}}),de.of({name:"TSX",extensions:["tsx"],load(){return he(()=>Promise.resolve().then(()=>uw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),de.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return he(()=>Promise.resolve().then(()=>uw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),de.of({name:"WebAssembly",extensions:["wat","wast"],load(){return he(()=>Promise.resolve().then(()=>e0t),void 0,import.meta.url).then(e=>e.wast())}}),de.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return he(()=>Promise.resolve().then(()=>yht),void 0,import.meta.url).then(e=>e.xml())}}),de.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return he(()=>import("./index-CMv0JWYs.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),de.of({name:"APL",extensions:["dyalog","apl"],load(){return he(()=>Promise.resolve().then(()=>Tyt),void 0,import.meta.url).then(e=>xe(e.apl))}}),de.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return he(()=>Promise.resolve().then(()=>Ryt),void 0,import.meta.url).then(e=>xe(e.asciiArmor))}}),de.of({name:"ASN.1",extensions:["asn","asn1"],load(){return he(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>xe(e.asn1({})))}}),de.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return he(()=>Promise.resolve().then(()=>Cyt),void 0,import.meta.url).then(e=>xe(e.asterisk))}}),de.of({name:"Brainfuck",extensions:["b","bf"],load(){return he(()=>Promise.resolve().then(()=>zyt),void 0,import.meta.url).then(e=>xe(e.brainfuck))}}),de.of({name:"Cobol",extensions:["cob","cpy"],load(){return he(()=>Promise.resolve().then(()=>Ovt),void 0,import.meta.url).then(e=>xe(e.cobol))}}),de.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.csharp))}}),de.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return he(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>xe(e.clojure))}}),de.of({name:"ClojureScript",extensions:["cljs"],load(){return he(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>xe(e.clojure))}}),de.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return he(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>xe(e.gss))}}),de.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return he(()=>Promise.resolve().then(()=>nvt),void 0,import.meta.url).then(e=>xe(e.cmake))}}),de.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return he(()=>Promise.resolve().then(()=>xvt),void 0,import.meta.url).then(e=>xe(e.coffeeScript))}}),de.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return he(()=>Promise.resolve().then(()=>Rvt),void 0,import.meta.url).then(e=>xe(e.commonLisp))}}),de.of({name:"Cypher",extensions:["cyp","cypher"],load(){return he(()=>Promise.resolve().then(()=>Lvt),void 0,import.meta.url).then(e=>xe(e.cypher))}}),de.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return he(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>xe(e.cython))}}),de.of({name:"Crystal",extensions:["cr"],load(){return he(()=>Promise.resolve().then(()=>Yvt),void 0,import.meta.url).then(e=>xe(e.crystal))}}),de.of({name:"D",extensions:["d"],load(){return he(()=>Promise.resolve().then(()=>tbt),void 0,import.meta.url).then(e=>xe(e.d))}}),de.of({name:"Dart",extensions:["dart"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.dart))}}),de.of({name:"diff",extensions:["diff","patch"],load(){return he(()=>Promise.resolve().then(()=>nbt),void 0,import.meta.url).then(e=>xe(e.diff))}}),de.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return he(()=>Promise.resolve().then(()=>pbt),void 0,import.meta.url).then(e=>xe(e.dockerFile))}}),de.of({name:"DTD",extensions:["dtd"],load(){return he(()=>Promise.resolve().then(()=>$bt),void 0,import.meta.url).then(e=>xe(e.dtd))}}),de.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return he(()=>Promise.resolve().then(()=>Sbt),void 0,import.meta.url).then(e=>xe(e.dylan))}}),de.of({name:"EBNF",load(){return he(()=>Promise.resolve().then(()=>xbt),void 0,import.meta.url).then(e=>xe(e.ebnf))}}),de.of({name:"ECL",extensions:["ecl"],load(){return he(()=>Promise.resolve().then(()=>Ebt),void 0,import.meta.url).then(e=>xe(e.ecl))}}),de.of({name:"edn",extensions:["edn"],load(){return he(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>xe(e.clojure))}}),de.of({name:"Eiffel",extensions:["e"],load(){return he(()=>Promise.resolve().then(()=>Ubt),void 0,import.meta.url).then(e=>xe(e.eiffel))}}),de.of({name:"Elm",extensions:["elm"],load(){return he(()=>Promise.resolve().then(()=>Fbt),void 0,import.meta.url).then(e=>xe(e.elm))}}),de.of({name:"Erlang",extensions:["erl"],load(){return he(()=>Promise.resolve().then(()=>ywt),void 0,import.meta.url).then(e=>xe(e.erlang))}}),de.of({name:"Esper",load(){return he(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>xe(e.esper))}}),de.of({name:"Factor",extensions:["factor"],load(){return he(()=>Promise.resolve().then(()=>vwt),void 0,import.meta.url).then(e=>xe(e.factor))}}),de.of({name:"FCL",load(){return he(()=>Promise.resolve().then(()=>Qwt),void 0,import.meta.url).then(e=>xe(e.fcl))}}),de.of({name:"Forth",extensions:["forth","fth","4th"],load(){return he(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>xe(e.forth))}}),de.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return he(()=>Promise.resolve().then(()=>Cwt),void 0,import.meta.url).then(e=>xe(e.fortran))}}),de.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return he(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>xe(e.fSharp))}}),de.of({name:"Gas",extensions:["s"],load(){return he(()=>Promise.resolve().then(()=>zwt),void 0,import.meta.url).then(e=>xe(e.gas))}}),de.of({name:"Gherkin",extensions:["feature"],load(){return he(()=>Promise.resolve().then(()=>Uwt),void 0,import.meta.url).then(e=>xe(e.gherkin))}}),de.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return he(()=>Promise.resolve().then(()=>Fwt),void 0,import.meta.url).then(e=>xe(e.groovy))}}),de.of({name:"Haskell",extensions:["hs"],load(){return he(()=>Promise.resolve().then(()=>n1t),void 0,import.meta.url).then(e=>xe(e.haskell))}}),de.of({name:"Haxe",extensions:["hx"],load(){return he(()=>Promise.resolve().then(()=>vB),void 0,import.meta.url).then(e=>xe(e.haxe))}}),de.of({name:"HXML",extensions:["hxml"],load(){return he(()=>Promise.resolve().then(()=>vB),void 0,import.meta.url).then(e=>xe(e.hxml))}}),de.of({name:"HTTP",load(){return he(()=>Promise.resolve().then(()=>Q1t),void 0,import.meta.url).then(e=>xe(e.http))}}),de.of({name:"IDL",extensions:["pro"],load(){return he(()=>Promise.resolve().then(()=>E1t),void 0,import.meta.url).then(e=>xe(e.idl))}}),de.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return he(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>xe(e.jsonld))}}),de.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return he(()=>Promise.resolve().then(()=>A1t),void 0,import.meta.url).then(e=>xe(e.jinja2))}}),de.of({name:"Julia",extensions:["jl"],load(){return he(()=>Promise.resolve().then(()=>sSt),void 0,import.meta.url).then(e=>xe(e.julia))}}),de.of({name:"Kotlin",extensions:["kt","kts"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.kotlin))}}),de.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return he(()=>Promise.resolve().then(()=>OSt),void 0,import.meta.url).then(e=>xe(e.liveScript))}}),de.of({name:"Lua",extensions:["lua"],load(){return he(()=>Promise.resolve().then(()=>ySt),void 0,import.meta.url).then(e=>xe(e.lua))}}),de.of({name:"mIRC",extensions:["mrc"],load(){return he(()=>Promise.resolve().then(()=>YSt),void 0,import.meta.url).then(e=>xe(e.mirc))}}),de.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return he(()=>Promise.resolve().then(()=>PSt),void 0,import.meta.url).then(e=>xe(e.mathematica))}}),de.of({name:"Modelica",extensions:["mo"],load(){return he(()=>Promise.resolve().then(()=>KSt),void 0,import.meta.url).then(e=>xe(e.modelica))}}),de.of({name:"MUMPS",extensions:["mps"],load(){return he(()=>Promise.resolve().then(()=>hxt),void 0,import.meta.url).then(e=>xe(e.mumps))}}),de.of({name:"Mbox",extensions:["mbox"],load(){return he(()=>Promise.resolve().then(()=>WSt),void 0,import.meta.url).then(e=>xe(e.mbox))}}),de.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return he(()=>Promise.resolve().then(()=>yxt),void 0,import.meta.url).then(e=>xe(e.nginx))}}),de.of({name:"NSIS",extensions:["nsh","nsi"],load(){return he(()=>Promise.resolve().then(()=>vxt),void 0,import.meta.url).then(e=>xe(e.nsis))}}),de.of({name:"NTriples",extensions:["nt","nq"],load(){return he(()=>Promise.resolve().then(()=>bxt),void 0,import.meta.url).then(e=>xe(e.ntriples))}}),de.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.objectiveC))}}),de.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.objectiveCpp))}}),de.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return he(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>xe(e.oCaml))}}),de.of({name:"Octave",extensions:["m"],load(){return he(()=>Promise.resolve().then(()=>Ext),void 0,import.meta.url).then(e=>xe(e.octave))}}),de.of({name:"Oz",extensions:["oz"],load(){return he(()=>Promise.resolve().then(()=>Zxt),void 0,import.meta.url).then(e=>xe(e.oz))}}),de.of({name:"Pascal",extensions:["p","pas"],load(){return he(()=>Promise.resolve().then(()=>Bxt),void 0,import.meta.url).then(e=>xe(e.pascal))}}),de.of({name:"Perl",extensions:["pl","pm"],load(){return he(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>xe(e.perl))}}),de.of({name:"Pig",extensions:["pig"],load(){return he(()=>Promise.resolve().then(()=>eQt),void 0,import.meta.url).then(e=>xe(e.pig))}}),de.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return he(()=>Promise.resolve().then(()=>mQt),void 0,import.meta.url).then(e=>xe(e.powerShell))}}),de.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return he(()=>Promise.resolve().then(()=>gQt),void 0,import.meta.url).then(e=>xe(e.properties))}}),de.of({name:"ProtoBuf",extensions:["proto"],load(){return he(()=>Promise.resolve().then(()=>wQt),void 0,import.meta.url).then(e=>xe(e.protobuf))}}),de.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return he(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>xe(e.pug))}}),de.of({name:"Puppet",extensions:["pp"],load(){return he(()=>Promise.resolve().then(()=>QQt),void 0,import.meta.url).then(e=>xe(e.puppet))}}),de.of({name:"Q",extensions:["q"],load(){return he(()=>Promise.resolve().then(()=>jQt),void 0,import.meta.url).then(e=>xe(e.q))}}),de.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return he(()=>Promise.resolve().then(()=>NQt),void 0,import.meta.url).then(e=>xe(e.r))}}),de.of({name:"RPM Changes",load(){return he(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>xe(e.rpmChanges))}}),de.of({name:"RPM Spec",extensions:["spec"],load(){return he(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>xe(e.rpmSpec))}}),de.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return he(()=>Promise.resolve().then(()=>FQt),void 0,import.meta.url).then(e=>xe(e.ruby))}}),de.of({name:"SAS",extensions:["sas"],load(){return he(()=>Promise.resolve().then(()=>JQt),void 0,import.meta.url).then(e=>xe(e.sas))}}),de.of({name:"Scala",extensions:["scala"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.scala))}}),de.of({name:"Scheme",extensions:["scm","ss"],load(){return he(()=>Promise.resolve().then(()=>dkt),void 0,import.meta.url).then(e=>xe(e.scheme))}}),de.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return he(()=>Promise.resolve().then(()=>mkt),void 0,import.meta.url).then(e=>xe(e.shell))}}),de.of({name:"Sieve",extensions:["siv","sieve"],load(){return he(()=>Promise.resolve().then(()=>bkt),void 0,import.meta.url).then(e=>xe(e.sieve))}}),de.of({name:"Smalltalk",extensions:["st"],load(){return he(()=>Promise.resolve().then(()=>xkt),void 0,import.meta.url).then(e=>xe(e.smalltalk))}}),de.of({name:"Solr",load(){return he(()=>Promise.resolve().then(()=>Xkt),void 0,import.meta.url).then(e=>xe(e.solr))}}),de.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return he(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>xe(e.sml))}}),de.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return he(()=>Promise.resolve().then(()=>Ukt),void 0,import.meta.url).then(e=>xe(e.sparql))}}),de.of({name:"Spreadsheet",alias:["excel","formula"],load(){return he(()=>Promise.resolve().then(()=>Wkt),void 0,import.meta.url).then(e=>xe(e.spreadsheet))}}),de.of({name:"Squirrel",extensions:["nut"],load(){return he(()=>Promise.resolve().then(()=>hd),void 0,import.meta.url).then(e=>xe(e.squirrel))}}),de.of({name:"Stylus",extensions:["styl"],load(){return he(()=>Promise.resolve().then(()=>sPt),void 0,import.meta.url).then(e=>xe(e.stylus))}}),de.of({name:"Swift",extensions:["swift"],load(){return he(()=>Promise.resolve().then(()=>PPt),void 0,import.meta.url).then(e=>xe(e.swift))}}),de.of({name:"sTeX",load(){return he(()=>Promise.resolve().then(()=>OH),void 0,import.meta.url).then(e=>xe(e.stex))}}),de.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return he(()=>Promise.resolve().then(()=>OH),void 0,import.meta.url).then(e=>xe(e.stex))}}),de.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return he(()=>Promise.resolve().then(()=>XH),void 0,import.meta.url).then(e=>xe(e.verilog))}}),de.of({name:"Tcl",extensions:["tcl"],load(){return he(()=>Promise.resolve().then(()=>XPt),void 0,import.meta.url).then(e=>xe(e.tcl))}}),de.of({name:"Textile",extensions:["textile"],load(){return he(()=>Promise.resolve().then(()=>CPt),void 0,import.meta.url).then(e=>xe(e.textile))}}),de.of({name:"TiddlyWiki",load(){return he(()=>Promise.resolve().then(()=>n5t),void 0,import.meta.url).then(e=>xe(e.tiddlyWiki))}}),de.of({name:"Tiki wiki",load(){return he(()=>Promise.resolve().then(()=>c5t),void 0,import.meta.url).then(e=>xe(e.tiki))}}),de.of({name:"TOML",extensions:["toml"],load(){return he(()=>Promise.resolve().then(()=>u5t),void 0,import.meta.url).then(e=>xe(e.toml))}}),de.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return he(()=>Promise.resolve().then(()=>f5t),void 0,import.meta.url).then(e=>xe(e.troff))}}),de.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return he(()=>Promise.resolve().then(()=>X5t),void 0,import.meta.url).then(e=>xe(e.ttcn))}}),de.of({name:"TTCN_CFG",extensions:["cfg"],load(){return he(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>xe(e.ttcnCfg))}}),de.of({name:"Turtle",extensions:["ttl"],load(){return he(()=>Promise.resolve().then(()=>q5t),void 0,import.meta.url).then(e=>xe(e.turtle))}}),de.of({name:"Web IDL",extensions:["webidl"],load(){return he(()=>Promise.resolve().then(()=>P_t),void 0,import.meta.url).then(e=>xe(e.webIDL))}}),de.of({name:"VB.NET",extensions:["vb"],load(){return he(()=>Promise.resolve().then(()=>F5t),void 0,import.meta.url).then(e=>xe(e.vb))}}),de.of({name:"VBScript",extensions:["vbs"],load(){return he(()=>Promise.resolve().then(()=>H5t),void 0,import.meta.url).then(e=>xe(e.vbScript))}}),de.of({name:"Velocity",extensions:["vtl"],load(){return he(()=>Promise.resolve().then(()=>e_t),void 0,import.meta.url).then(e=>xe(e.velocity))}}),de.of({name:"Verilog",extensions:["v"],load(){return he(()=>Promise.resolve().then(()=>XH),void 0,import.meta.url).then(e=>xe(e.verilog))}}),de.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return he(()=>Promise.resolve().then(()=>c_t),void 0,import.meta.url).then(e=>xe(e.vhdl))}}),de.of({name:"XQuery",extensions:["xy","xquery"],load(){return he(()=>Promise.resolve().then(()=>z_t),void 0,import.meta.url).then(e=>xe(e.xQuery))}}),de.of({name:"Yacas",extensions:["ys"],load(){return he(()=>Promise.resolve().then(()=>M_t),void 0,import.meta.url).then(e=>xe(e.yacas))}}),de.of({name:"Z80",extensions:["z80"],load(){return he(()=>Promise.resolve().then(()=>K_t),void 0,import.meta.url).then(e=>xe(e.z80))}}),de.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return he(()=>Promise.resolve().then(()=>rR),void 0,import.meta.url).then(e=>xe(e.mscgen))}}),de.of({name:"Xù",extensions:["xu"],load(){return he(()=>Promise.resolve().then(()=>rR),void 0,import.meta.url).then(e=>xe(e.xu))}}),de.of({name:"MsGenny",extensions:["msgenny"],load(){return he(()=>Promise.resolve().then(()=>rR),void 0,import.meta.url).then(e=>xe(e.msgenny))}}),de.of({name:"Vue",extensions:["vue"],load(){return he(()=>Promise.resolve().then(()=>l0t),void 0,import.meta.url).then(e=>e.vue())}}),de.of({name:"Angular Template",load(){return he(()=>Promise.resolve().then(()=>P0t),void 0,import.meta.url).then(e=>e.angular())}})];class p8{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=tr(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(Ege(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 sM(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 Nat(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=sM(t)+sM(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Rv(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Nat(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function Hk(e,t){return n=>{for(let r=tr(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 lM{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Bd(e){return e.selection.main.from}function Ege(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 m8=Yf.define();function Gat(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ye.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const cM=new WeakMap;function Yat(e){if(!Array.isArray(e))return e;let t=cM.get(e);return t||cM.set(e,t=Rv(e)),t}const ox=jn.define(),ny=jn.define();class Iat{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=yo(t,n),i=Wc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(yo(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=yo(t,0),w=Wc(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=yo(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=Wc(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,w=Math.min(t.length,200),x=0;v<w&&O<l;){let b=yo(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=Ipe(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&&(y=!1)),x=Q,v+=Wc(b)}return O==l&&o[0]==0&&y?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+(y?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?Wc(yo(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 Zat{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 Ei=Ot.define({combine(e){return Wm(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:Dat,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=>uM(t(r),n(r)),optionClass:(t,n)=>r=>uM(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function uM(e,t){return e?t?e+" "+t:e:t}function Dat(e,t,n,r,i,a){let o=e.textDirection==Er.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,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Vat(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 KT(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 Mat{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(Ei);this.optionContent=Vat(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=KT(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(Ei).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:ny.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=KT(a.length,o,t.state.facet(Ei).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=KT(n.options.length,n.selected,this.view.state.facet(Ei).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=>Za(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&&Fat(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(Ei).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 Lat(e,t){return n=>new Mat(n,e,t)}function Fat(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 OM(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Bat(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(Ei);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 lM(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Zat(O):new Iat(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 lM(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):OM(c.completion)>OM(s)&&(o[o.length-1]=c),s=c.completion}return o}class Dh{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 Dh(this.options,dM(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=Bat(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ei).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 Dh(s,dM(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:not,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Dh(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 Dh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class sx{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new sx(eot,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ei),a=(r.override||n.languageDataAt("autocomplete",Bd(n)).map(Yat)).map(l=>(this.active.find(u=>u.source==l)||new ls(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(g8));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Hat(a,this.active)||s?o=Dh.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 ls(l.source,0):l));for(let l of t.effects)l.is(qge)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new sx(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kat:Jat}}function Hat(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 Kat={"aria-autocomplete":"list"},Jat={};function dM(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const eot=[];function jge(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(m8);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 ls{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=jge(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ls(i.source,0)),r&4&&i.state==0&&(i=new ls(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(ox))i=new ls(i.source,1,a.value);else if(a.is(ny))i=new ls(i.source,0);else if(a.is(g8))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(Bd(t.state))}}class dp extends ls{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=Bd(t.state);if(s>o||!i||n&2&&(Bd(t.startState)==this.from||s<this.limit))return new ls(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return tot(i.validFor,t.state,a,o)?new dp(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new p8(t.state,s,!1)))?new dp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Bd(t.state)):new ls(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new dp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ls(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function tot(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Ege(e,!0).test(i)}const g8=jn.define({map(e,t){return e.map(n=>n.map(t))}}),qge=jn.define(),Ga=Ka.define({create(){return sx.start()},update(e,t){return e.update(t)},provide:e=>[l8.from(e,t=>t.tooltip),bt.contentAttributes.from(e,t=>t.attrs)]});function $8(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ga).active.find(i=>i.source==t.source);return r instanceof dp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Gat(e.state,n,r.from,r.to)),{annotations:m8.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const not=Lat(Ga,$8);function sw(e,t="option"){return n=>{let r=n.state.field(Ga,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ei).interactionDelay)return!1;let i=1,a;t=="page"&&(a=ige(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:qge.of(s)}),!0}}const rot=e=>{let t=e.state.field(Ga,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ei).interactionDelay?!1:$8(e,t.open.options[t.open.selected])},fM=e=>e.state.field(Ga,!1)?(e.dispatch({effects:ox.of(!0)}),!0):!1,iot=e=>{let t=e.state.field(Ga,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:ny.of(null)}),!0)};class aot{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const oot=50,sot=1e3,lot=Si.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(Ga).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ga),n=e.state.facet(Ei);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ga)==t)return;let r=e.transactions.some(a=>{let o=jge(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>oot&&Date.now()-o.time>sot){for(let s of o.context.abortListeners)try{s()}catch(l){Za(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(ox)))&&(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(Ga);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(Ei).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Bd(t),r=new p8(t,n,e.explicit,this.view),i=new aot(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:ny.of(null)}),Za(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(Ei).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ei),r=this.view.state.field(Ga);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=Bd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new dp(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 ls(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:g8.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ga,!1);if(t&&t.tooltip&&this.view.state.facet(Ei).closeOnBlur){let n=t.open&&ige(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:ny.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ox.of(!1)}),20),this.composing=0}}}),cot=typeof navigator=="object"&&/Win/.test(navigator.platform),uot=IO.highest(bt.domEventHandlers({keydown(e,t){let n=t.state.field(Ga,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(cot&&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&&$8(t,r),!1}})),Cge=bt.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 Oot{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class y8{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ii.TrackDel),r=t.mapPos(this.to,1,Ii.TrackDel);return n==null||r==null?null:new y8(this.field,n,r)}}class v8{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(Lk);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 y8(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 Oot(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 v8(r,i)}}let dot=On.widget({widget:new class extends ku{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),fot=On.mark({class:"cm-snippetField"});class Nm{constructor(t,n){this.ranges=t,this.active=n,this.deco=On.set(t.map(r=>(r.from==r.to?dot:fot).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 Nm(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 Xv=jn.define({map(e,t){return e&&e.map(t)}}),hot=jn.define(),ry=Ka.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Xv))return n.value;if(n.is(hot)&&e)return new Nm(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=>bt.decorations.from(e,t=>t?t.deco:On.none)});function b8(e,t){return Ye.create(e.filter(n=>n.field==t).map(n=>Ye.range(n.from,n.to)))}function pot(e){let t=v8.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:er.of(o)},scrollIntoView:!0,annotations:r?[m8.of(r),Di.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=b8(s,0)),s.some(u=>u.field>0)){let u=new Nm(s,0),O=c.effects=[Xv.of(u)];n.state.field(ry,!1)===void 0&&O.push(jn.appendConfig.of([ry,vot,bot,Cge]))}n.dispatch(n.state.update(c))}}function Age(e){return({state:t,dispatch:n})=>{let r=t.field(ry,!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:b8(r.ranges,i),effects:Xv.of(a?null:new Nm(r.ranges,i)),scrollIntoView:!0})),!0}}const mot=({state:e,dispatch:t})=>e.field(ry,!1)?(t(e.update({effects:Xv.of(null)})),!0):!1,got=Age(1),$ot=Age(-1),yot=[{key:"Tab",run:got,shift:$ot},{key:"Escape",run:mot}],hM=Ot.define({combine(e){return e.length?e[0]:yot}}),vot=IO.highest(Dk.compute([hM],e=>e.facet(hM)));function Qr(e,t){return Object.assign(Object.assign({},t),{apply:pot(e)})}const bot=bt.domEventHandlers({mousedown(e,t){let n=t.state.field(ry,!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:b8(n.ranges,i.field),effects:Xv.of(n.ranges.some(a=>a.field>i.field)?new Nm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),iy={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Cd=jn.define({map(e,t){let n=t.mapPos(e,-1,Ii.TrackAfter);return n??void 0}}),w8=new class extends mf{};w8.startSide=1;w8.endSide=-1;const zge=Ka.define({create(){return En.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(Cd)&&(e=e.update({add:[w8.range(n.value,n.value+1)]}));return e}});function vOn(){return[Sot,zge]}const JT="()[]{}<>«»»«[]{}";function Uge(e){for(let t=0;t<JT.length;t+=2)if(JT.charCodeAt(t)==e)return JT.charAt(t+1);return Ipe(e<128?e:e+1)}function Wge(e,t){return e.languageDataAt("closeBrackets",t)[0]||iy}const wot=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Sot=bt.inputHandler.of((e,t,n,r)=>{if((wot?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Wc(yo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Qot(e.state,r);return a?(e.dispatch(a),!0):!1}),xot=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Wge(e,e.selection.main.head).brackets||iy.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=kot(e.doc,o.head);for(let l of r)if(l==s&&Kk(e.doc,o.head)==Uge(yo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ye.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},bOn=[{key:"Backspace",run:xot}];function Qot(e,t){let n=Wge(e,e.selection.main.head),r=n.brackets||iy.brackets;for(let i of r){let a=Uge(yo(i,0));if(t==i)return a==i?Tot(e,i,r.indexOf(i+i+i)>-1,n):Pot(e,i,a,n.before||iy.before);if(t==a&&Nge(e,e.selection.main.from))return _ot(e,i,a)}return null}function Nge(e,t){let n=!1;return e.field(zge).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function Kk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Wc(yo(n,0)))}function kot(e,t){let n=e.sliceString(t-2,t);return Wc(yo(n,0))==n.length?n:n.slice(1)}function Pot(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:Cd.of(o.to+t.length),range:Ye.range(o.anchor+t.length,o.head+t.length)};let s=Kk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Cd.of(o.head+t.length),range:Ye.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function _ot(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&Kk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ye.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function Tot(e,t,n,r){let i=r.stringPrefixes||iy.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Cd.of(s.to+t.length),range:Ye.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=Kk(e.doc,l),u;if(c==t){if(pM(e,l))return{changes:{insert:t+t,from:l},effects:Cd.of(l+t.length),range:Ye.cursor(l+t.length)};if(Nge(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ye.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=mM(e,l-2*t.length,i))>-1&&pM(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Cd.of(l+t.length),range:Ye.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ss.Word&&mM(e,l,i)>-1&&!Rot(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Cd.of(l+t.length),range:Ye.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function pM(e,t){let n=tr(e).resolveInner(t+1);return n.parent&&n.from==t}function Rot(e,t,n,r){let i=tr(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 mM(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ss.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))!=ss.Word)return a}return-1}function wOn(e={}){return[uot,Ga,Ei.of(e),lot,Eot,Cge]}const Xot=[{key:"Ctrl-Space",run:fM},{mac:"Alt-`",run:fM},{key:"Escape",run:iot},{key:"ArrowDown",run:sw(!0)},{key:"ArrowUp",run:sw(!1)},{key:"PageDown",run:sw(!0,"page")},{key:"PageUp",run:sw(!1,"page")},{key:"Enter",run:rot}],Eot=IO.highest(Dk.computeN([Ei],e=>e.facet(Ei).defaultKeymap?[Xot]:[]));class lx{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new lx(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=[[Yt.contextHash,i]]}addChild(t,n){t.prop(Yt.contextHash)!=this.hash&&(t=new gn(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 gn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new gn(Oi.none,i,a,o,this.hashProp)})}}var Ie;(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"})(Ie||(Ie={}));class jot{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let qot=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 D0(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 gM(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==Ie.OrderedList?Q8:x8)(n,t,!1);return r>0&&(e.type!=Ie.BulletList||S8(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const Gge={[Ie.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(Pn(Ie.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ws(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ie.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ie.OrderedList]:gM,[Ie.BulletList]:gM,[Ie.Document](){return!0}};function ws(e){return e==32||e==9||e==10||e==13}function D0(e,t=0){for(;t<e.length&&ws(e.charCodeAt(t));)t++;return t}function $M(e,t,n){for(;t>n&&ws(e.charCodeAt(t-1));)t--;return t}function Yge(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 Ige(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function S8(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(!ws(a))return-1}return n&&e.next==45&&Vge(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Bge.SetextHeading)>-1||r<3?-1:1}function Zge(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function x8(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ws(e.text.charCodeAt(e.pos+1)))&&(!n||Zge(t,Ie.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Q8(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&&!ws(e.text.charCodeAt(r+1))||n&&!Zge(t,Ie.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Dge(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 Vge(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&&ws(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const wC=/^[ \t]*$/,Mge=/-->/,Lge=/\?>/,SC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Mge],[/^\s*<\?/,Lge],[/^\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,wC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,wC]];function Fge(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=SC.length-(n?1:0);i<a;i++)if(SC[i][0].test(r))return i;return-1}function yM(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 Od(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ie.CodeText?e[r].to=n:e.push(Pn(Ie.CodeText,t,n))}const lw={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(Od(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){Od(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==Ie.CodeText?Od(o,c.from,c.to):o.push(c);s=[]}Od(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&&Od(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ie.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ie.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Yge(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=$M(t.text,t.text.length,o),l=[Pn(Ie.CodeMark,r,r+a)];o<s&&l.push(Pn(Ie.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(Pn(Ie.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||Od(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&&Od(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ie.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Ige(t);return n<0?!1:(e.startContext(Ie.Blockquote,t.pos),e.addNode(Ie.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(S8(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ie.HorizontalRule,n),!0},BulletList(e,t){let n=x8(t,e,!1);if(n<0)return!1;e.block.type!=Ie.BulletList&&e.startContext(Ie.BulletList,t.basePos,t.next);let r=yM(t,t.pos+1);return e.startContext(Ie.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ie.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Q8(t,e,!1);if(n<0)return!1;e.block.type!=Ie.OrderedList&&e.startContext(Ie.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=yM(t,t.pos+n);return e.startContext(Ie.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ie.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Dge(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=$M(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!ws(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ie.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ie.HeaderMark,o-r,a-r);let l=s.finish(Ie.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=Fge(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=SC[n][1],a=[],o=i!=wC;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==Mge?Ie.CommentBlock:i==Lge?Ie.ProcessingInstructionBlock:Ie.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class Cot{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+`
819
819
  `+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)&&D0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,Pn(Ie.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(a0e(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(Pn(Ie.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(r0e(t,D0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=D0(t,this.pos),r=0;if(n>this.pos){let i=i0e(t,n,this.start);if(i){let a=e2(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=e2(t,this.pos)),r>0&&r<t.length?r:-1}else return e2(t,this.pos)}}}function e2(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!ws(n))return-1}return t}class Aot{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:Vge(n),a=n.next;if(i<0)return!1;let o=Pn(Ie.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,Pn(a==61?Ie.SetextHeading1:Ie.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const Bge={LinkReference(e,t){return t.content.charCodeAt(0)==91?new Cot(t):null},SetextHeading(){return new Aot}},zot=[(e,t)=>Dge(t)>=0,(e,t)=>Yge(t)>=0,(e,t)=>Ige(t)>=0,(e,t)=>x8(t,e,!0)>=0,(e,t)=>Q8(t,e,!0)>=0,(e,t)=>S8(t,e,!0)>=0,(e,t)=>Fge(t,e,!0)>=0],Uot={text:"",end:0};class Wot{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new qot,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=lx.create(Ie.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new Iot(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 jot(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+=`
820
820
  `+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=o0e(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=Uot;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 "+Ie[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==`
821
821
  `?"":n;else{let i=n.indexOf(`
@@ -844,7 +844,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
844
844
  `,o.end),l=t.slice(o.end,s===-1?t.length:s);if(JTt.test(l))return Ya;const c=l.length-l.replace(e2t,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+Bp(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]===jP?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const _l=e=>e.typingAt!==null,a2t=e=>e.arm!==null;function Hf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+Bp(e.value).length}}function TU(e,t,n,r){const i=Hf(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=Bp(e.value),c=k7(a-i.start,0,l.length),u=k7(o-i.start,0,l.length),O=Bp(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),f=a+O.length,p=t.slice(0,a)+WSe.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 IH(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=_l(e)&&e.value===""&&r.startsWith("-");if(_l(e)&&(a||r.includes(`
845
845
  `))){const o=zx(e);return r.includes(`
846
846
  `)?{...i,capture:o}:{...i,capture:Lh(o,i.buffer,i.caret,"typing")}}return TU(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function zx(e){return _l(e)?{arm:e.arm,typingAt:null,value:""}:e}function o2t(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 s2t(e,t,n,r,i){const a=o2t(t,n),o=Hf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:zx(e),buffer:n,caret:r};else{const l=TU(e,n,r,a);l?s=l:_l(e)&&a.inserted.includes(`
847
- `)&&(s={capture:zx(e),buffer:n,caret:r})}return{...s,capture:Lh(s.capture,s.buffer,s.caret,i)}}function l2t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Hf(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=LSe(i,t.value),c=l+jP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ya,buffer:u,caret:s+c.length,payload:{index:i,key:KSe(a,e.draw),value:t.value,marker:l}}}function c2t(e,t){const n=Hf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=HSe(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ya,buffer:i,caret:n.start+r.length,restored:Q7(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:Q7(r),restoredText:r}}}function ZH(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function u2t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Hf(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:zx(e),buffer:i,caret:a,payload:null}}function O2t(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=TU(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=wn(i);if(!a)return i===""?null:u2t(t,n,e.selection,i);const o=t.arm,s=LSe(e.index,a),l=s+jP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ya,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:KSe(e.taken,e.draw),value:a,marker:s}}}const MSe=e=>`${Q7(e)} chars`,LSe=(e,t)=>`[Credential #${e}, ${MSe(t)}]`;function d2t(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 f2t(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 Iv(e,t){if(d2t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const vR=/\[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,bR=/\[credential NOT stored \u2014 [^\]\n]*\]/y,wR=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,h2t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&x7.test(t[1])?t[1]:""};function p2t(e,t){if(e.charCodeAt(t)!==91)return null;vR.lastIndex=t;const n=vR.exec(e);if(vR.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};bR.lastIndex=t;const r=bR.exec(e);if(bR.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};wR.lastIndex=t;const i=wR.exec(e);return wR.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:h2t(i[0])}:null}function qP(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=p2t(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 DH(e,t){const n=[];for(const r of t){const i=Iv(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 m2t(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 g2t=e=>`[credential ${e.key} (${MSe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function $2t(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Iv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of ISe(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?m2t(l??"lost",s?.key):g2t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const y2t=(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.`,v2t=e=>`Remove credential #${e}`,b2t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,w2t=(e,t,n)=>y2t(e,t,n),S2t="Undo",x2t=e=>`Credential #${e} removed`,Q2t=e=>e.unredacted!==null?e.unredacted:e.armed?E2t:e.cleared!==null?w2t(e.cleared.key,e.cleared.index,e.undoCap):null;function k2t(e){const{buffer:t,payload:n}=e,r=Iv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===jP?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 P2t(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 VH=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function MH(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 _2t="store unconfirmed",T2t="Credential store unconfirmed",R2t=e=>e===""?T2t:`${e} · ${_2t}`,FSe="Paste the value again after /credential to store it again.",X2t=e=>`${e} ${FSe}`;function LH(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. ${FSe}`}const E2t="armed — add a space, then type or paste the secret",j2t="masked as you type — Enter turns it into a pill, Esc cancels",q2t="masked — Enter opens the credential picker; type or paste the secret into this span",C2t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",BSe="\0held",A2t=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===BSe?`${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 HSe(e,t){const n=Hf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const FH=(e,t)=>e&&e.over===t?e.chars:null,z2t=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},U2t=16,W2t=16;function KSe(e=[],t=z2t){const n=new Set(e);for(let r=0;r<U2t;r++){const i=GH+BH(8,t);if(!n.has(i))return i}return GH+BH(W2t,t)}const BH=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=NH[t(NH.length)];return n},JSe=j("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),exe=j("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),txe=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>h.jsxs("span",{className:j("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?exe:JSe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(Dse,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(c9e,{"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(Li,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),vy="#lo-credential/",N2t=`${vy}unstored`,HH=`${vy}unconfirmed`,G2t=/^\d+$/,nxe=e=>e.kind==="stored"?`${vy}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${HH}/${e.key}`:HH:N2t;function Y2t(e){if(!e||!e.startsWith(vy))return null;const t=e.slice(vy.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return x7.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!x7.test(r)||!G2t.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function KH(e,t){const n=Y2t(e);if(n===null)return null;const r=qP(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return nxe(i)!==e?null:n}const CP=()=>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=qP(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:nxe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},I2t=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?R2t(e.key):"Credential not stored",Z2t=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?X2t(t):t,D2t=({citation:e,title:t})=>h.jsx(txe,{tone:e.kind==="stored"?"live":"warning",label:I2t(e),chars:e.kind==="stored"?e.chars:null,title:Z2t(e,t),className:"align-middle"}),V2t=(e,t)=>typeof t=="string"?KH(e,t):t==null?KH(e,""):null,M2t=e=>({href:t,title:n,children:r})=>{const i=V2t(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(D2t,{citation:i,title:n})},rxe=e=>e.startsWith("data:")?"data":e.startsWith("blob:")?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",ixe=e=>{const t=rxe(e);return t==="other"?"path":t},L2t={id:"open-file",label:"Open file"},F2t={id:"show-in-canvas",label:"Show in canvas"},B2t={id:"open-folder",label:"Open folder"},H2t={id:"copy-file-path",label:"Copy file path"},Nw={id:"copy-image",label:"Copy image"},K2t={id:"copy-image-url",label:"Copy image URL"},J2t={id:"open-in-browser",label:"Open in browser"};function axe(e,{canShowInCanvas:t,source:n}){const r=t?[F2t]:[];switch(e){case"path":return[...r,L2t,B2t,H2t,Nw];case"data":return[...r,Nw];case"blob":return[Nw];case"http":return[...eRt(n)?[Nw]:[],K2t,J2t];case"other":return[]}}const oxe=(e,t)=>axe(e,t).length>0;function eRt(e){try{const t=new URL(e),n=t.hostname==="localhost"||t.hostname==="127.0.0.1";return t.protocol==="http:"&&n&&(t.port==="1111"||t.port==="8080")}catch{return!1}}const RU=e=>e.startsWith("file://")?e.slice(7):e;function tRt(e){const t=e.indexOf(",");if(t===-1)throw new Error("Malformed data URL");const n=e.slice(5,t),r=e.slice(t+1),i=n.split(";")[0]||"application/octet-stream";if(n.endsWith(";base64")){const s=atob(r),l=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)l[c]=s.charCodeAt(c);return new Blob([l],{type:i})}const a=decodeURIComponent(r),o=new Uint8Array(a.length);for(let s=0;s<a.length;s+=1)o[s]=a.charCodeAt(s);return new Blob([o],{type:i})}async function nRt(e,t,n){if(e==="data")return tRt(t);if(e==="blob"){const o=bZe(n??t);if(o===null)throw new Error("These image bytes are not available in this window");return o}if(e==="http"){const o=await fetch(n??t);if(!o.ok)throw new Error(`The image server answered ${o.status}`);return o.blob()}const r=window.api?.readFileBytes;if(typeof r!="function")throw new Error("This window cannot read local files");const i=RU(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:jde(i)})}const rRt=e=>e.trim().toLowerCase()!=="image/png";async function iRt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!rRt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await aRt(t);if(n.naturalWidth===0||n.naturalHeight===0)throw new Error("This image could not be decoded for the clipboard");const r=document.createElement("canvas");r.width=n.naturalWidth,r.height=n.naturalHeight;const i=r.getContext("2d");if(i===null)throw new Error("This window cannot re-encode the image for the clipboard");i.drawImage(n,0,0);const a=await new Promise(o=>{r.toBlob(o,"image/png")});if(a===null)throw new Error("This image could not be re-encoded for the clipboard");return a}finally{URL.revokeObjectURL(t)}}function aRt(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("This image could not be decoded for the clipboard")),r.src=e})}const oRt={"open-file":h.jsx(fv,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(pue,{"aria-hidden":"true"}),"open-folder":h.jsx(_p,{"aria-hidden":"true"}),"copy-file-path":h.jsx(lue,{"aria-hidden":"true"}),"copy-image":h.jsx(mk,{"aria-hidden":"true"}),"copy-image-url":h.jsx(f9e,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Oue,{"aria-hidden":"true"})},sxe=({file:e,src:t,label:n,onShowInCanvas:r,tooltip:i="Image actions","aria-label":a})=>{const o=ixe(e),s=axe(o,{canShowInCanvas:!!r,source:t??e});if(s.length===0)return null;const l=async(d,f,p)=>{try{await navigator.clipboard.writeText(d),uf(f)}catch(m){console.error(`${p}: `,m),Mi(p)}},c=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const d=await nRt(o,e,t),f=await iRt(d);await navigator.clipboard.write([new ClipboardItem({[f.type]:f})]),uf("Image copied to clipboard")}catch(d){console.error("Failed to copy image: ",d),Mi("Failed to copy image")}},u=d=>{const f=RU(e);switch(d.id){case"open-file":AO(f);return;case"open-folder":SU(f);return;case"show-in-canvas":r?.();return;case"copy-file-path":l(f,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":c();return;case"copy-image-url":l(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":xU(t??e);return}},O=a??`Actions for ${n??"this image"}`;return h.jsxs(EA,{children:[h.jsx(Ut,{content:i,children:h.jsx(jA,{asChild:!0,children:h.jsx(Ae,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":O,onClick:d=>d.stopPropagation(),children:h.jsx(uue,{"aria-hidden":"true"})})})}),h.jsx(qA,{align:"end",className:"min-w-45",onClick:d=>d.stopPropagation(),children:s.map(d=>h.jsxs(Tl,{onSelect:()=>u(d),children:[oRt[d.id],h.jsx("span",{children:d.label})]},d.id))})]})},sRt=({src:e,alt:t,title:n,className:r})=>{const i=_P(),a=e??"",o=rxe(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=oxe(o,{canShowInCanvas:s,source:a});return h.jsxs("span",{className:j("group/mdimg relative inline-block max-w-full"),children:[h.jsx("img",{src:e,alt:t,title:n,className:r}),l&&h.jsx("span",{"data-markdown-image":"",className:j("pointer-events-none absolute top-1 right-1 z-[2] opacity-0","transition-opacity duration-fast ease-out-quart","group-hover/mdimg:pointer-events-auto group-hover/mdimg:opacity-100","group-focus-within/mdimg:pointer-events-auto group-focus-within/mdimg:opacity-100","has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100"),children:h.jsx(sxe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||AO(RU(a))})}:void 0})})]})};function lRt(){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 cRt={tokenize:uRt,concrete:!0,name:"mathFlow"},JH={tokenize:ORt,partial:!0};function uRt(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"),un(e,c,"whitespace")(v))}function c(v){return v===null||$t(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||$t(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(JH,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,f)(v)}function f(v){return(a?un(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):$t(v)?e.attempt(JH,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||$t(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,w,x){let b=0;return un(v,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(T){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(T)}function Q(T){return T===36?(b++,v.consume(T),Q):b<o?x(T):(v.exit("mathFlowFenceSequence"),un(v,P,"whitespace")(T))}function P(T){return T===null||$t(T)?(v.exit("mathFlowFence"),w(T)):x(T)}}}function ORt(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 dRt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:fRt,previous:hRt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):$t(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),f(m))}function f(m){return m===null||m===32||m===36||$t(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),f)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",f(m))}}}function fRt(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 hRt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function pRt(e){return{flow:{36:cRt},text:{36:dRt()}}}const Fh=36,eK=e=>e!==null&&e<-2,tK=e=>e===null||e===32||e<0,nK=e=>e!==null&&e>=48&&e<=57,lxe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:mRt,previous:gRt,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===Fh?(r.consume(g),s++,d):s<2&&!t||s===1&&(tK(g)||nK(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===Fh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):eK(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===Fh||eK(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===Fh?(r.consume(g),c++,m):c===s?s===1&&(tK(l)||nK(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function mRt(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 gRt(e){return e!==Fh||this.events[this.events.length-1][1].type==="characterEscape"}const $Rt=pRt().flow,yRt=lxe();function AP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?yRt:lxe(e);n.push({flow:$Rt,text:{[Fh]:i}}),r.push(lRt())}const vRt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),bRt=/\$(?!\d)(.+?)\$/,wRt=/\$\$([\s\S]+?)\$\$/,SRt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,xRt=/\\[a-zA-Z]+(\{[^}]*\})?/,rK=e=>bRt.test(e)||wRt.test(e)||SRt.test(e)?!0:xRt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),QRt=e=>{const t=qP(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},kRt=e=>qP(e).filter(t=>t.kind!=="text").length,PRt=e=>{if(!rK(e))return!1;const t=QRt(e);return t===null?!0:rK(t)||t.includes("$")?!1:kRt(e)<2},tn="var(--color-ink)",gc="var(--color-ink-muted)",gl="var(--color-surface)",Zu="var(--color-elevated)",$c="var(--color-sunken)",Hi="var(--color-hairline)",Du="var(--color-control)",xh="var(--color-accent)",v0="var(--color-accent-wash)",_Rt="var(--color-accent-alt-wash)",TRt="var(--color-on-accent)",RRt="var(--color-info)",cxe="var(--color-info-wash)",XRt="var(--color-success)",uxe="var(--color-success-wash)",ERt="var(--color-warning)",P7="var(--color-warning-wash)",jRt="var(--color-warning-border)",SR="var(--color-danger)",_7="var(--color-danger-wash)",iK=[v0,_Rt,cxe,uxe,P7,_7],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),qRt=()=>{const e={primaryColor:Vu("--color-accent"),secondaryColor:Vu("--color-success"),tertiaryColor:Vu("--color-info"),mainBkg:Vu("--color-elevated"),clusterBkg:Vu("--color-sunken"),clusterBorder:Vu("--color-hairline"),edgeLabelBackground:Vu("--color-surface"),quadrant1Fill:Vu("--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:gl,primaryTextColor:tn,primaryBorderColor:Du,secondaryTextColor:tn,secondaryBorderColor:Hi,tertiaryTextColor:tn,tertiaryBorderColor:Hi,lineColor:gc,arrowheadColor:gc,textColor:tn,secondBkg:$c,border1:Du,border2:Hi,labelColor:tn,nodeBkg:Zu,nodeBorder:Du,nodeTextColor:tn,defaultLinkColor:gc,titleColor:tn,noteBkgColor:P7,noteBorderColor:jRt,noteTextColor:tn,actorBkg:Zu,actorBorder:Du,actorTextColor:tn,actorLineColor:Hi,signalColor:gc,signalTextColor:tn,labelBoxBkgColor:Zu,labelBoxBorderColor:Hi,labelTextColor:tn,loopTextColor:tn,activationBkgColor:v0,activationBorderColor:xh,sequenceNumberColor:gl,sectionBkgColor:$c,sectionBkgColor2:gl,altSectionBkgColor:$c,excludeBkgColor:$c,taskBkgColor:v0,taskBorderColor:Du,taskTextColor:tn,taskTextLightColor:tn,taskTextDarkColor:tn,taskTextOutsideColor:tn,taskTextClickableColor:xh,activeTaskBkgColor:v0,activeTaskBorderColor:xh,gridColor:Hi,doneTaskBkgColor:$c,doneTaskBorderColor:Hi,critBkgColor:_7,critBorderColor:SR,todayLineColor:xh,transitionColor:gc,transitionLabelColor:tn,stateLabelColor:tn,stateBkg:Zu,labelBackgroundColor:gl,compositeBackground:$c,altBackground:$c,compositeTitleBackground:Zu,compositeBorder:Hi,innerEndBackground:tn,specialStateColor:tn,classText:tn,attributeBackgroundColorOdd:gl,attributeBackgroundColorEven:$c,rowOdd:gl,rowEven:$c,errorBkgColor:_7,errorTextColor:SR,pieTitleTextColor:tn,pieSectionTextColor:tn,pieLegendTextColor:tn,pieStrokeColor:gl,pieOuterStrokeColor:Hi,requirementBackground:Zu,requirementBorderColor:Du,requirementTextColor:tn,relationColor:gc,relationLabelBackground:gl,relationLabelColor:tn,branchLabelColor:TRt,commitLabelColor:tn,commitLabelBackground:gl,tagLabelColor:tn,tagLabelBackground:v0,tagLabelBorder:Du,quadrant2Fill:cxe,quadrant3Fill:uxe,quadrant4Fill:P7,quadrant2TextFill:tn,quadrant3TextFill:tn,quadrant4TextFill:tn,quadrantPointFill:xh,archEdgeColor:gc,archEdgeArrowColor:gc,archGroupBorderColor:Hi,scaleLabelColor:tn,packet:{startByteColor:tn,endByteColor:tn,labelColor:tn,titleColor:tn,blockStrokeColor:Du,blockFillColor:Zu},radar:{axisColor:gc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Hi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:gl,titleColor:tn,xAxisTitleColor:tn,xAxisLabelColor:tn,xAxisTickColor:Hi,xAxisLineColor:Hi,yAxisTitleColor:tn,yAxisLabelColor:tn,yAxisTickColor:Hi,yAxisLineColor:Hi,plotColorPalette:[xh,RRt,XRt,ERt,SR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Zu,t[`surfacePeer${n}`]=Hi;for(let n=0;n<8;n++)t[`fillType${n}`]=iK[n%iK.length];return{...t,...e}};let xR=null,aK=null;const CRt=async e=>{xR||(xR=he(async()=>{const{default:n}=await import("./mermaid.core-C9rYU-0l.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,2,3]),import.meta.url).then(({default:n})=>n));const t=await xR;return aK!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:qRt()}),aK=e),t},oK=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:j("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(Ut,{content:"Zoom in",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(kue,{})})}),h.jsx(Ut,{content:"Zoom out",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(Pue,{})})}),h.jsx(Ut,{content:"Drag the diagram to pan",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(E9e,{})})}),h.jsx(Ut,{content:"Reset view",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(yk,{})})}),h.jsx(Ut,{content:"Save as SVG",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(gk,{})})}),h.jsx(Ut,{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(mk,{className:j(t&&"text-success")})})}),s]}),T7=({title:e,children:t})=>h.jsxs(Yl,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(k0,{children:e}),h.jsx(P0,{children:t})]});class ARt extends $.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(T7,{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 zRt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,f]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,w]=$.useState({x:0,y:0}),[x,b]=$.useState("idle"),[S,Q]=$.useState("idle"),P=ar(z=>z.themeName),T=$.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const z=await CRt(P),ie=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:F}=await z.render(ie,e);if(!F||typeof F!="string"||F.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(F)}catch(z){console.error("Mermaid rendering error:",z);const ie=z instanceof Error?z.message:"Failed to render mermaid diagram";a(ie),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{T().catch(z=>{console.error("Error in renderDiagram effect:",z),a("Failed to initialize diagram rendering"),s(!1)})},[T]);const _=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ie=r.current.getBoundingClientRect(),F=document.createElement("div");F.innerHTML=l;const H=F.querySelector("svg");if(!H)return 1;const oe=H.getBoundingClientRect?.()?.width||Number.parseFloat(H.getAttribute("width")||"0")||H.viewBox?.baseVal?.width||800,L=H.getBoundingClientRect?.()?.height||Number.parseFloat(H.getAttribute("height")||"0")||H.viewBox?.baseVal?.height||600,K=ie.width*.9/oe,re=ie.height*.9/L;return Math.min(K,re,1)}catch(z){return console.error("Error calculating fullscreen scale:",z),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const z=_();m({scale:z,x:0,y:0})}catch(z){console.error("Error setting fullscreen transform:",z)}},100)},[u,l,_]);const E=$.useCallback((z=!1)=>{try{(z?m:f)(F=>({...F,scale:Math.min(F.scale*1.2,10)}))}catch(ie){console.error("Error in zoom in:",ie)}},[]),C=$.useCallback((z=!1)=>{try{(z?m:f)(F=>({...F,scale:Math.max(F.scale/1.2,.1)}))}catch(ie){console.error("Error in zoom out:",ie)}},[]),A=$.useCallback((z=!1)=>{try{const ie=z?m:f;if(z){const F=_();ie({scale:F,x:0,y:0})}else ie({scale:1,x:0,y:0})}catch(ie){console.error("Error in reset:",ie)}},[_]),U=$.useCallback(()=>{if(l)try{const z=new Blob([l],{type:"image/svg+xml"}),ie=URL.createObjectURL(z),F=document.createElement("a");F.href=ie,F.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(ie)}catch(z){console.error("Failed to save SVG:",z)}},[l]),N=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(z){console.error("Failed to copy Mermaid chart text:",z)}},[e]),Z=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(z){console.error("Failed to copy Mermaid chart text:",z)}},[e]),G=$.useCallback(z=>{try{y(!0),w({x:z.clientX,y:z.clientY}),z.preventDefault()}catch(ie){console.error("Error in mouse down:",ie)}},[]),D=$.useCallback((z,ie=!1)=>{try{if(!g)return;const F=z.clientX-v.x,H=z.clientY-v.y;(ie?m:f)(L=>({...L,x:L.x+F,y:L.y+H})),w({x:z.clientX,y:z.clientY})}catch(F){console.error("Error in mouse move:",F)}},[g,v]),I=$.useCallback(()=>{try{y(!1)}catch(z){console.error("Error in mouse up:",z)}},[]),W=$.useCallback((z,ie=!1)=>{try{z.preventDefault();const F=z.deltaY>0?.9:1.1;(ie?m:f)(oe=>({...oe,scale:Math.min(Math.max(oe.scale*F,.1),5)}))}catch(F){console.error("Error in wheel:",F)}},[]),J=$.useCallback(z=>{try{O(z)}catch(ie){console.error("Error toggling fullscreen:",ie)}},[]);if(i)return h.jsxs(T7,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:j("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:j("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const ee=(z=!1)=>{try{const ie=z?r:n,F=z?p:d;return h.jsx("div",{ref:ie,className:j("mermaid flex w-full items-center justify-center",z?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:G,onMouseMove:H=>D(H,z),onMouseUp:I,onMouseLeave:I,onWheel:H=>W(H,z),children:o?h.jsx("div",{className:j("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:j("flex h-full w-full items-center justify-center"),style:{transform:`translate(${F.x}px, ${F.y}px) scale(${F.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ie){return console.error("Error rendering diagram content:",ie),h.jsx(T7,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:j("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[ee(!1),h.jsx(oK,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>C(!1),onReset:()=>A(!1),onSave:U,onCopy:N,children:h.jsx(Ut,{content:"Fullscreen",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>J(!0),children:h.jsx(S9e,{})})})})]}),h.jsx(j$,{open:u,onClose:()=>J(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:j("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[ee(!0),h.jsx(oK,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>C(!0),onReset:()=>A(!0),onSave:U,onCopy:Z,children:h.jsx(Ut,{content:"Close fullscreen",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>J(!1),children:h.jsx(Li,{})})})})]})})]})}),URt=$.memo(e=>h.jsx(ARt,{children:h.jsx(zRt,{...e})}));let Oxe=!1,QR=null;const WRt=()=>(QR||(QR=he(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(Oxe=!0,e))),QR),NRt=/language-(\w+)/,GRt=/\n$/,dxe=({href:e,children:t})=>{const n=ySe(e),r=_P();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=>ZRt(i,r):void 0,children:t})},YRt=e=>ySe(e)?.kind==="file",IRt=xSe,ZRt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(SSe)??"file",i=n.getAttribute(IRt),a=oTt({kind:r,hasHighlight:bTt(n),canOpenInCanvas:wU(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||AO(i)});return}AO(i)}},fxe=(e,t)=>t==="href"&&YRt(e)?e:Ife(e),XU={a:dxe,table:vRt,img:sRt,code:({node:e,className:t,children:n,...r})=>NRt.exec(t??"")?.[1]==="mermaid"?h.jsx(URt,{chart:String(n).replace(GRt,"")}):h.jsx("code",{className:t,...r,children:n})},DRt={...XU,a:M2t(dxe)},VRt=[YO],MRt=[YO,AP],LRt=[YO,TP],FRt=[YO,AP,TP],BRt=[YO,CP,RP],HRt=[YO,AP,CP,RP],KRt=[YO,TP,CP,RP],JRt=[YO,AP,TP,CP,RP],eXt={"000":VRt,"001":BRt,"010":LRt,"011":KRt,100:MRt,101:HRt,110:FRt,111:JRt},tXt=[],nXt=[OJe],hxe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),pxe=(e,t,n)=>{const r=$.useMemo(()=>PRt(e),[e]),[i,a]=$.useState(Oxe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return WRt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:eXt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?nXt:tXt}},mxe=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=Gtt(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=lTt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return wSe(r,window.api?.probeFiles,gle).then(()=>{i&&r.some(s=>bSe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},zP=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=pxe(a,r,i),l=hxe(t);return mxe(a,r),h.jsx("div",{className:j("lo-markdown",n),style:l,children:h.jsx(Yfe,{remarkPlugins:o,rehypePlugins:s,urlTransform:fxe,components:i?DRt:XU,children:a})})});zP.displayName="MarkdownRenderer";const gxe=$.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=pxe(e,!0,!1);return mxe(e,!0),h.jsx(Yfe,{remarkPlugins:t,rehypePlugins:n,urlTransform:fxe,components:XU,children:e})});gxe.displayName="StableBlock";const $xe=$.memo(({text:e,animate:t})=>h.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));$xe.displayName="ArrivedText";const yxe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=QTt());const i=r.current,a=$.useRef([]),o=$.useRef(0);TTt(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+RTt(e.slice(l)),d=[{offset:l,animate:!1}];for(const p of c){if(p.offset>=O)break;d.push(p)}const f=hxe(t);return h.jsxs("div",{className:j("lo-markdown",n),style:f,children:[i.blocks.map((p,m)=>h.jsx(gxe,{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($xe,{text:e.slice(p.offset,g),animate:p.animate},p.offset)})})]})};yxe.displayName="StreamingMarkdown";const To=({isUser:e,children:t,className:n})=>e?h.jsx("div",{className:j("flex w-full justify-end",n),children:t}):h.jsx("div",{className:j("group relative w-full",n),children:t}),EU=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},rXt=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 jU=EU(Date.now()),rO=null;const H1=new Set,vxe=()=>{rO!==null&&clearTimeout(rO),rO=setTimeout(()=>{rO=null,jU=EU(Date.now());for(const e of H1)e();vxe()},rXt(Date.now())),rO.unref?.()},iXt=e=>(H1.add(e),jU=EU(Date.now()),vxe(),()=>{H1.delete(e),H1.size===0&&rO!==null&&(clearTimeout(rO),rO=null)}),sK=()=>jU,aXt=()=>$.useSyncExternalStore(iXt,sK,sK),oXt=e=>new Date(e+1e3),sXt=()=>oXt(aXt());function kR(e,t){const n=t&&t.cache?t.cache:hXt,r=t&&t.serializer?t.serializer:dXt;return(t&&t.strategy?t.strategy:uXt)(e,{cache:n,serializer:r})}function lXt(e){return e==null||typeof e=="number"||typeof e=="boolean"}function cXt(e,t,n,r){const i=lXt(r)?r:n(r);let a=t.get(i);return typeof a>"u"&&(a=e.call(this,r),t.set(i,a)),a}function bxe(e,t,n){const r=Array.prototype.slice.call(arguments,3),i=n(r);let a=t.get(i);return typeof a>"u"&&(a=e.apply(this,r),t.set(i,a)),a}function wxe(e,t,n,r,i){return n.bind(t,e,r,i)}function uXt(e,t){const n=e.length===1?cXt:bxe;return wxe(e,this,n,t.cache.create(),t.serializer)}function OXt(e,t){return wxe(e,this,bxe,t.cache.create(),t.serializer)}const dXt=function(){return JSON.stringify(arguments)};var fXt=class{constructor(){this.cache=Object.create(null)}get(e){return this.cache[e]}set(e,t){this.cache[e]=t}};const hXt={create:function(){return new fXt}},PR={variadic:OXt},pXt=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function mXt(e){const t={};return e.replace(pXt,n=>{const r=n.length;switch(n[0]){case"G":t.era=r===4?"long":r===5?"narrow":"short";break;case"y":t.year=r===2?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":t.month=["numeric","2-digit","short","long","narrow"][r-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":t.day=["numeric","2-digit"][r-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":t.weekday=r===4?"long":r===5?"narrow":"short";break;case"e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-3];break;case"c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-3];break;case"a":t.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":t.hourCycle="h12",t.hour=["numeric","2-digit"][r-1];break;case"H":t.hourCycle="h23",t.hour=["numeric","2-digit"][r-1];break;case"K":t.hourCycle="h11",t.hour=["numeric","2-digit"][r-1];break;case"k":t.hourCycle="h24",t.hour=["numeric","2-digit"][r-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":t.minute=["numeric","2-digit"][r-1];break;case"s":t.second=["numeric","2-digit"][r-1];break;case"S":case"A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case"z":t.timeZoneName=r<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return""}),t}const gXt=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function $Xt(e){if(e.length===0)throw new Error("Number skeleton cannot be empty");const t=e.split(gXt).filter(r=>r.length>0),n=[];for(const r of t){let i=r.split("/");if(i.length===0)throw new Error("Invalid number skeleton");const[a,...o]=i;for(const s of o)if(s.length===0)throw new Error("Invalid number skeleton");n.push({stem:a,options:o})}return n}function yXt(e){return e.replace(/^(.*?)-/,"")}const lK=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,Sxe=/^(@+)?(\+|#+)?[rs]?$/g,vXt=/(\*)(0+)|(#+)(0+)|(0+)/g,xxe=/^(0+)$/;function cK(e){const t={};return e[e.length-1]==="r"?t.roundingPriority="morePrecision":e[e.length-1]==="s"&&(t.roundingPriority="lessPrecision"),e.replace(Sxe,function(n,r,i){return typeof i!="string"?(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length):i==="+"?t.minimumSignificantDigits=r.length:r[0]==="#"?t.maximumSignificantDigits=r.length:(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length+(typeof i=="string"?i.length:0)),""}),t}function Qxe(e){switch(e){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":case"()":return{currencySign:"accounting"};case"sign-always":case"+!":return{signDisplay:"always"};case"sign-accounting-always":case"()!":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":case"+?":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":case"()?":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":case"+_":return{signDisplay:"never"}}}function bXt(e){let t;if(e[0]==="E"&&e[1]==="E"?(t={notation:"engineering"},e=e.slice(2)):e[0]==="E"&&(t={notation:"scientific"},e=e.slice(1)),t){const n=e.slice(0,2);if(n==="+!"?(t.signDisplay="always",e=e.slice(2)):n==="+?"&&(t.signDisplay="exceptZero",e=e.slice(2)),!xxe.test(e))throw new Error("Malformed concise eng/scientific notation");t.minimumIntegerDigits=e.length}return t}function uK(e){const t={},n=Qxe(e);return n||t}function wXt(e){let t={};for(const n of e){switch(n.stem){case"percent":case"%":t.style="percent";continue;case"%x100":t.style="percent",t.scale=100;continue;case"currency":t.style="currency",t.currency=n.options[0];continue;case"group-off":case",_":t.useGrouping=!1;continue;case"precision-integer":case".":t.maximumFractionDigits=0;continue;case"measure-unit":case"unit":t.style="unit",t.unit=yXt(n.options[0]);continue;case"compact-short":case"K":t.notation="compact",t.compactDisplay="short";continue;case"compact-long":case"KK":t.notation="compact",t.compactDisplay="long";continue;case"scientific":t={...t,notation:"scientific",...n.options.reduce((a,o)=>({...a,...uK(o)}),{})};continue;case"engineering":t={...t,notation:"engineering",...n.options.reduce((a,o)=>({...a,...uK(o)}),{})};continue;case"notation-simple":t.notation="standard";continue;case"unit-width-narrow":t.currencyDisplay="narrowSymbol",t.unitDisplay="narrow";continue;case"unit-width-short":t.currencyDisplay="code",t.unitDisplay="short";continue;case"unit-width-full-name":t.currencyDisplay="name",t.unitDisplay="long";continue;case"unit-width-iso-code":t.currencyDisplay="symbol";continue;case"scale":t.scale=parseFloat(n.options[0]);continue;case"rounding-mode-floor":t.roundingMode="floor";continue;case"rounding-mode-ceiling":t.roundingMode="ceil";continue;case"rounding-mode-down":t.roundingMode="trunc";continue;case"rounding-mode-up":t.roundingMode="expand";continue;case"rounding-mode-half-even":t.roundingMode="halfEven";continue;case"rounding-mode-half-down":t.roundingMode="halfTrunc";continue;case"rounding-mode-half-up":t.roundingMode="halfExpand";continue;case"integer-width":if(n.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");n.options[0].replace(vXt,function(a,o,s,l,c,u){if(o)t.minimumIntegerDigits=s.length;else{if(l&&c)throw new Error("We currently do not support maximum integer digits");if(u)throw new Error("We currently do not support exact integer digits")}return""});continue}if(xxe.test(n.stem)){t.minimumIntegerDigits=n.stem.length;continue}if(lK.test(n.stem)){if(n.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");n.stem.replace(lK,function(o,s,l,c,u,O){return l==="*"?t.minimumFractionDigits=s.length:c&&c[0]==="#"?t.maximumFractionDigits=c.length:u&&O?(t.minimumFractionDigits=u.length,t.maximumFractionDigits=u.length+O.length):(t.minimumFractionDigits=s.length,t.maximumFractionDigits=s.length),""});const a=n.options[0];a==="w"?t={...t,trailingZeroDisplay:"stripIfInteger"}:a&&(t={...t,...cK(a)});continue}if(Sxe.test(n.stem)){t={...t,...cK(n.stem)};continue}const r=Qxe(n.stem);r&&(t={...t,...r});const i=bXt(n.stem);i&&(t={...t,...i})}return t}let SXt=function(e){return e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG",e}({});function OK(e){return e.type===0}function xXt(e){return e.type===1}function kxe(e){return e.type===2}function Pxe(e){return e.type===3}function _xe(e){return e.type===4}function Txe(e){return e.type===5}function Rxe(e){return e.type===6}function QXt(e){return e.type===7}function Xxe(e){return e.type===8}function Exe(e){return!!(e&&typeof e=="object"&&e.type===0)}function R7(e){return!!(e&&typeof e=="object"&&e.type===1)}const jxe=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,kXt=/([^\t-\r -\/:-@\[-\^`\{-~\x85\xA0-\xA7\xA9\xAB\xAC\xAE\xB0\xB1\xB6\xBB\xBF\xD7\xF7\u1680\u2000-\u200A\u2010-\u2029\u202F-\u203E\u2041-\u2053\u2055-\u205F\u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3000-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]*)/g,Gg={"001":["H","h"],419:["h","H","hB","hb"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["h","H","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BI:["H","h"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["h","H","hB","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BY:["H","h"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["h","H","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["h","H","hB","hb"],CU:["h","H","hB","hb"],CV:["H","hB"],CW:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["h","H","hB","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FO:["H","h"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GL:["H","h"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GS:["H","h","hb","hB"],GT:["h","H","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["h","H","hB","hb"],HR:["H","hB"],HU:["H","h"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","K","h"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MG:["H","h"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MT:["H","h"],MU:["H","h"],MV:["H","h"],MW:["h","hb","H","hB"],MX:["h","H","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["h","H","hB","hb"],NL:["H","hB"],NO:["H","h"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["h","H","hB","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PL:["H","h"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["h","H","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],RW:["H","h"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["h","H","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TH:["H","h"],TJ:["H","h"],TL:["H","hB","hb","h"],TM:["H","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["h","H","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VN:["H","h"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],ZW:["H","h"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"en-HK":["h","hb","H","hB"],"en-IL":["H","h","hb","hB"],"en-MY":["h","hb","H","hB"],"es-BR":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ku-SY":["H","hB"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function PXt(e,t){let n="";for(let r=0;r<e.length;r++){const i=e.charAt(r);if(i==="j"){let a=0;for(;r+1<e.length&&e.charAt(r+1)===i;)a++,r++;let o=1+(a&1),s=a<2?1:3+(a>>1),l="a",c=_Xt(t);for((c=="H"||c=="k")&&(s=0);s-- >0;)n+=l;for(;o-- >0;)n=c+n}else i==="J"?n+="H":n+=i}return n}function _Xt(e){let t=e.hourCycle;if(t===void 0){const i=e;t=i.getHourCycles?.()[0]??i.hourCycles?.[0]}if(t)switch(t){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}const n=e.language;let r;return n!=="root"&&(r=e.maximize().region),(Gg[`${n}-${r}`]||Gg[r||""]||Gg[n||""]||Gg[`${n}-001`]||Gg["001"])[0].charAt(0)}const TXt=new RegExp(`^${jxe.source}*`),RXt=new RegExp(`${jxe.source}*$`);function xn(e,t){return{start:e,end:t}}const XXt=!!Object.fromEntries,EXt=!!String.prototype.trimStart,jXt=!!String.prototype.trimEnd,dK=XXt?Object.fromEntries:function(t){const n={};for(const[r,i]of t)n[r]=i;return n},qXt=EXt?function(t){return t.trimStart()}:function(t){return t.replace(TXt,"")},CXt=jXt?function(t){return t.trimEnd()}:function(t){return t.replace(RXt,"")};let fK=AXt();function AXt(){try{const e=new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");if(e.exec("a ")?.[1]==="a")return e}catch{}return kXt}function zXt(e,t){return fK.lastIndex=t,fK.exec(e)[1]??""}function UXt(e){if(e.length===0)return null;let t=1,n=1;for(let r=0;r<e.length;){const i=e.charCodeAt(r);switch(i){case 35:case 39:case 60:case 123:case 125:return null}if(i===10)t++,n=1,r++;else if(n++,i>=55296&&i<=56319&&r+1<e.length){const a=e.charCodeAt(r+1);r+=a>=56320&&a<=57343?2:1}else r++}return{offset:e.length,line:t,column:n}}var WXt=class{constructor(e,t={}){this.message=e,this.position={offset:0,line:1,column:1},this.ignoreTag=!!t.ignoreTag,this.locale=t.locale,this.requiresOtherClause=!!t.requiresOtherClause,this.shouldParseSkeletons=!!t.shouldParseSkeletons}parse(){if(this.offset()!==0)throw Error("parser can only be used once");if(this.message.length>0){const e=this.message.charCodeAt(0);if(e!==35&&e!==39&&e!==60&&e!==123&&e!==125){const t=UXt(this.message);if(t){const n=this.clonePosition();return this.position=t,{val:[{type:0,value:this.message,location:xn(n,this.clonePosition())}],err:null}}}}return this.parseMessage(0,"",!1)}parseMessage(e,t,n){let r=[];for(;!this.isEOF();){const i=this.char();if(i===123){const a=this.parseArgument(e,n);if(a.err)return a;r.push(a.val)}else{if(i===125&&e>0)break;if(i===35&&(t==="plural"||t==="selectordinal")){const a=this.clonePosition();this.bump(),r.push({type:7,location:xn(a,this.clonePosition())})}else if(i===60&&!this.ignoreTag&&this.peek()===47){if(n)break;return this.error(26,xn(this.clonePosition(),this.clonePosition()))}else if(i===60&&!this.ignoreTag&&X7(this.peek()||0)){const a=this.parseTag(e,t);if(a.err)return a;r.push(a.val)}else{const a=this.parseLiteral(e,t);if(a.err)return a;r.push(a.val)}}}return{val:r,err:null}}parseTag(e,t){const n=this.clonePosition();this.bump();const r=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:0,value:`<${r}/>`,location:xn(n,this.clonePosition())},err:null};if(this.bumpIf(">")){const i=this.parseMessage(e+1,t,!0);if(i.err)return i;const a=i.val,o=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!X7(this.char()))return this.error(23,xn(o,this.clonePosition()));const s=this.clonePosition();return r!==this.parseTagName()?this.error(26,xn(s,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:8,value:r,children:a,location:xn(n,this.clonePosition())},err:null}:this.error(23,xn(o,this.clonePosition())))}else return this.error(27,xn(n,this.clonePosition()))}else return this.error(23,xn(n,this.clonePosition()))}parseTagName(){const e=this.offset();for(this.bump();!this.isEOF()&&GXt(this.char());)this.bump();return this.message.slice(e,this.offset())}parseLiteral(e,t){const n=this.clonePosition();let r="";for(;;){const a=this.tryParseQuote(t);if(a){r+=a;continue}const o=this.tryParseUnquoted(e,t);if(o){r+=o;continue}const s=this.tryParseLeftAngleBracket();if(s){r+=s;continue}break}const i=xn(n,this.clonePosition());return{val:{type:0,value:r,location:i},err:null}}tryParseLeftAngleBracket(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!NXt(this.peek()||0))?(this.bump(),"<"):null}tryParseQuote(e){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(e==="plural"||e==="selectordinal")break;return null;default:return null}this.bump();const t=[this.char()];for(this.bump();!this.isEOF();){const n=this.char();if(n===39)if(this.peek()===39)t.push(39),this.bump();else{this.bump();break}else t.push(n);this.bump()}return String.fromCodePoint(...t)}tryParseUnquoted(e,t){if(this.isEOF())return null;const n=this.char();return n===60||n===123||n===35&&(t==="plural"||t==="selectordinal")||n===125&&e>0?null:(this.bump(),String.fromCodePoint(n))}parseArgument(e,t){const n=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(1,xn(n,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(2,xn(n,this.clonePosition()));let r=this.parseIdentifierIfPossible().value;if(!r)return this.error(3,xn(n,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(1,xn(n,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:1,value:r,location:xn(n,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(1,xn(n,this.clonePosition())):this.parseArgumentOptions(e,t,r,n);default:return this.error(3,xn(n,this.clonePosition()))}}parseIdentifierIfPossible(){const e=this.clonePosition(),t=this.offset(),n=zXt(this.message,t),r=t+n.length;return this.bumpTo(r),{value:n,location:xn(e,this.clonePosition())}}parseArgumentOptions(e,t,n,r){let i=this.clonePosition(),a=this.parseIdentifierIfPossible().value,o=this.clonePosition();switch(a){case"":return this.error(4,xn(i,o));case"number":case"date":case"time":{this.bumpSpace();let s=null;if(this.bumpIf(",")){this.bumpSpace();const u=this.clonePosition(),O=this.parseSimpleArgStyleIfPossible();if(O.err)return O;const d=CXt(O.val);if(d.length===0)return this.error(6,xn(this.clonePosition(),this.clonePosition()));s={style:d,styleLocation:xn(u,this.clonePosition())}}const l=this.tryParseArgumentClose(r);if(l.err)return l;const c=xn(r,this.clonePosition());if(s&&s.style.startsWith("::")){let u=qXt(s.style.slice(2));if(a==="number"){const O=this.parseNumberSkeletonFromString(u,s.styleLocation);return O.err?O:{val:{type:2,value:n,location:c,style:O.val},err:null}}else{if(u.length===0)return this.error(10,c);let O=u;this.locale&&(O=PXt(u,this.locale));const d={type:1,pattern:O,location:s.styleLocation,parsedOptions:this.shouldParseSkeletons?mXt(O):{}};return{val:{type:a==="date"?3:4,value:n,location:c,style:d},err:null}}}return{val:{type:a==="number"?2:a==="date"?3:4,value:n,location:c,style:s?.style??null},err:null}}case"plural":case"selectordinal":case"select":{const s=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(12,xn(s,{...s}));this.bumpSpace();let l=this.parseIdentifierIfPossible(),c=0;if(a!=="select"&&l.value==="offset"){if(!this.bumpIf(":"))return this.error(13,xn(this.clonePosition(),this.clonePosition()));this.bumpSpace();const f=this.tryParseDecimalInteger(13,14);if(f.err)return f;this.bumpSpace(),l=this.parseIdentifierIfPossible(),c=f.val}const u=this.tryParsePluralOrSelectOptions(e,a,t,l);if(u.err)return u;const O=this.tryParseArgumentClose(r);if(O.err)return O;const d=xn(r,this.clonePosition());return a==="select"?{val:{type:5,value:n,options:dK(u.val),location:d},err:null}:{val:{type:6,value:n,options:dK(u.val),offset:c,pluralType:a==="plural"?"cardinal":"ordinal",location:d},err:null}}default:return this.error(5,xn(i,o))}}tryParseArgumentClose(e){return this.isEOF()||this.char()!==125?this.error(1,xn(e,this.clonePosition())):(this.bump(),{val:!0,err:null})}parseSimpleArgStyleIfPossible(){let e=0;const t=this.clonePosition();for(;!this.isEOF();)switch(this.char()){case 39:{this.bump();let n=this.clonePosition();if(!this.bumpUntil("'"))return this.error(11,xn(n,this.clonePosition()));this.bump();break}case 123:e+=1,this.bump();break;case 125:if(e>0)e-=1;else return{val:this.message.slice(t.offset,this.offset()),err:null};break;default:this.bump()}return{val:this.message.slice(t.offset,this.offset()),err:null}}parseNumberSkeletonFromString(e,t){let n=[];try{n=$Xt(e)}catch{return this.error(7,t)}return{val:{type:0,tokens:n,location:t,parsedOptions:this.shouldParseSkeletons?wXt(n):{}},err:null}}tryParsePluralOrSelectOptions(e,t,n,r){let i=!1;const a=[],o=new Set;let{value:s,location:l}=r;for(;;){if(s.length===0){const d=this.clonePosition();if(t!=="select"&&this.bumpIf("=")){const f=this.tryParseDecimalInteger(16,19);if(f.err)return f;l=xn(d,this.clonePosition()),s=this.message.slice(d.offset,this.offset())}else break}if(o.has(s))return this.error(t==="select"?21:20,l);s==="other"&&(i=!0),this.bumpSpace();const c=this.clonePosition();if(!this.bumpIf("{"))return this.error(t==="select"?17:18,xn(this.clonePosition(),this.clonePosition()));const u=this.parseMessage(e+1,t,n);if(u.err)return u;const O=this.tryParseArgumentClose(c);if(O.err)return O;a.push([s,{value:u.val,location:xn(c,this.clonePosition())}]),o.add(s),this.bumpSpace(),{value:s,location:l}=this.parseIdentifierIfPossible()}return a.length===0?this.error(t==="select"?15:16,xn(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!i?this.error(22,xn(this.clonePosition(),this.clonePosition())):{val:a,err:null}}tryParseDecimalInteger(e,t){let n=1;const r=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(n=-1);let i=!1,a=0;for(;!this.isEOF();){const s=this.char();if(s>=48&&s<=57)i=!0,a=a*10+(s-48),this.bump();else break}const o=xn(r,this.clonePosition());return i?(a*=n,Number.isSafeInteger(a)?{val:a,err:null}:this.error(t,o)):this.error(e,o)}offset(){return this.position.offset}isEOF(){return this.offset()===this.message.length}clonePosition(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}}char(){const e=this.position.offset;if(e>=this.message.length)throw Error("out of bound");const t=this.message.codePointAt(e);if(t===void 0)throw Error(`Offset ${e} is at invalid UTF-16 code unit boundary`);return t}error(e,t){return{val:null,err:{kind:e,message:this.message,location:t}}}bump(){if(this.isEOF())return;const e=this.char();e===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=e<65536?1:2)}bumpIf(e){const t=this.offset();if(this.message.slice(t,t+e.length)===e){for(let n=0;n<e.length;n++)this.bump();return!0}return!1}bumpUntil(e){const t=this.offset(),n=this.message.indexOf(e,t);return n>=0?(this.bumpTo(n),!0):(this.bumpTo(this.message.length),!1)}bumpTo(e){if(this.offset()>e)throw Error(`targetOffset ${e} must be greater than or equal to the current offset ${this.offset()}`);for(e=Math.min(e,this.message.length);;){const t=this.offset();if(t===e)break;if(t>e)throw Error(`targetOffset ${e} is at invalid UTF-16 code unit boundary`);if(this.bump(),this.isEOF())break}}bumpSpace(){for(;!this.isEOF()&&YXt(this.char());)this.bump()}peek(){if(this.isEOF())return null;const e=this.char(),t=this.offset();return this.message.charCodeAt(t+(e>=65536?2:1))??null}};function X7(e){return e>=97&&e<=122||e>=65&&e<=90}function NXt(e){return X7(e)||e===47}function GXt(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function YXt(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function E7(e){e.forEach(t=>{if(delete t.location,Txe(t)||Rxe(t))for(const n in t.options)delete t.options[n].location,E7(t.options[n].value);else kxe(t)&&Exe(t.style)||(Pxe(t)||_xe(t))&&R7(t.style)?delete t.style.location:Xxe(t)&&E7(t.children)})}function IXt(e,t={}){t={shouldParseSkeletons:!0,requiresOtherClause:!0,...t};const n=new WXt(e,t).parse();if(n.err){const r=SyntaxError(SXt[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t?.captureLocation||E7(n.val),n.val}var UP=class extends Error{constructor(e,t,n){super(e),this.code=t,this.originalMessage=n}toString(){return`[formatjs Error: ${this.code}] ${this.message}`}},hK=class extends UP{constructor(e,t,n,r){super(`Invalid values for "${e}": "${t}". Options are "${Object.keys(n).join('", "')}"`,"INVALID_VALUE",r)}},ZXt=class extends UP{constructor(e,t,n){super(`Value for "${e}" must be of type ${t}`,"INVALID_VALUE",n)}},DXt=class extends UP{constructor(e,t){super(`The intl string context variable "${e}" was not provided to the string "${t}"`,"MISSING_VALUE",t)}};function VXt(e){return e.length<2?e:e.reduce((t,n)=>{const r=t[t.length-1];return!r||r.type!==0||n.type!==0?t.push(n):r.value+=n.value,t},[])}function MXt(e){return typeof e=="function"}function K1(e,t,n,r,i,a,o){if(e.length===1&&OK(e[0]))return[{type:0,value:e[0].value}];const s=[];for(const l of e){if(OK(l)){s.push({type:0,value:l.value});continue}if(QXt(l)){typeof a=="number"&&s.push({type:0,value:n.getNumberFormat(t).format(a)});continue}const{value:c}=l;if(!(i&&c in i))throw new DXt(c,o);let u=i[c];if(xXt(l)){(!u||typeof u=="string"||typeof u=="number"||typeof u=="bigint")&&(u=typeof u=="string"||typeof u=="number"||typeof u=="bigint"?String(u):""),s.push({type:typeof u=="string"?0:1,value:u});continue}if(Pxe(l)){const O=typeof l.style=="string"?r.date[l.style]:R7(l.style)?l.style.parsedOptions:void 0;s.push({type:0,value:n.getDateTimeFormat(t,O).format(u)});continue}if(_xe(l)){const O=typeof l.style=="string"?r.time[l.style]:R7(l.style)?l.style.parsedOptions:r.time.medium;s.push({type:0,value:n.getDateTimeFormat(t,O).format(u)});continue}if(kxe(l)){const O=typeof l.style=="string"?r.number[l.style]:Exe(l.style)?l.style.parsedOptions:void 0;if(O&&O.scale){const d=O.scale||1;if(typeof u=="bigint"){if(!Number.isInteger(d))throw new TypeError(`Cannot apply fractional scale ${d} to bigint value. Scale must be an integer when formatting bigint.`);u=u*BigInt(d)}else u=u*d}s.push({type:0,value:n.getNumberFormat(t,O).format(u)});continue}if(Xxe(l)){const{children:O,value:d}=l,f=i[d];if(!MXt(f))throw new ZXt(d,"function",o);let p=f(K1(O,t,n,r,i,a).map(m=>m.value));Array.isArray(p)||(p=[p]),s.push(...p.map(m=>({type:typeof m=="string"?0:1,value:m})))}if(Txe(l)){const O=u,d=(Object.prototype.hasOwnProperty.call(l.options,O)?l.options[O]:void 0)||l.options.other;if(!d)throw new hK(l.value,u,Object.keys(l.options),o);s.push(...K1(d.value,t,n,r,i));continue}if(Rxe(l)){const O=`=${u}`;let d=Object.prototype.hasOwnProperty.call(l.options,O)?l.options[O]:void 0;if(!d){if(!Intl.PluralRules)throw new UP(`Intl.PluralRules is not available in this environment.
847
+ `)&&(s={capture:zx(e),buffer:n,caret:r})}return{...s,capture:Lh(s.capture,s.buffer,s.caret,i)}}function l2t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Hf(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=LSe(i,t.value),c=l+jP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ya,buffer:u,caret:s+c.length,payload:{index:i,key:KSe(a,e.draw),value:t.value,marker:l}}}function c2t(e,t){const n=Hf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=HSe(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ya,buffer:i,caret:n.start+r.length,restored:Q7(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:Q7(r),restoredText:r}}}function ZH(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function u2t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Hf(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:zx(e),buffer:i,caret:a,payload:null}}function O2t(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=TU(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=wn(i);if(!a)return i===""?null:u2t(t,n,e.selection,i);const o=t.arm,s=LSe(e.index,a),l=s+jP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ya,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:KSe(e.taken,e.draw),value:a,marker:s}}}const MSe=e=>`${Q7(e)} chars`,LSe=(e,t)=>`[Credential #${e}, ${MSe(t)}]`;function d2t(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 f2t(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 Iv(e,t){if(d2t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const vR=/\[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,bR=/\[credential NOT stored \u2014 [^\]\n]*\]/y,wR=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,h2t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&x7.test(t[1])?t[1]:""};function p2t(e,t){if(e.charCodeAt(t)!==91)return null;vR.lastIndex=t;const n=vR.exec(e);if(vR.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};bR.lastIndex=t;const r=bR.exec(e);if(bR.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};wR.lastIndex=t;const i=wR.exec(e);return wR.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:h2t(i[0])}:null}function qP(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=p2t(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 DH(e,t){const n=[];for(const r of t){const i=Iv(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 m2t(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 g2t=e=>`[credential ${e.key} (${MSe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function $2t(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Iv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of ISe(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?m2t(l??"lost",s?.key):g2t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const y2t=(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.`,v2t=e=>`Remove credential #${e}`,b2t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,w2t=(e,t,n)=>y2t(e,t,n),S2t="Undo",x2t=e=>`Credential #${e} removed`,Q2t=e=>e.unredacted!==null?e.unredacted:e.armed?E2t:e.cleared!==null?w2t(e.cleared.key,e.cleared.index,e.undoCap):null;function k2t(e){const{buffer:t,payload:n}=e,r=Iv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===jP?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 P2t(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 VH=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function MH(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 _2t="store unconfirmed",T2t="Credential store unconfirmed",R2t=e=>e===""?T2t:`${e} · ${_2t}`,FSe="Paste the value again after /credential to store it again.",X2t=e=>`${e} ${FSe}`;function LH(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. ${FSe}`}const E2t="armed — add a space, then type or paste the secret",j2t="masked as you type — Enter turns it into a pill, Esc cancels",q2t="masked — Enter opens the credential picker; type or paste the secret into this span",C2t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",BSe="\0held",A2t=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===BSe?`${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 HSe(e,t){const n=Hf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const FH=(e,t)=>e&&e.over===t?e.chars:null,z2t=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},U2t=16,W2t=16;function KSe(e=[],t=z2t){const n=new Set(e);for(let r=0;r<U2t;r++){const i=GH+BH(8,t);if(!n.has(i))return i}return GH+BH(W2t,t)}const BH=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=NH[t(NH.length)];return n},JSe=j("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),exe=j("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),txe=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>h.jsxs("span",{className:j("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?exe:JSe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(Dse,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(c9e,{"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(Li,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),vy="#lo-credential/",N2t=`${vy}unstored`,HH=`${vy}unconfirmed`,G2t=/^\d+$/,nxe=e=>e.kind==="stored"?`${vy}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${HH}/${e.key}`:HH:N2t;function Y2t(e){if(!e||!e.startsWith(vy))return null;const t=e.slice(vy.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return x7.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!x7.test(r)||!G2t.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function KH(e,t){const n=Y2t(e);if(n===null)return null;const r=qP(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return nxe(i)!==e?null:n}const CP=()=>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=qP(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:nxe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},I2t=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?R2t(e.key):"Credential not stored",Z2t=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?X2t(t):t,D2t=({citation:e,title:t})=>h.jsx(txe,{tone:e.kind==="stored"?"live":"warning",label:I2t(e),chars:e.kind==="stored"?e.chars:null,title:Z2t(e,t),className:"align-middle"}),V2t=(e,t)=>typeof t=="string"?KH(e,t):t==null?KH(e,""):null,M2t=e=>({href:t,title:n,children:r})=>{const i=V2t(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(D2t,{citation:i,title:n})},rxe=e=>e.startsWith("data:")?"data":e.startsWith("blob:")?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",ixe=e=>{const t=rxe(e);return t==="other"?"path":t},L2t={id:"open-file",label:"Open file"},F2t={id:"show-in-canvas",label:"Show in canvas"},B2t={id:"open-folder",label:"Open folder"},H2t={id:"copy-file-path",label:"Copy file path"},Nw={id:"copy-image",label:"Copy image"},K2t={id:"copy-image-url",label:"Copy image URL"},J2t={id:"open-in-browser",label:"Open in browser"};function axe(e,{canShowInCanvas:t,source:n}){const r=t?[F2t]:[];switch(e){case"path":return[...r,L2t,B2t,H2t,Nw];case"data":return[...r,Nw];case"blob":return[Nw];case"http":return[...eRt(n)?[Nw]:[],K2t,J2t];case"other":return[]}}const oxe=(e,t)=>axe(e,t).length>0;function eRt(e){try{const t=new URL(e),n=t.hostname==="localhost"||t.hostname==="127.0.0.1";return t.protocol==="http:"&&n&&(t.port==="1111"||t.port==="8080")}catch{return!1}}const RU=e=>e.startsWith("file://")?e.slice(7):e;function tRt(e){const t=e.indexOf(",");if(t===-1)throw new Error("Malformed data URL");const n=e.slice(5,t),r=e.slice(t+1),i=n.split(";")[0]||"application/octet-stream";if(n.endsWith(";base64")){const s=atob(r),l=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)l[c]=s.charCodeAt(c);return new Blob([l],{type:i})}const a=decodeURIComponent(r),o=new Uint8Array(a.length);for(let s=0;s<a.length;s+=1)o[s]=a.charCodeAt(s);return new Blob([o],{type:i})}async function nRt(e,t,n){if(e==="data")return tRt(t);if(e==="blob"){const o=bZe(n??t);if(o===null)throw new Error("These image bytes are not available in this window");return o}if(e==="http"){const o=await fetch(n??t);if(!o.ok)throw new Error(`The image server answered ${o.status}`);return o.blob()}const r=window.api?.readFileBytes;if(typeof r!="function")throw new Error("This window cannot read local files");const i=RU(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:jde(i)})}const rRt=e=>e.trim().toLowerCase()!=="image/png";async function iRt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!rRt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await aRt(t);if(n.naturalWidth===0||n.naturalHeight===0)throw new Error("This image could not be decoded for the clipboard");const r=document.createElement("canvas");r.width=n.naturalWidth,r.height=n.naturalHeight;const i=r.getContext("2d");if(i===null)throw new Error("This window cannot re-encode the image for the clipboard");i.drawImage(n,0,0);const a=await new Promise(o=>{r.toBlob(o,"image/png")});if(a===null)throw new Error("This image could not be re-encoded for the clipboard");return a}finally{URL.revokeObjectURL(t)}}function aRt(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("This image could not be decoded for the clipboard")),r.src=e})}const oRt={"open-file":h.jsx(fv,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(pue,{"aria-hidden":"true"}),"open-folder":h.jsx(_p,{"aria-hidden":"true"}),"copy-file-path":h.jsx(lue,{"aria-hidden":"true"}),"copy-image":h.jsx(mk,{"aria-hidden":"true"}),"copy-image-url":h.jsx(f9e,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Oue,{"aria-hidden":"true"})},sxe=({file:e,src:t,label:n,onShowInCanvas:r,tooltip:i="Image actions","aria-label":a})=>{const o=ixe(e),s=axe(o,{canShowInCanvas:!!r,source:t??e});if(s.length===0)return null;const l=async(d,f,p)=>{try{await navigator.clipboard.writeText(d),uf(f)}catch(m){console.error(`${p}: `,m),Mi(p)}},c=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const d=await nRt(o,e,t),f=await iRt(d);await navigator.clipboard.write([new ClipboardItem({[f.type]:f})]),uf("Image copied to clipboard")}catch(d){console.error("Failed to copy image: ",d),Mi("Failed to copy image")}},u=d=>{const f=RU(e);switch(d.id){case"open-file":AO(f);return;case"open-folder":SU(f);return;case"show-in-canvas":r?.();return;case"copy-file-path":l(f,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":c();return;case"copy-image-url":l(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":xU(t??e);return}},O=a??`Actions for ${n??"this image"}`;return h.jsxs(EA,{children:[h.jsx(Ut,{content:i,children:h.jsx(jA,{asChild:!0,children:h.jsx(Ae,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":O,onClick:d=>d.stopPropagation(),children:h.jsx(uue,{"aria-hidden":"true"})})})}),h.jsx(qA,{align:"end",className:"min-w-45",onClick:d=>d.stopPropagation(),children:s.map(d=>h.jsxs(Tl,{onSelect:()=>u(d),children:[oRt[d.id],h.jsx("span",{children:d.label})]},d.id))})]})},sRt=({src:e,alt:t,title:n,className:r})=>{const i=_P(),a=e??"",o=rxe(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=oxe(o,{canShowInCanvas:s,source:a});return h.jsxs("span",{className:j("group/mdimg relative inline-block max-w-full"),children:[h.jsx("img",{src:e,alt:t,title:n,className:r}),l&&h.jsx("span",{"data-markdown-image":"",className:j("pointer-events-none absolute top-1 right-1 z-[2] opacity-0","transition-opacity duration-fast ease-out-quart","group-hover/mdimg:pointer-events-auto group-hover/mdimg:opacity-100","group-focus-within/mdimg:pointer-events-auto group-focus-within/mdimg:opacity-100","has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100"),children:h.jsx(sxe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||AO(RU(a))})}:void 0})})]})};function lRt(){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 cRt={tokenize:uRt,concrete:!0,name:"mathFlow"},JH={tokenize:ORt,partial:!0};function uRt(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"),un(e,c,"whitespace")(v))}function c(v){return v===null||$t(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||$t(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(JH,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,f)(v)}function f(v){return(a?un(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):$t(v)?e.attempt(JH,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||$t(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,w,x){let b=0;return un(v,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(T){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(T)}function Q(T){return T===36?(b++,v.consume(T),Q):b<o?x(T):(v.exit("mathFlowFenceSequence"),un(v,P,"whitespace")(T))}function P(T){return T===null||$t(T)?(v.exit("mathFlowFence"),w(T)):x(T)}}}function ORt(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 dRt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:fRt,previous:hRt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):$t(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),f(m))}function f(m){return m===null||m===32||m===36||$t(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),f)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",f(m))}}}function fRt(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 hRt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function pRt(e){return{flow:{36:cRt},text:{36:dRt()}}}const Fh=36,eK=e=>e!==null&&e<-2,tK=e=>e===null||e===32||e<0,nK=e=>e!==null&&e>=48&&e<=57,lxe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:mRt,previous:gRt,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===Fh?(r.consume(g),s++,d):s<2&&!t||s===1&&(tK(g)||nK(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===Fh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):eK(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===Fh||eK(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===Fh?(r.consume(g),c++,m):c===s?s===1&&(tK(l)||nK(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function mRt(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 gRt(e){return e!==Fh||this.events[this.events.length-1][1].type==="characterEscape"}const $Rt=pRt().flow,yRt=lxe();function AP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?yRt:lxe(e);n.push({flow:$Rt,text:{[Fh]:i}}),r.push(lRt())}const vRt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),bRt=/\$(?!\d)(.+?)\$/,wRt=/\$\$([\s\S]+?)\$\$/,SRt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,xRt=/\\[a-zA-Z]+(\{[^}]*\})?/,rK=e=>bRt.test(e)||wRt.test(e)||SRt.test(e)?!0:xRt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),QRt=e=>{const t=qP(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},kRt=e=>qP(e).filter(t=>t.kind!=="text").length,PRt=e=>{if(!rK(e))return!1;const t=QRt(e);return t===null?!0:rK(t)||t.includes("$")?!1:kRt(e)<2},tn="var(--color-ink)",gc="var(--color-ink-muted)",gl="var(--color-surface)",Zu="var(--color-elevated)",$c="var(--color-sunken)",Hi="var(--color-hairline)",Du="var(--color-control)",xh="var(--color-accent)",v0="var(--color-accent-wash)",_Rt="var(--color-accent-alt-wash)",TRt="var(--color-on-accent)",RRt="var(--color-info)",cxe="var(--color-info-wash)",XRt="var(--color-success)",uxe="var(--color-success-wash)",ERt="var(--color-warning)",P7="var(--color-warning-wash)",jRt="var(--color-warning-border)",SR="var(--color-danger)",_7="var(--color-danger-wash)",iK=[v0,_Rt,cxe,uxe,P7,_7],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),qRt=()=>{const e={primaryColor:Vu("--color-accent"),secondaryColor:Vu("--color-success"),tertiaryColor:Vu("--color-info"),mainBkg:Vu("--color-elevated"),clusterBkg:Vu("--color-sunken"),clusterBorder:Vu("--color-hairline"),edgeLabelBackground:Vu("--color-surface"),quadrant1Fill:Vu("--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:gl,primaryTextColor:tn,primaryBorderColor:Du,secondaryTextColor:tn,secondaryBorderColor:Hi,tertiaryTextColor:tn,tertiaryBorderColor:Hi,lineColor:gc,arrowheadColor:gc,textColor:tn,secondBkg:$c,border1:Du,border2:Hi,labelColor:tn,nodeBkg:Zu,nodeBorder:Du,nodeTextColor:tn,defaultLinkColor:gc,titleColor:tn,noteBkgColor:P7,noteBorderColor:jRt,noteTextColor:tn,actorBkg:Zu,actorBorder:Du,actorTextColor:tn,actorLineColor:Hi,signalColor:gc,signalTextColor:tn,labelBoxBkgColor:Zu,labelBoxBorderColor:Hi,labelTextColor:tn,loopTextColor:tn,activationBkgColor:v0,activationBorderColor:xh,sequenceNumberColor:gl,sectionBkgColor:$c,sectionBkgColor2:gl,altSectionBkgColor:$c,excludeBkgColor:$c,taskBkgColor:v0,taskBorderColor:Du,taskTextColor:tn,taskTextLightColor:tn,taskTextDarkColor:tn,taskTextOutsideColor:tn,taskTextClickableColor:xh,activeTaskBkgColor:v0,activeTaskBorderColor:xh,gridColor:Hi,doneTaskBkgColor:$c,doneTaskBorderColor:Hi,critBkgColor:_7,critBorderColor:SR,todayLineColor:xh,transitionColor:gc,transitionLabelColor:tn,stateLabelColor:tn,stateBkg:Zu,labelBackgroundColor:gl,compositeBackground:$c,altBackground:$c,compositeTitleBackground:Zu,compositeBorder:Hi,innerEndBackground:tn,specialStateColor:tn,classText:tn,attributeBackgroundColorOdd:gl,attributeBackgroundColorEven:$c,rowOdd:gl,rowEven:$c,errorBkgColor:_7,errorTextColor:SR,pieTitleTextColor:tn,pieSectionTextColor:tn,pieLegendTextColor:tn,pieStrokeColor:gl,pieOuterStrokeColor:Hi,requirementBackground:Zu,requirementBorderColor:Du,requirementTextColor:tn,relationColor:gc,relationLabelBackground:gl,relationLabelColor:tn,branchLabelColor:TRt,commitLabelColor:tn,commitLabelBackground:gl,tagLabelColor:tn,tagLabelBackground:v0,tagLabelBorder:Du,quadrant2Fill:cxe,quadrant3Fill:uxe,quadrant4Fill:P7,quadrant2TextFill:tn,quadrant3TextFill:tn,quadrant4TextFill:tn,quadrantPointFill:xh,archEdgeColor:gc,archEdgeArrowColor:gc,archGroupBorderColor:Hi,scaleLabelColor:tn,packet:{startByteColor:tn,endByteColor:tn,labelColor:tn,titleColor:tn,blockStrokeColor:Du,blockFillColor:Zu},radar:{axisColor:gc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Hi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:gl,titleColor:tn,xAxisTitleColor:tn,xAxisLabelColor:tn,xAxisTickColor:Hi,xAxisLineColor:Hi,yAxisTitleColor:tn,yAxisLabelColor:tn,yAxisTickColor:Hi,yAxisLineColor:Hi,plotColorPalette:[xh,RRt,XRt,ERt,SR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Zu,t[`surfacePeer${n}`]=Hi;for(let n=0;n<8;n++)t[`fillType${n}`]=iK[n%iK.length];return{...t,...e}};let xR=null,aK=null;const CRt=async e=>{xR||(xR=he(async()=>{const{default:n}=await import("./mermaid.core-C85gayGw.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,2,3]),import.meta.url).then(({default:n})=>n));const t=await xR;return aK!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:qRt()}),aK=e),t},oK=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:j("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(Ut,{content:"Zoom in",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(kue,{})})}),h.jsx(Ut,{content:"Zoom out",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(Pue,{})})}),h.jsx(Ut,{content:"Drag the diagram to pan",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(E9e,{})})}),h.jsx(Ut,{content:"Reset view",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(yk,{})})}),h.jsx(Ut,{content:"Save as SVG",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(gk,{})})}),h.jsx(Ut,{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(mk,{className:j(t&&"text-success")})})}),s]}),T7=({title:e,children:t})=>h.jsxs(Yl,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(k0,{children:e}),h.jsx(P0,{children:t})]});class ARt extends $.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(T7,{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 zRt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,f]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,w]=$.useState({x:0,y:0}),[x,b]=$.useState("idle"),[S,Q]=$.useState("idle"),P=ar(z=>z.themeName),T=$.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const z=await CRt(P),ie=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:F}=await z.render(ie,e);if(!F||typeof F!="string"||F.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(F)}catch(z){console.error("Mermaid rendering error:",z);const ie=z instanceof Error?z.message:"Failed to render mermaid diagram";a(ie),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{T().catch(z=>{console.error("Error in renderDiagram effect:",z),a("Failed to initialize diagram rendering"),s(!1)})},[T]);const _=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ie=r.current.getBoundingClientRect(),F=document.createElement("div");F.innerHTML=l;const H=F.querySelector("svg");if(!H)return 1;const oe=H.getBoundingClientRect?.()?.width||Number.parseFloat(H.getAttribute("width")||"0")||H.viewBox?.baseVal?.width||800,L=H.getBoundingClientRect?.()?.height||Number.parseFloat(H.getAttribute("height")||"0")||H.viewBox?.baseVal?.height||600,K=ie.width*.9/oe,re=ie.height*.9/L;return Math.min(K,re,1)}catch(z){return console.error("Error calculating fullscreen scale:",z),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const z=_();m({scale:z,x:0,y:0})}catch(z){console.error("Error setting fullscreen transform:",z)}},100)},[u,l,_]);const E=$.useCallback((z=!1)=>{try{(z?m:f)(F=>({...F,scale:Math.min(F.scale*1.2,10)}))}catch(ie){console.error("Error in zoom in:",ie)}},[]),C=$.useCallback((z=!1)=>{try{(z?m:f)(F=>({...F,scale:Math.max(F.scale/1.2,.1)}))}catch(ie){console.error("Error in zoom out:",ie)}},[]),A=$.useCallback((z=!1)=>{try{const ie=z?m:f;if(z){const F=_();ie({scale:F,x:0,y:0})}else ie({scale:1,x:0,y:0})}catch(ie){console.error("Error in reset:",ie)}},[_]),U=$.useCallback(()=>{if(l)try{const z=new Blob([l],{type:"image/svg+xml"}),ie=URL.createObjectURL(z),F=document.createElement("a");F.href=ie,F.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(ie)}catch(z){console.error("Failed to save SVG:",z)}},[l]),N=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(z){console.error("Failed to copy Mermaid chart text:",z)}},[e]),Z=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(z){console.error("Failed to copy Mermaid chart text:",z)}},[e]),G=$.useCallback(z=>{try{y(!0),w({x:z.clientX,y:z.clientY}),z.preventDefault()}catch(ie){console.error("Error in mouse down:",ie)}},[]),D=$.useCallback((z,ie=!1)=>{try{if(!g)return;const F=z.clientX-v.x,H=z.clientY-v.y;(ie?m:f)(L=>({...L,x:L.x+F,y:L.y+H})),w({x:z.clientX,y:z.clientY})}catch(F){console.error("Error in mouse move:",F)}},[g,v]),I=$.useCallback(()=>{try{y(!1)}catch(z){console.error("Error in mouse up:",z)}},[]),W=$.useCallback((z,ie=!1)=>{try{z.preventDefault();const F=z.deltaY>0?.9:1.1;(ie?m:f)(oe=>({...oe,scale:Math.min(Math.max(oe.scale*F,.1),5)}))}catch(F){console.error("Error in wheel:",F)}},[]),J=$.useCallback(z=>{try{O(z)}catch(ie){console.error("Error toggling fullscreen:",ie)}},[]);if(i)return h.jsxs(T7,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:j("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:j("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const ee=(z=!1)=>{try{const ie=z?r:n,F=z?p:d;return h.jsx("div",{ref:ie,className:j("mermaid flex w-full items-center justify-center",z?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:G,onMouseMove:H=>D(H,z),onMouseUp:I,onMouseLeave:I,onWheel:H=>W(H,z),children:o?h.jsx("div",{className:j("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:j("flex h-full w-full items-center justify-center"),style:{transform:`translate(${F.x}px, ${F.y}px) scale(${F.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ie){return console.error("Error rendering diagram content:",ie),h.jsx(T7,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:j("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[ee(!1),h.jsx(oK,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>C(!1),onReset:()=>A(!1),onSave:U,onCopy:N,children:h.jsx(Ut,{content:"Fullscreen",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>J(!0),children:h.jsx(S9e,{})})})})]}),h.jsx(j$,{open:u,onClose:()=>J(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:j("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[ee(!0),h.jsx(oK,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>C(!0),onReset:()=>A(!0),onSave:U,onCopy:Z,children:h.jsx(Ut,{content:"Close fullscreen",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>J(!1),children:h.jsx(Li,{})})})})]})})]})}),URt=$.memo(e=>h.jsx(ARt,{children:h.jsx(zRt,{...e})}));let Oxe=!1,QR=null;const WRt=()=>(QR||(QR=he(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(Oxe=!0,e))),QR),NRt=/language-(\w+)/,GRt=/\n$/,dxe=({href:e,children:t})=>{const n=ySe(e),r=_P();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=>ZRt(i,r):void 0,children:t})},YRt=e=>ySe(e)?.kind==="file",IRt=xSe,ZRt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(SSe)??"file",i=n.getAttribute(IRt),a=oTt({kind:r,hasHighlight:bTt(n),canOpenInCanvas:wU(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||AO(i)});return}AO(i)}},fxe=(e,t)=>t==="href"&&YRt(e)?e:Ife(e),XU={a:dxe,table:vRt,img:sRt,code:({node:e,className:t,children:n,...r})=>NRt.exec(t??"")?.[1]==="mermaid"?h.jsx(URt,{chart:String(n).replace(GRt,"")}):h.jsx("code",{className:t,...r,children:n})},DRt={...XU,a:M2t(dxe)},VRt=[YO],MRt=[YO,AP],LRt=[YO,TP],FRt=[YO,AP,TP],BRt=[YO,CP,RP],HRt=[YO,AP,CP,RP],KRt=[YO,TP,CP,RP],JRt=[YO,AP,TP,CP,RP],eXt={"000":VRt,"001":BRt,"010":LRt,"011":KRt,100:MRt,101:HRt,110:FRt,111:JRt},tXt=[],nXt=[OJe],hxe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),pxe=(e,t,n)=>{const r=$.useMemo(()=>PRt(e),[e]),[i,a]=$.useState(Oxe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return WRt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:eXt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?nXt:tXt}},mxe=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=Gtt(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=lTt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return wSe(r,window.api?.probeFiles,gle).then(()=>{i&&r.some(s=>bSe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},zP=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=pxe(a,r,i),l=hxe(t);return mxe(a,r),h.jsx("div",{className:j("lo-markdown",n),style:l,children:h.jsx(Yfe,{remarkPlugins:o,rehypePlugins:s,urlTransform:fxe,components:i?DRt:XU,children:a})})});zP.displayName="MarkdownRenderer";const gxe=$.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=pxe(e,!0,!1);return mxe(e,!0),h.jsx(Yfe,{remarkPlugins:t,rehypePlugins:n,urlTransform:fxe,components:XU,children:e})});gxe.displayName="StableBlock";const $xe=$.memo(({text:e,animate:t})=>h.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));$xe.displayName="ArrivedText";const yxe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=QTt());const i=r.current,a=$.useRef([]),o=$.useRef(0);TTt(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+RTt(e.slice(l)),d=[{offset:l,animate:!1}];for(const p of c){if(p.offset>=O)break;d.push(p)}const f=hxe(t);return h.jsxs("div",{className:j("lo-markdown",n),style:f,children:[i.blocks.map((p,m)=>h.jsx(gxe,{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($xe,{text:e.slice(p.offset,g),animate:p.animate},p.offset)})})]})};yxe.displayName="StreamingMarkdown";const To=({isUser:e,children:t,className:n})=>e?h.jsx("div",{className:j("flex w-full justify-end",n),children:t}):h.jsx("div",{className:j("group relative w-full",n),children:t}),EU=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},rXt=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 jU=EU(Date.now()),rO=null;const H1=new Set,vxe=()=>{rO!==null&&clearTimeout(rO),rO=setTimeout(()=>{rO=null,jU=EU(Date.now());for(const e of H1)e();vxe()},rXt(Date.now())),rO.unref?.()},iXt=e=>(H1.add(e),jU=EU(Date.now()),vxe(),()=>{H1.delete(e),H1.size===0&&rO!==null&&(clearTimeout(rO),rO=null)}),sK=()=>jU,aXt=()=>$.useSyncExternalStore(iXt,sK,sK),oXt=e=>new Date(e+1e3),sXt=()=>oXt(aXt());function kR(e,t){const n=t&&t.cache?t.cache:hXt,r=t&&t.serializer?t.serializer:dXt;return(t&&t.strategy?t.strategy:uXt)(e,{cache:n,serializer:r})}function lXt(e){return e==null||typeof e=="number"||typeof e=="boolean"}function cXt(e,t,n,r){const i=lXt(r)?r:n(r);let a=t.get(i);return typeof a>"u"&&(a=e.call(this,r),t.set(i,a)),a}function bxe(e,t,n){const r=Array.prototype.slice.call(arguments,3),i=n(r);let a=t.get(i);return typeof a>"u"&&(a=e.apply(this,r),t.set(i,a)),a}function wxe(e,t,n,r,i){return n.bind(t,e,r,i)}function uXt(e,t){const n=e.length===1?cXt:bxe;return wxe(e,this,n,t.cache.create(),t.serializer)}function OXt(e,t){return wxe(e,this,bxe,t.cache.create(),t.serializer)}const dXt=function(){return JSON.stringify(arguments)};var fXt=class{constructor(){this.cache=Object.create(null)}get(e){return this.cache[e]}set(e,t){this.cache[e]=t}};const hXt={create:function(){return new fXt}},PR={variadic:OXt},pXt=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function mXt(e){const t={};return e.replace(pXt,n=>{const r=n.length;switch(n[0]){case"G":t.era=r===4?"long":r===5?"narrow":"short";break;case"y":t.year=r===2?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":t.month=["numeric","2-digit","short","long","narrow"][r-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":t.day=["numeric","2-digit"][r-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":t.weekday=r===4?"long":r===5?"narrow":"short";break;case"e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-3];break;case"c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-3];break;case"a":t.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":t.hourCycle="h12",t.hour=["numeric","2-digit"][r-1];break;case"H":t.hourCycle="h23",t.hour=["numeric","2-digit"][r-1];break;case"K":t.hourCycle="h11",t.hour=["numeric","2-digit"][r-1];break;case"k":t.hourCycle="h24",t.hour=["numeric","2-digit"][r-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":t.minute=["numeric","2-digit"][r-1];break;case"s":t.second=["numeric","2-digit"][r-1];break;case"S":case"A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case"z":t.timeZoneName=r<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return""}),t}const gXt=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function $Xt(e){if(e.length===0)throw new Error("Number skeleton cannot be empty");const t=e.split(gXt).filter(r=>r.length>0),n=[];for(const r of t){let i=r.split("/");if(i.length===0)throw new Error("Invalid number skeleton");const[a,...o]=i;for(const s of o)if(s.length===0)throw new Error("Invalid number skeleton");n.push({stem:a,options:o})}return n}function yXt(e){return e.replace(/^(.*?)-/,"")}const lK=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,Sxe=/^(@+)?(\+|#+)?[rs]?$/g,vXt=/(\*)(0+)|(#+)(0+)|(0+)/g,xxe=/^(0+)$/;function cK(e){const t={};return e[e.length-1]==="r"?t.roundingPriority="morePrecision":e[e.length-1]==="s"&&(t.roundingPriority="lessPrecision"),e.replace(Sxe,function(n,r,i){return typeof i!="string"?(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length):i==="+"?t.minimumSignificantDigits=r.length:r[0]==="#"?t.maximumSignificantDigits=r.length:(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length+(typeof i=="string"?i.length:0)),""}),t}function Qxe(e){switch(e){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":case"()":return{currencySign:"accounting"};case"sign-always":case"+!":return{signDisplay:"always"};case"sign-accounting-always":case"()!":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":case"+?":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":case"()?":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":case"+_":return{signDisplay:"never"}}}function bXt(e){let t;if(e[0]==="E"&&e[1]==="E"?(t={notation:"engineering"},e=e.slice(2)):e[0]==="E"&&(t={notation:"scientific"},e=e.slice(1)),t){const n=e.slice(0,2);if(n==="+!"?(t.signDisplay="always",e=e.slice(2)):n==="+?"&&(t.signDisplay="exceptZero",e=e.slice(2)),!xxe.test(e))throw new Error("Malformed concise eng/scientific notation");t.minimumIntegerDigits=e.length}return t}function uK(e){const t={},n=Qxe(e);return n||t}function wXt(e){let t={};for(const n of e){switch(n.stem){case"percent":case"%":t.style="percent";continue;case"%x100":t.style="percent",t.scale=100;continue;case"currency":t.style="currency",t.currency=n.options[0];continue;case"group-off":case",_":t.useGrouping=!1;continue;case"precision-integer":case".":t.maximumFractionDigits=0;continue;case"measure-unit":case"unit":t.style="unit",t.unit=yXt(n.options[0]);continue;case"compact-short":case"K":t.notation="compact",t.compactDisplay="short";continue;case"compact-long":case"KK":t.notation="compact",t.compactDisplay="long";continue;case"scientific":t={...t,notation:"scientific",...n.options.reduce((a,o)=>({...a,...uK(o)}),{})};continue;case"engineering":t={...t,notation:"engineering",...n.options.reduce((a,o)=>({...a,...uK(o)}),{})};continue;case"notation-simple":t.notation="standard";continue;case"unit-width-narrow":t.currencyDisplay="narrowSymbol",t.unitDisplay="narrow";continue;case"unit-width-short":t.currencyDisplay="code",t.unitDisplay="short";continue;case"unit-width-full-name":t.currencyDisplay="name",t.unitDisplay="long";continue;case"unit-width-iso-code":t.currencyDisplay="symbol";continue;case"scale":t.scale=parseFloat(n.options[0]);continue;case"rounding-mode-floor":t.roundingMode="floor";continue;case"rounding-mode-ceiling":t.roundingMode="ceil";continue;case"rounding-mode-down":t.roundingMode="trunc";continue;case"rounding-mode-up":t.roundingMode="expand";continue;case"rounding-mode-half-even":t.roundingMode="halfEven";continue;case"rounding-mode-half-down":t.roundingMode="halfTrunc";continue;case"rounding-mode-half-up":t.roundingMode="halfExpand";continue;case"integer-width":if(n.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");n.options[0].replace(vXt,function(a,o,s,l,c,u){if(o)t.minimumIntegerDigits=s.length;else{if(l&&c)throw new Error("We currently do not support maximum integer digits");if(u)throw new Error("We currently do not support exact integer digits")}return""});continue}if(xxe.test(n.stem)){t.minimumIntegerDigits=n.stem.length;continue}if(lK.test(n.stem)){if(n.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");n.stem.replace(lK,function(o,s,l,c,u,O){return l==="*"?t.minimumFractionDigits=s.length:c&&c[0]==="#"?t.maximumFractionDigits=c.length:u&&O?(t.minimumFractionDigits=u.length,t.maximumFractionDigits=u.length+O.length):(t.minimumFractionDigits=s.length,t.maximumFractionDigits=s.length),""});const a=n.options[0];a==="w"?t={...t,trailingZeroDisplay:"stripIfInteger"}:a&&(t={...t,...cK(a)});continue}if(Sxe.test(n.stem)){t={...t,...cK(n.stem)};continue}const r=Qxe(n.stem);r&&(t={...t,...r});const i=bXt(n.stem);i&&(t={...t,...i})}return t}let SXt=function(e){return e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG",e}({});function OK(e){return e.type===0}function xXt(e){return e.type===1}function kxe(e){return e.type===2}function Pxe(e){return e.type===3}function _xe(e){return e.type===4}function Txe(e){return e.type===5}function Rxe(e){return e.type===6}function QXt(e){return e.type===7}function Xxe(e){return e.type===8}function Exe(e){return!!(e&&typeof e=="object"&&e.type===0)}function R7(e){return!!(e&&typeof e=="object"&&e.type===1)}const jxe=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,kXt=/([^\t-\r -\/:-@\[-\^`\{-~\x85\xA0-\xA7\xA9\xAB\xAC\xAE\xB0\xB1\xB6\xBB\xBF\xD7\xF7\u1680\u2000-\u200A\u2010-\u2029\u202F-\u203E\u2041-\u2053\u2055-\u205F\u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3000-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]*)/g,Gg={"001":["H","h"],419:["h","H","hB","hb"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["h","H","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BI:["H","h"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["h","H","hB","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BY:["H","h"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["h","H","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["h","H","hB","hb"],CU:["h","H","hB","hb"],CV:["H","hB"],CW:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["h","H","hB","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FO:["H","h"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GL:["H","h"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GS:["H","h","hb","hB"],GT:["h","H","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["h","H","hB","hb"],HR:["H","hB"],HU:["H","h"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","K","h"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MG:["H","h"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MT:["H","h"],MU:["H","h"],MV:["H","h"],MW:["h","hb","H","hB"],MX:["h","H","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["h","H","hB","hb"],NL:["H","hB"],NO:["H","h"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["h","H","hB","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PL:["H","h"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["h","H","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],RW:["H","h"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["h","H","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TH:["H","h"],TJ:["H","h"],TL:["H","hB","hb","h"],TM:["H","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["h","H","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VN:["H","h"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],ZW:["H","h"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"en-HK":["h","hb","H","hB"],"en-IL":["H","h","hb","hB"],"en-MY":["h","hb","H","hB"],"es-BR":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ku-SY":["H","hB"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function PXt(e,t){let n="";for(let r=0;r<e.length;r++){const i=e.charAt(r);if(i==="j"){let a=0;for(;r+1<e.length&&e.charAt(r+1)===i;)a++,r++;let o=1+(a&1),s=a<2?1:3+(a>>1),l="a",c=_Xt(t);for((c=="H"||c=="k")&&(s=0);s-- >0;)n+=l;for(;o-- >0;)n=c+n}else i==="J"?n+="H":n+=i}return n}function _Xt(e){let t=e.hourCycle;if(t===void 0){const i=e;t=i.getHourCycles?.()[0]??i.hourCycles?.[0]}if(t)switch(t){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}const n=e.language;let r;return n!=="root"&&(r=e.maximize().region),(Gg[`${n}-${r}`]||Gg[r||""]||Gg[n||""]||Gg[`${n}-001`]||Gg["001"])[0].charAt(0)}const TXt=new RegExp(`^${jxe.source}*`),RXt=new RegExp(`${jxe.source}*$`);function xn(e,t){return{start:e,end:t}}const XXt=!!Object.fromEntries,EXt=!!String.prototype.trimStart,jXt=!!String.prototype.trimEnd,dK=XXt?Object.fromEntries:function(t){const n={};for(const[r,i]of t)n[r]=i;return n},qXt=EXt?function(t){return t.trimStart()}:function(t){return t.replace(TXt,"")},CXt=jXt?function(t){return t.trimEnd()}:function(t){return t.replace(RXt,"")};let fK=AXt();function AXt(){try{const e=new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");if(e.exec("a ")?.[1]==="a")return e}catch{}return kXt}function zXt(e,t){return fK.lastIndex=t,fK.exec(e)[1]??""}function UXt(e){if(e.length===0)return null;let t=1,n=1;for(let r=0;r<e.length;){const i=e.charCodeAt(r);switch(i){case 35:case 39:case 60:case 123:case 125:return null}if(i===10)t++,n=1,r++;else if(n++,i>=55296&&i<=56319&&r+1<e.length){const a=e.charCodeAt(r+1);r+=a>=56320&&a<=57343?2:1}else r++}return{offset:e.length,line:t,column:n}}var WXt=class{constructor(e,t={}){this.message=e,this.position={offset:0,line:1,column:1},this.ignoreTag=!!t.ignoreTag,this.locale=t.locale,this.requiresOtherClause=!!t.requiresOtherClause,this.shouldParseSkeletons=!!t.shouldParseSkeletons}parse(){if(this.offset()!==0)throw Error("parser can only be used once");if(this.message.length>0){const e=this.message.charCodeAt(0);if(e!==35&&e!==39&&e!==60&&e!==123&&e!==125){const t=UXt(this.message);if(t){const n=this.clonePosition();return this.position=t,{val:[{type:0,value:this.message,location:xn(n,this.clonePosition())}],err:null}}}}return this.parseMessage(0,"",!1)}parseMessage(e,t,n){let r=[];for(;!this.isEOF();){const i=this.char();if(i===123){const a=this.parseArgument(e,n);if(a.err)return a;r.push(a.val)}else{if(i===125&&e>0)break;if(i===35&&(t==="plural"||t==="selectordinal")){const a=this.clonePosition();this.bump(),r.push({type:7,location:xn(a,this.clonePosition())})}else if(i===60&&!this.ignoreTag&&this.peek()===47){if(n)break;return this.error(26,xn(this.clonePosition(),this.clonePosition()))}else if(i===60&&!this.ignoreTag&&X7(this.peek()||0)){const a=this.parseTag(e,t);if(a.err)return a;r.push(a.val)}else{const a=this.parseLiteral(e,t);if(a.err)return a;r.push(a.val)}}}return{val:r,err:null}}parseTag(e,t){const n=this.clonePosition();this.bump();const r=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:0,value:`<${r}/>`,location:xn(n,this.clonePosition())},err:null};if(this.bumpIf(">")){const i=this.parseMessage(e+1,t,!0);if(i.err)return i;const a=i.val,o=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!X7(this.char()))return this.error(23,xn(o,this.clonePosition()));const s=this.clonePosition();return r!==this.parseTagName()?this.error(26,xn(s,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:8,value:r,children:a,location:xn(n,this.clonePosition())},err:null}:this.error(23,xn(o,this.clonePosition())))}else return this.error(27,xn(n,this.clonePosition()))}else return this.error(23,xn(n,this.clonePosition()))}parseTagName(){const e=this.offset();for(this.bump();!this.isEOF()&&GXt(this.char());)this.bump();return this.message.slice(e,this.offset())}parseLiteral(e,t){const n=this.clonePosition();let r="";for(;;){const a=this.tryParseQuote(t);if(a){r+=a;continue}const o=this.tryParseUnquoted(e,t);if(o){r+=o;continue}const s=this.tryParseLeftAngleBracket();if(s){r+=s;continue}break}const i=xn(n,this.clonePosition());return{val:{type:0,value:r,location:i},err:null}}tryParseLeftAngleBracket(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!NXt(this.peek()||0))?(this.bump(),"<"):null}tryParseQuote(e){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(e==="plural"||e==="selectordinal")break;return null;default:return null}this.bump();const t=[this.char()];for(this.bump();!this.isEOF();){const n=this.char();if(n===39)if(this.peek()===39)t.push(39),this.bump();else{this.bump();break}else t.push(n);this.bump()}return String.fromCodePoint(...t)}tryParseUnquoted(e,t){if(this.isEOF())return null;const n=this.char();return n===60||n===123||n===35&&(t==="plural"||t==="selectordinal")||n===125&&e>0?null:(this.bump(),String.fromCodePoint(n))}parseArgument(e,t){const n=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(1,xn(n,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(2,xn(n,this.clonePosition()));let r=this.parseIdentifierIfPossible().value;if(!r)return this.error(3,xn(n,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(1,xn(n,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:1,value:r,location:xn(n,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(1,xn(n,this.clonePosition())):this.parseArgumentOptions(e,t,r,n);default:return this.error(3,xn(n,this.clonePosition()))}}parseIdentifierIfPossible(){const e=this.clonePosition(),t=this.offset(),n=zXt(this.message,t),r=t+n.length;return this.bumpTo(r),{value:n,location:xn(e,this.clonePosition())}}parseArgumentOptions(e,t,n,r){let i=this.clonePosition(),a=this.parseIdentifierIfPossible().value,o=this.clonePosition();switch(a){case"":return this.error(4,xn(i,o));case"number":case"date":case"time":{this.bumpSpace();let s=null;if(this.bumpIf(",")){this.bumpSpace();const u=this.clonePosition(),O=this.parseSimpleArgStyleIfPossible();if(O.err)return O;const d=CXt(O.val);if(d.length===0)return this.error(6,xn(this.clonePosition(),this.clonePosition()));s={style:d,styleLocation:xn(u,this.clonePosition())}}const l=this.tryParseArgumentClose(r);if(l.err)return l;const c=xn(r,this.clonePosition());if(s&&s.style.startsWith("::")){let u=qXt(s.style.slice(2));if(a==="number"){const O=this.parseNumberSkeletonFromString(u,s.styleLocation);return O.err?O:{val:{type:2,value:n,location:c,style:O.val},err:null}}else{if(u.length===0)return this.error(10,c);let O=u;this.locale&&(O=PXt(u,this.locale));const d={type:1,pattern:O,location:s.styleLocation,parsedOptions:this.shouldParseSkeletons?mXt(O):{}};return{val:{type:a==="date"?3:4,value:n,location:c,style:d},err:null}}}return{val:{type:a==="number"?2:a==="date"?3:4,value:n,location:c,style:s?.style??null},err:null}}case"plural":case"selectordinal":case"select":{const s=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(12,xn(s,{...s}));this.bumpSpace();let l=this.parseIdentifierIfPossible(),c=0;if(a!=="select"&&l.value==="offset"){if(!this.bumpIf(":"))return this.error(13,xn(this.clonePosition(),this.clonePosition()));this.bumpSpace();const f=this.tryParseDecimalInteger(13,14);if(f.err)return f;this.bumpSpace(),l=this.parseIdentifierIfPossible(),c=f.val}const u=this.tryParsePluralOrSelectOptions(e,a,t,l);if(u.err)return u;const O=this.tryParseArgumentClose(r);if(O.err)return O;const d=xn(r,this.clonePosition());return a==="select"?{val:{type:5,value:n,options:dK(u.val),location:d},err:null}:{val:{type:6,value:n,options:dK(u.val),offset:c,pluralType:a==="plural"?"cardinal":"ordinal",location:d},err:null}}default:return this.error(5,xn(i,o))}}tryParseArgumentClose(e){return this.isEOF()||this.char()!==125?this.error(1,xn(e,this.clonePosition())):(this.bump(),{val:!0,err:null})}parseSimpleArgStyleIfPossible(){let e=0;const t=this.clonePosition();for(;!this.isEOF();)switch(this.char()){case 39:{this.bump();let n=this.clonePosition();if(!this.bumpUntil("'"))return this.error(11,xn(n,this.clonePosition()));this.bump();break}case 123:e+=1,this.bump();break;case 125:if(e>0)e-=1;else return{val:this.message.slice(t.offset,this.offset()),err:null};break;default:this.bump()}return{val:this.message.slice(t.offset,this.offset()),err:null}}parseNumberSkeletonFromString(e,t){let n=[];try{n=$Xt(e)}catch{return this.error(7,t)}return{val:{type:0,tokens:n,location:t,parsedOptions:this.shouldParseSkeletons?wXt(n):{}},err:null}}tryParsePluralOrSelectOptions(e,t,n,r){let i=!1;const a=[],o=new Set;let{value:s,location:l}=r;for(;;){if(s.length===0){const d=this.clonePosition();if(t!=="select"&&this.bumpIf("=")){const f=this.tryParseDecimalInteger(16,19);if(f.err)return f;l=xn(d,this.clonePosition()),s=this.message.slice(d.offset,this.offset())}else break}if(o.has(s))return this.error(t==="select"?21:20,l);s==="other"&&(i=!0),this.bumpSpace();const c=this.clonePosition();if(!this.bumpIf("{"))return this.error(t==="select"?17:18,xn(this.clonePosition(),this.clonePosition()));const u=this.parseMessage(e+1,t,n);if(u.err)return u;const O=this.tryParseArgumentClose(c);if(O.err)return O;a.push([s,{value:u.val,location:xn(c,this.clonePosition())}]),o.add(s),this.bumpSpace(),{value:s,location:l}=this.parseIdentifierIfPossible()}return a.length===0?this.error(t==="select"?15:16,xn(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!i?this.error(22,xn(this.clonePosition(),this.clonePosition())):{val:a,err:null}}tryParseDecimalInteger(e,t){let n=1;const r=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(n=-1);let i=!1,a=0;for(;!this.isEOF();){const s=this.char();if(s>=48&&s<=57)i=!0,a=a*10+(s-48),this.bump();else break}const o=xn(r,this.clonePosition());return i?(a*=n,Number.isSafeInteger(a)?{val:a,err:null}:this.error(t,o)):this.error(e,o)}offset(){return this.position.offset}isEOF(){return this.offset()===this.message.length}clonePosition(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}}char(){const e=this.position.offset;if(e>=this.message.length)throw Error("out of bound");const t=this.message.codePointAt(e);if(t===void 0)throw Error(`Offset ${e} is at invalid UTF-16 code unit boundary`);return t}error(e,t){return{val:null,err:{kind:e,message:this.message,location:t}}}bump(){if(this.isEOF())return;const e=this.char();e===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=e<65536?1:2)}bumpIf(e){const t=this.offset();if(this.message.slice(t,t+e.length)===e){for(let n=0;n<e.length;n++)this.bump();return!0}return!1}bumpUntil(e){const t=this.offset(),n=this.message.indexOf(e,t);return n>=0?(this.bumpTo(n),!0):(this.bumpTo(this.message.length),!1)}bumpTo(e){if(this.offset()>e)throw Error(`targetOffset ${e} must be greater than or equal to the current offset ${this.offset()}`);for(e=Math.min(e,this.message.length);;){const t=this.offset();if(t===e)break;if(t>e)throw Error(`targetOffset ${e} is at invalid UTF-16 code unit boundary`);if(this.bump(),this.isEOF())break}}bumpSpace(){for(;!this.isEOF()&&YXt(this.char());)this.bump()}peek(){if(this.isEOF())return null;const e=this.char(),t=this.offset();return this.message.charCodeAt(t+(e>=65536?2:1))??null}};function X7(e){return e>=97&&e<=122||e>=65&&e<=90}function NXt(e){return X7(e)||e===47}function GXt(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function YXt(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function E7(e){e.forEach(t=>{if(delete t.location,Txe(t)||Rxe(t))for(const n in t.options)delete t.options[n].location,E7(t.options[n].value);else kxe(t)&&Exe(t.style)||(Pxe(t)||_xe(t))&&R7(t.style)?delete t.style.location:Xxe(t)&&E7(t.children)})}function IXt(e,t={}){t={shouldParseSkeletons:!0,requiresOtherClause:!0,...t};const n=new WXt(e,t).parse();if(n.err){const r=SyntaxError(SXt[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t?.captureLocation||E7(n.val),n.val}var UP=class extends Error{constructor(e,t,n){super(e),this.code=t,this.originalMessage=n}toString(){return`[formatjs Error: ${this.code}] ${this.message}`}},hK=class extends UP{constructor(e,t,n,r){super(`Invalid values for "${e}": "${t}". Options are "${Object.keys(n).join('", "')}"`,"INVALID_VALUE",r)}},ZXt=class extends UP{constructor(e,t,n){super(`Value for "${e}" must be of type ${t}`,"INVALID_VALUE",n)}},DXt=class extends UP{constructor(e,t){super(`The intl string context variable "${e}" was not provided to the string "${t}"`,"MISSING_VALUE",t)}};function VXt(e){return e.length<2?e:e.reduce((t,n)=>{const r=t[t.length-1];return!r||r.type!==0||n.type!==0?t.push(n):r.value+=n.value,t},[])}function MXt(e){return typeof e=="function"}function K1(e,t,n,r,i,a,o){if(e.length===1&&OK(e[0]))return[{type:0,value:e[0].value}];const s=[];for(const l of e){if(OK(l)){s.push({type:0,value:l.value});continue}if(QXt(l)){typeof a=="number"&&s.push({type:0,value:n.getNumberFormat(t).format(a)});continue}const{value:c}=l;if(!(i&&c in i))throw new DXt(c,o);let u=i[c];if(xXt(l)){(!u||typeof u=="string"||typeof u=="number"||typeof u=="bigint")&&(u=typeof u=="string"||typeof u=="number"||typeof u=="bigint"?String(u):""),s.push({type:typeof u=="string"?0:1,value:u});continue}if(Pxe(l)){const O=typeof l.style=="string"?r.date[l.style]:R7(l.style)?l.style.parsedOptions:void 0;s.push({type:0,value:n.getDateTimeFormat(t,O).format(u)});continue}if(_xe(l)){const O=typeof l.style=="string"?r.time[l.style]:R7(l.style)?l.style.parsedOptions:r.time.medium;s.push({type:0,value:n.getDateTimeFormat(t,O).format(u)});continue}if(kxe(l)){const O=typeof l.style=="string"?r.number[l.style]:Exe(l.style)?l.style.parsedOptions:void 0;if(O&&O.scale){const d=O.scale||1;if(typeof u=="bigint"){if(!Number.isInteger(d))throw new TypeError(`Cannot apply fractional scale ${d} to bigint value. Scale must be an integer when formatting bigint.`);u=u*BigInt(d)}else u=u*d}s.push({type:0,value:n.getNumberFormat(t,O).format(u)});continue}if(Xxe(l)){const{children:O,value:d}=l,f=i[d];if(!MXt(f))throw new ZXt(d,"function",o);let p=f(K1(O,t,n,r,i,a).map(m=>m.value));Array.isArray(p)||(p=[p]),s.push(...p.map(m=>({type:typeof m=="string"?0:1,value:m})))}if(Txe(l)){const O=u,d=(Object.prototype.hasOwnProperty.call(l.options,O)?l.options[O]:void 0)||l.options.other;if(!d)throw new hK(l.value,u,Object.keys(l.options),o);s.push(...K1(d.value,t,n,r,i));continue}if(Rxe(l)){const O=`=${u}`;let d=Object.prototype.hasOwnProperty.call(l.options,O)?l.options[O]:void 0;if(!d){if(!Intl.PluralRules)throw new UP(`Intl.PluralRules is not available in this environment.
848
848
  Try polyfilling it using "@formatjs/intl-pluralrules"
849
849
  `,"MISSING_INTL_API",o);const p=typeof u=="bigint"?Number(u):u,m=n.getPluralRules(t,{type:l.pluralType}).select(p-(l.offset||0));d=(Object.prototype.hasOwnProperty.call(l.options,m)?l.options[m]:void 0)||l.options.other}if(!d)throw new hK(l.value,u,Object.keys(l.options),o);const f=typeof u=="bigint"?Number(u):u;s.push(...K1(d.value,t,n,r,i,f-(l.offset||0)));continue}}return VXt(s)}function LXt(e,t){return t?{...e,...t,...Object.keys(e).reduce((n,r)=>(n[r]={...e[r],...t[r]},n),{})}:e}function FXt(e,t){return t?Object.keys(e).reduce((n,r)=>(n[r]=LXt(e[r],t[r]),n),{...e}):e}function _R(e){return{create(){return{get(t){return e[t]},set(t,n){e[t]=n}}}}}function BXt(e={number:{},dateTime:{},pluralRules:{}}){return{getNumberFormat:kR((...t)=>new Intl.NumberFormat(...t),{cache:_R(e.number),strategy:PR.variadic}),getDateTimeFormat:kR((...t)=>new Intl.DateTimeFormat(...t),{cache:_R(e.dateTime),strategy:PR.variadic}),getPluralRules:kR((...t)=>new Intl.PluralRules(...t),{cache:_R(e.pluralRules),strategy:PR.variadic})}}var HXt=class Pc{constructor(t,n=Pc.defaultLocale,r,i){if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=a=>{const o=this.formatToParts(a);if(o.length===1)return o[0].value;const s=o.reduce((l,c)=>(!l.length||c.type!==0||typeof l[l.length-1]!="string"?l.push(c.value):l[l.length-1]+=c.value,l),[]);return s.length<=1?s[0]||"":s},this.formatToParts=a=>K1(this.ast,this.locales,this.formatters,this.formats,a,void 0,this.message),this.resolvedOptions=()=>({locale:this.resolvedLocale?.toString()||Intl.NumberFormat.supportedLocalesOf(this.locales)[0]}),this.getAst=()=>this.ast,this.locales=n,this.resolvedLocale=Pc.resolveLocale(n),typeof t=="string"){if(this.message=t,!Pc.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");const{...a}=i||{};this.ast=Pc.__parse(t,{...a,locale:this.resolvedLocale})}else this.ast=t;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=FXt(Pc.formats,r),this.formatters=i&&i.formatters||BXt(this.formatterCache)}static{this.memoizedDefaultLocale=null}static get defaultLocale(){return Pc.memoizedDefaultLocale||(Pc.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),Pc.memoizedDefaultLocale}static{this.resolveLocale=t=>{if(typeof Intl.Locale>"u")return;const n=Intl.NumberFormat.supportedLocalesOf(t);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}}static{this.__parse=IXt}static{this.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}}}};const KXt={},JXt={},e4t={},t4t={"ui.console.close.body":"This ends the program running here and removes its tab.","ui.console.close.busy":"Closing…","ui.console.close.confirm":"Close terminal","ui.console.close.kept":"Its output is kept.","ui.console.close.title":"Close this terminal?","ui.console.create_failed.detail":"The console host is running, and refused to start a program for this conversation — so this is one attempt failing rather than the console being switched off. Trying again is the first thing to do; if it keeps failing, the line below is the host's own reason.","ui.console.create_failed.retry":"Try again","ui.console.create_failed.title":"The console could not start in this session","ui.console.empty.detail":"A console runs a program in this conversation's directory and keeps its output, whether or not this pane is open.","ui.console.empty.title":"No console in this session","ui.console.ended.exit_code":"exit code {code}","ui.console.ended.exit_unknown":"exit code not observed","ui.console.ended.live":"This terminal has ended","ui.console.ended.restored":"This terminal has ended and its history was restored","ui.console.loading.create":"Starting a console","ui.console.loading.read":"Reading this session's console","ui.console.new":"New console","ui.console.pane.blip":"Finished since you last looked","ui.console.pane.close":"Close console","ui.console.pane.close_refusal":"The terminal could not be closed.","ui.console.pane.label":"Console","ui.console.pane.needs_conversation.detail":"A console runs in a conversation's working directory, so there is nowhere to put one yet.","ui.console.pane.needs_conversation.title":"A console needs a conversation","ui.console.pane.surfaces":"Console surfaces","ui.console.secure":"Secure input is on: what you type here is not recorded.","ui.console.unavailable.disabled.detail":"LOCAL_OPERATOR_UI_CONSOLE_HOST is set to 0 in this app's environment, so no terminal is started and no surface can be created. Removing that setting turns the console back on.","ui.console.unavailable.disabled.title":"The console is switched off for this run","ui.console.unavailable.pty.detail":"Terminal support did not load for this run. Updating Local Operator restores it, and the app's log names the reason.","ui.console.unavailable.title":"The console is not available in this app","ui.console.unavailable.unknown.detail":"This window could not reach the console, and did not say why. The app's log carries the reason."},n4t={},r4t={},i4t={"ui.onboarding.connect.intro":"Local Operator needs an AI account to work. Radient is the easiest: one browser sign-in and nothing to paste. Already pay for ChatGPT or Claude? Sign in with that instead. Anything else is under More providers.","ui.onboarding.default_model.block.loading_models":"Loading the model list…","ui.onboarding.default_model.block.pick_a_model":"Pick a model to continue.","ui.onboarding.default_model.change":"Change","ui.onboarding.default_model.connected_pick":"{brand} is connected. Pick the model new chats should use.","ui.onboarding.default_model.empty_helper":"No providers are connected yet. Go back a step to connect one.","ui.onboarding.default_model.fallback_name":"{brand}'s default model","ui.onboarding.default_model.intro":"New chats use this model. Every agent can pick a different one later.","ui.onboarding.default_model.loading":"Loading your models","ui.onboarding.default_model.none_connected":"No provider is connected yet. Go back to connect one, or skip setup and connect one later from the chat.","ui.onboarding.default_model.nothing_saved":"Nothing will be saved: your Local Operator can't list {brand} models yet, so setup finishes without a default model. Pick one in Settings before your first message.","ui.onboarding.default_model.provider_fallback":"this provider's","ui.onboarding.default_model.tag.applied":"your default","ui.onboarding.default_model.tag.suggested":"suggested for your account","ui.onboarding.dialog.setup":"Setup","ui.onboarding.extras.greeting_done":"{name} is your chief of staff. Her conversation is where you pick up with her, and it is one keystroke away in the sidebar. You can also skip straight to a new chat.","ui.onboarding.extras.greeting_owed":"{name} is your chief of staff. She will say hello first, ask what to call you and what you would like help with, and show you around. You can also skip straight to a new chat.","ui.onboarding.extras.next_meet":"Next: meet {name}","ui.onboarding.modal.action.back":"Back","ui.onboarding.modal.action.continue":"Continue","ui.onboarding.modal.action.finish":"Finish","ui.onboarding.modal.action.meet":"Meet {name}","ui.onboarding.modal.action.skip":"Skip","ui.onboarding.modal.action.skip_for_now":"Skip for now","ui.onboarding.modal.action.skip_to_chat":"Skip to chat","ui.onboarding.modal.error.aida_open_failed":"{name}'s conversation could not be opened, so you are in a new chat instead.","ui.onboarding.modal.title.connect_provider":"Connect an AI account","ui.onboarding.modal.title.default_model":"Your default model","ui.onboarding.modal.title.extras":"Web search (optional)","ui.onboarding.modal.title.extras_with_name":"Web search, then meet {name}","ui.onboarding.modal.title.fallback":"First-time setup","ui.onboarding.search.each_key_saved":"Each key is saved on your device as soon as you leave its field.","ui.onboarding.search.intro":"Agents can look things up while they work — today's prices, this week's news — instead of relying on what the model already knows.","ui.onboarding.search.mode.free":"Free","ui.onboarding.search.mode.free_detail":"Uses a rotating pool of free providers — DuckDuckGo, Tavily's free tier, Exa and Parallel. No key needed; the pool is shared, so searches can be slower at busy times.","ui.onboarding.search.mode.keys":"Add API keys","ui.onboarding.search.mode.keys_detail":"Bring your own keys for the search providers you use.","ui.onboarding.search.mode.label":"Search setup","ui.onboarding.search.recommended":"Recommended","ui.onboarding.search.row.get_your":"Get your {name}","ui.onboarding.search.row.not_saved":"Not saved — {message}","ui.onboarding.search.row.placeholder":"Paste your API key","ui.onboarding.search.row.save_failed":"The key could not be saved.","ui.onboarding.search.row.saved":"Saved","ui.onboarding.search.row.saving":"Saving {name}"},a4t={},o4t={},s4t={},l4t={"ui.settings.language.effective":"In effect: {locale}","ui.settings.language.external_notice":"Interface language changed elsewhere — now {language}.","ui.settings.language.dialog.title":"Interface language","ui.settings.language.dialog.description":"Applies across the app and the terminal — the same setting the settings page edits.","ui.settings.language.dialog.save":"Save","ui.settings.language.dialog.saved":"Saved","ui.settings.language.dialog.loading":"Loading the current setting...","ui.settings.language.palette_action":"Change interface language","ui.settings.language.dialog.unavailable":"The connected service does not serve the settings this dialog edits.","ui.settings.language.dialog.retry":"Retry","ui.settings.language.dialog.retrying":"Retrying","ui.settings.language.general.description":"Choose the language shared by the app and terminal. Changes save immediately; existing conversations are not rewritten.","ui.settings.language.general.system":"Use system","ui.settings.language.general.unavailable_choice":"Not available","ui.settings.language.general.pending":"Saving language…","ui.settings.language.general.saved":"Language saved.","ui.settings.language.general.write_error":"The language was not saved. Your previous setting is unchanged. {message}","ui.settings.language.general.readback_error":"The write was confirmed, but the current setting could not be checked. Reconnect or retry before changing it again.","ui.settings.language.general.effective":"App language in effect: {locale}","ui.settings.language.general.last_known":"Last synced app language: {locale}","ui.settings.language.general.no_resolution":"The app language has not been set yet."},c4t={},u4t={...KXt,...JXt,...e4t,...t4t,...n4t,...r4t,...i4t,...a4t,...o4t,...s4t,...l4t,...c4t},O4t="i18n",d4t="en",fO="language";function f4t(){const t=globalThis.navigator?.language;return typeof t=="string"&&t.trim()!==""?t:void 0}function h4t(e){return(e?.[O4t]??0)>=1}function qxe(e){const t=e?.language;if(h4t(e?.features)&&typeof t=="string"&&t.trim()!=="")return{locale:t,source:"backend"};const n=f4t();return n?{locale:n,source:"device"}:{locale:d4t,source:"default"}}let J1=qxe(void 0);const j7=new Set;function Hp(){return J1.locale}function p4t(e){return j7.add(e),()=>{j7.delete(e)}}function m4t(e){if(!(e.locale===J1.locale&&e.source===J1.source)){J1=e;for(const t of[...j7])t()}}function ROn(e){m4t(qxe(e))}const g4t=new Map;function $4t(e,t){return g4t.get(t)?.[e]??u4t[e]}const pK=new Map;function y4t(e,t){const n=`${e}\0${t}`;let r=pK.get(n);return r===void 0&&(r=new HXt(t,e),pK.set(n,r)),r}function v4t(e,t={},n=Hp()){const r=$4t(e,n);if(r===void 0)return e;try{const i=y4t(n,r).format(t);return typeof i=="string"?i:String(i)}catch{return e}}function qU(e,t){return v4t(e,t??{})}const mK=new Map,gK=new Map;function Cxe(e){return e===void 0?"":JSON.stringify(e)}function CU(e,t){const n=`${e}\0${Cxe(t)}`;let r=mK.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),mK.set(n,r)),r}function b4t(e,t){const n=`${e}\0${Cxe(t)}`;let r=gK.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),gK.set(n,r)),r}function Axe(e,t,n){return CU(n??Hp(),t).format(e)}function w4t(e,t,n){return CU(n??Hp(),t).format(e)}function S4t(e,t,n){return CU(Hp(),t).format(e)}function zxe(e,t,n){return b4t(n,t).format(e)}const x4t=5e3;let Uxe=0;function Q4t(e=x4t){Uxe=Date.now()+e}function XOn(e=Date.now()){return e<=Uxe}function k4t(e){Q4t(),e.invalidateQueries({queryKey:Hr.capabilities})}const EOn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":Axe(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},P4t=(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=w4t(n,{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=Axe(n,{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),""}},_4t=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":S4t(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},T4t={turn:"Sent",answer:"Answered",tool:"Ran"},Wxe=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=sXt();if(Number.isNaN(r.getTime()))return null;const a=_4t(r,{hour12:!0});return h.jsx(Ut,{content:a,side:"bottom",delayDuration:1200,children:h.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${T4t[t]} ${a}`,className:j("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:P4t(r,i)})})},AU=({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(Q9e,{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(Li,{"aria-hidden":"true"})})]},n.id))]}),R4t=({children:e,className:t})=>h.jsx("span",{"aria-hidden":!0,className:j("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),X4t={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},E4t=({line:e})=>h.jsx("span",{className:j(X4t[e.kind],"block"),children:e.text}),j4t=({diff:e,className:t})=>{const n=kje(e);return h.jsxs("div",{className:j("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>h.jsx(E4t,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:Pje(n.hidden)})]})},q4t=(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()},$K=e=>e.startsWith("file://")?e.slice(7):e,C4t={READ:{verb:"Read",runningVerb:"Reading",icon:bz},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:vue},EDIT:{verb:"Edited",runningVerb:"Editing",icon:Z9e},CODE:{verb:"Ran code",runningVerb:"Running code",icon:cue},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:a8e},DONE:{verb:"Finished",runningVerb:"Finishing",icon:CA},ASK:{verb:"Asked",runningVerb:"Asking",icon:hk},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:Aze}},A4t={verb:"Worked on the request",runningVerb:"Working on the request",icon:cue},z4t=(e,t,n,r)=>{const i=e?C4t[e]:A4t;let a;if(t)a=$K(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=$K(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?q4t(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},yK="min-h-5 py-0",U4t=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>h.jsxs("span",{className:j("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[h.jsx(R4t,{className:j(a?"text-danger":"text-ink-dim",o&&TOe),children:e}),h.jsxs("span",{className:j(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[h.jsxs("span",{...U_,className:j("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?h.jsxs("span",{...U_,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?h.jsxs("span",{...U_,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),vK=({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=z4t(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?bp:p.icon,y=a||!c||!O?h.jsx(g,{}):O,v=h.jsx(U4t,{icon:y,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(_a,{summary:v,chevron:"leading",summaryAlign:w,defaultOpen:o,className:l,rowClassName:f?yK:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx(_a,{disabled:!0,summary:v,summaryAlign:w,className:l,rowClassName:f?yK:void 0})},Nxe=8,W4t="… deeper values not shown",N4t="(empty)";function G4t(e){return`… ${e} more line${e===1?"":"s"}`}const bK=.5;function Y4t(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 Gxe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function zU(e){return typeof e=="object"&&e!==null}function Yxe(e,t,n,r){if(n>Nxe){r.push({key:t,value:W4t,depth:n});return}if(zU(e)){for(const[a,o]of Object.entries(e))Yxe(o,t?`${t}.${a}`:a,n+1,r);return}const i=Gxe(e);i!==null&&r.push({key:t,value:i,depth:n})}function Ixe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))Yxe(r,n,1,t);return t}const I4t=512;function Z4t(e,t){if(t)return!0;if(!e)return!1;let n=I4t;const r=(i,a)=>{if(n--<=0||a>Nxe)return!0;if(!zU(i))return Gxe(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 D4t(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(!zU(n))return null;const r=Ixe(n);return r.length>0?r:[{key:"",value:N4t,depth:1}]}const V4t=8,q7="max-h-[min(320px,40vh)]",M4t=q7,L4t=({line:e})=>h.jsxs("div",{className:j("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*V4t},children:[e.key?h.jsxs("span",{className:j("text-ink-muted"),children:[e.key,": "]}):null,h.jsx("span",{className:j("text-ink-dim"),children:e.value})]}),wK=({lines:e,label:t})=>h.jsx("div",{className:j("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>h.jsx(L4t,{line:n},r))});function SK(e){const[t,n]=$.useState(0),[r,i]=$.useState(!1);return $.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+bK);const f=c.children.length>0?Array.from(c.children):[c];n(Y4t(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,bK))};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 xK=({lines:e,overflowing:t})=>t?h.jsx("span",{className:j("mt-1 block text-ink-dim"),children:e>0?G4t(e):" "}):null,F4t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=Ixe(e),o=D4t(t),s=$.useRef(null),l=$.useRef(null),c=SK(s),u=SK(l);return a.length===0&&!t&&!i?null:h.jsxs("div",{className:j("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&h.jsxs("div",{"data-detail-section":"input",children:[h.jsx("div",{ref:s,className:j(q7,"overflow-auto"),children:h.jsx(wK,{lines:a,label:"input"})}),h.jsx(xK,{lines:c.lines,overflowing:c.overflowing})]}),i&&h.jsx("div",{className:j("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&h.jsxs("div",{className:j(a.length>0&&"mt-3"),"data-detail-section":"output",children:[h.jsx("span",{className:j("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),h.jsx("div",{ref:l,className:j(q7,"overflow-auto"),children:o?h.jsx(wK,{lines:o,label:"result-json"}):h.jsx("pre",{className:j("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(xK,{lines:u.lines,overflowing:u.overflowing})]})]})},B4t="mcp__",H4t={bash:c8e,read:$k,write:UY,edit:UY,glob:_p,grep:hv,todo:p9e,wake:pk,list_variables:GY,read_variable:GY,browser:WY,console:Sz,project:Rze,project_delete:O8e,web_search:WY,web_fetch:gk,task:Vd,agent:Vd,send:Sue,peer:s9e,sessions:M9e};function K4t(e){const t=e.trim().toLowerCase(),n=H4t[t];return n||(t.startsWith(B4t)?bue:y8e)}const J4t=wz,eEt=b9e,tEt=y9e,QK="min-h-5 py-0",kK={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},nEt=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?kK.plain:kK[hje(t)],rEt=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",iEt=({added:e,removed:t})=>e<=0&&t<=0?null:h.jsxs("span",{className:j("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&h.jsxs("span",{className:j("text-success"),children:["+",e]}),t>0&&h.jsxs("span",{className:j("text-danger"),children:["-",t]})]}),TR={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},aEt=1e3;function oEt(e){const[t,n]=$.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return $.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,aEt);return()=>window.clearInterval(i)},[e]),t}const sEt=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=oEt(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?nje[t]:void 0,c=s?l??null:o?l??TR[e]:null,O=j("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?aje[t]??null:null,f=s&&t?rje[t]:void 0,p=s?t==="mailbox"?eEt:t==="unconfirmed"?tEt:null:e==="interrupted"?J4t:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":Hl(a??0):MA(n);return h.jsxs("span",{className:j("flex shrink-0 items-center gap-1.5"),children:[c?h.jsx("span",{className:O,title:f,"aria-hidden":d?!0:void 0,children:c}):null,h.jsxs("span",{className:j("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",m),children:[p?h.jsx(p,{"aria-hidden":!0}):null,!o&&TR[e]?h.jsx("span",{className:j("sr-only"),children:TR[e]}):null,d?h.jsx("span",{className:j("sr-only"),children:d}):null]}),h.jsx("span",{className:j("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:g})]})},vO=({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",y=o==="error",v=K4t(e),w=cf(e),{verb:x,object:b}=Cle(e,r,i,g,t,sje(s)),S=h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),children:[h.jsx("span",{"aria-hidden":!0,className:j("flex size-3.5 shrink-0 [&_svg]:size-3.5",nEt(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:j("shrink-0 whitespace-nowrap text-body-sm",rEt(o)),title:w,children:x}),h.jsx("span",{className:j("min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:b,children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),h.jsx("span",{className:j("sr-only"),children:"pending"})]}):b}),h.jsx(iEt,{added:u,removed:O}),h.jsx(sEt,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?"bg-elevated":y?"bg-danger-wash":"hover:bg-row-hover",P=d?h.jsx(_a,{summary:S,chevron:"leading",defaultOpen:f,className:j("@container/toolrow",p),rowClassName:QK,triggerClassName:j("-mx-2 rounded-sm px-2",Q),children:d}):h.jsx(_a,{disabled:!0,summary:S,rowClassName:QK,className:j("@container/toolrow",(g||y)&&j("-mx-2 rounded-sm px-2",Q),p)});return m?h.jsxs("div",{className:j("flex flex-col"),children:[P,m]}):P},lEt=3,Zxe=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},C7=e=>{const t=new Map;let n=0;for(const a of e){const o=Zxe(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=OEt(dEt(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}},cEt=e=>C7(e).units;function uEt(e){return cEt(e).join(" · ")}const PK={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"}},RR=5,OEt=e=>{if(e.length<=RR)return e.map(r=>r.label);const t=e.slice(0,RR),n=e.slice(RR).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},dEt=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=Zxe(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",PK.todo);else{const u=PK[l];if(u)n(`kind:${l}`,u);else{const O=cf(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 fEt(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 hEt(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=fEt(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 pEt(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return Cle(n.name,n.summary??"",null,!0,n.op)}return null}function mEt(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.filter(s=>t.isReceipt?.(s)),o=r.filter(s=>t.isFoldable(s)).map(s=>{const l={name:t.nameOf(s),failed:t.failedOf(s),durationS:t.durationOf?t.durationOf(s):null,startedAtMs:t.startedAtOf?t.startedAtOf(s):null,endedAtMs:t.endedAtOf?t.endedAtOf(s):null};return t.summaryOf&&(l.summary=t.summaryOf(s)),t.opOf&&(l.op=t.opOf(s)),t.runningOf&&(l.running=t.runningOf(s)),t.executingOf&&(l.executing=t.executingOf(s)),l});if(o.length>=lEt)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:o,summary:{...C7(o),units:[...C7(o).units,...t.receiptSummaryOf?.(a)??[]]},failedCount:o.filter(s=>s.failed).length,span:hEt(o),live:pEt(o)});else for(const s of r)n.push({kind:"row",row:s});r=[]};for(const a of e){if((a.gap==="turn"||a.gap==="first")&&i(),t.isFoldable(a)||t.isReceipt?.(a)){r.push(a);continue}i(),n.push({kind:"row",row:a})}return i(),n}const _K=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&n.record.customType==="hub_message")))for(const r of n.record.images??[])ok(r)&&t.push(r);return t},eS=5,gEt=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<eS?{shown:Math.max(e,0),more:0}:{shown:eS-1,more:e-(eS-1)},$Et=e=>{const t=eS-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},Ux=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function Wx(e){return e.record.kind==="tool"?e.record.durationS:null}function A7(e){let t=null;for(const n of e){const r=Wx(n);typeof r=="number"&&(t=(t??0)+r)}return t}function yEt(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 vEt="min-h-5 py-0",bEt=1e3;function wEt(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,bEt);return()=>window.clearInterval(i)},[e]),t}const SEt=({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=wEt(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":MA(d),p=$.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(_a,{open:i,onOpenChange:a,rowClassName:vEt,triggerClassName:j("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),children:[r!==null&&!i&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{"data-fold-live":"",className:j("min-w-0 shrink-[100000] truncate"),title:`${r.verb} ${r.object}`,children:[h.jsx("span",{className:j("text-accent"),children:r.verb})," ",h.jsx("span",{className:j("font-mono text-mono-sm text-ink-muted"),children:r.object})]}),h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"})]}),h.jsx("span",{className:j("min-w-0 break-words text-body-sm text-ink-muted"),title:`${t} actions`,"data-fold-summary":"",children:e.units.map((g,y)=>h.jsxs($.Fragment,{children:[y>0&&h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:j(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),Ux(l)!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{className:j("shrink-0 text-ink-muted text-meta"),children:Ux(l)})]}),f!==""&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{"data-fold-span":"",className:j("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:f})]})]}),children:h.jsx("div",{className:j("flex flex-col"),children:u})}),!i&&s&&s(m)]})},xEt="min-h-5 py-0",Yg=()=>h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),QEt=({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,group:g=null})=>{const y=o?`${a}+ actions`:a===1?"1 action":`${a} actions`,v=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,w=g===null?null:`At least ${g.count} messages — earlier rows are not loaded`,x=$.useRef(null),b=()=>{x.current?.querySelector("button[aria-expanded]")?.focus(),d(!0)};return h.jsxs("div",{ref:x,className:j("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u?"true":void 0,"data-record-id":n,children:[h.jsx(_a,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:xEt,triggerClassName:j("-ml-2 -mr-2 w-[calc(100%+1rem)] rounded-sm pl-2 pr-6","hover:bg-row-hover"),chevronClassName:j("-mr-6","text-ink-muted"),summary:h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&h.jsx(h.Fragment,{children:h.jsx(CA,{"aria-hidden":!0,className:j("size-3.5 shrink-0 text-success")})}),g!==null?h.jsxs(h.Fragment,{children:[c!==null&&h.jsx(Yg,{}),h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),title:o?w??void 0:void 0,"aria-label":o?w??void 0:void 0,children:o?`${g.count}+`:`${g.count}`}),g.spanS!==null&&h.jsxs(h.Fragment,{children:[h.jsx(Yg,{}),h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:Hl(g.spanS)})]})]}):h.jsxs(h.Fragment,{children:[c!==null&&(i!==null||a>0)&&h.jsx(Yg,{}),i!==null&&h.jsxs("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:["Took ",Hl(i)]}),i!==null&&a>0&&h.jsx(Yg,{}),a>0&&h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),title:o?v:void 0,"aria-label":o?v:void 0,children:y})]}),Ux(m)!==null&&h.jsxs(h.Fragment,{children:[h.jsx(Yg,{}),h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:Ux(m)})]}),u&&h.jsx("span",{className:j("sr-only"),children:"completed"}),l!==null&&h.jsx("span",{className:j("ml-auto"),children:h.jsx(Wxe,{timestamp:l,scope:"answer"})})]}),children:h.jsx("div",{className:j("flex flex-col"),children:f})}),!O&&p&&h.jsx("div",{className:j("pb-2"),children:p(b)})]})},Dxe=e=>{const t=$.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=$.useCallback(()=>window.matchMedia(e).matches,[e]);return $.useSyncExternalStore(t,n,()=>!1)},TK=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],kEt=80,PEt=1e3,_Et=({activity:e,phase:t,startedAt:n,clock:r,className:i})=>{const[a,o]=$.useState(0),[s,l]=$.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),[c,u]=$.useState(!1),O=r!==!1&&!c,d=Dxe("(prefers-reduced-motion: reduce)"),f=$.useRef(n??Date.now()),p=$.useRef(t),m=$.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=$.useRef(r!==!1),y=$.useRef(t);return $.useEffect(()=>{const v=r!==!1,w=g.current,x=y.current===t;g.current=v,y.current=t,!w&&v&&x&&l(Math.floor((Date.now()-f.current)/1e3))},[r,t]),$.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-f.current)/1e3)),PEt):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const w=window.setInterval(()=>o(x=>(x+1)%TK.length),kEt);return()=>{window.clearInterval(w),v!==null&&window.clearInterval(v)}},[d,O]),h.jsxs("div",{className:j("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[h.jsx("span",{"aria-hidden":!0,className:j("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:TK[a]}),h.jsx("span",{className:j("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),h.jsx("span",{"aria-hidden":!0,className:j("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?Hl(s):""})]})},Vxe="lo-missing-session-notice",TEt=/^\s*<reply-to>([\s\S]*?)<\/reply-to>/,UU=e=>{const t=[];let n=e;for(;;){const r=TEt.exec(n);if(r===null)break;t.push({id:is(),text:r[1]}),n=n.slice(r[0].length)}return{replies:t,remainingContent:n.trim()}},by=({children:e,className:t,boundary:n="hairline",...r})=>h.jsx("div",{className:j("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm",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}),REt="could not be displayed. It may have been moved, renamed, or deleted.",WU="could not be displayed. Its stored copy is not available to this reader.",XEt="could not be played. Its stored copy is not available to this reader.",wy=({name:e,detail:t=REt,className:n,compact:r=!1})=>r?h.jsx("div",{className:j("flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken",n),role:"img","aria-label":`${e} ${t}`,title:`${e} ${t}`,children:h.jsx(NY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):h.jsxs("div",{className:j("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[h.jsx(NY,{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}`]})]}),xd=1,Mxe=4,RK=(e,t)=>Math.min(Mxe,Math.max(xd,e+t)),Ig=Object.freeze({x:0,y:0}),XR=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),ER=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,EEt=(e,t)=>`Image ${e+1} of ${t}`,XK=(e,t,n)=>{const r=Math.max(0,n-1)/2,i=t.width*r||0,a=t.height*r||0;return{x:Math.min(i,Math.max(-i,e.x)),y:Math.min(a,Math.max(-a,e.y))}},jEt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",qEt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",EK=e=>j(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),CEt="opacity-45",NU=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a,pending:o=!1,group:s,layerRef:l})=>{const[c,u]=$.useState(null),O=e!==void 0&&c===e,[d,f]=$.useState(xd),[p,m]=$.useState(Ig),g=$.useRef(e);$.useLayoutEffect(()=>{g.current!==e&&(g.current=e,f(xd),m(Ig))},[e]);const[y,v]=$.useState(!0),w=$.useRef(null);$.useEffect(()=>{if(!n)return;let z;const ie=()=>{clearTimeout(z),z=setTimeout(()=>{const H=w.current;if(H&&(H.matches(":hover")||H.contains(document.activeElement))){ie();return}v(!1)},LOe)},F=()=>{v(!0),ie()};return v(!0),ie(),document.addEventListener("pointermove",F,{passive:!0}),document.addEventListener("pointerdown",F,{passive:!0}),document.addEventListener("keydown",F),document.addEventListener("focusin",F),()=>{clearTimeout(z),document.removeEventListener("pointermove",F),document.removeEventListener("pointerdown",F),document.removeEventListener("keydown",F),document.removeEventListener("focusin",F)}},[n]);const x=s?.onPrev,b=s?.onNext,S=s!==void 0&&s.count>1,Q=S?qEt:jEt,P=$.useRef(null),T=l??P;$.useEffect(()=>{if(!n||!S)return;const z=ie=>{ie.defaultPrevented||ie.metaKey||ie.ctrlKey||ie.altKey||(ie.key==="ArrowLeft"?(ie.preventDefault(),x?.()):ie.key==="ArrowRight"&&(ie.preventDefault(),b?.()))};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[n,S,x,b]),_A(n,"image-lightbox");const _=$.useRef(null),E=e!==void 0&&!O,C=d===xd&&p.x===Ig.x&&p.y===Ig.y,A=z=>{if(!E)return;f(z);const ie=_.current;ie&&m(F=>XK(F,{width:ie.clientWidth,height:ie.clientHeight},z))},U=()=>{E&&(f(xd),m(Ig))},N=$.useRef(null),[Z,G]=$.useState(!1),D=E&&d>xd,I=z=>{!D||z.button!==0||(z.currentTarget.setPointerCapture(z.pointerId),N.current={pointerId:z.pointerId,startX:z.clientX,startY:z.clientY,pan:p},G(!0))},W=z=>{const ie=N.current,F=_.current;!ie||ie.pointerId!==z.pointerId||!F||m(XK({x:ie.pan.x+(z.clientX-ie.startX),y:ie.pan.y+(z.clientY-ie.startY)},{width:F.clientWidth,height:F.clientHeight},d))},J=z=>{N.current?.pointerId===z.pointerId&&(N.current=null,G(!1))},ee=e!==void 0&&!O?h.jsx("div",{ref:_,"data-image-viewport":"",tabIndex:-1,className:j(Q,"relative h-fit w-fit overflow-hidden leading-none outline-none",D&&(Z?"cursor-grabbing":"cursor-grab"),D&&"touch-none"),onPointerDown:I,onPointerMove:W,onPointerUp:J,onPointerCancel:J,children:h.jsx("img",{src:e,alt:t,draggable:!1,className:j(Q,"block select-none object-contain"),style:C?void 0:{transform:`translate(${p.x}px, ${p.y}px) scale(${d})`},onError:()=>u(e)})}):e===void 0&&o?h.jsx("div",{className:EK(Q),"aria-hidden":"true"}):h.jsx("div",{className:EK(Q),children:a});return h.jsx(TA,{open:n,onOpenChange:r,children:h.jsxs(RA,{ref:T,tabIndex:-1,onOpenAutoFocus:z=>{z.preventDefault(),(_.current??T.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:z=>{const ie=i?.current;ie&&(z.preventDefault(),ie.focus())},className:j("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",Q,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx(XA,{className:"sr-only",children:t}),S&&s?h.jsx("div",{"aria-live":"polite",className:"sr-only",children:EEt(s.index,s.count)}):null,ee,h.jsxs("div",{ref:w,"data-image-viewer-controls":"",className:j("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",y?"opacity-100 duration-fast":`${CEt} duration-base`),children:[S&&s?.filmstrip?h.jsx("div",{className:"pointer-events-auto fixed inset-x-0 bottom-4 mx-auto w-fit max-w-[calc(100vw-256px)]",children:s.filmstrip}):null,S?h.jsxs(h.Fragment,{children:[h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Previous image",title:"Previous image",onClick:s?.onPrev,className:"pointer-events-auto fixed top-0 bottom-0 left-4 my-auto","data-image-viewer-prev":"",children:h.jsx(fze,{"aria-hidden":"true"})}),h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Next image",title:"Next image",onClick:s?.onNext,className:"pointer-events-auto fixed top-0 right-4 bottom-0 my-auto","data-image-viewer-next":"",children:h.jsx(Zse,{"aria-hidden":"true"})})]}):null,h.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",title:"Zoom out",disabled:!E||d===xd,onClick:()=>A(RK(d,-1)),children:h.jsx(Pue,{"aria-hidden":"true"})}),h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",title:"Zoom in",disabled:!E||d===Mxe,onClick:()=>A(RK(d,1)),children:h.jsx(kue,{"aria-hidden":"true"})}),h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",title:"Reset view",disabled:!E||C,onClick:U,children:h.jsx(yk,{"aria-hidden":"true"})})]}),h.jsx(fRe,{asChild:!0,children:h.jsx(Ae,{variant:"ghost",size:"icon-sm",className:j("pointer-events-auto fixed top-4 right-4"),"aria-label":"Close image",title:"Close image",children:h.jsx(Li,{"aria-hidden":"true"})})})]})]})})};NU.displayName="ImageLightbox";const AEt={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(" ")},zEt=/[/\\]/,jK=e=>{const t=e.split(zEt);return t[t.length-1]},Lxe=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o})=>{const[s,l]=$.useState(!1),[c,u]=$.useState(!1),[O,d]=$.useState(!1),f=$.useRef(null),p=ar(T=>T.setCanvasOpen),{setViewMode:m}=jd(),g=$.useCallback(async()=>{const T=jK(e),_=U=>{U&&console.error("Error processing file:",U);const N=e.startsWith("file://")?e.substring(7):e;window.api.openFile(N).catch(Z=>{console.error("Error opening file:",Z)})},{setFiles:E,setOpenTabs:C,setSelectedTab:A}=jd.getState();if(e.startsWith("data:"))if(b7(T)){const U=e,N={id:U,title:T,path:U,content:e,type:DS(e)},G=jd.getState().conversations?.[n],D=G?.files??[],I=G?.openTabs??[],W=(()=>{const z=D.findIndex(ie=>ie.id===U);return z!==-1?[...D.slice(0,z),N,...D.slice(z+1)]:[...D,N]})();E(n,W);const ee=I.some(z=>z.id===U)?I:[...I,{id:U,title:T}];C(n,ee),A(n,U),p(!0),m(n,"documents")}else p(!0),m(n,"files");else{const U=e.startsWith("file://")?e.substring(7):e;try{const N=await window.api.readFile(U);if(N.success&&b7(T)){const Z=U,G={id:Z,title:T,path:U,content:N.data,type:DS(e)},I=jd.getState().conversations?.[n],W=I?.files??[],J=I?.openTabs??[],ee=(()=>{const F=W.findIndex(H=>H.id===Z);return F!==-1?[...W.slice(0,F),G,...W.slice(F+1)]:[...W,G]})();E(n,ee);const ie=J.some(F=>F.id===Z)?J:[...J,{id:Z,title:T}];C(n,ie),A(n,Z),p(!0),m(n,"documents");return}p(!0),m(n,"files")}catch(N){const Z=N instanceof Error?N.message:String(N??"Unknown error reading file");return _(Z)}}},[e,p,m,n]),y=()=>{l(!0)},v=ixe(e),x=(v==="path"||v==="data")&&n!=="",b=oxe(v,{canShowInCanvas:x,source:t}),S=v==="path",Q=r??jK(e);if(s)return h.jsx(wy,{name:Q,compact:i==="thumbnail"});const P=h.jsx(by,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:j(AEt[i],c?"opacity-100":"opacity-0"),src:t,alt:Q,onLoad:()=>u(!0),onError:y})});return h.jsxs("div",{className:"group relative inline-block",children:[h.jsx("button",{ref:f,type:"button",className:j("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>d(!0),"aria-label":o?o.label:`Expand ${Q}`,title:o?o.title:`Click to expand ${Q}`,"aria-current":o?.current?"true":void 0,children:P}),b&&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:T=>{T.stopPropagation()},onKeyDown:T=>T.stopPropagation(),children:h.jsx(sxe,{file:e,src:t,label:Q,onShowInCanvas:x?g:void 0})}),o?null:a?a({open:O,onOpenChange:d,restoreFocusTo:f}):h.jsx(NU,{src:t,label:Q,open:O,onOpenChange:d,restoreFocusTo:f,fallback:h.jsx(wy,{name:Q,detail:S?void 0:WU})})]})});Lxe.displayName="ImageAttachment";const tS=new Map;function UEt(e,t){const n=tS.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await lf(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=qde(i.data,i.mimeType);return r.holders<=0?(Pk(a),null):(Ade(t,a),a)}catch{return null}finally{tS.delete(t)}})(),tS.set(t,r),r.promise}function WEt(e){const t=tS.get(e);t&&(t.holders-=1)}function Fxe(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?Cde(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=jS(u);if(d)return i(d),o(!1),()=>{O=!1,qS(u)};i(null),o(!1);let f=!0;return UEt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(jS(u))}}),()=>{O=!1,f&&WEt(u),qS(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}function Bxe(e,t){return Fxe(e,t)}const NEt=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),GEt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},YEt=({cold:e,children:t})=>e?h.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,IEt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=NEt})=>{const s=e.length,[l,c]=$.useState(()=>XR(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(XR(t,s)));const d=XR(l,s),f=e[d]??GEt,p=o(f,d,s),m=Bxe(f,n),g=$.useRef(null),y=$.useRef(null),[v,w]=$.useState(!1),x=$.useCallback(G=>{g.current=G,w(G!==null)},[]),b=G=>{const D=g.current?.querySelector(`button[aria-label="Show image ${G+1} of ${s}"]`);D?D.focus():y.current?.focus()},S=G=>{const D=ER(d,s,G),I=g.current?.contains(document.activeElement)??!1;c(D),I&&b(D)},Q=()=>S(-1),P=()=>S(1),T=JSON.stringify([n?.sessionId,n?.childId,e.map(G=>[G.id,G.attachment,G.mimeType])]),[_,E]=$.useState(()=>({identity:T,open:r,indices:new Set}));(_.identity!==T||_.open!==r)&&E({identity:T,open:r,indices:new Set});const C=$.useCallback(G=>{E(D=>{if(!r||D.identity!==T||!D.open||G.every(W=>D.indices.has(W)))return D;const I=new Set(D.indices);for(const W of G)I.add(W);return{...D,indices:I}})},[T,r]),A=ER(d,s,-1),U=ER(d,s,1);$.useEffect(()=>{r&&C([d,A,U])},[r,d,A,U,C]),$.useEffect(()=>{const G=g.current;if(!r||!v||!G||typeof IntersectionObserver>"u")return;let D=!0;const I=new IntersectionObserver(W=>{D&&C(W.filter(J=>J.isIntersecting).map(J=>Number(J.target.dataset.imageSlot)-1))},{root:G});for(const W of G.querySelectorAll("[data-image-slot]"))I.observe(W);return()=>{D=!1,I.disconnect()}},[r,v,C]);const N=(G,D)=>!!G.data||!G.attachment||D===d||D===A||D===U||_.identity===T&&_.open&&_.indices.has(D);$.useEffect(()=>{(g.current?.querySelector(`[data-image-slot="${d+1}"]`)??g.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[v,d]);const Z=s>1?h.jsx("ul",{role:"list",ref:x,"aria-label":`${s} images`,"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((G,D)=>h.jsx("li",{"data-image-slot":D+1,className:j("flex shrink-0 scroll-mx-px rounded-sm leading-none",D===d&&"ring-1 ring-ink"),children:h.jsx(YEt,{cold:!!G.attachment&&!G.data,children:N(G,D)?h.jsx(Dm,{image:G,scope:n,size:"thumbnail",label:o(G,D,s),press:{onPress:()=>c(D),label:`Show image ${D+1} of ${s}`,title:`Show image ${D+1} of ${s}`,current:D===d}}):h.jsx("button",{type:"button","aria-label":`Show image ${D+1} of ${s}`,title:`Show image ${D+1} of ${s}`,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{C([D]),c(D)},children:h.jsx(by,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},G.id))}):void 0;return h.jsx(NU,{src:m.state==="ready"?m.url:void 0,pending:m.state==="resolving",label:p,open:r,onOpenChange:i,restoreFocusTo:a,fallback:h.jsx(wy,{name:p,detail:WU}),layerRef:y,group:{index:d,count:s,onPrev:Q,onNext:P,filmstrip:Z}})},Dm=({image:e,scope:t,label:n,size:r,group:i,press:a})=>{const o=Bxe(e,t);if(o.state==="resolving"){const l=h.jsx(by,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""});return a?h.jsx("button",{type:"button","aria-label":a.label,title:a.title,"aria-current":a.current||void 0,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:a.onPress,children:l}):h.jsx("div",{className:j("inline-block max-w-full"),"aria-hidden":!0,children:l})}if(o.state==="missing")return h.jsx(wy,{name:n,compact:r==="thumbnail",detail:WU});const s=o.url;return h.jsx("div",{className:j("inline-block max-w-full"),children:h.jsx(Lxe,{file:s,src:s,label:n,size:r,conversationId:t?.sessionId??"",press:a,overlay:i?l=>h.jsx(IEt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:l.open,onOpenChange:l.onOpenChange,restoreFocusTo:l.restoreFocusTo}):void 0})})},ZEt="Generating name…",DEt={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 VEt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function GU(e,t){return`Turn ${e} of ${t}`}const MEt=e=>e.charAt(0).toLowerCase()+e.slice(1);function LEt(e,t){const n=GU(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function FEt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function BEt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function HEt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const KEt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function JEt(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 ejt(e,t){const n=MEt(GU(e.turn,t));if(e.kind==="user"){const i=JEt(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 tjt(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 jR(e,t){const n=[];for(const r of t)tjt(e,r)==="pending"&&n.push(r);return n}const njt=120,qK=80,rjt="Turn checkpoints",ijt={complete:bu,error:bp,interrupted:wz,open:bze},ajt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},ojt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?ijt[n]:null,i=BEt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:j("text-body-sm font-medium text-ink"),children:[GU(e.turn,t),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:j("font-normal text-ink-muted"),children:a})]})]}),FEt(e)&&h.jsx("p",{className:j("text-ink-dim text-meta"),children:ZEt}),i&&h.jsx("p",{className:j("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&h.jsx("div",{className:j("flex items-center gap-1.5 text-ink-dim text-meta"),children:h.jsxs("span",{className:j("flex items-center gap-1",ajt[n]),children:[h.jsx(r,{"aria-hidden":"true",className:j("size-3.5 shrink-0")}),KEt[n]]})})]})},sjt=$.memo(function({checkpoint:t,state:n,label:r,roving:i,registerTick:a,onPreview:o,onPreviewEnd:s,onFocusMark:l,onBlurMark:c,onActivate:u,onKeyMark:O,describedBy:d}){const f=p=>{p.pointerType!=="touch"&&o(t.id)};return h.jsx("button",{ref:p=>a(t.id,p),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":d,tabIndex:i?0:-1,className:j("group pointer-events-auto block h-2.5 w-7"),onPointerMove:f,onPointerLeave:s,onFocus:()=>l(t.id),onBlur:c,onClick:()=>u(t.id),onKeyDown:p=>O(p,t.id),children:h.jsx("span",{"aria-hidden":"true",className:j("ml-auto mr-1.5 block h-0.5 w-5 origin-right rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",DEt[n])})})}),ljt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{const s=$.useId(),[l,c]=$.useState(null),[u,O]=$.useState(null),[d,f]=$.useState(null),p=$.useRef(t);p.current=t;const m=$.useRef(new Map),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),w=$.useCallback(()=>{y.current!==null&&(clearTimeout(y.current),y.current=null),v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),x=$.useCallback((L,K)=>{w();const re=()=>{O(L),f(p.current.find(Oe=>Oe.id===L)??null)};if(K<=0){re();return}y.current=setTimeout(()=>{y.current=null,re()},K)},[w]),b=$.useCallback(L=>{if(w(),L<=0){O(null);return}v.current=setTimeout(()=>{v.current=null,O(null)},L)},[w]),S=$.useRef(e);$.useEffect(()=>{S.current!==e&&(S.current=e,w(),J.current=null,c(null),O(null),f(null))},[e,w]);const Q=$.useRef(null);$.useLayoutEffect(()=>{const L=g.current;if(!(t.length===0||L===null)){if(o!==null&&P.current===e){Q.current=e;return}Q.current!==e&&(Q.current=e,L.scrollTop=L.scrollHeight)}},[o,t.length,e]);const P=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const L=g.current,K=m.current.get(o);if(L===null||K===void 0)return;P.current=e;const re=L.getBoundingClientRect(),Oe=K.getBoundingClientRect(),se=Oe.top-re.top+L.scrollTop,$e=se+Oe.height,ye=24;se<L.scrollTop+ye?L.scrollTop=Math.max(0,se-ye):$e>L.scrollTop+L.clientHeight-ye&&(L.scrollTop=$e-L.clientHeight+ye)},[o,e]),$.useEffect(()=>()=>w(),[w]);const T=$.useRef(r);$.useEffect(()=>{T.current=r});const _=$.useMemo(()=>HEt(t),[t]),E=$.useMemo(()=>new Map(t.map(L=>[L.id,ejt(L,_)])),[t,_]),C=u&&d?.id===u?d:null,A=u&&m.current.get(u)||null,U=$.useMemo(()=>({current:A}),[A]),N=C!==null&&A!==null;$.useEffect(()=>{T.current(N&&u?u:null)},[N,u]);const Z=$.useCallback((L,K)=>{K?m.current.set(L,K):m.current.delete(L)},[]),[G,D]=$.useState(null),I=G&&t.some(L=>L.id===G)?G:t[0]?.id??null,W=$.useCallback(L=>{const K=Math.max(0,Math.min(t.length-1,L)),re=t[K];re&&(D(re.id),m.current.get(re.id)?.focus())},[t]),J=$.useRef(null),ee=$.useCallback(L=>{J.current!==L&&(J.current=L,c(L),x(L,njt))},[x]),z=$.useCallback(()=>{J.current=null,c(L=>L===null?L:null),b(qK)},[b]),ie=$.useCallback(L=>{J.current=L,D(L),c(K=>K===L?K:L),x(L,0)},[x]),F=$.useCallback(()=>{J.current=null,c(L=>L===null?L:null),b(qK)},[b]),H=$.useCallback(L=>{b(0),J.current=null,c(null),n(L)},[b,n]),oe=$.useCallback((L,K)=>{if(L.key==="Escape"){b(0);return}const re=t.findIndex(Oe=>Oe.id===K);if(!(re<0)){if(L.key==="ArrowDown"){L.preventDefault(),L.stopPropagation(),W(re+1);return}if(L.key==="ArrowUp"){L.preventDefault(),L.stopPropagation(),W(re-1);return}if(L.key==="Home"){L.preventDefault(),L.stopPropagation(),W(0);return}L.key==="End"&&(L.preventDefault(),L.stopPropagation(),W(t.length-1))}},[t,b,W]);return t.length===0&&!i?null:h.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":rjt,className:j("pointer-events-none absolute inset-y-0 right-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[h.jsxs("div",{"data-rail-frame":"",ref:g,className:j("max-h-[min(calc(100%-4rem),420px)] w-7 overflow-y-auto overscroll-contain","[&::-webkit-scrollbar]:hidden","[mask-image:linear-gradient(to_bottom,transparent_0,#000_24px,#000_calc(100%-24px),transparent_100%)]"),children:[i&&h.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:j("ml-auto mr-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),h.jsx("div",{"data-rail-track":"",className:"py-6",children:t.map(L=>h.jsx(sjt,{checkpoint:L,state:VEt({id:L.id,previewId:l,activeId:o,loaded:a?a.has(L.id):!0}),label:E.get(L.id)??"",roving:L.id===I,registerTick:Z,onPreview:ee,onPreviewEnd:z,onFocusMark:ie,onBlurMark:F,onActivate:H,onKeyMark:oe,describedBy:N&&u===L.id?s:void 0},L.id))})]}),h.jsxs(hRe,{open:N,onOpenChange:L=>{L||b(0)},children:[h.jsx(pRe,{virtualRef:U}),C&&h.jsx(mRe,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":C.kind==="user"?"Your message":LEt(C,_),onOpenAutoFocus:L=>L.preventDefault(),onCloseAutoFocus:L=>L.preventDefault(),onFocusOutside:L=>{const K=L.detail?.originalEvent?.target;K instanceof Element&&K.closest("[data-lo-checkpoint-rail]")&&L.preventDefault()},className:j("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:C.kind==="user"?h.jsx("div",{"data-checkpoint-card-text":"",className:j("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:C.text}):h.jsx(ojt,{checkpoint:C,turnCount:_})})]})]})},cjt=$.memo(ljt);function ujt(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 Ojt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function djt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function Hxe(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):!Ojt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function fjt(e,t){return djt(e,t)||Hxe(e,t)!==null}const hjt=3;function pjt(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>=hjt){n.onMissing();return}const s=Hxe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const CK=(e,t,n)=>n===1?"Image":`Image ${t+1}`,AK=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=gEt(e.length,{uncapped:r}),s=$Et(a),l=s.length>1,c=new Set;for(let O=0,d=0;d<s.length;d+=1)c.add(O),O+=s[d];const u=e.slice(0,a).map((O,d)=>h.jsx("li",{className:j("flex leading-none",l&&c.has(d)&&"col-start-1"),children:h.jsx(Dm,{image:O,scope:t,size:"thumbnail",label:CK(O,d,e.length),group:{images:e,index:d,labelFor:CK}})},O.id));return h.jsxs("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-fold-media":"",className:j("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ml-5":"ml-0"),children:[u,o>0&&h.jsx("li",{className:j("flex h-[78px] items-center leading-none"),children:h.jsx(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 mjt(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 gjt(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 $jt=({video:e,scope:t,label:n})=>{const r=Fxe(e,t),[i,a]=$.useState(!1);return r.state==="missing"||i?h.jsx(wy,{name:n,detail:XEt}):r.state==="resolving"?h.jsx("div",{className:j("inline-block max-w-full self-start"),"aria-hidden":!0,children:h.jsx(by,{"data-attachment-reserved":""})}):h.jsx("div",{className:j("inline-block max-w-full self-start"),children:h.jsx(by,{children:h.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:j("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})},Kxe="generate_video",yjt=new Set(["generate_image",Kxe]);function vjt(e){return yjt.has(e)}function Jxe(e){return e===Kxe}function bjt(e){return Jxe(e)?"video":"image"}function wjt(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 Sjt(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:wjt(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 zK(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?eQe:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const eQe=Object.freeze({fraction:null,logs:[],queuePosition:null});function xjt(e,{stopping:t=!1}={}){const n=Sjt(e.details),r=bjt(e.toolName);if(e.stopped===!0)return{state:"cancelled"};if(e.notRunKind==="skipped"||e.notRunKind==="aborted")return{state:"cancelled"};if(e.notRunReason)return{state:"failed",material:r,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??[],material:r,durationS:e.durationS??null,receipt:"already-finished"}:n.stage==="cancelled"&&n.errorType===null?{state:"cancelled"}:{state:"failed",material:r,message:n.error??e.output,errorType:n.errorType};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,startedAtMs:null,progress:eQe}:{state:"queued",composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:n.queuePosition};case"running":{const i=e.startedAt??null;return t?{state:"cancelling",generating:!0,startedAtMs:i,progress:zK(n)}:{state:"running",material:r,startedAtMs:i,progress:zK(n),note:n.error}}case"done":return{state:"done",images:e.images??[],material:r,durationS:e.durationS??null,receipt:"generated"}}}function Qjt(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}function kjt(e,t){if(!Jxe(e))return t?{onCancel:t}:void 0}const Pjt=1e3;function _jt(e){const[t,n]=$.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return $.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,Pjt);return()=>window.clearInterval(i)},[e]),t}function Tjt(){return h.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:j("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:h.jsx("span",{className:j("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 Rjt({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?h1(e.argumentBytes):null;break;case"running":n=e.material==="video"?"Generating video…":"Generating image…",r=t===null?null:Hl(t);break;case"cancelling":n="Cancelling…";break;case"done":n=e.receipt==="already-finished"?"Already finished.":e.material==="video"?"Generated video":"Generated image",r=e.receipt==="already-finished"||e.durationS===null?null:MA(e.durationS);break;case"failed":n=e.message??(e.material==="video"?"The video could not be generated.":"The image could not be generated."),i=!0;break;case"cancelled":n="Cancelled";break}return h.jsxs("p",{className:j("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[h.jsx("span",{className:j("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:h.jsxs("span",{className:j("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function Xjt({line:e}){return h.jsx("p",{"data-imagegen-log":"",title:e,className:j("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function Ejt({line:e}){return h.jsx("p",{"data-imagegen-note":"",className:j("min-w-0 text-body-sm text-ink-dim"),children:e})}function jjt(e,t){return e==="cancel"?"Cancel":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const qjt=({view:e,scope:t,actions:n})=>{const r=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,i=_jt(r),a=Qjt(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:j("flex w-full flex-col gap-2"),children:[l?h.jsx(Tjt,{}):null,h.jsx(Rjt,{view:e,elapsed:i}),e.state==="running"&&typeof e.note=="string"?h.jsx(Ejt,{line:e.note}):null,l&&e.progress.fraction!==null?h.jsx(gRe,{"aria-label":"Image generation progress",className:j("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,c===null?null:h.jsx(Xjt,{line:c}),e.state==="done"&&e.images.length>0?h.jsx("div",{className:j("flex flex-col gap-2"),children:e.images.map((u,O)=>{const d=u.kind==="video"?"Generated video":"Generated image",f=e.images.length===1?d:`${d} ${O+1}`;return u.kind==="video"?h.jsx($jt,{video:u,scope:t,label:f},u.id):h.jsx(Dm,{image:u,scope:t,label:f},u.id)})}):null,a.length>0?h.jsx("div",{"data-imagegen-controls":"",className:j("flex items-center gap-2"),children:a.map(u=>h.jsx(Ae,{variant:"secondary",size:"sm",disabled:u.disabled,onClick:o[u.kind],children:jjt(u.kind,e.state)},u.kind))}):null]})},n$=1e4,tQe=/\s/,Cjt=e=>{for(let t=e.length;t>0;t-=1){const n=e[t-1];if(n===`
850
850
  `)return t;if(n==="."||n==="!"||n==="?"){const r=e[t];if(r===void 0||tQe.test(r))return t}}return-1},Ajt=e=>{for(let t=e.length;t>0;t-=1)if(tQe.test(e[t-1]))return t;return-1},zjt=/[\uD800-\uDBFF]/,Ujt=e=>zjt.test(e[n$-1])?n$-1:n$;function YU(e){if(e.length<=n$)return{text:e,clipped:!1};const t=e.slice(0,n$),n=Cjt(t),r=Ajt(t),i=n>0?n:r>0?r:Ujt(t),a=e.slice(0,i).trimEnd();return{text:a.length>0?a:t,clipped:!0}}const nQe="[speech]",Wjt="Couldn't speak this aloud. Try again.",Njt="Couldn't speak this aloud. Try again.",rQe="This conversation's agent is no longer available.",Gjt=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.",rQe,"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 Yjt(e){const t=e instanceof Error?e.message:String(e);return Gjt.has(t)?t:(console.error(`${nQe} ${t}`),Wjt)}function Ijt(e){return(e instanceof Error?e.message:String(e))===rQe}function Zjt(e){const t=e?.binding?.agent;return typeof t=="string"&&t.length>0?t:null}function Djt(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 Vjt=100;function Mjt(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 qR(e){try{return await e()}catch{return null}}async function Ljt(e){if(!e)return null;const t=pv(Uf.baseUrl),n=await qR(async()=>{const{profiles:a}=await _e({op:"profiles.list"});return Djt(e,a)});if(n?.state==="agent")return n.agentId;if(n?.state==="role-without-agent")return null;const r=await qR(async()=>{const a=await t.agents.listAgents(1,Vjt,e);return a.status<400?Mjt(e,a.result??null):null});return r||await qR(async()=>{const a=await t.agents.getAgent(e);return a.status<400?a.result?.id??null:null})}function IU(e){return br(t=>e?Zjt(t.sessions.find(n=>n.session_id===e)):null)}const Fjt=20,iQe=e=>`msg:${e}`,Bjt=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")},Nx=(e,t)=>`sel:${e}:${Bjt(t)}`,ZU=(e,t)=>async()=>{const n=()=>UK.speech.create({input:t}),r=await Ljt(e);return r===null?n():UK.speech.createForAgent(r,{input_text:t}).catch(i=>{if(!Ijt(i))throw i;return n()})},UK=pv(Uf.baseUrl),Hjt=e=>{for(;e.size>Fjt;){const t=e.keys().next().value;if(t===void 0)return;e.delete(t)}},CR=new Map,Kjt=(e,t)=>{let n=CR.get(e);return n===void 0&&(n=t().finally(()=>{CR.delete(e)}),CR.set(e,n)),n},Zv=Fi((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 Kjt(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),Hjt(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(`${nQe} playback failed for ${n}`),Mi(Njt))},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}),Mi(Yjt(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(iQe(n),ZU(r,i))}}));function DU({key:e,getText:t,play:n,available:r=!0}){const{dismiss:i,stopSpeech:a,loadingKey:o,playingKey:s,audioCache:l,heardKeys:c}=Zv(),{canUseRadientSpeech:u,speechBlock:O}=RYe(),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:AOe("speaking-aloud",O),y=!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:y,reason:g,active:d||f,press:()=>{if(d){a();return}if(f){e!==null&&i(e);return}if(y)return;const b=t();if(b===null||b.trim().length===0)return;const{text:S,clipped:Q}=YU(b);Q&&!p&&Pp(`Reading the first ${S.length.toLocaleString("en-US")} characters. The rest is not read aloud.`),n({text:S})}}}function aQe(e){$.useEffect(()=>{if(e!==null)return()=>{Zv.getState().dismiss(e)}},[e])}const VU=({control:e,side:t="top"})=>{const n=$.useId(),r=e.disabled&&e.reason!==null;return h.jsx(Ut,{content:e.tooltip,side:t,children:h.jsxs("span",{className:j("flex"),tabIndex:r?0:void 0,"aria-describedby":r?n:void 0,children:[h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":e.label,className:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:e.press,disabled:e.disabled,children:e.isPlaying?h.jsx($1,{"aria-hidden":"true"}):e.isLoading?h.jsx(hs,{size:"xs"}):h.jsx(g8e,{"aria-hidden":"true"})}),r&&h.jsx("span",{id:n,className:"sr-only",children:e.reason})]})})},Vm="data-lo-quote-toolkit";function z7(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const WK=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${Vm}]`)??null,Jjt=e=>e.nodeType===Node.ELEMENT_NODE,e3t=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>Jjt(r)&&r.hasAttribute(Vm));return n===-1?t.length:n},t3t=(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,n3t=e=>{const t=Array.from(document.querySelectorAll(`[${Vm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>t3t(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function Sy(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(WK(n.startContainer)||WK(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,e3t(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:n3t(n)}}const oQe=8,r3t=.5;function i3t(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 NK=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function a3t({lines:e,container:t,viewport:n,size:r,gap:i=oQe,row:a,belowWhenOffFirstLine:o=!1}){if(e.length===0)return null;const s=i3t(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*r3t,d=l.top-i-r.height>=s.top,f=c.bottom+i+r.height<=s.bottom,m=d&&!(o&&O&&f);return{top:NK(m?l.top-i-r.height:c.bottom+i,s.top,s.bottom-r.height),left:NK(l.left,s.left,s.right-r.width),placement:m?"above":"below"}}const GK="[data-lo-canonical-transcript]",o3t="[data-lo-transcript-content]",YK=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),s3t=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function sQe(e){const{turnRef:t,visible:n,lines:r,measureKey:i,belowWhenOffFirstLine:a}=e,o=$.useRef(null),[s,l]=$.useState(null),c=$.useRef(r);c.current=r;const u=$.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=a3t({lines:f,container:YK((O.closest(GK)??O).getBoundingClientRect()),viewport:s3t(),size:{width:d.offsetWidth,height:d.offsetHeight},row:YK(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),m=O.getBoundingClientRect(),g=p?{top:p.top-m.top,left:p.left-m.left,placement:p.placement}:null;l(y=>y===g||y&&g&&y.top===g.top&&y.left===g.left&&y.placement===g.placement?y:g)},[t,a]);return $.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(GK),p=f?.querySelector(o3t),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 lQe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(Sy(e.current)?.text??null);return i(),document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[e]);const r=$.useCallback(()=>n(null),[]);return{text:t,clear:r}}const Uh="data-lo-link-toolbar",l3t=120,c3t=2;function cQe(e){const[t,n]=$.useState(null),[r,i]=$.useState(!1),a=$.useRef(null);a.current=t;const o=$.useRef(null),s=$.useRef(null),l=$.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=OTt(u);if(O){n(f=>f===O?f:O),i(f=>f===!0?f:!0);return}if(i(f=>f===!1?f:!1),kSe()){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]);$.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()},l3t))},p=(Q,P)=>{const T=o.current;if(!T||!u.contains(T))return!1;const _=u.querySelector(`[${Uh}]`),E=oQe+c3t;for(const C of[T,_]){if(!C)continue;const A=C.getBoundingClientRect();if(!(A.width<=0||A.height<=0)&&Q>=A.left-E&&Q<=A.right+E&&P>=A.top-E&&P<=A.bottom+E)return!0}return!1},m=Q=>{const P=Q.target;if(P?.closest(`[${Vm}]`))return;const T=P?.closest(zh)??null;!T&&p(Q.clientX,Q.clientY)||f(T)},g=Q=>{const P=Q.relatedTarget;P&&u.contains(P)||p(Q.clientX,Q.clientY)||d(null)},y=Q=>{const P=Q.target?.closest(zh);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(`[${Uh}] button:not([disabled])`)),x=Q=>{const P=Q.target;if(!P)return!1;if(P.closest(`[${Uh}]`)){const C=w(),A=C.indexOf(P);if(A===-1)return!1;if(Q.shiftKey&&A===0){const U=o.current;return U instanceof HTMLElement?(U.focus(),!0):!1}if(!Q.shiftKey&&A===C.length-1){const U=Array.from(u.querySelectorAll(zh)),N=o.current,Z=N?U.indexOf(N)+1:-1,G=Z>0?U[Z]:void 0;return G?(G.focus(),!0):!1}return!1}if(Q.shiftKey)return!1;const _=P.closest(zh);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 T=Q.target?.closest(zh);!T||!u.contains(T)||(Q.preventDefault(),d(T),requestAnimationFrame(()=>{u.querySelector(`[${Uh}] 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",y),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",y),u.removeEventListener("focusout",v),u.removeEventListener("keydown",b),document.removeEventListener("pointerdown",S,!0),document.removeEventListener("selectionchange",l)}},[e,l]);const c=$.useCallback(()=>{s.current=a.current,o.current=null,l()},[l]);return $.useEffect(()=>{if(!t)return;const u=O=>{if(O.key!=="Escape"||O.target?.closest(`[${Uh}]`))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 uQe(e,t,n){const r=cn(i=>i.addReply);return $.useCallback(()=>{const a=Sy(t.current)?.text??(kSe()?null:n?.()??null);a&&(r(e,{id:is(),text:a}),window.getSelection()?.removeAllRanges(),qz())},[r,e,t,n])}const OQe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(xSe)??"",o=n.getAttribute("data-lo-kind")??"file",s=_P(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=uQe(e,t,l),{text:u}=lQe(t),{speak:O}=Zv(),d=IU(e),f=u??l(),p=f===null?null:Nx(e,YU(f).text);aQe(p);const m=DU({key:p,getText:()=>Sy(t.current)?.text??l(),play:({text:N})=>O(Nx(e,N),ZU(d,N))}),[g,y]=$.useState(!1),[v,w]=$.useState(()=>B1(a)??null),{controlRef:x,placement:b}=sQe({turnRef:t,visible:!0,lines:()=>{const N=n.getClientRects();return Array.from(N,Z=>({top:Z.top,left:Z.left,right:Z.right,bottom:Z.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const N=B1(a);if(w(N??null),y(!1),N!==void 0)return;let Z=!0;return sTt(a,window.api?.probeFiles).then(()=>{Z&&w(B1(a)??null)}),()=>{Z=!1}},[a]);const S=o==="file"&&wU(s,a),Q=TSe({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:S}),P=hTt({kind:o,target:a,probe:v,quotable:r,canOpenInCanvas:S});if(!P||!a)return null;const T=async()=>{await ESe(a)&&y(!0)},_=async()=>{if(o==="url"){await UH(o,a);return}s&&Q&&await s.openInCanvas(a)||await UH(o,a)||w(null)},E=async()=>{await AO(a)||w(null)},C=async()=>{await SU(a)||w(null)},A={quote:h.jsx(wue,{}),copy:g?h.jsx(bu,{}):h.jsx(mk,{}),open:Q?h.jsx(N9e,{}):o==="url"?h.jsx(Oue,{}):h.jsx(fv,{}),"open-default":h.jsx(aze,{}),"open-folder":h.jsx(_p,{})},U={quote:c,copy:()=>{T()},open:()=>{_()},"open-default":()=>{E()},"open-folder":()=>{C()}};return h.jsxs("div",{[Vm]:"",[Uh]:"",ref:x,role:"toolbar","aria-label":P.label,className:j("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!b&&"invisible"),style:b?{top:b.top,left:b.left}:void 0,onMouseDown:N=>N.preventDefault(),onKeyDown:N=>{if(N.key!=="Escape")return;window.getSelection()?.removeAllRanges();const Z=n;N.preventDefault(),i(),Z.focus?.()},children:[P.actions.map(N=>h.jsxs($.Fragment,{children:[h.jsx(Ut,{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:U[N.id],children:A[N.id]})}),N.id==="quote"&&h.jsx(VU,{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 u3t({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:["copy","speak",...n]}function dQe(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const IK=96;function O3t(e){const t=e.replace(/\s+/g," ").trim();return t.length<=IK?t:`${t.slice(0,IK-1).trimEnd()}…`}const d3t="Answer actions",f3t="Your message actions",h3t="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 p3t(e){return e?"opacity-100":h3t}const m3t=2e3,g3t=1e4;function jOn(e){const{request:t}=e;return t?e.now-t.requestedAt>g3t?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let ZK=0,Gw=0;const $3t=Fi(e=>({request:null,requestPanel:(t,n,r,i)=>{ZK+=1,e({request:{destination:t,nonce:ZK,requestedAt:Date.now(),invoker:n??null,...r?{sessionId:r}:{},...i?.id?{entryId:i.id}:{},...i?.id&&i.excerpt?{entryExcerpt:i.excerpt}:{},...r&&i?.subjectName?{subjectName:i.subjectName}:{}}})},consumePanel:t=>e(n=>n.request?.nonce===t?{request:null}:n),presenterClaimed:!1,claimPresenter:()=>{Gw+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Gw=Math.max(0,Gw-1),Gw===0&&e({presenterClaimed:!1}))}}})),y3t=(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)},v3t=9e4,DK=new Set,b3t=2600,fQe=$.memo(function({bodyText:t,kind:n="answer",agentId:r,speechId:i,revealId:a,revealAt:o,conversationId:s,entryId:l}){const[c,u]=$.useState(!1),[O,d]=$.useState(!1),f=$.useRef(null),p=$.useRef(null),m=$.useRef(null),g=$.useRef(null),{playSpeech:y}=Zv(),v=IU(r??null),w=DU({key:i?iQe(i):null,getText:()=>t,play:({text:E})=>{i&&y(i,v,E)}}),x=$3t(E=>E.requestPanel),S=u3t({role:n,forkable:!!(s&&l)}),Q=c||w.active;$.useEffect(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]),$.useEffect(()=>{if(!a||o===void 0||DK.has(a)||(DK.add(a),Date.now()-o>v3t))return;const E=p.current;if(E===null)return;const C=E.closest(".group")??E;if(y3t(E,C))return;d(!0);const A=()=>{d(!1),C.removeEventListener("pointerenter",A),C.removeEventListener("focusin",A)};return C.addEventListener("pointerenter",A),C.addEventListener("focusin",A),()=>{C.removeEventListener("pointerenter",A),C.removeEventListener("focusin",A)}},[a,o]),$.useEffect(()=>{if(O)return g.current=setTimeout(()=>{g.current=null,d(!1)},b3t),()=>{g.current!==null&&clearTimeout(g.current)}},[O]);const P=async()=>{await ESe(t)&&(u(!0),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,u(!1)},m3t))},T=()=>{!s||!l||x("session.fork",m.current,s,{id:l,excerpt:O3t(t)})},_={copy:h.jsx(Ut,{content:c?"Copied":"Copy",side:"bottom",children:h.jsx(Ae,{variant:"ghost",size:"icon-sm","aria-label":c?"Copied":"Copy",className:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:P,children:c?h.jsx(bu,{"aria-hidden":"true"}):h.jsx(mk,{"aria-hidden":"true"})})}),speak:h.jsx(VU,{control:w,side:"bottom"}),fork:h.jsx(Ut,{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:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:T,children:h.jsx(Kze,{"aria-hidden":"true"})})})};return h.jsx("div",{role:"toolbar","aria-label":n==="user"?f3t:d3t,ref:p,onAnimationEnd:E=>{E.target===E.currentTarget&&d(!1)},...O?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:{"data-lo-answer-actions":""},className:j("flex shrink-0 items-center gap-1",p3t(Q)),children:S.map(E=>h.jsx($.Fragment,{children:_[E]},E))})}),w3t="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Yw="@min-[260px]/olderhistory:hidden",Iw="@max-[260px]/olderhistory:hidden",hQe="lo-older-history-hint",S3t=({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:w3t,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:Yw,children:"Not loaded"}),h.jsx("span",{className:Iw,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:Yw,children:"Did not load"}),h.jsx("span",{className:Iw,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(hs,{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:hQe,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:Yw,children:t?"Earlier history above":"Scroll up for earlier"}),h.jsxs("span",{className:Iw,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:Yw,children:"Earlier not loaded"}),h.jsx("span",{className:Iw,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"})]})},x3t="/settings?section=providers",VK="/settings?section=providers&provider=radient",Q3t="/settings?section=radient",MK=/sign in to radient/i,k3t=[/insufficient credits/i,/credit balance is too low/i],P3t=[/rate limit or quota/i],_3t=[/insufficient credits/i,/\bHTTP 402\b/i];function pQe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function MU(e){return pQe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&_3t.some(n=>n.test(e.text)):!1}function T3t(e){if(!MU(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 R3t(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function LK(e){const t=pQe(e.provider)||MK.test(e.text);let n=R3t(e.category);return MU(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(MK.test(e.text)?n="sign-in":k3t.some(r=>r.test(e.text))?n="billing":P3t.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:"Sign in to Radient",to:VK}:n==="billing"&&t?{label:"Open Radient account",to:Q3t}:{label:"Open provider settings",to:t?VK:x3t}}const mQe=({conversationId:e,turnRef:t})=>{const{text:n,clear:r}=lQe(t),i=n!==null,a=uQe(e,t),{controlRef:o,placement:s}=sQe({turnRef:t,visible:i,lines:()=>Sy(t.current)?.lines??null}),{speak:l}=Zv(),c=IU(e),u=n===null?null:Nx(e,YU(n).text);aQe(u);const O=DU({key:u,getText:()=>Sy(t.current)?.text??null,play:({text:d})=>l(Nx(e,d),ZU(c,d))});return $.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",{[Vm]:"",ref:o,className:j("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!s&&"invisible"),style:s?{top:s.top,left:s.left}:void 0,onMouseDown:d=>d.preventDefault(),children:[h.jsx(Ut,{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(wue,{})})}),h.jsx(VU,{control:O,side:s?.placement==="below"?"bottom":"top"})]}):null},gQe={all:["radient-prices"],prices:()=>[...gQe.all,"prices"]},X3t=()=>{const e=Et({queryKey:gQe.prices(),queryFn:()=>Gz({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}},FK="https://console.radienthq.com/dashboard/verification",BK="https://console.radienthq.com/dashboard/billing",HK="Top up in Radient console";function E3t(e){return!e.email_verified&&e.signup_grant!=="claimed"}const qOn=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,U7=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,j3t=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`${U7(e)} in free credits`;function KK(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function q3t(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const C3t=(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 A3t(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:FK},{label:HK,url:BK}]};if(E3t(e)){const i=KK(e.claim_url,FK),{action:a}=C3t(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 ${j3t(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 ${U7(n.bonus_amount)} free on your first top-up of ${U7(n.minimum_purchase)} or more.`),{state:"verified",lines:r,links:[{label:HK,url:KK(n?.topup_url,BK)}]}}const z3t=5*1e3,U3t=({action:e})=>{const{user:t,accountRead:n}=WOe({staleTime:z3t,retryOnMount:!1}),r=xi(),{prices:i}=X3t(),o=r.isPending||n==="checking"?null:A3t(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(JQ,{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:()=>q3t(s.url),children:s.label},s.url)),h.jsx(Ae,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx(oue,{to:e.to,children:e.label})})]})]})},AR=(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)},$Qe=24,yQe=6,W7=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),JK=async e=>{for(let t=0;t<yQe;t+=1){if(e())return;await W7()}},vQe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},W3t=e=>{const t=vQe(e.loadOlder),n=()=>JK(()=>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 JK(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},b0="data-jump-highlight",N3t=1400,G3t=12,Y3t=1200,I3t=yQe,Z3t=I3t+2,D3t=2,V3t=30,eJ=1,Zg=$Qe;let Qh=0;async function M3t(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await W3t({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:G3t,maxRows:Y3t})==="landed"}async function L3t(e,t){Qh+=1;const n=Qh;AR(e,t,"reversed",Zg);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<Z3t&&(await W7(),!(i||n!==Qh));c+=1){const u=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Zg;if(Math.abs(u)<=eJ){if(s+=1,s>=D3t){l=!0;break}continue}s=0,AR(e,t,"reversed",Zg)}if(l&&!i&&n===Qh){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<V3t;d+=1){if(await W7(),i||n!==Qh||!c.isConnected||!u.isConnected)return;const f=u.getBoundingClientRect().top-c.getBoundingClientRect().top-c.clientTop-Zg;if(Math.abs(f)<=eJ)continue;AR(c,u,"reversed",Zg);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===Qh){const s=e.ownerDocument?.defaultView;s!=null&&e.dispatchEvent(new s.Event("scroll"))}}function bQe(e,t,n){return new Promise(r=>{pjt(e,n,{onRevealed:i=>{tJ(i),L3t(t,i).then(()=>{i.isConnected&&!i.hasAttribute(b0)&&tJ(i),r("landed")})},onMissing:()=>{r("missing")}})})}const zR=new WeakMap;function tJ(e){const t=zR.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(b0);e.removeAttribute(b0),n&&e.offsetHeight,e.setAttribute(b0,""),zR.set(e,window.setTimeout(()=>{zR.delete(e),e.removeAttribute(b0)},N3t))}const Bh=120,Zw=400,F3t=.5,B3t=320,H3t=900,K3t=64,LU=2,UR=24,WR=3,J3t=4,xy=12,eqt=xy,tqt=120,nqt=.35,nJ=12,rqt=8,iqt=xy,aqt=.5,rJ=()=>({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}),wQe=e=>Math.min(H3t,Math.max(B3t,Math.round(e*F3t))),oqt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=Zw?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=Zw?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=Zw?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>=Zw,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>=K3t&&!e.travelledSinceLatch?{...r,armed:!0,clampLatched:!1,travelledSinceLatch:!0}:{...e,lastInputAt:t.at}:e.busy?{...r,retained:!0}:{...r,armed:!0}},Dw=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=LU,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 SQe(e,t=wQe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const sqt=(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=wQe(t.clientHeight),{inZone:a}=SQe(t,i),o=n-e.lastInputAt>=Bh||t.distanceFromTopPx<=LU,s=e.revealsThisAct<iqt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<nJ&&s)return o?Dw({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed)return e.deliberate?Dw(e,r,t):r==="fetch"&&e.failures>=WR?{action:"none",state:{...e,armed:!1}}:o?a?r==="fetch"&&e.actFetchSpent?{action:"none",state:{...e,armed:!1}}:Dw(e,r,t):{action:"none",state:{...e,armed:!1}}:{action:"none",state:e};if(e.continuation){const l=e.actAsks<eqt,c=l&&e.chainInvisible>0&&e.chainInvisible<xy;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<nJ:(c||l&&e.chainFetch<J3t)&&e.failures<WR)?Dw({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},iJ=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<rqt,l=r===null&&t&&i!==null&&i<Math.max(tqt,nqt*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,xy):0,continuation:t&&n>0||c&&e.chainInvisible+1<xy||!e.retained&&!e.turnedAround}},lqt=e=>({...e,busy:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),cqt=e=>({...e,busy:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),uqt=(e,t,n,r)=>n===r?xQe(e,t):null,xQe=(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)<aqt?0:n},Oqt="lo-supplement",dqt="s";function fqt(e,t){return`${Oqt}://${dqt}/${e}/${t}`}const hqt="[supplement] frame torn down after a second load (hostile navigation or a blocked attempt)";function pqt(e){let t=e.parentElement;for(;t;){const n=window.getComputedStyle(t);if((n.overflowY==="auto"||n.overflowY==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function mqt({component:e,sessionId:t,documentHtml:n,documentFailed:r=!1,onRetry:i,onHeightChange:a,className:o}){const s=Zle(e),[l,c]=$.useState(s),[u,O]=$.useState(!1),[d,f]=$.useState(!0),p=$.useRef(null),m=$.useRef(null),g=$.useRef(""),y=$.useRef(!1),v=$.useRef(""),w=$.useRef(()=>{}),x=$.useRef(0),b=$.useRef(s),S=$.useRef(null),Q=$.useRef(()=>{}),P=$.useRef(a),T=$.useRef(()=>{}),_=$.useCallback(E=>{y.current||(y.current=!0,v.current=E,O(!0))},[]);return $.useEffect(()=>{if(n===null)return;const E=m.current;if(!E)return;g.current=O3e();const C=window.api?.desktop?.armSupplementFrame,A=t!==null&&yS(e.attachment);let U;if(C===void 0)U=p3e(n);else if(A)U=fqt(t,e.attachment);else{_("no-address");return}let N=!1,Z=!1,G=null,D=null,I=null;const W={resize:null,error:!1},J=window.setTimeout(()=>{N||_("no-ready")},AG),ee=re=>{E.contentWindow?.postMessage(re,"*")},z=()=>{y.current||D===null&&(ee({lo:"supplement-host",t:"ping"}),D=window.setTimeout(()=>{D=null,_("no-pong")},AG))};w.current=()=>{Z||y.current||(Z=!0,z(),G=window.setInterval(z,c3e))};const ie=re=>{const Oe=p.current;if(Oe){const se=pqt(Oe);if(se&&Oe.getBoundingClientRect().top<se.getBoundingClientRect().top){S.current=re,P.current?.(re);return}}S.current=null,P.current?.(re),re!==b.current&&(b.current=re,c(re))},F=()=>{I===null&&(I=window.requestAnimationFrame(()=>{I=null;const{resize:re,error:Oe}=W;if(W.resize=null,W.error=!1,Oe){_("frame-error");return}re!==null&&ie(re)}))},H=re=>{if(y.current||re.source!==E.contentWindow||re.origin!=="null")return;const Oe=u3e(re.data,g.current);if(Oe){if(Oe.t==="ready"){N||(N=!0,window.clearTimeout(J));return}if(Oe.t==="pong"){D!==null&&(window.clearTimeout(D),D=null);return}if(Oe.t==="resize"){W.resize=Dle(Oe.h),f(!1),F();return}W.error=!0,F()}},oe=()=>{const re=S.current;re!==null&&ie(re)};window.addEventListener("message",H),window.addEventListener("scroll",oe,!0);let L=!1;return(async()=>{if(C)try{await C(U)}catch{}L||(E.src=U)})(),()=>{L=!0,window.clearTimeout(J),G!==null&&window.clearInterval(G),D!==null&&window.clearTimeout(D),I!==null&&window.cancelAnimationFrame(I),window.removeEventListener("message",H),window.removeEventListener("scroll",oe,!0),w.current=()=>{}}},[n,_,t,e.attachment]),P.current=a,T.current=E=>{y.current||x.current!==1||m.current?.contentWindow?.postMessage({lo:"supplement-host",t:"theme",mode:E.mode,vars:E.vars,nonce:g.current},"*")},$.useEffect(()=>h3e(E=>T.current(E)),[]),Q.current=()=>{const E=x.current+1;if(x.current=E,E>1){console.debug(hqt),_("second-load");return}T.current(Ile()),w.current()},u||r?h.jsxs("div",{className:"text-ink-dim text-meta","data-supplement-frame-fallback":r?"document":v.current,children:["Couldn't render this graphic",i&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"px-1 text-ink-dim",children:"·"}),h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-frame-retry":"",onClick:()=>i(),children:"Retry"})]})]}):h.jsxs("div",{className:o,"data-supplement-frame-box":"",children:[h.jsxs("div",{ref:p,"data-supplement-frame":"",className:"relative overflow-hidden",style:{height:l,width:"100%"},children:[n!==null&&h.jsx("iframe",{ref:m,title:e.title,sandbox:"allow-scripts",onLoad:()=>Q.current(),className:"block h-full w-full border-0"}),d&&h.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 animate-shimmer bg-elevated/40 bg-gradient-to-r from-transparent via-elevated/60 to-transparent bg-[length:200%_100%] bg-[position:-200%_50%] bg-no-repeat"})]}),h.jsxs("span",{className:"block truncate text-ink-muted text-meta",title:`Source: ${e.source}`,"data-supplement-source":"",children:["Source: ",Zd(e.source)]})]})}const gqt=2*1024*1024,Hh=new Map,NR=new Map,$qt=64,aJ={html:null,failed:!1};async function yqt(e,t){const n=`${e}:${t}`,r=NR.get(n);if(r)return r;const i=(async()=>{try{const a=await lf({op:"sessions.supplementDocument",sessionId:e,digest:t},null);if(a.kind!=="json")return null;const o=a.body,s=o&&typeof o.html=="string"?o.html:null;if(s===null||s.length>gqt)return null;for(Hh.set(n,s);Hh.size>$qt;){const l=Hh.keys().next().value;if(l===void 0)break;Hh.delete(l)}return s}catch{return null}finally{NR.delete(n)}})();return NR.set(n,i),i}function vqt(e,t,n){const[r,i]=$.useState(()=>{if(!e||!yS(t))return aJ;const a=Hh.get(`${e}:${t}`);return a!==void 0?{html:a,failed:!1}:aJ});return $.useEffect(()=>{if(!n||!e||!yS(t))return;const a=Hh.get(`${e}:${t}`);if(a!==void 0){i({html:a,failed:!1});return}let o=!1;return yqt(e,t).then(s=>{o||i(s!==null?{html:s,failed:!1}:{html:null,failed:!0})}),()=>{o=!0}},[n,e,t]),r}function bqt({path:e}){switch(Ede(e)){case"image":return h.jsx(Gze,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return h.jsx(Zze,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return h.jsx($k,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return h.jsx(fv,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}const GR=$.memo(function({actionPath:t,label:n,suffix:r,size:i,pane:a}){const o=wqt(a,t),[s,l]=$.useState(!1),c=async()=>{o&&a&&await a.openInCanvas(t)||await AO(t)};return h.jsxs("div",{className:"group flex w-full items-center gap-2 text-meta",children:[h.jsx(bqt,{path:t}),h.jsxs("button",{type:"button",className:"min-w-0 flex-1 truncate text-left text-ink hover:text-ink-dim","data-supplement-file":"",title:t,onClick:()=>{c()},children:[Zd(n),r&&r!==n&&h.jsx("span",{className:"ml-2 text-ink-muted",children:Zd(r)})]}),i&&h.jsx("span",{className:"shrink-0 text-ink-dim",children:i}),h.jsxs(EA,{children:[h.jsx(Ut,{content:"File actions",children:h.jsx(jA,{asChild:!0,children:h.jsx("button",{type:"button",className:"shrink-0 text-ink-dim opacity-0 group-hover:opacity-100 focus-visible:opacity-100","aria-label":`Actions for ${n||"this file"}`,children:h.jsx(uue,{"aria-hidden":"true",className:"size-3.5"})})})}),h.jsxs(qA,{align:"end",className:"min-w-45",children:[o&&h.jsxs(Tl,{onSelect:()=>{a?.openInCanvas(t)},children:[h.jsx(pue,{"aria-hidden":"true"}),h.jsx("span",{children:"Open in canvas"})]}),h.jsxs(Tl,{onSelect:()=>{AO(t)},children:[h.jsx(fv,{"aria-hidden":"true"}),h.jsx("span",{children:"Open in default app"})]}),h.jsxs(Tl,{onSelect:()=>{SU(t)},children:[h.jsx(_p,{"aria-hidden":"true"}),h.jsx("span",{children:"Reveal in Finder"})]}),h.jsxs(Tl,{onSelect:()=>{navigator.clipboard.writeText(t).then(()=>l(!0)).catch(()=>Mi("Failed to copy file path"))},children:[h.jsx(lue,{"aria-hidden":"true"}),h.jsx("span",{children:s?"Copied":"Copy file path"})]})]})]})]})});function wqt(e,t){try{return wU(e,t)}catch{return!1}}const oJ=$.memo(function({component:t,sessionId:n,onRetry:r,onHeight:i}){const a=$.useRef(null),[o,s]=$.useState(!1);$.useEffect(()=>{const u=a.current;if(u===null)return;if(typeof IntersectionObserver>"u"){s(!0);return}const O=new IntersectionObserver(d=>{for(const f of d)f.isIntersecting&&s(!0)},{rootMargin:"200px 0px"});return O.observe(u),()=>O.disconnect()},[]);const l=vqt(n,t.attachment,o),c=$.useCallback(u=>{i?.(t.attachment,u)},[i,t.attachment]);return h.jsx("div",{ref:a,"data-supplement-slot":"",children:h.jsx(mqt,{component:t,sessionId:n,documentHtml:l.html,documentFailed:l.failed,onRetry:r,onHeightChange:i?c:void 0})})}),Sqt=$.memo(function({record:t,sessionId:n,condensed:r=!1}){const i=_P(),[a,o]=$.useState(!1),[s,l]=$.useState(!1),[c,u]=$.useState(!1),[O,d]=$.useState(!1),[f,p]=$.useState(""),[m,g]=$.useState(!1),[y,v]=$.useState(()=>new Map),[w,x]=$.useState(0),b=Zje(t,t.live),S=t.files,Q=t.filesMore,P=t.components,T=S.length+Q,_=async z=>{if(n){g(!0);try{await _e({...z,sessionId:n,job:t.job,anchor:t.anchor})}catch(ie){Mi(mv("Highlights could not be updated.",ie))}finally{g(!1)}}},E=()=>{_({op:"supplements.cancel"})},C=()=>{_({op:"supplements.restart"})},A=()=>{const z=f.trim();z&&(d(!1),p(""),_({op:"supplements.steer",text:z}))},U=$.useCallback((z,ie)=>{v(F=>{if(F.get(z)===ie)return F;const H=new Map(F);return H.set(z,ie),H})},[]),N=$3e(typeof window>"u"?900:window.innerHeight),{visible:Z}=y3e(P,N,y);$.useEffect(()=>{x(z=>Math.max(z,Z.length))},[Z.length]);const G=Math.min(P.length,Math.max(w,Z.length)),D=P.slice(0,G),I=P.slice(G),W=z=>b==="preparing"||b==="files_preparing"||b==="cancelled_retry"||b==="files_cancelled_retry"||b==="failed_retry"||b==="files_failed_retry"?h.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta","data-supplement-line":"",children:[z!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-ink-muted",children:z}),h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"})]}),(b==="preparing"||b==="files_preparing")&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"relative inline-block size-3 overflow-hidden rounded-full bg-sunken",children:h.jsx("span",{className:"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"})}),h.jsx("span",{className:"text-ink-muted",children:Dje})]}),(b==="cancelled_retry"||b==="files_cancelled_retry")&&h.jsx("span",{className:"text-ink-muted",children:Vje}),(b==="failed_retry"||b==="files_failed_retry")&&h.jsx("span",{className:"text-ink-muted",children:Mje}),(b==="preparing"||b==="files_preparing")&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),!O&&h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-adjust":"",onClick:()=>d(!0),children:Lje}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60","data-supplement-cancel":"",disabled:m||t.state==="cancelling",onClick:E,children:Fje})]}),(b==="cancelled_retry"||b==="files_cancelled_retry"||b==="failed_retry"||b==="files_failed_retry")&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-retry":"",onClick:C,children:Bje})]})]}):null,J=O?h.jsxs("div",{className:"flex items-center gap-2 text-meta","data-supplement-adjust-form":"",children:[h.jsx("input",{autoFocus:!0,className:"min-w-0 flex-1 rounded-sm border border-control bg-canvas px-1.5 py-0.5 text-ink text-meta",maxLength:Aje,placeholder:"Adjust the graphic…",value:f,onChange:z=>p(z.target.value),onKeyDown:z=>{z.key==="Enter"&&A(),z.key==="Escape"&&(d(!1),p(""))}}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60",disabled:m||!f.trim(),onClick:A,children:"Send"})]}):null;if(b==="nothing")return null;if(r){if(b==="block"){const z=n3e(t);return z===null?null:h.jsx("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,children:h.jsx("div",{className:"text-ink-muted text-meta","data-supplement-condensed":"",children:z})})}return h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,children:[W(r3e(t)),J]})}let ee=null;return(S.length>0||Q>0)&&(T<=2&&P.length===0&&Q===0?ee=h.jsx("div",{className:"flex flex-col gap-1","data-supplement-files-summary":"",children:S.map(z=>{const{name:ie,path:F,size:H}=y3(z);return h.jsx(GR,{actionPath:z.path,label:ie||F,suffix:F,size:H,pane:i},z.path)})}):ee=h.jsxs("div",{className:"flex flex-col gap-1","data-supplement-files":"",children:[S.map(z=>{const{name:ie,path:F,size:H}=y3(z);return h.jsx(GR,{actionPath:z.path,label:ie||F,suffix:F,size:H,pane:i},`${z.path}:${z.name}`)}),Q>0&&h.jsx(_a,{chevronClassName:"text-ink-dim",open:a,onOpenChange:o,rowClassName:"min-h-0 py-0",summary:h.jsx("span",{"data-supplement-more":"",children:a?"Show fewer":Kje(Q)}),children:t.more.slice(0,20).map(z=>h.jsx(GR,{actionPath:z,label:z,suffix:"",size:"",pane:i},z))})]})),h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,children:[ee,W(null),t.detail?.includes("prepared:unsupported")&&h.jsx("p",{className:"text-meta text-ink-muted","data-supplement-refusal":"",children:"Inline preview unavailable. This HTML needs unsupported resources or document content. Open the file to view it."}),(b==="failed_retry"||b==="files_failed_retry")&&h.jsxs("div",{className:"flex flex-col gap-1 text-meta text-ink-muted","data-supplement-diagnostic":"",children:[h.jsx("p",{children:x3e(t)}),((t.attempts?.length??0)>0||(t.detail?.length??0)>0)&&h.jsx(_a,{open:s,onOpenChange:l,rowClassName:"min-h-6 py-0",chevronClassName:"text-ink-dim",summary:"Details",children:h.jsxs("div",{className:"max-h-[min(320px,40vh)] overflow-auto break-words font-mono text-ink-dim",children:[t.model&&h.jsxs("p",{children:["Model: ",t.model]}),h.jsxs("p",{children:["Attempts: ",t.attempts?.length??0]}),t.detail?.map(z=>h.jsx("p",{children:S3e(z)},z))]})})]}),J,b==="block"&&P.length>0&&h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-components":"",children:[D.map(z=>h.jsx(oJ,{component:z,sessionId:n,onRetry:n?C:void 0,onHeight:U},z.attachment)),I.length>0&&h.jsx(_a,{chevronClassName:"text-ink-dim",open:c,onOpenChange:u,rowClassName:"min-h-0 py-0",summary:h.jsx("span",{"data-supplement-show-all":"",children:c?"Show fewer":e3e(I.length)}),children:I.map(z=>h.jsx(oJ,{component:z,sessionId:n,onRetry:n?C:void 0,onHeight:U},z.attachment))})]})]})});function xqt(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const Qqt=e=>e?"⌘F":"Ctrl+F";function kqt(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function Pqt(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function _qt(e,t){return t>=0&&t<e.length?e[t]:null}function Tqt(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 Rqt={user:"You",agent:"Agent"},Xqt="related match",sJ="Search this conversation",Eqt="Search results",jqt="Close search";function qqt(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 Cqt="No messages match this search.",Aqt="Still indexing this conversation.",zqt="Results appear as the index catches up.",Uqt="Newer messages may be missing while the index catches up.",Wqt="This conversation lives on another device, so it cannot be searched here.",Nqt="This conversation could not be searched.",Gqt="Try again",Yqt="Check again",Iqt="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",Zqt="Updating — the list below is the previous search's.",Dqt="Going to that message…";function Vqt(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function Mqt(e){return e.state==="building"}async function Lqt(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await bQe(n,e,t)==="landed"?"revealed":"not-mounted"}async function Fqt(e){const t=e.query.trim().slice(0,UA);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??lle,1),cle);return _e({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const Bqt=200,Hqt=1500;function Kqt({sessionId:e,enabled:t}){const[n,r]=$.useState(""),[i,a]=$.useState("idle"),[o,s]=$.useState([]),[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,f]=$.useState(-1),p=$.useRef(0),m=$.useRef(0),g=$.useRef(0),y=$.useRef(""),v=$.useRef(null),w=$.useRef(null),x=$.useRef(new Set),b=$.useRef(e);b.current=e;const S=$.useCallback(()=>{w.current!==null&&(clearTimeout(w.current),w.current=null)},[]),Q=$.useCallback((U,N)=>{x.current.has(U)||(x.current.add(U),console.warn(U,N))},[]),P=$.useCallback(()=>{p.current+=1,S(),v.current=null,g.current=0,a("idle"),s(U=>U.length===0?U:[]),c(!1),O(!1),f(-1)},[S]),T=$.useRef(()=>{}),_=$.useCallback((U,N)=>{const Z=kqt(N.state);a(Z);const G=Z==="ready"||Z==="building",D=G?N.hits:[];if(g.current=D.length,s(D),c(G&&N.truncated),O(Z==="building"&&N.partial),f(D.length>0?0:-1),Z==="building"&&Mqt(N)){if(v.current!==U){v.current=U;const I=p.current;w.current=setTimeout(()=>{w.current=null,p.current===I&&T.current(U,"follow-up")},Hqt)}}else S()},[S]),E=$.useCallback((U,N)=>{const Z=b.current;if(!Z)return;const G=p.current,D=++m.current;N==="fresh"&&(S(),v.current=null,a("loading")),Fqt({sessionId:Z,query:U}).then(I=>{D!==m.current||p.current!==G||_(U,I)}).catch(I=>{D!==m.current||p.current!==G||(Q("thread search could not be answered:",I),S(),v.current=null,g.current=0,s([]),c(!1),O(!1),f(-1),a("error"))})},[_,S,Q]);T.current=E,$.useEffect(()=>{const U=`${t?"1":"0"}:${e??""}`;if(y.current!==U&&(y.current=U,x.current=new Set,P(),r(D=>D===""?D:""),!t||!e))return;if(!t||!e){P();return}const N=n.trim();if(N.length===0){P();return}const Z=p.current,G=setTimeout(()=>{p.current===Z&&T.current(N,"fresh")},Bqt);return()=>clearTimeout(G)},[n,t,e,P]),$.useEffect(()=>()=>S(),[S]);const C=$.useCallback(U=>{f(N=>Pqt(N,U,g.current))},[]),A=$.useCallback(()=>{const U=n.trim();!t||!e||U.length===0||T.current(U,"fresh")},[t,e,n]);return{query:n,setQuery:r,state:i,hits:o,truncated:l,partial:u,cursor:d,moveCursor:C,activeHit:_qt(o,d),refresh:A}}const Jqt=j("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),eCt="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",tCt=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,nCt=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=Tqt(e.snippet,e.ranges);return h.jsxs("li",{id:n,role:"option","aria-selected":t,onMouseDown:a=>a.preventDefault(),onClick:()=>r(e),className:j("relative flex cursor-pointer flex-col gap-0.5 px-3 py-2",t?Jqt:"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:Rqt[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:Xqt})]})]}),h.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?h.jsx("mark",{className:eCt,children:a.text},o):h.jsx("span",{children:a.text},o))})]})},rCt=({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=$.useId(),p=`${f}-list`,m=$.useCallback(b=>`${f}-opt-${b}`,[f]),g=$.useRef(null),y=i>=0&&i<r.length?r[i]:null,v=r.length>0,w=n==="error"||n==="building";$.useEffect(()=>{g.current?.focus(),g.current?.select()},[]),$.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(),y!==null?l(y):w&&c();return}};return h.jsxs("div",{"data-lo-thread-search":"",role:"presentation",onKeyDown:b=>{b.defaultPrevented||b.key==="Escape"&&(b.preventDefault(),u())},className:"pointer-events-auto w-[26rem] max-w-full rounded-md border border-hairline bg-elevated text-body-sm text-ink shadow-overlay",children:[h.jsx("div",{className:"p-2",children:h.jsxs("div",{className:j("flex items-center gap-2 rounded-sm border border-control bg-surface px-2","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[h.jsx(hv,{"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:UA,placeholder:sJ,"aria-label":sJ,role:"combobox","aria-expanded":v,"aria-controls":v?p:void 0,"aria-activedescendant":y!==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":jqt,onClick:u,children:h.jsx(Li,{"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?Zqt:"Searching…"),n==="ready"&&(r.length>0?qqt(r):Cqt),n==="building"&&(o?Uqt:Aqt),n==="unsupported"&&Wqt,n==="error"&&Nqt,n==="ready"&&a&&v&&h.jsxs("span",{className:"text-ink-dim",children:[" ",Vqt(r.length)]}),n==="building"&&!o&&h.jsxs("span",{className:"text-ink-dim",children:[" ",zqt]})]}),w&&h.jsx(Ae,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?Yqt:Gqt})]}),v&&h.jsx("ul",{id:p,role:"listbox","aria-label":Eqt,"aria-busy":n==="loading",className:j("max-h-80 overflow-y-auto border-t border-hairline py-1",n==="loading"&&"opacity-60"),children:r.map((b,S)=>h.jsx(nCt,{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:Dqt}),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(Ed,{shortcut:"↑"}),h.jsx(Ed,{shortcut:"↓"}),h.jsx("span",{children:"browse"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(Ed,{shortcut:"↵"}),h.jsx("span",{children:"jump"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(Ed,{shortcut:"esc"}),h.jsx("span",{children:"close"})]}),h.jsx("span",{className:"ml-auto text-ink-dim text-meta",children:Qqt(O)})]})]})},iCt=({sessionId:e,containerRef:t,onReveal:n})=>{const[r,i]=$.useState(!1),[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(null),c=Kqt({sessionId:e,enabled:r}),u=$.useCallback(()=>{const f=document.activeElement;l.current=f instanceof HTMLElement?f:null,i(!0)},[]),O=$.useCallback(()=>{i(!1);const f=l.current;l.current=null,f?.isConnected&&f.focus()},[]);$.useEffect(()=>{const f=p=>{if(p.defaultPrevented||!xqt(p))return;const m=p.target;if(!(!(s.current!==null&&m!==null&&s.current.contains(m))&&(q$(p.target)||Wue(p.target)===null))){if(p.preventDefault(),r){const y=s.current?.querySelector("input");y?.focus(),y?.select();return}u()}};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[r,u]);const d=$.useCallback(async f=>{o(!0);try{if(n){await n(f.id);return}await Lqt(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(rCt,{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:tCt(),jumping:a})}):null},aCt='button, a, input, textarea, [role="button"], [contenteditable]',oCt='[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]',sCt=4,lCt=200,lJ=e=>{const t=e;return typeof t?.closest!="function"?!0:t.closest(aCt)!==null},cCt=e=>e.querySelector(oCt)!==null,uCt=(e,t)=>t-e<lCt,OCt=e=>e.controlPress?"control":e.modalOpen?"modal":e.pressHadSelection||e.selectionNotCollapsed||e.shiftExtends?"selection":e.dragged?"drag":e.scrolledRecently?"scroll":"focus";function QQe(e){return e.status==="reconnecting"||e.status==="unavailable"&&!!e.failure||!!e.missing}function kQe(e){return QQe(e)||!!e.stale}function dCt(e){return e.status==="reconnecting"?!1:kQe(e)}function PQe(e){return e.admittedSend||QQe(e)?!1:e.filterHeld===!0&&e.recordCount>0?!0:e.awaitingHydration&&(e.recordCount===0||e.stale===!0)}function fCt(e){return e.recordCount===0&&!e.admittedSend&&!PQe(e)&&!kQe(e)}const hCt=({isSmallView:e=!1})=>h.jsxs("output",{"aria-label":"Loading conversation",className:j("flex items-center gap-2",e&&"gap-1.5"),children:[h.jsx("span",{"aria-hidden":"true",className:"size-2 shrink-0 rounded-full bg-elevated animate-pulse-visible"}),h.jsx("span",{className:"text-ink-dim text-meta",children:"Loading conversation…"})]}),_Qe="display.turn_answer_rail";function pCt(e,t){return e&&t?"-ml-[13px] border-hairline border-l pl-3":"w-full"}function TQe(e){return Vz(e)!==null}function mCt(e,t){return e.segments.some(n=>n.collapsed&&!t?.has(n.key))}function RQe(e){return!(e.kind!=="tool"||e.isError!==!0||VA(e.delivery)||e.neverSent===!0||e.notRunReason!==null&&e.notRunReason!==void 0||e.stopped===!0||kp(e.notRunKind))}function gCt(e){switch(e){case"peer":case"hub_message":return"peer";case"wake":return"wake";case"monitor_prompt":return"monitor";case"job_result":return"job";default:return null}}function YR(e){return e.kind==="user"||TQe(e)?!0:e.kind==="assistant"&&Fc(e)}function $Ct(e){const t=z$(e);return t!==null&&t!=="user"}function yCt(e){return ZA({...XEe,...e.sender??{}})}function vCt(e,t,n={}){const r=n.spanHeadLoaded??!0;for(let m=t.from;m<=t.to;m+=1)if(YR(e[m]))return null;if(t.from>0&&!YR(e[t.from-1])||t.to+1<e.length&&!YR(e[t.to+1]))return null;const i=[];for(let m=t.from;m<=t.to;m+=1)$Ct(e[m])&&i.push(e[m]);if(i.length<2)return null;const a=i[0],o=i[i.length-1];let s=0,l=0;const c=new Map;for(let m=t.from;m<=t.to;m+=1){const g=e[m];if(g.kind==="tool"&&!ff(g)){s+=1,RQe(g)&&(l+=1);continue}if(g.kind==="peer"){const y=yCt(g);c.set(y,(c.get(y)??0)+1)}}let u=null,O=!1;for(const m of i){const g=gCt(z$(m));g!==null&&(u===null?u=g:u!==g&&(O=!0))}const d=O?"mixed":u??"mixed",f=[];if(d==="peer"){const m=[...c.entries()].map(([v,w])=>({label:v,count:w})),g=new Map(m.map((v,w)=>[v.label,w]));m.sort((v,w)=>w.count-v.count||(g.get(v.label)??0)-(g.get(w.label)??0));const y=m.slice(0,2);if(m.length>2){let v=0;for(const w of m.slice(2))v+=w.count;y.push({label:`${m.length-2} more`,count:v})}f.push(...y)}const p=[];for(let m=t.from;m<=t.to;m+=1)p.push(e[m].id);return{key:`qg:${e[t.from].id}`,family:d,count:i.length,firstTs:r?a.ts:null,lastTs:r?o.ts:null,senders:f,actions:s,failed:l,open:n.open??t.to===e.length-1,rowIds:p}}function XQe(e,t){const n=Mz(e),r=t.focusHold??null,i=t.openRuns??bCt;return{runs:n.map((a,o)=>WCt(e,a,o===n.length-1&&t.live,r,i,t.mode,t.runFacts,t.hideCrossSession===!0,t.factPage))}}const bCt=new Set,wCt=new Set(["output","args","intent","diff","frame","truncated"]),cJ=new WeakMap;let IR=0;const SCt=e=>{const t=cJ.get(e);return t!==void 0?`@${t}`:(IR+=1,cJ.set(e,IR),`@${IR}`)},uJ=new WeakMap;function xCt(e){const t=uJ.get(e);if(t!==void 0)return t;const n=e,r={};for(const a of Object.keys(n)){if(wCt.has(a))continue;const o=n[a];if(a==="text"){r[a]=o?1:0;continue}if(a==="images"){r[a]=Array.isArray(o)?SCt(o):o??null;continue}r[a]=o}const i=JSON.stringify(r)??"null";return uJ.set(e,i),i}function QCt(e){const t=[];for(const n of e)t.push(`${n.gap}${n.closesTurn?"+":"-"}`),t.push(xCt(n.record));return t.join("\0")}function kCt(e){const t=[e.live?"live":"settled",e.mode??"",e.focusHold??"",e.hideCrossSession?"hide":"show"];if(e.openRuns)for(const n of[...e.openRuns].sort())t.push(`open:${n}`);if(e.runFacts&&e.runFacts.size>0){const n=[];for(const r of[...e.runFacts.keys()].sort()){const i=e.runFacts.get(r);i&&n.push(`${r}:${i.actions}:${i.workedSeconds??""}:${i.complete?"c":"p"}:${i.failed}:${i.openingUserId??""}:${i.closingAnswerId??""}:${i.crossSessionActions??""}:${i.crossSessionWorkedSeconds??""}`)}t.push(`facts:${n.join(",")}`)}return e.factPage&&t.push(`page:${e.factPage.newestKey??""}:${e.factPage.ids.size}`),t.join("\0")}function PCt(e,t){return`${e}${kCt(t)}`}const ZR=720;function FU(e,t,n,r=0,i=!1,a=EQe(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 EQe(e,t){const n=e.length;if(n<=t)return null;const r=n-t;return Mz(e).find(i=>i.openingIndex<=r&&r<=i.endIndex)??null}function _Ct(e,t){return e.runs.find(r=>!r.run.opensWithUserRow&&r.segments.some(i=>i.collapsed&&!t?.has(i.key)))?.key??null}function TCt(e,t,n){const r=_Ct(e,n);return r===null||e.runs.find(a=>a.key===r)?.factApplied?null:t===null||!t.opensWithUserRow&&t.key===r?r:null}function jQe(e,t,n){const r=e.length,i=FU(e,t,n.snapMaxExtra,n.completedRunMaxExtra,n.live??!1),a=r>i?e.slice(r-i):e,o=XQe(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 RCt=12;function XCt(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=FU(e,O,n.snapMaxExtra,n.completedRunMaxExtra,n.live??!1),f=u.get(d);if(f!==void 0)return f;const p=jQe(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 qQe=12;function ECt(e,t){return e>=qQe||t.halted||t.loadingOlder||!t.hasMore||!t.headCut||!t.mayWalk?{fetch:!1,spent:e}:{fetch:!0,spent:e+1}}const OJ=()=>({key:null,spent:0,halted:!1});function jCt(e,t){return t===null||t===e.key?e:{key:t,spent:0,halted:!1}}function qCt(e,t){return t&&e.gap==="trace"?"item":e.gap}function dJ(e,t){const n=e.filter(s=>!(s.record.kind==="tool"&&ff(s.record))),r=[];let i=0,a=null;for(const s of n){if(s.record.kind!=="tool")continue;const l=RQe(s.record);r.push({name:lde(s.record),failed:l}),l&&(i+=1,a??=s.record.id)}const o=A7(n);return{durationS:t.headLoaded&&o!==null&&o>=1?o:null,actions:r.length,partial:t.partial,failed:i,firstFailedId:a,title:r.length>0?uEt(r):null,group:t.group??null}}function CCt(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(Qk(i)||Fc(i)&&rde(i))return r}return n}function ACt(e,t,n){if(!n||n.size===0)return null;const r=n.get(t.key);if(r!==void 0)return r;for(let i=t.openingIndex;i<=t.endIndex;i+=1){const a=n.get(e[i]?.record.id??"");if(a!==void 0)return a}return null}function zCt(e,t,n){if(n===void 0)return[];if(n===null)return null;let r=-1;for(let a=0;a<e.length;a+=1)n.ids.has(e[a].record.id)&&(r=a);if(r<0)return null;const i=[];for(let a=Math.max(r+1,t.openingIndex);a<=t.endIndex&&a<e.length;a+=1){const o=e[a];if(o.record.kind==="tool"&&!n.ids.has(o.record.id)){if(!o.record.id.startsWith("tool:")||o.record.neverSent===!0||(o.record.notRunReason??null)!==null)return null;i.push(o)}}return i}function UCt(e,t){if(e===null)return null;let n=e.actions,r=e.workedSeconds;if(t){const i=e.crossSessionActions;if(i===null)return null;if(n=Math.max(0,n-i),r!==null){const a=e.crossSessionWorkedSeconds;a!==null?r=Math.max(0,r-a):i>0&&(r=null)}}return{actions:n,workedSeconds:r,failed:e.failed,complete:e.complete}}function WCt(e,t,n,r,i,a,o,s=!1,l=void 0){const c=e.slice(t.openingIndex,t.endIndex+1),u=c.map(G=>G.record),O=t.opensWithUserRow?1:0,d=ACt(e,t,o),f=d===null?null:zCt(e,t,l);let p=f===null?null:UCt(d,s);if(p!==null&&f!==null&&f.length>0){const G=f.every(I=>typeof Wx(I)=="number"),D=G?A7(f):null;if(!G||p.workedSeconds!==null&&D===null)p=null;else{const I=p.workedSeconds;p={...p,actions:p.actions+f.length,workedSeconds:I===null||D===null?null:I+D}}}const m=p===null?t.opensWithUserRow:t.opensWithUserRow&&d?.openingUserId!=null&&e[t.openingIndex]?.record.id===d.openingUserId,g=HIe(u,{from:O,paints:Fc,isStatement:oq,pinned:TQe,mode:a}),y=g.answer?.closeIndex??null,v=y===null?null:u[y].id,w=(()=>{if(t.quietCloseId===null)return null;const G=u.findIndex(D=>D.id===t.quietCloseId);return G===-1?null:G})();let x=-1;g.segments.forEach((G,D)=>{(y===null||G.to<y)&&(x=D)});const b=g.segments.filter(G=>y===null||G.to<y).length,S=g.segments.length>0&&(t.opensWithUserRow||t.closingAnswerId!==null||t.quietCloseId!==null),Q=n?CCt(u,g.cycles):-1,P=n?Q+1:-1;let T=-1;const _=g.segments.map((G,D)=>{const I=c.slice(G.from,G.to+1),W=y!==null&&G.from>y,J=!(G.from===O&&!m);J||(T=D);const ee=vCt(u,G,{spanHeadLoaded:J,open:G.to===u.length-1&&t.endIndex===e.length-1}),ie=G.to===c.length-1&&t.endIndex===e.length-1?`qg:${I[0].record.id}`:`seg:${W?I[0].record.id:(c[G.to+1]??I[I.length-1]).record.id}`,F=JIe(u,g.cycles,G,ee),H=ee!==null&&Q>=G.from,oe=S&&(P<0||G.to<P||H)&&!(r!==null&&!i.has(ie)&&I.some(L=>L.record.id===r));return{key:ie,rows:I,firstId:I[0].record.id,segmentIds:I.map(L=>L.record.id),gap:qCt(I[0],G.from>O),afterAnswer:W,label:F,completed:eZe(u,g.cycles,G,y,F!==null,w),collapsed:oe,stampTs:D===x&&y!==null&&b===1?u[y].ts:null,facts:dJ(I,{partial:!J,headLoaded:J,group:ee})}}),E=T>=0?_[T]:null;let C=!1;if(p!==null&&E!==null){let G=0,D=0;for(const[z,ie]of _.entries())z!==T&&(G+=ie.facts.actions,D+=A7(ie.rows)??0);const I=Math.max(0,p.actions-G),W=p.workedSeconds===null?null:Math.max(0,p.workedSeconds-D),J=E.rows.filter(z=>z.record.kind==="tool").length;C=J>I;const ee=C?Math.max(I,J):I;_[T]={...E,facts:{...E.facts,actions:ee,durationS:W!==null&&W>=1?W:null,partial:!p.complete||C||n&&f!==null&&f.length>0}}}const A=y===null?c:c.slice(0,y+1),U=dJ(A,{partial:!m,headLoaded:m}),N=(()=>{if(p===null||T<0)return null;let G=0,D=0;for(const I of _)I.afterAnswer||(G+=I.facts.actions,D+=I.facts.durationS??0);return{actions:G,worked:D,partial:!p.complete||C||n&&f!==null&&f.length>0,failed:p.failed}})(),Z=_.flatMap(G=>G.rows);return{key:t.key,run:t,factApplied:p!==null&&T>=0,collapses:_.some(G=>G.collapsed),recordIds:c.map(G=>G.record.id),hidden:Z,gap:_[0]?.gap??"item",facts:N===null?U:{...U,actions:N.actions,durationS:N.worked>=1?N.worked:null,partial:N.partial,failed:N.failed},answerId:v,stampTs:y===null?null:u[y].ts,segments:_}}const NCt=160,fJ=2,GCt=(e,t,n)=>{const[r,i]=$.useState(null),a=$.useMemo(()=>`${t.length}\0${t[0]?.record.id??""}\0${t[t.length-1]?.record.id??""}`,[t]),o=$.useMemo(()=>new Set(t.map(u=>u.record.id)),[a]),s=$.useMemo(()=>n.filter(u=>o.has(u.id)),[n,o]),l=$.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+$Qe+1&&b>f&&(f=b,d=w.id)}const g=u.scrollHeight-u.clientHeight,y=Math.abs(u.scrollTop)<=fJ,v=Math.abs(u.scrollTop+g)<=fJ;y?d=m:v&&(d=p),i(w=>w===d?w:d)},[e,s]),c=$.useRef(l);return c.current=l,$.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()},NCt)};return u.addEventListener("scroll",f,{passive:!0}),()=>{u.removeEventListener("scroll",f),O!==0&&window.cancelAnimationFrame(O),window.clearTimeout(d)}},[e]),$.useEffect(()=>{l()},[l]),{activeId:r,loadedIds:o}},YCt=8,Wh=new Map,nS=new Map,CQe=new Set;function Vw(e){return Wh.get(e)??null}function COn(e){const t=!nS.has(e),n=AQe(e);return t?n.then(r=>(CQe.add(e),r)):n}const rS=new Map;function ICt(e,t){let n=rS.get(e);return n===void 0&&(n=new Set,rS.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&rS.delete(e)}}function ZCt(e){return CQe.delete(e)}function AQe(e){const t=nS.get(e);if(t)return t;const n=_e({op:"sessions.checkpoints",sessionId:e}).then(r=>{Wh.delete(e),Wh.set(e,r);for(const i of rS.get(e)??[])i(r);for(;Wh.size>YCt;){const i=Wh.keys().next();if(i.done)break;Wh.delete(i.value)}return r}).finally(()=>{nS.delete(e)});return nS.set(e,n),n}const DCt=1500,VCt=45e3,MCt=[];function LCt(e){const t=e?Vw(e):null,[n,r]=$.useState(()=>t?"ready":"idle"),[i,a]=$.useState(()=>t),[o,s]=$.useState(e);if(o!==e){s(e);const P=e?Vw(e):null;a(P),r(P?"ready":"idle")}const l=$.useRef(e),c=$.useRef(0),u=$.useRef(null),O=$.useRef(new Set),d=$.useRef(null),f=$.useRef(null),p=$.useRef(new Set),m=$.useCallback(()=>{d.current!==null&&(clearTimeout(d.current),d.current=null),f.current=null},[]),g=$.useCallback((P,T)=>{p.current.has(P)||(p.current.add(P),console.warn(P,T))},[]),y=$.useRef(async()=>{}),v=$.useRef(()=>{}),w=$.useCallback(async(P,T)=>{if(P===c.current&&u.current!==P){u.current=P;try{if(T==="served"){const E=Vw(l.current);if(E!==null){if(P!==c.current)return;a(E),r("ready"),O.current.size>0&&(O.current=new Set(jR(E,O.current))),O.current.size>0&&v.current(P);return}}const _=await AQe(l.current);if(P!==c.current)return;a(_),r("ready"),O.current.size>0&&(O.current=new Set(jR(_,O.current))),O.current.size>0&&v.current(P)}catch(_){if(P!==c.current)return;g("checkpoints are unavailable for this conversation; the rail stays hidden:",_),m(),T==="initial"&&(a(null),r("error"))}finally{u.current===P&&(u.current=null)}}},[g,m]);y.current=w;const x=$.useCallback(P=>{if(P!==c.current||d.current!==null)return;const T=f.current??Date.now()+VCt;f.current=T,d.current=setTimeout(()=>{if(d.current=null,P===c.current){if(O.current.size===0){f.current=null;return}if(Date.now()>=T){O.current=new Set,f.current=null;return}y.current(P,"refresh").then(()=>{P===c.current&&O.current.size>0&&v.current(P)})}},DCt)},[]);v.current=x;const b=$.useCallback(()=>{l.current&&w(c.current,"refresh")},[w]),S=$.useCallback(P=>{const T=l.current;if(!T)return;const _=c.current,E=P&&P.length>0?{op:"sessions.checkpoints.warm",sessionId:T,ids:P.slice(0,l3)}:{op:"sessions.checkpoints.warm",sessionId:T};(async()=>{try{const C=await _e(E);if(_!==c.current)return;for(const A of C.pending)O.current.add(A);O.current.size>0&&v.current(_)}catch(C){if(_!==c.current)return;g("checkpoint naming is unavailable; the cards keep their fallback text:",C)}})()},[g]);$.useEffect(()=>{if(e)return ICt(e,P=>{a(P),r("ready"),O.current.size>0&&(O.current=new Set(jR(P,O.current)))})},[e]),$.useEffect(()=>{l.current=e,c.current+=1;const P=c.current;u.current=null,O.current=new Set,m(),p.current=new Set;const T=e?Vw(e):null,_=e?ZCt(e):!1,E=T!==null&&_;if(a(T),!e){r("idle");return}return r(T?"ready":"loading"),w(P,T?E?"served":"refresh":"initial"),()=>{c.current+=1,m()}},[e,w,m]);const Q=i!==null&&(i.index.state==="building"||i.index.state==="stale");return{state:n,building:Q,checkpoints:i?.checkpoints??MCt,warm:S,refresh:b}}const zQe="display-settings",UQe="display.hide_cross_session",WQe=[UQe,_Qe],FCt=150;function BCt(){try{const e=localStorage.getItem(zQe);if(e===null)return{};const t=JSON.parse(e);if(t===null||typeof t!="object")return{};const n={};for(const r of WQe)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}catch{return{}}}function HCt(e){if(e)try{const t={};for(const n of WQe){const r=e.find(i=>i.key===n);r&&(t[n]=r.value??null)}localStorage.setItem(zQe,JSON.stringify(t))}catch{}}function KCt(e,t){const n=e?.find(r=>r.key===t);if(n)return n.value===!0}function JCt(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]===!0}function e7t(e){return e.answer!==void 0?e.answer?"on":"off":e.plane==="denied"||e.plane==="failed"?"off":e.owed&&!e.holdSpent&&e.seed===!0?"pending":e.seed===!0?"on":"off"}function NQe(){const[e,t]=$.useState(void 0);return $.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 t7t="general",n7t={[fO]:t7t};function r7t(e,t){return n7t[e]??t}const GQe="session.cleanup.delegated.max_age_hours",i7t="session.cleanup.delegated.enabled",a7t="session_delegated",o7t=2,s7t=720,pu=24,N7=30*pu,BU=72,HU=/^\d+$/,l7t=[2,6,12,24,48,72,168,336,720];function WP(e){if(e.key!==GQe||e.kind!=="int"||e.unit&&e.unit!=="hours")return null;const t=e.minimum??o7t,n=e.maximum??s7t;return{min:t,max:n,stops:l7t.filter(r=>r>=t&&r<=n),defaultHours:typeof e.default=="number"&&Number.isInteger(e.default)?e.default:null}}const DR=(e,t,n)=>`${e} ${e===1?t:n}`;function Yc(e){return e>0&&e%N7===0?DR(e/N7,"month","months"):e>=BU&&e%pu===0?DR(e/pu,"day","days"):DR(e,"hour","hours")}function c7t(e){return e>=BU&&e%pu===0?`${e/pu}d`:`${e}h`}function u7t(e){return e>=BU&&e%pu===0?{text:String(e/pu),unit:"days"}:{text:String(e),unit:"hours"}}function hJ(e){const t=e.text.trim();return HU.test(t)?String(Number(t)*(e.unit==="days"?pu:1)):t}function O7t(e){const t=e.max%N7===0?`${Yc(e.max)} (${e.max/pu} days)`:Yc(e.max);return`between ${Yc(e.min)} and ${t}`}function d7t(e,t){return Math.min(t.max,Math.max(t.min,e))}function YQe(e,t){const n=e.trim();if(!HU.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:`${Yc(r)} is too ${i?"long":"short"}. Choose a time ${O7t(t)}.`,nearest:d7t(r,t)}}return{ok:!0,hours:r}}const IQe={language:{label:"Interface language",help:"Interface language, one setting shared with the terminal. auto follows your operating system, falling back to English."},[i7t]:{label:"Remove delegated sessions automatically",help:"Applies to subagent runs, agent shells and background runs only.",gateLabel:"automatic removal"},[GQe]:{label:"Remove after",help:"The retention window: how long a delegated session (a subagent or background run) can sit idle before it is removed."}},f7t={session_delegated:"Delegated work: subagents and background sessions"};function h7t(e){return f7t[e.name]??e.title}function iS(e){const t=IQe[e.key],n=r7t(e.key,e.section);return t?{...e,label:t.label,help:t.help,section:n}:n===e.section?e:{...e,section:n}}function p7t(e,t){return IQe[e]?.gateLabel??t}const m7t={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",language:"core","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"},g7t={model:"core",approvals:"core",web_tools:"core",desktop:"advanced"};function Qd(e){return e.tier==="core"||e.tier==="advanced"?e.tier:m7t[e.key]??g7t[e.section]??"advanced"}function $7t(e){return e.length===0?!1:e.filter(n=>Qd(n)==="core").length*2>=e.length}function y7t(e,t,n){return t?{layout:null,filter:e?[]:[...n]}:{layout:{opened:e?[...n]:[],closed:e?[]:[...n]},filter:[]}}const ZQe="__cascade__";function Kp(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function yc(e){return{value:e.kind==="list"?(e.value??[]).join(`