@maincode-ai/matilda-code 0.21.10-nightly.20261006.71a1cdd54 → 0.21.10-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/chunks/agent-U43GELHB.js +3 -0
  2. package/chunks/agent-headless-7STBERN4.js +3 -0
  3. package/chunks/{askUserQuestion-MJ4FTAOQ.js → askUserQuestion-G2H4VCRY.js} +1 -1
  4. package/chunks/{chunk-KDDFCFN2.js → chunk-2NBII5ND.js} +1 -1
  5. package/chunks/{chunk-32T6RWWT.js → chunk-2PPJ3MJT.js} +1 -1
  6. package/chunks/{chunk-LSDMWVW6.js → chunk-6Q6PMGBD.js} +1 -1
  7. package/chunks/{chunk-6SBKU5ST.js → chunk-6ZMDAPGZ.js} +446 -446
  8. package/chunks/chunk-BN2CPSZ5.js +34 -0
  9. package/chunks/{chunk-6TLGXGK7.js → chunk-GWGQRU36.js} +1 -1
  10. package/chunks/{chunk-ADKBIRO5.js → chunk-H6WMNUW2.js} +1 -1
  11. package/chunks/chunk-HMZOLFRP.js +10 -0
  12. package/chunks/chunk-HYVP4472.js +8 -0
  13. package/chunks/{chunk-3ZAMYREW.js → chunk-IJUI5A6G.js} +1 -1
  14. package/chunks/{chunk-B3NVKOSU.js → chunk-KSNBNXBC.js} +1 -1
  15. package/chunks/{chunk-6B5BDE7S.js → chunk-PIFQEMZZ.js} +8 -8
  16. package/chunks/chunk-SE3XDSIJ.js +35 -0
  17. package/chunks/{chunk-F7CBVSLO.js → chunk-TFWOXSAP.js} +2 -2
  18. package/chunks/{chunk-KWCGGQCW.js → chunk-X6BEBYGX.js} +1 -1
  19. package/chunks/{chunk-Q7YBRGHD.js → chunk-XJYPRCV7.js} +2 -2
  20. package/chunks/{computer-use-B4GKBLRO.js → computer-use-QN46FSNK.js} +1 -1
  21. package/chunks/contextCommand-7G5FHBBE.js +3 -0
  22. package/chunks/{cron-create-BTTPO3JC.js → cron-create-MILWOYF6.js} +1 -1
  23. package/chunks/{cron-delete-U55RHRID.js → cron-delete-IEOPMRWP.js} +1 -1
  24. package/chunks/{cron-list-J4HRR46K.js → cron-list-GGBUA7S7.js} +1 -1
  25. package/chunks/{dist-SVKXQXJX.js → dist-ZOFMYY3D.js} +1 -1
  26. package/chunks/{edit-57SY7ZTG.js → edit-7AZARQPL.js} +1 -1
  27. package/chunks/{enter-worktree-YNUSOHXS.js → enter-worktree-GKYG5CD2.js} +1 -1
  28. package/chunks/{enterPlanMode-BWJKHEL2.js → enterPlanMode-ICTG6ULZ.js} +1 -1
  29. package/chunks/{exit-worktree-LFO6IY4T.js → exit-worktree-ZWYXIEIC.js} +1 -1
  30. package/chunks/{exitPlanMode-YEWZMKY2.js → exitPlanMode-5BQ4MY5I.js} +1 -1
  31. package/chunks/{geminiContentGenerator-ROVF5ZDW.js → geminiContentGenerator-APSI54U5.js} +1 -1
  32. package/chunks/glob-NPEYXTA6.js +22 -0
  33. package/chunks/{grep-SZFVCCG5.js → grep-4NQTKAN6.js} +1 -1
  34. package/chunks/{ls-CLDNF3YS.js → ls-FQYKJYAK.js} +1 -1
  35. package/chunks/{lsp-7SKRKR5Q.js → lsp-FGMC4KSB.js} +1 -1
  36. package/chunks/{matildaAgentContentGenerator-4TE52UGH.js → matildaAgentContentGenerator-HVIGLQJZ.js} +1 -1
  37. package/chunks/matildaContentGenerator-5VOBYNAJ.js +8 -0
  38. package/chunks/monitor-RMKMKOUY.js +32 -0
  39. package/chunks/notebook-edit-H3ZFKBLR.js +17 -0
  40. package/chunks/{openaiContentGenerator-4UHFUHKP.js → openaiContentGenerator-X6TFPZGL.js} +1 -1
  41. package/chunks/{read-file-J5UBJYDO.js → read-file-3J3ZMBI2.js} +1 -1
  42. package/chunks/ripGrep-WDYTLRCE.js +3 -0
  43. package/chunks/scheduler-TKK5QECI.js +8 -0
  44. package/chunks/{send-message-XXRROIL7.js → send-message-5PJPE34J.js} +1 -1
  45. package/chunks/{serve-E2ZZRXU4.js → serve-24HVCLFM.js} +1 -1
  46. package/chunks/shell-YPEMRDRO.js +3 -0
  47. package/chunks/{skill-B5OOZ7T6.js → skill-HWDNN7P7.js} +1 -1
  48. package/chunks/src-W5VAKS5Y.js +3 -0
  49. package/chunks/{symbol-search-3MVTK4KV.js → symbol-search-BSE3FWJX.js} +1 -1
  50. package/chunks/{syntheticOutput-QEUQIVQJ.js → syntheticOutput-DX4NN34N.js} +1 -1
  51. package/chunks/{task-create-AEJQ73GE.js → task-create-3PW7T36X.js} +1 -1
  52. package/chunks/task-detach-TGM25ZIU.js +9 -0
  53. package/chunks/{task-list-ZEJTNZ2O.js → task-list-AZLBAQVL.js} +1 -1
  54. package/chunks/{task-stop-JO3CXG2K.js → task-stop-B5PTXVMO.js} +1 -1
  55. package/chunks/{task-update-3YY37VFN.js → task-update-ARPBRTC5.js} +1 -1
  56. package/chunks/{team-create-AQ4KCPWU.js → team-create-D4N2QVBX.js} +1 -1
  57. package/chunks/{team-delete-4YYLUV23.js → team-delete-AGYMEW6E.js} +1 -1
  58. package/chunks/{todoWrite-7BZMVNBC.js → todoWrite-3XJNFIBR.js} +1 -1
  59. package/chunks/{tool-search-OWJC3UTX.js → tool-search-LRVN3W5W.js} +1 -1
  60. package/chunks/{update-goal-CF6G57J7.js → update-goal-KLUMJFUA.js} +1 -1
  61. package/chunks/{web-fetch-K575OWZ7.js → web-fetch-Y64RF72K.js} +1 -1
  62. package/chunks/{web-search-F6JRBXFV.js → web-search-I3D4EN5B.js} +1 -1
  63. package/chunks/{workflow-LNRFWGOR.js → workflow-BSK53DUN.js} +2 -2
  64. package/chunks/write-file-GDKSQBMU.js +15 -0
  65. package/cli.js +473 -470
  66. package/package.json +2 -2
  67. package/sandbox-macos-restrictive-closed.sb +4 -0
  68. package/sandbox-macos-restrictive-open.sb +4 -0
  69. package/sandbox-macos-restrictive-proxied.sb +4 -0
  70. package/chunks/agent-HBEJN6Y2.js +0 -3
  71. package/chunks/agent-headless-J7IKRSAB.js +0 -3
  72. package/chunks/chunk-34DXSYJZ.js +0 -34
  73. package/chunks/chunk-FRL6KOLY.js +0 -35
  74. package/chunks/contextCommand-JZEOLK23.js +0 -3
  75. package/chunks/glob-2S65PMOT.js +0 -22
  76. package/chunks/matildaContentGenerator-7BKTRYT7.js +0 -8
  77. package/chunks/monitor-XT2J65M2.js +0 -32
  78. package/chunks/notebook-edit-PIQTMARV.js +0 -17
  79. package/chunks/ripGrep-IHRVX425.js +0 -3
  80. package/chunks/scheduler-VGTCNDKV.js +0 -8
  81. package/chunks/shell-EIGO7KF7.js +0 -3
  82. package/chunks/src-T6CCEC2P.js +0 -3
  83. package/chunks/write-file-DME6VBEN.js +0 -15
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as j,d as Zt}from"./chunk-4F4DA5UI.js";import{a as tn,b as At,c as nn,d as on}from"./chunk-DC7LAFZZ.js";import{b as Wt,d as qt,g as yt,j as Yt,k as Jt,s as en,v as ue}from"./chunk-S7G6QPEP.js";import{b as A,e as B}from"./chunk-4J6DC24J.js";import{a as Xt,d as Qt}from"./chunk-SDTWBD62.js";import{Bb as de,Jc as ht,Kc as Ct,Mb as ft,Mc as Tt,Pa as Co,Pb as gt,Ra as To,Rb as mt,Sa as X,Wa as xe,Xa as ke,Ya as Ie,a as _,ab as pt,eb as Oe,f as U,fb as V,na as ut,tb as we,ub as Pe}from"./chunk-B3NVKOSU.js";import{b as rn}from"./chunk-3YLXGE6T.js";import{P as ve,T as zt,V as dt,aa as O,d as Vt,e as ae,f as le,k as at}from"./chunk-VLYRNOD3.js";import{b as lt,c as v,f as ct,g as ce,h as M,i as be,k as jt,l as x,n as J}from"./chunk-FWDMPRKU.js";import{b as g}from"./chunk-GZPNIYVZ.js";import{f as ho}from"./chunk-OWGSC52X.js";g();function Q(t){return!Number.isFinite(t)||t<=0?0:Math.ceil(t/4)}function De(t){let e=t.candidates||0,n=t.thoughts||0;return n>e?e+n:Math.max(e,n)}function yo(t){return t.total&&t.total>0?Math.max(t.total,(t.prompt||0)+De(t)):(t.prompt||0)+De(t)}function Ao(t){let e=Math.max(0,t.thoughtsTokens||0),n=De({candidates:t.outputTokens||0,thoughts:e}),o=Math.max(t.totalTokens||0,(t.inputTokens||0)+n);return{...t,outputTokens:n,thoughtsTokens:e,totalTokens:o}}g();g();var So=/[A-Za-z\u00C0-\u024F]/g;function Eo(t){return t>=1024&&t<=1279||t>=1280&&t<=1327||t>=11744&&t<=11775||t>=42560&&t<=42655||t>=12352&&t<=12543||t>=13312&&t<=19903||t>=19968&&t<=40959||t>=63744&&t<=64255||t>=44032&&t<=55215}function St(t){let e=t.codePointAt(0);return e!==void 0&&Eo(e)}function _o(t){let e=t.match(So)?.length??0;if(e<24)return!1;let n=0;for(let o of t)St(o)&&n++;return n===0||e>=n*8}function Le(t){if(!t||!_o(t))return t;let e="",n=0,o=[...t];for(;n<o.length;){if(!St(o[n])){e+=o[n],n++;continue}let r=n;for(;r>0&&o[r-1]===" ";)r--;let i=n+1;for(;i<o.length&&St(o[i]);)i++;for(;i<o.length&&o[i]===" ";)i++;let s=r>0?o[r-1]:"",a=i<o.length?o[i]:"";(/[A-Za-z0-9]/.test(s)&&/[A-Za-z0-9]/.test(a)||o[r]===" "||o[i-1]===" ")&&(e+=" "),n=i,r<n&&o[r]===" "&&e.endsWith(" ")&&(e=e.slice(0,-1))}return e.replace(/ {2,}/g," ")}g();var Z=O("TAGGED_THINKING_PARSER"),fe=["<think>","<thinking>"],ge=["</think>","</thinking>"],Mo=Math.max(...fe.map(t=>t.length),...ge.map(t=>t.length));function pe(t,e,n){e&&t.push(n==="thought"?{text:e,thought:!0}:{text:e})}function Ue(t,e,n){let o=t.length-e;return o<=0||o>Mo?!1:n.some(r=>r.startsWith(t.slice(e,e+o)))}function Ne(t,e,n){return n.find(o=>t.startsWith(o,e))}function _t(t){if(!t)return t;let e=t;return e=e.replace(/<\/?think(?:ing)?>/gi,""),e=e.replace(/[A-Za-z]*long[_-]?message[_-]?THINKING/gi,""),e=e.replace(/\bM?long[_-]?message\b/gi,""),e=e.replace(/(^|[\s>])THINKING(?=[\sA-Z<]|$)/g,"$1"),e!==t&&(e=e.replace(/[ \t]{2,}/g," ")),e}function sn(t){let e=[];for(let n of t){if(n.thought===!0||typeof n.text!="string"){e.push(n);continue}let o=Le(_t(n.text));(o.length>0||/^\s+$/.test(n.text))&&e.push({text:o.length>0?o:n.text})}return e}var Et=class{mode="text";buffer="";parse(e,n=!1){this.buffer+=e;let o=this.buffer.toLowerCase(),r=[],i="",s=0;for(;s<this.buffer.length;){if(this.mode==="text"){let a=Ne(o,s,fe);if(a){Z.debug(`taggedThinking: detected open tag "${a}" at offset ${s}`),pe(r,i,this.mode),i="",this.mode="thought",s+=a.length;continue}let l=Ne(o,s,ge);if(l){Z.debug(`taggedThinking: dropping orphan close tag "${l}" at offset ${s}`),pe(r,i,this.mode),i="",s+=l.length;continue}if(!n&&(Ue(o,s,fe)||Ue(o,s,ge)))break}else{let a=Ne(o,s,ge);if(a){Z.debug(`taggedThinking: detected close tag "${a}" at offset ${s}`),pe(r,i,this.mode),i="",this.mode="text",s+=a.length;continue}let l=Ne(o,s,fe);if(l){s+=l.length;continue}if(!n&&(Ue(o,s,ge)||Ue(o,s,fe)))break}i+=this.buffer[s],s+=1}return s<this.buffer.length?(pe(r,i,this.mode),this.buffer=this.buffer.slice(s),Z.debug(`taggedThinking: emitted ${r.length} part(s), buffered ${this.buffer.length} char(s)`),sn(r)):(this.buffer="",this.mode==="thought"&&i&&Z.warn(`taggedThinking: flushing ${i.length} chars of unclosed thought on stream end`),pe(r,i,this.mode),Z.debug(`taggedThinking: emitted ${r.length} part(s), flush complete`),sn(r))}};function an(t){return new Et().parse(t,!0)}var P=O("CONVERTER"),gn="(attached media from previous tool call)";function mn(t,e={}){let n=t.prompt_tokens||0,o=t.completion_tokens||0,r=t.total_tokens||0,i=t.prompt_tokens_details,s=i?.cached_tokens??i?.cachedTokens??t.cached_tokens??t.prompt_cache_hit_tokens??t.cache_read_input_tokens??0,a=t.completion_tokens_details,l=a?.reasoning_tokens??a?.reasoningTokens??t.reasoning_tokens??0,c=Math.max(0,e.estimatedReasoningTokens??0),u=Math.max(0,e.estimatedContentTokens??0),p=l>0?l:c,d=o;p>0&&(o>=p?d=o:d=o+p),(u>0||c>0)&&(d=Math.max(d,u+(l>0?0:c),u+p)),r>n&&(n>0||o>0||p>0)&&(d=Math.max(d,r-n)),p===0&&c>0&&(p=c),p>d&&(p=d);let h=t.usage_is_incomplete===!0||o>0&&n===0||r>0&&n===0&&o===0,m=n,f=r;return(f===0&&(m>0||d>0)||f>0&&m>0&&f<m+d)&&(f=m+d),{promptTokenCount:m,candidatesTokenCount:d,totalTokenCount:f,cachedContentTokenCount:s,thoughtsTokenCount:p,...h?{usageIsIncomplete:!0}:{}}}var Ro=64,ln=1024;function cn(t,e){if(t.length===0)return"";if(e.emittedText.length===0)return e.emittedText=t,e.emittedLength=t.length,t;if(e.cumulativeMode){if(t.startsWith(e.emittedText)){let n=t.slice(e.emittedText.length);return e.emittedText=t,e.emittedLength=t.length,n}return e.emittedText.startsWith(t)?(P.debug(`normalizeStreamingTextDelta: cumulative rewind suppression (emitted=${e.emittedText.length}b, chunk=${t.length}b)`),""):(P.debug("normalizeStreamingTextDelta: exiting cumulative mode (chunk does not match prior accumulated text)"),e.cumulativeMode=!1,e.emittedText=t,e.emittedLength+=t.length,t)}if(t.length>e.emittedText.length&&t.startsWith(e.emittedText)){let n=e.emittedText.length,r=n>=ln&&e.emittedLength>n?e.emittedLength:n;if(t.length>r){let i=t.slice(r);return e.emittedText=t,e.emittedLength=t.length,e.cumulativeMode=!0,P.debug(`normalizeStreamingTextDelta: entered cumulative mode (prefix overlap, baseline=${n}b sliceFrom=${r}b -> curr=${t.length}b)`),i}}return t===e.emittedText?t.length>=Ro?(e.cumulativeMode=!0,P.debug(`normalizeStreamingTextDelta: entered cumulative mode (exact repeat, ${t.length}b)`),""):(e.emittedLength+=t.length,t):(e.emittedText.length<ln&&(e.emittedText+=t),e.emittedLength+=t.length,t)}function hn(t){if(!t||typeof t!="object")return t;let e=JSON.parse(JSON.stringify(t)),n=o=>{if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return o.map(n);let r={};for(let[i,s]of Object.entries(o))if(i==="type"&&typeof s=="string"){let a=s.toLowerCase();a==="integer"?r[i]="integer":a==="number"?r[i]="number":r[i]=a}else i==="minimum"||i==="maximum"||i==="multipleOf"?typeof s=="string"&&!isNaN(Number(s))?r[i]=Number(s):r[i]=s:i==="minLength"||i==="maxLength"||i==="minItems"||i==="maxItems"?typeof s=="string"&&!isNaN(Number(s))?r[i]=parseInt(s,10):r[i]=s:typeof s=="object"?r[i]=n(s):r[i]=s;return r};return n(e)}async function vo(t,e="auto"){let n=[];for(let o of t){let r;if("tool"in o?r=await o.tool():r=o,r.functionDeclarations){for(let i of r.functionDeclarations)if(i.name&&i.description){let s;i.parametersJsonSchema?s={...i.parametersJsonSchema}:i.parameters&&(s=hn(i.parameters)),s&&(s=qt(s,e)),n.push({type:"function",function:{name:i.name,description:i.description,parameters:s}})}}}return n}function bo(t,e,n={cleanOrphanToolCalls:!0}){let o=[];return ko(t,o),Io(t.contents,o,e),o=fn(o),n.cleanOrphanToolCalls&&(o=Ko(o),o=fn(o)),o}function xo(t,e){let n=t.candidates?.[0],o=n?.content?.parts||[],r=[],i=[],s=[],a=0;for(let f of o)typeof f=="string"?i.push(f):"text"in f&&f.text?"thought"in f&&f.thought?r.push(f.text):i.push(f.text):"functionCall"in f&&f.functionCall&&(s.push({id:f.functionCall.id||`call_${a}`,type:"function",function:{name:f.functionCall.name||"",arguments:JSON.stringify(f.functionCall.args||{})}}),a+=1);let l={role:"assistant",content:i.join("")||null,refusal:null},c=r.join("");c&&(l.reasoning_content=c),s.length>0&&(l.tool_calls=s);let u=Go(n?.finishReason),p=t.usageMetadata,d={prompt_tokens:p?.promptTokenCount||0,completion_tokens:p?.candidatesTokenCount||0,total_tokens:p?.totalTokenCount||0};p?.cachedContentTokenCount!==void 0&&(d.prompt_tokens_details={cached_tokens:p.cachedContentTokenCount});let h=t.createTime?Number(t.createTime):Date.now(),m=Number.isFinite(h)?Math.floor(h/1e3):Math.floor(Date.now()/1e3);return{id:t.responseId||`gemini-${Date.now()}`,object:"chat.completion",created:m,model:t.modelVersion||e.model,choices:[{index:0,message:l,finish_reason:u,logprobs:null}],usage:d}}function ko(t,e){if(!t.config?.systemInstruction)return;let n=Tn(t.config.systemInstruction);n&&e.push({role:"system",content:n})}function Io(t,e,n){if(Array.isArray(t))for(let o of t)dn(o,e,n);else t&&dn(t,e,n)}function dn(t,e,n){if(typeof t=="string"){e.push({role:"user",content:t});return}if(!Do(t))return;let o=t.parts||[],r=t.role==="model"?"assistant":"user",i=[],s=[],a=[],l=0,c=new Set,u=new Set,p=[];for(let d of o){if(typeof d=="string"){i.push({type:"text",text:d});continue}"text"in d&&"thought"in d&&d.thought&&r==="assistant"&&d.text&&s.push(d.text),"text"in d&&d.text&&!("thought"in d&&d.thought)&&i.push({type:"text",text:d.text});let h=Cn(d,n);if(h&&r==="user"&&i.push(h),"functionCall"in d&&d.functionCall&&r==="assistant"){let m=d.functionCall.id;if(m){if(c.has(m)){P.debug(`Dropping duplicate functionCall id=${m} while converting content`);continue}c.add(m)}a.push({id:m||`call_${l}`,type:"function",function:{name:d.functionCall.name||"",arguments:JSON.stringify(d.functionCall.args||{})}}),l+=1}if(d.functionResponse&&r==="user"){let m=d.functionResponse.id;if(m){if(u.has(m))continue;u.add(m)}let f=wo(d.functionResponse,n);if(f){if(n.splitToolMedia&&Array.isArray(f.content)){let C=[],T=[];for(let y of f.content)y&&(y.type==="image_url"||y.type==="input_audio"||y.type==="video_url"||y.type==="file")?C.push(y):y&&y.type==="text"&&T.push(y);if(C.length>0){let y=T.map(S=>S.text).join(`
3
+ import{a as j,d as Zt}from"./chunk-4F4DA5UI.js";import{a as tn,b as At,c as nn,d as on}from"./chunk-DC7LAFZZ.js";import{b as Wt,d as qt,g as yt,j as Yt,k as Jt,s as en,v as ue}from"./chunk-S7G6QPEP.js";import{b as A,e as B}from"./chunk-4J6DC24J.js";import{a as Xt,d as Qt}from"./chunk-SDTWBD62.js";import{Bb as de,Jc as ht,Kc as Ct,Mb as ft,Mc as Tt,Pa as Co,Pb as gt,Ra as To,Rb as mt,Sa as X,Wa as xe,Xa as ke,Ya as Ie,a as _,ab as pt,eb as Oe,f as U,fb as V,na as ut,tb as we,ub as Pe}from"./chunk-KSNBNXBC.js";import{b as rn}from"./chunk-3YLXGE6T.js";import{P as ve,T as zt,V as dt,aa as O,d as Vt,e as ae,f as le,k as at}from"./chunk-VLYRNOD3.js";import{b as lt,c as v,f as ct,g as ce,h as M,i as be,k as jt,l as x,n as J}from"./chunk-FWDMPRKU.js";import{b as g}from"./chunk-GZPNIYVZ.js";import{f as ho}from"./chunk-OWGSC52X.js";g();function Q(t){return!Number.isFinite(t)||t<=0?0:Math.ceil(t/4)}function De(t){let e=t.candidates||0,n=t.thoughts||0;return n>e?e+n:Math.max(e,n)}function yo(t){return t.total&&t.total>0?Math.max(t.total,(t.prompt||0)+De(t)):(t.prompt||0)+De(t)}function Ao(t){let e=Math.max(0,t.thoughtsTokens||0),n=De({candidates:t.outputTokens||0,thoughts:e}),o=Math.max(t.totalTokens||0,(t.inputTokens||0)+n);return{...t,outputTokens:n,thoughtsTokens:e,totalTokens:o}}g();g();var So=/[A-Za-z\u00C0-\u024F]/g;function Eo(t){return t>=1024&&t<=1279||t>=1280&&t<=1327||t>=11744&&t<=11775||t>=42560&&t<=42655||t>=12352&&t<=12543||t>=13312&&t<=19903||t>=19968&&t<=40959||t>=63744&&t<=64255||t>=44032&&t<=55215}function St(t){let e=t.codePointAt(0);return e!==void 0&&Eo(e)}function _o(t){let e=t.match(So)?.length??0;if(e<24)return!1;let n=0;for(let o of t)St(o)&&n++;return n===0||e>=n*8}function Le(t){if(!t||!_o(t))return t;let e="",n=0,o=[...t];for(;n<o.length;){if(!St(o[n])){e+=o[n],n++;continue}let r=n;for(;r>0&&o[r-1]===" ";)r--;let i=n+1;for(;i<o.length&&St(o[i]);)i++;for(;i<o.length&&o[i]===" ";)i++;let s=r>0?o[r-1]:"",a=i<o.length?o[i]:"";(/[A-Za-z0-9]/.test(s)&&/[A-Za-z0-9]/.test(a)||o[r]===" "||o[i-1]===" ")&&(e+=" "),n=i,r<n&&o[r]===" "&&e.endsWith(" ")&&(e=e.slice(0,-1))}return e.replace(/ {2,}/g," ")}g();var Z=O("TAGGED_THINKING_PARSER"),fe=["<think>","<thinking>"],ge=["</think>","</thinking>"],Mo=Math.max(...fe.map(t=>t.length),...ge.map(t=>t.length));function pe(t,e,n){e&&t.push(n==="thought"?{text:e,thought:!0}:{text:e})}function Ue(t,e,n){let o=t.length-e;return o<=0||o>Mo?!1:n.some(r=>r.startsWith(t.slice(e,e+o)))}function Ne(t,e,n){return n.find(o=>t.startsWith(o,e))}function _t(t){if(!t)return t;let e=t;return e=e.replace(/<\/?think(?:ing)?>/gi,""),e=e.replace(/[A-Za-z]*long[_-]?message[_-]?THINKING/gi,""),e=e.replace(/\bM?long[_-]?message\b/gi,""),e=e.replace(/(^|[\s>])THINKING(?=[\sA-Z<]|$)/g,"$1"),e!==t&&(e=e.replace(/[ \t]{2,}/g," ")),e}function sn(t){let e=[];for(let n of t){if(n.thought===!0||typeof n.text!="string"){e.push(n);continue}let o=Le(_t(n.text));(o.length>0||/^\s+$/.test(n.text))&&e.push({text:o.length>0?o:n.text})}return e}var Et=class{mode="text";buffer="";parse(e,n=!1){this.buffer+=e;let o=this.buffer.toLowerCase(),r=[],i="",s=0;for(;s<this.buffer.length;){if(this.mode==="text"){let a=Ne(o,s,fe);if(a){Z.debug(`taggedThinking: detected open tag "${a}" at offset ${s}`),pe(r,i,this.mode),i="",this.mode="thought",s+=a.length;continue}let l=Ne(o,s,ge);if(l){Z.debug(`taggedThinking: dropping orphan close tag "${l}" at offset ${s}`),pe(r,i,this.mode),i="",s+=l.length;continue}if(!n&&(Ue(o,s,fe)||Ue(o,s,ge)))break}else{let a=Ne(o,s,ge);if(a){Z.debug(`taggedThinking: detected close tag "${a}" at offset ${s}`),pe(r,i,this.mode),i="",this.mode="text",s+=a.length;continue}let l=Ne(o,s,fe);if(l){s+=l.length;continue}if(!n&&(Ue(o,s,ge)||Ue(o,s,fe)))break}i+=this.buffer[s],s+=1}return s<this.buffer.length?(pe(r,i,this.mode),this.buffer=this.buffer.slice(s),Z.debug(`taggedThinking: emitted ${r.length} part(s), buffered ${this.buffer.length} char(s)`),sn(r)):(this.buffer="",this.mode==="thought"&&i&&Z.warn(`taggedThinking: flushing ${i.length} chars of unclosed thought on stream end`),pe(r,i,this.mode),Z.debug(`taggedThinking: emitted ${r.length} part(s), flush complete`),sn(r))}};function an(t){return new Et().parse(t,!0)}var P=O("CONVERTER"),gn="(attached media from previous tool call)";function mn(t,e={}){let n=t.prompt_tokens||0,o=t.completion_tokens||0,r=t.total_tokens||0,i=t.prompt_tokens_details,s=i?.cached_tokens??i?.cachedTokens??t.cached_tokens??t.prompt_cache_hit_tokens??t.cache_read_input_tokens??0,a=t.completion_tokens_details,l=a?.reasoning_tokens??a?.reasoningTokens??t.reasoning_tokens??0,c=Math.max(0,e.estimatedReasoningTokens??0),u=Math.max(0,e.estimatedContentTokens??0),p=l>0?l:c,d=o;p>0&&(o>=p?d=o:d=o+p),(u>0||c>0)&&(d=Math.max(d,u+(l>0?0:c),u+p)),r>n&&(n>0||o>0||p>0)&&(d=Math.max(d,r-n)),p===0&&c>0&&(p=c),p>d&&(p=d);let h=t.usage_is_incomplete===!0||o>0&&n===0||r>0&&n===0&&o===0,m=n,f=r;return(f===0&&(m>0||d>0)||f>0&&m>0&&f<m+d)&&(f=m+d),{promptTokenCount:m,candidatesTokenCount:d,totalTokenCount:f,cachedContentTokenCount:s,thoughtsTokenCount:p,...h?{usageIsIncomplete:!0}:{}}}var Ro=64,ln=1024;function cn(t,e){if(t.length===0)return"";if(e.emittedText.length===0)return e.emittedText=t,e.emittedLength=t.length,t;if(e.cumulativeMode){if(t.startsWith(e.emittedText)){let n=t.slice(e.emittedText.length);return e.emittedText=t,e.emittedLength=t.length,n}return e.emittedText.startsWith(t)?(P.debug(`normalizeStreamingTextDelta: cumulative rewind suppression (emitted=${e.emittedText.length}b, chunk=${t.length}b)`),""):(P.debug("normalizeStreamingTextDelta: exiting cumulative mode (chunk does not match prior accumulated text)"),e.cumulativeMode=!1,e.emittedText=t,e.emittedLength+=t.length,t)}if(t.length>e.emittedText.length&&t.startsWith(e.emittedText)){let n=e.emittedText.length,r=n>=ln&&e.emittedLength>n?e.emittedLength:n;if(t.length>r){let i=t.slice(r);return e.emittedText=t,e.emittedLength=t.length,e.cumulativeMode=!0,P.debug(`normalizeStreamingTextDelta: entered cumulative mode (prefix overlap, baseline=${n}b sliceFrom=${r}b -> curr=${t.length}b)`),i}}return t===e.emittedText?t.length>=Ro?(e.cumulativeMode=!0,P.debug(`normalizeStreamingTextDelta: entered cumulative mode (exact repeat, ${t.length}b)`),""):(e.emittedLength+=t.length,t):(e.emittedText.length<ln&&(e.emittedText+=t),e.emittedLength+=t.length,t)}function hn(t){if(!t||typeof t!="object")return t;let e=JSON.parse(JSON.stringify(t)),n=o=>{if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return o.map(n);let r={};for(let[i,s]of Object.entries(o))if(i==="type"&&typeof s=="string"){let a=s.toLowerCase();a==="integer"?r[i]="integer":a==="number"?r[i]="number":r[i]=a}else i==="minimum"||i==="maximum"||i==="multipleOf"?typeof s=="string"&&!isNaN(Number(s))?r[i]=Number(s):r[i]=s:i==="minLength"||i==="maxLength"||i==="minItems"||i==="maxItems"?typeof s=="string"&&!isNaN(Number(s))?r[i]=parseInt(s,10):r[i]=s:typeof s=="object"?r[i]=n(s):r[i]=s;return r};return n(e)}async function vo(t,e="auto"){let n=[];for(let o of t){let r;if("tool"in o?r=await o.tool():r=o,r.functionDeclarations){for(let i of r.functionDeclarations)if(i.name&&i.description){let s;i.parametersJsonSchema?s={...i.parametersJsonSchema}:i.parameters&&(s=hn(i.parameters)),s&&(s=qt(s,e)),n.push({type:"function",function:{name:i.name,description:i.description,parameters:s}})}}}return n}function bo(t,e,n={cleanOrphanToolCalls:!0}){let o=[];return ko(t,o),Io(t.contents,o,e),o=fn(o),n.cleanOrphanToolCalls&&(o=Ko(o),o=fn(o)),o}function xo(t,e){let n=t.candidates?.[0],o=n?.content?.parts||[],r=[],i=[],s=[],a=0;for(let f of o)typeof f=="string"?i.push(f):"text"in f&&f.text?"thought"in f&&f.thought?r.push(f.text):i.push(f.text):"functionCall"in f&&f.functionCall&&(s.push({id:f.functionCall.id||`call_${a}`,type:"function",function:{name:f.functionCall.name||"",arguments:JSON.stringify(f.functionCall.args||{})}}),a+=1);let l={role:"assistant",content:i.join("")||null,refusal:null},c=r.join("");c&&(l.reasoning_content=c),s.length>0&&(l.tool_calls=s);let u=Go(n?.finishReason),p=t.usageMetadata,d={prompt_tokens:p?.promptTokenCount||0,completion_tokens:p?.candidatesTokenCount||0,total_tokens:p?.totalTokenCount||0};p?.cachedContentTokenCount!==void 0&&(d.prompt_tokens_details={cached_tokens:p.cachedContentTokenCount});let h=t.createTime?Number(t.createTime):Date.now(),m=Number.isFinite(h)?Math.floor(h/1e3):Math.floor(Date.now()/1e3);return{id:t.responseId||`gemini-${Date.now()}`,object:"chat.completion",created:m,model:t.modelVersion||e.model,choices:[{index:0,message:l,finish_reason:u,logprobs:null}],usage:d}}function ko(t,e){if(!t.config?.systemInstruction)return;let n=Tn(t.config.systemInstruction);n&&e.push({role:"system",content:n})}function Io(t,e,n){if(Array.isArray(t))for(let o of t)dn(o,e,n);else t&&dn(t,e,n)}function dn(t,e,n){if(typeof t=="string"){e.push({role:"user",content:t});return}if(!Do(t))return;let o=t.parts||[],r=t.role==="model"?"assistant":"user",i=[],s=[],a=[],l=0,c=new Set,u=new Set,p=[];for(let d of o){if(typeof d=="string"){i.push({type:"text",text:d});continue}"text"in d&&"thought"in d&&d.thought&&r==="assistant"&&d.text&&s.push(d.text),"text"in d&&d.text&&!("thought"in d&&d.thought)&&i.push({type:"text",text:d.text});let h=Cn(d,n);if(h&&r==="user"&&i.push(h),"functionCall"in d&&d.functionCall&&r==="assistant"){let m=d.functionCall.id;if(m){if(c.has(m)){P.debug(`Dropping duplicate functionCall id=${m} while converting content`);continue}c.add(m)}a.push({id:m||`call_${l}`,type:"function",function:{name:d.functionCall.name||"",arguments:JSON.stringify(d.functionCall.args||{})}}),l+=1}if(d.functionResponse&&r==="user"){let m=d.functionResponse.id;if(m){if(u.has(m))continue;u.add(m)}let f=wo(d.functionResponse,n);if(f){if(n.splitToolMedia&&Array.isArray(f.content)){let C=[],T=[];for(let y of f.content)y&&(y.type==="image_url"||y.type==="input_audio"||y.type==="video_url"||y.type==="file")?C.push(y):y&&y.type==="text"&&T.push(y);if(C.length>0){let y=T.map(S=>S.text).join(`
4
4
  `);f.content=y||"[media attached in following user message]",p.push(...C)}}e.push(f)}}}if(p.length>0&&e.push({role:"user",content:[{type:"text",text:gn},...p]}),r==="assistant"){if(i.length===0&&a.length===0&&s.length===0)return;let h={role:"assistant",content:i.filter(f=>f.type==="text").map(f=>f.text).join("")||(s.length>0?"":null)};a.length>0&&(h.tool_calls=a);let m=s.join("");m&&(h.reasoning_content=m),e.push(h);return}i.length>0&&e.push({role:"user",content:i})}function Oo(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="object"){let e=t,n=e.output;if(typeof n=="string")return n;let o=e.error;if(typeof o=="string")return o}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}function wo(t,e){let n=Oo(t.response),o=[];n&&o.push({type:"text",text:n});for(let r of t.parts||[]){if("text"in r&&typeof r.text=="string"){r.text.length>0&&o.push({type:"text",text:r.text});continue}let i=Cn(r,e);i&&o.push(i)}return o.length===0?{role:"tool",tool_call_id:t.id||"",content:""}:{role:"tool",tool_call_id:t.id||"",content:o}}function Cn(t,e){let{modalities:n}=e;if(t.inlineData?.mimeType&&t.inlineData?.data){let o=t.inlineData.mimeType,r=un(o),i=t.inlineData.displayName||o;if(r==="image")return n.image?{type:"image_url",image_url:{url:`data:${o};base64,${t.inlineData.data}`}}:z("image",i,e);if(o==="application/pdf")return n.pdf?{type:"file",file:{filename:t.inlineData.displayName||"document.pdf",file_data:`data:${o};base64,${t.inlineData.data}`}}:z("pdf",i,e);if(r==="audio"){if(!n.audio)return z("audio",i,e);let s=Po(o);if(s)return{type:"input_audio",input_audio:{data:`data:${o};base64,${t.inlineData.data}`,format:s}}}return r==="video"?n.video?{type:"video_url",video_url:{url:`data:${o};base64,${t.inlineData.data}`}}:z("video",i,e):{type:"text",text:`Unsupported inline media type: ${o} (${i}).`}}if(t.fileData?.mimeType&&t.fileData?.fileUri){let o=t.fileData.displayName||"file",r=t.fileData.fileUri,i=t.fileData.mimeType,s=un(i);if(s==="image")return n.image?{type:"image_url",image_url:{url:r}}:z("image",o,e);if(i==="application/pdf")return n.pdf?{type:"file",file:{filename:o,file_data:r}}:z("pdf",o,e);if(s==="video")return n.video?{type:"video_url",video_url:{url:r}}:z("video",o,e);let a=t.fileData.displayName?` (${t.fileData.displayName})`:"";return{type:"text",text:`Unsupported file media type: ${i}${a}.`}}return null}function z(t,e,n){P.warn(`Model '${n.model}' does not support ${t} input. Replacing with text placeholder: ${e}`);let o;return t==="pdf"?o=`This model does not support PDF input directly. The read_file tool cannot extract PDF content either. To extract text from the PDF file, try using skills if applicable, or guide user to install pdf skill by running this slash command:
5
5
  /extensions install https://github.com/anthropics/skills:document-skills`:o=`This model does not support ${t} input. The read_file tool cannot process this type of file either. To handle this file, try using skills if applicable, or any tools installed at system wide, or let the user know you cannot process this type of file.`,{type:"text",text:`[Unsupported ${t} file: "${e}". ${o}]`}}function un(t){return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"file"}function Po(t){return t.includes("wav")?"wav":t.includes("mp3")||t.includes("mpeg")?"mp3":null}function Do(t){return typeof t=="object"&&t!==null&&"role"in t&&"parts"in t&&Array.isArray(t.parts)}function Tn(t){return typeof t=="string"?t:Array.isArray(t)?t.map(e=>Tn(e)).filter(Boolean).join(`
6
6
  `):typeof t=="object"&&t!==null&&"parts"in t&&t.parts?.map(n=>typeof n=="string"?n:"text"in n&&n.text||"").filter(Boolean).join(`
@@ -8,7 +8,7 @@ import{a as j,d as Zt}from"./chunk-4F4DA5UI.js";import{a as tn,b as At,c as nn,d
8
8
  ${n}`:n;return{...o,text:a}}return e}};g();function Hn(t){switch(t){case"openai":return"OPENAI_API_KEY";case"anthropic":return"ANTHROPIC_API_KEY";case"gemini":return"GEMINI_API_KEY";case"vertex-ai":return"GOOGLE_API_KEY";default:return"API_KEY"}}function Bn(t){switch(t){case"openai":return"OPENAI_MODEL";case"anthropic":return"ANTHROPIC_MODEL";case"gemini":return"GEMINI_MODEL";case"vertex-ai":return"GOOGLE_MODEL";default:return"MODEL"}}var F=class extends Error{constructor(e){super(e),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},je=class extends F{code="STRICT_MISSING_CREDENTIALS";constructor(e,n,o){let r=e||"(unknown)",i=n||"(unknown)";super(`Missing credentials for modelProviders model '${i}'. `+(o?`Current configured envKey: '${o}'. Set that environment variable, or update modelProviders.${r}[].envKey.`:`Configure modelProviders.${r}[].envKey and set that environment variable.`))}},ze=class extends F{code="STRICT_MISSING_MODEL_ID";constructor(e){super(`Missing model id for strict modelProviders resolution (authType: ${e}).`)}},We=class extends F{code="MISSING_API_KEY";constructor(e){super(`Missing API key for ${e.authType} auth. Current model: '${e.model||"(unknown)"}', baseUrl: '${e.baseUrl||"(default)"}'. Provide an API key via settings (security.auth.apiKey), or set the environment variable '${e.envKey}'.`)}},qe=class extends F{code="MISSING_MODEL";constructor(e){super(`Missing model for ${e.authType} auth. Set the environment variable '${e.envKey}'.`)}},Ye=class extends F{code="MISSING_BASE_URL";constructor(e){super(`Missing baseUrl for modelProviders model '${e.model||"(unknown)"}'. Configure modelProviders.${e.authType||"(unknown)"}[].baseUrl.`)}},Je=class extends F{code="MISSING_ANTHROPIC_BASE_URL_ENV";constructor(){super("ANTHROPIC_BASE_URL environment variable not found.")}};g();import Kr from"node:process";g();var Vn={image:!0,pdf:!0,audio:!0,video:!0},Fr=[[/^gemini-3/,Vn],[/^gemini-/,Vn],[/^gpt-5/,{image:!0}],[/^gpt-/,{image:!0}],[/^o\d/,{image:!0}],[/^claude-/,{image:!0,pdf:!0}],[/^matilda3\.5-plus/,{image:!0,video:!0}],[/^matilda3\.6-plus/,{image:!0,video:!0}],[/^matilda3\.7-plus/,{image:!0,video:!0}],[/^coder-model$/,{image:!0,video:!0}],[/^matilda-vl-/,{image:!0,video:!0}],[/^matilda3-vl-/,{image:!0,video:!0}],[/^matilda-code$/,{}],[/^matilda3-coder-/,{}],[/^matilda3\.6-35b/,{image:!0,video:!0}],[/^matilda/,{}],[/^deepseek/,{}],[/^glm-4\.5v/,{image:!0}],[/^glm-5(?:-|$)/,{}],[/^glm-/,{}],[/^minimax-m3/i,{image:!0,video:!0}],[/^minimax-/,{}],[/^kimi-k2\.5/,{image:!0,video:!0}],[/^kimi-/,{}],[/^doubao-seed(ance|ream)/,{}],[/^doubao-seed/,{image:!0}],[/^doubao-.*(vision|vl)/,{image:!0}],[/^doubao/,{}]];function Ce(t){let e=en(t);for(let[n,o]of Fr)if(n.test(e))return{...o};return{}}g();var Xe="$runtime|";function Na(t){let e=t;for(;e.startsWith(Xe);){let n=e.split("|").slice(2).join("|");if(!n)break;e=n}return e}g();g();g();var Qe=["samplingParams","timeout","maxRetries","retryErrorCodes","enableCacheControl","schemaCompliance","reasoning","contextWindowSize","customHeaders","extra_body","modalities","splitToolMedia","matildaAgentSdk","matildaAgentPurpose","matildaAgentResponseMode","openAIRequestProfile"],jn=["model","apiKey","apiKeyEnvKey","baseUrl"],Ze=[...jn,...Qe],Ha={openai:{apiKey:["OPENAI_API_KEY"],baseUrl:["OPENAI_BASE_URL"],model:["OPENAI_MODEL","MATILDA_MODEL"]},anthropic:{apiKey:["ANTHROPIC_API_KEY"],baseUrl:["ANTHROPIC_BASE_URL"],model:["ANTHROPIC_MODEL"]},gemini:{apiKey:["GEMINI_API_KEY"],baseUrl:[],model:["GEMINI_MODEL"]},"vertex-ai":{apiKey:["GOOGLE_API_KEY"],baseUrl:[],model:["GOOGLE_MODEL"]},"matilda-oauth":{apiKey:[],baseUrl:[],model:[]}},Ba={openai:Zt,"matilda-oauth":j},et=[{id:"coder-model",name:"coder-model",description:"Matilda 3.6 Plus \u2014 efficient hybrid model with leading coding performance",capabilities:{vision:!0}}],Va=et.map(t=>t.id);var kt=O("MODEL_REGISTRY");function zn(t){if(Object.values(G).includes(t))return t}function Gr(t){return/^minimax-m3/i.test(t.trim().toLowerCase())}function Wn(t,e){return e?`${t}\0${e}`:t}var tt=class{modelsByAuthType;getDefaultBaseUrl(e){switch(e){case"matilda-oauth":return"DYNAMIC_MATILDA_OAUTH_BASE_URL";case"openai":return Yt;default:return""}}constructor(e){if(this.modelsByAuthType=new Map,this.registerAuthTypeModels("matilda-oauth",et),e)for(let[n,o]of Object.entries(e)){let r=zn(n);if(!r){kt.warn(`Invalid authType key "${n}" in modelProviders config. Expected one of: ${Object.values(G).join(", ")}. Skipping.`);continue}r!=="matilda-oauth"&&this.registerAuthTypeModels(r,o)}}registerAuthTypeModels(e,n){let o=new Map;for(let r of n){let i=Wn(r.id,r.baseUrl);if(o.has(i)){kt.warn(`Duplicate model id "${r.id}"${r.baseUrl?` with baseUrl "${r.baseUrl}"`:""} for authType "${e}". Using the first registered config.`);continue}let s=this.resolveModelConfig(r,e);o.set(i,s)}this.modelsByAuthType.set(e,o)}getModelsForAuthType(e){let n=this.modelsByAuthType.get(e);return n?Array.from(n.values()).map(o=>({id:o.id,label:o.name,description:o.description,capabilities:o.capabilities,authType:o.authType,isVision:o.capabilities?.vision??!1,contextWindowSize:o.generationConfig.contextWindowSize??ue(o.id),modalities:o.generationConfig.modalities,baseUrl:o.baseUrl,envKey:o.envKey})):[]}getModel(e,n,o){let r=this.modelsByAuthType.get(e);if(!r)return;if(o)return r.get(Wn(n,o));let i=r.get(n);if(i)return i;for(let s of r.values())if(s.id===n)return s}hasModel(e,n,o){return this.getModel(e,n,o)!==void 0}getDefaultModelForAuthType(e){if(e==="matilda-oauth")return this.getModel(e,j);let n=this.modelsByAuthType.get(e);if(!(!n||n.size===0))return Array.from(n.values())[0]}resolveModelConfig(e,n){this.validateModelConfig(e,n);let o={...e.generationConfig??{}};return(o.modalities===void 0||Gr(e.id))&&(o.modalities=Ce(e.id)),{...e,authType:n,name:e.name||e.id,baseUrl:e.baseUrl||this.getDefaultBaseUrl(n),generationConfig:o,capabilities:e.capabilities||{}}}validateModelConfig(e,n){if(!e.id)throw new Error(`Model config in authType '${n}' missing required field: id`)}reloadModels(e){for(let n of this.modelsByAuthType.keys())n!=="matilda-oauth"&&this.modelsByAuthType.delete(n);if(e)for(let[n,o]of Object.entries(e)){let r=zn(n);if(!r){kt.warn(`Invalid authType key "${n}" in modelProviders config. Expected one of: ${Object.values(G).join(", ")}. Skipping.`);continue}r!=="matilda-oauth"&&this.registerAuthTypeModels(r,o)}}};var qn=class t{modelRegistry;currentAuthType;_generationConfig;generationConfigSources;strictModelProviderSelection=!1;requireCachedMatildaCredentialsOnce=!1;hasManualCredentials=!1;onModelChange;authTypeWasExplicitlyProvided;runtimeModelSnapshots=new Map;activeRuntimeModelSnapshotId;static deepClone(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(o=>t.deepClone(o));let n={};for(let o of Object.keys(e))n[o]=t.deepClone(e[o]);return n}constructor(e={}){this.modelRegistry=new tt(e.modelProvidersConfig),this.onModelChange=e.onModelChange,this._generationConfig={...e.generationConfig||{}},this.generationConfigSources=e.generationConfigSources||{},this.authTypeWasExplicitlyProvided=e.initialAuthType!==void 0,this.currentAuthType=e.initialAuthType}createStateSnapshotForRollback(){return{currentAuthType:this.currentAuthType,generationConfig:t.deepClone(this._generationConfig),generationConfigSources:t.deepClone(this.generationConfigSources),strictModelProviderSelection:this.strictModelProviderSelection,requireCachedMatildaCredentialsOnce:this.requireCachedMatildaCredentialsOnce,hasManualCredentials:this.hasManualCredentials,activeRuntimeModelSnapshotId:this.activeRuntimeModelSnapshotId}}rollbackToStateSnapshot(e){this.currentAuthType=e.currentAuthType,this._generationConfig=e.generationConfig,this.generationConfigSources=e.generationConfigSources,this.strictModelProviderSelection=e.strictModelProviderSelection,this.requireCachedMatildaCredentialsOnce=e.requireCachedMatildaCredentialsOnce,this.hasManualCredentials=e.hasManualCredentials,this.activeRuntimeModelSnapshotId=e.activeRuntimeModelSnapshotId}getModel(){return this._generationConfig.model||j}getCurrentAuthType(){return this.currentAuthType}wasAuthTypeExplicitlyProvided(){return this.authTypeWasExplicitlyProvided}getAvailableModels(){return this.currentAuthType?this.modelRegistry.getModelsForAuthType(this.currentAuthType):[]}getAvailableModelsForAuthType(e){return this.modelRegistry.getModelsForAuthType(e)}getAllConfiguredModels(e){let n=e&&e.length>0?e:Object.values(G),o=new Set,r=[];for(let l of n)o.has(l)||(o.add(l),r.push(l));let i=[];r.includes("matilda-oauth")&&i.push("matilda-oauth");for(let l of r)l!=="matilda-oauth"&&i.push(l);let s=this.getRuntimeModelOption(),a=[];for(let l of i)s&&s.authType===l&&a.push(s),a.push(...this.modelRegistry.getModelsForAuthType(l));return a}hasModel(e,n){return this.modelRegistry.hasModel(e,n)}getResolvedModel(e,n){return this.modelRegistry.getModel(e,n)}isManagedMatildaResolvedModel(e){return e?.id===At&&e?.envKey===tn&&e?.baseUrl===on&&e?.generationConfig?.openAIRequestProfile==="matilda-code"}isManagedMatildaModel(e){let n=e.trim();return!n||!this.currentAuthType?!1:this.isManagedMatildaResolvedModel(this.modelRegistry.getModel(this.currentAuthType,n))}getPublicModelId(e){return this.isManagedMatildaModel(e)?At:e}getModelDisplayName(e){return this.isManagedMatildaModel(e)?nn:this.currentAuthType?this.modelRegistry.getModel(this.currentAuthType,e)?.name??e:e}async setModel(e,n){if(this.currentAuthType==="matilda-oauth"&&e===j){this.strictModelProviderSelection=!1,this._generationConfig.model=e,this.generationConfigSources.model={kind:"programmatic",detail:n?.reason||"setModel"},this.onModelChange&&await this.onModelChange("matilda-oauth",!1);return}if(this.currentAuthType&&this.modelRegistry.hasModel(this.currentAuthType,e)){await this.switchModel(this.currentAuthType,e);return}let o=this.createStateSnapshotForRollback();try{this.strictModelProviderSelection=!1,this._generationConfig.model=e,this.generationConfigSources.model={kind:"programmatic",detail:n?.reason||"setModel"},this.applyRawModelDerivedDefaults(e),this.onModelChange&&this.currentAuthType&&await this.onModelChange(this.currentAuthType,!0)}catch(r){throw this.rollbackToStateSnapshot(o),r}}applyRawModelDerivedDefaults(e){this.shouldUpdateModelDerivedDefault("modalities")&&(this._generationConfig.modalities=Ce(e),this.generationConfigSources.modalities={kind:"computed",detail:"auto-detected from model"}),this.shouldUpdateModelDerivedDefault("contextWindowSize")&&(this._generationConfig.contextWindowSize=ue(e,"input"),this.generationConfigSources.contextWindowSize={kind:"computed",detail:"auto-detected from model"})}shouldUpdateModelDerivedDefault(e){let n=this.generationConfigSources[e];return n===void 0||n.kind==="computed"||n.kind==="default"||n.kind==="modelProviders"||n.kind==="programmatic"||n.kind==="unknown"}async switchModel(e,n,o){let r=this.extractRuntimeModelSnapshotId(n);if(r){await this.switchToRuntimeModel(r);return}let i=this.createStateSnapshotForRollback();e==="matilda-oauth"&&o?.requireCachedCredentials&&(this.requireCachedMatildaCredentialsOnce=!0);try{let s=e!==this.currentAuthType;this.currentAuthType=e;let a=this.modelRegistry.getModel(e,n,o?.baseUrl);if(!a)throw new Error(`Model '${n}' not found for authType '${e}'`);let l=i.generationConfig.model||"",c=!s&&l?this.modelRegistry.getModel(e,l,i.generationConfig.baseUrl)??this.modelRegistry.getModel(e,l):void 0,u=e!=="matilda-oauth"&&!s&&!!i.generationConfig.apiKey&&!!a.envKey&&c?.envKey===a.envKey&&c.baseUrl===a.baseUrl,p=u?i.generationConfig.apiKey:void 0,d=u?i.generationConfigSources.apiKey:void 0;this.applyResolvedModelDefaults(a),!this._generationConfig.apiKey&&p&&(this._generationConfig.apiKey=p,d&&(this.generationConfigSources.apiKey=t.deepClone(d))),this.activeRuntimeModelSnapshotId=void 0;let h=s?!0:this.checkRequiresRefresh(l);this.onModelChange&&await this.onModelChange(e,h)}catch(s){throw this.rollbackToStateSnapshot(i),s}}buildRuntimeModelSnapshotId(e,n){return`${Xe}${e}|${n}`}extractRuntimeModelSnapshotId(e){if(e.startsWith(Xe))return this.runtimeModelSnapshots.has(e)?e:void 0;if(this.runtimeModelSnapshots.has(e))return e}getGenerationConfig(){return this._generationConfig}getGenerationConfigSources(){return this.generationConfigSources}mergeSettingsGenerationConfig(e){if(e)for(let n of Qe)!(n in this._generationConfig)&&n in e&&(this._generationConfig[n]=e[n],this.generationConfigSources[n]={kind:"settings",detail:`model.generationConfig.${n}`})}updateCredentials(e,n){(e.apiKey||e.baseUrl||e.model)&&(this.hasManualCredentials=!0,this.clearProviderSourcedConfig()),e.apiKey&&(this._generationConfig.apiKey=e.apiKey,this.generationConfigSources.apiKey={kind:"programmatic",detail:"updateCredentials"}),e.baseUrl&&(this._generationConfig.baseUrl=e.baseUrl,this.generationConfigSources.baseUrl={kind:"programmatic",detail:"updateCredentials"}),e.model&&(this._generationConfig.model=e.model,this.generationConfigSources.model={kind:"programmatic",detail:"updateCredentials"}),this.strictModelProviderSelection=!1,this._generationConfig.apiKeyEnvKey=void 0,n&&this.mergeSettingsGenerationConfig(n),this.syncRuntimeModelSnapshotWithCredentials()}syncRuntimeModelSnapshotWithCredentials(){let e=this.currentAuthType,{model:n,apiKey:o,baseUrl:r}=this._generationConfig;if(!(!n||!e||!o||!r)&&!this.modelRegistry.hasModel(e,n,r))if(this.activeRuntimeModelSnapshotId&&this.runtimeModelSnapshots.has(this.activeRuntimeModelSnapshotId)){let i=this.runtimeModelSnapshots.get(this.activeRuntimeModelSnapshotId);i.apiKey=o,i.baseUrl=r,i.modelId=n;let s=this.buildRuntimeModelSnapshotId(i.authType,i.modelId);s!==i.id&&(this.runtimeModelSnapshots.delete(i.id),i.id=s,this.runtimeModelSnapshots.set(s,i),this.activeRuntimeModelSnapshotId=s),i.createdAt=Date.now()}else this.detectAndCaptureRuntimeModel()}clearProviderSourcedConfig(){for(let e of Ze)this.generationConfigSources[e]?.kind==="modelProviders"&&(delete this._generationConfig[e],delete this.generationConfigSources[e])}isStrictModelProviderSelection(){return this.strictModelProviderSelection}resetStrictModelProviderSelection(){this.strictModelProviderSelection=!1}consumeRequireCachedCredentialsFlag(){let e=this.requireCachedMatildaCredentialsOnce;return this.requireCachedMatildaCredentialsOnce=!1,e}applyResolvedModelDefaults(e){if(this.strictModelProviderSelection=!0,this.hasManualCredentials=!1,this._generationConfig.model=e.id,this.generationConfigSources.model={kind:"modelProviders",authType:e.authType,modelId:e.id,detail:"model.id"},this.currentAuthType==="matilda-oauth"?(this._generationConfig.apiKey="MATILDA_OAUTH_DYNAMIC_TOKEN",this.generationConfigSources.apiKey={kind:"computed",detail:"Matilda OAuth placeholder token"},this._generationConfig.apiKeyEnvKey=void 0,delete this.generationConfigSources.apiKeyEnvKey):(this._generationConfig.apiKey=void 0,this._generationConfig.apiKeyEnvKey=void 0),e.envKey!==void 0){let o=Kr.env[e.envKey];o&&(this._generationConfig.apiKey=o,this.generationConfigSources.apiKey={kind:"env",envKey:e.envKey,via:{kind:"modelProviders",authType:e.authType,modelId:e.id,detail:"envKey"}}),this._generationConfig.apiKeyEnvKey=e.envKey,this.generationConfigSources.apiKeyEnvKey={kind:"modelProviders",authType:e.authType,modelId:e.id,detail:"envKey"}}this._generationConfig.baseUrl=e.baseUrl,this.generationConfigSources.baseUrl={kind:"modelProviders",authType:e.authType,modelId:e.id,detail:"baseUrl"};let n=e.generationConfig;for(let o of Qe)this._generationConfig[o]=n[o],this.generationConfigSources[o]={kind:"modelProviders",authType:e.authType,modelId:e.id,detail:`generationConfig.${o}`};n.contextWindowSize===void 0&&(this._generationConfig.contextWindowSize=ue(e.id,"input"),this.generationConfigSources.contextWindowSize={kind:"computed",detail:"auto-detected from model"}),n.modalities===void 0&&(this._generationConfig.modalities=Ce(e.id),this.generationConfigSources.modalities={kind:"computed",detail:"auto-detected from model"})}checkRequiresRefresh(e){let n=this.currentAuthType;if(!n)return!0;if(n==="matilda-oauth")return!1;let o=this.modelRegistry.getModel(n,this._generationConfig.model||"",this._generationConfig.baseUrl||void 0),r=this.modelRegistry.getModel(n,e);return!r||!o||r.envKey!==o.envKey||r.baseUrl!==o.baseUrl}syncAfterAuthRefresh(e,n){this.strictModelProviderSelection=!1;let o=this.currentAuthType;this.currentAuthType=e;let r=this.generationConfigSources.baseUrl?.kind==="modelProviders"?this._generationConfig.baseUrl:void 0,i=n?this.modelRegistry.getModel(e,n,r)??this.modelRegistry.getModel(e,n):void 0;if(i){let h=this.generationConfigSources.baseUrl?.kind==="modelProviders"&&(this._generationConfig.apiKeyEnvKey!==i.envKey||this._generationConfig.baseUrl!==i.baseUrl),m=o===e&&this._generationConfig.model===n&&!h,f=m?this._generationConfig.apiKey:void 0,C=m&&this.generationConfigSources.apiKey?{...this.generationConfigSources.apiKey}:void 0,T=this.generationConfigSources.baseUrl,y=m&&!!this._generationConfig.baseUrl&&(T?.kind==="cli"||T?.kind==="env"||T?.kind==="settings"),S=y?this._generationConfig.baseUrl:void 0,R=y&&T?{...T}:void 0;this.applyResolvedModelDefaults(i),m&&!this._generationConfig.apiKey&&f&&(this._generationConfig.apiKey=f,C&&(this.generationConfigSources.apiKey=C)),S&&(this._generationConfig.baseUrl=S,R&&(this.generationConfigSources.baseUrl=R)),this.strictModelProviderSelection=!0,this.activeRuntimeModelSnapshotId=void 0;return}let s=this.generationConfigSources.apiKey,a=this.generationConfigSources.baseUrl,l=this._generationConfig.apiKey&&s?.kind!=="modelProviders"||this._generationConfig.baseUrl&&a?.kind!=="modelProviders";if(!(o!==e)&&(n===void 0||!this.modelRegistry.hasModel(e,n))&&(this.hasManualCredentials||l)){n&&(this._generationConfig.model=n,this.generationConfigSources.model||(this.generationConfigSources.model={kind:"programmatic",detail:"auth refresh (preserved credentials)"}));return}let p=this.modelRegistry.getDefaultModelForAuthType(e);if(p){this.applyResolvedModelDefaults(p),this.activeRuntimeModelSnapshotId=void 0;return}n&&(this._generationConfig.model=n,this.generationConfigSources.model||(this.generationConfigSources.model={kind:"programmatic",detail:"auth refresh (no default model)"}))}setOnModelChange(e){this.onModelChange=e}detectAndCaptureRuntimeModel(){let{model:e,apiKey:n,baseUrl:o,apiKeyEnvKey:r,...i}=this._generationConfig,s=this.currentAuthType;if(!e||!s)return;if(this.modelRegistry.hasModel(s,e,o)){this.clearRuntimeModelSnapshotForAuthType(s);return}if(!(this._generationConfig.apiKey&&this._generationConfig.baseUrl))return;let l=this.buildRuntimeModelSnapshotId(s,e),c={id:l,authType:s,modelId:e,apiKey:n,baseUrl:o,apiKeyEnvKey:r,generationConfig:i,sources:{...this.generationConfigSources},createdAt:Date.now()};return this.runtimeModelSnapshots.set(l,c),this.activeRuntimeModelSnapshotId=l,this.cleanupOldRuntimeModelSnapshots(),l}getActiveRuntimeModelSnapshot(){if(this.activeRuntimeModelSnapshotId)return this.runtimeModelSnapshots.get(this.activeRuntimeModelSnapshotId)}getActiveRuntimeModelSnapshotId(){return this.activeRuntimeModelSnapshotId}async switchToRuntimeModel(e){let n=this.runtimeModelSnapshots.get(e);if(!n)throw new Error(`Runtime model snapshot '${e}' not found`);let o=this.createStateSnapshotForRollback();try{let r=n.authType!==this.currentAuthType;this.currentAuthType=n.authType,this.activeRuntimeModelSnapshotId=e,this.strictModelProviderSelection=!1,this.hasManualCredentials=!0,this._generationConfig.model=n.modelId,this.generationConfigSources.model={kind:"programmatic",detail:"runtimeModelSwitch"},n.apiKey&&(this._generationConfig.apiKey=n.apiKey,this.generationConfigSources.apiKey=n.sources.apiKey||{kind:"programmatic",detail:"runtimeModelSwitch"}),n.baseUrl&&(this._generationConfig.baseUrl=n.baseUrl,this.generationConfigSources.baseUrl=n.sources.baseUrl||{kind:"programmatic",detail:"runtimeModelSwitch"}),n.apiKeyEnvKey&&(this._generationConfig.apiKeyEnvKey=n.apiKeyEnvKey),n.generationConfig&&Object.assign(this._generationConfig,n.generationConfig);let i=r;this.onModelChange&&await this.onModelChange(n.authType,i)}catch(r){throw this.rollbackToStateSnapshot(o),r}}getRuntimeModelOption(){let e=this.getActiveRuntimeModelSnapshot();if(e)return{id:e.modelId,label:e.modelId,authType:e.authType,isVision:!1,contextWindowSize:e.generationConfig?.contextWindowSize,isRuntimeModel:!0,runtimeSnapshotId:e.id}}clearRuntimeModelSnapshotForAuthType(e){for(let[n,o]of this.runtimeModelSnapshots.entries())o.authType===e&&(this.runtimeModelSnapshots.delete(n),this.activeRuntimeModelSnapshotId===n&&(this.activeRuntimeModelSnapshotId=void 0))}cleanupOldRuntimeModelSnapshots(){let e=new Map;for(let n of this.runtimeModelSnapshots.values()){let o=e.get(n.authType);(!o||n.createdAt>o.createdAt)&&e.set(n.authType,n)}this.runtimeModelSnapshots.clear();for(let n of e.values())this.runtimeModelSnapshots.set(n.id,n);this.activeRuntimeModelSnapshotId&&!this.runtimeModelSnapshots.has(this.activeRuntimeModelSnapshotId)&&(this.activeRuntimeModelSnapshotId=void 0)}reloadModelProvidersConfig(e){this.modelRegistry.reloadModels(e)}};g();import{readFileSync as ri}from"node:fs";import{join as ii}from"node:path";g();g();import{randomBytes as $r,createHash as Hr}from"node:crypto";function Yn(t){return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"}function It(){let t=$r(32).toString("base64url"),e=Hr("sha256").update(t).digest("base64url");return{codeVerifier:t,codeChallenge:e}}function Te(t,e){return{accessToken:t.access_token,refreshToken:t.refresh_token??e?.refreshToken,expiresAt:Date.now()+(t.expires_in??3600)*1e3,idToken:t.id_token??e?.idToken}}async function Ot(t){let e=t.replace(/\/+$/,""),n=new URL("/.well-known/oauth-authorization-server",e);if(n.protocol!=="https:"&&!Yn(n.hostname))throw new Error(`Refusing OAuth discovery over insecure transport: ${n.origin}`);let o=await fetch(n,{headers:{accept:"application/json"}});if(!o.ok)throw new Error(`OAuth discovery failed (${o.status}) for ${n.origin}`);let r=await o.json();if(!r.issuer||!r.authorization_endpoint||!r.token_endpoint)throw new Error(`OAuth discovery document missing required fields for ${n.origin}`);return{issuer:r.issuer,authorization_endpoint:r.authorization_endpoint,token_endpoint:r.token_endpoint,device_authorization_endpoint:r.device_authorization_endpoint}}g();import{promises as nt,openSync as Br,closeSync as Vr,unlinkSync as Jn,statSync as jr}from"node:fs";import{dirname as zr}from"node:path";var Wr=1e4,qr=3e4,Yr=50;function wt(t){let e=async()=>{try{let r=await nt.readFile(t,"utf8"),i=JSON.parse(r);return i&&typeof i=="object"?i:{}}catch(r){if(r.code==="ENOENT")return{};throw r}},n=async r=>{await nt.mkdir(zr(t),{recursive:!0}),await nt.writeFile(t,JSON.stringify(r,null,2),{mode:384}),await nt.chmod(t,384).catch(()=>{})};return{store:{async get(r){return(await e())[r]??null},async set(r,i){let s=await e();s[r]=i,await n(s)},async remove(r){let i=await e();r in i&&(delete i[r],await n(i))}},lock:Jr(`${t}.lock`)}}function Jr(t){let e=Promise.resolve();return n=>{let o=e.then(async()=>{await Xr(t);try{return await n()}finally{Qr(t)}});return e=o.then(()=>{},()=>{}),o}}async function Xr(t){let e=Date.now()+Wr;for(;;)try{Vr(Br(t,"wx"));return}catch(n){if(n.code!=="EEXIST")throw n;try{if(Date.now()-jr(t).mtimeMs>qr){Jn(t);continue}}catch{continue}if(Date.now()>e)throw new Error(`Timed out acquiring credential lock at ${t}`);await Zr(Yr)}}function Qr(t){try{Jn(t)}catch{}}function Zr(t){return new Promise(e=>setTimeout(e,t))}g();var te=class extends Error{code="invalid_grant";constructor(e="Refresh token is no longer valid \u2014 sign in again."){super(e),this.name="InvalidGrantError"}};function Pt(t){let e=t.storageKey??"default",n=t.fetchImpl??fetch,o=t.expirySkewMs??6e4,r=null,i=async()=>{let l=await t.store.get(e);if(!l)return null;try{let c=JSON.parse(l);return c.accessToken?c:null}catch{return null}},s=l=>l.expiresAt-Date.now()>o,a=l=>t.lock(async()=>{let c=await i()??l;if(c.accessToken!==l.accessToken&&s(c))return c.accessToken;if(!c.refreshToken)throw new te("No refresh token available \u2014 sign in again.");let u=await n(t.tokenEndpoint,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",client_id:t.clientId,refresh_token:c.refreshToken})});if(!u.ok){let h=await u.text().catch(()=>"");throw u.status>=400&&u.status<500&&ei(h)==="invalid_grant"?(await t.store.remove(e),new te):new Error(`Token refresh failed (${u.status})`)}let p=await u.json(),d=Te(p,c);return await t.store.set(e,JSON.stringify(d)),d.accessToken});return{async getAccessToken(l){let c=await i();if(!c)throw new te("Not signed in.");return!l?.forceRefresh&&s(c)?c.accessToken:(r||(r=a(c).finally(()=>{r=null})),r)}}}function ei(t){try{return JSON.parse(t).error}catch{return}}g();import{createServer as ti}from"node:http";import{randomBytes as ni}from"node:crypto";async function Dt(t){if(t.transport.kind!=="loopback")throw new Error(`Unsupported login transport: ${t.transport.kind}`);if(t.signal?.aborted)throw new Error("Login aborted");let e=m=>t.onEvent?.(m),{codeVerifier:n,codeChallenge:o}=It(),r=ni(16).toString("hex"),i=t.timeoutMs??5*60*1e3,s=t.transport.successRedirect;e({type:"state",status:"idle"});let a,l,c=new Promise((m,f)=>{a=m,l=f});c.catch(()=>{});let u=ti((m,f)=>{let C=new URL(m.url??"/","http://127.0.0.1");if(C.pathname!=="/callback"){f.writeHead(404).end();return}let T=C.searchParams.get("error"),y=C.searchParams.get("state"),S=C.searchParams.get("code");if(T){let R=C.searchParams.get("error_description"),$=R?`OAuth error: ${T} (${R})`:`OAuth error: ${T}`;f.writeHead(400,{"content-type":"text/plain; charset=utf-8"}).end(`Sign-in failed: ${T}
9
9
  `,()=>l(new Error($)));return}if(y!==r){f.writeHead(400).end("State mismatch"),l(new Error("OAuth state mismatch"));return}if(!S){f.writeHead(400).end("Missing authorization code");return}oi(f,s,()=>a(S))}),p=await new Promise((m,f)=>{u.once("error",f),u.listen(t.transport.port??0,"127.0.0.1",()=>{m(u.address().port)})}),d=setTimeout(()=>l(new Error("Login timed out \u2014 the browser never reached the local callback. The hosted success page is not a completed sign-in.")),i),h=()=>l(new Error("Login aborted"));t.signal?.addEventListener("abort",h,{once:!0});try{let m=`http://127.0.0.1:${p}/callback`,f=new URL(t.metadata.authorization_endpoint);f.searchParams.set("client_id",t.clientId),f.searchParams.set("response_type","code"),f.searchParams.set("redirect_uri",m),f.searchParams.set("code_challenge",o),f.searchParams.set("code_challenge_method","S256"),f.searchParams.set("state",r),f.searchParams.set("prompt","select_account"),f.searchParams.set("scope",t.scope??"openid offline_access");let C=f.toString();e({type:"authorize_url",url:C}),e({type:"state",status:"awaiting_user"}),t.openBrowser&&await t.openBrowser(C);let T=await c;e({type:"state",status:"exchanging"});let y=await fetch(t.metadata.token_endpoint,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:t.clientId,code:T,code_verifier:n,redirect_uri:m})});if(!y.ok){let R=await y.text().catch(()=>"");throw new Error(`Token exchange failed (${y.status}): ${R}`)}let S=Te(await y.json());return e({type:"state",status:"authenticated"}),S}catch(m){throw e({type:"state",status:"error"}),m}finally{clearTimeout(d),t.signal?.removeEventListener("abort",h),u.close()}}function oi(t,e,n){t.writeHead(302,{location:e}).end(n)}var ye="matilda-code",Xn="matilda-desktop",si="openid profile email offline_access",Ae="MATILDA_API_KEY",ai="matilda";function Se(t){return t.trim().replace(/\/+$/,"").replace(/\/api\/v1(?:\/code)?$/i,"")}function Qn(){return ii(ve.getGlobalMatildaDir(),"matilda-auth.json")}function ot(){return wt(Qn())}function li(t){return t==="desktop"}function Ee(t){return t?.clientId?t.clientId:li(t?.channel)?Xn:ye}function oe(t){return`matilda:${t}`}function rt(t){return`${oe(t)}:refresh-rejected`}function _e(t){return t===ye?[oe(t),ai]:[oe(t)]}function ci(){try{let t=ri(Qn(),"utf8");return JSON.parse(t)}catch{return{}}}function Lt(t){if(!t)return null;try{let e=JSON.parse(t);return typeof e?.accessToken=="string"&&typeof e?.baseUrl=="string"?e:null}catch{return null}}function di(t,e){return Se(t)===Se(e)}function ui(t){if(!t)return{};try{let e=t.split(".")[1],n=Buffer.from(e.replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf8"),o=JSON.parse(n);return{sub:o.sub,email:o.email,name:o.name}}catch{return{}}}function pi(t,e){let n=ui(t.idToken);return{accessToken:t.accessToken,accessTokenExpiresAt:t.expiresAt,refreshToken:t.refreshToken??"",userId:n.sub,email:n.email,displayName:n.name,baseUrl:e}}async function Zn(t){try{return await Ot(t)}catch{return{issuer:t,authorization_endpoint:`${t}/api/auth/oauth/authorize`,token_endpoint:`${t}/api/auth/oauth/token`,device_authorization_endpoint:`${t}/api/auth/oauth/device/code`}}}function q(t){try{let e=ci(),n=Ee(t);for(let o of _e(n)){let r=Lt(e[o]);if(r)return r}return null}catch{return null}}async function fi(t){let e=Ee(t),n=ot().store;for(let o of _e(e))await n.remove(o);await n.set(rt(e),"1"),delete process.env[Ae]}function gi(t){return t instanceof Error?t.code==="invalid_grant"||t.name==="InvalidGrantError"?!0:t.message==="Token refresh failed (401)":!1}function ne(t){Ut({authStage:t.authStage,authOutcome:t.authOutcome,occurrenceCount:t.occurrenceCount},{baseUrl:t.baseUrl,token:t.token}).catch(()=>{})}async function mi(t,e){let n=Ee(e),o=ot().store;await o.set(oe(n),JSON.stringify(t)),await o.remove(rt(n));for(let r of _e(n))r!==oe(n)&&await o.remove(r);process.env[Ae]=t.accessToken}async function hi(t){let e=Ee(t),n=ot().store;for(let o of _e(e))await n.remove(o);await n.remove(rt(e)),delete process.env[Ae]}function zl(t){let e=q(t);return e?{authenticated:!0,userId:e.userId,email:e.email,displayName:e.displayName,baseUrl:e.baseUrl,accessTokenExpiresAt:e.accessTokenExpiresAt}:{authenticated:!1}}async function Wl(t){let e={channel:t?.channel,clientId:t?.clientId},n=q(e);if(n?.accessToken){let o=Se(n.baseUrl);await fetch(`${o}/api/auth/logout`,{method:"POST",headers:{authorization:`Bearer ${n.accessToken}`,"content-type":"application/json"},body:JSON.stringify(n.refreshToken?{refreshToken:n.refreshToken}:{}),signal:t?.signal??AbortSignal.timeout(5e3)}).catch(()=>{})}await hi(e)}async function Nt(t){let e=Ee(t),n=oe(e),o=q({channel:t?.channel,clientId:e});if(!o||t?.baseUrl&&!di(o.baseUrl,t.baseUrl))return t?.fallbackAccessToken??process.env[Ae]??"";let r=Se(o.baseUrl),i=await Zn(r),{store:s,lock:a}=ot(),l=Ci(s,a,i.token_endpoint,o.baseUrl,e,n,t?.signal),c=e===ye&&(!!t?.forceRefresh||o.accessTokenExpiresAt-Date.now()<=3e5),u;try{u=await l.getAccessToken({forceRefresh:t?.forceRefresh})}catch(p){throw c&&ne({baseUrl:o.baseUrl,token:o.accessToken,authStage:"refresh",authOutcome:"failed"}),e===Xn&&gi(p)&&await fi({channel:t?.channel,clientId:e}),p}return c&&ne({baseUrl:o.baseUrl,token:u,authStage:"refresh",authOutcome:"succeeded"}),process.env[Ae]=u,u}async function ql(t){await Nt(t);let e=q(t);if(!e)throw new Error("No Matilda credentials to refresh \u2014 sign in again.");return e}function Ci(t,e,n,o,r,i,s){let a=_e(r);return Pt({tokenEndpoint:n,clientId:r,store:{get:async u=>{let p=u===i?a:[u],d=null;for(let m of p)if(d=Lt(await t.get(m)),d)break;if(!d?.accessToken)return null;let h={accessToken:d.accessToken,refreshToken:d.refreshToken,expiresAt:d.accessTokenExpiresAt};return JSON.stringify(h)},set:async(u,p)=>{let d=JSON.parse(p),h=u===i?a:[u],m={};for(let C of h){let T=Lt(await t.get(C));if(T){m=T;break}}let f={...m,accessToken:d.accessToken,accessTokenExpiresAt:d.expiresAt,refreshToken:d.refreshToken??m.refreshToken??"",baseUrl:m.baseUrl??o};await t.set(i,JSON.stringify(f)),await t.remove(rt(r));for(let C of a)C!==i&&await t.remove(C)},remove:async u=>{let p=u===i?a:[u];for(let d of p)await t.remove(d)}},storageKey:i,lock:e,fetchImpl:(u,p)=>fetch(u,{...p,signal:s}),expirySkewMs:3e5})}function Ti(){return process.env.MATILDA_AUTH_SKIP_BROWSER!=="1"&&rn()}async function Yl(t){let e=Se(t.baseUrl),n=await Zn(e),o="",r=0,i=0,s={},a=p=>{s[p]=(s[p]??0)+1},c=await(p=>(r+=1,Dt({metadata:n,clientId:ye,scope:p,transport:{kind:"loopback",successRedirect:`${e}/api/auth/oauth/success?client_id=${encodeURIComponent(ye)}`},signal:t.signal,onEvent:d=>{d.type==="authorize_url"&&(o=d.url,t.onAuthorizeUrl?.(d.url)),d.type==="state"&&d.status==="exchanging"&&(i+=1)},openBrowser:async d=>{if(t.openBrowser===!1||!Ti()){a("skipped");return}try{let{default:h}=await import("./open-QQ7FWG4A.js");(await h(d)).once("error",()=>{}),a("succeeded")}catch{a("failed")}}})))(si),u=pi(c,t.baseUrl);await mi(u),ne({baseUrl:t.baseUrl,token:u.accessToken,authStage:"auth_started",authOutcome:"started",occurrenceCount:r});for(let[p,d]of Object.entries(s))ne({baseUrl:t.baseUrl,token:u.accessToken,authStage:"browser_opened",authOutcome:p,occurrenceCount:d});return i>0&&ne({baseUrl:t.baseUrl,token:u.accessToken,authStage:"callback_received",authOutcome:"succeeded",occurrenceCount:i}),ne({baseUrl:t.baseUrl,token:u.accessToken,authStage:"token_persisted",authOutcome:"succeeded"}),{...u,authorizeUrl:o}}var G=(i=>(i.USE_OPENAI="openai",i.MATILDA_OAUTH="matilda-oauth",i.USE_GEMINI="gemini",i.USE_VERTEX_AI="vertex-ai",i.USE_ANTHROPIC="anthropic",i))(G||{}),yi="MATILDA_AGENT_SDK",it="MATILDA_API_KEY";function Ai(t,e){if(t.apiKey||t.apiKeyEnvKey!==it)return;let n=q({channel:e});n?.accessToken&&(t.apiKey=n.accessToken,process.env[it]=n.accessToken)}async function Si(t,e){if(t.apiKeyEnvKey!==it)return;let n=q({channel:e});if(!n?.accessToken)return;let o=await Nt({baseUrl:t.baseUrl,fallbackAccessToken:n.accessToken,channel:e});o&&(t.apiKey=o,process.env[it]=o)}function Ei(t){return t.matildaAgentSdk===!0||process.env[yi]==="1"}function Ft(t,e,n){t[e]=n}function _i(t,e){return t?.[e]}function Mi(t,e,n,o,r){let i={...o||{}},s=r?.strictModelProvider===!0,a={...n||{},authType:e,proxy:t?.getProxy()};Ft(i,"authType",{kind:"computed",detail:"provided by caller"}),t?.getProxy()&&Ft(i,"proxy",{kind:"computed",detail:"Config.getProxy()"});let l=u=>_i(o,u)??{kind:"unknown"};for(let u of Ze)n&&u in n&&!i[u]&&Ft(i,u,l(u));Ai(a,t.getChannel());let c=to(a,s);if(!c.valid)throw new Error(c.errors.map(u=>u.message).join(`
10
10
  `));return{config:a,sources:i}}function to(t,e=!1){let n=[];if(t.authType==="matilda-oauth")return{valid:!0,errors:[]};if(!t.apiKey)if(e)n.push(new je(t.authType,t.model,t.apiKeyEnvKey));else{let o=t.apiKeyEnvKey||Hn(t.authType);n.push(new We({authType:t.authType,model:t.model,baseUrl:t.baseUrl,envKey:o}))}if(!t.model)if(e)n.push(new ze(t.authType));else{let o=Bn(t.authType);n.push(new qe({authType:t.authType,envKey:o}))}return t.authType==="anthropic"&&!t.baseUrl&&(e?n.push(new Ye({authType:t.authType,model:t.model})):t.authType==="anthropic"&&n.push(new Je)),{valid:n.length===0,errors:n}}function nc(t,e,n){return Mi(t,e,n).config}function eo(t){let e=t;for(;e instanceof Error;){if("code"in e&&e.code==="ERR_MODULE_NOT_FOUND")return e;e=e.cause}}async function oc(t,e,n){await Si(t,e.getChannel());let o=to(t,!1);if(!o.valid)throw new Error(o.errors.map(s=>s.message).join(`
11
- `));let r=t.authType;if(!r)throw new Error("ContentGeneratorConfig must have an authType");let i;try{if(r==="openai")if(Ei(t)){let{createMatildaAgentContentGenerator:s}=await import("./matildaAgentContentGenerator-4TE52UGH.js");i=s(t,e)}else{let{createOpenAIContentGenerator:s}=await import("./openaiContentGenerator-4UHFUHKP.js");i=s(t,e)}else if(r==="matilda-oauth"){let{getMatildaOAuthClient:s}=await import("./matildaOAuth2-W2DQO2NK.js"),{MatildaContentGenerator:a}=await import("./matildaContentGenerator-7BKTRYT7.js");try{let l=await s(e,n?{requireCachedCredentials:!0}:void 0);i=new a(l,t,e)}catch(l){throw eo(l)?l:new Error(l instanceof Error?l.message:String(l))}}else if(r==="anthropic"){let{createAnthropicContentGenerator:s}=await import("./anthropicContentGenerator-SFJGSZHT.js");i=s(t,e)}else if(r==="gemini"||r==="vertex-ai"){let{createGeminiContentGenerator:s}=await import("./geminiContentGenerator-ROVF5ZDW.js");i=s(t,e)}else throw new Error(`Error creating contentGenerator: Unsupported authType: ${r}`)}catch(s){let a=eo(s);throw a?new Error(`Matilda was updated in the background and needs to be restarted.
11
+ `));let r=t.authType;if(!r)throw new Error("ContentGeneratorConfig must have an authType");let i;try{if(r==="openai")if(Ei(t)){let{createMatildaAgentContentGenerator:s}=await import("./matildaAgentContentGenerator-HVIGLQJZ.js");i=s(t,e)}else{let{createOpenAIContentGenerator:s}=await import("./openaiContentGenerator-X6TFPZGL.js");i=s(t,e)}else if(r==="matilda-oauth"){let{getMatildaOAuthClient:s}=await import("./matildaOAuth2-W2DQO2NK.js"),{MatildaContentGenerator:a}=await import("./matildaContentGenerator-5VOBYNAJ.js");try{let l=await s(e,n?{requireCachedCredentials:!0}:void 0);i=new a(l,t,e)}catch(l){throw eo(l)?l:new Error(l instanceof Error?l.message:String(l))}}else if(r==="anthropic"){let{createAnthropicContentGenerator:s}=await import("./anthropicContentGenerator-SFJGSZHT.js");i=s(t,e)}else if(r==="gemini"||r==="vertex-ai"){let{createGeminiContentGenerator:s}=await import("./geminiContentGenerator-APSI54U5.js");i=s(t,e)}else throw new Error(`Error creating contentGenerator: Unsupported authType: ${r}`)}catch(s){let a=eo(s);throw a?new Error(`Matilda was updated in the background and needs to be restarted.
12
12
  Please exit and restart Matilda to use the '${r}' provider.`,{cause:a}):s}return new he(i,e,t)}var Ri=["x-matilda-client-name","x-matilda-client-version","x-matilda-client-operating-system","x-matilda-client-architecture","x-matilda-client-distribution-channel","x-matilda-client-release-channel"],vi=new Set([...Ri,...Qt]),bi=new Set(["VSCode","ACP","SDK","CI"]),re="(?:0|[1-9]\\d{0,4})\\.(?:0|[1-9]\\d{0,4})\\.(?:0|[1-9]\\d{0,4})",xi="[A-Za-z][0-9A-Za-z-]{0,23}",no="(?:0|[1-9]\\d{0,11}|[0-9A-Fa-f]{7,12})",ki=new RegExp(`^${re}(?:-${xi}(?:\\.${no})+)?$`),Ii=63,Oi=new RegExp(`^${re}$`),wi=new RegExp(`^${re}-preview\\.(?:0|[1-9]\\d{0,11})$`),Pi=new RegExp(`^${re}-canary\\.(?:0|[1-9]\\d{0,11})$`),Di=new RegExp(`^${re}-nightly\\.(?:0|[1-9]\\d{0,11})\\.[0-9A-Fa-f]{7,12}$`),Li=new RegExp(`^${re}-(preview|canary|nightly|development|internal)(?:\\.${no})+$`);function Ui(t){return t==="desktop"?"desktop":t===void 0||bi.has(t)?"code_cli":"unknown"}function Ni(t){if(t==="android")return"android";if(t==="darwin")return"macos";if(t==="win32")return"windows";if(t==="linux")return"linux"}function Fi(t){if(t==="x64")return"x64";if(t==="arm64")return"arm64"}function Gi(t){if(t===void 0)return"npm";if(t==="desktop")return"direct-download";if(t==="VSCode")return"vscode-marketplace"}function Ki(t,e){if(e==="desktop")return"matilda-desktop";if(t==="VSCode")return"matilda-vscode";if(e==="code_cli")return"matilda-code"}function $i(t){if(typeof t=="string"&&!(t.length>Ii||!ki.test(t)))return t}function Hi(t){if(t!==void 0)return Oi.test(t)?"stable":wi.test(t)?"preview":Pi.test(t)?"canary":Di.test(t)?"nightly":Li.exec(t)?.[1]}function oo(t,e=process.platform,n=process.arch){let o=t.getChannel?.(),r=Ui(o),i=$i(o==="desktop"&&process.env.CRAFT_AGENT_VERSION!==void 0?process.env.CRAFT_AGENT_VERSION:t.getCliVersion?.()),s=Hi(i),a=Ni(e),l=Fi(n),c=Gi(o),u=Ki(o,r);return{...u?{"x-matilda-client-name":u}:{},...i?{"x-matilda-client-version":i}:{},...a?{"x-matilda-client-operating-system":a}:{},...l?{"x-matilda-client-architecture":l}:{},...c?{"x-matilda-client-distribution-channel":c}:{},...s?{"x-matilda-client-release-channel":s}:{}}}function cc(t){let e=t.toLowerCase();return vi.has(e)||e.startsWith("x-matilda-reported-")}function Bi(t){let e=t??Jt;try{let n=new URL(e);if(n.protocol!=="https:"&&n.protocol!=="http:")return!1;let o=n.hostname.toLowerCase();return o==="matilda.maincode.com"||o.endsWith(".matilda.maincode.com")||o==="core-api.matilda"}catch{return!1}}function dc(t,e=t.apiKey){return t.authType==="matilda-oauth"?!0:t.authType==="openai"&&!!e&&Bi(t.baseUrl)}var Vi=3e3,Me=1,ji=24*60*60*1e3,ro=20,io=999,zi=new Set(["UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","SELF_SIGNED_CERT_IN_CHAIN","DEPTH_ZERO_SELF_SIGNED_CERT","CERT_HAS_EXPIRED","ERR_TLS_CERT_ALTNAME_INVALID"]),Wi=new Set(["ENOTFOUND","EAI_AGAIN"]),qi=new Set(["ECONNREFUSED","EHOSTUNREACH","ENETUNREACH"]),Yi=new Set(["ABORT_ERR","ETIMEDOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT"]),Ji=new Set(["ECONNRESET","EPIPE","UND_ERR_SOCKET"]);function Xi(t){return`${new URL(t).origin}/api/client-events`}function Qi(t){let e={eventType:t.eventType,platform:"cli"};return t.eventType==="network_error"&&(e.transportReason=t.transportReason,e.transportStage=t.transportStage,e.responseReceived=t.responseReceived,e.occurrenceCount=t.occurrenceCount),t.eventType==="auth_funnel"&&(e.authStage=t.authStage,e.authOutcome=t.authOutcome,e.occurrenceCount=t.occurrenceCount),t.eventType==="network_error"&&(e.reportedSurface=t.reportedSurface,e.reportedOs=t.reportedOs,e.reportedArchitecture=t.reportedArchitecture,e.reportedProcess=t.reportedProcess,e.reportedReleaseChannel=t.reportedReleaseChannel,t.reportedVersion&&(e.reportedVersion=t.reportedVersion)),e}async function Gt(t,e){let{baseUrl:n,token:o}=e;if(!n||!o)return!1;let r=e.fetchImpl??fetch,i=new AbortController,s=setTimeout(()=>i.abort(),e.timeoutMs??Vi);try{let a=await r(Xi(n),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${o}`},body:JSON.stringify(Qi(t)),signal:i.signal});return a.ok?!0:(be.warn(`client-events beacon: server rejected payload (HTTP ${a.status})`),!1)}catch{return!1}finally{clearTimeout(s)}}async function Ut(t,e){let n=typeof t.occurrenceCount=="number"&&Number.isFinite(t.occurrenceCount)?Math.max(1,Math.min(Math.floor(t.occurrenceCount),io)):1;return Gt({eventType:"auth_funnel",authStage:t.authStage,authOutcome:t.authOutcome,occurrenceCount:n},e)}function so(){try{let t=K.readFileSync(co(),"utf8"),e=JSON.parse(t);return e.schemaVersion!==Me||!Array.isArray(e.failures)?void 0:{schemaVersion:Me,failures:e.failures.filter(Zi)}}catch{return}}function Zi(t){if(!t||typeof t!="object")return!1;let e=t;return e.eventType==="network_error"&&typeof e.transportReason=="string"&&typeof e.transportStage=="string"&&typeof e.responseReceived=="boolean"&&typeof e.occurrenceCount=="number"&&typeof e.reportedSurface=="string"&&typeof e.reportedOs=="string"&&typeof e.reportedArchitecture=="string"&&typeof e.reportedProcess=="string"&&typeof e.reportedReleaseChannel=="string"&&typeof e.firstObservedAtMs=="number"&&typeof e.lastObservedAtMs=="number"}function ao(t){let e=co();if(t.failures.length===0){try{K.rmSync(e,{force:!0})}catch{}return}try{K.mkdirSync(st.dirname(e),{recursive:!0}),K.writeFileSync(e,`${JSON.stringify(t)}
13
13
  `,"utf8")}catch{}}function lo(t,e){return t.filter(n=>e-n.lastObservedAtMs<=ji).sort((n,o)=>n.firstObservedAtMs-o.firstObservedAtMs).slice(-ro)}function es(t){let e=oo(t);return{reportedSurface:e["x-matilda-client-name"]==="matilda-desktop"?"desktop":e["x-matilda-client-name"]==="matilda-code"||e["x-matilda-client-name"]==="matilda-vscode"?"code_cli":"unknown",reportedOs:e["x-matilda-client-operating-system"]??"unknown",reportedArchitecture:e["x-matilda-client-architecture"]??"unknown",reportedProcess:e["x-matilda-client-name"]??"unknown",reportedVersion:e["x-matilda-client-version"],reportedReleaseChannel:e["x-matilda-client-release-channel"]??"unknown"}}function ts(t){if(!t||typeof t!="object")return;let e=t.code;if(typeof e=="string")return e;if(!(t instanceof Error)||!t.cause||typeof t.cause!="object")return;let n=t.cause.code;return typeof n=="string"?n:void 0}function ns(t){if(!(!t||typeof t!="object"))for(let e of["status","statusCode"]){let n=t[e];if(typeof n=="number")return n}}function os(t,e){let n=ts(t);if(n&&zi.has(n))return{reason:"tls",stage:"tls",responseReceived:!1};if(n&&Wi.has(n))return{reason:"dns",stage:"resolve",responseReceived:!1};if(n&&qi.has(n))return{reason:"connect",stage:"connect",responseReceived:!1};if(n&&Yi.has(n))return{reason:"timeout",stage:n==="UND_ERR_BODY_TIMEOUT"?"response":"request",responseReceived:n==="UND_ERR_BODY_TIMEOUT"};if(n&&Ji.has(n))return{reason:"reset",stage:n==="UND_ERR_SOCKET"?"response":"request",responseReceived:n==="UND_ERR_SOCKET"};let o=ns(t),r=t instanceof Error?t.message.toLowerCase():String(t).toLowerCase();if(r.includes("self signed")||r.includes("certificate")||r.includes("tls"))return{reason:"tls",stage:"tls",responseReceived:!1};if(o===407||n==="proxy_auth_required")return{reason:"proxy",stage:"connect",responseReceived:!0};if(e&&r.includes("proxy")&&(r.includes("407")||r.includes("connect")||r.includes("fetch failed")))return{reason:"proxy",stage:"connect",responseReceived:!1};if(r.includes("timed out")||r.includes("timeout")||r.includes("deadline exceeded"))return{reason:"timeout",stage:"request",responseReceived:!1};if(r.includes("fetch failed"))return{reason:"unknown",stage:"unknown",responseReceived:!1}}function rs(t,e){return t.findIndex(n=>n.transportReason===e.transportReason&&n.transportStage===e.transportStage&&n.responseReceived===e.responseReceived&&n.reportedSurface===e.reportedSurface&&n.reportedOs===e.reportedOs&&n.reportedArchitecture===e.reportedArchitecture&&n.reportedProcess===e.reportedProcess&&n.reportedVersion===e.reportedVersion&&n.reportedReleaseChannel===e.reportedReleaseChannel)}function hc(t,e){let n=es(e.cliConfig);if(n.reportedSurface!=="code_cli"&&n.reportedSurface!=="desktop")return!1;let o=os(t,e.proxyConfigured);if(!o)return!1;let r=Date.now(),i={eventType:"network_error",transportReason:o.reason,transportStage:o.stage,responseReceived:o.responseReceived,occurrenceCount:1,...n,firstObservedAtMs:r,lastObservedAtMs:r},s=so()??{schemaVersion:Me,failures:[]},a=lo(s.failures,r),l=rs(a,i);if(l>=0){let c=a[l];a[l]={...c,occurrenceCount:Math.min(c.occurrenceCount+1,io),lastObservedAtMs:r}}else a.push(i);return ao({schemaVersion:Me,failures:a.slice(-ro)}),!0}async function Cc(t){let e=so();if(!e)return;let n=lo(e.failures,Date.now()),o=[];for(let r=0;r<n.length;r+=1){let i=n[r];if(!await Gt({eventType:i.eventType,transportReason:i.transportReason,transportStage:i.transportStage,responseReceived:i.responseReceived,occurrenceCount:i.occurrenceCount,reportedSurface:i.reportedSurface,reportedOs:i.reportedOs,reportedArchitecture:i.reportedArchitecture,reportedProcess:i.reportedProcess,reportedVersion:i.reportedVersion,reportedReleaseChannel:i.reportedReleaseChannel},t)){o.push(...n.slice(r));break}}ao({schemaVersion:Me,failures:o})}function co(){return st.join(ve.getGlobalMatildaDir(),"telemetry","cli-transport-failures.json")}var po=(n=>(n.GCP="gcp",n.LOCAL="local",n))(po||{}),bu="local",xu="http://localhost:4317";g();J();var ss=new Set(["service.version","service.instance.id","session.id"]);function Y(t,e){be.warn(t),e?.push(t)}function fo(t,e){if(!t)return{};let n={};for(let o of t.split(",")){let r=o.trim();if(!r)continue;let i=r.indexOf("=");if(i<0){Y(`Skipping malformed OTEL_RESOURCE_ATTRIBUTES entry: "${r}" (hint: percent-encode literal commas as %2C)`,e);continue}let s=r.slice(0,i).trim();if(!s)continue;let a=r.slice(i+1).trim(),l;try{l=decodeURIComponent(s)}catch{Y(`Invalid percent-encoding in OTEL_RESOURCE_ATTRIBUTES key "${s}", using raw key`,e),l=s}let c;try{c=decodeURIComponent(a)}catch{Y(`Invalid percent-encoding in OTEL_RESOURCE_ATTRIBUTES for key "${l}", using raw value`,e),c=a}n[l]=c}return n}function Kt(t,e,n){for(let o of ss)o in t&&(Y(`${e} cannot override reserved key "${o}"; ignoring`,n),delete t[o]);return t}function go(t,e){if(t==null)return{};if(typeof t!="object"||Array.isArray(t))return Y("settings.telemetry.resourceAttributes must be an object; ignoring",e),{};let n={};for(let[o,r]of Object.entries(t)){let i=o.trim();if(!i){Y("settings.telemetry.resourceAttributes has an empty or whitespace-only key; ignoring",e);continue}typeof r=="string"?n[i]=r:Y(`settings.telemetry.resourceAttributes value for "${i}" must be a string (got ${typeof r}); ignoring`,e)}return n}function Re(t){if(t!==void 0)return t==="true"||t==="1"}function uo(t){if(t!==void 0){if(t==="local"||t==="local")return"local";if(t==="gcp"||t==="gcp")return"gcp"}}async function is(t){let e=t.argv??{},n=t.env??{},o=t.settings??{},r=e.telemetry??Re(n.MATILDA_TELEMETRY_ENABLED)??o.enabled,i=e.telemetryTarget??n.MATILDA_TELEMETRY_TARGET??o.target,s=uo(i);if(i!==void 0&&s===void 0)throw new at(`Invalid telemetry target: ${String(i)}. Valid values are: local, gcp`);let a=e.telemetryOtlpEndpoint??n.MATILDA_TELEMETRY_OTLP_ENDPOINT??n.OTEL_EXPORTER_OTLP_ENDPOINT??o.otlpEndpoint,l=e.telemetryOtlpProtocol??n.MATILDA_TELEMETRY_OTLP_PROTOCOL??o.otlpProtocol,c=["grpc","http"].find(L=>L===l);if(l!==void 0&&c===void 0)throw new at(`Invalid telemetry OTLP protocol: ${String(l)}. Valid values are: grpc, http`);let u=e.telemetryLogPrompts??Re(n.MATILDA_TELEMETRY_LOG_PROMPTS)??o.logPrompts,p=Re(n.MATILDA_TELEMETRY_INCLUDE_SENSITIVE_SPAN_ATTRIBUTES)??o.includeSensitiveSpanAttributes??!1,d=e.telemetryOutfile??n.MATILDA_TELEMETRY_OUTFILE??o.outfile,h=n.MATILDA_TELEMETRY_OTLP_TRACES_ENDPOINT??n.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT??o.otlpTracesEndpoint,m=n.MATILDA_TELEMETRY_OTLP_LOGS_ENDPOINT??n.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT??o.otlpLogsEndpoint,f=n.MATILDA_TELEMETRY_OTLP_METRICS_ENDPOINT??n.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT??o.otlpMetricsEndpoint,C=[],T=Kt(fo(n.OTEL_RESOURCE_ATTRIBUTES,C),"OTEL_RESOURCE_ATTRIBUTES",C),y=Kt(go(o.resourceAttributes,C),"settings.telemetry.resourceAttributes",C),S={...T,...y},R=n.OTEL_SERVICE_NAME?.trim();R&&(S["service.name"]=R);let $=Object.keys(S).length?S:void 0,H=Re(n.MATILDA_TELEMETRY_METRICS_INCLUDE_SESSION_ID)??o.metrics?.includeSessionId??!1;return{enabled:r,target:s,otlpEndpoint:a,otlpProtocol:c,otlpTracesEndpoint:h,otlpLogsEndpoint:m,otlpMetricsEndpoint:f,logPrompts:u,includeSensitiveSpanAttributes:p,outfile:d,resourceAttributes:$,metrics:{includeSessionId:H},resourceAttributeWarnings:C.length?C:void 0}}export{Et as a,Q as b,De as c,yo as d,Ao as e,mn as f,Ge as g,Fn as h,zo as i,me as j,Vs as k,Re as l,uo as m,is as n,ee as o,Ve as p,ir as q,xt as r,sr as s,Mn as t,ar as u,lr as v,Rn as w,cr as x,vn as y,bn as z,xn as A,dr as B,ur as C,Rr as D,vr as E,br as F,xr as G,kr as H,Ir as I,Or as J,wr as K,Pr as L,oo as M,cc as N,dc as O,Gt as P,Ut as Q,hc as R,Cc as S,po as T,bu as U,xu as V,Ce as W,Xe as X,Na as Y,Qe as Z,Ha as _,Ba as $,et as aa,Va as ba,Wn as ca,tt as da,qn as ea,Qn as fa,q as ga,mi as ha,hi as ia,zl as ja,Wl as ka,Nt as la,ql as ma,Ti as na,Yl as oa,G as pa,Mi as qa,to as ra,nc as sa,oc as ta};
14
14
  /**
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Bf as X,Df as H,Ni as K}from"./chunk-6SBKU5ST.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-KWCGGQCW.js";import"./chunk-QHA3ZBRO.js";import"./chunk-Q7YBRGHD.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{i as S}from"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as B,i as G}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();d();d();import{homedir as ye}from"node:os";d();import{join as I}from"node:path";import{homedir as R}from"node:os";var l="0.5.2",ue="https://matilda.maincode.com/assets/computer-use",me="https://github.com/trycua/cua/releases/download";function E(e=process.platform,t=process.arch,o=l){let r=o;if(e==="darwin"){let n=`cua-driver-rs-${r}-${t==="arm64"?"darwin-arm64":"darwin-x86_64"}`;return{asset:`${n}.tar.gz`,extractDir:n,binaryRelPath:"CuaDriver.app/Contents/MacOS/cua-driver",hasApp:!0}}if(e==="linux"){if(t!=="x64")throw new Error(`Computer Use: unsupported Linux arch '${t}' (only x64).`);return{asset:`cua-driver-rs-${r}-linux-x86_64-binary.tar.gz`,extractDir:".",binaryRelPath:"cua-driver",hasApp:!1}}if(e==="win32"){let n=`cua-driver-rs-${r}-${t==="arm64"?"windows-arm64":"windows-x86_64"}`;return{asset:`${n}.zip`,extractDir:n,binaryRelPath:"cua-driver.exe",hasApp:!1}}throw new Error(`Computer Use: unsupported platform '${e}'.`)}function U(e,t=process.env,o=l){let r=[],i=t.MATILDA_COMPUTER_USE_DOWNLOAD_HOST;return i&&r.push(`${ge(i)}/cua-driver-rs/v${o}/${e}`),r.push(`${ue}/cua-driver-rs/v${o}/${e}`),r.push(`${me}/cua-driver-rs-v${o}/${e}`),r}function J(e=process.env,t=l){return U("checksums.txt",e,t)}var he="MATILDA_COMPUTER_USE_MAX_IMAGE_DIMENSION";function V(e){if(e===void 0||typeof e=="string"&&e.trim()==="")return;let t=typeof e=="number"?e:Number(e);if(!(!Number.isInteger(t)||t<0))return t}function Y(e,t=process.env){let o=V(t[he]);return o!==void 0?o:V(e)}function fe(e=R()){return I(e,".matilda","computer-use")}function N(e=R(),t=l){return I(fe(e),`cua-driver-rs-${t}`)}function u(e=R(),t=process.platform,o=process.arch,r=l){let i=E(t,o,r);return I(N(e,r),i.extractDir,i.binaryRelPath)}function h(e=l){return`cua-driver-rs@${e}`}function ge(e){return e.endsWith("/")?e.slice(0,-1):e}var f=class e{static singleton;binary;onProgress;maxImageDimension;client;startPromise;constructor(t){this.binary=t.binary,this.onProgress=t.onProgress??(()=>{}),this.maxImageDimension=t.maxImageDimension}setMaxImageDimension(t){this.maxImageDimension=t}static shared(){return e.singleton||(e.singleton=new e({binary:u(ye())})),e.singleton}static setSharedForTest(t){e.singleton=t}isStarted(){return this.client!==void 0}async start(t){if(!this.client)return this.startPromise?this.startPromise:(this.startPromise=this.doStart(t).finally(()=>{this.startPromise=void 0}),this.startPromise)}async doStart(t){let o=t??this.onProgress;o("Starting Computer Use driver...");let r=new H({command:this.binary,args:["mcp"],env:{...process.env}}),i=new X({name:"matilda-code-computer-use",version:"1.0.0"},{capabilities:{}});await i.connect(r),this.client=i,await this.applyRuntimeConfig(i,o)}async applyRuntimeConfig(t,o){if(this.maxImageDimension!==void 0)try{await t.callTool({name:"set_config",arguments:{max_image_dimension:this.maxImageDimension}})}catch(r){let i=r instanceof Error?r.message:String(r);o(`Computer Use: could not apply max_image_dimension=${this.maxImageDimension} (${i}); using driver default.`)}}async listTools(){if(!this.client)throw new Error("ComputerUseClient not started");return this.client.listTools()}async callTool(t,o){if(!this.client)throw new Error("ComputerUseClient not started");try{return await this.client.callTool({name:t,arguments:o})}catch(r){if(!Q(r))throw r;let i=r;for(let n=0;n<3;n++){if(await this.stop(),await this.start(),!this.client)throw new Error("ComputerUseClient reconnect failed");try{return await this.client.callTool({name:t,arguments:o})}catch(s){if(!Q(s))throw s;i=s,await new Promise(a=>setTimeout(a,1e3))}}throw i}}async stop(){let t=this.client;if(this.client=void 0,t)try{await t.close()}catch{}}};function Q(e){let t=e instanceof Error?e.message:String(e);return/connection closed|not connected|connection refused|daemon transport error|os error 61/i.test(t)}d();var M=["bring_to_front","check_for_update","check_permissions","click","double_click","drag","end_session","get_accessibility_tree","get_agent_cursor_state","get_config","get_cursor_position","get_recording_state","get_screen_size","get_window_state","hotkey","kill_app","launch_app","list_apps","list_windows","move_cursor","page","press_key","replay_trajectory","right_click","scroll","set_agent_cursor_enabled","set_agent_cursor_motion","set_agent_cursor_style","set_config","set_value","start_recording","start_session","stop_recording","type_text","zoom"],g={bring_to_front:{description:'Activate a window so subsequent input tools with `dispatch:"foreground"` land on it without a per-call SetForegroundWindow flash. **Windows-only:** on macOS this tool returns an error pointing to the platform-native `NSRunningApplication.activate` (which the macOS input tools don\'t need because CGEvent.postToPid reaches backgrounded windows). On Linux this tool also stubs out; use `wmctrl -a` or `xdotool windowactivate` if you need explicit activation.',parameterSchema:{additionalProperties:!1,properties:{pid:{type:"integer"},window_id:{type:"integer"}},required:["pid"],type:"object"}},check_for_update:{description:"Check whether a newer cua-driver-rs release is available on GitHub. Returns the current and latest versions, an `update_available` boolean, the install one-liner, and the release notes URL. Read-only \u2014 never installs. Mirror of `cua-driver check-update --json`.",parameterSchema:{additionalProperties:!1,properties:{},type:"object"}},check_permissions:{description:"Report TCC permission status for Accessibility and Screen Recording. By default also raises the system permission dialogs for any missing grants \u2014 Apple's request APIs are no-ops when the grant is already active, so this is safe to call repeatedly. Pass {\"prompt\": false} for a purely read-only status check.\n\nReturns: `accessibility` + `screen_recording` (booleans from the TCC preflight APIs), `screen_recording_capturable` (a live ScreenCaptureKit probe \u2014 if it disagrees with `screen_recording`, the preflight grant belongs to a different process), and `source` (which TCC identity the booleans reflect: the CuaDriver daemon vs the launching terminal/IDE). macOS attributes grants to the responsible process, so a standalone call from a terminal reports the terminal's grants, not the driver's.",parameterSchema:{additionalProperties:!1,properties:{prompt:{description:"Raise the system permission prompts for missing grants. Default true.",type:"boolean"}},type:"object"}},click:{description:`Left-click against a target pid. **Prefer \`element_index\` over pixel coordinates** \u2014 element_index works on backgrounded / minimized / hidden / off-Space windows, surfaces a stable handle that survives rebuilds, and tells you what you're clicking via the cached element's role + label. Reach for \`x, y\` only when the target is a canvas / video / WebGL / custom-drawn surface that doesn't appear in the AX tree.
3
+ import{Af as X,Cf as H,Pi as K}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{i as S}from"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as B,i as G}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();d();d();import{homedir as ye}from"node:os";d();import{join as I}from"node:path";import{homedir as R}from"node:os";var l="0.5.2",ue="https://matilda.maincode.com/assets/computer-use",me="https://github.com/trycua/cua/releases/download";function E(e=process.platform,t=process.arch,o=l){let r=o;if(e==="darwin"){let n=`cua-driver-rs-${r}-${t==="arm64"?"darwin-arm64":"darwin-x86_64"}`;return{asset:`${n}.tar.gz`,extractDir:n,binaryRelPath:"CuaDriver.app/Contents/MacOS/cua-driver",hasApp:!0}}if(e==="linux"){if(t!=="x64")throw new Error(`Computer Use: unsupported Linux arch '${t}' (only x64).`);return{asset:`cua-driver-rs-${r}-linux-x86_64-binary.tar.gz`,extractDir:".",binaryRelPath:"cua-driver",hasApp:!1}}if(e==="win32"){let n=`cua-driver-rs-${r}-${t==="arm64"?"windows-arm64":"windows-x86_64"}`;return{asset:`${n}.zip`,extractDir:n,binaryRelPath:"cua-driver.exe",hasApp:!1}}throw new Error(`Computer Use: unsupported platform '${e}'.`)}function U(e,t=process.env,o=l){let r=[],i=t.MATILDA_COMPUTER_USE_DOWNLOAD_HOST;return i&&r.push(`${ge(i)}/cua-driver-rs/v${o}/${e}`),r.push(`${ue}/cua-driver-rs/v${o}/${e}`),r.push(`${me}/cua-driver-rs-v${o}/${e}`),r}function J(e=process.env,t=l){return U("checksums.txt",e,t)}var he="MATILDA_COMPUTER_USE_MAX_IMAGE_DIMENSION";function V(e){if(e===void 0||typeof e=="string"&&e.trim()==="")return;let t=typeof e=="number"?e:Number(e);if(!(!Number.isInteger(t)||t<0))return t}function Y(e,t=process.env){let o=V(t[he]);return o!==void 0?o:V(e)}function fe(e=R()){return I(e,".matilda","computer-use")}function N(e=R(),t=l){return I(fe(e),`cua-driver-rs-${t}`)}function u(e=R(),t=process.platform,o=process.arch,r=l){let i=E(t,o,r);return I(N(e,r),i.extractDir,i.binaryRelPath)}function h(e=l){return`cua-driver-rs@${e}`}function ge(e){return e.endsWith("/")?e.slice(0,-1):e}var f=class e{static singleton;binary;onProgress;maxImageDimension;client;startPromise;constructor(t){this.binary=t.binary,this.onProgress=t.onProgress??(()=>{}),this.maxImageDimension=t.maxImageDimension}setMaxImageDimension(t){this.maxImageDimension=t}static shared(){return e.singleton||(e.singleton=new e({binary:u(ye())})),e.singleton}static setSharedForTest(t){e.singleton=t}isStarted(){return this.client!==void 0}async start(t){if(!this.client)return this.startPromise?this.startPromise:(this.startPromise=this.doStart(t).finally(()=>{this.startPromise=void 0}),this.startPromise)}async doStart(t){let o=t??this.onProgress;o("Starting Computer Use driver...");let r=new H({command:this.binary,args:["mcp"],env:{...process.env}}),i=new X({name:"matilda-code-computer-use",version:"1.0.0"},{capabilities:{}});await i.connect(r),this.client=i,await this.applyRuntimeConfig(i,o)}async applyRuntimeConfig(t,o){if(this.maxImageDimension!==void 0)try{await t.callTool({name:"set_config",arguments:{max_image_dimension:this.maxImageDimension}})}catch(r){let i=r instanceof Error?r.message:String(r);o(`Computer Use: could not apply max_image_dimension=${this.maxImageDimension} (${i}); using driver default.`)}}async listTools(){if(!this.client)throw new Error("ComputerUseClient not started");return this.client.listTools()}async callTool(t,o){if(!this.client)throw new Error("ComputerUseClient not started");try{return await this.client.callTool({name:t,arguments:o})}catch(r){if(!Q(r))throw r;let i=r;for(let n=0;n<3;n++){if(await this.stop(),await this.start(),!this.client)throw new Error("ComputerUseClient reconnect failed");try{return await this.client.callTool({name:t,arguments:o})}catch(s){if(!Q(s))throw s;i=s,await new Promise(a=>setTimeout(a,1e3))}}throw i}}async stop(){let t=this.client;if(this.client=void 0,t)try{await t.close()}catch{}}};function Q(e){let t=e instanceof Error?e.message:String(e);return/connection closed|not connected|connection refused|daemon transport error|os error 61/i.test(t)}d();var M=["bring_to_front","check_for_update","check_permissions","click","double_click","drag","end_session","get_accessibility_tree","get_agent_cursor_state","get_config","get_cursor_position","get_recording_state","get_screen_size","get_window_state","hotkey","kill_app","launch_app","list_apps","list_windows","move_cursor","page","press_key","replay_trajectory","right_click","scroll","set_agent_cursor_enabled","set_agent_cursor_motion","set_agent_cursor_style","set_config","set_value","start_recording","start_session","stop_recording","type_text","zoom"],g={bring_to_front:{description:'Activate a window so subsequent input tools with `dispatch:"foreground"` land on it without a per-call SetForegroundWindow flash. **Windows-only:** on macOS this tool returns an error pointing to the platform-native `NSRunningApplication.activate` (which the macOS input tools don\'t need because CGEvent.postToPid reaches backgrounded windows). On Linux this tool also stubs out; use `wmctrl -a` or `xdotool windowactivate` if you need explicit activation.',parameterSchema:{additionalProperties:!1,properties:{pid:{type:"integer"},window_id:{type:"integer"}},required:["pid"],type:"object"}},check_for_update:{description:"Check whether a newer cua-driver-rs release is available on GitHub. Returns the current and latest versions, an `update_available` boolean, the install one-liner, and the release notes URL. Read-only \u2014 never installs. Mirror of `cua-driver check-update --json`.",parameterSchema:{additionalProperties:!1,properties:{},type:"object"}},check_permissions:{description:"Report TCC permission status for Accessibility and Screen Recording. By default also raises the system permission dialogs for any missing grants \u2014 Apple's request APIs are no-ops when the grant is already active, so this is safe to call repeatedly. Pass {\"prompt\": false} for a purely read-only status check.\n\nReturns: `accessibility` + `screen_recording` (booleans from the TCC preflight APIs), `screen_recording_capturable` (a live ScreenCaptureKit probe \u2014 if it disagrees with `screen_recording`, the preflight grant belongs to a different process), and `source` (which TCC identity the booleans reflect: the CuaDriver daemon vs the launching terminal/IDE). macOS attributes grants to the responsible process, so a standalone call from a terminal reports the terminal's grants, not the driver's.",parameterSchema:{additionalProperties:!1,properties:{prompt:{description:"Raise the system permission prompts for missing grants. Default true.",type:"boolean"}},type:"object"}},click:{description:`Left-click against a target pid. **Prefer \`element_index\` over pixel coordinates** \u2014 element_index works on backgrounded / minimized / hidden / off-Space windows, surfaces a stable handle that survives rebuilds, and tells you what you're clicking via the cached element's role + label. Reach for \`x, y\` only when the target is a canvas / video / WebGL / custom-drawn surface that doesn't appear in the AX tree.
4
4
 
5
5
  Two addressing modes:
6
6
 
@@ -0,0 +1,3 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{c as a,d as b,e as c}from"./chunk-H6WMNUW2.js";import"./chunk-GWGQRU36.js";import"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{a as collectContextData,c as contextCommand,b as formatContextUsageText};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as p,c as f}from"./chunk-TXMXCR7D.js";import{a as y}from"./chunk-YULUB745.js";import{a as n}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as m,i as c,p as d,q as h}from"./chunk-6B5BDE7S.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as u}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";u();var i=class extends m{constructor(e,t){super(t);this.config=e}getDescription(){return`${this.params.cron}: ${this.params.prompt}`}async getDefaultPermission(){return"ask"}async execute(){let e=this.config.getCronScheduler(),t=this.params.recurring!==!1,s=this.params.durable===!0;try{p(this.params.cron),f(this.params.cron,new Date);let r=s?await e.createDurable(this.params.cron,this.params.prompt,t):e.create(this.params.cron,this.params.prompt,t),o=y(r.cronExpr),w=`Scheduled ${r.id} (${o})${s?" [durable]":""}`,l=s?`Persisted to ${n}`:"Session-only (not written to disk, dies when Matilda exits)";return{llmContent:t?`Scheduled recurring job ${r.id} (${r.cronExpr}). ${l}. Auto-expires after 7 days. Use CronDelete to cancel sooner.`:`Scheduled one-shot task ${r.id} (${r.cronExpr}). ${l}. It will fire once then auto-delete.`,returnDisplay:w}}catch(r){let o=r instanceof Error?r.message:String(r);return{llmContent:`Error creating cron job: ${o}`,returnDisplay:o,error:{message:o}}}}},g=class a extends c{constructor(e){super(a.Name,h.CRON_CREATE,`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.
3
+ import{a as p,c as f}from"./chunk-TXMXCR7D.js";import{a as y}from"./chunk-YULUB745.js";import{a as n}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as m,i as c,p as d,q as h}from"./chunk-PIFQEMZZ.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as u}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";u();var i=class extends m{constructor(e,t){super(t);this.config=e}getDescription(){return`${this.params.cron}: ${this.params.prompt}`}async getDefaultPermission(){return"ask"}async execute(){let e=this.config.getCronScheduler(),t=this.params.recurring!==!1,s=this.params.durable===!0;try{p(this.params.cron),f(this.params.cron,new Date);let r=s?await e.createDurable(this.params.cron,this.params.prompt,t):e.create(this.params.cron,this.params.prompt,t),o=y(r.cronExpr),w=`Scheduled ${r.id} (${o})${s?" [durable]":""}`,l=s?`Persisted to ${n}`:"Session-only (not written to disk, dies when Matilda exits)";return{llmContent:t?`Scheduled recurring job ${r.id} (${r.cronExpr}). ${l}. Auto-expires after 7 days. Use CronDelete to cancel sooner.`:`Scheduled one-shot task ${r.id} (${r.cronExpr}). ${l}. It will fire once then auto-delete.`,returnDisplay:w}}catch(r){let o=r instanceof Error?r.message:String(r);return{llmContent:`Error creating cron job: ${o}`,returnDisplay:o,error:{message:o}}}}},g=class a extends c{constructor(e){super(a.Name,h.CRON_CREATE,`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.
4
4
 
5
5
  Uses standard 5-field cron in the user's local timezone: minute hour day-of-month month day-of-week. "0 9 * * *" means 9am local \u2014 no timezone conversion needed.
6
6
 
@@ -1,3 +1,3 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as d,f as u}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as l,i as c,p as m,q as p}from"./chunk-6B5BDE7S.js";import"./chunk-EQEQPZLQ.js";import{d as n}from"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as i}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";i();var s=class extends l{constructor(r,o){super(o);this.config=r}getDescription(){return this.params.id}async execute(){let r=this.config.getCronScheduler(),o;try{o=await r.delete(this.params.id),o||(o=await u(this.config.getProjectRoot(),[this.params.id])>0)}catch(e){let t=`Failed to cancel job ${this.params.id}: ${n(e)}`;return{llmContent:t,returnDisplay:t,error:{message:t}}}if(o){let e=`Cancelled job ${this.params.id}.`,t=`Cancelled ${this.params.id}`;return{llmContent:e,returnDisplay:t}}else{let e=`Job ${this.params.id} not found.`;return{llmContent:e,returnDisplay:e,error:{message:e}}}}},f=class a extends c{constructor(r){super(a.Name,p.CRON_DELETE,`Cancel a cron job previously scheduled with CronCreate. Removes it from the in-memory session store or from ${d} (durable jobs).`,"other",{type:"object",properties:{id:{type:"string",description:"Job ID returned by CronCreate."}},required:["id"],additionalProperties:!1},!0,!1,!0,!1,"cron delete cancel remove");this.config=r}static Name=m.CRON_DELETE;createInvocation(r){return new s(this.config,r)}};export{f as CronDeleteTool};
3
+ import{a as d,f as u}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as l,i as c,p as m,q as p}from"./chunk-PIFQEMZZ.js";import"./chunk-EQEQPZLQ.js";import{d as n}from"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as i}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";i();var s=class extends l{constructor(r,o){super(o);this.config=r}getDescription(){return this.params.id}async execute(){let r=this.config.getCronScheduler(),o;try{o=await r.delete(this.params.id),o||(o=await u(this.config.getProjectRoot(),[this.params.id])>0)}catch(e){let t=`Failed to cancel job ${this.params.id}: ${n(e)}`;return{llmContent:t,returnDisplay:t,error:{message:t}}}if(o){let e=`Cancelled job ${this.params.id}.`,t=`Cancelled ${this.params.id}`;return{llmContent:e,returnDisplay:t}}else{let e=`Job ${this.params.id} not found.`;return{llmContent:e,returnDisplay:e,error:{message:e}}}}},f=class a extends c{constructor(r){super(a.Name,p.CRON_DELETE,`Cancel a cron job previously scheduled with CronCreate. Removes it from the in-memory session store or from ${d} (durable jobs).`,"other",{type:"object",properties:{id:{type:"string",description:"Job ID returned by CronCreate."}},required:["id"],additionalProperties:!1},!0,!1,!0,!1,"cron delete cancel remove");this.config=r}static Name=m.CRON_DELETE;createInvocation(r){return new s(this.config,r)}};export{f as CronDeleteTool};
@@ -1,5 +1,5 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as m}from"./chunk-YULUB745.js";import{a as d,c as g}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as l,i as c,p,q as u}from"./chunk-6B5BDE7S.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as a}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";a();var s=class extends l{constructor(e,t){super(t);this.config=e}getDescription(){return""}async execute(){let e=this.config.getCronScheduler(),t;try{t=await g(this.config.getProjectRoot())}catch(r){let o=r instanceof Error?r.message:String(r);return{llmContent:`Error listing cron jobs: ${o}`,returnDisplay:o,error:{message:o}}}let n=[...t.map(r=>({id:r.id,cron:r.cron,prompt:r.prompt,recurring:r.recurring,durable:!0})),...e.list().filter(r=>!r.durable).map(r=>({id:r.id,cron:r.cronExpr,prompt:r.prompt,recurring:r.recurring,durable:!1}))];if(n.length===0){let r="No active cron jobs.";return{llmContent:r,returnDisplay:r}}let y=n.map(r=>{let o=r.recurring?"recurring":"one-shot",h=r.durable?"durable":"session-only";return`${r.id} \u2014 ${r.cron} (${o}) [${h}]: ${r.prompt}`}).join(`
3
+ import{a as m}from"./chunk-YULUB745.js";import{a as d,c as g}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as l,i as c,p,q as u}from"./chunk-PIFQEMZZ.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as a}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";a();var s=class extends l{constructor(e,t){super(t);this.config=e}getDescription(){return""}async execute(){let e=this.config.getCronScheduler(),t;try{t=await g(this.config.getProjectRoot())}catch(r){let o=r instanceof Error?r.message:String(r);return{llmContent:`Error listing cron jobs: ${o}`,returnDisplay:o,error:{message:o}}}let n=[...t.map(r=>({id:r.id,cron:r.cron,prompt:r.prompt,recurring:r.recurring,durable:!0})),...e.list().filter(r=>!r.durable).map(r=>({id:r.id,cron:r.cronExpr,prompt:r.prompt,recurring:r.recurring,durable:!1}))];if(n.length===0){let r="No active cron jobs.";return{llmContent:r,returnDisplay:r}}let y=n.map(r=>{let o=r.recurring?"recurring":"one-shot",h=r.durable?"durable":"session-only";return`${r.id} \u2014 ${r.cron} (${o}) [${h}]: ${r.prompt}`}).join(`
4
4
  `),T=n.map(r=>`${r.id} ${m(r.cron)} [${r.durable?"durable":"session-only"}]`).join(`
5
5
  `);return{llmContent:y,returnDisplay:T}}},f=class i extends c{constructor(e){super(i.Name,u.CRON_LIST,`List all cron jobs scheduled via CronCreate, both session-only and durable (${d}).`,"other",{type:"object",properties:{},additionalProperties:!1},!0,!1,!0,!1,"cron list scheduled jobs");this.config=e}static Name=p.CRON_LIST;createInvocation(e){return new s(this.config,e)}};export{f as CronListTool};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as Nh,b as Kh,c as Jh}from"./chunk-WZ75OGYY.js";import{a as Vh}from"./chunk-PA6532AY.js";import"./chunk-XMZIY7XX.js";import{f as js}from"./chunk-3HUM74NZ.js";import"./chunk-JSFA3NEP.js";import"./chunk-TZIDSCTF.js";import{a as Ch,b as Ah,c as Dh,d as Mh,e as Bh,f as Lh,g as Wh,h as Uh}from"./chunk-U347OO7S.js";import{i as Hh}from"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import{a as __matilda_dirname,b as N}from"./chunk-GZPNIYVZ.js";import{a as Y,d as Xt,f as Rh}from"./chunk-OWGSC52X.js";var zo=Xt((qf,$o)=>{"use strict";N();var Qh=Nh(),Xh=Y("crypto"),Yh=Y("url"),Zh=Kh(),td=Y("http"),ed=Y("https"),ad=Y("http2"),rd=Y("util"),id=Jh(),sd=Y("zlib"),io=Y("stream"),od=Y("events");function ct(y){return y&&typeof y=="object"&&"default"in y?y:{default:y}}var so=ct(Qh),nd=ct(Xh),hd=ct(Yh),dd=ct(Zh),ld=ct(td),cd=ct(ed),oo=ct(ad),nr=ct(rd),pd=ct(id),zt=ct(sd),gt=ct(io);function no(y,e){return function(){return y.apply(e,arguments)}}var{toString:md}=Object.prototype,{getPrototypeOf:hr}=Object,{iterator:Ve,toStringTag:ho}=Symbol,Qe=(y=>e=>{let a=md.call(e);return y[a]||(y[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),pt=y=>(y=y.toLowerCase(),e=>Qe(e)===y),Xe=y=>e=>typeof e===y,{isArray:re}=Array,Zt=Xe("undefined");function fe(y){return y!==null&&!Zt(y)&&y.constructor!==null&&!Zt(y.constructor)&&rt(y.constructor.isBuffer)&&y.constructor.isBuffer(y)}var lo=pt("ArrayBuffer");function ud(y){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(y):e=y&&y.buffer&&lo(y.buffer),e}var yd=Xe("string"),rt=Xe("function"),co=Xe("number"),ve=y=>y!==null&&typeof y=="object",gd=y=>y===!0||y===!1,Le=y=>{if(Qe(y)!=="object")return!1;let e=hr(y);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(ho in y)&&!(Ve in y)},fd=y=>{if(!ve(y)||fe(y))return!1;try{return Object.keys(y).length===0&&Object.getPrototypeOf(y)===Object.prototype}catch{return!1}},vd=pt("Date"),_d=pt("File"),bd=y=>!!(y&&typeof y.uri<"u"),Sd=y=>y&&typeof y.getParts<"u",Id=pt("Blob"),wd=pt("FileList"),kd=y=>ve(y)&&rt(y.pipe);function Td(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof globalThis<"u"?globalThis:{}}var Gs=Td(),Rs=typeof Gs.FormData<"u"?Gs.FormData:void 0,Pd=y=>{let e;return y&&(Rs&&y instanceof Rs||rt(y.append)&&((e=Qe(y))==="formdata"||e==="object"&&rt(y.toString)&&y.toString()==="[object FormData]"))},qd=pt("URLSearchParams"),[Fd,$d,zd,Ed]=["ReadableStream","Request","Response","Headers"].map(pt),Od=y=>y.trim?y.trim():y.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _e(y,e,{allOwnKeys:a=!1}={}){if(y===null||typeof y>"u")return;let r,s;if(typeof y!="object"&&(y=[y]),re(y))for(r=0,s=y.length;r<s;r++)e.call(null,y[r],r,y);else{if(fe(y))return;let i=a?Object.getOwnPropertyNames(y):Object.keys(y),o=i.length,t;for(r=0;r<o;r++)t=i[r],e.call(null,y[t],t,y)}}function po(y,e){if(fe(y))return null;e=e.toLowerCase();let a=Object.keys(y),r=a.length,s;for(;r-- >0;)if(s=a[r],e===s.toLowerCase())return s;return null}var Ct=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:globalThis,mo=y=>!Zt(y)&&y!==Ct;function Qa(){let{caseless:y,skipUndefined:e}=mo(this)&&this||{},a={},r=(s,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;let o=y&&po(a,i)||i;Le(a[o])&&Le(s)?a[o]=Qa(a[o],s):Le(s)?a[o]=Qa({},s):re(s)?a[o]=s.slice():(!e||!Zt(s))&&(a[o]=s)};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&_e(arguments[s],r);return a}var xd=(y,e,a,{allOwnKeys:r}={})=>(_e(e,(s,i)=>{a&&rt(s)?Object.defineProperty(y,i,{value:no(s,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(y,i,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),y),jd=y=>(y.charCodeAt(0)===65279&&(y=y.slice(1)),y),Gd=(y,e,a,r)=>{y.prototype=Object.create(e.prototype,r),Object.defineProperty(y.prototype,"constructor",{value:y,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(y,"super",{value:e.prototype}),a&&Object.assign(y.prototype,a)},Rd=(y,e,a,r)=>{let s,i,o,t={};if(e=e||{},y==null)return e;do{for(s=Object.getOwnPropertyNames(y),i=s.length;i-- >0;)o=s[i],(!r||r(o,y,e))&&!t[o]&&(e[o]=y[o],t[o]=!0);y=a!==!1&&hr(y)}while(y&&(!a||a(y,e))&&y!==Object.prototype);return e},Cd=(y,e,a)=>{y=String(y),(a===void 0||a>y.length)&&(a=y.length),a-=e.length;let r=y.indexOf(e,a);return r!==-1&&r===a},Ad=y=>{if(!y)return null;if(re(y))return y;let e=y.length;if(!co(e))return null;let a=new Array(e);for(;e-- >0;)a[e]=y[e];return a},Dd=(y=>e=>y&&e instanceof y)(typeof Uint8Array<"u"&&hr(Uint8Array)),Md=(y,e)=>{let r=(y&&y[Ve]).call(y),s;for(;(s=r.next())&&!s.done;){let i=s.value;e.call(y,i[0],i[1])}},Bd=(y,e)=>{let a,r=[];for(;(a=y.exec(e))!==null;)r.push(a);return r},Ld=pt("HTMLFormElement"),Wd=y=>y.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,r,s){return r.toUpperCase()+s}),Cs=(({hasOwnProperty:y})=>(e,a)=>y.call(e,a))(Object.prototype),Ud=pt("RegExp"),uo=(y,e)=>{let a=Object.getOwnPropertyDescriptors(y),r={};_e(a,(s,i)=>{let o;(o=e(s,i,y))!==!1&&(r[i]=o||s)}),Object.defineProperties(y,r)},Hd=y=>{uo(y,(e,a)=>{if(rt(y)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;let r=y[a];if(rt(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},Nd=(y,e)=>{let a={},r=s=>{s.forEach(i=>{a[i]=!0})};return re(y)?r(y):r(String(y).split(e)),a},Kd=()=>{},Jd=(y,e)=>y!=null&&Number.isFinite(y=+y)?y:e;function Vd(y){return!!(y&&rt(y.append)&&y[ho]==="FormData"&&y[Ve])}var Qd=y=>{let e=new Array(10),a=(r,s)=>{if(ve(r)){if(e.indexOf(r)>=0)return;if(fe(r))return r;if(!("toJSON"in r)){e[s]=r;let i=re(r)?[]:{};return _e(r,(o,t)=>{let f=a(o,s+1);!Zt(f)&&(i[t]=f)}),e[s]=void 0,i}}return r};return a(y,0)},Xd=pt("AsyncFunction"),Yd=y=>y&&(ve(y)||rt(y))&&rt(y.then)&&rt(y.catch),yo=((y,e)=>y?setImmediate:e?((a,r)=>(Ct.addEventListener("message",({source:s,data:i})=>{s===Ct&&i===a&&r.length&&r.shift()()},!1),s=>{r.push(s),Ct.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",rt(Ct.postMessage)),Zd=typeof queueMicrotask<"u"?queueMicrotask.bind(Ct):typeof process<"u"&&process.nextTick||yo,tl=y=>y!=null&&rt(y[Ve]),q={isArray:re,isArrayBuffer:lo,isBuffer:fe,isFormData:Pd,isArrayBufferView:ud,isString:yd,isNumber:co,isBoolean:gd,isObject:ve,isPlainObject:Le,isEmptyObject:fd,isReadableStream:Fd,isRequest:$d,isResponse:zd,isHeaders:Ed,isUndefined:Zt,isDate:vd,isFile:_d,isReactNativeBlob:bd,isReactNative:Sd,isBlob:Id,isRegExp:Ud,isFunction:rt,isStream:kd,isURLSearchParams:qd,isTypedArray:Dd,isFileList:wd,forEach:_e,merge:Qa,extend:xd,trim:Od,stripBOM:jd,inherits:Gd,toFlatObject:Rd,kindOf:Qe,kindOfTest:pt,endsWith:Cd,toArray:Ad,forEachEntry:Md,matchAll:Bd,isHTMLForm:Ld,hasOwnProperty:Cs,hasOwnProp:Cs,reduceDescriptors:uo,freezeMethods:Hd,toObjectSet:Nd,toCamelCase:Wd,noop:Kd,toFiniteNumber:Jd,findKey:po,global:Ct,isContextDefined:mo,isSpecCompliantForm:Vd,toJSONObject:Qd,isAsyncFn:Xd,isThenable:Yd,setImmediate:yo,asap:Zd,isIterable:tl},tt=class y extends Error{static from(e,a,r,s,i,o){let t=new y(e.message,a||e.code,r,s,i);return t.cause=e,t.name=e.name,e.status!=null&&t.status==null&&(t.status=e.status),o&&Object.assign(t,o),t}constructor(e,a,r,s,i){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,a&&(this.code=a),r&&(this.config=r),s&&(this.request=s),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:q.toJSONObject(this.config),code:this.code,status:this.status}}};tt.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";tt.ERR_BAD_OPTION="ERR_BAD_OPTION";tt.ECONNABORTED="ECONNABORTED";tt.ETIMEDOUT="ETIMEDOUT";tt.ERR_NETWORK="ERR_NETWORK";tt.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";tt.ERR_DEPRECATED="ERR_DEPRECATED";tt.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";tt.ERR_BAD_REQUEST="ERR_BAD_REQUEST";tt.ERR_CANCELED="ERR_CANCELED";tt.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";tt.ERR_INVALID_URL="ERR_INVALID_URL";var z=tt;function Xa(y){return q.isPlainObject(y)||q.isArray(y)}function go(y){return q.endsWith(y,"[]")?y.slice(0,-2):y}function Ua(y,e,a){return y?y.concat(e).map(function(s,i){return s=go(s),!a&&i?"["+s+"]":s}).join(a?".":""):e}function el(y){return q.isArray(y)&&!y.some(Xa)}var al=q.toFlatObject(q,{},null,function(e){return/^is[A-Z]/.test(e)});function Ye(y,e,a){if(!q.isObject(y))throw new TypeError("target must be an object");e=e||new(so.default||FormData),a=q.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,b){return!q.isUndefined(b[S])});let r=a.metaTokens,s=a.visitor||u,i=a.dots,o=a.indexes,f=(a.Blob||typeof Blob<"u"&&Blob)&&q.isSpecCompliantForm(e);if(!q.isFunction(s))throw new TypeError("visitor must be a function");function p(_){if(_===null)return"";if(q.isDate(_))return _.toISOString();if(q.isBoolean(_))return _.toString();if(!f&&q.isBlob(_))throw new z("Blob is not supported. Use a Buffer instead.");return q.isArrayBuffer(_)||q.isTypedArray(_)?f&&typeof Blob=="function"?new Blob([_]):Buffer.from(_):_}function u(_,S,b){let I=_;if(q.isReactNative(e)&&q.isReactNativeBlob(_))return e.append(Ua(b,S,i),p(_)),!1;if(_&&!b&&typeof _=="object"){if(q.endsWith(S,"{}"))S=r?S:S.slice(0,-2),_=JSON.stringify(_);else if(q.isArray(_)&&el(_)||(q.isFileList(_)||q.endsWith(S,"[]"))&&(I=q.toArray(_)))return S=go(S),I.forEach(function(F,R){!(q.isUndefined(F)||F===null)&&e.append(o===!0?Ua([S],R,i):o===null?S:S+"[]",p(F))}),!1}return Xa(_)?!0:(e.append(Ua(b,S,i),p(_)),!1)}let c=[],m=Object.assign(al,{defaultVisitor:u,convertValue:p,isVisitable:Xa});function g(_,S){if(!q.isUndefined(_)){if(c.indexOf(_)!==-1)throw Error("Circular reference detected in "+S.join("."));c.push(_),q.forEach(_,function(I,$){(!(q.isUndefined(I)||I===null)&&s.call(e,I,q.isString($)?$.trim():$,S,m))===!0&&g(I,S?S.concat($):[$])}),c.pop()}}if(!q.isObject(y))throw new TypeError("data must be an object");return g(y),e}function As(y){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(y).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function fo(y,e){this._pairs=[],y&&Ye(y,this,e)}var vo=fo.prototype;vo.append=function(e,a){this._pairs.push([e,a])};vo.toString=function(e){let a=e?function(r){return e.call(this,r,As)}:As;return this._pairs.map(function(s){return a(s[0])+"="+a(s[1])},"").join("&")};function rl(y){return encodeURIComponent(y).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function dr(y,e,a){if(!e)return y;let r=a&&a.encode||rl,s=q.isFunction(a)?{serialize:a}:a,i=s&&s.serialize,o;if(i?o=i(e,s):o=q.isURLSearchParams(e)?e.toString():new fo(e,s).toString(r),o){let t=y.indexOf("#");t!==-1&&(y=y.slice(0,t)),y+=(y.indexOf("?")===-1?"?":"&")+o}return y}var Ya=class{constructor(){this.handlers=[]}use(e,a,r){return this.handlers.push({fulfilled:e,rejected:a,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){q.forEach(this.handlers,function(r){r!==null&&e(r)})}},Ds=Ya,Ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},il=hd.default.URLSearchParams,Ha="abcdefghijklmnopqrstuvwxyz",Ms="0123456789",_o={DIGIT:Ms,ALPHA:Ha,ALPHA_DIGIT:Ha+Ha.toUpperCase()+Ms},sl=(y=16,e=_o.ALPHA_DIGIT)=>{let a="",{length:r}=e,s=new Uint32Array(y);nd.default.randomFillSync(s);for(let i=0;i<y;i++)a+=e[s[i]%r];return a},ol={isNode:!0,classes:{URLSearchParams:il,FormData:so.default,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:_o,generateString:sl,protocols:["http","https","file","data"]},lr=typeof window<"u"&&typeof document<"u",Za=typeof navigator=="object"&&navigator||void 0,nl=lr&&(!Za||["ReactNative","NativeScript","NS"].indexOf(Za.product)<0),hl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",dl=lr&&window.location.href||"http://localhost",ll=Object.freeze({__proto__:null,hasBrowserEnv:lr,hasStandardBrowserWebWorkerEnv:hl,hasStandardBrowserEnv:nl,navigator:Za,origin:dl}),U={...ll,...ol};function cl(y,e){return Ye(y,new U.classes.URLSearchParams,{visitor:function(a,r,s,i){return U.isNode&&q.isBuffer(a)?(this.append(r,a.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...e})}function pl(y){return q.matchAll(/\w+|\[(\w*)]/g,y).map(e=>e[0]==="[]"?"":e[1]||e[0])}function ml(y){let e={},a=Object.keys(y),r,s=a.length,i;for(r=0;r<s;r++)i=a[r],e[i]=y[i];return e}function bo(y){function e(a,r,s,i){let o=a[i++];if(o==="__proto__")return!0;let t=Number.isFinite(+o),f=i>=a.length;return o=!o&&q.isArray(s)?s.length:o,f?(q.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!t):((!s[o]||!q.isObject(s[o]))&&(s[o]=[]),e(a,r,s[o],i)&&q.isArray(s[o])&&(s[o]=ml(s[o])),!t)}if(q.isFormData(y)&&q.isFunction(y.entries)){let a={};return q.forEachEntry(y,(r,s)=>{e(pl(r),s,a,0)}),a}return null}function ul(y,e,a){if(q.isString(y))try{return(e||JSON.parse)(y),q.trim(y)}catch(r){if(r.name!=="SyntaxError")throw r}return(a||JSON.stringify)(y)}var cr={transitional:Ze,adapter:["xhr","http","fetch"],transformRequest:[function(e,a){let r=a.getContentType()||"",s=r.indexOf("application/json")>-1,i=q.isObject(e);if(i&&q.isHTMLForm(e)&&(e=new FormData(e)),q.isFormData(e))return s?JSON.stringify(bo(e)):e;if(q.isArrayBuffer(e)||q.isBuffer(e)||q.isStream(e)||q.isFile(e)||q.isBlob(e)||q.isReadableStream(e))return e;if(q.isArrayBufferView(e))return e.buffer;if(q.isURLSearchParams(e))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let t;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return cl(e,this.formSerializer).toString();if((t=q.isFileList(e))||r.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return Ye(t?{"files[]":e}:e,f&&new f,this.formSerializer)}}return i||s?(a.setContentType("application/json",!1),ul(e)):e}],transformResponse:[function(e){let a=this.transitional||cr.transitional,r=a&&a.forcedJSONParsing,s=this.responseType==="json";if(q.isResponse(e)||q.isReadableStream(e))return e;if(e&&q.isString(e)&&(r&&!this.responseType||s)){let o=!(a&&a.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(t){if(o)throw t.name==="SyntaxError"?z.from(t,z.ERR_BAD_RESPONSE,this,null,this.response):t}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:U.classes.FormData,Blob:U.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};q.forEach(["delete","get","head","post","put","patch"],y=>{cr.headers[y]={}});var pr=cr,yl=q.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gl=y=>{let e={},a,r,s;return y&&y.split(`
3
+ import{a as Vh}from"./chunk-PA6532AY.js";import{a as Nh,b as Kh,c as Jh}from"./chunk-WZ75OGYY.js";import"./chunk-XMZIY7XX.js";import{f as js}from"./chunk-3HUM74NZ.js";import"./chunk-JSFA3NEP.js";import"./chunk-TZIDSCTF.js";import{a as Ch,b as Ah,c as Dh,d as Mh,e as Bh,f as Lh,g as Wh,h as Uh}from"./chunk-U347OO7S.js";import{i as Hh}from"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import{a as __matilda_dirname,b as N}from"./chunk-GZPNIYVZ.js";import{a as Y,d as Xt,f as Rh}from"./chunk-OWGSC52X.js";var zo=Xt((qf,$o)=>{"use strict";N();var Qh=Nh(),Xh=Y("crypto"),Yh=Y("url"),Zh=Kh(),td=Y("http"),ed=Y("https"),ad=Y("http2"),rd=Y("util"),id=Jh(),sd=Y("zlib"),io=Y("stream"),od=Y("events");function ct(y){return y&&typeof y=="object"&&"default"in y?y:{default:y}}var so=ct(Qh),nd=ct(Xh),hd=ct(Yh),dd=ct(Zh),ld=ct(td),cd=ct(ed),oo=ct(ad),nr=ct(rd),pd=ct(id),zt=ct(sd),gt=ct(io);function no(y,e){return function(){return y.apply(e,arguments)}}var{toString:md}=Object.prototype,{getPrototypeOf:hr}=Object,{iterator:Ve,toStringTag:ho}=Symbol,Qe=(y=>e=>{let a=md.call(e);return y[a]||(y[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),pt=y=>(y=y.toLowerCase(),e=>Qe(e)===y),Xe=y=>e=>typeof e===y,{isArray:re}=Array,Zt=Xe("undefined");function fe(y){return y!==null&&!Zt(y)&&y.constructor!==null&&!Zt(y.constructor)&&rt(y.constructor.isBuffer)&&y.constructor.isBuffer(y)}var lo=pt("ArrayBuffer");function ud(y){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(y):e=y&&y.buffer&&lo(y.buffer),e}var yd=Xe("string"),rt=Xe("function"),co=Xe("number"),ve=y=>y!==null&&typeof y=="object",gd=y=>y===!0||y===!1,Le=y=>{if(Qe(y)!=="object")return!1;let e=hr(y);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(ho in y)&&!(Ve in y)},fd=y=>{if(!ve(y)||fe(y))return!1;try{return Object.keys(y).length===0&&Object.getPrototypeOf(y)===Object.prototype}catch{return!1}},vd=pt("Date"),_d=pt("File"),bd=y=>!!(y&&typeof y.uri<"u"),Sd=y=>y&&typeof y.getParts<"u",Id=pt("Blob"),wd=pt("FileList"),kd=y=>ve(y)&&rt(y.pipe);function Td(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof globalThis<"u"?globalThis:{}}var Gs=Td(),Rs=typeof Gs.FormData<"u"?Gs.FormData:void 0,Pd=y=>{let e;return y&&(Rs&&y instanceof Rs||rt(y.append)&&((e=Qe(y))==="formdata"||e==="object"&&rt(y.toString)&&y.toString()==="[object FormData]"))},qd=pt("URLSearchParams"),[Fd,$d,zd,Ed]=["ReadableStream","Request","Response","Headers"].map(pt),Od=y=>y.trim?y.trim():y.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _e(y,e,{allOwnKeys:a=!1}={}){if(y===null||typeof y>"u")return;let r,s;if(typeof y!="object"&&(y=[y]),re(y))for(r=0,s=y.length;r<s;r++)e.call(null,y[r],r,y);else{if(fe(y))return;let i=a?Object.getOwnPropertyNames(y):Object.keys(y),o=i.length,t;for(r=0;r<o;r++)t=i[r],e.call(null,y[t],t,y)}}function po(y,e){if(fe(y))return null;e=e.toLowerCase();let a=Object.keys(y),r=a.length,s;for(;r-- >0;)if(s=a[r],e===s.toLowerCase())return s;return null}var Ct=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:globalThis,mo=y=>!Zt(y)&&y!==Ct;function Qa(){let{caseless:y,skipUndefined:e}=mo(this)&&this||{},a={},r=(s,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;let o=y&&po(a,i)||i;Le(a[o])&&Le(s)?a[o]=Qa(a[o],s):Le(s)?a[o]=Qa({},s):re(s)?a[o]=s.slice():(!e||!Zt(s))&&(a[o]=s)};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&_e(arguments[s],r);return a}var xd=(y,e,a,{allOwnKeys:r}={})=>(_e(e,(s,i)=>{a&&rt(s)?Object.defineProperty(y,i,{value:no(s,a),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(y,i,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),y),jd=y=>(y.charCodeAt(0)===65279&&(y=y.slice(1)),y),Gd=(y,e,a,r)=>{y.prototype=Object.create(e.prototype,r),Object.defineProperty(y.prototype,"constructor",{value:y,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(y,"super",{value:e.prototype}),a&&Object.assign(y.prototype,a)},Rd=(y,e,a,r)=>{let s,i,o,t={};if(e=e||{},y==null)return e;do{for(s=Object.getOwnPropertyNames(y),i=s.length;i-- >0;)o=s[i],(!r||r(o,y,e))&&!t[o]&&(e[o]=y[o],t[o]=!0);y=a!==!1&&hr(y)}while(y&&(!a||a(y,e))&&y!==Object.prototype);return e},Cd=(y,e,a)=>{y=String(y),(a===void 0||a>y.length)&&(a=y.length),a-=e.length;let r=y.indexOf(e,a);return r!==-1&&r===a},Ad=y=>{if(!y)return null;if(re(y))return y;let e=y.length;if(!co(e))return null;let a=new Array(e);for(;e-- >0;)a[e]=y[e];return a},Dd=(y=>e=>y&&e instanceof y)(typeof Uint8Array<"u"&&hr(Uint8Array)),Md=(y,e)=>{let r=(y&&y[Ve]).call(y),s;for(;(s=r.next())&&!s.done;){let i=s.value;e.call(y,i[0],i[1])}},Bd=(y,e)=>{let a,r=[];for(;(a=y.exec(e))!==null;)r.push(a);return r},Ld=pt("HTMLFormElement"),Wd=y=>y.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,r,s){return r.toUpperCase()+s}),Cs=(({hasOwnProperty:y})=>(e,a)=>y.call(e,a))(Object.prototype),Ud=pt("RegExp"),uo=(y,e)=>{let a=Object.getOwnPropertyDescriptors(y),r={};_e(a,(s,i)=>{let o;(o=e(s,i,y))!==!1&&(r[i]=o||s)}),Object.defineProperties(y,r)},Hd=y=>{uo(y,(e,a)=>{if(rt(y)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;let r=y[a];if(rt(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},Nd=(y,e)=>{let a={},r=s=>{s.forEach(i=>{a[i]=!0})};return re(y)?r(y):r(String(y).split(e)),a},Kd=()=>{},Jd=(y,e)=>y!=null&&Number.isFinite(y=+y)?y:e;function Vd(y){return!!(y&&rt(y.append)&&y[ho]==="FormData"&&y[Ve])}var Qd=y=>{let e=new Array(10),a=(r,s)=>{if(ve(r)){if(e.indexOf(r)>=0)return;if(fe(r))return r;if(!("toJSON"in r)){e[s]=r;let i=re(r)?[]:{};return _e(r,(o,t)=>{let f=a(o,s+1);!Zt(f)&&(i[t]=f)}),e[s]=void 0,i}}return r};return a(y,0)},Xd=pt("AsyncFunction"),Yd=y=>y&&(ve(y)||rt(y))&&rt(y.then)&&rt(y.catch),yo=((y,e)=>y?setImmediate:e?((a,r)=>(Ct.addEventListener("message",({source:s,data:i})=>{s===Ct&&i===a&&r.length&&r.shift()()},!1),s=>{r.push(s),Ct.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",rt(Ct.postMessage)),Zd=typeof queueMicrotask<"u"?queueMicrotask.bind(Ct):typeof process<"u"&&process.nextTick||yo,tl=y=>y!=null&&rt(y[Ve]),q={isArray:re,isArrayBuffer:lo,isBuffer:fe,isFormData:Pd,isArrayBufferView:ud,isString:yd,isNumber:co,isBoolean:gd,isObject:ve,isPlainObject:Le,isEmptyObject:fd,isReadableStream:Fd,isRequest:$d,isResponse:zd,isHeaders:Ed,isUndefined:Zt,isDate:vd,isFile:_d,isReactNativeBlob:bd,isReactNative:Sd,isBlob:Id,isRegExp:Ud,isFunction:rt,isStream:kd,isURLSearchParams:qd,isTypedArray:Dd,isFileList:wd,forEach:_e,merge:Qa,extend:xd,trim:Od,stripBOM:jd,inherits:Gd,toFlatObject:Rd,kindOf:Qe,kindOfTest:pt,endsWith:Cd,toArray:Ad,forEachEntry:Md,matchAll:Bd,isHTMLForm:Ld,hasOwnProperty:Cs,hasOwnProp:Cs,reduceDescriptors:uo,freezeMethods:Hd,toObjectSet:Nd,toCamelCase:Wd,noop:Kd,toFiniteNumber:Jd,findKey:po,global:Ct,isContextDefined:mo,isSpecCompliantForm:Vd,toJSONObject:Qd,isAsyncFn:Xd,isThenable:Yd,setImmediate:yo,asap:Zd,isIterable:tl},tt=class y extends Error{static from(e,a,r,s,i,o){let t=new y(e.message,a||e.code,r,s,i);return t.cause=e,t.name=e.name,e.status!=null&&t.status==null&&(t.status=e.status),o&&Object.assign(t,o),t}constructor(e,a,r,s,i){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,a&&(this.code=a),r&&(this.config=r),s&&(this.request=s),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:q.toJSONObject(this.config),code:this.code,status:this.status}}};tt.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";tt.ERR_BAD_OPTION="ERR_BAD_OPTION";tt.ECONNABORTED="ECONNABORTED";tt.ETIMEDOUT="ETIMEDOUT";tt.ERR_NETWORK="ERR_NETWORK";tt.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";tt.ERR_DEPRECATED="ERR_DEPRECATED";tt.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";tt.ERR_BAD_REQUEST="ERR_BAD_REQUEST";tt.ERR_CANCELED="ERR_CANCELED";tt.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";tt.ERR_INVALID_URL="ERR_INVALID_URL";var z=tt;function Xa(y){return q.isPlainObject(y)||q.isArray(y)}function go(y){return q.endsWith(y,"[]")?y.slice(0,-2):y}function Ua(y,e,a){return y?y.concat(e).map(function(s,i){return s=go(s),!a&&i?"["+s+"]":s}).join(a?".":""):e}function el(y){return q.isArray(y)&&!y.some(Xa)}var al=q.toFlatObject(q,{},null,function(e){return/^is[A-Z]/.test(e)});function Ye(y,e,a){if(!q.isObject(y))throw new TypeError("target must be an object");e=e||new(so.default||FormData),a=q.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,b){return!q.isUndefined(b[S])});let r=a.metaTokens,s=a.visitor||u,i=a.dots,o=a.indexes,f=(a.Blob||typeof Blob<"u"&&Blob)&&q.isSpecCompliantForm(e);if(!q.isFunction(s))throw new TypeError("visitor must be a function");function p(_){if(_===null)return"";if(q.isDate(_))return _.toISOString();if(q.isBoolean(_))return _.toString();if(!f&&q.isBlob(_))throw new z("Blob is not supported. Use a Buffer instead.");return q.isArrayBuffer(_)||q.isTypedArray(_)?f&&typeof Blob=="function"?new Blob([_]):Buffer.from(_):_}function u(_,S,b){let I=_;if(q.isReactNative(e)&&q.isReactNativeBlob(_))return e.append(Ua(b,S,i),p(_)),!1;if(_&&!b&&typeof _=="object"){if(q.endsWith(S,"{}"))S=r?S:S.slice(0,-2),_=JSON.stringify(_);else if(q.isArray(_)&&el(_)||(q.isFileList(_)||q.endsWith(S,"[]"))&&(I=q.toArray(_)))return S=go(S),I.forEach(function(F,R){!(q.isUndefined(F)||F===null)&&e.append(o===!0?Ua([S],R,i):o===null?S:S+"[]",p(F))}),!1}return Xa(_)?!0:(e.append(Ua(b,S,i),p(_)),!1)}let c=[],m=Object.assign(al,{defaultVisitor:u,convertValue:p,isVisitable:Xa});function g(_,S){if(!q.isUndefined(_)){if(c.indexOf(_)!==-1)throw Error("Circular reference detected in "+S.join("."));c.push(_),q.forEach(_,function(I,$){(!(q.isUndefined(I)||I===null)&&s.call(e,I,q.isString($)?$.trim():$,S,m))===!0&&g(I,S?S.concat($):[$])}),c.pop()}}if(!q.isObject(y))throw new TypeError("data must be an object");return g(y),e}function As(y){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(y).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function fo(y,e){this._pairs=[],y&&Ye(y,this,e)}var vo=fo.prototype;vo.append=function(e,a){this._pairs.push([e,a])};vo.toString=function(e){let a=e?function(r){return e.call(this,r,As)}:As;return this._pairs.map(function(s){return a(s[0])+"="+a(s[1])},"").join("&")};function rl(y){return encodeURIComponent(y).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function dr(y,e,a){if(!e)return y;let r=a&&a.encode||rl,s=q.isFunction(a)?{serialize:a}:a,i=s&&s.serialize,o;if(i?o=i(e,s):o=q.isURLSearchParams(e)?e.toString():new fo(e,s).toString(r),o){let t=y.indexOf("#");t!==-1&&(y=y.slice(0,t)),y+=(y.indexOf("?")===-1?"?":"&")+o}return y}var Ya=class{constructor(){this.handlers=[]}use(e,a,r){return this.handlers.push({fulfilled:e,rejected:a,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){q.forEach(this.handlers,function(r){r!==null&&e(r)})}},Ds=Ya,Ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},il=hd.default.URLSearchParams,Ha="abcdefghijklmnopqrstuvwxyz",Ms="0123456789",_o={DIGIT:Ms,ALPHA:Ha,ALPHA_DIGIT:Ha+Ha.toUpperCase()+Ms},sl=(y=16,e=_o.ALPHA_DIGIT)=>{let a="",{length:r}=e,s=new Uint32Array(y);nd.default.randomFillSync(s);for(let i=0;i<y;i++)a+=e[s[i]%r];return a},ol={isNode:!0,classes:{URLSearchParams:il,FormData:so.default,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:_o,generateString:sl,protocols:["http","https","file","data"]},lr=typeof window<"u"&&typeof document<"u",Za=typeof navigator=="object"&&navigator||void 0,nl=lr&&(!Za||["ReactNative","NativeScript","NS"].indexOf(Za.product)<0),hl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",dl=lr&&window.location.href||"http://localhost",ll=Object.freeze({__proto__:null,hasBrowserEnv:lr,hasStandardBrowserWebWorkerEnv:hl,hasStandardBrowserEnv:nl,navigator:Za,origin:dl}),U={...ll,...ol};function cl(y,e){return Ye(y,new U.classes.URLSearchParams,{visitor:function(a,r,s,i){return U.isNode&&q.isBuffer(a)?(this.append(r,a.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...e})}function pl(y){return q.matchAll(/\w+|\[(\w*)]/g,y).map(e=>e[0]==="[]"?"":e[1]||e[0])}function ml(y){let e={},a=Object.keys(y),r,s=a.length,i;for(r=0;r<s;r++)i=a[r],e[i]=y[i];return e}function bo(y){function e(a,r,s,i){let o=a[i++];if(o==="__proto__")return!0;let t=Number.isFinite(+o),f=i>=a.length;return o=!o&&q.isArray(s)?s.length:o,f?(q.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!t):((!s[o]||!q.isObject(s[o]))&&(s[o]=[]),e(a,r,s[o],i)&&q.isArray(s[o])&&(s[o]=ml(s[o])),!t)}if(q.isFormData(y)&&q.isFunction(y.entries)){let a={};return q.forEachEntry(y,(r,s)=>{e(pl(r),s,a,0)}),a}return null}function ul(y,e,a){if(q.isString(y))try{return(e||JSON.parse)(y),q.trim(y)}catch(r){if(r.name!=="SyntaxError")throw r}return(a||JSON.stringify)(y)}var cr={transitional:Ze,adapter:["xhr","http","fetch"],transformRequest:[function(e,a){let r=a.getContentType()||"",s=r.indexOf("application/json")>-1,i=q.isObject(e);if(i&&q.isHTMLForm(e)&&(e=new FormData(e)),q.isFormData(e))return s?JSON.stringify(bo(e)):e;if(q.isArrayBuffer(e)||q.isBuffer(e)||q.isStream(e)||q.isFile(e)||q.isBlob(e)||q.isReadableStream(e))return e;if(q.isArrayBufferView(e))return e.buffer;if(q.isURLSearchParams(e))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let t;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return cl(e,this.formSerializer).toString();if((t=q.isFileList(e))||r.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return Ye(t?{"files[]":e}:e,f&&new f,this.formSerializer)}}return i||s?(a.setContentType("application/json",!1),ul(e)):e}],transformResponse:[function(e){let a=this.transitional||cr.transitional,r=a&&a.forcedJSONParsing,s=this.responseType==="json";if(q.isResponse(e)||q.isReadableStream(e))return e;if(e&&q.isString(e)&&(r&&!this.responseType||s)){let o=!(a&&a.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(t){if(o)throw t.name==="SyntaxError"?z.from(t,z.ERR_BAD_RESPONSE,this,null,this.response):t}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:U.classes.FormData,Blob:U.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};q.forEach(["delete","get","head","post","put","patch"],y=>{cr.headers[y]={}});var pr=cr,yl=q.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gl=y=>{let e={},a,r,s;return y&&y.split(`
4
4
  `).forEach(function(o){s=o.indexOf(":"),a=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!a||e[a]&&yl[a])&&(a==="set-cookie"?e[a]?e[a].push(r):e[a]=[r]:e[a]=e[a]?e[a]+", "+r:r)}),e},Bs=Symbol("internals");function ye(y){return y&&String(y).trim().toLowerCase()}function We(y){return y===!1||y==null?y:q.isArray(y)?y.map(We):String(y)}function fl(y){let e=Object.create(null),a=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=a.exec(y);)e[r[1]]=r[2];return e}var vl=y=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(y.trim());function Na(y,e,a,r,s){if(q.isFunction(r))return r.call(this,e,a);if(s&&(e=a),!!q.isString(e)){if(q.isString(r))return e.indexOf(r)!==-1;if(q.isRegExp(r))return r.test(e)}}function _l(y){return y.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,a,r)=>a.toUpperCase()+r)}function bl(y,e){let a=q.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(y,r+a,{value:function(s,i,o){return this[r].call(this,e,s,i,o)},configurable:!0})})}var te=class{constructor(e){e&&this.set(e)}set(e,a,r){let s=this;function i(t,f,p){let u=ye(f);if(!u)throw new Error("header name must be a non-empty string");let c=q.findKey(s,u);(!c||s[c]===void 0||p===!0||p===void 0&&s[c]!==!1)&&(s[c||f]=We(t))}let o=(t,f)=>q.forEach(t,(p,u)=>i(p,u,f));if(q.isPlainObject(e)||e instanceof this.constructor)o(e,a);else if(q.isString(e)&&(e=e.trim())&&!vl(e))o(gl(e),a);else if(q.isObject(e)&&q.isIterable(e)){let t={},f,p;for(let u of e){if(!q.isArray(u))throw TypeError("Object iterator must return a key-value pair");t[p=u[0]]=(f=t[p])?q.isArray(f)?[...f,u[1]]:[f,u[1]]:u[1]}o(t,a)}else e!=null&&i(a,e,r);return this}get(e,a){if(e=ye(e),e){let r=q.findKey(this,e);if(r){let s=this[r];if(!a)return s;if(a===!0)return fl(s);if(q.isFunction(a))return a.call(this,s,r);if(q.isRegExp(a))return a.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,a){if(e=ye(e),e){let r=q.findKey(this,e);return!!(r&&this[r]!==void 0&&(!a||Na(this,this[r],r,a)))}return!1}delete(e,a){let r=this,s=!1;function i(o){if(o=ye(o),o){let t=q.findKey(r,o);t&&(!a||Na(r,r[t],t,a))&&(delete r[t],s=!0)}}return q.isArray(e)?e.forEach(i):i(e),s}clear(e){let a=Object.keys(this),r=a.length,s=!1;for(;r--;){let i=a[r];(!e||Na(this,this[i],i,e,!0))&&(delete this[i],s=!0)}return s}normalize(e){let a=this,r={};return q.forEach(this,(s,i)=>{let o=q.findKey(r,i);if(o){a[o]=We(s),delete a[i];return}let t=e?_l(i):String(i).trim();t!==i&&delete a[i],a[t]=We(s),r[t]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let a=Object.create(null);return q.forEach(this,(r,s)=>{r!=null&&r!==!1&&(a[s]=e&&q.isArray(r)?r.join(", "):r)}),a}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,a])=>e+": "+a).join(`
5
5
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...a){let r=new this(e);return a.forEach(s=>r.set(s)),r}static accessor(e){let r=(this[Bs]=this[Bs]={accessors:{}}).accessors,s=this.prototype;function i(o){let t=ye(o);r[t]||(bl(s,o),r[t]=!0)}return q.isArray(e)?e.forEach(i):i(e),this}};te.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);q.reduceDescriptors(te.prototype,({value:y},e)=>{let a=e[0].toUpperCase()+e.slice(1);return{get:()=>y,set(r){this[a]=r}}});q.freezeMethods(te);var it=te;function Ka(y,e){let a=this||pr,r=e||a,s=it.from(r.headers),i=r.data;return q.forEach(y,function(t){i=t.call(a,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function So(y){return!!(y&&y.__CANCEL__)}var tr=class extends z{constructor(e,a,r){super(e??"canceled",z.ERR_CANCELED,a,r),this.name="CanceledError",this.__CANCEL__=!0}},Dt=tr;function Yt(y,e,a){let r=a.config.validateStatus;!a.status||!r||r(a.status)?y(a):e(new z("Request failed with status code "+a.status,[z.ERR_BAD_REQUEST,z.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function Sl(y){return typeof y!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(y)}function Il(y,e){return e?y.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):y}function mr(y,e,a){let r=!Sl(e);return y&&(r||a==!1)?Il(y,e):e}var Ne="1.13.6";function Io(y){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(y);return e&&e[1]||""}var wl=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function kl(y,e,a){let r=a&&a.Blob||U.classes.Blob,s=Io(y);if(e===void 0&&r&&(e=!0),s==="data"){y=s.length?y.slice(s.length+1):y;let i=wl.exec(y);if(!i)throw new z("Invalid URL",z.ERR_INVALID_URL);let o=i[1],t=i[2],f=i[3],p=Buffer.from(decodeURIComponent(f),t?"base64":"utf8");if(e){if(!r)throw new z("Blob is not supported",z.ERR_NOT_SUPPORT);return new r([p],{type:o})}return p}throw new z("Unsupported protocol "+s,z.ERR_NOT_SUPPORT)}var Ja=Symbol("internals"),er=class extends gt.default.Transform{constructor(e){e=q.toFlatObject(e,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(r,s)=>!q.isUndefined(s[r])),super({readableHighWaterMark:e.chunkSize});let a=this[Ja]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",r=>{r==="progress"&&(a.isCaptured||(a.isCaptured=!0))})}_read(e){let a=this[Ja];return a.onReadCallback&&a.onReadCallback(),super._read(e)}_transform(e,a,r){let s=this[Ja],i=s.maxRate,o=this.readableHighWaterMark,t=s.timeWindow,f=1e3/t,p=i/f,u=s.minChunkSize!==!1?Math.max(s.minChunkSize,p*.01):0,c=(g,_)=>{let S=Buffer.byteLength(g);s.bytesSeen+=S,s.bytes+=S,s.isCaptured&&this.emit("progress",s.bytesSeen),this.push(g)?process.nextTick(_):s.onReadCallback=()=>{s.onReadCallback=null,process.nextTick(_)}},m=(g,_)=>{let S=Buffer.byteLength(g),b=null,I=o,$,F=0;if(i){let R=Date.now();(!s.ts||(F=R-s.ts)>=t)&&(s.ts=R,$=p-s.bytes,s.bytes=$<0?-$:0,F=0),$=p-s.bytes}if(i){if($<=0)return setTimeout(()=>{_(null,g)},t-F);$<I&&(I=$)}I&&S>I&&S-I>u&&(b=g.subarray(I),g=g.subarray(0,I)),c(g,b?()=>{process.nextTick(_,null,b)}:_)};m(e,function g(_,S){if(_)return r(_);S?m(S,g):r(null)})}},Ls=er,{asyncIterator:Ws}=Symbol,Tl=async function*(y){y.stream?yield*y.stream():y.arrayBuffer?yield await y.arrayBuffer():y[Ws]?yield*y[Ws]():yield y},wo=Tl,Pl=U.ALPHABET.ALPHA_DIGIT+"-_",ge=typeof TextEncoder=="function"?new TextEncoder:new nr.default.TextEncoder,At=`\r
6
6
  `,ql=ge.encode(At),Fl=2,ar=class{constructor(e,a){let{escapeName:r}=this.constructor,s=q.isString(a),i=`Content-Disposition: form-data; name="${r(e)}"${!s&&a.name?`; filename="${r(a.name)}"`:""}${At}`;s?a=ge.encode(String(a).replace(/\r?\n|\r\n?/g,At)):i+=`Content-Type: ${a.type||"application/octet-stream"}${At}`,this.headers=ge.encode(i+At),this.contentLength=s?a.byteLength:a.size,this.size=this.headers.byteLength+this.contentLength+Fl,this.name=e,this.value=a}async*encode(){yield this.headers;let{value:e}=this;q.isTypedArray(e)?yield e:yield*wo(e),yield ql}static escapeName(e){return String(e).replace(/[\r\n"]/g,a=>({"\r":"%0D","\n":"%0A",'"':"%22"})[a])}},$l=(y,e,a)=>{let{tag:r="form-data-boundary",size:s=25,boundary:i=r+"-"+U.generateString(s,Pl)}=a||{};if(!q.isFormData(y))throw TypeError("FormData instance required");if(i.length<1||i.length>70)throw Error("boundary must be 10-70 characters long");let o=ge.encode("--"+i+At),t=ge.encode("--"+i+"--"+At),f=t.byteLength,p=Array.from(y.entries()).map(([c,m])=>{let g=new ar(c,m);return f+=g.size,g});f+=o.byteLength*p.length,f=q.toFiniteNumber(f);let u={"Content-Type":`multipart/form-data; boundary=${i}`};return Number.isFinite(f)&&(u["Content-Length"]=f),e&&e(u),io.Readable.from(async function*(){for(let c of p)yield o,yield*c.encode();yield t}())},zl=$l,rr=class extends gt.default.Transform{__transform(e,a,r){this.push(e),r()}_transform(e,a,r){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let s=Buffer.alloc(2);s[0]=120,s[1]=156,this.push(s,a)}this.__transform(e,a,r)}},El=rr,Ol=(y,e)=>q.isAsyncFn(y)?function(...a){let r=a.pop();y.apply(this,a).then(s=>{try{e?r(null,...e(s)):r(null,s)}catch(i){r(i)}},r)}:y,xl=Ol;function jl(y,e){y=y||10;let a=new Array(y),r=new Array(y),s=0,i=0,o;return e=e!==void 0?e:1e3,function(f){let p=Date.now(),u=r[i];o||(o=p),a[s]=f,r[s]=p;let c=i,m=0;for(;c!==s;)m+=a[c++],c=c%y;if(s=(s+1)%y,s===i&&(i=(i+1)%y),p-o<e)return;let g=u&&p-u;return g?Math.round(m*1e3/g):void 0}}function Gl(y,e){let a=0,r=1e3/e,s,i,o=(p,u=Date.now())=>{a=u,s=null,i&&(clearTimeout(i),i=null),y(...p)};return[(...p)=>{let u=Date.now(),c=u-a;c>=r?o(p,u):(s=p,i||(i=setTimeout(()=>{i=null,o(s)},r-c)))},()=>s&&o(s)]}var ee=(y,e,a=3)=>{let r=0,s=jl(50,250);return Gl(i=>{let o=i.loaded,t=i.lengthComputable?i.total:void 0,f=o-r,p=s(f),u=o<=t;r=o;let c={loaded:o,total:t,progress:t?o/t:void 0,bytes:f,rate:p||void 0,estimated:p&&t&&u?(t-o)/p:void 0,event:i,lengthComputable:t!=null,[e?"download":"upload"]:!0};y(c)},a)},Ke=(y,e)=>{let a=y!=null;return[r=>e[0]({lengthComputable:a,total:y,loaded:r}),e[1]]},Je=y=>(...e)=>q.asap(()=>y(...e));function Rl(y){if(!y||typeof y!="string"||!y.startsWith("data:"))return 0;let e=y.indexOf(",");if(e<0)return 0;let a=y.slice(5,e),r=y.slice(e+1);if(/;base64/i.test(a)){let i=r.length,o=r.length;for(let m=0;m<o;m++)if(r.charCodeAt(m)===37&&m+2<o){let g=r.charCodeAt(m+1),_=r.charCodeAt(m+2);(g>=48&&g<=57||g>=65&&g<=70||g>=97&&g<=102)&&(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)&&(i-=2,m+=2)}let t=0,f=o-1,p=m=>m>=2&&r.charCodeAt(m-2)===37&&r.charCodeAt(m-1)===51&&(r.charCodeAt(m)===68||r.charCodeAt(m)===100);f>=0&&(r.charCodeAt(f)===61?(t++,f--):p(f)&&(t++,f-=3)),t===1&&f>=0&&(r.charCodeAt(f)===61||p(f))&&t++;let c=Math.floor(i/4)*3-(t||0);return c>0?c:0}return Buffer.byteLength(r,"utf8")}var Us={flush:zt.default.constants.Z_SYNC_FLUSH,finishFlush:zt.default.constants.Z_SYNC_FLUSH},Cl={flush:zt.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:zt.default.constants.BROTLI_OPERATION_FLUSH},Hs=q.isFunction(zt.default.createBrotliDecompress),{http:Al,https:Dl}=pd.default,Ml=/https:?/,Ns=U.protocols.map(y=>y+":"),Ks=(y,[e,a])=>(y.on("end",a).on("error",a),e),ir=class{constructor(){this.sessions=Object.create(null)}getSession(e,a){a=Object.assign({sessionTimeout:1e3},a);let r=this.sessions[e];if(r){let u=r.length;for(let c=0;c<u;c++){let[m,g]=r[c];if(!m.destroyed&&!m.closed&&nr.default.isDeepStrictEqual(g,a))return m}}let s=oo.default.connect(e,a),i,o=()=>{if(i)return;i=!0;let u=r,c=u.length,m=c;for(;m--;)if(u[m][0]===s){c===1?delete this.sessions[e]:u.splice(m,1);return}},t=s.request,{sessionTimeout:f}=a;if(f!=null){let u,c=0;s.request=function(){let m=t.apply(this,arguments);return c++,u&&(clearTimeout(u),u=null),m.once("close",()=>{--c||(u=setTimeout(()=>{u=null,o()},f))}),m}}s.once("close",o);let p=[s,a];return r?r.push(p):r=this.sessions[e]=[p],s}},Bl=new ir;function Ll(y,e){y.beforeRedirects.proxy&&y.beforeRedirects.proxy(y),y.beforeRedirects.config&&y.beforeRedirects.config(y,e)}function ko(y,e,a){let r=e;if(!r&&r!==!1){let s=dd.default.getProxyForUrl(a);s&&(r=new URL(s))}if(r){if(r.username&&(r.auth=(r.username||"")+":"+(r.password||"")),r.auth){if(!!(r.auth.username||r.auth.password))r.auth=(r.auth.username||"")+":"+(r.auth.password||"");else if(typeof r.auth=="object")throw new z("Invalid proxy authorization",z.ERR_BAD_OPTION,{proxy:r});let o=Buffer.from(r.auth,"utf8").toString("base64");y.headers["Proxy-Authorization"]="Basic "+o}y.headers.host=y.hostname+(y.port?":"+y.port:"");let s=r.hostname||r.host;y.hostname=s,y.host=s,y.port=r.port,y.path=a,r.protocol&&(y.protocol=r.protocol.includes(":")?r.protocol:`${r.protocol}:`)}y.beforeRedirects.proxy=function(i){ko(i,e,i.href)}}var Wl=typeof process<"u"&&q.kindOf(process)==="process",Ul=y=>new Promise((e,a)=>{let r,s,i=(f,p)=>{s||(s=!0,r&&r(f,p))},o=f=>{i(f),e(f)},t=f=>{i(f,!0),a(f)};y(o,t,f=>r=f).catch(t)}),Hl=({address:y,family:e})=>{if(!q.isString(y))throw TypeError("address must be a string");return{address:y,family:e||(y.indexOf(".")<0?6:4)}},Js=(y,e)=>Hl(q.isObject(y)?y:{address:y,family:e}),Nl={request(y,e){let a=y.protocol+"//"+y.hostname+":"+(y.port||(y.protocol==="https:"?443:80)),{http2Options:r,headers:s}=y,i=Bl.getSession(a,r),{HTTP2_HEADER_SCHEME:o,HTTP2_HEADER_METHOD:t,HTTP2_HEADER_PATH:f,HTTP2_HEADER_STATUS:p}=oo.default.constants,u={[o]:y.protocol.replace(":",""),[t]:y.method,[f]:y.path};q.forEach(s,(m,g)=>{g.charAt(0)!==":"&&(u[g]=m)});let c=i.request(u);return c.once("response",m=>{let g=c;m=Object.assign({},m);let _=m[p];delete m[p],g.headers=m,g.statusCode=+_,e(g)}),c}},Kl=Wl&&function(e){return Ul(async function(r,s,i){let{data:o,lookup:t,family:f,httpVersion:p=1,http2Options:u}=e,{responseType:c,responseEncoding:m}=e,g=e.method.toUpperCase(),_,S=!1,b;if(p=+p,Number.isNaN(p))throw TypeError(`Invalid protocol version: '${e.httpVersion}' is not a number`);if(p!==1&&p!==2)throw TypeError(`Unsupported protocol version '${p}'`);let I=p===2;if(t){let j=xl(t,O=>q.isArray(O)?O:[O]);t=(O,A,st)=>{j(O,A,(H,lt,$t)=>{if(H)return st(H);let at=q.isArray(lt)?lt.map(Me=>Js(Me)):[Js(lt,$t)];A.all?st(H,at):st(H,at[0].address,at[0].family)})}}let $=new od.EventEmitter;function F(j){try{$.emit("abort",!j||j.type?new Dt(null,e,b):j)}catch(O){console.warn("emit error",O)}}$.once("abort",s);let R=()=>{e.cancelToken&&e.cancelToken.unsubscribe(F),e.signal&&e.signal.removeEventListener("abort",F),$.removeAllListeners()};(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(F),e.signal&&(e.signal.aborted?F():e.signal.addEventListener("abort",F))),i((j,O)=>{if(_=!0,O){S=!0,R();return}let{data:A}=j;if(A instanceof gt.default.Readable||A instanceof gt.default.Duplex){let st=gt.default.finished(A,()=>{st(),R()})}else R()});let M=mr(e.baseURL,e.url,e.allowAbsoluteUrls),C=new URL(M,U.hasBrowserEnv?U.origin:void 0),W=C.protocol||Ns[0];if(W==="data:"){if(e.maxContentLength>-1){let O=String(e.url||M||"");if(Rl(O)>e.maxContentLength)return s(new z("maxContentLength size of "+e.maxContentLength+" exceeded",z.ERR_BAD_RESPONSE,e))}let j;if(g!=="GET")return Yt(r,s,{status:405,statusText:"method not allowed",headers:{},config:e});try{j=kl(e.url,c==="blob",{Blob:e.env&&e.env.Blob})}catch(O){throw z.from(O,z.ERR_BAD_REQUEST,e)}return c==="text"?(j=j.toString(m),(!m||m==="utf8")&&(j=q.stripBOM(j))):c==="stream"&&(j=gt.default.Readable.from(j)),Yt(r,s,{data:j,status:200,statusText:"OK",headers:new it,config:e})}if(Ns.indexOf(W)===-1)return s(new z("Unsupported protocol "+W,z.ERR_BAD_REQUEST,e));let J=it.from(e.headers).normalize();J.set("User-Agent","axios/"+Ne,!1);let{onUploadProgress:qt,onDownloadProgress:Vt}=e,Rt=e.maxRate,_t,yt;if(q.isSpecCompliantForm(o)){let j=J.getContentType(/boundary=([-_\w\d]{10,70})/i);o=zl(o,O=>{J.set(O)},{tag:`axios-${Ne}-boundary`,boundary:j&&j[1]||void 0})}else if(q.isFormData(o)&&q.isFunction(o.getHeaders)){if(J.set(o.getHeaders()),!J.hasContentLength())try{let j=await nr.default.promisify(o.getLength).call(o);Number.isFinite(j)&&j>=0&&J.setContentLength(j)}catch{}}else if(q.isBlob(o)||q.isFile(o))o.size&&J.setContentType(o.type||"application/octet-stream"),J.setContentLength(o.size||0),o=gt.default.Readable.from(wo(o));else if(o&&!q.isStream(o)){if(!Buffer.isBuffer(o))if(q.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(q.isString(o))o=Buffer.from(o,"utf-8");else return s(new z("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",z.ERR_BAD_REQUEST,e));if(J.setContentLength(o.length,!1),e.maxBodyLength>-1&&o.length>e.maxBodyLength)return s(new z("Request body larger than maxBodyLength limit",z.ERR_BAD_REQUEST,e))}let bt=q.toFiniteNumber(J.getContentLength());q.isArray(Rt)?(_t=Rt[0],yt=Rt[1]):_t=yt=Rt,o&&(qt||_t)&&(q.isStream(o)||(o=gt.default.Readable.from(o,{objectMode:!1})),o=gt.default.pipeline([o,new Ls({maxRate:q.toFiniteNumber(_t)})],q.noop),qt&&o.on("progress",Ks(o,Ke(bt,ee(Je(qt),!1,3)))));let Ft;if(e.auth){let j=e.auth.username||"",O=e.auth.password||"";Ft=j+":"+O}if(!Ft&&C.username){let j=C.username,O=C.password;Ft=j+":"+O}Ft&&J.delete("authorization");let Q;try{Q=dr(C.pathname+C.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(j){let O=new Error(j.message);return O.config=e,O.url=e.url,O.exists=!0,s(O)}J.set("Accept-Encoding","gzip, compress, deflate"+(Hs?", br":""),!1);let X={path:Q,method:g,headers:J.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:Ft,protocol:W,family:f,beforeRedirect:Ll,beforeRedirects:{},http2Options:u};!q.isUndefined(t)&&(X.lookup=t),e.socketPath?X.socketPath=e.socketPath:(X.hostname=C.hostname.startsWith("[")?C.hostname.slice(1,-1):C.hostname,X.port=C.port,ko(X,e.proxy,W+"//"+C.hostname+(C.port?":"+C.port:"")+X.path));let et,Qt=Ml.test(X.protocol);if(X.agent=Qt?e.httpsAgent:e.httpAgent,I?et=Nl:e.transport?et=e.transport:e.maxRedirects===0?et=Qt?cd.default:ld.default:(e.maxRedirects&&(X.maxRedirects=e.maxRedirects),e.beforeRedirect&&(X.beforeRedirects.config=e.beforeRedirect),et=Qt?Dl:Al),e.maxBodyLength>-1?X.maxBodyLength=e.maxBodyLength:X.maxBodyLength=1/0,e.insecureHTTPParser&&(X.insecureHTTPParser=e.insecureHTTPParser),b=et.request(X,function(O){if(b.destroyed)return;let A=[O],st=q.toFiniteNumber(O.headers["content-length"]);if(Vt||yt){let at=new Ls({maxRate:q.toFiniteNumber(yt)});Vt&&at.on("progress",Ks(at,Ke(st,ee(Je(Vt),!0,3)))),A.push(at)}let H=O,lt=O.req||b;if(e.decompress!==!1&&O.headers["content-encoding"])switch((g==="HEAD"||O.statusCode===204)&&delete O.headers["content-encoding"],(O.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":A.push(zt.default.createUnzip(Us)),delete O.headers["content-encoding"];break;case"deflate":A.push(new El),A.push(zt.default.createUnzip(Us)),delete O.headers["content-encoding"];break;case"br":Hs&&(A.push(zt.default.createBrotliDecompress(Cl)),delete O.headers["content-encoding"])}H=A.length>1?gt.default.pipeline(A,q.noop):A[0];let $t={status:O.statusCode,statusText:O.statusMessage,headers:new it(O.headers),config:e,request:lt};if(c==="stream")$t.data=H,Yt(r,s,$t);else{let at=[],Me=0;H.on("data",function(Z){at.push(Z),Me+=Z.length,e.maxContentLength>-1&&Me>e.maxContentLength&&(S=!0,H.destroy(),F(new z("maxContentLength size of "+e.maxContentLength+" exceeded",z.ERR_BAD_RESPONSE,e,lt)))}),H.on("aborted",function(){if(S)return;let Z=new z("stream has been aborted",z.ERR_BAD_RESPONSE,e,lt);H.destroy(Z),s(Z)}),H.on("error",function(Z){b.destroyed||s(z.from(Z,null,e,lt))}),H.on("end",function(){try{let Z=at.length===1?at[0]:Buffer.concat(at);c!=="arraybuffer"&&(Z=Z.toString(m),(!m||m==="utf8")&&(Z=q.stripBOM(Z))),$t.data=Z}catch(Z){return s(z.from(Z,null,e,$t.request,$t))}Yt(r,s,$t)})}$.once("abort",at=>{H.destroyed||(H.emit("error",at),H.destroy())})}),$.once("abort",j=>{b.close?b.close():b.destroy(j)}),b.on("error",function(O){s(z.from(O,null,e,b))}),b.on("socket",function(O){O.setKeepAlive(!0,1e3*60)}),e.timeout){let j=parseInt(e.timeout,10);if(Number.isNaN(j)){F(new z("error trying to parse `config.timeout` to int",z.ERR_BAD_OPTION_VALUE,e,b));return}b.setTimeout(j,function(){if(_)return;let A=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",st=e.transitional||Ze;e.timeoutErrorMessage&&(A=e.timeoutErrorMessage),F(new z(A,st.clarifyTimeoutError?z.ETIMEDOUT:z.ECONNABORTED,e,b))})}else b.setTimeout(0);if(q.isStream(o)){let j=!1,O=!1;o.on("end",()=>{j=!0}),o.once("error",A=>{O=!0,b.destroy(A)}),o.on("close",()=>{!j&&!O&&F(new Dt("Request stream has been aborted",e,b))}),o.pipe(b)}else o&&b.write(o),b.end()})},Jl=U.hasStandardBrowserEnv?((y,e)=>a=>(a=new URL(a,U.origin),y.protocol===a.protocol&&y.host===a.host&&(e||y.port===a.port)))(new URL(U.origin),U.navigator&&/(msie|trident)/i.test(U.navigator.userAgent)):()=>!0,Vl=U.hasStandardBrowserEnv?{write(y,e,a,r,s,i,o){if(typeof document>"u")return;let t=[`${y}=${encodeURIComponent(e)}`];q.isNumber(a)&&t.push(`expires=${new Date(a).toUTCString()}`),q.isString(r)&&t.push(`path=${r}`),q.isString(s)&&t.push(`domain=${s}`),i===!0&&t.push("secure"),q.isString(o)&&t.push(`SameSite=${o}`),document.cookie=t.join("; ")},read(y){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp("(?:^|; )"+y+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(y){this.write(y,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}},Vs=y=>y instanceof it?{...y}:y;function Mt(y,e){e=e||{};let a={};function r(p,u,c,m){return q.isPlainObject(p)&&q.isPlainObject(u)?q.merge.call({caseless:m},p,u):q.isPlainObject(u)?q.merge({},u):q.isArray(u)?u.slice():u}function s(p,u,c,m){if(q.isUndefined(u)){if(!q.isUndefined(p))return r(void 0,p,c,m)}else return r(p,u,c,m)}function i(p,u){if(!q.isUndefined(u))return r(void 0,u)}function o(p,u){if(q.isUndefined(u)){if(!q.isUndefined(p))return r(void 0,p)}else return r(void 0,u)}function t(p,u,c){if(c in e)return r(p,u);if(c in y)return r(void 0,p)}let f={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:t,headers:(p,u,c)=>s(Vs(p),Vs(u),c,!0)};return q.forEach(Object.keys({...y,...e}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;let c=q.hasOwnProp(f,u)?f[u]:s,m=c(y[u],e[u],u);q.isUndefined(m)&&c!==t||(a[u]=m)}),a}var To=y=>{let e=Mt({},y),{data:a,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:t}=e;if(e.headers=o=it.from(o),e.url=dr(mr(e.baseURL,e.url,e.allowAbsoluteUrls),y.params,y.paramsSerializer),t&&o.set("Authorization","Basic "+btoa((t.username||"")+":"+(t.password?unescape(encodeURIComponent(t.password)):""))),q.isFormData(a)){if(U.hasStandardBrowserEnv||U.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(q.isFunction(a.getHeaders)){let f=a.getHeaders(),p=["content-type","content-length"];Object.entries(f).forEach(([u,c])=>{p.includes(u.toLowerCase())&&o.set(u,c)})}}if(U.hasStandardBrowserEnv&&(r&&q.isFunction(r)&&(r=r(e)),r||r!==!1&&Jl(e.url))){let f=s&&i&&Vl.read(i);f&&o.set(s,f)}return e},Ql=typeof XMLHttpRequest<"u",Xl=Ql&&function(y){return new Promise(function(a,r){let s=To(y),i=s.data,o=it.from(s.headers).normalize(),{responseType:t,onUploadProgress:f,onDownloadProgress:p}=s,u,c,m,g,_;function S(){g&&g(),_&&_(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(s.method.toUpperCase(),s.url,!0),b.timeout=s.timeout;function I(){if(!b)return;let F=it.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),M={data:!t||t==="text"||t==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:F,config:y,request:b};Yt(function(W){a(W),S()},function(W){r(W),S()},M),b=null}"onloadend"in b?b.onloadend=I:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(I)},b.onabort=function(){b&&(r(new z("Request aborted",z.ECONNABORTED,y,b)),b=null)},b.onerror=function(R){let M=R&&R.message?R.message:"Network Error",C=new z(M,z.ERR_NETWORK,y,b);C.event=R||null,r(C),b=null},b.ontimeout=function(){let R=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded",M=s.transitional||Ze;s.timeoutErrorMessage&&(R=s.timeoutErrorMessage),r(new z(R,M.clarifyTimeoutError?z.ETIMEDOUT:z.ECONNABORTED,y,b)),b=null},i===void 0&&o.setContentType(null),"setRequestHeader"in b&&q.forEach(o.toJSON(),function(R,M){b.setRequestHeader(M,R)}),q.isUndefined(s.withCredentials)||(b.withCredentials=!!s.withCredentials),t&&t!=="json"&&(b.responseType=s.responseType),p&&([m,_]=ee(p,!0),b.addEventListener("progress",m)),f&&b.upload&&([c,g]=ee(f),b.upload.addEventListener("progress",c),b.upload.addEventListener("loadend",g)),(s.cancelToken||s.signal)&&(u=F=>{b&&(r(!F||F.type?new Dt(null,y,b):F),b.abort(),b=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));let $=Io(s.url);if($&&U.protocols.indexOf($)===-1){r(new z("Unsupported protocol "+$+":",z.ERR_BAD_REQUEST,y));return}b.send(i||null)})},Yl=(y,e)=>{let{length:a}=y=y?y.filter(Boolean):[];if(e||a){let r=new AbortController,s,i=function(p){if(!s){s=!0,t();let u=p instanceof Error?p:this.reason;r.abort(u instanceof z?u:new Dt(u instanceof Error?u.message:u))}},o=e&&setTimeout(()=>{o=null,i(new z(`timeout of ${e}ms exceeded`,z.ETIMEDOUT))},e),t=()=>{y&&(o&&clearTimeout(o),o=null,y.forEach(p=>{p.unsubscribe?p.unsubscribe(i):p.removeEventListener("abort",i)}),y=null)};y.forEach(p=>p.addEventListener("abort",i));let{signal:f}=r;return f.unsubscribe=()=>q.asap(t),f}},Zl=Yl,tc=function*(y,e){let a=y.byteLength;if(!e||a<e){yield y;return}let r=0,s;for(;r<a;)s=r+e,yield y.slice(r,s),r=s},ec=async function*(y,e){for await(let a of ac(y))yield*tc(a,e)},ac=async function*(y){if(y[Symbol.asyncIterator]){yield*y;return}let e=y.getReader();try{for(;;){let{done:a,value:r}=await e.read();if(a)break;yield r}}finally{await e.cancel()}},Qs=(y,e,a,r)=>{let s=ec(y,e),i=0,o,t=f=>{o||(o=!0,r&&r(f))};return new ReadableStream({async pull(f){try{let{done:p,value:u}=await s.next();if(p){t(),f.close();return}let c=u.byteLength;if(a){let m=i+=c;a(m)}f.enqueue(new Uint8Array(u))}catch(p){throw t(p),p}},cancel(f){return t(f),s.return()}},{highWaterMark:2})},Xs=64*1024,{isFunction:Be}=q,rc=(({Request:y,Response:e})=>({Request:y,Response:e}))(q.global),{ReadableStream:Ys,TextEncoder:Zs}=q.global,to=(y,...e)=>{try{return!!y(...e)}catch{return!1}},ic=y=>{y=q.merge.call({skipUndefined:!0},rc,y);let{fetch:e,Request:a,Response:r}=y,s=e?Be(e):typeof fetch=="function",i=Be(a),o=Be(r);if(!s)return!1;let t=s&&Be(Ys),f=s&&(typeof Zs=="function"?(_=>S=>_.encode(S))(new Zs):async _=>new Uint8Array(await new a(_).arrayBuffer())),p=i&&t&&to(()=>{let _=!1,S=new a(U.origin,{body:new Ys,method:"POST",get duplex(){return _=!0,"half"}}).headers.has("Content-Type");return _&&!S}),u=o&&t&&to(()=>q.isReadableStream(new r("").body)),c={stream:u&&(_=>_.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(_=>{!c[_]&&(c[_]=(S,b)=>{let I=S&&S[_];if(I)return I.call(S);throw new z(`Response type '${_}' is not supported`,z.ERR_NOT_SUPPORT,b)})});let m=async _=>{if(_==null)return 0;if(q.isBlob(_))return _.size;if(q.isSpecCompliantForm(_))return(await new a(U.origin,{method:"POST",body:_}).arrayBuffer()).byteLength;if(q.isArrayBufferView(_)||q.isArrayBuffer(_))return _.byteLength;if(q.isURLSearchParams(_)&&(_=_+""),q.isString(_))return(await f(_)).byteLength},g=async(_,S)=>{let b=q.toFiniteNumber(_.getContentLength());return b??m(S)};return async _=>{let{url:S,method:b,data:I,signal:$,cancelToken:F,timeout:R,onDownloadProgress:M,onUploadProgress:C,responseType:W,headers:J,withCredentials:qt="same-origin",fetchOptions:Vt}=To(_),Rt=e||fetch;W=W?(W+"").toLowerCase():"text";let _t=Zl([$,F&&F.toAbortSignal()],R),yt=null,bt=_t&&_t.unsubscribe&&(()=>{_t.unsubscribe()}),Ft;try{if(C&&p&&b!=="get"&&b!=="head"&&(Ft=await g(J,I))!==0){let O=new a(S,{method:"POST",body:I,duplex:"half"}),A;if(q.isFormData(I)&&(A=O.headers.get("content-type"))&&J.setContentType(A),O.body){let[st,H]=Ke(Ft,ee(Je(C)));I=Qs(O.body,Xs,st,H)}}q.isString(qt)||(qt=qt?"include":"omit");let Q=i&&"credentials"in a.prototype,X={...Vt,signal:_t,method:b.toUpperCase(),headers:J.normalize().toJSON(),body:I,duplex:"half",credentials:Q?qt:void 0};yt=i&&new a(S,X);let et=await(i?Rt(yt,Vt):Rt(S,X)),Qt=u&&(W==="stream"||W==="response");if(u&&(M||Qt&&bt)){let O={};["status","statusText","headers"].forEach(lt=>{O[lt]=et[lt]});let A=q.toFiniteNumber(et.headers.get("content-length")),[st,H]=M&&Ke(A,ee(Je(M),!0))||[];et=new r(Qs(et.body,Xs,st,()=>{H&&H(),bt&&bt()}),O)}W=W||"text";let j=await c[q.findKey(c,W)||"text"](et,_);return!Qt&&bt&&bt(),await new Promise((O,A)=>{Yt(O,A,{data:j,headers:it.from(et.headers),status:et.status,statusText:et.statusText,config:_,request:yt})})}catch(Q){throw bt&&bt(),Q&&Q.name==="TypeError"&&/Load failed|fetch/i.test(Q.message)?Object.assign(new z("Network Error",z.ERR_NETWORK,_,yt,Q&&Q.response),{cause:Q.cause||Q}):z.from(Q,Q&&Q.code,_,yt,Q&&Q.response)}}},sc=new Map,Po=y=>{let e=y&&y.env||{},{fetch:a,Request:r,Response:s}=e,i=[r,s,a],o=i.length,t=o,f,p,u=sc;for(;t--;)f=i[t],p=u.get(f),p===void 0&&u.set(f,p=t?new Map:ic(e)),u=p;return p};Po();var ur={http:Kl,xhr:Xl,fetch:{get:Po}};q.forEach(ur,(y,e)=>{if(y){try{Object.defineProperty(y,"name",{value:e})}catch{}Object.defineProperty(y,"adapterName",{value:e})}});var eo=y=>`- ${y}`,oc=y=>q.isFunction(y)||y===null||y===!1;function nc(y,e){y=q.isArray(y)?y:[y];let{length:a}=y,r,s,i={};for(let o=0;o<a;o++){r=y[o];let t;if(s=r,!oc(r)&&(s=ur[(t=String(r)).toLowerCase()],s===void 0))throw new z(`Unknown adapter '${t}'`);if(s&&(q.isFunction(s)||(s=s.get(e))))break;i[t||"#"+o]=s}if(!s){let o=Object.entries(i).map(([f,p])=>`adapter ${f} `+(p===!1?"is not supported by the environment":"is not available in the build")),t=a?o.length>1?`since :
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as y}from"./chunk-5PMMY47S.js";import{De as K,Re as R,Se as x,Ye as X,Ze as V,af as Q,df as Y,ka as I,ve as A,we as G,xc as q}from"./chunk-6SBKU5ST.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-KWCGGQCW.js";import"./chunk-QHA3ZBRO.js";import"./chunk-Q7YBRGHD.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{Lb as z,Oa as j,_c as H,ca as U,ha as N,wc as D}from"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{w as B}from"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{i as k,p as P,q as W}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{D as w,E as S,G as M,aa as $,b as C}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as T}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";T();import*as m from"node:fs";import*as u from"node:path";T();var se={"\u2010":"-","\u2011":"-","\u2012":"-","\u2013":"-","\u2014":"-","\u2015":"-","\u2212":"-","\u2018":"'","\u2019":"'","\u201A":"'","\u201B":"'","\u201C":'"',"\u201D":'"',"\u201E":'"',"\u201F":'"',"\xA0":" ","\u2002":" ","\u2003":" ","\u2004":" ","\u2005":" ","\u2006":" ","\u2007":" ","\u2008":" ","\u2009":" ","\u200A":" ","\u202F":" ","\u205F":" ","\u3000":" "};function L(n){if(n==="")return n;let t="";for(let i of n)t+=se[i]??i;return t}var ae=[n=>n,n=>n.trimEnd()];function ce(n){return L(n).trimEnd()}function J(n,t,i){if(t.length===0)return 0;if(t.length>n.length)return null;e:for(let e=0;e<=n.length-t.length;e++){for(let r=0;r<t.length;r++)if(i(n[e+r])!==i(t[r]))continue e;return e}return null}function fe(n){let t=n.split(`
3
+ import{a as y}from"./chunk-5PMMY47S.js";import{$e as Q,Ce as K,Qe as R,Re as x,Xe as X,Ye as V,cf as Y,ka as I,ue as A,ve as G,xc as q}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{Lb as z,Oa as j,_c as H,ca as U,ha as N,wc as D}from"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{w as B}from"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{i as k,p as P,q as W}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{D as w,E as S,G as M,aa as $,b as C}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as T}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";T();import*as m from"node:fs";import*as u from"node:path";T();var se={"\u2010":"-","\u2011":"-","\u2012":"-","\u2013":"-","\u2014":"-","\u2015":"-","\u2212":"-","\u2018":"'","\u2019":"'","\u201A":"'","\u201B":"'","\u201C":'"',"\u201D":'"',"\u201E":'"',"\u201F":'"',"\xA0":" ","\u2002":" ","\u2003":" ","\u2004":" ","\u2005":" ","\u2006":" ","\u2007":" ","\u2008":" ","\u2009":" ","\u200A":" ","\u202F":" ","\u205F":" ","\u3000":" "};function L(n){if(n==="")return n;let t="";for(let i of n)t+=se[i]??i;return t}var ae=[n=>n,n=>n.trimEnd()];function ce(n){return L(n).trimEnd()}function J(n,t,i){if(t.length===0)return 0;if(t.length>n.length)return null;e:for(let e=0;e<=n.length-t.length;e++){for(let r=0;r<t.length;r++)if(i(n[e+r])!==i(t[r]))continue e;return e}return null}function fe(n){let t=n.split(`
4
4
  `),i=new Array(t.length+1),e=0;for(let r=0;r<t.length;r++)i[r]=e,e+=t[r].length,r<t.length-1&&(e+=1);return i[t.length]=n.length,{lines:t,offsets:i}}function Z(n,t,i,e,r,o){if(r===0)return o?`
5
5
  `:"";let f=t[e]??0,l=e+r-1,c=(t[l]??0)+(i[l]?.length??0);if(o){let g=t[e+r];g!==void 0?c=g:n.endsWith(`
6
6
  `)&&(c=n.length)}return n.slice(f,c)}function de(n,t){let{lines:i,offsets:e}=fe(n),r=t.split(`
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Uj as T,Zf as W,fg as s}from"./chunk-6SBKU5ST.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-KWCGGQCW.js";import"./chunk-QHA3ZBRO.js";import"./chunk-Q7YBRGHD.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as $,i as E,p as m,q as R}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as b}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();var o=b("ENTER_WORKTREE"),P=`Creates an isolated git worktree at \`<projectRoot>/.matilda/worktrees/<slug>\` and returns its absolute path so subsequent file edits, shell commands, and other tools can operate inside it.
3
+ import{Wj as T,Yf as W,eg as s}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as $,i as E,p as m,q as R}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as b}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();var o=b("ENTER_WORKTREE"),P=`Creates an isolated git worktree at \`<projectRoot>/.matilda/worktrees/<slug>\` and returns its absolute path so subsequent file edits, shell commands, and other tools can operate inside it.
4
4
 
5
5
  ## When to Use
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{I as r}from"./chunk-6SBKU5ST.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-KWCGGQCW.js";import"./chunk-QHA3ZBRO.js";import"./chunk-Q7YBRGHD.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as m,i as u,p as d,q as c}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as p}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as l}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";l();var y=p("ENTER_PLAN_MODE"),g=`Use this tool to lower into plan mode before doing uncertain or complex work. Entering plan mode is a privilege reduction, so it does not require user confirmation.
3
+ import{dh as r}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as m,i as u,p as d,q as c}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as p}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as l}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";l();var y=p("ENTER_PLAN_MODE"),g=`Use this tool to lower into plan mode before doing uncertain or complex work. Entering plan mode is a privilege reduction, so it does not require user confirmation.
4
4
 
5
5
  ## When to Use This Tool
6
6
  Use this tool when the task is not yet clear enough to safely execute, for example when it requires multi-file changes, design choices, investigation before a plan can be summarized, or when requirements are ambiguous. While investigating, if complexity rises or you find yourself repeatedly needing to ask the user, enter plan mode and consolidate a plan.
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Tj as C,Vj as x,Xf as k,_f as W,fg as l}from"./chunk-6SBKU5ST.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-KWCGGQCW.js";import"./chunk-QHA3ZBRO.js";import"./chunk-Q7YBRGHD.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as E,i as R,p as c,q as T}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as b,b as $}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();import*as S from"node:fs/promises";var h=b("EXIT_WORKTREE"),O=`Exits a worktree previously created by ${c.ENTER_WORKTREE}.
3
+ import{Vj as C,Wf as k,Xj as x,Zf as W,eg as l}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as E,i as R,p as c,q as T}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as b,b as $}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();import*as S from"node:fs/promises";var h=b("EXIT_WORKTREE"),O=`Exits a worktree previously created by ${c.ENTER_WORKTREE}.
4
4
 
5
5
  ## Behavior
6
6