@spfunctions/cli 1.7.23 → 1.7.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/641.index.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/641.index.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.id=641,exports.ids=[641],exports.modules={52731:(e,t,n)=>{"use strict";O
|
|
|
6
6
|
depsCount: ${t},
|
|
7
7
|
deps: ${n}}`};const a={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(e){const[t,n]=function({schema:e}){const t={},n={};for(const o in e){if("__proto__"===o)continue;(Array.isArray(e[o])?t:n)[o]=e[o]}return[t,n]}(e);s(e,t),c(e,n)}};function s(e,t=e.schema){const{gen:n,data:r,it:a}=e;if(0===Object.keys(t).length)return;const s=n.let("missing");for(const c in t){const u=t[c];if(0===u.length)continue;const l=(0,i.propertyInData)(n,r,c,a.opts.ownProperties);e.setParams({property:c,depsCount:u.length,deps:u.join(", ")}),a.allErrors?n.if(l,()=>{for(const t of u)(0,i.checkReportMissingProp)(e,t)}):(n.if(o._`${l} && (${(0,i.checkMissingProp)(e,u,s)})`),(0,i.reportMissingProp)(e,s),n.else())}}function c(e,t=e.schema){const{gen:n,data:o,keyword:a,it:s}=e,c=n.name("valid");for(const u in t)(0,r.alwaysValidSchema)(s,t[u])||(n.if((0,i.propertyInData)(n,o,u,s.opts.ownProperties),()=>{const t=e.subschema({keyword:a,schemaProp:u},c);e.mergeValidEvaluated(t,c)},()=>n.var(c,!0)),e.ok(c))}t.validatePropertyDeps=s,t.validateSchemaDeps=c,t.default=a},48584:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=n(84464),i={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:e})=>o.str`must match "${e.ifClause}" schema`,params:({params:e})=>o._`{failingKeyword: ${e.ifClause}}`},code(e){const{gen:t,parentSchema:n,it:i}=e;void 0===n.then&&void 0===n.else&&(0,r.checkStrictMode)(i,'"if" without "then" and "else" is ignored');const s=a(i,"then"),c=a(i,"else");if(!s&&!c)return;const u=t.let("valid",!0),l=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},l);e.mergeEvaluated(t)}(),e.reset(),s&&c){const n=t.let("ifClause");e.setParams({ifClause:n}),t.if(l,d("then",n),d("else",n))}else s?t.if(l,d("then")):t.if((0,o.not)(l),d("else"));function d(n,r){return()=>{const i=e.subschema({keyword:n},l);t.assign(u,l),e.mergeValidEvaluated(i,u),r?t.assign(r,o._`${n}`):e.setParams({ifClause:n})}}e.pass(u,()=>e.error(!0))}};function a(e,t){const n=e.schema[t];return void 0!==n&&!(0,r.alwaysValidSchema)(e,n)}t.default=i},28775:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(73448),r=n(6467),i=n(75791),a=n(52959),s=n(16182),c=n(95826),u=n(71372),l=n(42431),d=n(88778),p=n(50664),h=n(8350),f=n(89380),m=n(22490),g=n(39205),b=n(48584),y=n(46829);t.default=function(e=!1){const t=[h.default,f.default,m.default,g.default,b.default,y.default,u.default,l.default,c.default,d.default,p.default];return e?t.push(r.default,a.default):t.push(o.default,i.default),t.push(s.default),t}},75791:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateTuple=void 0;const o=n(81436),r=n(84464),i=n(28484),a={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:n}=e;if(Array.isArray(t))return s(e,"additionalItems",t);n.items=!0,(0,r.alwaysValidSchema)(n,t)||e.ok((0,i.validateArray)(e))}};function s(e,t,n=e.schema){const{gen:i,parentSchema:a,data:s,keyword:c,it:u}=e;!function(e){const{opts:o,errSchemaPath:i}=u,a=n.length,s=a===e.minItems&&(a===e.maxItems||!1===e[t]);if(o.strictTuples&&!s){const e=`"${c}" is ${a}-tuple, but minItems or maxItems/${t} are not specified or different at path "${i}"`;(0,r.checkStrictMode)(u,e,o.strictTuples)}}(a),u.opts.unevaluated&&n.length&&!0!==u.items&&(u.items=r.mergeEvaluated.items(i,n.length,u.items));const l=i.name("valid"),d=i.const("len",o._`${s}.length`);n.forEach((t,n)=>{(0,r.alwaysValidSchema)(u,t)||(i.if(o._`${d} > ${n}`,()=>e.subschema({keyword:c,schemaProp:n,dataProp:n},l)),e.ok(l))})}t.validateTuple=s,t.default=a},52959:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=n(84464),i=n(28484),a=n(73448),s={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>o.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>o._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:n,it:o}=e,{prefixItems:s}=n;o.items=!0,(0,r.alwaysValidSchema)(o,t)||(s?(0,a.validateAdditionalItems)(e,s):e.ok((0,i.validateArray)(e)))}};t.default=s},8350:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(84464),r={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:r}=e;if((0,o.alwaysValidSchema)(r,n))return void e.fail();const i=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),e.failResult(i,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};t.default=r},22490:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=n(84464),i={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:e})=>o._`{passingSchemas: ${e.passing}}`},code(e){const{gen:t,schema:n,parentSchema:i,it:a}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(a.opts.discriminator&&i.discriminator)return;const s=n,c=t.let("valid",!1),u=t.let("passing",null),l=t.name("_valid");e.setParams({passing:u}),t.block(function(){s.forEach((n,i)=>{let s;(0,r.alwaysValidSchema)(a,n)?t.var(l,!0):s=e.subschema({keyword:"oneOf",schemaProp:i,compositeRule:!0},l),i>0&&t.if(o._`${l} && ${c}`).assign(c,!1).assign(u,o._`[${u}, ${i}]`).else(),t.if(l,()=>{t.assign(c,!0),t.assign(u,i),s&&e.mergeEvaluated(s,o.Name)})})}),e.result(c,()=>e.reset(),()=>e.error(!0))}};t.default=i},50664:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(28484),r=n(81436),i=n(84464),a=n(84464),s={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:s,parentSchema:c,it:u}=e,{opts:l}=u,d=(0,o.allSchemaProperties)(n),p=d.filter(e=>(0,i.alwaysValidSchema)(u,n[e]));if(0===d.length||p.length===d.length&&(!u.opts.unevaluated||!0===u.props))return;const h=l.strictSchema&&!l.allowMatchingProperties&&c.properties,f=t.name("valid");!0===u.props||u.props instanceof r.Name||(u.props=(0,a.evaluatedPropsToName)(t,u.props));const{props:m}=u;function g(e){for(const t in h)new RegExp(e).test(t)&&(0,i.checkStrictMode)(u,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function b(n){t.forIn("key",s,i=>{t.if(r._`${(0,o.usePattern)(e,n)}.test(${i})`,()=>{const o=p.includes(n);o||e.subschema({keyword:"patternProperties",schemaProp:n,dataProp:i,dataPropType:a.Type.Str},f),u.opts.unevaluated&&!0!==m?t.assign(r._`${m}[${i}]`,!0):o||u.allErrors||t.if((0,r.not)(f),()=>t.break())})})}!function(){for(const e of d)h&&g(e),u.allErrors?b(e):(t.var(f,!0),b(e),t.if(f))}()}};t.default=s},6467:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(75791),r={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,o.validateTuple)(e,"items")};t.default=r},88778:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(87881),r=n(28484),i=n(84464),a=n(42431),s={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:s,data:c,it:u}=e;"all"===u.opts.removeAdditional&&void 0===s.additionalProperties&&a.default.code(new o.KeywordCxt(u,a.default,"additionalProperties"));const l=(0,r.allSchemaProperties)(n);for(const e of l)u.definedProperties.add(e);u.opts.unevaluated&&l.length&&!0!==u.props&&(u.props=i.mergeEvaluated.props(t,(0,i.toHash)(l),u.props));const d=l.filter(e=>!(0,i.alwaysValidSchema)(u,n[e]));if(0===d.length)return;const p=t.name("valid");for(const n of d)h(n)?f(n):(t.if((0,r.propertyInData)(t,c,n,u.opts.ownProperties)),f(n),u.allErrors||t.else().var(p,!0),t.endIf()),e.it.definedProperties.add(n),e.ok(p);function h(e){return u.opts.useDefaults&&!u.compositeRule&&void 0!==n[e].default}function f(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},p)}}};t.default=s},71372:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=n(84464),i={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:e})=>o._`{propertyName: ${e.propertyName}}`},code(e){const{gen:t,schema:n,data:i,it:a}=e;if((0,r.alwaysValidSchema)(a,n))return;const s=t.name("valid");t.forIn("key",i,n=>{e.setParams({propertyName:n}),e.subschema({keyword:"propertyNames",data:n,dataTypes:["string"],propertyName:n,compositeRule:!0},s),t.if((0,o.not)(s),()=>{e.error(!0),a.allErrors||t.break()})}),e.ok(s)}};t.default=i},46829:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(84464),r={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){void 0===t.if&&(0,o.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};t.default=r},28484:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateUnion=t.validateArray=t.usePattern=t.callValidateCode=t.schemaProperties=t.allSchemaProperties=t.noPropertyInData=t.propertyInData=t.isOwnProperty=t.hasPropFunc=t.reportMissingProp=t.checkMissingProp=t.checkReportMissingProp=void 0;const o=n(81436),r=n(84464),i=n(90630),a=n(84464);function s(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:o._`Object.prototype.hasOwnProperty`})}function c(e,t,n){return o._`${s(e)}.call(${t}, ${n})`}function u(e,t,n,r){const i=o._`${t}${(0,o.getProperty)(n)} === undefined`;return r?(0,o.or)(i,(0,o.not)(c(e,t,n))):i}function l(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}t.checkReportMissingProp=function(e,t){const{gen:n,data:r,it:i}=e;n.if(u(n,r,t,i.opts.ownProperties),()=>{e.setParams({missingProperty:o._`${t}`},!0),e.error()})},t.checkMissingProp=function({gen:e,data:t,it:{opts:n}},r,i){return(0,o.or)(...r.map(r=>(0,o.and)(u(e,t,r,n.ownProperties),o._`${i} = ${r}`)))},t.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},t.hasPropFunc=s,t.isOwnProperty=c,t.propertyInData=function(e,t,n,r){const i=o._`${t}${(0,o.getProperty)(n)} !== undefined`;return r?o._`${i} && ${c(e,t,n)}`:i},t.noPropertyInData=u,t.allSchemaProperties=l,t.schemaProperties=function(e,t){return l(t).filter(n=>!(0,r.alwaysValidSchema)(e,t[n]))},t.callValidateCode=function({schemaCode:e,data:t,it:{gen:n,topSchemaRef:r,schemaPath:a,errorPath:s},it:c},u,l,d){const p=d?o._`${e}, ${t}, ${r}${a}`:t,h=[[i.default.instancePath,(0,o.strConcat)(i.default.instancePath,s)],[i.default.parentData,c.parentData],[i.default.parentDataProperty,c.parentDataProperty],[i.default.rootData,i.default.rootData]];c.opts.dynamicRef&&h.push([i.default.dynamicAnchors,i.default.dynamicAnchors]);const f=o._`${p}, ${n.object(...h)}`;return l!==o.nil?o._`${u}.call(${l}, ${f})`:o._`${u}(${f})`};const d=o._`new RegExp`;t.usePattern=function({gen:e,it:{opts:t}},n){const r=t.unicodeRegExp?"u":"",{regExp:i}=t.code,s=i(n,r);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:o._`${"new RegExp"===i.code?d:(0,a.useFunc)(e,i)}(${n}, ${r})`})},t.validateArray=function(e){const{gen:t,data:n,keyword:i,it:a}=e,s=t.name("valid");if(a.allErrors){const e=t.let("valid",!0);return c(()=>t.assign(e,!1)),e}return t.var(s,!0),c(()=>t.break()),s;function c(a){const c=t.const("len",o._`${n}.length`);t.forRange("i",0,c,n=>{e.subschema({keyword:i,dataProp:n,dataPropType:r.Type.Num},s),t.if((0,o.not)(s),a)})}},t.validateUnion=function(e){const{gen:t,schema:n,keyword:i,it:a}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(e=>(0,r.alwaysValidSchema)(a,e))&&!a.opts.unevaluated)return;const s=t.let("valid",!1),c=t.name("_valid");t.block(()=>n.forEach((n,r)=>{const a=e.subschema({keyword:i,schemaProp:r,compositeRule:!0},c);t.assign(s,o._`${s} || ${c}`);e.mergeValidEvaluated(a,c)||t.if((0,o.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}},69872:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};t.default=n},97397:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(69872),r=n(92996),i=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",o.default,r.default];t.default=i},92996:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.callRef=t.getValidate=void 0;const o=n(53162),r=n(28484),i=n(81436),a=n(90630),s=n(2718),c=n(84464),u={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:n,it:r}=e,{baseId:a,schemaEnv:c,validateName:u,opts:p,self:h}=r,{root:f}=c;if(("#"===n||"#/"===n)&&a===f.baseId)return function(){if(c===f)return d(e,u,c,c.$async);const n=t.scopeValue("root",{ref:f});return d(e,i._`${n}.validate`,f,f.$async)}();const m=s.resolveRef.call(h,f,a,n);if(void 0===m)throw new o.default(r.opts.uriResolver,a,n);return m instanceof s.SchemaEnv?function(t){const n=l(e,t);d(e,n,t,t.$async)}(m):function(o){const r=t.scopeValue("schema",!0===p.code.source?{ref:o,code:(0,i.stringify)(o)}:{ref:o}),a=t.name("valid"),s=e.subschema({schema:o,dataTypes:[],schemaPath:i.nil,topSchemaRef:r,errSchemaPath:n},a);e.mergeEvaluated(s),e.ok(a)}(m)}};function l(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):i._`${n.scopeValue("wrapper",{ref:t})}.validate`}function d(e,t,n,o){const{gen:s,it:u}=e,{allErrors:l,schemaEnv:d,opts:p}=u,h=p.passContext?a.default.this:i.nil;function f(e){const t=i._`${e}.errors`;s.assign(a.default.vErrors,i._`${a.default.vErrors} === null ? ${t} : ${a.default.vErrors}.concat(${t})`),s.assign(a.default.errors,i._`${a.default.vErrors}.length`)}function m(e){var t;if(!u.opts.unevaluated)return;const o=null===(t=null==n?void 0:n.validate)||void 0===t?void 0:t.evaluated;if(!0!==u.props)if(o&&!o.dynamicProps)void 0!==o.props&&(u.props=c.mergeEvaluated.props(s,o.props,u.props));else{const t=s.var("props",i._`${e}.evaluated.props`);u.props=c.mergeEvaluated.props(s,t,u.props,i.Name)}if(!0!==u.items)if(o&&!o.dynamicItems)void 0!==o.items&&(u.items=c.mergeEvaluated.items(s,o.items,u.items));else{const t=s.var("items",i._`${e}.evaluated.items`);u.items=c.mergeEvaluated.items(s,t,u.items,i.Name)}}o?function(){if(!d.$async)throw new Error("async schema referenced by sync schema");const n=s.let("valid");s.try(()=>{s.code(i._`await ${(0,r.callValidateCode)(e,t,h)}`),m(t),l||s.assign(n,!0)},e=>{s.if(i._`!(${e} instanceof ${u.ValidationError})`,()=>s.throw(e)),f(e),l||s.assign(n,!1)}),e.ok(n)}():e.result((0,r.callValidateCode)(e,t,h),()=>m(t),()=>f(t))}t.getValidate=l,t.callRef=d,t.default=u},28886:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=n(87115),i=n(2718),a=n(53162),s=n(84464),c={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===r.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>o._`{error: ${e}, tag: ${n}, tagValue: ${t}}`},code(e){const{gen:t,data:n,schema:c,parentSchema:u,it:l}=e,{oneOf:d}=u;if(!l.opts.discriminator)throw new Error("discriminator: requires discriminator option");const p=c.propertyName;if("string"!=typeof p)throw new Error("discriminator: requires propertyName");if(c.mapping)throw new Error("discriminator: mapping is not supported");if(!d)throw new Error("discriminator: requires oneOf keyword");const h=t.let("valid",!1),f=t.const("tag",o._`${n}${(0,o.getProperty)(p)}`);function m(n){const r=t.name("valid"),i=e.subschema({keyword:"oneOf",schemaProp:n},r);return e.mergeEvaluated(i,o.Name),r}t.if(o._`typeof ${f} == "string"`,()=>function(){const n=function(){var e;const t={},n=r(u);let o=!0;for(let t=0;t<d.length;t++){let u=d[t];if((null==u?void 0:u.$ref)&&!(0,s.schemaHasRulesButRef)(u,l.self.RULES)){const e=u.$ref;if(u=i.resolveRef.call(l.self,l.schemaEnv.root,l.baseId,e),u instanceof i.SchemaEnv&&(u=u.schema),void 0===u)throw new a.default(l.opts.uriResolver,l.baseId,e)}const h=null===(e=null==u?void 0:u.properties)||void 0===e?void 0:e[p];if("object"!=typeof h)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);o=o&&(n||r(u)),c(h,t)}if(!o)throw new Error(`discriminator: "${p}" must be required`);return t;function r({required:e}){return Array.isArray(e)&&e.includes(p)}function c(e,t){if(e.const)h(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`);for(const n of e.enum)h(n,t)}}function h(e,n){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${p}" values must be unique strings`);t[e]=n}}();t.if(!1);for(const e in n)t.elseIf(o._`${f} === ${e}`),t.assign(h,m(n[e]));t.else(),e.error(!1,{discrError:r.DiscrError.Mapping,tag:f,tagName:p}),t.endIf()}(),()=>e.error(!1,{discrError:r.DiscrError.Tag,tag:f,tagName:p})),e.ok(h)}};t.default=c},87115:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(n||(t.DiscrError=n={}))},39941:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(97397),r=n(85481),i=n(28775),a=n(72601),s=n(56620),c=[o.default,r.default,(0,i.default)(),a.default,s.metadataVocabulary,s.contentVocabulary];t.default=c},26402:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>o.str`must match format "${e}"`,params:({schemaCode:e})=>o._`{format: ${e}}`},code(e,t){const{gen:n,data:r,$data:i,schema:a,schemaCode:s,it:c}=e,{opts:u,errSchemaPath:l,schemaEnv:d,self:p}=c;u.validateFormats&&(i?function(){const i=n.scopeValue("formats",{ref:p.formats,code:u.code.formats}),a=n.const("fDef",o._`${i}[${s}]`),c=n.let("fType"),l=n.let("format");n.if(o._`typeof ${a} == "object" && !(${a} instanceof RegExp)`,()=>n.assign(c,o._`${a}.type || "string"`).assign(l,o._`${a}.validate`),()=>n.assign(c,o._`"string"`).assign(l,a)),e.fail$data((0,o.or)(!1===u.strictSchema?o.nil:o._`${s} && !${l}`,function(){const e=d.$async?o._`(${a}.async ? await ${l}(${r}) : ${l}(${r}))`:o._`${l}(${r})`,n=o._`(typeof ${l} == "function" ? ${e} : ${l}.test(${r}))`;return o._`${l} && ${l} !== true && ${c} === ${t} && !${n}`}()))}():function(){const i=p.formats[a];if(!i)return void function(){if(!1===u.strictSchema)return void p.logger.warn(e());throw new Error(e());function e(){return`unknown format "${a}" ignored in schema at path "${l}"`}}();if(!0===i)return;const[s,c,h]=function(e){const t=e instanceof RegExp?(0,o.regexpCode)(e):u.code.formats?o._`${u.code.formats}${(0,o.getProperty)(a)}`:void 0,r=n.scopeValue("formats",{key:a,ref:e,code:t});if("object"==typeof e&&!(e instanceof RegExp))return[e.type||"string",e.validate,o._`${r}.validate`];return["string",e,r]}(i);s===t&&e.pass(function(){if("object"==typeof i&&!(i instanceof RegExp)&&i.async){if(!d.$async)throw new Error("async format in sync schema");return o._`await ${h}(${r})`}return"function"==typeof c?o._`${h}(${r})`:o._`${h}.test(${r})`}())}())}};t.default=r},72601:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=[n(26402).default];t.default=o},56620:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.contentVocabulary=t.metadataVocabulary=void 0,t.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],t.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]},98026:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=n(84464),i=n(24951),a={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>o._`{allowedValue: ${e}}`},code(e){const{gen:t,data:n,$data:a,schemaCode:s,schema:c}=e;a||c&&"object"==typeof c?e.fail$data(o._`!${(0,r.useFunc)(t,i.default)}(${n}, ${s})`):e.fail(o._`${c} !== ${n}`)}};t.default=a},93200:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=n(84464),i=n(24951),a={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>o._`{allowedValues: ${e}}`},code(e){const{gen:t,data:n,$data:a,schema:s,schemaCode:c,it:u}=e;if(!a&&0===s.length)throw new Error("enum must have non-empty array");const l=s.length>=u.opts.loopEnum;let d;const p=()=>null!=d?d:d=(0,r.useFunc)(t,i.default);let h;if(l||a)h=t.let("valid"),e.block$data(h,function(){t.assign(h,!1),t.forOf("v",c,e=>t.if(o._`${p()}(${n}, ${e})`,()=>t.assign(h,!0).break()))});else{if(!Array.isArray(s))throw new Error("ajv implementation error");const e=t.const("vSchema",c);h=(0,o.or)(...s.map((t,r)=>function(e,t){const r=s[t];return"object"==typeof r&&null!==r?o._`${p()}(${n}, ${e}[${t}])`:o._`${n} === ${r}`}(e,r)))}e.pass(h)}};t.default=a},85481:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(43723),r=n(18132),i=n(46962),a=n(96023),s=n(895),c=n(94504),u=n(36296),l=n(65132),d=n(98026),p=n(93200),h=[o.default,r.default,i.default,a.default,s.default,c.default,u.default,l.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},d.default,p.default];t.default=h},36296:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxItems"===e?"more":"fewer";return o.str`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>o._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:r}=e,i="maxItems"===t?o.operators.GT:o.operators.LT;e.fail$data(o._`${n}.length ${i} ${r}`)}};t.default=r},46962:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=n(84464),i=n(36214),a={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxLength"===e?"more":"fewer";return o.str`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>o._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:a,it:s}=e,c="maxLength"===t?o.operators.GT:o.operators.LT,u=!1===s.opts.unicode?o._`${n}.length`:o._`${(0,r.useFunc)(e.gen,i.default)}(${n})`;e.fail$data(o._`${u} ${c} ${a}`)}};t.default=a},43723:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r=o.operators,i={maximum:{okStr:"<=",ok:r.LTE,fail:r.GT},minimum:{okStr:">=",ok:r.GTE,fail:r.LT},exclusiveMaximum:{okStr:"<",ok:r.LT,fail:r.GTE},exclusiveMinimum:{okStr:">",ok:r.GT,fail:r.LTE}},a={message:({keyword:e,schemaCode:t})=>o.str`must be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>o._`{comparison: ${i[e].okStr}, limit: ${t}}`},s={keyword:Object.keys(i),type:"number",schemaType:"number",$data:!0,error:a,code(e){const{keyword:t,data:n,schemaCode:r}=e;e.fail$data(o._`${n} ${i[t].fail} ${r} || isNaN(${n})`)}};t.default=s},895:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n="maxProperties"===e?"more":"fewer";return o.str`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>o._`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:r}=e,i="maxProperties"===t?o.operators.GT:o.operators.LT;e.fail$data(o._`Object.keys(${n}).length ${i} ${r}`)}};t.default=r},18132:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(81436),r={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>o.str`must be multiple of ${e}`,params:({schemaCode:e})=>o._`{multipleOf: ${e}}`},code(e){const{gen:t,data:n,schemaCode:r,it:i}=e,a=i.opts.multipleOfPrecision,s=t.let("res"),c=a?o._`Math.abs(Math.round(${s}) - ${s}) > 1e-${a}`:o._`${s} !== parseInt(${s})`;e.fail$data(o._`(${r} === 0 || (${s} = ${n}/${r}, ${c}))`)}};t.default=r},96023:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(28484),r=n(84464),i=n(81436),a={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>i.str`must match pattern "${e}"`,params:({schemaCode:e})=>i._`{pattern: ${e}}`},code(e){const{gen:t,data:n,$data:a,schema:s,schemaCode:c,it:u}=e,l=u.opts.unicodeRegExp?"u":"";if(a){const{regExp:o}=u.opts.code,a="new RegExp"===o.code?i._`new RegExp`:(0,r.useFunc)(t,o),s=t.let("valid");t.try(()=>t.assign(s,i._`${a}(${c}, ${l}).test(${n})`),()=>t.assign(s,!1)),e.fail$data(i._`!${s}`)}else{const t=(0,o.usePattern)(e,s);e.fail$data(i._`!${t}.test(${n})`)}}};t.default=a},94504:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(28484),r=n(81436),i=n(84464),a={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>r.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>r._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:n,schemaCode:a,data:s,$data:c,it:u}=e,{opts:l}=u;if(!c&&0===n.length)return;const d=n.length>=l.loopRequired;if(u.allErrors?function(){if(d||c)e.block$data(r.nil,p);else for(const t of n)(0,o.checkReportMissingProp)(e,t)}():function(){const i=t.let("missing");if(d||c){const n=t.let("valid",!0);e.block$data(n,()=>function(n,i){e.setParams({missingProperty:n}),t.forOf(n,a,()=>{t.assign(i,(0,o.propertyInData)(t,s,n,l.ownProperties)),t.if((0,r.not)(i),()=>{e.error(),t.break()})},r.nil)}(i,n)),e.ok(n)}else t.if((0,o.checkMissingProp)(e,n,i)),(0,o.reportMissingProp)(e,i),t.else()}(),l.strictRequired){const t=e.parentSchema.properties,{definedProperties:o}=e.it;for(const e of n)if(void 0===(null==t?void 0:t[e])&&!o.has(e)){const t=`required property "${e}" is not defined at "${u.schemaEnv.baseId+u.errSchemaPath}" (strictRequired)`;(0,i.checkStrictMode)(u,t,u.opts.strictRequired)}}function p(){t.forOf("prop",a,n=>{e.setParams({missingProperty:n}),t.if((0,o.noPropertyInData)(t,s,n,l.ownProperties),()=>e.error())})}}};t.default=a},65132:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(86685),r=n(81436),i=n(84464),a=n(24951),s={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>r.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>r._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:n,$data:s,schema:c,parentSchema:u,schemaCode:l,it:d}=e;if(!s&&!c)return;const p=t.let("valid"),h=u.items?(0,o.getSchemaTypes)(u.items):[];function f(i,a){const s=t.name("item"),c=(0,o.checkDataTypes)(h,s,d.opts.strictNumbers,o.DataType.Wrong),u=t.const("indices",r._`{}`);t.for(r._`;${i}--;`,()=>{t.let(s,r._`${n}[${i}]`),t.if(c,r._`continue`),h.length>1&&t.if(r._`typeof ${s} == "string"`,r._`${s} += "_"`),t.if(r._`typeof ${u}[${s}] == "number"`,()=>{t.assign(a,r._`${u}[${s}]`),e.error(),t.assign(p,!1).break()}).code(r._`${u}[${s}] = ${i}`)})}function m(o,s){const c=(0,i.useFunc)(t,a.default),u=t.name("outer");t.label(u).for(r._`;${o}--;`,()=>t.for(r._`${s} = ${o}; ${s}--;`,()=>t.if(r._`${c}(${n}[${o}], ${n}[${s}])`,()=>{e.error(),t.assign(p,!1).break(u)})))}e.block$data(p,function(){const o=t.let("i",r._`${n}.length`),i=t.let("j");e.setParams({i:o,j:i}),t.assign(p,!0),t.if(r._`${o} > 1`,()=>(h.length>0&&!h.some(e=>"object"===e||"array"===e)?f:m)(o,i))},r._`${l} === false`),e.ok(p)}};t.default=s},38793:(e,t)=>{"use strict";t.byteLength=function(e){var t=s(e),n=t[0],o=t[1];return 3*(n+o)/4-o},t.toByteArray=function(e){var t,n,i=s(e),a=i[0],c=i[1],u=new r(function(e,t,n){return 3*(t+n)/4-n}(0,a,c)),l=0,d=c>0?a-4:a;for(n=0;n<d;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===c&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,u[l++]=255&t);1===c&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,o=e.length,r=o%3,i=[],a=16383,s=0,c=o-r;s<c;s+=a)i.push(u(e,s,s+a>c?c:s+a));1===r?(t=e[o-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===r&&(t=(e[o-2]<<8)+e[o-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],o=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=i[a],o[i.charCodeAt(a)]=a;function s(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function u(e,t,n){for(var o,r=[],i=t;i<n;i+=3)o=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),r.push(c(o));return r.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},51259:function(e){!function(t){"use strict";var n,o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,r=Math.ceil,i=Math.floor,a="[BigNumber Error] ",s=a+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,l=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,h=1e9;function f(e){var t=0|e;return e>0||e===t?t:t-1}function m(e){for(var t,n,o=1,r=e.length,i=e[0]+"";o<r;){for(t=e[o++]+"",n=u-t.length;n--;t="0"+t);i+=t}for(r=i.length;48===i.charCodeAt(--r););return i.slice(0,r+1||1)}function g(e,t){var n,o,r=e.c,i=t.c,a=e.s,s=t.s,c=e.e,u=t.e;if(!a||!s)return null;if(n=r&&!r[0],o=i&&!i[0],n||o)return n?o?0:-s:a;if(a!=s)return a;if(n=a<0,o=c==u,!r||!i)return o?0:!r^n?1:-1;if(!o)return c>u^n?1:-1;for(s=(c=r.length)<(u=i.length)?c:u,a=0;a<s;a++)if(r[a]!=i[a])return r[a]>i[a]^n?1:-1;return c==u?0:c>u^n?1:-1}function b(e,t,n,o){if(e<t||e>n||e!==i(e))throw Error(a+(o||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function y(e){var t=e.c.length-1;return f(e.e/u)==t&&e.c[t]%2!=0}function v(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function _(e,t,n){var o,r;if(t<0){for(r=n+".";++t;r+=n);e=r+e}else if(++t>(o=e.length)){for(r=n,t-=o;--t;r+=n);e+=r}else t<o&&(e=e.slice(0,t)+"."+e.slice(t));return e}n=function e(t){var n,w,O,S,x,T,P,C,k,j,E=B.prototype={constructor:B,toString:null,valueOf:null},R=new B(1),A=20,I=4,M=-7,N=21,$=-1e7,D=1e7,U=!1,L=1,q=0,F={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},W="0123456789abcdefghijklmnopqrstuvwxyz",J=!0;function B(e,t){var n,r,a,c,d,p,h,f,m=this;if(!(m instanceof B))return new B(e,t);if(null==t){if(e&&!0===e._isBigNumber)return m.s=e.s,void(!e.c||e.e>D?m.c=m.e=null:e.e<$?m.c=[m.e=0]:(m.e=e.e,m.c=e.c.slice()));if((p="number"==typeof e)&&0*e==0){if(m.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,d=e;d>=10;d/=10,c++);return void(c>D?m.c=m.e=null:(m.e=c,m.c=[e]))}f=String(e)}else{if(!o.test(f=String(e)))return O(m,f,p);m.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(c=f.indexOf("."))>-1&&(f=f.replace(".","")),(d=f.search(/e/i))>0?(c<0&&(c=d),c+=+f.slice(d+1),f=f.substring(0,d)):c<0&&(c=f.length)}else{if(b(t,2,W.length,"Base"),10==t&&J)return z(m=new B(e),A+m.e+1,I);if(f=String(e),p="number"==typeof e){if(0*e!=0)return O(m,f,p,t);if(m.s=1/e<0?(f=f.slice(1),-1):1,B.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(s+e)}else m.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(n=W.slice(0,t),c=d=0,h=f.length;d<h;d++)if(n.indexOf(r=f.charAt(d))<0){if("."==r){if(d>c){c=h;continue}}else if(!a&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){a=!0,d=-1,c=0;continue}return O(m,String(e),p,t)}p=!1,(c=(f=w(f,t,10,m.s)).indexOf("."))>-1?f=f.replace(".",""):c=f.length}for(d=0;48===f.charCodeAt(d);d++);for(h=f.length;48===f.charCodeAt(--h););if(f=f.slice(d,++h)){if(h-=d,p&&B.DEBUG&&h>15&&(e>l||e!==i(e)))throw Error(s+m.s*e);if((c=c-d-1)>D)m.c=m.e=null;else if(c<$)m.c=[m.e=0];else{if(m.e=c,m.c=[],d=(c+1)%u,c<0&&(d+=u),d<h){for(d&&m.c.push(+f.slice(0,d)),h-=u;d<h;)m.c.push(+f.slice(d,d+=u));d=u-(f=f.slice(d)).length}else d-=h;for(;d--;f+="0");m.c.push(+f)}}else m.c=[m.e=0]}function G(e,t,n,o){var r,i,a,s,c;if(null==n?n=I:b(n,0,8),!e.c)return e.toString();if(r=e.c[0],a=e.e,null==t)c=m(e.c),c=1==o||2==o&&(a<=M||a>=N)?v(c,a):_(c,a,"0");else if(i=(e=z(new B(e),t,n)).e,s=(c=m(e.c)).length,1==o||2==o&&(t<=i||i<=M)){for(;s<t;c+="0",s++);c=v(c,i)}else if(t-=a+(2===o&&i>a),c=_(c,i,"0"),i+1>s){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=i-s)>0)for(i+1==s&&(c+=".");t--;c+="0");return e.s<0&&r?"-"+c:c}function V(e,t){for(var n,o,r=1,i=new B(e[0]);r<e.length;r++)(!(o=new B(e[r])).s||(n=g(i,o))===t||0===n&&i.s===t)&&(i=o);return i}function H(e,t,n){for(var o=1,r=t.length;!t[--r];t.pop());for(r=t[0];r>=10;r/=10,o++);return(n=o+n*u-1)>D?e.c=e.e=null:n<$?e.c=[e.e=0]:(e.e=n,e.c=t),e}function z(e,t,n,o){var a,s,l,p,h,f,m,g=e.c,b=d;if(g){e:{for(a=1,p=g[0];p>=10;p/=10,a++);if((s=t-a)<0)s+=u,l=t,h=g[f=0],m=i(h/b[a-l-1]%10);else if((f=r((s+1)/u))>=g.length){if(!o)break e;for(;g.length<=f;g.push(0));h=m=0,a=1,l=(s%=u)-u+1}else{for(h=p=g[f],a=1;p>=10;p/=10,a++);m=(l=(s%=u)-u+a)<0?0:i(h/b[a-l-1]%10)}if(o=o||t<0||null!=g[f+1]||(l<0?h:h%b[a-l-1]),o=n<4?(m||o)&&(0==n||n==(e.s<0?3:2)):m>5||5==m&&(4==n||o||6==n&&(s>0?l>0?h/b[a-l]:0:g[f-1])%10&1||n==(e.s<0?8:7)),t<1||!g[0])return g.length=0,o?(t-=e.e+1,g[0]=b[(u-t%u)%u],e.e=-t||0):g[0]=e.e=0,e;if(0==s?(g.length=f,p=1,f--):(g.length=f+1,p=b[u-s],g[f]=l>0?i(h/b[a-l]%b[l])*p:0),o)for(;;){if(0==f){for(s=1,l=g[0];l>=10;l/=10,s++);for(l=g[0]+=p,p=1;l>=10;l/=10,p++);s!=p&&(e.e++,g[0]==c&&(g[0]=1));break}if(g[f]+=p,g[f]!=c)break;g[f--]=0,p=1}for(s=g.length;0===g[--s];g.pop());}e.e>D?e.c=e.e=null:e.e<$&&(e.c=[e.e=0])}return e}function K(e){var t,n=e.e;return null===n?e.toString():(t=m(e.c),t=n<=M||n>=N?v(t,n):_(t,n,"0"),e.s<0?"-"+t:t)}return B.clone=e,B.ROUND_UP=0,B.ROUND_DOWN=1,B.ROUND_CEIL=2,B.ROUND_FLOOR=3,B.ROUND_HALF_UP=4,B.ROUND_HALF_DOWN=5,B.ROUND_HALF_EVEN=6,B.ROUND_HALF_CEIL=7,B.ROUND_HALF_FLOOR=8,B.EUCLID=9,B.config=B.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(a+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(b(n=e[t],0,h,t),A=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(b(n=e[t],0,8,t),I=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(b(n[0],-h,0,t),b(n[1],0,h,t),M=n[0],N=n[1]):(b(n,-h,h,t),M=-(N=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)b(n[0],-h,-1,t),b(n[1],1,h,t),$=n[0],D=n[1];else{if(b(n,-h,h,t),!n)throw Error(a+t+" cannot be zero: "+n);$=-(D=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(a+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw U=!n,Error(a+"crypto unavailable");U=n}else U=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(b(n=e[t],0,9,t),L=n),e.hasOwnProperty(t="POW_PRECISION")&&(b(n=e[t],0,h,t),q=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(a+t+" not an object: "+n);F=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(a+t+" invalid: "+n);J="0123456789"==n.slice(0,10),W=n}}return{DECIMAL_PLACES:A,ROUNDING_MODE:I,EXPONENTIAL_AT:[M,N],RANGE:[$,D],CRYPTO:U,MODULO_MODE:L,POW_PRECISION:q,FORMAT:F,ALPHABET:W}},B.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!B.DEBUG)return!0;var t,n,o=e.c,r=e.e,s=e.s;e:if("[object Array]"=={}.toString.call(o)){if((1===s||-1===s)&&r>=-h&&r<=h&&r===i(r)){if(0===o[0]){if(0===r&&1===o.length)return!0;break e}if((t=(r+1)%u)<1&&(t+=u),String(o[0]).length==t){for(t=0;t<o.length;t++)if((n=o[t])<0||n>=c||n!==i(n))break e;if(0!==n)return!0}}}else if(null===o&&null===r&&(null===s||1===s||-1===s))return!0;throw Error(a+"Invalid BigNumber: "+e)},B.maximum=B.max=function(){return V(arguments,-1)},B.minimum=B.min=function(){return V(arguments,1)},B.random=(S=9007199254740992,x=Math.random()*S&2097151?function(){return i(Math.random()*S)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,n,o,s,c,l=0,p=[],f=new B(R);if(null==e?e=A:b(e,0,h),s=r(e/u),U)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)(c=131072*t[l]+(t[l+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),t[l]=n[0],t[l+1]=n[1]):(p.push(c%1e14),l+=2);l=s/2}else{if(!crypto.randomBytes)throw U=!1,Error(a+"crypto unavailable");for(t=crypto.randomBytes(s*=7);l<s;)(c=281474976710656*(31&t[l])+1099511627776*t[l+1]+4294967296*t[l+2]+16777216*t[l+3]+(t[l+4]<<16)+(t[l+5]<<8)+t[l+6])>=9e15?crypto.randomBytes(7).copy(t,l):(p.push(c%1e14),l+=7);l=s/7}if(!U)for(;l<s;)(c=x())<9e15&&(p[l++]=c%1e14);for(s=p[--l],e%=u,s&&e&&(c=d[u-e],p[l]=i(s/c)*c);0===p[l];p.pop(),l--);if(l<0)p=[o=0];else{for(o=-1;0===p[0];p.splice(0,1),o-=u);for(l=1,c=p[0];c>=10;c/=10,l++);l<u&&(o-=u-l)}return f.e=o,f.c=p,f}),B.sum=function(){for(var e=1,t=arguments,n=new B(t[0]);e<t.length;)n=n.plus(t[e++]);return n},w=function(){var e="0123456789";function t(e,t,n,o){for(var r,i,a=[0],s=0,c=e.length;s<c;){for(i=a.length;i--;a[i]*=t);for(a[0]+=o.indexOf(e.charAt(s++)),r=0;r<a.length;r++)a[r]>n-1&&(null==a[r+1]&&(a[r+1]=0),a[r+1]+=a[r]/n|0,a[r]%=n)}return a.reverse()}return function(o,r,i,a,s){var c,u,l,d,p,h,f,g,b=o.indexOf("."),y=A,v=I;for(b>=0&&(d=q,q=0,o=o.replace(".",""),h=(g=new B(r)).pow(o.length-b),q=d,g.c=t(_(m(h.c),h.e,"0"),10,i,e),g.e=g.c.length),l=d=(f=t(o,r,i,s?(c=W,e):(c=e,W))).length;0==f[--d];f.pop());if(!f[0])return c.charAt(0);if(b<0?--l:(h.c=f,h.e=l,h.s=a,f=(h=n(h,g,y,v,i)).c,p=h.r,l=h.e),b=f[u=l+y+1],d=i/2,p=p||u<0||null!=f[u+1],p=v<4?(null!=b||p)&&(0==v||v==(h.s<0?3:2)):b>d||b==d&&(4==v||p||6==v&&1&f[u-1]||v==(h.s<0?8:7)),u<1||!f[0])o=p?_(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(f.length=u,p)for(--i;++f[--u]>i;)f[u]=0,u||(++l,f=[1].concat(f));for(d=f.length;!f[--d];);for(b=0,o="";b<=d;o+=c.charAt(f[b++]));o=_(o,l,c.charAt(0))}return o}}(),n=function(){function e(e,t,n){var o,r,i,a,s=0,c=e.length,u=t%p,l=t/p|0;for(e=e.slice();c--;)s=((r=u*(i=e[c]%p)+(o=l*i+(a=e[c]/p|0)*u)%p*p+s)/n|0)+(o/p|0)+l*a,e[c]=r%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,o){var r,i;if(n!=o)i=n>o?1:-1;else for(r=i=0;r<n;r++)if(e[r]!=t[r]){i=e[r]>t[r]?1:-1;break}return i}function n(e,t,n,o){for(var r=0;n--;)e[n]-=r,r=e[n]<t[n]?1:0,e[n]=r*o+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(o,r,a,s,l){var d,p,h,m,g,b,y,v,_,w,O,S,x,T,P,C,k,j=o.s==r.s?1:-1,E=o.c,R=r.c;if(!(E&&E[0]&&R&&R[0]))return new B(o.s&&r.s&&(E?!R||E[0]!=R[0]:R)?E&&0==E[0]||!R?0*j:j/0:NaN);for(_=(v=new B(j)).c=[],j=a+(p=o.e-r.e)+1,l||(l=c,p=f(o.e/u)-f(r.e/u),j=j/u|0),h=0;R[h]==(E[h]||0);h++);if(R[h]>(E[h]||0)&&p--,j<0)_.push(1),m=!0;else{for(T=E.length,C=R.length,h=0,j+=2,(g=i(l/(R[0]+1)))>1&&(R=e(R,g,l),E=e(E,g,l),C=R.length,T=E.length),x=C,O=(w=E.slice(0,C)).length;O<C;w[O++]=0);k=R.slice(),k=[0].concat(k),P=R[0],R[1]>=l/2&&P++;do{if(g=0,(d=t(R,w,C,O))<0){if(S=w[0],C!=O&&(S=S*l+(w[1]||0)),(g=i(S/P))>1)for(g>=l&&(g=l-1),y=(b=e(R,g,l)).length,O=w.length;1==t(b,w,y,O);)g--,n(b,C<y?k:R,y,l),y=b.length,d=1;else 0==g&&(d=g=1),y=(b=R.slice()).length;if(y<O&&(b=[0].concat(b)),n(w,b,O,l),O=w.length,-1==d)for(;t(R,w,C,O)<1;)g++,n(w,C<O?k:R,O,l),O=w.length}else 0===d&&(g++,w=[0]);_[h++]=g,w[0]?w[O++]=E[x]||0:(w=[E[x]],O=1)}while((x++<T||null!=w[0])&&j--);m=null!=w[0],_[0]||_.splice(0,1)}if(l==c){for(h=1,j=_[0];j>=10;j/=10,h++);z(v,a+(v.e=h+p*u-1)+1,s,m)}else v.e=p,v.r=+m;return v}}(),T=/^(-?)0([xbo])(?=\w[\w.]*$)/i,P=/^([^.]+)\.$/,C=/^\.([^.]+)$/,k=/^-?(Infinity|NaN)$/,j=/^\s*\+(?=[\w.])|^\s+|\s+$/g,O=function(e,t,n,o){var r,i=n?t:t.replace(j,"");if(k.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!n&&(i=i.replace(T,function(e,t,n){return r="x"==(n=n.toLowerCase())?16:"b"==n?2:8,o&&o!=r?e:t}),o&&(r=o,i=i.replace(P,"$1").replace(C,"0.$1")),t!=i))return new B(i,r);if(B.DEBUG)throw Error(a+"Not a"+(o?" base "+o:"")+" number: "+t);e.s=null}e.c=e.e=null},E.absoluteValue=E.abs=function(){var e=new B(this);return e.s<0&&(e.s=1),e},E.comparedTo=function(e,t){return g(this,new B(e,t))},E.decimalPlaces=E.dp=function(e,t){var n,o,r,i=this;if(null!=e)return b(e,0,h),null==t?t=I:b(t,0,8),z(new B(i),e+i.e+1,t);if(!(n=i.c))return null;if(o=((r=n.length-1)-f(this.e/u))*u,r=n[r])for(;r%10==0;r/=10,o--);return o<0&&(o=0),o},E.dividedBy=E.div=function(e,t){return n(this,new B(e,t),A,I)},E.dividedToIntegerBy=E.idiv=function(e,t){return n(this,new B(e,t),0,1)},E.exponentiatedBy=E.pow=function(e,t){var n,o,s,c,l,d,p,h,f=this;if((e=new B(e)).c&&!e.isInteger())throw Error(a+"Exponent not an integer: "+K(e));if(null!=t&&(t=new B(t)),l=e.e>14,!f.c||!f.c[0]||1==f.c[0]&&!f.e&&1==f.c.length||!e.c||!e.c[0])return h=new B(Math.pow(+K(f),l?e.s*(2-y(e)):+K(e))),t?h.mod(t):h;if(d=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new B(NaN);(o=!d&&f.isInteger()&&t.isInteger())&&(f=f.mod(t))}else{if(e.e>9&&(f.e>0||f.e<-1||(0==f.e?f.c[0]>1||l&&f.c[1]>=24e7:f.c[0]<8e13||l&&f.c[0]<=9999975e7)))return c=f.s<0&&y(e)?-0:0,f.e>-1&&(c=1/c),new B(d?1/c:c);q&&(c=r(q/u+2))}for(l?(n=new B(.5),d&&(e.s=1),p=y(e)):p=(s=Math.abs(+K(e)))%2,h=new B(R);;){if(p){if(!(h=h.times(f)).c)break;c?h.c.length>c&&(h.c.length=c):o&&(h=h.mod(t))}if(s){if(0===(s=i(s/2)))break;p=s%2}else if(z(e=e.times(n),e.e+1,1),e.e>14)p=y(e);else{if(0===(s=+K(e)))break;p=s%2}f=f.times(f),c?f.c&&f.c.length>c&&(f.c.length=c):o&&(f=f.mod(t))}return o?h:(d&&(h=R.div(h)),t?h.mod(t):c?z(h,q,I,void 0):h)},E.integerValue=function(e){var t=new B(this);return null==e?e=I:b(e,0,8),z(t,t.e+1,e)},E.isEqualTo=E.eq=function(e,t){return 0===g(this,new B(e,t))},E.isFinite=function(){return!!this.c},E.isGreaterThan=E.gt=function(e,t){return g(this,new B(e,t))>0},E.isGreaterThanOrEqualTo=E.gte=function(e,t){return 1===(t=g(this,new B(e,t)))||0===t},E.isInteger=function(){return!!this.c&&f(this.e/u)>this.c.length-2},E.isLessThan=E.lt=function(e,t){return g(this,new B(e,t))<0},E.isLessThanOrEqualTo=E.lte=function(e,t){return-1===(t=g(this,new B(e,t)))||0===t},E.isNaN=function(){return!this.s},E.isNegative=function(){return this.s<0},E.isPositive=function(){return this.s>0},E.isZero=function(){return!!this.c&&0==this.c[0]},E.minus=function(e,t){var n,o,r,i,a=this,s=a.s;if(t=(e=new B(e,t)).s,!s||!t)return new B(NaN);if(s!=t)return e.s=-t,a.plus(e);var l=a.e/u,d=e.e/u,p=a.c,h=e.c;if(!l||!d){if(!p||!h)return p?(e.s=-t,e):new B(h?a:NaN);if(!p[0]||!h[0])return h[0]?(e.s=-t,e):new B(p[0]?a:3==I?-0:0)}if(l=f(l),d=f(d),p=p.slice(),s=l-d){for((i=s<0)?(s=-s,r=p):(d=l,r=h),r.reverse(),t=s;t--;r.push(0));r.reverse()}else for(o=(i=(s=p.length)<(t=h.length))?s:t,s=t=0;t<o;t++)if(p[t]!=h[t]){i=p[t]<h[t];break}if(i&&(r=p,p=h,h=r,e.s=-e.s),(t=(o=h.length)-(n=p.length))>0)for(;t--;p[n++]=0);for(t=c-1;o>s;){if(p[--o]<h[o]){for(n=o;n&&!p[--n];p[n]=t);--p[n],p[o]+=c}p[o]-=h[o]}for(;0==p[0];p.splice(0,1),--d);return p[0]?H(e,p,d):(e.s=3==I?-1:1,e.c=[e.e=0],e)},E.modulo=E.mod=function(e,t){var o,r,i=this;return e=new B(e,t),!i.c||!e.s||e.c&&!e.c[0]?new B(NaN):!e.c||i.c&&!i.c[0]?new B(i):(9==L?(r=e.s,e.s=1,o=n(i,e,0,3),e.s=r,o.s*=r):o=n(i,e,0,L),(e=i.minus(o.times(e))).c[0]||1!=L||(e.s=i.s),e)},E.multipliedBy=E.times=function(e,t){var n,o,r,i,a,s,l,d,h,m,g,b,y,v,_,w=this,O=w.c,S=(e=new B(e,t)).c;if(!(O&&S&&O[0]&&S[0]))return!w.s||!e.s||O&&!O[0]&&!S||S&&!S[0]&&!O?e.c=e.e=e.s=null:(e.s*=w.s,O&&S?(e.c=[0],e.e=0):e.c=e.e=null),e;for(o=f(w.e/u)+f(e.e/u),e.s*=w.s,(l=O.length)<(m=S.length)&&(y=O,O=S,S=y,r=l,l=m,m=r),r=l+m,y=[];r--;y.push(0));for(v=c,_=p,r=m;--r>=0;){for(n=0,g=S[r]%_,b=S[r]/_|0,i=r+(a=l);i>r;)n=((d=g*(d=O[--a]%_)+(s=b*d+(h=O[a]/_|0)*g)%_*_+y[i]+n)/v|0)+(s/_|0)+b*h,y[i--]=d%v;y[i]=n}return n?++o:y.splice(0,1),H(e,y,o)},E.negated=function(){var e=new B(this);return e.s=-e.s||null,e},E.plus=function(e,t){var n,o=this,r=o.s;if(t=(e=new B(e,t)).s,!r||!t)return new B(NaN);if(r!=t)return e.s=-t,o.minus(e);var i=o.e/u,a=e.e/u,s=o.c,l=e.c;if(!i||!a){if(!s||!l)return new B(r/0);if(!s[0]||!l[0])return l[0]?e:new B(s[0]?o:0*r)}if(i=f(i),a=f(a),s=s.slice(),r=i-a){for(r>0?(a=i,n=l):(r=-r,n=s),n.reverse();r--;n.push(0));n.reverse()}for((r=s.length)-(t=l.length)<0&&(n=l,l=s,s=n,t=r),r=0;t;)r=(s[--t]=s[t]+l[t]+r)/c|0,s[t]=c===s[t]?0:s[t]%c;return r&&(s=[r].concat(s),++a),H(e,s,a)},E.precision=E.sd=function(e,t){var n,o,r,i=this;if(null!=e&&e!==!!e)return b(e,1,h),null==t?t=I:b(t,0,8),z(new B(i),e,t);if(!(n=i.c))return null;if(o=(r=n.length-1)*u+1,r=n[r]){for(;r%10==0;r/=10,o--);for(r=n[0];r>=10;r/=10,o++);}return e&&i.e+1>o&&(o=i.e+1),o},E.shiftedBy=function(e){return b(e,-9007199254740991,l),this.times("1e"+e)},E.squareRoot=E.sqrt=function(){var e,t,o,r,i,a=this,s=a.c,c=a.s,u=a.e,l=A+4,d=new B("0.5");if(1!==c||!s||!s[0])return new B(!c||c<0&&(!s||s[0])?NaN:s?a:1/0);if(0==(c=Math.sqrt(+K(a)))||c==1/0?(((t=m(s)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=f((u+1)/2)-(u<0||u%2),o=new B(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):o=new B(c+""),o.c[0])for((c=(u=o.e)+l)<3&&(c=0);;)if(i=o,o=d.times(i.plus(n(a,i,l,1))),m(i.c).slice(0,c)===(t=m(o.c)).slice(0,c)){if(o.e<u&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(r||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(o,o.e+A+2,1),e=!o.times(o).eq(a));break}if(!r&&(z(i,i.e+A+2,0),i.times(i).eq(a))){o=i;break}l+=4,c+=4,r=1}return z(o,o.e+A+1,I,e)},E.toExponential=function(e,t){return null!=e&&(b(e,0,h),e++),G(this,e,t,1)},E.toFixed=function(e,t){return null!=e&&(b(e,0,h),e=e+this.e+1),G(this,e,t)},E.toFormat=function(e,t,n){var o,r=this;if(null==n)null!=e&&t&&"object"==typeof t?(n=t,t=null):e&&"object"==typeof e?(n=e,e=t=null):n=F;else if("object"!=typeof n)throw Error(a+"Argument not an object: "+n);if(o=r.toFixed(e,t),r.c){var i,s=o.split("."),c=+n.groupSize,u=+n.secondaryGroupSize,l=n.groupSeparator||"",d=s[0],p=s[1],h=r.s<0,f=h?d.slice(1):d,m=f.length;if(u&&(i=c,c=u,u=i,m-=i),c>0&&m>0){for(i=m%c||c,d=f.substr(0,i);i<m;i+=c)d+=l+f.substr(i,c);u>0&&(d+=l+f.slice(i)),h&&(d="-"+d)}o=p?d+(n.decimalSeparator||"")+((u=+n.fractionGroupSize)?p.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):p):d}return(n.prefix||"")+o+(n.suffix||"")},E.toFraction=function(e){var t,o,r,i,s,c,l,p,h,f,g,b,y=this,v=y.c;if(null!=e&&(!(l=new B(e)).isInteger()&&(l.c||1!==l.s)||l.lt(R)))throw Error(a+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+K(l));if(!v)return new B(y);for(t=new B(R),h=o=new B(R),r=p=new B(R),b=m(v),s=t.e=b.length-y.e-1,t.c[0]=d[(c=s%u)<0?u+c:c],e=!e||l.comparedTo(t)>0?s>0?t:h:l,c=D,D=1/0,l=new B(b),p.c[0]=0;f=n(l,t,0,1),1!=(i=o.plus(f.times(r))).comparedTo(e);)o=r,r=i,h=p.plus(f.times(i=h)),p=i,t=l.minus(f.times(i=t)),l=i;return i=n(e.minus(o),r,0,1),p=p.plus(i.times(h)),o=o.plus(i.times(r)),p.s=h.s=y.s,g=n(h,r,s*=2,I).minus(y).abs().comparedTo(n(p,o,s,I).minus(y).abs())<1?[h,r]:[p,o],D=c,g},E.toNumber=function(){return+K(this)},E.toPrecision=function(e,t){return null!=e&&b(e,1,h),G(this,e,t,2)},E.toString=function(e){var t,n=this,o=n.s,r=n.e;return null===r?o?(t="Infinity",o<0&&(t="-"+t)):t="NaN":(null==e?t=r<=M||r>=N?v(m(n.c),r):_(m(n.c),r,"0"):10===e&&J?t=_(m((n=z(new B(n),A+r+1,I)).c),n.e,"0"):(b(e,2,W.length,"Base"),t=w(_(m(n.c),r,"0"),10,e,o,!0)),o<0&&n.c[0]&&(t="-"+t)),t},E.valueOf=E.toJSON=function(){return K(this)},E._isBigNumber=!0,null!=t&&B.set(t),B}(),n.default=n.BigNumber=n,"function"==typeof define&&define.amd?define(function(){return n}):e.exports?e.exports=n:(t||(t="undefined"!=typeof self&&self?self:window),t.BigNumber=n)}(this)},39732:(e,t,n)=>{"use strict";var o=n(20181).Buffer,r=n(20181).SlowBuffer;function i(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var n=0,r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}e.exports=i,i.install=function(){o.prototype.equal=r.prototype.equal=function(e){return i(this,e)}};var a=o.prototype.equal,s=r.prototype.equal;i.restore=function(){o.prototype.equal=a,r.prototype.equal=s}},325:(e,t,n)=>{"use strict";var o=n(93058).Buffer,r=n(5028),i=128;function a(e){if(o.isBuffer(e))return e;if("string"==typeof e)return o.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function s(e,t,n){for(var o=0;t+o<n&&0===e[t+o];)++o;return e[t+o]>=i&&--o,o}e.exports={derToJose:function(e,t){e=a(e);var n=r(t),i=n+1,s=e.length,c=0;if(48!==e[c++])throw new Error('Could not find expected "seq"');var u=e[c++];if(129===u&&(u=e[c++]),s-c<u)throw new Error('"seq" specified length of "'+u+'", only "'+(s-c)+'" remaining');if(2!==e[c++])throw new Error('Could not find expected "int" for "r"');var l=e[c++];if(s-c-2<l)throw new Error('"r" specified length of "'+l+'", only "'+(s-c-2)+'" available');if(i<l)throw new Error('"r" specified length of "'+l+'", max of "'+i+'" is acceptable');var d=c;if(c+=l,2!==e[c++])throw new Error('Could not find expected "int" for "s"');var p=e[c++];if(s-c!==p)throw new Error('"s" specified length of "'+p+'", expected "'+(s-c)+'"');if(i<p)throw new Error('"s" specified length of "'+p+'", max of "'+i+'" is acceptable');var h=c;if((c+=p)!==s)throw new Error('Expected to consume entire buffer, but "'+(s-c)+'" bytes remain');var f=n-l,m=n-p,g=o.allocUnsafe(f+l+m+p);for(c=0;c<f;++c)g[c]=0;e.copy(g,c,d+Math.max(-f,0),d+l);for(var b=c=n;c<b+m;++c)g[c]=0;return e.copy(g,c,h+Math.max(-m,0),h+p),g=(g=g.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=a(e);var n=r(t),c=e.length;if(c!==2*n)throw new TypeError('"'+t+'" signatures must be "'+2*n+'" bytes, saw "'+c+'"');var u=s(e,0,n),l=s(e,n,e.length),d=n-u,p=n-l,h=2+d+1+1+p,f=h<i,m=o.allocUnsafe((f?2:3)+h),g=0;return m[g++]=48,f?m[g++]=h:(m[g++]=129,m[g++]=255&h),m[g++]=2,m[g++]=d,u<0?(m[g++]=0,g+=e.copy(m,g,0,n)):g+=e.copy(m,g,u,n),m[g++]=2,m[g++]=p,l<0?(m[g++]=0,e.copy(m,g,n)):e.copy(m,g,n+l),m}}},5028:e=>{"use strict";function t(e){return(e/8|0)+(e%8==0?0:1)}var n={ES256:t(256),ES384:t(384),ES512:t(521)};e.exports=function(e){var t=n[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},23860:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,o=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},a=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var o,r=t.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!i)return!1;for(o in e);return void 0===o||t.call(e,o)},s=function(e,t){o&&"__proto__"===t.name?o(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},c=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;if(r)return r(e,n).value}return e[n]};e.exports=function e(){var t,n,o,r,u,l,d=arguments[0],p=1,h=arguments.length,f=!1;for("boolean"==typeof d&&(f=d,d=arguments[1]||{},p=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});p<h;++p)if(null!=(t=arguments[p]))for(n in t)o=c(d,n),d!==(r=c(t,n))&&(f&&r&&(a(r)||(u=i(r)))?(u?(u=!1,l=o&&i(o)?o:[]):l=o&&a(o)?o:{},s(d,{name:n,newValue:e(f,l,r)})):void 0!==r&&s(d,{name:n,newValue:r}));return d}},1049:e=>{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var o,r,i;if(Array.isArray(t)){if((o=t.length)!=n.length)return!1;for(r=o;0!==r--;)if(!e(t[r],n[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((o=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=o;0!==r--;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;0!==r--;){var a=i[r];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n}},85693:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.GaxiosError=t.GAXIOS_ERROR_SYMBOL=void 0,t.defaultErrorRedactor=function e(t){const n="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";function o(e){e&&e.forEach((t,o)=>{(/^authentication$/i.test(o)||/^authorization$/i.test(o)||/secret/i.test(o))&&e.set(o,n)})}function r(e,t){if("object"==typeof e&&null!==e&&"string"==typeof e[t]){const o=e[t];(/grant_type=/i.test(o)||/assertion=/i.test(o)||/secret/i.test(o))&&(e[t]=n)}}function i(e){e&&"object"==typeof e&&(e instanceof FormData||e instanceof URLSearchParams||"forEach"in e&&"set"in e?e.forEach((t,o)=>{(["grant_type","assertion"].includes(o)||/secret/.test(o))&&e.set(o,n)}):("grant_type"in e&&(e.grant_type=n),"assertion"in e&&(e.assertion=n),"client_secret"in e&&(e.client_secret=n)))}t.config&&(o(t.config.headers),r(t.config,"data"),i(t.config.data),r(t.config,"body"),i(t.config.body),t.config.url.searchParams.has("token")&&t.config.url.searchParams.set("token",n),t.config.url.searchParams.has("client_secret")&&t.config.url.searchParams.set("client_secret",n));t.response&&(e({config:t.response.config}),o(t.response.headers),t.response.bodyUsed&&(r(t.response,"data"),i(t.response.data)));return t};const r=o(n(23860)),i=o(n(38823)).default.pkg;t.GAXIOS_ERROR_SYMBOL=Symbol.for(`${i.name}-gaxios-error`);class a extends Error{config;response;code;status;error;[t.GAXIOS_ERROR_SYMBOL]=i.version;static[Symbol.hasInstance](e){return!(!e||"object"!=typeof e||!(t.GAXIOS_ERROR_SYMBOL in e)||e[t.GAXIOS_ERROR_SYMBOL]!==i.version)||Function.prototype[Symbol.hasInstance].call(a,e)}constructor(e,t,n,o){if(super(e,{cause:o}),this.config=t,this.response=n,this.error=o instanceof Error?o:void 0,this.config=(0,r.default)(!0,{},t),this.response&&(this.response.config=(0,r.default)(!0,{},this.response.config)),this.response){try{this.response.data=function(e,t){switch(e){case"stream":default:return t;case"json":return JSON.parse(JSON.stringify(t));case"arraybuffer":return JSON.parse(Buffer.from(t).toString("utf8"));case"blob":return JSON.parse(t.text())}}(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}o instanceof DOMException?this.code=o.name:o&&"object"==typeof o&&"code"in o&&("string"==typeof o.code||"number"==typeof o.code)&&(this.code=o.code)}static extractAPIErrorFromResponse(e,t="The request failed"){let n=t;if("string"==typeof e.data&&(n=e.data),e.data&&"object"==typeof e.data&&"error"in e.data&&e.data.error&&!e.ok){if("string"==typeof e.data.error)return{message:e.data.error,code:e.status,status:e.statusText};if("object"==typeof e.data.error){n="message"in e.data.error&&"string"==typeof e.data.error.message?e.data.error.message:n;const t="status"in e.data.error&&"string"==typeof e.data.error.status?e.data.error.status:e.statusText,o="code"in e.data.error&&"number"==typeof e.data.error.code?e.data.error.code:e.status;if("errors"in e.data.error&&Array.isArray(e.data.error.errors)){const r=[];for(const t of e.data.error.errors)"object"==typeof t&&"message"in t&&"string"==typeof t.message&&r.push(t.message);return Object.assign({message:r.join("\n")||n,code:o,status:t},e.data.error)}return Object.assign({message:n,code:o,status:t},e.data.error)}}return{message:n,code:e.status,status:e.statusText}}}t.GaxiosError=a},5881:function(e,t,n){"use strict";var o,r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Gaxios=void 0;const i=r(n(23860)),a=n(65692),s=n(85693),c=n(64616),u=n(2203),l=n(4653);class d{agentCache=new Map;defaults;interceptors;constructor(e){this.defaults=e||{},this.interceptors={request:new l.GaxiosInterceptorManager,response:new l.GaxiosInterceptorManager}}fetch(...e){const t=e[0],n=e[1];let r;const i=new Headers;return"string"==typeof t?r=new URL(t):t instanceof URL?r=t:t&&t.url&&(r=new URL(t.url)),t&&"object"==typeof t&&"headers"in t&&o.mergeHeaders(i,t.headers),n&&o.mergeHeaders(i,new Headers(n.headers)),"object"!=typeof t||t instanceof URL?this.request({...n,headers:i,url:r}):this.request({...n,...t,headers:i,url:r})}async request(e={}){let t=await this.#e(e);return t=await this.#t(t),this.#n(this._request(t))}async _defaultAdapter(e){const t=e.fetchImplementation||this.defaults.fetchImplementation||await o.#o(),n={...e};delete n.data;const r=await t(e.url,n),i=await this.getResponseData(e,r);return Object.getOwnPropertyDescriptor(r,"data")?.configurable||Object.defineProperties(r,{data:{configurable:!0,writable:!0,enumerable:!0,value:i}}),Object.assign(r,{config:e,data:i})}async _request(e){try{let t;if(t=e.adapter?await e.adapter(e,this._defaultAdapter.bind(this)):await this._defaultAdapter(e),!e.validateStatus(t.status)){if("stream"===e.responseType){const e=[];for await(const n of t.data)e.push(n);t.data=e.toString()}const n=s.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new s.GaxiosError(n?.message,e,t,n)}return t}catch(t){let n;n=t instanceof s.GaxiosError?t:t instanceof Error?new s.GaxiosError(t.message,e,void 0,t):new s.GaxiosError("Unexpected Gaxios Error",e,void 0,t);const{shouldRetry:o,config:r}=await(0,c.getRetryConfig)(n);if(o&&r)return n.config.retryConfig.currentRetryAttempt=r.retryConfig.currentRetryAttempt,e.retryConfig=n.config?.retryConfig,this.#r(e),this._request(e);throw e.errorRedactor&&e.errorRedactor(n),n}}async getResponseData(e,t){if(204===t.status)return"";if(e.maxContentLength&&t.headers.has("content-length")&&e.maxContentLength<Number.parseInt(t.headers?.get("content-length")||""))throw new s.GaxiosError("Response's `Content-Length` is over the limit.",e,Object.assign(t,{config:e}));switch(e.responseType){case"stream":return t.body;case"json":{const e=await t.text();try{return JSON.parse(e)}catch{return e}}case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"text":return t.text();default:return this.getResponseDataFromContentType(t)}}#i(e,t=[]){const n=new URL(e),o=[...t],r=(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[];for(const e of r)o.push(e.trim());for(const e of o)if(e instanceof RegExp){if(e.test(n.toString()))return!1}else if(e instanceof URL){if(e.origin===n.origin)return!1}else if(e.startsWith("*.")||e.startsWith(".")){const t=e.replace(/^\*\./,".");if(n.hostname.endsWith(t))return!1}else if(e===n.origin||e===n.hostname||e===n.href)return!1;return!0}async#t(e){let t=Promise.resolve(e);for(const e of this.interceptors.request.values())e&&(t=t.then(e.resolved,e.rejected));return t}async#n(e){let t=Promise.resolve(e);for(const e of this.interceptors.response.values())e&&(t=t.then(e.resolved,e.rejected));return t}async#e(e){const t=new Headers(this.defaults.headers);o.mergeHeaders(t,e.headers);const r=(0,i.default)(!0,{},this.defaults,e);if(!r.url)throw new Error("URL is required.");if(r.baseURL&&(r.url=new URL(r.url,r.baseURL)),r.url=new URL(r.url),r.params)if(r.paramsSerializer){let e=r.paramsSerializer(r.params);e.startsWith("?")&&(e=e.slice(1));const t=r.url.toString().includes("?")?"&":"?";r.url=r.url+t+e}else{const e=r.url instanceof URL?r.url:new URL(r.url);for(const[t,n]of new URLSearchParams(r.params))e.searchParams.append(t,n);r.url=e}"number"==typeof e.maxContentLength&&(r.size=e.maxContentLength),"number"==typeof e.maxRedirects&&(r.follow=e.maxRedirects);const c="string"==typeof r.data||r.data instanceof ArrayBuffer||r.data instanceof Blob||globalThis.File&&r.data instanceof File||r.data instanceof FormData||r.data instanceof u.Readable||r.data instanceof ReadableStream||r.data instanceof String||r.data instanceof URLSearchParams||ArrayBuffer.isView(r.data)||["Blob","File","FormData"].includes(r.data?.constructor?.name||"");if(r.multipart?.length){const e=await(async()=>globalThis.crypto?.randomUUID()||(await Promise.resolve().then(n.t.bind(n,76982,23))).randomUUID())();t.set("content-type",`multipart/related; boundary=${e}`),r.body=u.Readable.from(this.getMultipartRequest(r.multipart,e))}else c?r.body=r.data:"object"==typeof r.data?"application/x-www-form-urlencoded"===t.get("Content-Type")?r.body=r.paramsSerializer?r.paramsSerializer(r.data):new URLSearchParams(r.data):(t.has("content-type")||t.set("content-type","application/json"),r.body=JSON.stringify(r.data)):r.data&&(r.body=r.data);r.validateStatus=r.validateStatus||this.validateStatus,r.responseType=r.responseType||"unknown",t.has("accept")||"json"!==r.responseType||t.set("accept","application/json");const l=r.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(r.agent);else if(l&&this.#i(r.url,r.noProxy)){const e=await o.#a();this.agentCache.has(l)?r.agent=this.agentCache.get(l):(r.agent=new e(l,{cert:r.cert,key:r.key}),this.agentCache.set(l,r.agent))}else r.cert&&r.key&&(this.agentCache.has(r.key)?r.agent=this.agentCache.get(r.key):(r.agent=new a.Agent({cert:r.cert,key:r.key}),this.agentCache.set(r.key,r.agent)));return"function"!=typeof r.errorRedactor&&!1!==r.errorRedactor&&(r.errorRedactor=s.defaultErrorRedactor),r.body&&!("duplex"in r)&&(r.duplex="half"),this.#r(r),Object.assign(r,{headers:t,url:r.url instanceof URL?r.url:new URL(r.url)})}#r(e){if(e.timeout){const t=AbortSignal.timeout(e.timeout);e.signal&&!e.signal.aborted?e.signal=AbortSignal.any([e.signal,t]):e.signal=t}}validateStatus(e){return e>=200&&e<300}async getResponseDataFromContentType(e){let t=e.headers.get("Content-Type");if(null===t)return e.text();if(t=t.toLowerCase(),t.includes("application/json")){let t=await e.text();try{t=JSON.parse(t)}catch{}return t}return t.match(/^text\//)?e.text():e.blob()}async*getMultipartRequest(e,t){const n=`--${t}--`;for(const n of e){const e=`--${t}\r\nContent-Type: ${n.headers.get("Content-Type")||"application/octet-stream"}\r\n\r\n`;yield e,"string"==typeof n.content?yield n.content:yield*n.content,yield"\r\n"}yield n}static#s;static#c;static async#a(){return this.#s||=(await Promise.all([n.e(830),n.e(669)]).then(n.t.bind(n,3669,23))).HttpsProxyAgent,this.#s}static async#o(){const e="undefined"!=typeof window&&!!window;return this.#c||=e?window.fetch:(await n.e(816).then(n.bind(n,70816))).default,this.#c}static mergeHeaders(e,...t){e=e instanceof Headers?e:new Headers(e);for(const n of t){(n instanceof Headers?n:new Headers(n)).forEach((t,n)=>{"set-cookie"===n?e.append(n,t):e.set(n,t)})}return e}}t.Gaxios=d,o=d},17842:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.instance=t.Gaxios=t.GaxiosError=void 0,t.request=async function(e){return t.instance.request(e)};const i=n(5881);Object.defineProperty(t,"Gaxios",{enumerable:!0,get:function(){return i.Gaxios}});var a=n(85693);Object.defineProperty(t,"GaxiosError",{enumerable:!0,get:function(){return a.GaxiosError}}),r(n(4653),t),t.instance=new i.Gaxios},4653:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GaxiosInterceptorManager=void 0;class n extends Set{}t.GaxiosInterceptorManager=n},64616:(e,t)=>{"use strict";function n(e){const t=o(e);if(e.config.signal?.aborted&&"TimeoutError"!==e.code||"AbortError"===e.code)return!1;if(!t||0===t.retry)return!1;if(!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries)return!1;if(!t.httpMethodsToRetry||!t.httpMethodsToRetry.includes(e.config.method?.toUpperCase()||"GET"))return!1;if(e.response&&e.response.status){let n=!1;for(const[o,r]of t.statusCodesToRetry){const t=e.response.status;if(t>=o&&t<=r){n=!0;break}}if(!n)return!1}return t.currentRetryAttempt=t.currentRetryAttempt||0,!(t.currentRetryAttempt>=t.retry)}function o(e){if(e&&e.config&&e.config.retryConfig)return e.config.retryConfig}Object.defineProperty(t,"__esModule",{value:!0}),t.getRetryConfig=async function(e){let t=o(e);if(!e||!e.config||!t&&!e.config.retry)return{shouldRetry:!1};t=t||{},t.currentRetryAttempt=t.currentRetryAttempt||0,t.retry=void 0===t.retry||null===t.retry?3:t.retry,t.httpMethodsToRetry=t.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],t.noResponseRetries=void 0===t.noResponseRetries||null===t.noResponseRetries?2:t.noResponseRetries,t.retryDelayMultiplier=t.retryDelayMultiplier?t.retryDelayMultiplier:2,t.timeOfFirstRequest=t.timeOfFirstRequest?t.timeOfFirstRequest:Date.now(),t.totalTimeout=t.totalTimeout?t.totalTimeout:Number.MAX_SAFE_INTEGER,t.maxRetryDelay=t.maxRetryDelay?t.maxRetryDelay:Number.MAX_SAFE_INTEGER;t.statusCodesToRetry=t.statusCodesToRetry||[[100,199],[408,408],[429,429],[500,599]],e.config.retryConfig=t;const r=t.shouldRetry||n;if(!await r(e))return{shouldRetry:!1,config:e.config};const i=function(e){const t=e.currentRetryAttempt?0:e.retryDelay??100,n=t+(Math.pow(e.retryDelayMultiplier,e.currentRetryAttempt)-1)/2*1e3,o=e.totalTimeout-(Date.now()-e.timeOfFirstRequest);return Math.min(n,o,e.maxRetryDelay)}(t);e.config.retryConfig.currentRetryAttempt+=1;const a=t.retryBackoff?t.retryBackoff(e,i):new Promise(e=>{setTimeout(e,i)});t.onRetryAttempt&&await t.onRetryAttempt(e);return await a,{shouldRetry:!0,config:e.config}}},34810:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AuthClient=t.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=t.DEFAULT_UNIVERSE=void 0;const o=n(24434),r=n(17842),i=n(37870),a=n(81577),s=n(65470);t.DEFAULT_UNIVERSE="googleapis.com",t.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=3e5;class c extends o.EventEmitter{apiKey;projectId;quotaProjectId;transporter;credentials={};eagerRefreshThresholdMillis=t.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS;forceRefreshOnFailure=!1;universeDomain=t.DEFAULT_UNIVERSE;static RequestMethodNameSymbol=Symbol("request method name");static RequestLogIdSymbol=Symbol("request log id");constructor(e={}){super();const n=(0,i.originalOrCamelOptions)(e);this.apiKey=e.apiKey,this.projectId=n.get("project_id")??null,this.quotaProjectId=n.get("quota_project_id"),this.credentials=n.get("credentials")??{},this.universeDomain=n.get("universe_domain")??t.DEFAULT_UNIVERSE,this.transporter=e.transporter??new r.Gaxios(e.transporterOptions),!1!==n.get("useAuthRequestParameters")&&(this.transporter.interceptors.request.add(c.DEFAULT_REQUEST_INTERCEPTOR),this.transporter.interceptors.response.add(c.DEFAULT_RESPONSE_INTERCEPTOR)),e.eagerRefreshThresholdMillis&&(this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis),this.forceRefreshOnFailure=e.forceRefreshOnFailure??!1}fetch(...e){const t=e[0],n=e[1];let o;const i=new Headers;return"string"==typeof t?o=new URL(t):t instanceof URL?o=t:t&&t.url&&(o=new URL(t.url)),t&&"object"==typeof t&&"headers"in t&&r.Gaxios.mergeHeaders(i,t.headers),n&&r.Gaxios.mergeHeaders(i,new Headers(n.headers)),"object"!=typeof t||t instanceof URL?this.request({...n,headers:i,url:o}):this.request({...n,...t,headers:i,url:o})}setCredentials(e){this.credentials=e}addSharedMetadataHeaders(e){return!e.has("x-goog-user-project")&&this.quotaProjectId&&e.set("x-goog-user-project",this.quotaProjectId),e}addUserProjectAndAuthHeaders(e,t){const n=t.get("x-goog-user-project"),o=t.get("authorization");return n&&e.set("x-goog-user-project",n),o&&e.set("authorization",o),e}static log=(0,a.log)("auth");static DEFAULT_REQUEST_INTERCEPTOR={resolved:async e=>{if(!e.headers.has("x-goog-api-client")){const t=process.version.replace(/^v/,"");e.headers.set("x-goog-api-client",`gl-node/${t}`)}const t=e.headers.get("User-Agent");t?t.includes(`${s.PRODUCT_NAME}/`)||e.headers.set("User-Agent",`${t} ${s.USER_AGENT}`):e.headers.set("User-Agent",s.USER_AGENT);try{const t=e,n=t[c.RequestMethodNameSymbol],o=`${Math.floor(1e3*Math.random())}`;t[c.RequestLogIdSymbol]=o;const r={url:e.url,headers:e.headers};n?c.log.info("%s [%s] request %j",n,o,r):c.log.info("[%s] request %j",o,r)}catch(e){}return e}};static DEFAULT_RESPONSE_INTERCEPTOR={resolved:async e=>{try{const t=e.config,n=t[c.RequestMethodNameSymbol],o=t[c.RequestLogIdSymbol];n?c.log.info("%s [%s] response %j",n,o,e.data):c.log.info("[%s] response %j",o,e.data)}catch(e){}return e},rejected:async e=>{try{const t=e.config,n=t[c.RequestMethodNameSymbol],o=t[c.RequestLogIdSymbol];n?c.log.info("%s [%s] error %j",n,o,e.response?.data):c.log.error("[%s] error %j",o,e.response?.data)}catch(e){}throw e}};static setMethodName(e,t){try{e[c.RequestMethodNameSymbol]=t}catch(e){}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}t.AuthClient=c},81261:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AwsClient=void 0;const o=n(27647),r=n(142),i=n(69157),a=n(37870),s=n(17842);class c extends r.BaseExternalAccountClient{environmentId;awsSecurityCredentialsSupplier;regionalCredVerificationUrl;awsRequestSigner;region;static#u="https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15";static AWS_EC2_METADATA_IPV4_ADDRESS="169.254.169.254";static AWS_EC2_METADATA_IPV6_ADDRESS="fd00:ec2::254";constructor(e){super(e);const t=(0,a.originalOrCamelOptions)(e),n=t.get("credential_source"),o=t.get("aws_security_credentials_supplier");if(!n&&!o)throw new Error("A credential source or AWS security credentials supplier must be specified.");if(n&&o)throw new Error("Only one of credential source or AWS security credentials supplier can be specified.");if(o)this.awsSecurityCredentialsSupplier=o,this.regionalCredVerificationUrl=c.#u,this.credentialSourceType="programmatic";else{const e=(0,a.originalOrCamelOptions)(n);this.environmentId=e.get("environment_id");const t=e.get("region_url"),o=e.get("url"),r=e.get("imdsv2_session_token_url");this.awsSecurityCredentialsSupplier=new i.DefaultAwsSecurityCredentialsSupplier({regionUrl:t,securityCredentialsUrl:o,imdsV2SessionTokenUrl:r}),this.regionalCredVerificationUrl=e.get("regional_cred_verification_url"),this.credentialSourceType="aws",this.validateEnvironmentId()}this.awsRequestSigner=null,this.region=""}validateEnvironmentId(){const e=this.environmentId?.match(/^(aws)(\d+)$/);if(!e||!this.regionalCredVerificationUrl)throw new Error('No valid AWS "credential_source" provided');if(1!==parseInt(e[2],10))throw new Error(`aws version "${e[2]}" is not supported in the current build.`)}async retrieveSubjectToken(){this.awsRequestSigner||(this.region=await this.awsSecurityCredentialsSupplier.getAwsRegion(this.supplierContext),this.awsRequestSigner=new o.AwsRequestSigner(async()=>this.awsSecurityCredentialsSupplier.getAwsSecurityCredentials(this.supplierContext),this.region));const e=await this.awsRequestSigner.getRequestOptions({...c.RETRY_CONFIG,url:this.regionalCredVerificationUrl.replace("{region}",this.region),method:"POST"}),t=[];return s.Gaxios.mergeHeaders({"x-goog-cloud-target-resource":this.audience},e.headers).forEach((e,n)=>t.push({key:n,value:e})),encodeURIComponent(JSON.stringify({url:e.url,method:e.method,headers:t}))}}t.AwsClient=c},27647:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AwsRequestSigner=void 0;const o=n(17842),r=n(88851),i="AWS4-HMAC-SHA256",a="aws4_request";async function s(e,t,n){return await e.signWithHmacSha256(t,n)}t.AwsRequestSigner=class{getCredentials;region;crypto;constructor(e,t){this.getCredentials=e,this.region=t,this.crypto=(0,r.createCrypto)()}async getRequestOptions(e){if(!e.url)throw new RangeError('"url" is required in "amzOptions"');const t="object"==typeof e.data?JSON.stringify(e.data):e.data,n=e.url,c=e.method||"GET",u=e.body||t,l=e.headers,d=await this.getCredentials(),p=new URL(n);if("string"!=typeof u&&void 0!==u)throw new TypeError(`'requestPayload' is expected to be a string if provided. Got: ${u}`);const h=await async function(e){const t=o.Gaxios.mergeHeaders(e.additionalAmzHeaders),n=e.requestPayload||"",c=e.host.split(".")[0],u=new Date,l=u.toISOString().replace(/[-:]/g,"").replace(/\.[0-9]+/,""),d=u.toISOString().replace(/[-]/g,"").replace(/T.*/,"");e.securityCredentials.token&&t.set("x-amz-security-token",e.securityCredentials.token);const p=o.Gaxios.mergeHeaders({host:e.host},t.has("date")?{}:{"x-amz-date":l},t);let h="";const f=[...p.keys()].sort();f.forEach(e=>{h+=`${e}:${p.get(e)}\n`});const m=f.join(";"),g=await e.crypto.sha256DigestHex(n),b=`${e.method.toUpperCase()}\n${e.canonicalUri}\n${e.canonicalQuerystring}\n${h}\n${m}\n${g}`,y=`${d}/${e.region}/${c}/${a}`,v=`${i}\n${l}\n${y}\n`+await e.crypto.sha256DigestHex(b),_=await async function(e,t,n,o,r){const i=await s(e,`AWS4${t}`,n),a=await s(e,i,o),c=await s(e,a,r);return await s(e,c,"aws4_request")}(e.crypto,e.securityCredentials.secretAccessKey,d,e.region,c),w=await s(e.crypto,_,v),O=`${i} Credential=${e.securityCredentials.accessKeyId}/${y}, SignedHeaders=${m}, Signature=${(0,r.fromArrayBufferToHex)(w)}`;return{amzDate:t.has("date")?void 0:l,authorizationHeader:O,canonicalQuerystring:e.canonicalQuerystring}}({crypto:this.crypto,host:p.host,canonicalUri:p.pathname,canonicalQuerystring:p.search.slice(1),method:c,region:this.region,securityCredentials:d,requestPayload:u,additionalAmzHeaders:l}),f=o.Gaxios.mergeHeaders(h.amzDate?{"x-amz-date":h.amzDate}:{},{authorization:h.authorizationHeader,host:p.host},l||{});d.token&&o.Gaxios.mergeHeaders(f,{"x-amz-security-token":d.token});const m={url:n,method:c,headers:f};return void 0!==u&&(m.body=u),m}}},142:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseExternalAccountClient=t.CLOUD_RESOURCE_MANAGER=t.EXTERNAL_ACCOUNT_TYPE=t.EXPIRATION_TIME_OFFSET=void 0;const o=n(17842),r=n(2203),i=n(34810),a=n(121),s=n(37870),c=n(65470),u="https://www.googleapis.com/auth/cloud-platform";t.EXPIRATION_TIME_OFFSET=3e5,t.EXTERNAL_ACCOUNT_TYPE="external_account",t.CLOUD_RESOURCE_MANAGER="https://cloudresourcemanager.googleapis.com/v1/projects/";class l extends i.AuthClient{scopes;projectNumber;audience;subjectTokenType;stsCredential;clientAuth;credentialSourceType;cachedAccessToken;serviceAccountImpersonationUrl;serviceAccountImpersonationLifetime;workforcePoolUserProject;configLifetimeRequested;tokenUrl;cloudResourceManagerURL;supplierContext;#l=null;constructor(e){super(e);const n=(0,s.originalOrCamelOptions)(e),o=n.get("type");if(o&&o!==t.EXTERNAL_ACCOUNT_TYPE)throw new Error(`Expected "${t.EXTERNAL_ACCOUNT_TYPE}" type but received "${e.type}"`);const r=n.get("client_id"),i=n.get("client_secret");this.tokenUrl=n.get("token_url")??"https://sts.{universeDomain}/v1/token".replace("{universeDomain}",this.universeDomain);const c=n.get("subject_token_type"),l=n.get("workforce_pool_user_project"),d=n.get("service_account_impersonation_url"),p=n.get("service_account_impersonation"),h=(0,s.originalOrCamelOptions)(p).get("token_lifetime_seconds");this.cloudResourceManagerURL=new URL(n.get("cloud_resource_manager_url")||`https://cloudresourcemanager.${this.universeDomain}/v1/projects/`),r&&(this.clientAuth={confidentialClientType:"basic",clientId:r,clientSecret:i}),this.stsCredential=new a.StsCredentials({tokenExchangeEndpoint:this.tokenUrl,clientAuthentication:this.clientAuth}),this.scopes=n.get("scopes")||[u],this.cachedAccessToken=null,this.audience=n.get("audience"),this.subjectTokenType=c,this.workforcePoolUserProject=l;const f=new RegExp("//iam\\.googleapis\\.com/locations/[^/]+/workforcePools/[^/]+/providers/.+");if(this.workforcePoolUserProject&&!this.audience.match(f))throw new Error("workforcePoolUserProject should not be set for non-workforce pool credentials.");this.serviceAccountImpersonationUrl=d,this.serviceAccountImpersonationLifetime=h,this.serviceAccountImpersonationLifetime?this.configLifetimeRequested=!0:(this.configLifetimeRequested=!1,this.serviceAccountImpersonationLifetime=3600),this.projectNumber=this.getProjectNumber(this.audience),this.supplierContext={audience:this.audience,subjectTokenType:this.subjectTokenType,transporter:this.transporter}}getServiceAccountEmail(){if(this.serviceAccountImpersonationUrl){if(this.serviceAccountImpersonationUrl.length>256)throw new RangeError(`URL is too long: ${this.serviceAccountImpersonationUrl}`);const e=/serviceAccounts\/(?<email>[^:]+):generateAccessToken$/.exec(this.serviceAccountImpersonationUrl);return e?.groups?.email||null}return null}setCredentials(e){super.setCredentials(e),this.cachedAccessToken=e}async getAccessToken(){return this.cachedAccessToken&&!this.isExpired(this.cachedAccessToken)||await this.refreshAccessTokenAsync(),{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){const e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(!t)return this.requestAsync(e);this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response))}async getProjectId(){const e=this.projectNumber||this.workforcePoolUserProject;if(this.projectId)return this.projectId;if(e){const t=await this.getRequestHeaders(),n={...l.RETRY_CONFIG,headers:t,url:`${this.cloudResourceManagerURL.toString()}${e}`,responseType:"json"};i.AuthClient.setMethodName(n,"getProjectId");const o=await this.transporter.request(n);return this.projectId=o.data.projectId,this.projectId}return null}async requestAsync(e,t=!1){let n;try{const t=await this.getRequestHeaders();e.headers=o.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),n=await this.transporter.request(e)}catch(n){const o=n.response;if(o){const n=o.status,i=o.config.data instanceof r.Readable;if(!t&&(401===n||403===n)&&!i&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return n}async refreshAccessTokenAsync(){this.#l=this.#l||this.#d();try{return await this.#l}finally{this.#l=null}}async#d(){const e=await this.retrieveSubjectToken(),t={grantType:"urn:ietf:params:oauth:grant-type:token-exchange",audience:this.audience,requestedTokenType:"urn:ietf:params:oauth:token-type:access_token",subjectToken:e,subjectTokenType:this.subjectTokenType,scope:this.serviceAccountImpersonationUrl?[u]:this.getScopesArray()},n=!this.clientAuth&&this.workforcePoolUserProject?{userProject:this.workforcePoolUserProject}:void 0,o=new Headers({"x-goog-api-client":this.getMetricsHeaderValue()}),r=await this.stsCredential.exchangeToken(t,o,n);return this.serviceAccountImpersonationUrl?this.cachedAccessToken=await this.getImpersonatedAccessToken(r.access_token):r.expires_in?this.cachedAccessToken={access_token:r.access_token,expiry_date:(new Date).getTime()+1e3*r.expires_in,res:r.res}:this.cachedAccessToken={access_token:r.access_token,res:r.res},this.credentials={},Object.assign(this.credentials,this.cachedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedAccessToken.expiry_date,access_token:this.cachedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedAccessToken}getProjectNumber(e){const t=e.match(/\/projects\/([^/]+)/);return t?t[1]:null}async getImpersonatedAccessToken(e){const t={...l.RETRY_CONFIG,url:this.serviceAccountImpersonationUrl,method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},data:{scope:this.getScopesArray(),lifetime:this.serviceAccountImpersonationLifetime+"s"},responseType:"json"};i.AuthClient.setMethodName(t,"getImpersonatedAccessToken");const n=await this.transporter.request(t),o=n.data;return{access_token:o.accessToken,expiry_date:new Date(o.expireTime).getTime(),res:n}}isExpired(e){const t=(new Date).getTime();return!!e.expiry_date&&t>=e.expiry_date-this.eagerRefreshThresholdMillis}getScopesArray(){return"string"==typeof this.scopes?[this.scopes]:this.scopes||[u]}getMetricsHeaderValue(){const e=process.version.replace(/^v/,""),t=void 0!==this.serviceAccountImpersonationUrl,n=this.credentialSourceType?this.credentialSourceType:"unknown";return`gl-node/${e} auth/${c.pkg.version} google-byoid-sdk source/${n} sa-impersonation/${t} config-lifetime/${this.configLifetimeRequested}`}getTokenUrl(){return this.tokenUrl}}t.BaseExternalAccountClient=l},26129:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CertificateSubjectTokenSupplier=t.InvalidConfigurationError=t.CertificateSourceUnavailableError=t.CERTIFICATE_CONFIGURATION_ENV_VARIABLE=void 0;const o=n(37870),r=n(79896),i=n(76982),a=n(65692);t.CERTIFICATE_CONFIGURATION_ENV_VARIABLE="GOOGLE_API_CERTIFICATE_CONFIG";class s extends Error{constructor(e){super(e),this.name="CertificateSourceUnavailableError"}}t.CertificateSourceUnavailableError=s;class c extends Error{constructor(e){super(e),this.name="InvalidConfigurationError"}}t.InvalidConfigurationError=c;t.CertificateSubjectTokenSupplier=class{certificateConfigPath;trustChainPath;cert;key;constructor(e){if(!e.useDefaultCertificateConfig&&!e.certificateConfigLocation)throw new c("Either `useDefaultCertificateConfig` must be true or a `certificateConfigLocation` must be provided.");if(e.useDefaultCertificateConfig&&e.certificateConfigLocation)throw new c("Both `useDefaultCertificateConfig` and `certificateConfigLocation` cannot be provided.");this.trustChainPath=e.trustChainPath,this.certificateConfigPath=e.certificateConfigLocation??""}async createMtlsHttpsAgent(){if(!this.key||!this.cert)throw new c("Cannot create mTLS Agent with missing certificate or key");return new a.Agent({key:this.key,cert:this.cert})}async getSubjectToken(){this.certificateConfigPath=await this.#p();const{certPath:e,keyPath:t}=await this.#h();return({cert:this.cert,key:this.key}=await this.#f(e,t)),await this.#m(this.cert)}async#p(){const e=this.certificateConfigPath;if(e){if(await(0,o.isValidFile)(e))return e;throw new s(`Provided certificate config path is invalid: ${e}`)}const n=process.env[t.CERTIFICATE_CONFIGURATION_ENV_VARIABLE];if(n){if(await(0,o.isValidFile)(n))return n;throw new s(`Path from environment variable "${t.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" is invalid: ${n}`)}const r=(0,o.getWellKnownCertificateConfigFileLocation)();if(await(0,o.isValidFile)(r))return r;throw new s(`Could not find certificate configuration file. Searched override path, the "${t.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" env var, and the gcloud path (${r}).`)}async#h(){const e=this.certificateConfigPath;let t;try{t=await r.promises.readFile(e,"utf8")}catch(t){throw new s(`Failed to read certificate config file at: ${e}`)}try{const n=JSON.parse(t),o=n?.cert_configs?.workload?.cert_path,r=n?.cert_configs?.workload?.key_path;if(!o||!r)throw new c(`Certificate config file (${e}) is missing required "cert_path" or "key_path" in the workload config.`);return{certPath:o,keyPath:r}}catch(t){if(t instanceof c)throw t;throw new c(`Failed to parse certificate config from ${e}: ${t.message}`)}}async#f(e,t){let n,o;try{n=await r.promises.readFile(e),new i.X509Certificate(n)}catch(t){const n=t instanceof Error?t.message:String(t);throw new s(`Failed to read certificate file at ${e}: ${n}`)}try{o=await r.promises.readFile(t),(0,i.createPrivateKey)(o)}catch(e){const n=e instanceof Error?e.message:String(e);throw new s(`Failed to read private key file at ${t}: ${n}`)}return{cert:n,key:o}}async#m(e){const t=new i.X509Certificate(e);if(!this.trustChainPath)return JSON.stringify([t.raw.toString("base64")]);try{const e=await r.promises.readFile(this.trustChainPath,"utf8"),n=(e.match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g)??[]).map((e,t)=>{try{return new i.X509Certificate(e)}catch(e){const n=e instanceof Error?e.message:String(e);throw new c(`Failed to parse certificate at index ${t} in trust chain file ${this.trustChainPath}: ${n}`)}}),o=n.findIndex(e=>t.raw.equals(e.raw));let a;if(-1===o)a=[t,...n];else{if(0!==o)throw new c(`Leaf certificate exists in the trust chain but is not the first entry (found at index ${o}).`);a=n}return JSON.stringify(a.map(e=>e.raw.toString("base64")))}catch(e){if(e instanceof c)throw e;const t=e instanceof Error?e.message:String(e);throw new s(`Failed to process certificate chain from ${this.trustChainPath}: ${t}`)}}}},20977:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Compute=void 0;const o=n(17842),r=n(69595),i=n(10091);class a extends i.OAuth2Client{serviceAccountEmail;scopes;constructor(e={}){super(e),this.credentials={expiry_date:1,refresh_token:"compute-placeholder"},this.serviceAccountEmail=e.serviceAccountEmail||"default",this.scopes=Array.isArray(e.scopes)?e.scopes:e.scopes?[e.scopes]:[]}async refreshTokenNoCache(){const e=`service-accounts/${this.serviceAccountEmail}/token`;let t;try{const n={property:e};this.scopes.length>0&&(n.params={scopes:this.scopes.join(",")}),t=await r.instance(n)}catch(e){throw e instanceof o.GaxiosError&&(e.message=`Could not refresh access token: ${e.message}`,this.wrapError(e)),e}const n=t;return t&&t.expires_in&&(n.expiry_date=(new Date).getTime()+1e3*t.expires_in,delete n.expires_in),this.emit("tokens",n),{tokens:n,res:null}}async fetchIdToken(e){const t=`service-accounts/${this.serviceAccountEmail}/identity?format=full&audience=${e}`;let n;try{const e={property:t};n=await r.instance(e)}catch(e){throw e instanceof Error&&(e.message=`Could not fetch ID token: ${e.message}`),e}return n}wrapError(e){const t=e.response;t&&t.status&&(e.status=t.status,403===t.status?e.message="A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified: "+e.message:404===t.status&&(e.message="A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: "+e.message))}}t.Compute=a},69157:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultAwsSecurityCredentialsSupplier=void 0;const o=n(34810);t.DefaultAwsSecurityCredentialsSupplier=class{regionUrl;securityCredentialsUrl;imdsV2SessionTokenUrl;additionalGaxiosOptions;constructor(e){this.regionUrl=e.regionUrl,this.securityCredentialsUrl=e.securityCredentialsUrl,this.imdsV2SessionTokenUrl=e.imdsV2SessionTokenUrl,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getAwsRegion(e){if(this.#g)return this.#g;const t=new Headers;if(!this.#g&&this.imdsV2SessionTokenUrl&&t.set("x-aws-ec2-metadata-token",await this.#b(e.transporter)),!this.regionUrl)throw new RangeError('Unable to determine AWS region due to missing "options.credential_source.region_url"');const n={...this.additionalGaxiosOptions,url:this.regionUrl,method:"GET",responseType:"text",headers:t};o.AuthClient.setMethodName(n,"getAwsRegion");const r=await e.transporter.request(n);return r.data.substr(0,r.data.length-1)}async getAwsSecurityCredentials(e){if(this.#y)return this.#y;const t=new Headers;this.imdsV2SessionTokenUrl&&t.set("x-aws-ec2-metadata-token",await this.#b(e.transporter));const n=await this.#v(t,e.transporter),o=await this.#_(n,t,e.transporter);return{accessKeyId:o.AccessKeyId,secretAccessKey:o.SecretAccessKey,token:o.Token}}async#b(e){const t={...this.additionalGaxiosOptions,url:this.imdsV2SessionTokenUrl,method:"PUT",responseType:"text",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"300"}};o.AuthClient.setMethodName(t,"#getImdsV2SessionToken");return(await e.request(t)).data}async#v(e,t){if(!this.securityCredentialsUrl)throw new Error('Unable to determine AWS role name due to missing "options.credential_source.url"');const n={...this.additionalGaxiosOptions,url:this.securityCredentialsUrl,method:"GET",responseType:"text",headers:e};o.AuthClient.setMethodName(n,"#getAwsRoleName");return(await t.request(n)).data}async#_(e,t,n){const r={...this.additionalGaxiosOptions,url:`${this.securityCredentialsUrl}/${e}`,headers:t,responseType:"json"};o.AuthClient.setMethodName(r,"#retrieveAwsSecurityCredentials");return(await n.request(r)).data}get#g(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||null}get#y(){return process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY?{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,token:process.env.AWS_SESSION_TOKEN}:null}}},77556:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DownscopedClient=t.EXPIRATION_TIME_OFFSET=t.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;const o=n(17842),r=n(2203),i=n(34810),a=n(121);t.MAX_ACCESS_BOUNDARY_RULES_COUNT=10,t.EXPIRATION_TIME_OFFSET=3e5;class s extends i.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(e,n={accessBoundary:{accessBoundaryRules:[]}}){if(super(e instanceof i.AuthClient?{}:e),e instanceof i.AuthClient?(this.authClient=e,this.credentialAccessBoundary=n):(this.authClient=e.authClient,this.credentialAccessBoundary=e.credentialAccessBoundary),0===this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length)throw new Error("At least one access boundary rule needs to be defined.");if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>t.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw new Error(`The provided access boundary has more than ${t.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(const e of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(0===e.availablePermissions.length)throw new Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new a.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(e){if(!e.expiry_date)throw new Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(e),this.cachedDownscopedAccessToken=e}async getAccessToken(){return this.cachedDownscopedAccessToken&&!this.isExpired(this.cachedDownscopedAccessToken)||await this.refreshAccessTokenAsync(),{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){const e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(!t)return this.requestAsync(e);this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response))}async requestAsync(e,t=!1){let n;try{const t=await this.getRequestHeaders();e.headers=o.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),n=await this.transporter.request(e)}catch(n){const o=n.response;if(o){const n=o.status,i=o.config.data instanceof r.Readable;if(!t&&(401===n||403===n)&&!i&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return n}async refreshAccessTokenAsync(){const e={grantType:"urn:ietf:params:oauth:grant-type:token-exchange",requestedTokenType:"urn:ietf:params:oauth:token-type:access_token",subjectToken:(await this.authClient.getAccessToken()).token,subjectTokenType:"urn:ietf:params:oauth:token-type:access_token"},t=await this.stsCredential.exchangeToken(e,void 0,this.credentialAccessBoundary),n=this.authClient.credentials?.expiry_date||null,o=t.expires_in?(new Date).getTime()+1e3*t.expires_in:n;return this.cachedDownscopedAccessToken={access_token:t.access_token,expiry_date:o,res:t.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(e){const t=(new Date).getTime();return!!e.expiry_date&&t>=e.expiry_date-this.eagerRefreshThresholdMillis}}t.DownscopedClient=s},60963:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GCPEnv=void 0,t.clear=function(){i=void 0},t.getEnv=async function(){if(i)return i;return i=async function(){let e=r.NONE;e=process.env.GAE_SERVICE||process.env.GAE_MODULE_NAME?r.APP_ENGINE:process.env.FUNCTION_NAME||process.env.FUNCTION_TARGET?r.CLOUD_FUNCTIONS:await async function(){return o.isAvailable()}()?await async function(){try{return await o.instance("attributes/cluster-name"),!0}catch(e){return!1}}()?r.KUBERNETES_ENGINE:process.env.K_CONFIGURATION?r.CLOUD_RUN:process.env.CLOUD_RUN_JOB?r.CLOUD_RUN_JOBS:r.COMPUTE_ENGINE:r.NONE;return e}(),i};const o=n(69595);var r;let i;!function(e){e.APP_ENGINE="APP_ENGINE",e.KUBERNETES_ENGINE="KUBERNETES_ENGINE",e.CLOUD_FUNCTIONS="CLOUD_FUNCTIONS",e.COMPUTE_ENGINE="COMPUTE_ENGINE",e.CLOUD_RUN="CLOUD_RUN",e.CLOUD_RUN_JOBS="CLOUD_RUN_JOBS",e.NONE="NONE"}(r||(t.GCPEnv=r={}))},43247:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidSubjectTokenError=t.InvalidMessageFieldError=t.InvalidCodeFieldError=t.InvalidTokenTypeFieldError=t.InvalidExpirationTimeFieldError=t.InvalidSuccessFieldError=t.InvalidVersionFieldError=t.ExecutableResponseError=t.ExecutableResponse=void 0;const n="urn:ietf:params:oauth:token-type:saml2",o="urn:ietf:params:oauth:token-type:id_token",r="urn:ietf:params:oauth:token-type:jwt";t.ExecutableResponse=class{version;success;expirationTime;tokenType;errorCode;errorMessage;subjectToken;constructor(e){if(!e.version)throw new a("Executable response must contain a 'version' field.");if(void 0===e.success)throw new s("Executable response must contain a 'success' field.");if(this.version=e.version,this.success=e.success,this.success){if(this.expirationTime=e.expiration_time,this.tokenType=e.token_type,this.tokenType!==n&&this.tokenType!==o&&this.tokenType!==r)throw new c(`Executable response must contain a 'token_type' field when successful and it must be one of ${o}, ${r}, or ${n}.`);if(this.tokenType===n){if(!e.saml_response)throw new d(`Executable response must contain a 'saml_response' field when token_type=${n}.`);this.subjectToken=e.saml_response}else{if(!e.id_token)throw new d(`Executable response must contain a 'id_token' field when token_type=${o} or ${r}.`);this.subjectToken=e.id_token}}else{if(!e.code)throw new u("Executable response must contain a 'code' field when unsuccessful.");if(!e.message)throw new l("Executable response must contain a 'message' field when unsuccessful.");this.errorCode=e.code,this.errorMessage=e.message}}isValid(){return!this.isExpired()&&this.success}isExpired(){return void 0!==this.expirationTime&&this.expirationTime<Math.round(Date.now()/1e3)}};class i extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}t.ExecutableResponseError=i;class a extends i{}t.InvalidVersionFieldError=a;class s extends i{}t.InvalidSuccessFieldError=s;t.InvalidExpirationTimeFieldError=class extends i{};class c extends i{}t.InvalidTokenTypeFieldError=c;class u extends i{}t.InvalidCodeFieldError=u;class l extends i{}t.InvalidMessageFieldError=l;class d extends i{}t.InvalidSubjectTokenError=d},34240:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExternalAccountAuthorizedUserClient=t.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=void 0;const o=n(34810),r=n(6653),i=n(17842),a=n(2203),s=n(142);t.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE="external_account_authorized_user";class c extends r.OAuthClientAuthHandler{#w;constructor(e){super(e),this.#w=e.tokenRefreshEndpoint}async refreshToken(e,t){const n={...c.RETRY_CONFIG,url:this.#w,method:"POST",headers:t,data:new URLSearchParams({grant_type:"refresh_token",refresh_token:e}),responseType:"json"};o.AuthClient.setMethodName(n,"refreshToken"),this.applyClientAuthenticationOptions(n);try{const e=await this.transporter.request(n),t=e.data;return t.res=e,t}catch(e){if(e instanceof i.GaxiosError&&e.response)throw(0,r.getErrorFromOAuthErrorResponse)(e.response.data,e);throw e}}}class u extends o.AuthClient{cachedAccessToken;externalAccountAuthorizedUserHandler;refreshToken;constructor(e){super(e),e.universe_domain&&(this.universeDomain=e.universe_domain),this.refreshToken=e.refresh_token;const t={confidentialClientType:"basic",clientId:e.client_id,clientSecret:e.client_secret};this.externalAccountAuthorizedUserHandler=new c({tokenRefreshEndpoint:e.token_url??"https://sts.{universeDomain}/v1/oauthtoken".replace("{universeDomain}",this.universeDomain),transporter:this.transporter,clientAuthentication:t}),this.cachedAccessToken=null,this.quotaProjectId=e.quota_project_id,this.eagerRefreshThresholdMillis="number"!=typeof e?.eagerRefreshThresholdMillis?s.EXPIRATION_TIME_OFFSET:e.eagerRefreshThresholdMillis,this.forceRefreshOnFailure=!!e?.forceRefreshOnFailure}async getAccessToken(){return this.cachedAccessToken&&!this.isExpired(this.cachedAccessToken)||await this.refreshAccessTokenAsync(),{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){const e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(!t)return this.requestAsync(e);this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response))}async requestAsync(e,t=!1){let n;try{const t=await this.getRequestHeaders();e.headers=i.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),n=await this.transporter.request(e)}catch(n){const o=n.response;if(o){const n=o.status,r=o.config.data instanceof a.Readable;if(!t&&(401===n||403===n)&&!r&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return n}async refreshAccessTokenAsync(){const e=await this.externalAccountAuthorizedUserHandler.refreshToken(this.refreshToken);return this.cachedAccessToken={access_token:e.access_token,expiry_date:(new Date).getTime()+1e3*e.expires_in,res:e.res},void 0!==e.refresh_token&&(this.refreshToken=e.refresh_token),this.cachedAccessToken}isExpired(e){const t=(new Date).getTime();return!!e.expiry_date&&t>=e.expiry_date-this.eagerRefreshThresholdMillis}}t.ExternalAccountAuthorizedUserClient=u},88323:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExternalAccountClient=void 0;const o=n(142),r=n(29960),i=n(81261),a=n(46077);t.ExternalAccountClient=class{constructor(){throw new Error("ExternalAccountClients should be initialized via: ExternalAccountClient.fromJSON(), directly via explicit constructors, eg. new AwsClient(options), new IdentityPoolClient(options), newPluggableAuthClientOptions, or via new GoogleAuth(options).getClient()")}static fromJSON(e){return e&&e.type===o.EXTERNAL_ACCOUNT_TYPE?e.credential_source?.environment_id?new i.AwsClient(e):e.credential_source?.executable?new a.PluggableAuthClient(e):new r.IdentityPoolClient(e):null}}},10932:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileSubjectTokenSupplier=void 0;const o=n(39023),r=n(79896),i=(0,o.promisify)(r.readFile??(()=>{})),a=(0,o.promisify)(r.realpath??(()=>{})),s=(0,o.promisify)(r.lstat??(()=>{}));t.FileSubjectTokenSupplier=class{filePath;formatType;subjectTokenFieldName;constructor(e){this.filePath=e.filePath,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName}async getSubjectToken(){let e,t=this.filePath;try{if(t=await a(t),!(await s(t)).isFile())throw new Error}catch(e){throw e instanceof Error&&(e.message=`The file at ${t} does not exist, or it is not a file. ${e.message}`),e}const n=await i(t,{encoding:"utf8"});if("text"===this.formatType)e=n;else if("json"===this.formatType&&this.subjectTokenFieldName){e=JSON.parse(n)[this.subjectTokenFieldName]}if(!e)throw new Error("Unable to parse the subject_token from the credential_source file");return e}}},95934:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GoogleAuth=t.GoogleAuthExceptionMessages=void 0;const o=n(35317),r=n(79896),i=n(17842),a=n(69595),s=n(70857),c=n(16928),u=n(88851),l=n(20977),d=n(12718),p=n(60963),h=n(75277),f=n(99807),m=n(39964),g=n(88323),b=n(142),y=n(34810),v=n(34240),_=n(37870);t.GoogleAuthExceptionMessages={API_KEY_WITH_CREDENTIALS:"API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.",NO_PROJECT_ID_FOUND:"Unable to detect a Project Id in the current environment. \nTo learn more about authentication and Google APIs, visit: \nhttps://cloud.google.com/docs/authentication/getting-started",NO_CREDENTIALS_FOUND:"Unable to find credentials in current environment. \nTo learn more about authentication and Google APIs, visit: \nhttps://cloud.google.com/docs/authentication/getting-started",NO_ADC_FOUND:"Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",NO_UNIVERSE_DOMAIN_FOUND:"Unable to detect a Universe Domain in the current environment.\nTo learn more about Universe Domain retrieval, visit: \nhttps://cloud.google.com/compute/docs/metadata/predefined-metadata-keys"};t.GoogleAuth=class{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#O=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(e={}){if(this._cachedProjectId=e.projectId||null,this.cachedCredential=e.authClient||null,this.keyFilename=e.keyFilename||e.keyFile,this.scopes=e.scopes,this.clientOptions=e.clientOptions||{},this.jsonContent=e.credentials||null,this.apiKey=e.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw new RangeError(t.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);e.universeDomain&&(this.clientOptions.universeDomain=e.universeDomain)}setGapicJWTValues(e){e.defaultServicePath=this.defaultServicePath,e.useJWTAccessWithScope=this.useJWTAccessWithScope,e.defaultScopes=this.defaultScopes}getProjectId(e){if(!e)return this.getProjectIdAsync();this.getProjectIdAsync().then(t=>e(null,t),e)}async getProjectIdOptional(){try{return await this.getProjectId()}catch(e){if(e instanceof Error&&e.message===t.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;throw e}}async findAndCacheProjectId(){let e=null;if(e||=await this.getProductionProjectId(),e||=await this.getFileProjectId(),e||=await this.getDefaultServiceProjectId(),e||=await this.getGCEProjectId(),e||=await this.getExternalAccountClientProjectId(),e)return this._cachedProjectId=e,e;throw new Error(t.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){return this._cachedProjectId?this._cachedProjectId:(this._findProjectIdPromise||(this._findProjectIdPromise=this.findAndCacheProjectId()),this._findProjectIdPromise)}async getUniverseDomainFromMetadataServer(){let e;try{e=await a.universe("universe-domain"),e||=y.DEFAULT_UNIVERSE}catch(t){if(!t||404!==t?.response?.status)throw t;e=y.DEFAULT_UNIVERSE}return e}async getUniverseDomain(){let e=(0,_.originalOrCamelOptions)(this.clientOptions).get("universe_domain");try{e??=(await this.getClient()).universeDomain}catch{e??=y.DEFAULT_UNIVERSE}return e}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(e={},t){let n;if("function"==typeof e?t=e:n=e,!t)return this.getApplicationDefaultAsync(n);this.getApplicationDefaultAsync(n).then(e=>t(null,e.credential,e.projectId),t)}async getApplicationDefaultAsync(e={}){if(this.cachedCredential)return await this.#S(this.cachedCredential,null);let n;if(n=await this._tryGetApplicationCredentialsFromEnvironmentVariable(e),n)return n instanceof h.JWT?n.scopes=this.scopes:n instanceof b.BaseExternalAccountClient&&(n.scopes=this.getAnyScopes()),await this.#S(n);if(n=await this._tryGetApplicationCredentialsFromWellKnownFile(e),n)return n instanceof h.JWT?n.scopes=this.scopes:n instanceof b.BaseExternalAccountClient&&(n.scopes=this.getAnyScopes()),await this.#S(n);if(await this._checkIsGCE())return e.scopes=this.getAnyScopes(),await this.#S(new l.Compute(e));throw new Error(t.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#S(e,t=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){const n=await this.getProjectIdOptional();return t&&(e.quotaProjectId=t),this.cachedCredential=e,{credential:e,projectId:n}}async _checkIsGCE(){return void 0===this.checkIsGCE&&(this.checkIsGCE=a.getGCPResidency()||await a.isAvailable()),this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(e){const t=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!t||0===t.length)return null;try{return this._getApplicationCredentialsFromFilePath(t,e)}catch(e){throw e instanceof Error&&(e.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${e.message}`),e}}async _tryGetApplicationCredentialsFromWellKnownFile(e){let t=null;if(this._isWindows())t=process.env.APPDATA;else{const e=process.env.HOME;e&&(t=c.join(e,".config"))}if(t&&(t=c.join(t,"gcloud","application_default_credentials.json"),r.existsSync(t)||(t=null)),!t)return null;return await this._getApplicationCredentialsFromFilePath(t,e)}async _getApplicationCredentialsFromFilePath(e,t={}){if(!e||0===e.length)throw new Error("The file path is invalid.");try{if(e=r.realpathSync(e),!r.lstatSync(e).isFile())throw new Error}catch(t){throw t instanceof Error&&(t.message=`The file at ${e} does not exist, or it is not a file. ${t.message}`),t}const n=r.createReadStream(e);return this.fromStream(n,t)}fromImpersonatedJSON(e){if(!e)throw new Error("Must pass in a JSON object containing an impersonated refresh token");if(e.type!==m.IMPERSONATED_ACCOUNT_TYPE)throw new Error(`The incoming JSON object does not have the "${m.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!e.source_credentials)throw new Error("The incoming JSON object does not contain a source_credentials field");if(!e.service_account_impersonation_url)throw new Error("The incoming JSON object does not contain a service_account_impersonation_url field");const t=this.fromJSON(e.source_credentials);if(e.service_account_impersonation_url?.length>256)throw new RangeError(`Target principal is too long: ${e.service_account_impersonation_url}`);const n=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(e.service_account_impersonation_url)?.groups?.target;if(!n)throw new RangeError(`Cannot extract target principal from ${e.service_account_impersonation_url}`);const o=(this.scopes||e.scopes||this.defaultScopes)??[];return new m.Impersonated({...e,sourceClient:t,targetPrincipal:n,targetScopes:Array.isArray(o)?o:[o]})}fromJSON(e,t={}){let n;const o=(0,_.originalOrCamelOptions)(t).get("universe_domain");return e.type===f.USER_REFRESH_ACCOUNT_TYPE?(n=new f.UserRefreshClient(t),n.fromJSON(e)):e.type===m.IMPERSONATED_ACCOUNT_TYPE?n=this.fromImpersonatedJSON(e):e.type===b.EXTERNAL_ACCOUNT_TYPE?(n=g.ExternalAccountClient.fromJSON({...e,...t}),n.scopes=this.getAnyScopes()):e.type===v.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE?n=new v.ExternalAccountAuthorizedUserClient({...e,...t}):(t.scopes=this.scopes,n=new h.JWT(t),this.setGapicJWTValues(n),n.fromJSON(e)),o&&(n.universeDomain=o),n}_cacheClientFromJSON(e,t){const n=this.fromJSON(e,t);return this.jsonContent=e,this.cachedCredential=n,n}fromStream(e,t={},n){let o={};if("function"==typeof t?n=t:o=t,!n)return this.fromStreamAsync(e,o);this.fromStreamAsync(e,o).then(e=>n(null,e),n)}fromStreamAsync(e,t){return new Promise((n,o)=>{if(!e)throw new Error("Must pass in a stream containing the Google auth settings.");const r=[];e.setEncoding("utf8").on("error",o).on("data",e=>r.push(e)).on("end",()=>{try{try{const e=JSON.parse(r.join("")),o=this._cacheClientFromJSON(e,t);return n(o)}catch(e){if(!this.keyFilename)throw e;const t=new h.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=t,this.setGapicJWTValues(t),n(t)}}catch(e){return o(e)}})})}fromAPIKey(e,t={}){return new h.JWT({...t,apiKey:e})}_isWindows(){const e=s.platform();return!!(e&&e.length>=3&&"win"===e.substring(0,3).toLowerCase())}async getDefaultServiceProjectId(){return new Promise(e=>{(0,o.exec)("gcloud config config-helper --format json",(t,n)=>{if(!t&&n)try{const t=JSON.parse(n).configuration.properties.core.project;return void e(t)}catch(e){}e(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){const e=await this.getClient();if(e&&e.projectId)return e.projectId}const e=await this._tryGetApplicationCredentialsFromEnvironmentVariable();return e?e.projectId:null}async getExternalAccountClientProjectId(){if(!this.jsonContent||this.jsonContent.type!==b.EXTERNAL_ACCOUNT_TYPE)return null;const e=await this.getClient();return await e.getProjectId()}async getGCEProjectId(){try{return await a.project("project-id")}catch(e){return null}}getCredentials(e){if(!e)return this.getCredentialsAsync();this.getCredentialsAsync().then(t=>e(null,t),e)}async getCredentialsAsync(){const e=await this.getClient();if(e instanceof m.Impersonated)return{client_email:e.getTargetPrincipal()};if(e instanceof b.BaseExternalAccountClient){const t=e.getServiceAccountEmail();if(t)return{client_email:t,universe_domain:e.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){const[e,t]=await Promise.all([a.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:e,universe_domain:t}}throw new Error(t.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#O=this.#O||this.#x();try{return await this.#O}finally{this.#O=null}}async#x(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);if(this.keyFilename){const e=c.resolve(this.keyFilename),t=r.createReadStream(e);return await this.fromStreamAsync(t,this.clientOptions)}if(this.apiKey){const e=await this.fromAPIKey(this.apiKey,this.clientOptions);e.scopes=this.scopes;const{credential:t}=await this.#S(e);return t}{const{credential:e}=await this.getApplicationDefaultAsync(this.clientOptions);return e}}async getIdTokenClient(e){const t=await this.getClient();if(!("fetchIdToken"in t))throw new Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new d.IdTokenClient({targetAudience:e,idTokenProvider:t})}async getAccessToken(){const e=await this.getClient();return(await e.getAccessToken()).token}async getRequestHeaders(e){return(await this.getClient()).getRequestHeaders(e)}async authorizeRequest(e={}){const t=e.url,n=await this.getClient(),o=await n.getRequestHeaders(t);return e.headers=i.Gaxios.mergeHeaders(e.headers,o),e}async fetch(...e){return(await this.getClient()).fetch(...e)}async request(e){return(await this.getClient()).request(e)}getEnv(){return(0,p.getEnv)()}async sign(e,t){const n=await this.getClient(),o=await this.getUniverseDomain();if(t=t||`https://iamcredentials.${o}/v1/projects/-/serviceAccounts/`,n instanceof m.Impersonated){return(await n.sign(e)).signedBlob}const r=(0,u.createCrypto)();if(n instanceof h.JWT&&n.key){return await r.sign(n.key,e)}const i=await this.getCredentials();if(!i.client_email)throw new Error("Cannot sign data without `client_email`.");return this.signBlob(r,i.client_email,e,t)}async signBlob(e,t,n,o){const r=new URL(o+`${t}:signBlob`);return(await this.request({method:"POST",url:r.href,data:{payload:e.encodeBase64StringUtf8(n)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}}},89390:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IAMAuth=void 0;t.IAMAuth=class{selector;token;constructor(e,t){this.selector=e,this.token=t,this.selector=e,this.token=t}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}},29960:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IdentityPoolClient=void 0;const o=n(142),r=n(37870),i=n(10932),a=n(24627),s=n(26129),c=n(121),u=n(17842);class l extends o.BaseExternalAccountClient{subjectTokenSupplier;constructor(e){super(e);const t=(0,r.originalOrCamelOptions)(e),n=t.get("credential_source"),o=t.get("subject_token_supplier");if(!n&&!o)throw new Error("A credential source or subject token supplier must be specified.");if(n&&o)throw new Error("Only one of credential source or subject token supplier can be specified.");if(o)this.subjectTokenSupplier=o,this.credentialSourceType="programmatic";else{const e=(0,r.originalOrCamelOptions)(n),t=(0,r.originalOrCamelOptions)(e.get("format")),o=t.get("type")||"text",c=t.get("subject_token_field_name");if("json"!==o&&"text"!==o)throw new Error(`Invalid credential_source format "${o}"`);if("json"===o&&!c)throw new Error("Missing subject_token_field_name for JSON credential_source format");const u=e.get("file"),d=e.get("url"),p=e.get("certificate"),h=e.get("headers");if(u&&d||d&&p||u&&p)throw new Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.');if(u)this.credentialSourceType="file",this.subjectTokenSupplier=new i.FileSubjectTokenSupplier({filePath:u,formatType:o,subjectTokenFieldName:c});else if(d)this.credentialSourceType="url",this.subjectTokenSupplier=new a.UrlSubjectTokenSupplier({url:d,formatType:o,subjectTokenFieldName:c,headers:h,additionalGaxiosOptions:l.RETRY_CONFIG});else{if(!p)throw new Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.');{this.credentialSourceType="certificate";const e=new s.CertificateSubjectTokenSupplier({useDefaultCertificateConfig:p.use_default_certificate_config,certificateConfigLocation:p.certificate_config_location,trustChainPath:p.trust_chain_path});this.subjectTokenSupplier=e}}}}async retrieveSubjectToken(){const e=await this.subjectTokenSupplier.getSubjectToken(this.supplierContext);if(this.subjectTokenSupplier instanceof s.CertificateSubjectTokenSupplier){const e=await this.subjectTokenSupplier.createMtlsHttpsAgent();this.stsCredential=new c.StsCredentials({tokenExchangeEndpoint:this.getTokenUrl(),clientAuthentication:this.clientAuth,transporter:new u.Gaxios({agent:e})}),this.transporter=new u.Gaxios({...this.transporter.defaults||{},agent:e})}return e}}t.IdentityPoolClient=l},12718:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IdTokenClient=void 0;const o=n(10091);class r extends o.OAuth2Client{targetAudience;idTokenProvider;constructor(e){super(e),this.targetAudience=e.targetAudience,this.idTokenProvider=e.idTokenProvider}async getRequestMetadataAsync(){if(!this.credentials.id_token||!this.credentials.expiry_date||this.isTokenExpiring()){const e=await this.idTokenProvider.fetchIdToken(this.targetAudience);this.credentials={id_token:e,expiry_date:this.getIdTokenExpiryDate(e)}}return{headers:new Headers({authorization:"Bearer "+this.credentials.id_token})}}getIdTokenExpiryDate(e){const t=e.split(".")[1];if(t){return 1e3*JSON.parse(Buffer.from(t,"base64").toString("ascii")).exp}}}t.IdTokenClient=r},39964:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Impersonated=t.IMPERSONATED_ACCOUNT_TYPE=void 0;const o=n(10091),r=n(17842),i=n(37870);t.IMPERSONATED_ACCOUNT_TYPE="impersonated_service_account";class a extends o.OAuth2Client{sourceClient;targetPrincipal;targetScopes;delegates;lifetime;endpoint;constructor(e={}){super(e),this.credentials={expiry_date:1,refresh_token:"impersonated-placeholder"},this.sourceClient=e.sourceClient??new o.OAuth2Client,this.targetPrincipal=e.targetPrincipal??"",this.delegates=e.delegates??[],this.targetScopes=e.targetScopes??[],this.lifetime=e.lifetime??3600;if(!!(0,i.originalOrCamelOptions)(e).get("universe_domain")){if(this.sourceClient.universeDomain!==this.universeDomain)throw new RangeError(`Universe domain ${this.sourceClient.universeDomain} in source credentials does not match ${this.universeDomain} universe domain set for impersonated credentials.`)}else this.universeDomain=this.sourceClient.universeDomain;this.endpoint=e.endpoint??`https://iamcredentials.${this.universeDomain}`}async sign(e){await this.sourceClient.getAccessToken();const t=`projects/-/serviceAccounts/${this.targetPrincipal}`,n=`${this.endpoint}/v1/${t}:signBlob`,o={delegates:this.delegates,payload:Buffer.from(e).toString("base64")};return(await this.sourceClient.request({...a.RETRY_CONFIG,url:n,data:o,method:"POST"})).data}getTargetPrincipal(){return this.targetPrincipal}async refreshToken(){try{await this.sourceClient.getAccessToken();const e="projects/-/serviceAccounts/"+this.targetPrincipal,t=`${this.endpoint}/v1/${e}:generateAccessToken`,n={delegates:this.delegates,scope:this.targetScopes,lifetime:this.lifetime+"s"},o=await this.sourceClient.request({...a.RETRY_CONFIG,url:t,data:n,method:"POST"}),r=o.data;return this.credentials.access_token=r.accessToken,this.credentials.expiry_date=Date.parse(r.expireTime),{tokens:this.credentials,res:o}}catch(e){if(!(e instanceof Error))throw e;let t=0,n="";throw e instanceof r.GaxiosError&&(t=e?.response?.data?.error?.status,n=e?.response?.data?.error?.message),t&&n?(e.message=`${t}: unable to impersonate: ${n}`,e):(e.message=`unable to impersonate: ${e}`,e)}}async fetchIdToken(e,t){await this.sourceClient.getAccessToken();const n=`projects/-/serviceAccounts/${this.targetPrincipal}`,o=`${this.endpoint}/v1/${n}:generateIdToken`,r={delegates:this.delegates,audience:e,includeEmail:t?.includeEmail??!0,useEmailAzp:t?.includeEmail??!0};return(await this.sourceClient.request({...a.RETRY_CONFIG,url:o,data:r,method:"POST"})).data.token}}t.Impersonated=a},27060:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JWTAccess=void 0;const o=n(33324),r=n(37870),i={alg:"RS256",typ:"JWT"};class a{email;key;keyId;projectId;eagerRefreshThresholdMillis;cache=new r.LRUCache({capacity:500,maxAge:36e5});constructor(e,t,n,o){this.email=e,this.key=t,this.keyId=n,this.eagerRefreshThresholdMillis=o??3e5}getCachedKey(e,t){let n=e;if(t&&Array.isArray(t)&&t.length?n=e?`${e}_${t.join("_")}`:`${t.join("_")}`:"string"==typeof t&&(n=e?`${e}_${t}`:t),!n)throw Error("Scopes or url must be provided");return n}getRequestHeaders(e,t,n){const r=this.getCachedKey(e,n),s=this.cache.get(r),c=Date.now();if(s&&s.expiration-c>this.eagerRefreshThresholdMillis)return new Headers(s.headers);const u=Math.floor(Date.now()/1e3),l=a.getExpirationTime(u);let d;if(Array.isArray(n)&&(n=n.join(" ")),d=n?{iss:this.email,sub:this.email,scope:n,exp:l,iat:u}:{iss:this.email,sub:this.email,aud:e,exp:l,iat:u},t)for(const e in d)if(t[e])throw new Error(`The '${e}' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.`);const p=this.keyId?{...i,kid:this.keyId}:i,h=Object.assign(d,t),f=o.sign({header:p,payload:h,secret:this.key}),m=new Headers({authorization:`Bearer ${f}`});return this.cache.set(r,{expiration:1e3*l,headers:m}),m}static getExpirationTime(e){return e+3600}fromJSON(e){if(!e)throw new Error("Must pass in a JSON object containing the service account auth settings.");if(!e.client_email)throw new Error("The incoming JSON object does not contain a client_email field");if(!e.private_key)throw new Error("The incoming JSON object does not contain a private_key field");this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id}fromStream(e,t){if(!t)return this.fromStreamAsync(e);this.fromStreamAsync(e).then(()=>t(),t)}fromStreamAsync(e){return new Promise((t,n)=>{e||n(new Error("Must pass in a stream containing the service account auth settings."));let o="";e.setEncoding("utf8").on("data",e=>o+=e).on("error",n).on("end",()=>{try{const e=JSON.parse(o);this.fromJSON(e),t()}catch(e){n(e)}})})}}t.JWTAccess=a},75277:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JWT=void 0;const o=n(33067),r=n(53165),i=n(27060),a=n(10091),s=n(34810);class c extends a.OAuth2Client{email;keyFile;key;keyId;defaultScopes;scopes;scope;subject;gtoken;additionalClaims;useJWTAccessWithScope;defaultServicePath;access;constructor(e={}){super(e),this.email=e.email,this.keyFile=e.keyFile,this.key=e.key,this.keyId=e.keyId,this.scopes=e.scopes,this.subject=e.subject,this.additionalClaims=e.additionalClaims,this.credentials={refresh_token:"jwt-placeholder",expiry_date:1}}createScoped(e){const t=new c(this);return t.scopes=e,t}async getRequestMetadataAsync(e){e=this.defaultServicePath?`https://${this.defaultServicePath}/`:e;const t=!this.hasUserScopes()&&e||this.useJWTAccessWithScope&&this.hasAnyScopes()||this.universeDomain!==s.DEFAULT_UNIVERSE;if(this.subject&&this.universeDomain!==s.DEFAULT_UNIVERSE)throw new RangeError(`Service Account user is configured for the credential. Domain-wide delegation is not supported in universes other than ${s.DEFAULT_UNIVERSE}`);if(!this.apiKey&&t){if(this.additionalClaims&&this.additionalClaims.target_audience){const{tokens:e}=await this.refreshToken();return{headers:this.addSharedMetadataHeaders(new Headers({authorization:`Bearer ${e.id_token}`}))}}{let t;this.access||(this.access=new i.JWTAccess(this.email,this.key,this.keyId,this.eagerRefreshThresholdMillis)),this.hasUserScopes()?t=this.scopes:e||(t=this.defaultScopes);const n=this.useJWTAccessWithScope||this.universeDomain!==s.DEFAULT_UNIVERSE,o=await this.access.getRequestHeaders(e??void 0,this.additionalClaims,n?t:void 0);return{headers:this.addSharedMetadataHeaders(o)}}}return this.hasAnyScopes()||this.apiKey?super.getRequestMetadataAsync(e):{headers:new Headers}}async fetchIdToken(e){const t=new o.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:{target_audience:e},transporter:this.transporter});if(await t.getToken({forceRefresh:!0}),!t.idToken)throw new Error("Unknown error: Failed to fetch ID token");return t.idToken}hasUserScopes(){return!!this.scopes&&this.scopes.length>0}hasAnyScopes(){return!!(this.scopes&&this.scopes.length>0)||!!(this.defaultScopes&&this.defaultScopes.length>0)}authorize(e){if(!e)return this.authorizeAsync();this.authorizeAsync().then(t=>e(null,t),e)}async authorizeAsync(){const e=await this.refreshToken();if(!e)throw new Error("No result returned");return this.credentials=e.tokens,this.credentials.refresh_token="jwt-placeholder",this.key=this.gtoken.googleTokenOptions?.key,this.email=this.gtoken.googleTokenOptions?.iss,e.tokens}async refreshTokenNoCache(){const e=this.createGToken(),t={access_token:(await e.getToken({forceRefresh:this.isTokenExpiring()})).access_token,token_type:"Bearer",expiry_date:e.expiresAt,id_token:e.idToken};return this.emit("tokens",t),{res:null,tokens:t}}createGToken(){return this.gtoken||(this.gtoken=new o.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:this.additionalClaims,transporter:this.transporter})),this.gtoken}fromJSON(e){if(!e)throw new Error("Must pass in a JSON object containing the service account auth settings.");if(!e.client_email)throw new Error("The incoming JSON object does not contain a client_email field");if(!e.private_key)throw new Error("The incoming JSON object does not contain a private_key field");this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(!t)return this.fromStreamAsync(e);this.fromStreamAsync(e).then(()=>t(),t)}fromStreamAsync(e){return new Promise((t,n)=>{if(!e)throw new Error("Must pass in a stream containing the service account auth settings.");let o="";e.setEncoding("utf8").on("error",n).on("data",e=>o+=e).on("end",()=>{try{const e=JSON.parse(o);this.fromJSON(e),t()}catch(e){n(e)}})})}fromAPIKey(e){if("string"!=typeof e)throw new Error("Must provide an API Key string.");this.apiKey=e}async getCredentials(){if(this.key)return{private_key:this.key,client_email:this.email};if(this.keyFile){this.createGToken();const e=await(0,r.getCredentials)(this.keyFile);return{private_key:e.privateKey,client_email:e.clientEmail}}throw new Error("A key or a keyFile must be provided to getCredentials.")}}t.JWT=c},53882:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LoginTicket=void 0;t.LoginTicket=class{envelope;payload;constructor(e,t){this.envelope=e,this.payload=t}getEnvelope(){return this.envelope}getPayload(){return this.payload}getUserId(){const e=this.getPayload();return e&&e.sub?e.sub:null}getAttributes(){return{envelope:this.getEnvelope(),payload:this.getPayload()}}}},10091:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Client=t.ClientAuthentication=t.CertificateFormat=t.CodeChallengeMethod=void 0;const o=n(17842),r=n(83480),i=n(2203),a=n(325),s=n(37870),c=n(88851),u=n(34810),l=n(53882);var d,p,h;!function(e){e.Plain="plain",e.S256="S256"}(d||(t.CodeChallengeMethod=d={})),function(e){e.PEM="PEM",e.JWK="JWK"}(p||(t.CertificateFormat=p={})),function(e){e.ClientSecretPost="ClientSecretPost",e.ClientSecretBasic="ClientSecretBasic",e.None="None"}(h||(t.ClientAuthentication=h={}));class f extends u.AuthClient{redirectUri;certificateCache={};certificateExpiry=null;certificateCacheFormat=p.PEM;refreshTokenPromises=new Map;endpoints;issuers;clientAuthentication;_clientId;_clientSecret;refreshHandler;constructor(e={},t,n){super("object"==typeof e?e:{}),"object"!=typeof e&&(e={clientId:e,clientSecret:t,redirectUri:n}),this._clientId=e.clientId||e.client_id,this._clientSecret=e.clientSecret||e.client_secret,this.redirectUri=e.redirectUri||e.redirect_uris?.[0],this.endpoints={tokenInfoUrl:"https://oauth2.googleapis.com/tokeninfo",oauth2AuthBaseUrl:"https://accounts.google.com/o/oauth2/v2/auth",oauth2TokenUrl:"https://oauth2.googleapis.com/token",oauth2RevokeUrl:"https://oauth2.googleapis.com/revoke",oauth2FederatedSignonPemCertsUrl:"https://www.googleapis.com/oauth2/v1/certs",oauth2FederatedSignonJwkCertsUrl:"https://www.googleapis.com/oauth2/v3/certs",oauth2IapPublicKeyUrl:"https://www.gstatic.com/iap/verify/public_key",...e.endpoints},this.clientAuthentication=e.clientAuthentication||h.ClientSecretPost,this.issuers=e.issuers||["accounts.google.com","https://accounts.google.com",this.universeDomain]}static GOOGLE_TOKEN_INFO_URL="https://oauth2.googleapis.com/tokeninfo";static CLOCK_SKEW_SECS_=300;static DEFAULT_MAX_TOKEN_LIFETIME_SECS_=86400;generateAuthUrl(e={}){if(e.code_challenge_method&&!e.code_challenge)throw new Error("If a code_challenge_method is provided, code_challenge must be included.");e.response_type=e.response_type||"code",e.client_id=e.client_id||this._clientId,e.redirect_uri=e.redirect_uri||this.redirectUri,Array.isArray(e.scope)&&(e.scope=e.scope.join(" "));return this.endpoints.oauth2AuthBaseUrl.toString()+"?"+r.stringify(e)}generateCodeVerifier(){throw new Error("generateCodeVerifier is removed, please use generateCodeVerifierAsync instead.")}async generateCodeVerifierAsync(){const e=(0,c.createCrypto)(),t=e.randomBytesBase64(96).replace(/\+/g,"~").replace(/=/g,"_").replace(/\//g,"-");return{codeVerifier:t,codeChallenge:(await e.sha256DigestBase64(t)).split("=")[0].replace(/\+/g,"-").replace(/\//g,"_")}}getToken(e,t){const n="string"==typeof e?{code:e}:e;if(!t)return this.getTokenAsync(n);this.getTokenAsync(n).then(e=>t(null,e.tokens,e.res),e=>t(e,null,e.response))}async getTokenAsync(e){const t=this.endpoints.oauth2TokenUrl.toString(),n=new Headers,o={client_id:e.client_id||this._clientId,code_verifier:e.codeVerifier,code:e.code,grant_type:"authorization_code",redirect_uri:e.redirect_uri||this.redirectUri};if(this.clientAuthentication===h.ClientSecretBasic){const e=Buffer.from(`${this._clientId}:${this._clientSecret}`);n.set("authorization",`Basic ${e.toString("base64")}`)}this.clientAuthentication===h.ClientSecretPost&&(o.client_secret=this._clientSecret);const r={...f.RETRY_CONFIG,method:"POST",url:t,data:new URLSearchParams((0,s.removeUndefinedValuesInObject)(o)),headers:n};u.AuthClient.setMethodName(r,"getTokenAsync");const i=await this.transporter.request(r),a=i.data;return i.data&&i.data.expires_in&&(a.expiry_date=(new Date).getTime()+1e3*i.data.expires_in,delete a.expires_in),this.emit("tokens",a),{tokens:a,res:i}}async refreshToken(e){if(!e)return this.refreshTokenNoCache(e);if(this.refreshTokenPromises.has(e))return this.refreshTokenPromises.get(e);const t=this.refreshTokenNoCache(e).then(t=>(this.refreshTokenPromises.delete(e),t),t=>{throw this.refreshTokenPromises.delete(e),t});return this.refreshTokenPromises.set(e,t),t}async refreshTokenNoCache(e){if(!e)throw new Error("No refresh token is set.");const t=this.endpoints.oauth2TokenUrl.toString(),n={refresh_token:e,client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token"};let r;try{const e={...f.RETRY_CONFIG,method:"POST",url:t,data:new URLSearchParams((0,s.removeUndefinedValuesInObject)(n))};u.AuthClient.setMethodName(e,"refreshTokenNoCache"),r=await this.transporter.request(e)}catch(e){throw e instanceof o.GaxiosError&&"invalid_grant"===e.message&&e.response?.data&&/ReAuth/i.test(e.response.data.error_description)&&(e.message=JSON.stringify(e.response.data)),e}const i=r.data;return r.data&&r.data.expires_in&&(i.expiry_date=(new Date).getTime()+1e3*r.data.expires_in,delete i.expires_in),this.emit("tokens",i),{tokens:i,res:r}}refreshAccessToken(e){if(!e)return this.refreshAccessTokenAsync();this.refreshAccessTokenAsync().then(t=>e(null,t.credentials,t.res),e)}async refreshAccessTokenAsync(){const e=await this.refreshToken(this.credentials.refresh_token),t=e.tokens;return t.refresh_token=this.credentials.refresh_token,this.credentials=t,{credentials:this.credentials,res:e.res}}getAccessToken(e){if(!e)return this.getAccessTokenAsync();this.getAccessTokenAsync().then(t=>e(null,t.token,t.res),e)}async getAccessTokenAsync(){if(!this.credentials.access_token||this.isTokenExpiring()){if(!this.credentials.refresh_token){if(!this.refreshHandler)throw new Error("No refresh token or refresh handler callback is set.");{const e=await this.processAndValidateRefreshHandler();if(e?.access_token)return this.setCredentials(e),{token:this.credentials.access_token}}}const e=await this.refreshAccessTokenAsync();if(!e.credentials||e.credentials&&!e.credentials.access_token)throw new Error("Could not refresh access token.");return{token:e.credentials.access_token,res:e.res}}return{token:this.credentials.access_token}}async getRequestHeaders(e){return(await this.getRequestMetadataAsync(e)).headers}async getRequestMetadataAsync(e){const t=this.credentials;if(!(t.access_token||t.refresh_token||this.apiKey||this.refreshHandler))throw new Error("No access, refresh token, API key or refresh handler callback is set.");if(t.access_token&&!this.isTokenExpiring()){t.token_type=t.token_type||"Bearer";const e=new Headers({authorization:t.token_type+" "+t.access_token});return{headers:this.addSharedMetadataHeaders(e)}}if(this.refreshHandler){const e=await this.processAndValidateRefreshHandler();if(e?.access_token){this.setCredentials(e);const t=new Headers({authorization:"Bearer "+this.credentials.access_token});return{headers:this.addSharedMetadataHeaders(t)}}}if(this.apiKey)return{headers:new Headers({"X-Goog-Api-Key":this.apiKey})};let n=null,o=null;try{n=await this.refreshToken(t.refresh_token),o=n.tokens}catch(e){const t=e;throw!t.response||403!==t.response.status&&404!==t.response.status||(t.message=`Could not refresh access token: ${t.message}`),t}const r=this.credentials;r.token_type=r.token_type||"Bearer",o.refresh_token=r.refresh_token,this.credentials=o;const i=new Headers({authorization:r.token_type+" "+o.access_token});return{headers:this.addSharedMetadataHeaders(i),res:n.res}}static getRevokeTokenUrl(e){return(new f).getRevokeTokenURL(e).toString()}getRevokeTokenURL(e){const t=new URL(this.endpoints.oauth2RevokeUrl);return t.searchParams.append("token",e),t}revokeToken(e,t){const n={...f.RETRY_CONFIG,url:this.getRevokeTokenURL(e).toString(),method:"POST"};if(u.AuthClient.setMethodName(n,"revokeToken"),!t)return this.transporter.request(n);this.transporter.request(n).then(e=>t(null,e),t)}revokeCredentials(e){if(!e)return this.revokeCredentialsAsync();this.revokeCredentialsAsync().then(t=>e(null,t),e)}async revokeCredentialsAsync(){const e=this.credentials.access_token;if(this.credentials={},e)return this.revokeToken(e);throw new Error("No access token to revoke.")}request(e,t){if(!t)return this.requestAsync(e);this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response))}async requestAsync(e,t=!1){try{const t=await this.getRequestMetadataAsync();return e.headers=o.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t.headers),this.apiKey&&e.headers.set("X-Goog-Api-Key",this.apiKey),await this.transporter.request(e)}catch(n){const o=n.response;if(o){const n=o.status,r=this.credentials&&this.credentials.access_token&&this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure),a=this.credentials&&this.credentials.access_token&&!this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure)&&this.refreshHandler,s=o.config.data instanceof i.Readable,c=401===n||403===n;if(!t&&c&&!s&&r)return await this.refreshAccessTokenAsync(),this.requestAsync(e,!0);if(!t&&c&&!s&&a){const t=await this.processAndValidateRefreshHandler();return t?.access_token&&this.setCredentials(t),this.requestAsync(e,!0)}}throw n}}verifyIdToken(e,t){if(t&&"function"!=typeof t)throw new Error("This method accepts an options object as the first parameter, which includes the idToken, audience, and maxExpiry.");if(!t)return this.verifyIdTokenAsync(e);this.verifyIdTokenAsync(e).then(e=>t(null,e),t)}async verifyIdTokenAsync(e){if(!e.idToken)throw new Error("The verifyIdToken method requires an ID Token");const t=await this.getFederatedSignonCertsAsync();return await this.verifySignedJwtWithCertsAsync(e.idToken,t.certs,e.audience,this.issuers,e.maxExpiry)}async getTokenInfo(e){const{data:t}=await this.transporter.request({...f.RETRY_CONFIG,method:"POST",headers:{"content-type":"application/x-www-form-urlencoded;charset=UTF-8",authorization:`Bearer ${e}`},url:this.endpoints.tokenInfoUrl.toString()}),n=Object.assign({expiry_date:(new Date).getTime()+1e3*t.expires_in,scopes:t.scope.split(" ")},t);return delete n.expires_in,delete n.scope,n}getFederatedSignonCerts(e){if(!e)return this.getFederatedSignonCertsAsync();this.getFederatedSignonCertsAsync().then(t=>e(null,t.certs,t.res),e)}async getFederatedSignonCertsAsync(){const e=(new Date).getTime(),t=(0,c.hasBrowserCrypto)()?p.JWK:p.PEM;if(this.certificateExpiry&&e<this.certificateExpiry.getTime()&&this.certificateCacheFormat===t)return{certs:this.certificateCache,format:t};let n,o;switch(t){case p.PEM:o=this.endpoints.oauth2FederatedSignonPemCertsUrl.toString();break;case p.JWK:o=this.endpoints.oauth2FederatedSignonJwkCertsUrl.toString();break;default:throw new Error(`Unsupported certificate format ${t}`)}try{const e={...f.RETRY_CONFIG,url:o};u.AuthClient.setMethodName(e,"getFederatedSignonCertsAsync"),n=await this.transporter.request(e)}catch(e){throw e instanceof Error&&(e.message=`Failed to retrieve verification certificates: ${e.message}`),e}const r=n?.headers.get("cache-control");let i=-1;if(r){const e=/max-age=(?<maxAge>[0-9]+)/.exec(r)?.groups?.maxAge;e&&(i=1e3*Number(e))}let a={};switch(t){case p.PEM:a=n.data;break;case p.JWK:for(const e of n.data.keys)a[e.kid]=e;break;default:throw new Error(`Unsupported certificate format ${t}`)}const s=new Date;return this.certificateExpiry=-1===i?null:new Date(s.getTime()+i),this.certificateCache=a,this.certificateCacheFormat=t,{certs:a,format:t,res:n}}getIapPublicKeys(e){if(!e)return this.getIapPublicKeysAsync();this.getIapPublicKeysAsync().then(t=>e(null,t.pubkeys,t.res),e)}async getIapPublicKeysAsync(){let e;const t=this.endpoints.oauth2IapPublicKeyUrl.toString();try{const n={...f.RETRY_CONFIG,url:t};u.AuthClient.setMethodName(n,"getIapPublicKeysAsync"),e=await this.transporter.request(n)}catch(e){throw e instanceof Error&&(e.message=`Failed to retrieve verification certificates: ${e.message}`),e}return{pubkeys:e.data,res:e}}verifySignedJwtWithCerts(){throw new Error("verifySignedJwtWithCerts is removed, please use verifySignedJwtWithCertsAsync instead.")}async verifySignedJwtWithCertsAsync(e,t,n,o,r){const i=(0,c.createCrypto)();r||(r=f.DEFAULT_MAX_TOKEN_LIFETIME_SECS_);const s=e.split(".");if(3!==s.length)throw new Error("Wrong number of segments in token: "+e);const u=s[0]+"."+s[1];let d,p,h=s[2];try{d=JSON.parse(i.decodeBase64StringUtf8(s[0]))}catch(e){throw e instanceof Error&&(e.message=`Can't parse token envelope: ${s[0]}': ${e.message}`),e}if(!d)throw new Error("Can't parse token envelope: "+s[0]);try{p=JSON.parse(i.decodeBase64StringUtf8(s[1]))}catch(e){throw e instanceof Error&&(e.message=`Can't parse token payload '${s[0]}`),e}if(!p)throw new Error("Can't parse token payload: "+s[1]);if(!Object.prototype.hasOwnProperty.call(t,d.kid))throw new Error("No pem found for envelope: "+JSON.stringify(d));const m=t[d.kid];"ES256"===d.alg&&(h=a.joseToDer(h,"ES256").toString("base64"));if(!await i.verify(m,u,h))throw new Error("Invalid token signature: "+e);if(!p.iat)throw new Error("No issue time in token: "+JSON.stringify(p));if(!p.exp)throw new Error("No expiration time in token: "+JSON.stringify(p));const g=Number(p.iat);if(isNaN(g))throw new Error("iat field using invalid format");const b=Number(p.exp);if(isNaN(b))throw new Error("exp field using invalid format");const y=(new Date).getTime()/1e3;if(b>=y+r)throw new Error("Expiration time too far in future: "+JSON.stringify(p));const v=g-f.CLOCK_SKEW_SECS_,_=b+f.CLOCK_SKEW_SECS_;if(y<v)throw new Error("Token used too early, "+y+" < "+v+": "+JSON.stringify(p));if(y>_)throw new Error("Token used too late, "+y+" > "+_+": "+JSON.stringify(p));if(o&&o.indexOf(p.iss)<0)throw new Error("Invalid issuer, expected one of ["+o+"], but got "+p.iss);if(null!=n){const e=p.aud;let t=!1;if(t=n.constructor===Array?n.indexOf(e)>-1:e===n,!t)throw new Error("Wrong recipient, payload audience != requiredAudience")}return new l.LoginTicket(d,p)}async processAndValidateRefreshHandler(){if(this.refreshHandler){const e=await this.refreshHandler();if(!e.access_token)throw new Error("No access token is returned by the refreshHandler callback.");return e}}isTokenExpiring(){const e=this.credentials.expiry_date;return!!e&&e<=(new Date).getTime()+this.eagerRefreshThresholdMillis}}t.OAuth2Client=f},6653:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OAuthClientAuthHandler=void 0,t.getErrorFromOAuthErrorResponse=function(e,t){const n=e.error,o=e.error_description,r=e.error_uri;let i=`Error code ${n}`;void 0!==o&&(i+=`: ${o}`);void 0!==r&&(i+=` - ${r}`);const a=new Error(i);if(t){const e=Object.keys(t);t.stack&&e.push("stack"),e.forEach(e=>{"message"!==e&&Object.defineProperty(a,e,{value:t[e],writable:!1,enumerable:!0})})}return a};const o=n(17842),r=n(88851),i=["PUT","POST","PATCH"];t.OAuthClientAuthHandler=class{#T=(0,r.createCrypto)();#P;transporter;constructor(e){e&&"clientId"in e?(this.#P=e,this.transporter=new o.Gaxios):(this.#P=e?.clientAuthentication,this.transporter=e?.transporter||new o.Gaxios)}applyClientAuthenticationOptions(e,t){e.headers=o.Gaxios.mergeHeaders(e.headers),this.injectAuthenticatedHeaders(e,t),t||this.injectAuthenticatedRequestBody(e)}injectAuthenticatedHeaders(e,t){if(t)e.headers=o.Gaxios.mergeHeaders(e.headers,{authorization:`Bearer ${t}`});else if("basic"===this.#P?.confidentialClientType){e.headers=o.Gaxios.mergeHeaders(e.headers);const t=this.#P.clientId,n=this.#P.clientSecret||"",r=this.#T.encodeBase64StringUtf8(`${t}:${n}`);o.Gaxios.mergeHeaders(e.headers,{authorization:`Basic ${r}`})}}injectAuthenticatedRequestBody(e){if("request-body"===this.#P?.confidentialClientType){const t=(e.method||"GET").toUpperCase();if(!i.includes(t))throw new Error(`${t} HTTP method does not support ${this.#P.confidentialClientType} client authentication`);const n=new Headers(e.headers).get("content-type");if(n?.startsWith("application/x-www-form-urlencoded")||e.data instanceof URLSearchParams){const t=new URLSearchParams(e.data??"");t.append("client_id",this.#P.clientId),t.append("client_secret",this.#P.clientSecret||""),e.data=t}else{if(!n?.startsWith("application/json"))throw new Error(`${n} content-types are not supported with ${this.#P.confidentialClientType} client authentication`);e.data=e.data||{},Object.assign(e.data,{client_id:this.#P.clientId,client_secret:this.#P.clientSecret||""})}}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}},62045:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PassThroughClient=void 0;const o=n(34810);class r extends o.AuthClient{async request(e){return this.transporter.request(e)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}t.PassThroughClient=r},46077:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PluggableAuthClient=t.ExecutableError=void 0;const o=n(142),r=n(43247),i=n(908);var a=n(908);Object.defineProperty(t,"ExecutableError",{enumerable:!0,get:function(){return a.ExecutableError}});const s=12e4;class c extends o.BaseExternalAccountClient{command;timeoutMillis;outputFile;handler;constructor(e){if(super(e),!e.credential_source.executable)throw new Error('No valid Pluggable Auth "credential_source" provided.');if(this.command=e.credential_source.executable.command,!this.command)throw new Error('No valid Pluggable Auth "credential_source" provided.');if(void 0===e.credential_source.executable.timeout_millis)this.timeoutMillis=3e4;else if(this.timeoutMillis=e.credential_source.executable.timeout_millis,this.timeoutMillis<5e3||this.timeoutMillis>s)throw new Error("Timeout must be between 5000 and 120000 milliseconds.");this.outputFile=e.credential_source.executable.output_file,this.handler=new i.PluggableAuthHandler({command:this.command,timeoutMillis:this.timeoutMillis,outputFile:this.outputFile}),this.credentialSourceType="executable"}async retrieveSubjectToken(){if("1"!==process.env.GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES)throw new Error("Pluggable Auth executables need to be explicitly allowed to run by setting the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment Variable to 1.");let e;if(this.outputFile&&(e=await this.handler.retrieveCachedResponse()),!e){const t=new Map;t.set("GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE",this.audience),t.set("GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE",this.subjectTokenType),t.set("GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE","0"),this.outputFile&&t.set("GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE",this.outputFile);const n=this.getServiceAccountEmail();n&&t.set("GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL",n),e=await this.handler.retrieveResponseFromExecutable(t)}if(e.version>1)throw new Error("Version of executable is not currently supported, maximum supported version is 1.");if(!e.success)throw new i.ExecutableError(e.errorMessage,e.errorCode);if(this.outputFile&&!e.expirationTime)throw new r.InvalidExpirationTimeFieldError("The executable response must contain the `expiration_time` field for successful responses when an output_file has been specified in the configuration.");if(e.isExpired())throw new Error("Executable response is expired.");return e.subjectToken}}t.PluggableAuthClient=c},908:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PluggableAuthHandler=t.ExecutableError=void 0;const o=n(43247),r=n(35317),i=n(79896);class a extends Error{code;constructor(e,t){super(`The executable failed with exit code: ${t} and error message: ${e}.`),this.code=t,Object.setPrototypeOf(this,new.target.prototype)}}t.ExecutableError=a;class s{commandComponents;timeoutMillis;outputFile;constructor(e){if(!e.command)throw new Error("No command provided.");if(this.commandComponents=s.parseCommand(e.command),this.timeoutMillis=e.timeoutMillis,!this.timeoutMillis)throw new Error("No timeoutMillis provided.");this.outputFile=e.outputFile}retrieveResponseFromExecutable(e){return new Promise((t,n)=>{const i=r.spawn(this.commandComponents[0],this.commandComponents.slice(1),{env:{...process.env,...Object.fromEntries(e)}});let s="";i.stdout.on("data",e=>{s+=e}),i.stderr.on("data",e=>{s+=e});const c=setTimeout(()=>(i.removeAllListeners(),i.kill(),n(new Error("The executable failed to finish within the timeout specified."))),this.timeoutMillis);i.on("close",e=>{if(clearTimeout(c),0!==e)return n(new a(s,e.toString()));try{const e=JSON.parse(s),n=new o.ExecutableResponse(e);return t(n)}catch(e){return e instanceof o.ExecutableResponseError?n(e):n(new o.ExecutableResponseError(`The executable returned an invalid response: ${s}`))}})})}async retrieveCachedResponse(){if(!this.outputFile||0===this.outputFile.length)return;let e;try{e=await i.promises.realpath(this.outputFile)}catch{return}if(!(await i.promises.lstat(e)).isFile())return;const t=await i.promises.readFile(e,{encoding:"utf8"});if(""!==t)try{const e=JSON.parse(t);return new o.ExecutableResponse(e).isValid()?new o.ExecutableResponse(e):void 0}catch(e){if(e instanceof o.ExecutableResponseError)throw e;throw new o.ExecutableResponseError(`The output file contained an invalid response: ${t}`)}}static parseCommand(e){const t=e.match(/(?:[^\s"]+|"[^"]*")+/g);if(!t)throw new Error(`Provided command: "${e}" could not be parsed.`);for(let e=0;e<t.length;e++)'"'===t[e][0]&&'"'===t[e].slice(-1)&&(t[e]=t[e].slice(1,-1));return t}}t.PluggableAuthHandler=s},99807:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRefreshClient=t.USER_REFRESH_ACCOUNT_TYPE=void 0;const o=n(10091),r=n(34810);t.USER_REFRESH_ACCOUNT_TYPE="authorized_user";class i extends o.OAuth2Client{_refreshToken;constructor(e,t,n,o,r){const i=e&&"object"==typeof e?e:{clientId:e,clientSecret:t,refreshToken:n,eagerRefreshThresholdMillis:o,forceRefreshOnFailure:r};super(i),this._refreshToken=i.refreshToken,this.credentials.refresh_token=i.refreshToken}async refreshTokenNoCache(){return super.refreshTokenNoCache(this._refreshToken)}async fetchIdToken(e){const t={...i.RETRY_CONFIG,url:this.endpoints.oauth2TokenUrl,method:"POST",data:new URLSearchParams({client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token",refresh_token:this._refreshToken,target_audience:e}),responseType:"json"};r.AuthClient.setMethodName(t,"fetchIdToken");return(await this.transporter.request(t)).data.id_token}fromJSON(e){if(!e)throw new Error("Must pass in a JSON object containing the user refresh token");if("authorized_user"!==e.type)throw new Error('The incoming JSON object does not have the "authorized_user" type');if(!e.client_id)throw new Error("The incoming JSON object does not contain a client_id field");if(!e.client_secret)throw new Error("The incoming JSON object does not contain a client_secret field");if(!e.refresh_token)throw new Error("The incoming JSON object does not contain a refresh_token field");this._clientId=e.client_id,this._clientSecret=e.client_secret,this._refreshToken=e.refresh_token,this.credentials.refresh_token=e.refresh_token,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(!t)return this.fromStreamAsync(e);this.fromStreamAsync(e).then(()=>t(),t)}async fromStreamAsync(e){return new Promise((t,n)=>{if(!e)return n(new Error("Must pass in a stream containing the user refresh token."));let o="";e.setEncoding("utf8").on("error",n).on("data",e=>o+=e).on("end",()=>{try{const e=JSON.parse(o);return this.fromJSON(e),t()}catch(e){return n(e)}})})}static fromJSON(e){const t=new i;return t.fromJSON(e),t}}t.UserRefreshClient=i},121:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StsCredentials=void 0;const o=n(17842),r=n(34810),i=n(6653),a=n(37870);class s extends i.OAuthClientAuthHandler{#C;constructor(e={tokenExchangeEndpoint:""},t){("object"!=typeof e||e instanceof URL)&&(e={tokenExchangeEndpoint:e,clientAuthentication:t}),super(e),this.#C=e.tokenExchangeEndpoint}async exchangeToken(e,t,n){const c={grant_type:e.grantType,resource:e.resource,audience:e.audience,scope:e.scope?.join(" "),requested_token_type:e.requestedTokenType,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType,actor_token:e.actingParty?.actorToken,actor_token_type:e.actingParty?.actorTokenType,options:n&&JSON.stringify(n)},u={...s.RETRY_CONFIG,url:this.#C.toString(),method:"POST",headers:t,data:new URLSearchParams((0,a.removeUndefinedValuesInObject)(c)),responseType:"json"};r.AuthClient.setMethodName(u,"exchangeToken"),this.applyClientAuthenticationOptions(u);try{const e=await this.transporter.request(u),t=e.data;return t.res=e,t}catch(e){if(e instanceof o.GaxiosError&&e.response)throw(0,i.getErrorFromOAuthErrorResponse)(e.response.data,e);throw e}}}t.StsCredentials=s},24627:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UrlSubjectTokenSupplier=void 0;const o=n(34810);t.UrlSubjectTokenSupplier=class{url;headers;formatType;subjectTokenFieldName;additionalGaxiosOptions;constructor(e){this.url=e.url,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName,this.headers=e.headers,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getSubjectToken(e){const t={...this.additionalGaxiosOptions,url:this.url,method:"GET",headers:this.headers,responseType:this.formatType};let n;if(o.AuthClient.setMethodName(t,"getSubjectToken"),"text"===this.formatType){n=(await e.transporter.request(t)).data}else if("json"===this.formatType&&this.subjectTokenFieldName){n=(await e.transporter.request(t)).data[this.subjectTokenFieldName]}if(!n)throw new Error("Unable to parse the subject_token from the credential_source URL");return n}}},93438:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserCrypto=void 0;const o=n(38793),r=n(96831);class i{constructor(){if("undefined"==typeof window||void 0===window.crypto||void 0===window.crypto.subtle)throw new Error("SubtleCrypto not found. Make sure it's an https:// website.")}async sha256DigestBase64(e){const t=(new TextEncoder).encode(e),n=await window.crypto.subtle.digest("SHA-256",t);return o.fromByteArray(new Uint8Array(n))}randomBytesBase64(e){const t=new Uint8Array(e);return window.crypto.getRandomValues(t),o.fromByteArray(t)}static padBase64(e){for(;e.length%4!=0;)e+="=";return e}async verify(e,t,n){const r={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},a=(new TextEncoder).encode(t),s=o.toByteArray(i.padBase64(n)),c=await window.crypto.subtle.importKey("jwk",e,r,!0,["verify"]);return await window.crypto.subtle.verify(r,c,Buffer.from(s),a)}async sign(e,t){const n={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},r=(new TextEncoder).encode(t),i=await window.crypto.subtle.importKey("jwk",e,n,!0,["sign"]),a=await window.crypto.subtle.sign(n,i,r);return o.fromByteArray(new Uint8Array(a))}decodeBase64StringUtf8(e){const t=o.toByteArray(i.padBase64(e));return(new TextDecoder).decode(t)}encodeBase64StringUtf8(e){const t=(new TextEncoder).encode(e);return o.fromByteArray(t)}async sha256DigestHex(e){const t=(new TextEncoder).encode(e),n=await window.crypto.subtle.digest("SHA-256",t);return(0,r.fromArrayBufferToHex)(n)}async signWithHmacSha256(e,t){const n="string"==typeof e?e:String.fromCharCode(...new Uint16Array(e)),o=new TextEncoder,r=await window.crypto.subtle.importKey("raw",o.encode(n),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return window.crypto.subtle.sign("HMAC",r,o.encode(t))}}t.BrowserCrypto=i},88851:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.createCrypto=function(){if(s())return new i.BrowserCrypto;return new a.NodeCrypto},t.hasBrowserCrypto=s;const i=n(93438),a=n(27388);function s(){return"undefined"!=typeof window&&void 0!==window.crypto&&void 0!==window.crypto.subtle}r(n(96831),t)},27388:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NodeCrypto=void 0;const o=n(76982);t.NodeCrypto=class{async sha256DigestBase64(e){return o.createHash("sha256").update(e).digest("base64")}randomBytesBase64(e){return o.randomBytes(e).toString("base64")}async verify(e,t,n){const r=o.createVerify("RSA-SHA256");return r.update(t),r.end(),r.verify(e,n,"base64")}async sign(e,t){const n=o.createSign("RSA-SHA256");return n.update(t),n.end(),n.sign(e,"base64")}decodeBase64StringUtf8(e){return Buffer.from(e,"base64").toString("utf-8")}encodeBase64StringUtf8(e){return Buffer.from(e,"utf-8").toString("base64")}async sha256DigestHex(e){return o.createHash("sha256").update(e).digest("hex")}async signWithHmacSha256(e,t){const n="string"==typeof e?e:(r=e,Buffer.from(r));var r;return function(e){const t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;++t)n[t]=e[t];return t}(o.createHmac("sha256",n).update(t).digest())}}},96831:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fromArrayBufferToHex=function(e){return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,"0")).join("")}},95412:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorWithCode=void 0;class n extends Error{code;constructor(e,t){super(e),this.code=t}}t.ErrorWithCode=n},53165:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getCredentials=async function(e){return p.create(e).getCredentials()};const o=n(16928),r=n(79896),i=n(39023),a=n(95412),s=r.readFile?(0,i.promisify)(r.readFile):async()=>{throw new a.ErrorWithCode("use key rather than keyFile.","MISSING_CREDENTIALS")};var c;!function(e){e.JSON=".json",e.DER=".der",e.CRT=".crt",e.PEM=".pem",e.P12=".p12",e.PFX=".pfx"}(c||(c={}));class u{keyFilePath;constructor(e){this.keyFilePath=e}async getCredentials(){const e=await s(this.keyFilePath,"utf8");let t;try{t=JSON.parse(e)}catch(e){throw new Error(`Invalid JSON key file: ${e.message}`)}const n=t.private_key,o=t.client_email;if(!n||!o)throw new a.ErrorWithCode("private_key and client_email are required.","MISSING_CREDENTIALS");return{privateKey:n,clientEmail:o}}}class l{keyFilePath;constructor(e){this.keyFilePath=e}async getCredentials(){return{privateKey:await s(this.keyFilePath,"utf8")}}}class d{async getCredentials(){throw new a.ErrorWithCode("*.p12 certificates are not supported after v6.1.2. Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.","UNKNOWN_CERTIFICATE_TYPE")}}class p{static create(e){switch(o.extname(e)){case c.JSON:return new u(e);case c.DER:case c.CRT:case c.PEM:return new l(e);case c.P12:case c.PFX:return new d;default:throw new a.ErrorWithCode("Unknown certificate type. Type is determined based on file extension. Current supported extensions are *.json, and *.pem.","UNKNOWN_CERTIFICATE_TYPE")}}}},17362:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getToken=async function(e){if(!e.transporter)throw new Error("No transporter set.");try{const t=r(e);return(await e.transporter.request(t)).data}catch(e){const t=e,n=t.response?.data;throw n?.error&&(t.message=`${n.error}: ${n.error_description}`),t}};const o=n(46490),r=e=>({method:"POST",url:"https://oauth2.googleapis.com/token",data:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:(0,o.getJwsSign)(e)}),responseType:"json",retryConfig:{httpMethodsToRetry:["POST"]}})},33067:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GoogleToken=void 0;const o=n(17842),r=n(71488),i=n(78024);t.GoogleToken=class{tokenOptions;tokenHandler;constructor(e){this.tokenOptions=e||{},this.tokenOptions.transporter=this.tokenOptions.transporter||{request:e=>(0,o.request)(e)},this.tokenOptions.iss||(this.tokenOptions.iss=this.tokenOptions.email),"object"==typeof this.tokenOptions.scope&&(this.tokenOptions.scope=this.tokenOptions.scope.join(" ")),this.tokenHandler=new r.TokenHandler(this.tokenOptions)}get expiresAt(){return this.tokenHandler.tokenExpiresAt}get accessToken(){return this.tokenHandler.token?.access_token}get idToken(){return this.tokenHandler.token?.id_token}get tokenType(){return this.tokenHandler.token?.token_type}get refreshToken(){return this.tokenHandler.token?.refresh_token}hasExpired(){return this.tokenHandler.hasExpired()}isTokenExpiring(){return this.tokenHandler.isTokenExpiring()}getToken(e,t={forceRefresh:!1}){let n;"function"==typeof e?n=e:"object"==typeof e&&(t=e);const o=this.tokenHandler.getToken(t.forceRefresh??!1);return n&&o.then(e=>n(null,e),n),o}revokeToken(e){if(!this.accessToken)return Promise.reject(new Error("No token to revoke."));const t=(0,i.revokeToken)(this.accessToken,this.tokenOptions.transporter);e&&t.then(()=>e(),e),this.tokenHandler=new r.TokenHandler(this.tokenOptions)}get googleTokenOptions(){return this.tokenOptions}}},46490:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildPayloadForJwsSign=a,t.getJwsSign=function(e){const t=a(e);return(0,o.sign)({header:{alg:r},payload:t,secret:e.key})};const o=n(33324),r="RS256",i="https://oauth2.googleapis.com/token";function a(e){const t=Math.floor((new Date).getTime()/1e3);return{iss:e.iss,scope:e.scope,aud:i,exp:t+3600,iat:t,sub:e.sub,...e.additionalClaims}}},78024:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.revokeToken=async function(e,t){const r=n+e;return await t.request({url:r,retry:o})};const n="https://oauth2.googleapis.com/revoke?token=",o=!0},71488:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TokenHandler=void 0;const o=n(17362),r=n(53165);t.TokenHandler=class{token;tokenExpiresAt;inFlightRequest;tokenOptions;constructor(e){this.tokenOptions=e}async processCredentials(){if(!this.tokenOptions.key&&!this.tokenOptions.keyFile)throw new Error("No key or keyFile set.");if(!this.tokenOptions.key&&this.tokenOptions.keyFile){const e=await(0,r.getCredentials)(this.tokenOptions.keyFile);this.tokenOptions.key=e.privateKey,this.tokenOptions.email=e.clientEmail}}isTokenExpiring(){if(!this.token||!this.tokenExpiresAt)return!0;const e=(new Date).getTime(),t=this.tokenOptions.eagerRefreshThresholdMillis??0;return this.tokenExpiresAt<=e+t}hasExpired(){(new Date).getTime();if(this.token&&this.tokenExpiresAt){return(new Date).getTime()>=this.tokenExpiresAt}return!0}async getToken(e){if(await this.processCredentials(),this.inFlightRequest&&!e)return this.inFlightRequest;if(this.token&&!this.isTokenExpiring()&&!e)return this.token;try{this.inFlightRequest=(0,o.getToken)(this.tokenOptions);const e=await this.inFlightRequest;return this.token=e,this.tokenExpiresAt=(new Date).getTime()+1e3*(e.expires_in??0),e}finally{this.inFlightRequest=void 0}}}},492:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.GoogleAuth=t.auth=t.PassThroughClient=t.ExternalAccountAuthorizedUserClient=t.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=t.ExecutableError=t.PluggableAuthClient=t.DownscopedClient=t.BaseExternalAccountClient=t.ExternalAccountClient=t.IdentityPoolClient=t.AwsRequestSigner=t.AwsClient=t.UserRefreshClient=t.LoginTicket=t.ClientAuthentication=t.OAuth2Client=t.CodeChallengeMethod=t.Impersonated=t.JWT=t.JWTAccess=t.IdTokenClient=t.IAMAuth=t.GCPEnv=t.Compute=t.DEFAULT_UNIVERSE=t.AuthClient=t.gaxios=t.gcpMetadata=void 0;const i=n(95934);Object.defineProperty(t,"GoogleAuth",{enumerable:!0,get:function(){return i.GoogleAuth}}),t.gcpMetadata=n(69595),t.gaxios=n(17842);var a=n(34810);Object.defineProperty(t,"AuthClient",{enumerable:!0,get:function(){return a.AuthClient}}),Object.defineProperty(t,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return a.DEFAULT_UNIVERSE}});var s=n(20977);Object.defineProperty(t,"Compute",{enumerable:!0,get:function(){return s.Compute}});var c=n(60963);Object.defineProperty(t,"GCPEnv",{enumerable:!0,get:function(){return c.GCPEnv}});var u=n(89390);Object.defineProperty(t,"IAMAuth",{enumerable:!0,get:function(){return u.IAMAuth}});var l=n(12718);Object.defineProperty(t,"IdTokenClient",{enumerable:!0,get:function(){return l.IdTokenClient}});var d=n(27060);Object.defineProperty(t,"JWTAccess",{enumerable:!0,get:function(){return d.JWTAccess}});var p=n(75277);Object.defineProperty(t,"JWT",{enumerable:!0,get:function(){return p.JWT}});var h=n(39964);Object.defineProperty(t,"Impersonated",{enumerable:!0,get:function(){return h.Impersonated}});var f=n(10091);Object.defineProperty(t,"CodeChallengeMethod",{enumerable:!0,get:function(){return f.CodeChallengeMethod}}),Object.defineProperty(t,"OAuth2Client",{enumerable:!0,get:function(){return f.OAuth2Client}}),Object.defineProperty(t,"ClientAuthentication",{enumerable:!0,get:function(){return f.ClientAuthentication}});var m=n(53882);Object.defineProperty(t,"LoginTicket",{enumerable:!0,get:function(){return m.LoginTicket}});var g=n(99807);Object.defineProperty(t,"UserRefreshClient",{enumerable:!0,get:function(){return g.UserRefreshClient}});var b=n(81261);Object.defineProperty(t,"AwsClient",{enumerable:!0,get:function(){return b.AwsClient}});var y=n(27647);Object.defineProperty(t,"AwsRequestSigner",{enumerable:!0,get:function(){return y.AwsRequestSigner}});var v=n(29960);Object.defineProperty(t,"IdentityPoolClient",{enumerable:!0,get:function(){return v.IdentityPoolClient}});var _=n(88323);Object.defineProperty(t,"ExternalAccountClient",{enumerable:!0,get:function(){return _.ExternalAccountClient}});var w=n(142);Object.defineProperty(t,"BaseExternalAccountClient",{enumerable:!0,get:function(){return w.BaseExternalAccountClient}});var O=n(77556);Object.defineProperty(t,"DownscopedClient",{enumerable:!0,get:function(){return O.DownscopedClient}});var S=n(46077);Object.defineProperty(t,"PluggableAuthClient",{enumerable:!0,get:function(){return S.PluggableAuthClient}}),Object.defineProperty(t,"ExecutableError",{enumerable:!0,get:function(){return S.ExecutableError}});var x=n(34240);Object.defineProperty(t,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return x.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}}),Object.defineProperty(t,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return x.ExternalAccountAuthorizedUserClient}});var T=n(62045);Object.defineProperty(t,"PassThroughClient",{enumerable:!0,get:function(){return T.PassThroughClient}}),r(n(33067),t);const P=new i.GoogleAuth;t.auth=P},37870:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LRUCache=void 0,t.snakeToCamel=c,t.originalOrCamelOptions=function(e){return{get:function(t){const n=e||{};return n[t]??n[c(t)]}}},t.removeUndefinedValuesInObject=function(e){return Object.entries(e).forEach(([t,n])=>{void 0!==n&&"undefined"!==n||delete e[t]}),e},t.isValidFile=async function(e){try{return(await o.promises.lstat(e)).isFile()}catch(e){return!1}},t.getWellKnownCertificateConfigFileLocation=function(){const e=process.env.CLOUDSDK_CONFIG||(r.platform().startsWith("win")?i.join(process.env.APPDATA||"",s):i.join(process.env.HOME||"",".config",s));return i.join(e,a)};const o=n(79896),r=n(70857),i=n(16928),a="certificate_config.json",s="gcloud";function c(e){return e.replace(/([_][^_])/g,e=>e.slice(1).toUpperCase())}t.LRUCache=class{capacity;#k=new Map;maxAge;constructor(e){this.capacity=e.capacity,this.maxAge=e.maxAge}#j(e,t){this.#k.delete(e),this.#k.set(e,{value:t,lastAccessed:Date.now()})}set(e,t){this.#j(e,t),this.#E()}get(e){const t=this.#k.get(e);if(t)return this.#j(e,t.value),this.#E(),t.value}#E(){const e=this.maxAge?Date.now()-this.maxAge:0;let t=this.#k.entries().next();for(;!t.done&&(this.#k.size>this.capacity||t.value[1].lastAccessed<e);)this.#k.delete(t.value[0]),t=this.#k.entries().next()}}},71628:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Colours=void 0;class n{static isEnabled(e){return e&&e.isTTY&&("function"!=typeof e.getColorDepth||e.getColorDepth()>2)}static refresh(){n.enabled=n.isEnabled(null===process||void 0===process?void 0:process.stderr),this.enabled?(n.reset="[0m",n.bright="[1m",n.dim="[2m",n.red="[31m",n.green="[32m",n.yellow="[33m",n.blue="[34m",n.magenta="[35m",n.cyan="[36m",n.white="[37m",n.grey="[90m"):(n.reset="",n.bright="",n.dim="",n.red="",n.green="",n.yellow="",n.blue="",n.magenta="",n.cyan="",n.white="",n.grey="")}}t.Colours=n,n.enabled=!1,n.reset="",n.bright="",n.dim="",n.red="",n.green="",n.yellow="",n.blue="",n.magenta="",n.cyan="",n.white="",n.grey="",n.refresh()},81577:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(74788),t)},74788:function(e,t,n){"use strict";var o,r=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.env=t.DebugLogBackendBase=t.placeholder=t.AdhocDebugLogger=t.LogSeverity=void 0,t.getNodeBackend=m,t.getDebugBackend=function(e){return new g(e)},t.getStructuredBackend=function(e){return new b(e)},t.setBackend=function(e){v=e,y.clear()},t.log=_;const s=n(24434),c=a(n(932)),u=a(n(39023)),l=n(71628);var d;!function(e){e.DEFAULT="DEFAULT",e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR"}(d||(t.LogSeverity=d={}));class p extends s.EventEmitter{constructor(e,t){super(),this.namespace=e,this.upstream=t,this.func=Object.assign(this.invoke.bind(this),{instance:this,on:(e,t)=>this.on(e,t)}),this.func.debug=(...e)=>this.invokeSeverity(d.DEBUG,...e),this.func.info=(...e)=>this.invokeSeverity(d.INFO,...e),this.func.warn=(...e)=>this.invokeSeverity(d.WARNING,...e),this.func.error=(...e)=>this.invokeSeverity(d.ERROR,...e),this.func.sublog=e=>_(e,this.func)}invoke(e,...t){if(this.upstream)try{this.upstream(e,...t)}catch(e){}try{this.emit("log",e,t)}catch(e){}}invokeSeverity(e,...t){this.invoke({severity:e},...t)}}t.AdhocDebugLogger=p,t.placeholder=new p("",()=>{}).func;class h{constructor(){var e;this.cached=new Map,this.filters=[],this.filtersSet=!1;let n=null!==(e=c.env[t.env.nodeEnables])&&void 0!==e?e:"*";"all"===n&&(n="*"),this.filters=n.split(",")}log(e,t,...n){try{this.filtersSet||(this.setFilters(),this.filtersSet=!0);let o=this.cached.get(e);o||(o=this.makeLogger(e),this.cached.set(e,o)),o(t,...n)}catch(e){console.error(e)}}}t.DebugLogBackendBase=h;class f extends h{constructor(){super(...arguments),this.enabledRegexp=/.*/g}isEnabled(e){return this.enabledRegexp.test(e)}makeLogger(e){return this.enabledRegexp.test(e)?(t,...n)=>{var o;const r=`${l.Colours.green}${e}${l.Colours.reset}`,i=`${l.Colours.yellow}${c.pid}${l.Colours.reset}`;let a;switch(t.severity){case d.ERROR:a=`${l.Colours.red}${t.severity}${l.Colours.reset}`;break;case d.INFO:a=`${l.Colours.magenta}${t.severity}${l.Colours.reset}`;break;case d.WARNING:a=`${l.Colours.yellow}${t.severity}${l.Colours.reset}`;break;default:a=null!==(o=t.severity)&&void 0!==o?o:d.DEFAULT}const s=u.formatWithOptions({colors:l.Colours.enabled},...n),p=Object.assign({},t);delete p.severity;const h=Object.getOwnPropertyNames(p).length?JSON.stringify(p):"",f=h?`${l.Colours.grey}${h}${l.Colours.reset}`:"";console.error("%s [%s|%s] %s%s",i,r,a,s,h?` ${f}`:"")}:()=>{}}setFilters(){const e=this.filters.join(",").replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^");this.enabledRegexp=new RegExp(`^${e}$`,"i")}}function m(){return new f}class g extends h{constructor(e){super(),this.debugPkg=e}makeLogger(e){const t=this.debugPkg(e);return(e,...n)=>{t(n[0],...n.slice(1))}}setFilters(){var e;const t=null!==(e=c.env.NODE_DEBUG)&&void 0!==e?e:"";c.env.NODE_DEBUG=`${t}${t?",":""}${this.filters.join(",")}`}}class b extends h{constructor(e){var t;super(),this.upstream=null!==(t=e)&&void 0!==t?t:void 0}makeLogger(e){var t;const n=null===(t=this.upstream)||void 0===t?void 0:t.makeLogger(e);return(e,...t)=>{var o;const r=null!==(o=e.severity)&&void 0!==o?o:d.INFO,i=Object.assign({severity:r,message:u.format(...t)},e),a=JSON.stringify(i);n?n(e,a):console.log("%s",a)}}setFilters(){var e;null===(e=this.upstream)||void 0===e||e.setFilters()}}t.env={nodeEnables:"GOOGLE_SDK_NODE_LOGGING"};const y=new Map;let v;function _(e,n){if(!v){if(!c.env[t.env.nodeEnables])return t.placeholder}if(!e)return t.placeholder;n&&(e=`${n.instance.namespace}:${e}`);const o=y.get(e);if(o)return o.func;if(null===v)return t.placeholder;void 0===v&&(v=m());const r=(()=>{let t;return new p(e,(n,...o)=>{if(t!==v){if(null===v)return;void 0===v&&(v=m()),t=v}null==v||v.log(e,n,...o)})})();return y.set(e,r),r.func}},14826:(e,t,n)=>{var o=n(93651).stringify,r=n(3197);e.exports=function(e){return{parse:r(e),stringify:o}},e.exports.parse=r(),e.exports.stringify=o},3197:(e,t,n)=>{var o=null;const r=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,i=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;e.exports=function(e){"use strict";var t={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(null!=e){if(!0===e.strict&&(t.strict=!0),!0===e.storeAsString&&(t.storeAsString=!0),t.alwaysParseAsBig=!0===e.alwaysParseAsBig&&e.alwaysParseAsBig,t.useNativeBigInt=!0===e.useNativeBigInt&&e.useNativeBigInt,void 0!==e.constructorAction){if("error"!==e.constructorAction&&"ignore"!==e.constructorAction&&"preserve"!==e.constructorAction)throw new Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${e.constructorAction}`);t.constructorAction=e.constructorAction}if(void 0!==e.protoAction){if("error"!==e.protoAction&&"ignore"!==e.protoAction&&"preserve"!==e.protoAction)throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${e.protoAction}`);t.protoAction=e.protoAction}}var a,s,c,u,l={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},d=function(e){throw{name:"SyntaxError",message:e,at:a,text:c}},p=function(e){return e&&e!==s&&d("Expected '"+e+"' instead of '"+s+"'"),s=c.charAt(a),a+=1,s},h=function(){var e,r="";for("-"===s&&(r="-",p("-"));s>="0"&&s<="9";)r+=s,p();if("."===s)for(r+=".";p()&&s>="0"&&s<="9";)r+=s;if("e"===s||"E"===s)for(r+=s,p(),"-"!==s&&"+"!==s||(r+=s,p());s>="0"&&s<="9";)r+=s,p();if(e=+r,isFinite(e))return null==o&&(o=n(51259)),r.length>15?t.storeAsString?r:t.useNativeBigInt?BigInt(r):new o(r):t.alwaysParseAsBig?t.useNativeBigInt?BigInt(e):new o(e):e;d("Bad number")},f=function(){var e,t,n,o="";if('"'===s)for(var r=a;p();){if('"'===s)return a-1>r&&(o+=c.substring(r,a-1)),p(),o;if("\\"===s){if(a-1>r&&(o+=c.substring(r,a-1)),p(),"u"===s){for(n=0,t=0;t<4&&(e=parseInt(p(),16),isFinite(e));t+=1)n=16*n+e;o+=String.fromCharCode(n)}else{if("string"!=typeof l[s])break;o+=l[s]}r=a}}d("Bad string")},m=function(){for(;s&&s<=" ";)p()};return u=function(){switch(m(),s){case"{":return function(){var e,n=Object.create(null);if("{"===s){if(p("{"),m(),"}"===s)return p("}"),n;for(;s;){if(e=f(),m(),p(":"),!0===t.strict&&Object.hasOwnProperty.call(n,e)&&d('Duplicate key "'+e+'"'),!0===r.test(e)?"error"===t.protoAction?d("Object contains forbidden prototype property"):"ignore"===t.protoAction?u():n[e]=u():!0===i.test(e)?"error"===t.constructorAction?d("Object contains forbidden constructor property"):"ignore"===t.constructorAction?u():n[e]=u():n[e]=u(),m(),"}"===s)return p("}"),n;p(","),m()}}d("Bad object")}();case"[":return function(){var e=[];if("["===s){if(p("["),m(),"]"===s)return p("]"),e;for(;s;){if(e.push(u()),m(),"]"===s)return p("]"),e;p(","),m()}}d("Bad array")}();case'"':return f();case"-":return h();default:return s>="0"&&s<="9"?h():function(){switch(s){case"t":return p("t"),p("r"),p("u"),p("e"),!0;case"f":return p("f"),p("a"),p("l"),p("s"),p("e"),!1;case"n":return p("n"),p("u"),p("l"),p("l"),null}d("Unexpected '"+s+"'")}()}},function(e,t){var n;return c=e+"",a=0,s=" ",n=u(),m(),s&&d("Syntax error"),"function"==typeof t?function e(n,o){var r,i=n[o];return i&&"object"==typeof i&&Object.keys(i).forEach(function(t){void 0!==(r=e(i,t))?i[t]=r:delete i[t]}),t.call(n,o,i)}({"":n},""):n}}},93651:(e,t,n)=>{var o=n(51259),r=e.exports;!function(){"use strict";var e,t,n,i=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function s(e){return i.lastIndex=0,i.test(e)?'"'+e.replace(i,function(e){var t=a[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function c(r,i){var a,u,l,d,p,h=e,f=i[r],m=null!=f&&(f instanceof o||o.isBigNumber(f));switch(f&&"object"==typeof f&&"function"==typeof f.toJSON&&(f=f.toJSON(r)),"function"==typeof n&&(f=n.call(i,r,f)),typeof f){case"string":return m?f:s(f);case"number":return isFinite(f)?String(f):"null";case"boolean":case"null":case"bigint":return String(f);case"object":if(!f)return"null";if(e+=t,p=[],"[object Array]"===Object.prototype.toString.apply(f)){for(d=f.length,a=0;a<d;a+=1)p[a]=c(a,f)||"null";return l=0===p.length?"[]":e?"[\n"+e+p.join(",\n"+e)+"\n"+h+"]":"["+p.join(",")+"]",e=h,l}if(n&&"object"==typeof n)for(d=n.length,a=0;a<d;a+=1)"string"==typeof n[a]&&(l=c(u=n[a],f))&&p.push(s(u)+(e?": ":":")+l);else Object.keys(f).forEach(function(t){var n=c(t,f);n&&p.push(s(t)+(e?": ":":")+n)});return l=0===p.length?"{}":e?"{\n"+e+p.join(",\n"+e)+"\n"+h+"}":"{"+p.join(",")+"}",e=h,l}}"function"!=typeof r.stringify&&(r.stringify=function(o,r,i){var a;if(e="",t="","number"==typeof i)for(a=0;a<i;a+=1)t+=" ";else"string"==typeof i&&(t=i);if(n=r,r&&"function"!=typeof r&&("object"!=typeof r||"number"!=typeof r.length))throw new Error("JSON.stringify");return c("",{"":o})})}()},81167:e=>{"use strict";var t=e.exports=function(e,t,o){"function"==typeof t&&(o=t,t={}),n(t,"function"==typeof(o=t.cb||o)?o:o.pre||function(){},o.post||function(){},e,"",e)};function n(e,r,i,a,s,c,u,l,d,p){if(a&&"object"==typeof a&&!Array.isArray(a)){for(var h in r(a,s,c,u,l,d,p),a){var f=a[h];if(Array.isArray(f)){if(h in t.arrayKeywords)for(var m=0;m<f.length;m++)n(e,r,i,f[m],s+"/"+h+"/"+m,c,s,h,a,m)}else if(h in t.propsKeywords){if(f&&"object"==typeof f)for(var g in f)n(e,r,i,f[g],s+"/"+h+"/"+o(g),c,s,h,a,g)}else(h in t.keywords||e.allKeys&&!(h in t.skipKeywords))&&n(e,r,i,f,s+"/"+h,c,s,h,a)}i(a,s,c,u,l,d,p)}}function o(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}},38622:(e,t,n)=>{var o,r=n(93058).Buffer,i=n(76982),a=n(325),s=n(39023),c="secret must be a string or buffer",u="key must be a string or a buffer",l="function"==typeof i.createPublicKey;function d(e){if(!r.isBuffer(e)&&"string"!=typeof e){if(!l)throw m(u);if("object"!=typeof e)throw m(u);if("string"!=typeof e.type)throw m(u);if("string"!=typeof e.asymmetricKeyType)throw m(u);if("function"!=typeof e.export)throw m(u)}}function p(e){if(!r.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw m("key must be a string, a buffer or an object")}function h(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function f(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var n=0;n<t;++n)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function m(e){var t=[].slice.call(arguments,1),n=s.format.bind(s,e).apply(null,t);return new TypeError(n)}function g(e){var t;return t=e,r.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function b(e){return function(t,n){!function(e){if(!r.isBuffer(e)){if("string"==typeof e)return e;if(!l)throw m(c);if("object"!=typeof e)throw m(c);if("secret"!==e.type)throw m(c);if("function"!=typeof e.export)throw m(c)}}(n),t=g(t);var o=i.createHmac("sha"+e,n);return h((o.update(t),o.digest("base64")))}}l&&(u+=" or a KeyObject",c+="or a KeyObject");var y="timingSafeEqual"in i?function(e,t){return e.byteLength===t.byteLength&&i.timingSafeEqual(e,t)}:function(e,t){return o||(o=n(39732)),o(e,t)};function v(e){return function(t,n,o){var i=b(e)(t,o);return y(r.from(n),r.from(i))}}function _(e){return function(t,n){p(n),t=g(t);var o=i.createSign("RSA-SHA"+e);return h((o.update(t),o.sign(n,"base64")))}}function w(e){return function(t,n,o){d(o),t=g(t),n=f(n);var r=i.createVerify("RSA-SHA"+e);return r.update(t),r.verify(o,n,"base64")}}function O(e){return function(t,n){p(n),t=g(t);var o=i.createSign("RSA-SHA"+e);return h((o.update(t),o.sign({key:n,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function S(e){return function(t,n,o){d(o),t=g(t),n=f(n);var r=i.createVerify("RSA-SHA"+e);return r.update(t),r.verify({key:o,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function x(e){var t=_(e);return function(){var n=t.apply(null,arguments);return n=a.derToJose(n,"ES"+e)}}function T(e){var t=w(e);return function(n,o,r){return o=a.joseToDer(o,"ES"+e).toString("base64"),t(n,o,r)}}function P(){return function(){return""}}function C(){return function(e,t){return""===t}}e.exports=function(e){var t={hs:b,rs:_,ps:O,es:x,none:P},n={hs:v,rs:w,ps:S,es:T,none:C},o=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!o)throw m('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',e);var r=(o[1]||o[3]).toLowerCase(),i=o[2];return{sign:t[r](i),verify:n[r](i)}}},33324:(e,t,n)=>{var o=n(78600),r=n(4368);t.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],t.sign=o.sign,t.verify=r.verify,t.decode=r.decode,t.isValid=r.isValid,t.createSign=function(e){return new o(e)},t.createVerify=function(e){return new r(e)}},41831:(e,t,n)=>{var o=n(93058).Buffer,r=n(2203);function i(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=o.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=o.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}n(39023).inherits(i,r),i.prototype.write=function(e){this.buffer=o.concat([this.buffer,o.from(e)]),this.emit("data",e)},i.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},e.exports=i},78600:(e,t,n)=>{var o=n(93058).Buffer,r=n(41831),i=n(38622),a=n(2203),s=n(95126),c=n(39023);function u(e,t){return o.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function l(e){var t=e.header,n=e.payload,o=e.secret||e.privateKey,r=e.encoding,a=i(t.alg),l=function(e,t,n){n=n||"utf8";var o=u(s(e),"binary"),r=u(s(t),n);return c.format("%s.%s",o,r)}(t,n,r),d=a.sign(l,o);return c.format("%s.%s",l,d)}function d(e){var t=e.secret;if(t=null==(t=null==t?e.privateKey:t)?e.key:t,!0===/^hs/i.test(e.header.alg)&&null==t)throw new TypeError("secret must be a string or buffer or a KeyObject");var n=new r(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new r(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}c.inherits(d,a),d.prototype.sign=function(){try{var e=l({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},d.sign=l,e.exports=d},95126:(e,t,n)=>{var o=n(20181).Buffer;e.exports=function(e){return"string"==typeof e?e:"number"==typeof e||o.isBuffer(e)?e.toString():JSON.stringify(e)}},4368:(e,t,n)=>{var o=n(93058).Buffer,r=n(41831),i=n(38622),a=n(2203),s=n(95126),c=n(39023),u=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function l(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}function d(e){var t=e.split(".",1)[0];return l(o.from(t,"base64").toString("binary"))}function p(e){return e.split(".")[2]}function h(e){return u.test(e)&&!!d(e)}function f(e,t,n){if(!t){var o=new Error("Missing algorithm parameter for jws.verify");throw o.code="MISSING_ALGORITHM",o}var r=p(e=s(e)),a=function(e){return e.split(".",2).join(".")}(e);return i(t).verify(a,r,n)}function m(e,t){if(t=t||{},!h(e=s(e)))return null;var n=d(e);if(!n)return null;var r=function(e,t){t=t||"utf8";var n=e.split(".")[1];return o.from(n,"base64").toString(t)}(e);return("JWT"===n.typ||t.json)&&(r=JSON.parse(r,t.encoding)),{header:n,payload:r,signature:p(e)}}function g(e){var t=(e=e||{}).secret;if(t=null==(t=null==t?e.publicKey:t)?e.key:t,!0===/^hs/i.test(e.algorithm)&&null==t)throw new TypeError("secret must be a string or buffer or a KeyObject");var n=new r(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new r(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}c.inherits(g,a),g.prototype.verify=function(){try{var e=f(this.signature.buffer,this.algorithm,this.key.buffer),t=m(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},g.decode=m,g.isValid=h,g.verify=f,e.exports=g},12103:(e,t,n)=>{"use strict";const o=n(5546),r=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class i extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,({message:e}=e)):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const a=(e,t)=>new Promise((n,a)=>{t={onFailedAttempt:()=>{},retries:10,...t};const s=o.operation(t);s.attempt(async o=>{try{n(await e(o))}catch(e){if(!(e instanceof Error))return void a(new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));if(e instanceof i)s.stop(),a(e.originalError);else if(e instanceof TypeError&&(c=e.message,!r.includes(c)))s.stop(),a(e);else{((e,t,n)=>{const o=n.retries-(t-1);e.attemptNumber=t,e.retriesLeft=o})(e,o,t);try{await t.onFailedAttempt(e)}catch(e){return void a(e)}s.retry(e)||a(s.mainError())}}var c})});e.exports=a,e.exports.default=a,e.exports.AbortError=i},77227:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.Allow=t.MalformedJSON=t.PartialJSON=t.parseJSON=t.parse=void 0;const i=n(83481);Object.defineProperty(t,"Allow",{enumerable:!0,get:function(){return i.Allow}}),r(n(83481),t);class a extends Error{}t.PartialJSON=a;class s extends Error{}function c(e,t=i.Allow.ALL){if("string"!=typeof e)throw new TypeError("expecting str, got "+typeof e);if(!e.trim())throw new Error(`${e} is empty`);return u(e.trim(),t)}t.MalformedJSON=s,t.parseJSON=c;const u=(e,t)=>{const n=e.length;let o=0;const r=e=>{throw new a(`${e} at position ${o}`)},c=e=>{throw new s(`${e} at position ${o}`)},u=()=>(f(),o>=n&&r("Unexpected end of input"),'"'===e[o]?l():"{"===e[o]?d():"["===e[o]?p():"null"===e.substring(o,o+4)||i.Allow.NULL&t&&n-o<4&&"null".startsWith(e.substring(o))?(o+=4,null):"true"===e.substring(o,o+4)||i.Allow.BOOL&t&&n-o<4&&"true".startsWith(e.substring(o))?(o+=4,!0):"false"===e.substring(o,o+5)||i.Allow.BOOL&t&&n-o<5&&"false".startsWith(e.substring(o))?(o+=5,!1):"Infinity"===e.substring(o,o+8)||i.Allow.INFINITY&t&&n-o<8&&"Infinity".startsWith(e.substring(o))?(o+=8,1/0):"-Infinity"===e.substring(o,o+9)||i.Allow._INFINITY&t&&1<n-o&&n-o<9&&"-Infinity".startsWith(e.substring(o))?(o+=9,-1/0):"NaN"===e.substring(o,o+3)||i.Allow.NAN&t&&n-o<3&&"NaN".startsWith(e.substring(o))?(o+=3,NaN):h()),l=()=>{const a=o;let s=!1;for(o++;o<n&&('"'!==e[o]||s&&"\\"===e[o-1]);)s="\\"===e[o]&&!s,o++;if('"'==e.charAt(o))try{return JSON.parse(e.substring(a,++o-Number(s)))}catch(e){c(String(e))}else if(i.Allow.STR&t)try{return JSON.parse(e.substring(a,o-Number(s))+'"')}catch(t){return JSON.parse(e.substring(a,e.lastIndexOf("\\"))+'"')}r("Unterminated string literal")},d=()=>{o++,f();const a={};try{for(;"}"!==e[o];){if(f(),o>=n&&i.Allow.OBJ&t)return a;const r=l();f(),o++;try{const e=u();a[r]=e}catch(e){if(i.Allow.OBJ&t)return a;throw e}f(),","===e[o]&&o++}}catch(e){if(i.Allow.OBJ&t)return a;r("Expected '}' at end of object")}return o++,a},p=()=>{o++;const n=[];try{for(;"]"!==e[o];)n.push(u()),f(),","===e[o]&&o++}catch(e){if(i.Allow.ARR&t)return n;r("Expected ']' at end of array")}return o++,n},h=()=>{if(0===o){"-"===e&&c("Not sure what '-' is");try{return JSON.parse(e)}catch(n){if(i.Allow.NUM&t)try{return JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch(e){}c(String(n))}}const a=o;for("-"===e[o]&&o++;e[o]&&-1===",]}".indexOf(e[o]);)o++;o!=n||i.Allow.NUM&t||r("Unterminated number literal");try{return JSON.parse(e.substring(a,o))}catch(t){"-"===e.substring(a,o)&&r("Not sure what '-' is");try{return JSON.parse(e.substring(a,e.lastIndexOf("e")))}catch(e){c(String(e))}}},f=()=>{for(;o<n&&" \n\r\t".includes(e[o]);)o++};return u()},l=c;t.parse=l},83481:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Allow=t.ALL=t.COLLECTION=t.ATOM=t.SPECIAL=t.INF=t._INFINITY=t.INFINITY=t.NAN=t.BOOL=t.NULL=t.OBJ=t.ARR=t.NUM=t.STR=void 0,t.STR=1,t.NUM=2,t.ARR=4,t.OBJ=8,t.NULL=16,t.BOOL=32,t.NAN=64,t.INFINITY=128,t._INFINITY=256,t.INF=t.INFINITY|t._INFINITY,t.SPECIAL=t.NULL|t.BOOL|t.INF|t.NAN,t.ATOM=t.STR|t.NUM|t.SPECIAL,t.COLLECTION=t.ARR|t.OBJ,t.ALL=t.ATOM|t.COLLECTION,t.Allow={STR:t.STR,NUM:t.NUM,ARR:t.ARR,OBJ:t.OBJ,NULL:t.NULL,BOOL:t.BOOL,NAN:t.NAN,INFINITY:t.INFINITY,_INFINITY:t._INFINITY,INF:t.INF,SPECIAL:t.SPECIAL,ATOM:t.ATOM,COLLECTION:t.COLLECTION,ALL:t.ALL},t.default=t.Allow},5546:(e,t,n)=>{e.exports=n(67084)},67084:(e,t,n)=>{var o=n(39538);t.operation=function(e){var n=t.timeouts(e);return new o(n,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})},t.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],r=0;r<t.retries;r++)o.push(this.createTimeout(r,t));return e&&e.forever&&!o.length&&o.push(this.createTimeout(r,t)),o.sort(function(e,t){return e-t}),o},t.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,o=Math.round(n*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return o=Math.min(o,t.maxTimeout)},t.wrap=function(e,n,o){if(n instanceof Array&&(o=n,n=null),!o)for(var r in o=[],e)"function"==typeof e[r]&&o.push(r);for(var i=0;i<o.length;i++){var a=o[i],s=e[a];e[a]=function(o){var r=t.operation(n),i=Array.prototype.slice.call(arguments,1),a=i.pop();i.push(function(e){r.retry(e)||(e&&(arguments[0]=r.mainError()),a.apply(this,arguments))}),r.attempt(function(){o.apply(e,i)})}.bind(e,s),e[a].options=n}}},39538:e=>{function t(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}e.exports=t,t.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},t.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},t.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var o=this;return this._timer=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},n),this._options.unref&&this._timer.unref(),!0},t.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},t.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},t.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},t.prototype.start=t.prototype.try,t.prototype.errors=function(){return this._errors},t.prototype.attempts=function(){return this._attempts},t.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,o=0;o<this._errors.length;o++){var r=this._errors[o],i=r.message,a=(e[i]||0)+1;e[i]=a,a>=n&&(t=r,n=a)}return t}},93058:(e,t,n)=>{
|
|
8
8
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
9
|
-
var o=n(20181),r=o.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return r(e,t,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?e.exports=o:(i(o,t),t.Buffer=a),a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return r(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=r(e);return void 0!==t?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o.SlowBuffer(e)}},95803:(e,t,n)=>{"use strict";const{EMPTY_BUFFER:o}=n(71791),r=Buffer[Symbol.species];function i(e,t,n,o,r){for(let i=0;i<r;i++)n[o+i]=e[i]^t[3&i]}function a(e,t){for(let n=0;n<e.length;n++)e[n]^=t[3&n]}if(e.exports={concat:function(e,t){if(0===e.length)return o;if(1===e.length)return e[0];const n=Buffer.allocUnsafe(t);let i=0;for(let t=0;t<e.length;t++){const o=e[t];n.set(o,i),i+=o.length}return i<t?new r(n.buffer,n.byteOffset,i):n},mask:i,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let n;return t instanceof ArrayBuffer?n=new r(t):ArrayBuffer.isView(t)?n=new r(t.buffer,t.byteOffset,t.byteLength):(n=Buffer.from(t),e.readOnly=!1),n},unmask:a},!process.env.WS_NO_BUFFER_UTIL)try{const t=n(18327);e.exports.mask=function(e,n,o,r,a){a<48?i(e,n,o,r,a):t.mask(e,n,o,r,a)},e.exports.unmask=function(e,n){e.length<32?a(e,n):t.unmask(e,n)}}catch(e){}},71791:e=>{"use strict";const t=["nodebuffer","arraybuffer","fragments"],n="undefined"!=typeof Blob;n&&t.push("blob"),e.exports={BINARY_TYPES:t,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:n,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},34634:(e,t,n)=>{"use strict";const{kForOnEventAttribute:o,kListener:r}=n(71791),i=Symbol("kCode"),a=Symbol("kData"),s=Symbol("kError"),c=Symbol("kMessage"),u=Symbol("kReason"),l=Symbol("kTarget"),d=Symbol("kType"),p=Symbol("kWasClean");class h{constructor(e){this[l]=null,this[d]=e}get target(){return this[l]}get type(){return this[d]}}Object.defineProperty(h.prototype,"target",{enumerable:!0}),Object.defineProperty(h.prototype,"type",{enumerable:!0});class f extends h{constructor(e,t={}){super(e),this[i]=void 0===t.code?0:t.code,this[u]=void 0===t.reason?"":t.reason,this[p]=void 0!==t.wasClean&&t.wasClean}get code(){return this[i]}get reason(){return this[u]}get wasClean(){return this[p]}}Object.defineProperty(f.prototype,"code",{enumerable:!0}),Object.defineProperty(f.prototype,"reason",{enumerable:!0}),Object.defineProperty(f.prototype,"wasClean",{enumerable:!0});class m extends h{constructor(e,t={}){super(e),this[s]=void 0===t.error?null:t.error,this[c]=void 0===t.message?"":t.message}get error(){return this[s]}get message(){return this[c]}}Object.defineProperty(m.prototype,"error",{enumerable:!0}),Object.defineProperty(m.prototype,"message",{enumerable:!0});class g extends h{constructor(e,t={}){super(e),this[a]=void 0===t.data?null:t.data}get data(){return this[a]}}Object.defineProperty(g.prototype,"data",{enumerable:!0});const b={addEventListener(e,t,n={}){for(const i of this.listeners(e))if(!n[o]&&i[r]===t&&!i[o])return;let i;if("message"===e)i=function(e,n){const o=new g("message",{data:n?e:e.toString()});o[l]=this,y(t,this,o)};else if("close"===e)i=function(e,n){const o=new f("close",{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});o[l]=this,y(t,this,o)};else if("error"===e)i=function(e){const n=new m("error",{error:e,message:e.message});n[l]=this,y(t,this,n)};else{if("open"!==e)return;i=function(){const e=new h("open");e[l]=this,y(t,this,e)}}i[o]=!!n[o],i[r]=t,n.once?this.once(e,i):this.on(e,i)},removeEventListener(e,t){for(const n of this.listeners(e))if(n[r]===t&&!n[o]){this.removeListener(e,n);break}}};function y(e,t,n){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}e.exports={CloseEvent:f,ErrorEvent:m,Event:h,EventTarget:b,MessageEvent:g}},61335:(e,t,n)=>{"use strict";const{tokenChars:o}=n(26615);function r(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}e.exports={format:function(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>!0===e?t:`${t}=${e}`).join("; ")})).join("; ")).join(", ")}).join(", ")},parse:function(e){const t=Object.create(null);let n,i,a=Object.create(null),s=!1,c=!1,u=!1,l=-1,d=-1,p=-1,h=0;for(;h<e.length;h++)if(d=e.charCodeAt(h),void 0===n)if(-1===p&&1===o[d])-1===l&&(l=h);else if(0===h||32!==d&&9!==d){if(59!==d&&44!==d)throw new SyntaxError(`Unexpected character at index ${h}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h);const o=e.slice(l,p);44===d?(r(t,o,a),a=Object.create(null)):n=o,l=p=-1}}else-1===p&&-1!==l&&(p=h);else if(void 0===i)if(-1===p&&1===o[d])-1===l&&(l=h);else if(32===d||9===d)-1===p&&-1!==l&&(p=h);else if(59===d||44===d){if(-1===l)throw new SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h),r(a,e.slice(l,p),!0),44===d&&(r(t,n,a),a=Object.create(null),n=void 0),l=p=-1}else{if(61!==d||-1===l||-1!==p)throw new SyntaxError(`Unexpected character at index ${h}`);i=e.slice(l,h),l=p=-1}else if(c){if(1!==o[d])throw new SyntaxError(`Unexpected character at index ${h}`);-1===l?l=h:s||(s=!0),c=!1}else if(u)if(1===o[d])-1===l&&(l=h);else if(34===d&&-1!==l)u=!1,p=h;else{if(92!==d)throw new SyntaxError(`Unexpected character at index ${h}`);c=!0}else if(34===d&&61===e.charCodeAt(h-1))u=!0;else if(-1===p&&1===o[d])-1===l&&(l=h);else if(-1===l||32!==d&&9!==d){if(59!==d&&44!==d)throw new SyntaxError(`Unexpected character at index ${h}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h);let o=e.slice(l,p);s&&(o=o.replace(/\\/g,""),s=!1),r(a,i,o),44===d&&(r(t,n,a),a=Object.create(null),n=void 0),i=void 0,l=p=-1}}else-1===p&&(p=h);if(-1===l||u||32===d||9===d)throw new SyntaxError("Unexpected end of input");-1===p&&(p=h);const f=e.slice(l,p);return void 0===n?r(t,f,a):(void 0===i?r(a,f,!0):r(a,i,s?f.replace(/\\/g,""):f),r(t,n,a)),t}}},10958:e=>{"use strict";const t=Symbol("kDone"),n=Symbol("kRun");e.exports=class{constructor(e){this[t]=()=>{this.pending--,this[n]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[n]()}[n](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[t])}}}},4376:(e,t,n)=>{"use strict";const o=n(43106),r=n(95803),i=n(10958),{kStatusCode:a}=n(71791),s=Buffer[Symbol.species],c=Buffer.from([0,0,255,255]),u=Symbol("permessage-deflate"),l=Symbol("total-length"),d=Symbol("callback"),p=Symbol("buffers"),h=Symbol("error");let f;function m(e){this[p].push(e),this[l]+=e.length}function g(e){this[l]+=e.length,this[u]._maxPayload<1||this[l]<=this[u]._maxPayload?this[p].push(e):(this[h]=new RangeError("Max payload size exceeded"),this[h].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[h][a]=1009,this.removeListener("data",g),this.reset())}function b(e){this[u]._inflate=null,this[h]?this[d](this[h]):(e[a]=1007,this[d](e))}e.exports=class{constructor(e,t,n){if(this._maxPayload=0|n,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!f){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;f=new i(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,n=e.find(e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(n.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?n.client_max_window_bits=t.clientMaxWindowBits:!0!==n.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete n.client_max_window_bits,n}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(n=n[0],"client_max_window_bits"===t){if(!0!==n){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}else if("server_max_window_bits"===t){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==n)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}e[t]=n})}),e}decompress(e,t,n){f.add(o=>{this._decompress(e,t,(e,t)=>{o(),n(e,t)})})}compress(e,t,n){f.add(o=>{this._compress(e,t,(e,t)=>{o(),n(e,t)})})}_decompress(e,t,n){const i=this._isServer?"client":"server";if(!this._inflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?o.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=o.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[u]=this,this._inflate[l]=0,this._inflate[p]=[],this._inflate.on("error",b),this._inflate.on("data",g)}this._inflate[d]=n,this._inflate.write(e),t&&this._inflate.write(c),this._inflate.flush(()=>{const e=this._inflate[h];if(e)return this._inflate.close(),this._inflate=null,void n(e);const o=r.concat(this._inflate[p],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[p]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,o)})}_compress(e,t,n){const i=this._isServer?"server":"client";if(!this._deflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?o.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=o.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[p]=[],this._deflate.on("data",m)}this._deflate[d]=n,this._deflate.write(e),this._deflate.flush(o.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=r.concat(this._deflate[p],this._deflate[l]);t&&(e=new s(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[l]=0,this._deflate[p]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,e)})}}},20893:(e,t,n)=>{"use strict";const{Writable:o}=n(2203),r=n(4376),{BINARY_TYPES:i,EMPTY_BUFFER:a,kStatusCode:s,kWebSocket:c}=n(71791),{concat:u,toArrayBuffer:l,unmask:d}=n(95803),{isValidStatusCode:p,isValidUTF8:h}=n(26615),f=Buffer[Symbol.species];e.exports=class extends o{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||i[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[c]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(8===this._opcode&&0==this._state)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new f(t.buffer,t.byteOffset+e,t.length-e),new f(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const n=this._buffers[0],o=t.length-e;e>=n.length?t.set(this._buffers.shift(),o):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new f(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const n=!(64&~t[0]);if(n&&!this._extensions[r.extensionName]){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=n}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),n=t.readUInt32BE(0);if(n>Math.pow(2,21)-1){return void e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}this._payloadLength=n*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){return void e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=a;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&0!==(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])&&d(t,this._mask)}if(this._opcode>7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[r.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(n)}this.dataMessage(t),0===this._state&&this.startLoop(t)})}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let o;o="nodebuffer"===this._binaryType?u(n,t):"arraybuffer"===this._binaryType?l(u(n,t)):"blob"===this._binaryType?new Blob(n):n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",o,!0),this._state=0,this.startLoop(e)}))}else{const o=u(n,t);if(!this._skipUTF8Validation&&!h(o)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",o,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)}));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,a),this.end();else{const n=e.readUInt16BE(0);if(!p(n)){const e=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const o=new f(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!h(o)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=0}}createError(e,t,n,o,r){this._loop=!1,this._errored=!0;const i=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,this.createError),i.code=r,i[s]=o,i}}},7389:(e,t,n)=>{"use strict";const{Duplex:o}=n(2203),{randomFillSync:r}=n(76982),i=n(4376),{EMPTY_BUFFER:a,kWebSocket:s,NOOP:c}=n(71791),{isBlob:u,isValidStatusCode:l}=n(26615),{mask:d,toBuffer:p}=n(95803),h=Symbol("kByteLength"),f=Buffer.alloc(4),m=8192;let g,b=m;class y{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=c,this[s]=void 0}static frame(e,t){let n,o,i=!1,a=2,s=!1;t.mask&&(n=t.maskBuffer||f,t.generateMask?t.generateMask(n):(b===m&&(void 0===g&&(g=Buffer.alloc(m)),r(g,0,m),b=0),n[0]=g[b++],n[1]=g[b++],n[2]=g[b++],n[3]=g[b++]),s=0===(n[0]|n[1]|n[2]|n[3]),a=6),"string"==typeof e?o=t.mask&&!s||void 0===t[h]?(e=Buffer.from(e)).length:t[h]:(o=e.length,i=t.mask&&t.readOnly&&!s);let c=o;o>=65536?(a+=8,c=127):o>125&&(a+=2,c=126);const u=Buffer.allocUnsafe(i?o+a:a);return u[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(u[0]|=64),u[1]=c,126===c?u.writeUInt16BE(o,2):127===c&&(u[2]=u[3]=0,u.writeUIntBE(o,4,6)),t.mask?(u[1]|=128,u[a-4]=n[0],u[a-3]=n[1],u[a-2]=n[2],u[a-1]=n[3],s?[u,e]:i?(d(e,n,u,a,o),[u]):(d(e,n,e,0,o),[u,e])):[u,e]}close(e,t,n,o){let r;if(void 0===e)r=a;else{if("number"!=typeof e||!l(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const n=Buffer.byteLength(t);if(n>123)throw new RangeError("The message must not be greater than 123 bytes");r=Buffer.allocUnsafe(2+n),r.writeUInt16BE(e,0),"string"==typeof t?r.write(t,2):r.set(t,2)}else r=Buffer.allocUnsafe(2),r.writeUInt16BE(e,0)}const i={[h]:r.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,r,!1,i,o]):this.sendFrame(y.frame(r,i),o)}ping(e,t,n){let o,r;if("string"==typeof e?(o=Buffer.byteLength(e),r=!1):u(e)?(o=e.size,r=!1):(o=(e=p(e)).length,r=p.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");const i={[h]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:r,rsv1:!1};u(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):0!==this._state?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(y.frame(e,i),n)}pong(e,t,n){let o,r;if("string"==typeof e?(o=Buffer.byteLength(e),r=!1):u(e)?(o=e.size,r=!1):(o=(e=p(e)).length,r=p.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");const i={[h]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:r,rsv1:!1};u(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):0!==this._state?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(y.frame(e,i),n)}send(e,t,n){const o=this._extensions[i.extensionName];let r,a,s=t.binary?2:1,c=t.compress;"string"==typeof e?(r=Buffer.byteLength(e),a=!1):u(e)?(r=e.size,a=!1):(r=(e=p(e)).length,a=p.readOnly),this._firstFragment?(this._firstFragment=!1,c&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(c=r>=o._threshold),this._compress=c):(c=!1,s=0),t.fin&&(this._firstFragment=!0);const l={[h]:r,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:a,rsv1:c};u(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,l,n]):this.getBlobData(e,this._compress,l,n):0!==this._state?this.enqueue([this.dispatch,e,this._compress,l,n]):this.dispatch(e,this._compress,l,n)}getBlobData(e,t,n,o){this._bufferedBytes+=n[h],this._state=2,e.arrayBuffer().then(e=>{if(this._socket.destroyed){const e=new Error("The socket was closed while the blob was being read");return void process.nextTick(v,this,e,o)}this._bufferedBytes-=n[h];const r=p(e);t?this.dispatch(r,t,n,o):(this._state=0,this.sendFrame(y.frame(r,n),o),this.dequeue())}).catch(e=>{process.nextTick(_,this,e,o)})}dispatch(e,t,n,o){if(!t)return void this.sendFrame(y.frame(e,n),o);const r=this._extensions[i.extensionName];this._bufferedBytes+=n[h],this._state=1,r.compress(e,n.fin,(e,t)=>{if(this._socket.destroyed){return void v(this,new Error("The socket was closed while data was being compressed"),o)}this._bufferedBytes-=n[h],this._state=0,n.readOnly=!1,this.sendFrame(y.frame(t,n),o),this.dequeue()})}dequeue(){for(;0===this._state&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][h],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][h],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}function v(e,t,n){"function"==typeof n&&n(t);for(let n=0;n<e._queue.length;n++){const o=e._queue[n],r=o[o.length-1];"function"==typeof r&&r(t)}}function _(e,t,n){v(e,t,n),e.onerror(t)}e.exports=y},86412:(e,t,n)=>{"use strict";n(56681);const{Duplex:o}=n(2203);function r(e){e.emit("close")}function i(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a(e){this.removeListener("error",a),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}e.exports=function(e,t){let n=!0;const s=new o({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(t,n){const o=!n&&s._readableState.objectMode?t.toString():t;s.push(o)||e.pause()}),e.once("error",function(e){s.destroyed||(n=!1,s.destroy(e))}),e.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(t,o){if(e.readyState===e.CLOSED)return o(t),void process.nextTick(r,s);let i=!1;e.once("error",function(e){i=!0,o(e)}),e.once("close",function(){i||o(t),process.nextTick(r,s)}),n&&e.terminate()},s._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once("finish",function(){t()}),e.close())):e.once("open",function(){s._final(t)})},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,o){e.readyState!==e.CONNECTING?e.send(t,o):e.once("open",function(){s._write(t,n,o)})},s.on("end",i),s.on("error",a),s}},43332:(e,t,n)=>{"use strict";const{tokenChars:o}=n(26615);e.exports={parse:function(e){const t=new Set;let n=-1,r=-1,i=0;for(;i<e.length;i++){const a=e.charCodeAt(i);if(-1===r&&1===o[a])-1===n&&(n=i);else if(0===i||32!==a&&9!==a){if(44!==a)throw new SyntaxError(`Unexpected character at index ${i}`);{if(-1===n)throw new SyntaxError(`Unexpected character at index ${i}`);-1===r&&(r=i);const o=e.slice(n,r);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);t.add(o),n=r=-1}}else-1===r&&-1!==n&&(r=i)}if(-1===n||-1!==r)throw new SyntaxError("Unexpected end of input");const a=e.slice(n,i);if(t.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);return t.add(a),t}}},26615:(e,t,n)=>{"use strict";const{isUtf8:o}=n(20181),{hasBlob:r}=n(71791);function i(e){const t=e.length;let n=0;for(;n<t;)if(128&e[n])if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}else n++;return!0}if(e.exports={isBlob:function(e){return r&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:i,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},o)e.exports.isValidUTF8=function(e){return e.length<24?i(e):o(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=n(62414);e.exports.isValidUTF8=function(e){return e.length<32?i(e):t(e)}}catch(e){}},70129:(e,t,n)=>{"use strict";const o=n(24434),r=n(58611),{Duplex:i}=n(2203),{createHash:a}=n(76982),s=n(61335),c=n(4376),u=n(43332),l=n(56681),{CLOSE_TIMEOUT:d,GUID:p,kWebSocket:h}=n(71791),f=/^[+/0-9A-Za-z]{22}==$/;function m(e){e._state=2,e.emit("close")}function g(){this.destroy()}function b(e,t,n,o){n=n||r.STATUS_CODES[t],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...o},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${r.STATUS_CODES[t]}\r\n`+Object.keys(o).map(e=>`${e}: ${o[e]}`).join("\r\n")+"\r\n\r\n"+n)}function y(e,t,n,o,r,i){if(e.listenerCount("wsClientError")){const o=new Error(r);Error.captureStackTrace(o,y),e.emit("wsClientError",o,n,t)}else b(n,o,r,i)}e.exports=class extends o{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:d,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:l,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=r.createServer((e,t)=>{const n=r.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const n of Object.keys(t))e.on(n,t[n]);return function(){for(const n of Object.keys(t))e.removeListener(n,t[n])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,n,o)=>{this.handleUpgrade(t,n,o,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",()=>{e(new Error("The server is not running"))}),void process.nextTick(m,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(m,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{m(this)})}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,o){t.on("error",g);const r=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void y(this,e,t,405,"Invalid HTTP method")}if(void 0===i||"websocket"!==i.toLowerCase()){return void y(this,e,t,400,"Invalid Upgrade header")}if(void 0===r||!f.test(r)){return void y(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(13!==a&&8!==a){return void y(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"})}if(!this.shouldHandle(e))return void b(t,400);const l=e.headers["sec-websocket-protocol"];let d=new Set;if(void 0!==l)try{d=u.parse(l)}catch(n){return void y(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const p=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&void 0!==p){const n=new c(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=s.parse(p);e[c.extensionName]&&(n.accept(e[c.extensionName]),h[c.extensionName]=n)}catch(n){return void y(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const i={origin:e.headers[""+(8===a?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(i,(i,a,s,c)=>{if(!i)return b(t,a||401,s,c);this.completeUpgrade(h,r,d,e,t,n,o)});if(!this.options.verifyClient(i))return b(t,401)}this.completeUpgrade(h,r,d,e,t,n,o)}completeUpgrade(e,t,n,o,r,i,u){if(!r.readable||!r.writable)return r.destroy();if(r[h])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return b(r,503);const l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${a("sha1").update(t+p).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(n.size){const e=this.options.handleProtocols?this.options.handleProtocols(n,o):n.values().next().value;e&&(l.push(`Sec-WebSocket-Protocol: ${e}`),d._protocol=e)}if(e[c.extensionName]){const t=e[c.extensionName].params,n=s.format({[c.extensionName]:[t]});l.push(`Sec-WebSocket-Extensions: ${n}`),d._extensions=e}this.emit("headers",l,o),r.write(l.concat("\r\n").join("\r\n")),r.removeListener("error",g),d.setSocket(r,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on("close",()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(m,this)})),u(d,o)}}},56681:(e,t,n)=>{"use strict";const o=n(24434),r=n(65692),i=n(58611),a=n(69278),s=n(64756),{randomBytes:c,createHash:u}=n(76982),{Duplex:l,Readable:d}=n(2203),{URL:p}=n(87016),h=n(4376),f=n(20893),m=n(7389),{isBlob:g}=n(26615),{BINARY_TYPES:b,CLOSE_TIMEOUT:y,EMPTY_BUFFER:v,GUID:_,kForOnEventAttribute:w,kListener:O,kStatusCode:S,kWebSocket:x,NOOP:T}=n(71791),{EventTarget:{addEventListener:P,removeEventListener:C}}=n(34634),{format:k,parse:j}=n(61335),{toBuffer:E}=n(95803),R=Symbol("kAborted"),A=[8,13],I=["CONNECTING","OPEN","CLOSING","CLOSED"],M=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class N extends o{constructor(e,t,n){super(),this._binaryType=b[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=v,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=N.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(n=t,t=[]):t=[t]),$(this,e,t,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){b.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,n){const o=new f({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),r=new m(e,this._extensions,n.generateMask);this._receiver=o,this._sender=r,this._socket=e,o[x]=this,r[x]=this,e[x]=this,o.on("conclude",W),o.on("drain",J),o.on("error",B),o.on("message",V),o.on("ping",H),o.on("pong",z),r.onerror=X,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Y),e.on("data",Q),e.on("end",ee),e.on("error",te),this._readyState=N.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=N.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[h.extensionName]&&this._extensions[h.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=N.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==N.CLOSED){if(this.readyState===N.CONNECTING){const e="WebSocket was closed before the connection was established";return void q(this,this._req,e)}this.readyState!==N.CLOSING?(this._readyState=N.CLOSING,this._sender.close(e,t,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Z(this)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end()}}pause(){this.readyState!==N.CONNECTING&&this.readyState!==N.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,n){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(n=e,e=t=void 0):"function"==typeof t&&(n=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===N.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||v,t,n)):F(this,e,n)}pong(e,t,n){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(n=e,e=t=void 0):"function"==typeof t&&(n=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===N.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||v,t,n)):F(this,e,n)}resume(){this.readyState!==N.CONNECTING&&this.readyState!==N.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,n){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(n=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==N.OPEN)return void F(this,e,n);const o={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[h.extensionName]||(o.compress=!1),this._sender.send(e||v,o,n)}terminate(){if(this.readyState!==N.CLOSED){if(this.readyState===N.CONNECTING){const e="WebSocket was closed before the connection was established";return void q(this,this._req,e)}this._socket&&(this._readyState=N.CLOSING,this._socket.destroy())}}}function $(e,t,n,o){const a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:y,protocolVersion:A[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=a.autoPong,e._closeTimeout=a.closeTimeout,!A.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${A.join(", ")})`);let s;if(t instanceof p)s=t;else try{s=new p(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===s.protocol?s.protocol="ws:":"https:"===s.protocol&&(s.protocol="wss:"),e._url=s.href;const l="wss:"===s.protocol,d="ws+unix:"===s.protocol;let f;if("ws:"===s.protocol||l||d?d&&!s.pathname?f="The URL's pathname is empty":s.hash&&(f="The URL contains a fragment identifier"):f='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"',f){const t=new SyntaxError(f);if(0===e._redirects)throw t;return void D(e,t)}const m=l?443:80,g=c(16).toString("base64"),b=l?r.request:i.request,v=new Set;let w,O;if(a.createConnection=a.createConnection||(l?L:U),a.defaultPort=a.defaultPort||m,a.port=s.port||m,a.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":g,Connection:"Upgrade",Upgrade:"websocket"},a.path=s.pathname+s.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(w=new h(!0!==a.perMessageDeflate?a.perMessageDeflate:{},!1,a.maxPayload),a.headers["Sec-WebSocket-Extensions"]=k({[h.extensionName]:w.offer()})),n.length){for(const e of n){if("string"!=typeof e||!M.test(e)||v.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");v.add(e)}a.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(s.username||s.password)&&(a.auth=`${s.username}:${s.password}`),d){const e=a.path.split(":");a.socketPath=e[0],a.path=e[1]}if(a.followRedirects){if(0===e._redirects){e._originalIpc=d,e._originalSecure=l,e._originalHostOrSocketPath=d?a.socketPath:s.host;const t=o&&o.headers;if(o={...o,headers:{}},t)for(const[e,n]of Object.entries(t))o.headers[e.toLowerCase()]=n}else if(0===e.listenerCount("redirect")){const t=d?!!e._originalIpc&&a.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!l)&&(delete a.headers.authorization,delete a.headers.cookie,t||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),O=e._req=b(a),e._redirects&&e.emit("redirect",e.url,O)}else O=e._req=b(a);a.timeout&&O.on("timeout",()=>{q(e,O,"Opening handshake has timed out")}),O.on("error",t=>{null===O||O[R]||(O=e._req=null,D(e,t))}),O.on("response",r=>{const i=r.headers.location,s=r.statusCode;if(i&&a.followRedirects&&s>=300&&s<400){if(++e._redirects>a.maxRedirects)return void q(e,O,"Maximum redirects exceeded");let r;O.abort();try{r=new p(i,t)}catch(t){const n=new SyntaxError(`Invalid URL: ${i}`);return void D(e,n)}$(e,r,n,o)}else e.emit("unexpected-response",O,r)||q(e,O,`Unexpected server response: ${r.statusCode}`)}),O.on("upgrade",(t,n,o)=>{if(e.emit("upgrade",t),e.readyState!==N.CONNECTING)return;O=e._req=null;const r=t.headers.upgrade;if(void 0===r||"websocket"!==r.toLowerCase())return void q(e,n,"Invalid Upgrade header");const i=u("sha1").update(g+_).digest("base64");if(t.headers["sec-websocket-accept"]!==i)return void q(e,n,"Invalid Sec-WebSocket-Accept header");const s=t.headers["sec-websocket-protocol"];let c;if(void 0!==s?v.size?v.has(s)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":v.size&&(c="Server sent no subprotocol"),c)return void q(e,n,c);s&&(e._protocol=s);const l=t.headers["sec-websocket-extensions"];if(void 0!==l){if(!w){return void q(e,n,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=j(l)}catch(t){return void q(e,n,"Invalid Sec-WebSocket-Extensions header")}const o=Object.keys(t);if(1!==o.length||o[0]!==h.extensionName){return void q(e,n,"Server indicated an extension that was not requested")}try{w.accept(t[h.extensionName])}catch(t){return void q(e,n,"Invalid Sec-WebSocket-Extensions header")}e._extensions[h.extensionName]=w}e.setSocket(n,o,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(O,e):O.end()}function D(e,t){e._readyState=N.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function U(e){return e.path=e.socketPath,a.connect(e)}function L(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=a.isIP(e.host)?"":e.host),s.connect(e)}function q(e,t,n){e._readyState=N.CLOSING;const o=new Error(n);Error.captureStackTrace(o,q),t.setHeader?(t[R]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(D,e,o)):(t.destroy(o),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function F(e,t,n){if(t){const n=g(t)?t.size:E(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${I[e.readyState]})`);process.nextTick(n,t)}}function W(e,t){const n=this[x];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,void 0!==n._socket[x]&&(n._socket.removeListener("data",Q),process.nextTick(K,n._socket),1005===e?n.close():n.close(e,t))}function J(){const e=this[x];e.isPaused||e._socket.resume()}function B(e){const t=this[x];void 0!==t._socket[x]&&(t._socket.removeListener("data",Q),process.nextTick(K,t._socket),t.close(e[S])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function G(){this[x].emitClose()}function V(e,t){this[x].emit("message",e,t)}function H(e){const t=this[x];t._autoPong&&t.pong(e,!this._isServer,T),t.emit("ping",e)}function z(e){this[x].emit("pong",e)}function K(e){e.resume()}function X(e){const t=this[x];t.readyState!==N.CLOSED&&(t.readyState===N.OPEN&&(t._readyState=N.CLOSING,Z(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function Z(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function Y(){const e=this[x];if(this.removeListener("close",Y),this.removeListener("data",Q),this.removeListener("end",ee),e._readyState=N.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&0!==this._readableState.length){const t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[x]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",G),e._receiver.on("finish",G))}function Q(e){this[x]._receiver.write(e)||this.pause()}function ee(){const e=this[x];e._readyState=N.CLOSING,e._receiver.end(),this.end()}function te(){const e=this[x];this.removeListener("error",te),this.on("error",T),e&&(e._readyState=N.CLOSING,this.destroy())}Object.defineProperty(N,"CONNECTING",{enumerable:!0,value:I.indexOf("CONNECTING")}),Object.defineProperty(N.prototype,"CONNECTING",{enumerable:!0,value:I.indexOf("CONNECTING")}),Object.defineProperty(N,"OPEN",{enumerable:!0,value:I.indexOf("OPEN")}),Object.defineProperty(N.prototype,"OPEN",{enumerable:!0,value:I.indexOf("OPEN")}),Object.defineProperty(N,"CLOSING",{enumerable:!0,value:I.indexOf("CLOSING")}),Object.defineProperty(N.prototype,"CLOSING",{enumerable:!0,value:I.indexOf("CLOSING")}),Object.defineProperty(N,"CLOSED",{enumerable:!0,value:I.indexOf("CLOSED")}),Object.defineProperty(N.prototype,"CLOSED",{enumerable:!0,value:I.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(N.prototype,e,{enumerable:!0})}),["open","error","close","message"].forEach(e=>{Object.defineProperty(N.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[w])return t[O];return null},set(t){for(const t of this.listeners(e))if(t[w]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[w]:!0})}})}),N.prototype.addEventListener=P,N.prototype.removeEventListener=C,e.exports=N},18327:module=>{module.exports=eval("require")("bufferutil")},62414:module=>{module.exports=eval("require")("utf-8-validate")},24352:(e,t,n)=>{"use strict";const{normalizeIPv6:o,removeDotSegments:r,recomposeAuthority:i,normalizeComponentEncoding:a,isIPv4:s,nonSimpleDomain:c}=n(15077),{SCHEMES:u,getSchemeHandler:l}=n(75300);function d(e,t,n,o){const i={};return o||(e=f(p(e,n),n),t=f(p(t,n),n)),!(n=n||{}).tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=r(t.path||""),i.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=r(t.path||""),i.query=t.query):(t.path?("/"===t.path[0]?i.path=r(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path:i.path="/"+t.path,i.path=r(i.path)),i.query=t.query):(i.path=e.path,void 0!==t.query?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function p(e,t){const n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},o=Object.assign({},t),a=[],s=l(o.scheme||n.scheme);s&&s.serialize&&s.serialize(n,o),void 0!==n.path&&(o.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),void 0!==n.scheme&&(n.path=n.path.split("%3A").join(":")))),"suffix"!==o.reference&&n.scheme&&a.push(n.scheme,":");const c=i(n);if(void 0!==c&&("suffix"!==o.reference&&a.push("//"),a.push(c),n.path&&"/"!==n.path[0]&&a.push("/")),void 0!==n.path){let e=n.path;o.absolutePath||s&&s.absolutePath||(e=r(e)),void 0===c&&"/"===e[0]&&"/"===e[1]&&(e="/%2F"+e.slice(2)),a.push(e)}return void 0!==n.query&&a.push("?",n.query),void 0!==n.fragment&&a.push("#",n.fragment),a.join("")}const h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function f(e,t){const n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let i=!1;"suffix"===n.reference&&(e=n.scheme?n.scheme+":"+e:"//"+e);const a=e.match(h);if(a){if(r.scheme=a[1],r.userinfo=a[3],r.host=a[4],r.port=parseInt(a[5],10),r.path=a[6]||"",r.query=a[7],r.fragment=a[8],isNaN(r.port)&&(r.port=a[5]),r.host){if(!1===s(r.host)){const e=o(r.host);r.host=e.host.toLowerCase(),i=e.isIPV6}else i=!0}void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||void 0!==r.query||r.path?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const t=l(n.scheme||r.scheme);if(!(n.unicodeSupport||t&&t.unicodeSupport)&&r.host&&(n.domainHost||t&&t.domainHost)&&!1===i&&c(r.host))try{r.host=URL.domainToASCII(r.host.toLowerCase())}catch(e){r.error=r.error||"Host's domain name can not be converted to ASCII: "+e}(!t||t&&!t.skipNormalize)&&(-1!==e.indexOf("%")&&(void 0!==r.scheme&&(r.scheme=unescape(r.scheme)),void 0!==r.host&&(r.host=unescape(r.host))),r.path&&(r.path=escape(unescape(r.path))),r.fragment&&(r.fragment=encodeURI(decodeURIComponent(r.fragment)))),t&&t.parse&&t.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return r}const m={SCHEMES:u,normalize:function(e,t){return"string"==typeof e?e=p(f(e,t),t):"object"==typeof e&&(e=f(p(e,t),t)),e},resolve:function(e,t,n){const o=n?Object.assign({scheme:"null"},n):{scheme:"null"},r=d(f(e,o),f(t,o),o,!0);return o.skipEscape=!0,p(r,o)},resolveComponent:d,equal:function(e,t,n){return"string"==typeof e?(e=unescape(e),e=p(a(f(e,n),!0),{...n,skipEscape:!0})):"object"==typeof e&&(e=p(a(e,!0),{...n,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=p(a(f(t,n),!0),{...n,skipEscape:!0})):"object"==typeof t&&(t=p(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:p,parse:f};e.exports=m,e.exports.default=m,e.exports.fastUri=m},75300:(e,t,n)=>{"use strict";const{isUUID:o}=n(15077),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=["http","https","ws","wss","urn","urn:uuid"];function a(e){return!0===e.secure||!1!==e.secure&&(!!e.scheme&&!(3!==e.scheme.length||"w"!==e.scheme[0]&&"W"!==e.scheme[0]||"s"!==e.scheme[1]&&"S"!==e.scheme[1]||"s"!==e.scheme[2]&&"S"!==e.scheme[2]))}function s(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function c(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const u={scheme:"http",domainHost:!0,parse:s,serialize:c},l={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=a(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(a(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,n]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}},d={http:u,https:{scheme:"https",domainHost:u.domainHost,parse:s,serialize:c},ws:l,wss:{scheme:"wss",domainHost:l.domainHost,parse:l.parse,serialize:l.serialize},urn:{scheme:"urn",parse:function(e,t){if(!e.path)return e.error="URN can not be parsed",e;const n=e.path.match(r);if(n){const o=t.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];const r=p(`${o}:${t.nid||e.nid}`);e.path=void 0,r&&(e=r.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){if(void 0===e.nid)throw new Error("URN without nid cannot be serialized");const n=t.scheme||e.scheme||"urn",o=e.nid.toLowerCase(),r=p(`${n}:${t.nid||o}`);r&&(e=r.serialize(e,t));const i=e,a=e.nss;return i.path=`${o||t.nid}:${a}`,t.skipEscape=!0,i},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(e,t){const n=e;return n.uuid=n.nss,n.nss=void 0,t.tolerant||n.uuid&&o(n.uuid)||(n.error=n.error||"UUID is not valid."),n},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};function p(e){return e&&(d[e]||d[e.toLowerCase()])||void 0}Object.setPrototypeOf(d,null),e.exports={wsIsSecure:a,SCHEMES:d,isValidSchemeName:function(e){return-1!==i.indexOf(e)},getSchemeHandler:p}},15077:e=>{"use strict";const t=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),n=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function o(e){let t="",n=0,o=0;for(o=0;o<e.length;o++)if(n=e[o].charCodeAt(0),48!==n){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[o];break}for(o+=1;o<e.length;o++){if(n=e[o].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[o]}return t}const r=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function i(e){return e.length=0,!0}function a(e,t,n){if(e.length){const r=o(e);if(""===r)return n.error=!0,!1;t.push(r),e.length=0}return!0}function s(e){if(function(e,t){let n=0;for(let o=0;o<e.length;o++)e[o]===t&&n++;return n}(e,":")<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const n={error:!1,address:"",zone:""},r=[],s=[];let c=!1,u=!1,l=a;for(let o=0;o<e.length;o++){const a=e[o];if("["!==a&&"]"!==a)if(":"!==a)if("%"===a){if(!l(s,r,n))break;l=i}else s.push(a);else{if(!0===c&&(u=!0),!l(s,r,n))break;if(++t>7){n.error=!0;break}o>0&&":"===e[o-1]&&(c=!0),r.push(":")}}return s.length&&(l===i?n.zone=s.join(""):u?r.push(s.join("")):r.push(o(s))),n.address=r.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+="%"+t.zone,n+="%25"+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}e.exports={nonSimpleDomain:r,recomposeAuthority:function(e){const t=[];if(void 0!==e.userinfo&&(t.push(e.userinfo),t.push("@")),void 0!==e.host){let o=unescape(e.host);if(!n(o)){const t=s(o);o=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}t.push(o)}return"number"!=typeof e.port&&"string"!=typeof e.port||(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0},normalizeComponentEncoding:function(e,t){const n=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=n(e.scheme)),void 0!==e.userinfo&&(e.userinfo=n(e.userinfo)),void 0!==e.host&&(e.host=n(e.host)),void 0!==e.path&&(e.path=n(e.path)),void 0!==e.query&&(e.query=n(e.query)),void 0!==e.fragment&&(e.fragment=n(e.fragment)),e},removeDotSegments:function(e){let t=e;const n=[];let o=-1,r=0;for(;r=t.length;){if(1===r){if("."===t)break;if("/"===t){n.push("/");break}n.push(t);break}if(2===r){if("."===t[0]){if("."===t[1])break;if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&("."===t[1]||"/"===t[1])){n.push("/");break}}else if(3===r&&"/.."===t){0!==n.length&&n.pop(),n.push("/");break}if("."===t[0]){if("."===t[1]){if("/"===t[2]){t=t.slice(3);continue}}else if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&"."===t[1]){if("/"===t[2]){t=t.slice(2);continue}if("."===t[2]&&"/"===t[3]){t=t.slice(3),0!==n.length&&n.pop();continue}}if(-1===(o=t.indexOf("/",1))){n.push(t);break}n.push(t.slice(0,o)),t=t.slice(o)}return n.join("")},isIPv4:n,isUUID:t,normalizeIPv6:s,stringArrayToHexStripped:o}},36128:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GCE_LINUX_BIOS_PATHS=void 0,t.isGoogleCloudServerless=a,t.isGoogleComputeEngineLinux=s,t.isGoogleComputeEngineMACAddress=c,t.isGoogleComputeEngine=u,t.detectGCPResidency=function(){return a()||u()};const o=n(79896),r=n(70857);t.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};const i=/^42:01/;function a(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function s(){if("linux"!==(0,r.platform)())return!1;try{(0,o.statSync)(t.GCE_LINUX_BIOS_PATHS.BIOS_DATE);const e=(0,o.readFileSync)(t.GCE_LINUX_BIOS_PATHS.BIOS_VENDOR,"utf8");return/Google/.test(e)}catch{return!1}}function c(){const e=(0,r.networkInterfaces)();for(const t of Object.values(e))if(t)for(const{mac:e}of t)if(i.test(e))return!0;return!1}function u(){return s()||c()}},69595:function(e,t,n){"use strict";var o,r=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return i(t,e),t}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.gcpResidencyCache=t.METADATA_SERVER_DETECTION=t.HEADERS=t.HEADER_VALUE=t.HEADER_NAME=t.SECONDARY_HOST_ADDRESS=t.HOST_ADDRESS=t.BASE_PATH=void 0,t.instance=function(e){return f("instance",e)},t.project=function(e){return f("project",e)},t.universe=function(e){return f("universe",e)},t.bulk=async function(e){const t={};return await Promise.all(e.map(e=>(async()=>{const n=await f(e),o=e.metadataKey;t[o]=n})())),t},t.isAvailable=async function(){if(process.env.METADATA_SERVER_DETECTION){const e=process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();if(!(e in t.METADATA_SERVER_DETECTION))throw new RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${e}\`, but it should be \`${Object.keys(t.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);switch(e){case"assume-present":return!0;case"none":return!1;case"bios-only":return b()}}try{return void 0===g&&(g=f("instance",void 0,process.env.DETECT_GCP_RETRIES?Number(process.env.DETECT_GCP_RETRIES):0,!(process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST))),await g,!0}catch(e){const t=e;if(process.env.DEBUG_AUTH&&console.info(t),"request-timeout"===t.type)return!1;if(t.response&&404===t.response.status)return!1;if(!(t.response&&404===t.response.status||t.code&&["EHOSTDOWN","EHOSTUNREACH","ENETUNREACH","ENOENT","ENOTFOUND","ECONNREFUSED"].includes(t.code.toString()))){let e="UNKNOWN";t.code&&(e=t.code.toString()),process.emitWarning(`received unexpected error = ${t.message} code = ${e}`,"MetadataLookupWarning")}return!1}},t.resetIsAvailableCache=function(){g=void 0},t.getGCPResidency=b,t.setGCPResidency=y,t.requestTimeout=v;const c=n(17842),u=n(14826),l=n(36128),d=a(n(81577));t.BASE_PATH="/computeMetadata/v1",t.HOST_ADDRESS="http://169.254.169.254",t.SECONDARY_HOST_ADDRESS="http://metadata.google.internal.",t.HEADER_NAME="Metadata-Flavor",t.HEADER_VALUE="Google",t.HEADERS=Object.freeze({[t.HEADER_NAME]:t.HEADER_VALUE});const p=d.log("gcp-metadata");function h(e){return e||(e=process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST||t.HOST_ADDRESS),/^https?:\/\//.test(e)||(e=`http://${e}`),new URL(t.BASE_PATH,e).href}async function f(e,n={},o=3,r=!1){const i=new Headers(t.HEADERS);let a="",s={};if("object"==typeof e){const t=e;new Headers(t.headers).forEach((e,t)=>i.set(t,e)),a=t.metadataKey,s=t.params||s,o=t.noResponseRetries||o,r=t.fastFail||r}else a=e;"string"==typeof n?a+=`/${n}`:(!function(e){Object.keys(e).forEach(e=>{switch(e){case"params":case"property":case"headers":break;case"qs":throw new Error("'qs' is not a valid configuration option. Please use 'params' instead.");default:throw new Error(`'${e}' is not a valid configuration option.`)}})}(n),n.property&&(a+=`/${n.property}`),new Headers(n.headers).forEach((e,t)=>i.set(t,e)),s=n.params||s);const l=r?m:c.request,d={url:`${h()}/${a}`,headers:i,retryConfig:{noResponseRetries:o},params:s,responseType:"text",timeout:v()};p.info("instance request %j",d);const f=await l(d);p.info("instance metadata is %s",f.data);const g=f.headers.get(t.HEADER_NAME);if(g!==t.HEADER_VALUE)throw new RangeError(`Invalid response from metadata service: incorrect ${t.HEADER_NAME} header. Expected '${t.HEADER_VALUE}', got ${g?`'${g}'`:"no header"}`);if("string"==typeof f.data)try{return u.parse(f.data)}catch{}return f.data}async function m(e){const n={...e,url:e.url?.toString().replace(h(),h(t.SECONDARY_HOST_ADDRESS))},o=(0,c.request)(e),r=(0,c.request)(n);return Promise.any([o,r])}let g;function b(){return null===t.gcpResidencyCache&&y(),t.gcpResidencyCache}function y(e=null){t.gcpResidencyCache=null!==e?e:(0,l.detectGCPResidency)()}function v(){return b()?0:3e3}t.METADATA_SERVER_DETECTION=Object.freeze({"assume-present":"don't try to ping the metadata server, but assume it's present",none:"don't try to ping the metadata server, but don't try to use it either","bios-only":"treat the result of a BIOS probe as canonical (don't fall back to pinging)","ping-only":"skip the BIOS probe, and go straight to pinging"}),t.gcpResidencyCache=null,s(n(36128),t)},50199:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDefaultOptions=t.defaultOptions=t.jsonDescription=t.ignoreOverride=void 0,t.ignoreOverride=Symbol("Let zodToJsonSchema decide on which parser to use");t.jsonDescription=(e,t)=>{if(t.description)try{return{...e,...JSON.parse(t.description)}}catch{}return e},t.defaultOptions={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"};t.getDefaultOptions=e=>"string"==typeof e?{...t.defaultOptions,name:e}:{...t.defaultOptions,...e}},29195:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRefs=void 0;const o=n(50199);t.getRefs=e=>{const t=(0,o.getDefaultOptions)(e),n=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}}},22691:(e,t)=>{"use strict";function n(e,t,n,o){o?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}Object.defineProperty(t,"__esModule",{value:!0}),t.setResponseValueAndErrors=t.addErrorMessage=void 0,t.addErrorMessage=n,t.setResponseValueAndErrors=function(e,t,o,r,i){e[t]=o,n(e,t,r,i)}},90946:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRelativePath=void 0;t.getRelativePath=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")}},76885:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(50199),t),r(n(29195),t),r(n(22691),t),r(n(90946),t),r(n(41607),t),r(n(23361),t),r(n(59624),t),r(n(95663),t),r(n(41107),t),r(n(10282),t),r(n(93406),t),r(n(2201),t),r(n(13148),t),r(n(45635),t),r(n(23468),t),r(n(53981),t),r(n(51057),t),r(n(49197),t),r(n(12136),t),r(n(92302),t),r(n(90108),t),r(n(58465),t),r(n(99549),t),r(n(57717),t),r(n(29935),t),r(n(77488),t),r(n(93246),t),r(n(91119),t),r(n(44394),t),r(n(69549),t),r(n(22706),t),r(n(63481),t),r(n(8448),t),r(n(8426),t),r(n(8013),t),r(n(6960),t),r(n(40402),t),r(n(71484),t);const i=n(71484);t.default=i.zodToJsonSchema},41607:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDef=void 0;const o=n(50199),r=n(40402),i=n(90946),a=n(59624);t.parseDef=function e(t,n,i=!1){const a=n.seen.get(t);if(n.override){const e=n.override?.(t,n,a,i);if(e!==o.ignoreOverride)return e}if(a&&!i){const e=s(a,n);if(void 0!==e)return e}const u={def:t,path:n.currentPath,jsonSchema:void 0};n.seen.set(t,u);const l=(0,r.selectParser)(t,t.typeName,n),d="function"==typeof l?e(l(),n):l;if(d&&c(t,n,d),n.postProcess){const e=n.postProcess(d,t,n);return u.jsonSchema=d,e}return u.jsonSchema=d,d};const s=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:(0,i.getRelativePath)(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),(0,a.parseAnyDef)(t)):"seen"===t.$refStrategy?(0,a.parseAnyDef)(t):void 0}},c=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n)},23361:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},59624:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseAnyDef=void 0;const o=n(90946);t.parseAnyDef=function(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?(0,o.getRelativePath)(t,e.currentPath):t.join("/")}}},95663:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseArrayDef=void 0;const o=n(19968),r=n(22691),i=n(41607);t.parseArrayDef=function(e,t){const n={type:"array"};return e.type?._def&&e.type?._def?.typeName!==o.ZodFirstPartyTypeKind.ZodAny&&(n.items=(0,i.parseDef)(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(0,r.setResponseValueAndErrors)(n,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&(0,r.setResponseValueAndErrors)(n,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&((0,r.setResponseValueAndErrors)(n,"minItems",e.exactLength.value,e.exactLength.message,t),(0,r.setResponseValueAndErrors)(n,"maxItems",e.exactLength.value,e.exactLength.message,t)),n}},41107:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBigintDef=void 0;const o=n(22691);t.parseBigintDef=function(e,t){const n={type:"integer",format:"int64"};if(!e.checks)return n;for(const r of e.checks)switch(r.kind){case"min":"jsonSchema7"===t.target?r.inclusive?(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t):(0,o.setResponseValueAndErrors)(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t));break;case"max":"jsonSchema7"===t.target?r.inclusive?(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t):(0,o.setResponseValueAndErrors)(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t));break;case"multipleOf":(0,o.setResponseValueAndErrors)(n,"multipleOf",r.value,r.message,t)}return n}},10282:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBooleanDef=void 0,t.parseBooleanDef=function(){return{type:"boolean"}}},93406:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBrandedDef=void 0;const o=n(41607);t.parseBrandedDef=function(e,t){return(0,o.parseDef)(e.type._def,t)}},2201:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseCatchDef=void 0;const o=n(41607);t.parseCatchDef=(e,t)=>(0,o.parseDef)(e.innerType._def,t)},13148:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDateDef=void 0;const o=n(22691);t.parseDateDef=function e(t,n,o){const i=o??n.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((o,r)=>e(t,n,o))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return r(t,n)}};const r=(e,t)=>{const n={type:"integer",format:"unix-time"};if("openApi3"===t.target)return n;for(const r of e.checks)switch(r.kind){case"min":(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t);break;case"max":(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t)}return n}},45635:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDefaultDef=void 0;const o=n(41607);t.parseDefaultDef=function(e,t){return{...(0,o.parseDef)(e.innerType._def,t),default:e.defaultValue()}}},23468:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEffectsDef=void 0;const o=n(41607),r=n(59624);t.parseEffectsDef=function(e,t){return"input"===t.effectStrategy?(0,o.parseDef)(e.schema._def,t):(0,r.parseAnyDef)(t)}},53981:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnumDef=void 0,t.parseEnumDef=function(e){return{type:"string",enum:Array.from(e.values)}}},51057:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseIntersectionDef=void 0;const o=n(41607);t.parseIntersectionDef=function(e,t){const n=[(0,o.parseDef)(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),(0,o.parseDef)(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let r="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const i=[];return n.forEach(e=>{if("type"in(t=e)&&"string"===t.type||!("allOf"in t)){let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:n,...o}=e;t=o}else r=void 0;i.push(t)}else i.push(...e.allOf),void 0===e.unevaluatedProperties&&(r=void 0);var t}),i.length?{allOf:i,...r}:void 0}},49197:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseLiteralDef=void 0,t.parseLiteralDef=function(e,t){const n=typeof e.value;return"bigint"!==n&&"number"!==n&&"boolean"!==n&&"string"!==n?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===n?"integer":n,enum:[e.value]}:{type:"bigint"===n?"integer":n,const:e.value}}},12136:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseMapDef=void 0;const o=n(41607),r=n(69549),i=n(59624);t.parseMapDef=function(e,t){return"record"===t.mapStrategy?(0,r.parseRecordDef)(e,t):{type:"array",maxItems:125,items:{type:"array",items:[(0,o.parseDef)(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||(0,i.parseAnyDef)(t),(0,o.parseDef)(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||(0,i.parseAnyDef)(t)],minItems:2,maxItems:2}}}},92302:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNativeEnumDef=void 0,t.parseNativeEnumDef=function(e){const t=e.values,n=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),o=Array.from(new Set(n.map(e=>typeof e)));return{type:1===o.length?"string"===o[0]?"string":"number":["string","number"],enum:n}}},90108:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNeverDef=void 0;const o=n(59624);t.parseNeverDef=function(e){return"openAi"===e.target?void 0:{not:(0,o.parseAnyDef)({...e,currentPath:[...e.currentPath,"not"]})}}},58465:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNullDef=void 0,t.parseNullDef=function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}},99549:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNullableDef=void 0;const o=n(41607),r=n(8013);t.parseNullableDef=function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:r.primitiveMappings[e.innerType._def.typeName],nullable:!0}:{type:[r.primitiveMappings[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const n=(0,o.parseDef)(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const n=(0,o.parseDef)(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}},57717:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNumberDef=void 0;const o=n(22691);t.parseNumberDef=function(e,t){const n={type:"number"};if(!e.checks)return n;for(const r of e.checks)switch(r.kind){case"int":n.type="integer",(0,o.addErrorMessage)(n,"type",r.message,t);break;case"min":"jsonSchema7"===t.target?r.inclusive?(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t):(0,o.setResponseValueAndErrors)(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t));break;case"max":"jsonSchema7"===t.target?r.inclusive?(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t):(0,o.setResponseValueAndErrors)(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t));break;case"multipleOf":(0,o.setResponseValueAndErrors)(n,"multipleOf",r.value,r.message,t)}return n}},29935:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseObjectDef=void 0;const o=n(41607);function r(e){try{return e.isOptional()}catch{return!0}}t.parseObjectDef=function(e,t){const n="openAi"===t.target,i={type:"object",properties:{}},a=[],s=e.shape();for(const e in s){let c=s[e];if(void 0===c||void 0===c._def)continue;let u=r(c);u&&n&&("ZodOptional"===c._def.typeName&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);const l=(0,o.parseDef)(c._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==l&&(i.properties[e]=l,u||a.push(e))}a.length&&(i.required=a);const c=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return(0,o.parseDef)(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==c&&(i.additionalProperties=c),i}},77488:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseOptionalDef=void 0;const o=n(41607),r=n(59624);t.parseOptionalDef=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return(0,o.parseDef)(e.innerType._def,t);const n=(0,o.parseDef)(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return n?{anyOf:[{not:(0,r.parseAnyDef)(t)},n]}:(0,r.parseAnyDef)(t)}},93246:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parsePipelineDef=void 0;const o=n(41607);t.parsePipelineDef=(e,t)=>{if("input"===t.pipeStrategy)return(0,o.parseDef)(e.in._def,t);if("output"===t.pipeStrategy)return(0,o.parseDef)(e.out._def,t);const n=(0,o.parseDef)(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[n,(0,o.parseDef)(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]})].filter(e=>void 0!==e)}}},91119:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parsePromiseDef=void 0;const o=n(41607);t.parsePromiseDef=function(e,t){return(0,o.parseDef)(e.type._def,t)}},44394:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseReadonlyDef=void 0;const o=n(41607);t.parseReadonlyDef=(e,t)=>(0,o.parseDef)(e.innerType._def,t)},69549:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRecordDef=void 0;const o=n(19968),r=n(41607),i=n(63481),a=n(93406),s=n(59624);t.parseRecordDef=function(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===o.ZodFirstPartyTypeKind.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,o)=>({...n,[o]:(0,r.parseDef)(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",o]})??(0,s.parseAnyDef)(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const n={type:"object",additionalProperties:(0,r.parseDef)(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return n;if(e.keyType?._def.typeName===o.ZodFirstPartyTypeKind.ZodString&&e.keyType._def.checks?.length){const{type:o,...r}=(0,i.parseStringDef)(e.keyType._def,t);return{...n,propertyNames:r}}if(e.keyType?._def.typeName===o.ZodFirstPartyTypeKind.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===o.ZodFirstPartyTypeKind.ZodBranded&&e.keyType._def.type._def.typeName===o.ZodFirstPartyTypeKind.ZodString&&e.keyType._def.type._def.checks?.length){const{type:o,...r}=(0,a.parseBrandedDef)(e.keyType._def,t);return{...n,propertyNames:r}}return n}},22706:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseSetDef=void 0;const o=n(22691),r=n(41607);t.parseSetDef=function(e,t){const n={type:"array",uniqueItems:!0,items:(0,r.parseDef)(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(0,o.setResponseValueAndErrors)(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&(0,o.setResponseValueAndErrors)(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}},63481:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseStringDef=t.zodPatterns=void 0;const o=n(22691);let r;function i(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let n=0;n<e.length;n++)a.has(e[n])||(t+="\\"),t+=e[n];return t}(e):e}t.zodPatterns={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===r&&(r=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),r),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/},t.parseStringDef=function(e,n){const r={type:"string"};if(e.checks)for(const a of e.checks)switch(a.kind){case"min":(0,o.setResponseValueAndErrors)(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value,a.message,n);break;case"max":(0,o.setResponseValueAndErrors)(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value,a.message,n);break;case"email":switch(n.emailStrategy){case"format:email":s(r,"email",a.message,n);break;case"format:idn-email":s(r,"idn-email",a.message,n);break;case"pattern:zod":c(r,t.zodPatterns.email,a.message,n)}break;case"url":s(r,"uri",a.message,n);break;case"uuid":s(r,"uuid",a.message,n);break;case"regex":c(r,a.regex,a.message,n);break;case"cuid":c(r,t.zodPatterns.cuid,a.message,n);break;case"cuid2":c(r,t.zodPatterns.cuid2,a.message,n);break;case"startsWith":c(r,RegExp(`^${i(a.value,n)}`),a.message,n);break;case"endsWith":c(r,RegExp(`${i(a.value,n)}$`),a.message,n);break;case"datetime":s(r,"date-time",a.message,n);break;case"date":s(r,"date",a.message,n);break;case"time":s(r,"time",a.message,n);break;case"duration":s(r,"duration",a.message,n);break;case"length":(0,o.setResponseValueAndErrors)(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value,a.message,n),(0,o.setResponseValueAndErrors)(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value,a.message,n);break;case"includes":c(r,RegExp(i(a.value,n)),a.message,n);break;case"ip":"v6"!==a.version&&s(r,"ipv4",a.message,n),"v4"!==a.version&&s(r,"ipv6",a.message,n);break;case"base64url":c(r,t.zodPatterns.base64url,a.message,n);break;case"jwt":c(r,t.zodPatterns.jwt,a.message,n);break;case"cidr":"v6"!==a.version&&c(r,t.zodPatterns.ipv4Cidr,a.message,n),"v4"!==a.version&&c(r,t.zodPatterns.ipv6Cidr,a.message,n);break;case"emoji":c(r,t.zodPatterns.emoji(),a.message,n);break;case"ulid":c(r,t.zodPatterns.ulid,a.message,n);break;case"base64":switch(n.base64Strategy){case"format:binary":s(r,"binary",a.message,n);break;case"contentEncoding:base64":(0,o.setResponseValueAndErrors)(r,"contentEncoding","base64",a.message,n);break;case"pattern:zod":c(r,t.zodPatterns.base64,a.message,n)}break;case"nanoid":c(r,t.zodPatterns.nanoid,a.message,n);case"toLowerCase":case"toUpperCase":case"trim":break;default:(()=>{})()}return r};const a=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function s(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):(0,o.setResponseValueAndErrors)(e,"format",t,n,r)}function c(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:u(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):(0,o.setResponseValueAndErrors)(e,"pattern",u(t,r),n,r)}function u(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;const n=e.flags.includes("i"),o=e.flags.includes("m"),r=e.flags.includes("s"),i=n?e.source.toLowerCase():e.source;let a="",s=!1,c=!1,u=!1;for(let e=0;e<i.length;e++)if(s)a+=i[e],s=!1;else{if(n)if(c){if(i[e].match(/[a-z]/)){u?(a+=i[e],a+=`${i[e-2]}-${i[e]}`.toUpperCase(),u=!1):"-"===i[e+1]&&i[e+2]?.match(/[a-z]/)?(a+=i[e],u=!0):a+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){a+=`[${i[e]}${i[e].toUpperCase()}]`;continue}if(o){if("^"===i[e]){a+="(^|(?<=[\r\n]))";continue}if("$"===i[e]){a+="($|(?=[\r\n]))";continue}}r&&"."===i[e]?a+=c?`${i[e]}\r\n`:`[${i[e]}\r\n]`:(a+=i[e],"\\"===i[e]?s=!0:c&&"]"===i[e]?c=!1:c||"["!==i[e]||(c=!0))}try{new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return a}},8448:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseTupleDef=void 0;const o=n(41607);t.parseTupleDef=function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,n)=>(0,o.parseDef)(e._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:(0,o.parseDef)(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>(0,o.parseDef)(e._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}},8426:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUndefinedDef=void 0;const o=n(59624);t.parseUndefinedDef=function(e){return{not:(0,o.parseAnyDef)(e)}}},8013:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUnionDef=t.primitiveMappings=void 0;const o=n(41607);t.primitiveMappings={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},t.parseUnionDef=function(e,n){if("openApi3"===n.target)return r(e,n);const o=e.options instanceof Map?Array.from(e.options.values()):e.options;if(o.every(e=>e._def.typeName in t.primitiveMappings&&(!e._def.checks||!e._def.checks.length))){const e=o.reduce((e,n)=>{const o=t.primitiveMappings[n._def.typeName];return o&&!e.includes(o)?[...e,o]:e},[]);return{type:e.length>1?e:e[0]}}if(o.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=o.reduce((e,t)=>{const n=typeof t._def.value;switch(n){case"string":case"number":case"boolean":return[...e,n];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===o.length){const t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:o.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(o.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:o.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return r(e,n)};const r=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>(0,o.parseDef)(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0}},6960:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUnknownDef=void 0;const o=n(59624);t.parseUnknownDef=function(e){return(0,o.parseAnyDef)(e)}},40402:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.selectParser=void 0;const o=n(19968),r=n(59624),i=n(95663),a=n(41107),s=n(10282),c=n(93406),u=n(2201),l=n(13148),d=n(45635),p=n(23468),h=n(53981),f=n(51057),m=n(49197),g=n(12136),b=n(92302),y=n(90108),v=n(58465),_=n(99549),w=n(57717),O=n(29935),S=n(77488),x=n(93246),T=n(91119),P=n(69549),C=n(22706),k=n(63481),j=n(8448),E=n(8426),R=n(8013),A=n(6960),I=n(44394);t.selectParser=(e,t,n)=>{switch(t){case o.ZodFirstPartyTypeKind.ZodString:return(0,k.parseStringDef)(e,n);case o.ZodFirstPartyTypeKind.ZodNumber:return(0,w.parseNumberDef)(e,n);case o.ZodFirstPartyTypeKind.ZodObject:return(0,O.parseObjectDef)(e,n);case o.ZodFirstPartyTypeKind.ZodBigInt:return(0,a.parseBigintDef)(e,n);case o.ZodFirstPartyTypeKind.ZodBoolean:return(0,s.parseBooleanDef)();case o.ZodFirstPartyTypeKind.ZodDate:return(0,l.parseDateDef)(e,n);case o.ZodFirstPartyTypeKind.ZodUndefined:return(0,E.parseUndefinedDef)(n);case o.ZodFirstPartyTypeKind.ZodNull:return(0,v.parseNullDef)(n);case o.ZodFirstPartyTypeKind.ZodArray:return(0,i.parseArrayDef)(e,n);case o.ZodFirstPartyTypeKind.ZodUnion:case o.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return(0,R.parseUnionDef)(e,n);case o.ZodFirstPartyTypeKind.ZodIntersection:return(0,f.parseIntersectionDef)(e,n);case o.ZodFirstPartyTypeKind.ZodTuple:return(0,j.parseTupleDef)(e,n);case o.ZodFirstPartyTypeKind.ZodRecord:return(0,P.parseRecordDef)(e,n);case o.ZodFirstPartyTypeKind.ZodLiteral:return(0,m.parseLiteralDef)(e,n);case o.ZodFirstPartyTypeKind.ZodEnum:return(0,h.parseEnumDef)(e);case o.ZodFirstPartyTypeKind.ZodNativeEnum:return(0,b.parseNativeEnumDef)(e);case o.ZodFirstPartyTypeKind.ZodNullable:return(0,_.parseNullableDef)(e,n);case o.ZodFirstPartyTypeKind.ZodOptional:return(0,S.parseOptionalDef)(e,n);case o.ZodFirstPartyTypeKind.ZodMap:return(0,g.parseMapDef)(e,n);case o.ZodFirstPartyTypeKind.ZodSet:return(0,C.parseSetDef)(e,n);case o.ZodFirstPartyTypeKind.ZodLazy:return()=>e.getter()._def;case o.ZodFirstPartyTypeKind.ZodPromise:return(0,T.parsePromiseDef)(e,n);case o.ZodFirstPartyTypeKind.ZodNaN:case o.ZodFirstPartyTypeKind.ZodNever:return(0,y.parseNeverDef)(n);case o.ZodFirstPartyTypeKind.ZodEffects:return(0,p.parseEffectsDef)(e,n);case o.ZodFirstPartyTypeKind.ZodAny:return(0,r.parseAnyDef)(n);case o.ZodFirstPartyTypeKind.ZodUnknown:return(0,A.parseUnknownDef)(n);case o.ZodFirstPartyTypeKind.ZodDefault:return(0,d.parseDefaultDef)(e,n);case o.ZodFirstPartyTypeKind.ZodBranded:return(0,c.parseBrandedDef)(e,n);case o.ZodFirstPartyTypeKind.ZodReadonly:return(0,I.parseReadonlyDef)(e,n);case o.ZodFirstPartyTypeKind.ZodCatch:return(0,u.parseCatchDef)(e,n);case o.ZodFirstPartyTypeKind.ZodPipeline:return(0,x.parsePipelineDef)(e,n);case o.ZodFirstPartyTypeKind.ZodFunction:case o.ZodFirstPartyTypeKind.ZodVoid:case o.ZodFirstPartyTypeKind.ZodSymbol:default:return}}},71484:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zodToJsonSchema=void 0;const o=n(41607),r=n(29195),i=n(59624);t.zodToJsonSchema=(e,t)=>{const n=(0,r.getRefs)(t);let a="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:(0,o.parseDef)(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??(0,i.parseAnyDef)(n)}),{}):void 0;const s="string"==typeof t?t:"title"===t?.nameStrategy?void 0:t?.name,c=(0,o.parseDef)(e._def,void 0===s?n:{...n,currentPath:[...n.basePath,n.definitionPath,s]},!1)??(0,i.parseAnyDef)(n),u="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==u&&(c.title=u),n.flags.hasReferencedOpenAiAnyType&&(a||(a={}),a[n.openAiAnyTypeName]||(a[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===n.$refStrategy?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));const l=void 0===s?a?{...c,[n.definitionPath]:a}:c:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,s].join("/"),[n.definitionPath]:{...a,[s]:c}};return"jsonSchema7"===n.target?l.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==n.target&&"openAi"!==n.target||(l.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===n.target&&("anyOf"in l||"oneOf"in l||"allOf"in l||"type"in l&&Array.isArray(l.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),l}},38823:(e,t,n)=>{"use strict";const o=n(66495);e.exports={pkg:o}},65470:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.USER_AGENT=t.PRODUCT_NAME=t.pkg=void 0;const o=n(96066);t.pkg=o;const r="google-api-nodejs-client";t.PRODUCT_NAME=r;const i=`${r}/${o.version}`;t.USER_AGENT=i},91087:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ZodError=t.quotelessJson=t.ZodIssueCode=void 0;const o=n(22046);t.ZodIssueCode=o.util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);t.quotelessJson=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},n={_errors:[]},o=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(o);else if("invalid_return_type"===r.code)o(r.returnTypeError);else if("invalid_arguments"===r.code)o(r.argumentsError);else if(0===r.path.length)n._errors.push(t(r));else{let e=n,o=0;for(;o<r.path.length;){const n=r.path[o];o===r.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(r))):e[n]=e[n]||{_errors:[]},e=e[n],o++}}};return o(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,o.util.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t=Object.create(null),n=[];for(const o of this.issues)if(o.path.length>0){const n=o.path[0];t[n]=t[n]||[],t[n].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}t.ZodError=r,r.create=e=>new r(e)},11977:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.defaultErrorMap=void 0,t.setErrorMap=function(e){i=e},t.getErrorMap=function(){return i};const r=o(n(44097));t.defaultErrorMap=r.default;let i=r.default},68953:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(11977),t),r(n(991),t),r(n(43006),t),r(n(22046),t),r(n(15063),t),r(n(91087),t)},58508:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.errorUtil=void 0,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(n||(t.errorUtil=n={}))},991:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isAsync=t.isValid=t.isDirty=t.isAborted=t.OK=t.DIRTY=t.INVALID=t.ParseStatus=t.EMPTY_PATH=t.makeIssue=void 0,t.addIssueToContext=function(e,n){const o=(0,r.getErrorMap)(),a=(0,t.makeIssue)({issueData:n,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,o,o===i.default?void 0:i.default].filter(e=>!!e)});e.common.issues.push(a)};const r=n(11977),i=o(n(44097));t.makeIssue=e=>{const{data:t,path:n,errorMaps:o,issueData:r}=e,i=[...n,...r.path||[]],a={...r,path:i};if(void 0!==r.message)return{...r,path:i,message:r.message};let s="";const c=o.filter(e=>!!e).slice().reverse();for(const e of c)s=e(a,{data:t,defaultError:s}).message;return{...r,path:i,message:s}},t.EMPTY_PATH=[];class a{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,n){const o=[];for(const r of n){if("aborted"===r.status)return t.INVALID;"dirty"===r.status&&e.dirty(),o.push(r.value)}return{status:e.value,value:o}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,o=await e.value;n.push({key:t,value:o})}return a.mergeObjectSync(e,n)}static mergeObjectSync(e,n){const o={};for(const r of n){const{key:n,value:i}=r;if("aborted"===n.status)return t.INVALID;if("aborted"===i.status)return t.INVALID;"dirty"===n.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"===n.value||void 0===i.value&&!r.alwaysSet||(o[n.value]=i.value)}return{status:e.value,value:o}}}t.ParseStatus=a,t.INVALID=Object.freeze({status:"aborted"});t.DIRTY=e=>({status:"dirty",value:e});t.OK=e=>({status:"valid",value:e});t.isAborted=e=>"aborted"===e.status;t.isDirty=e=>"dirty"===e.status;t.isValid=e=>"valid"===e.status;t.isAsync=e=>"undefined"!=typeof Promise&&e instanceof Promise},43006:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},22046:(e,t)=>{"use strict";var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.getParsedType=t.ZodParsedType=t.objectUtil=t.util=void 0,function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),o={};for(const e of n)o[e]=t[e];return e.objectValues(o)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(n||(t.util=n={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(o||(t.objectUtil=o={})),t.ZodParsedType=n.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);t.getParsedType=e=>{switch(typeof e){case"undefined":return t.ZodParsedType.undefined;case"string":return t.ZodParsedType.string;case"number":return Number.isNaN(e)?t.ZodParsedType.nan:t.ZodParsedType.number;case"boolean":return t.ZodParsedType.boolean;case"function":return t.ZodParsedType.function;case"bigint":return t.ZodParsedType.bigint;case"symbol":return t.ZodParsedType.symbol;case"object":return Array.isArray(e)?t.ZodParsedType.array:null===e?t.ZodParsedType.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?t.ZodParsedType.promise:"undefined"!=typeof Map&&e instanceof Map?t.ZodParsedType.map:"undefined"!=typeof Set&&e instanceof Set?t.ZodParsedType.set:"undefined"!=typeof Date&&e instanceof Date?t.ZodParsedType.date:t.ZodParsedType.object;default:return t.ZodParsedType.unknown}}},19968:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return r(t,e),t},a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.z=void 0;const s=i(n(68953));t.z=s,a(n(68953),t),t.default=s},44097:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(91087),r=n(22046);t.default=(e,t)=>{let n;switch(e.code){case o.ZodIssueCode.invalid_type:n=e.received===r.ZodParsedType.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case o.ZodIssueCode.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,r.util.jsonStringifyReplacer)}`;break;case o.ZodIssueCode.unrecognized_keys:n=`Unrecognized key(s) in object: ${r.util.joinValues(e.keys,", ")}`;break;case o.ZodIssueCode.invalid_union:n="Invalid input";break;case o.ZodIssueCode.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${r.util.joinValues(e.options)}`;break;case o.ZodIssueCode.invalid_enum_value:n=`Invalid enum value. Expected ${r.util.joinValues(e.options)}, received '${e.received}'`;break;case o.ZodIssueCode.invalid_arguments:n="Invalid function arguments";break;case o.ZodIssueCode.invalid_return_type:n="Invalid function return type";break;case o.ZodIssueCode.invalid_date:n="Invalid date";break;case o.ZodIssueCode.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:r.util.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case o.ZodIssueCode.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case o.ZodIssueCode.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case o.ZodIssueCode.custom:n="Invalid input";break;case o.ZodIssueCode.invalid_intersection_types:n="Intersection results could not be merged";break;case o.ZodIssueCode.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case o.ZodIssueCode.not_finite:n="Number must be finite";break;default:n=t.defaultError,r.util.assertNever(e)}return{message:n}},e.exports=t.default},15063:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.discriminatedUnion=t.date=t.boolean=t.bigint=t.array=t.any=t.coerce=t.ZodFirstPartyTypeKind=t.late=t.ZodSchema=t.Schema=t.ZodReadonly=t.ZodPipeline=t.ZodBranded=t.BRAND=t.ZodNaN=t.ZodCatch=t.ZodDefault=t.ZodNullable=t.ZodOptional=t.ZodTransformer=t.ZodEffects=t.ZodPromise=t.ZodNativeEnum=t.ZodEnum=t.ZodLiteral=t.ZodLazy=t.ZodFunction=t.ZodSet=t.ZodMap=t.ZodRecord=t.ZodTuple=t.ZodIntersection=t.ZodDiscriminatedUnion=t.ZodUnion=t.ZodObject=t.ZodArray=t.ZodVoid=t.ZodNever=t.ZodUnknown=t.ZodAny=t.ZodNull=t.ZodUndefined=t.ZodSymbol=t.ZodDate=t.ZodBoolean=t.ZodBigInt=t.ZodNumber=t.ZodString=t.ZodType=void 0,t.NEVER=t.void=t.unknown=t.union=t.undefined=t.tuple=t.transformer=t.symbol=t.string=t.strictObject=t.set=t.record=t.promise=t.preprocess=t.pipeline=t.ostring=t.optional=t.onumber=t.oboolean=t.object=t.number=t.nullable=t.null=t.never=t.nativeEnum=t.nan=t.map=t.literal=t.lazy=t.intersection=t.instanceof=t.function=t.enum=t.effect=void 0,t.datetimeRegex=R,t.custom=Se;const o=n(91087),r=n(11977),i=n(58508),a=n(991),s=n(22046);class c{constructor(e,t,n,o){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const u=(e,t)=>{if((0,a.isValid)(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new o.ZodError(e.common.issues);return this._error=t,this._error}}};function l(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:o,description:r}=e;if(t&&(n||o))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:r};return{errorMap:(t,r)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??r.defaultError}:void 0===r.data?{message:i??o??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:i??n??r.defaultError}},description:r}}class d{get description(){return this._def.description}_getType(e){return(0,s.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0,s.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new a.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,s.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if((0,a.isAsync)(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,s.getParsedType)(e)},o=this._parseSync({data:e,path:n.path,parent:n});return u(n,o)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,s.getParsedType)(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return(0,a.isValid)(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>(0,a.isValid)(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,s.getParsedType)(e)},o=this._parse({data:e,path:n.path,parent:n}),r=await((0,a.isAsync)(o)?o:Promise.resolve(o));return u(n,r)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,r)=>{const i=e(t),a=()=>r.addIssue({code:o.ZodIssueCode.custom,...n(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(e=>!!e||(a(),!1)):!!i||(a(),!1)})}refinement(e,t){return this._refinement((n,o)=>!!e(n)||(o.addIssue("function"==typeof t?t(n,o):t),!1))}_refinement(e){return new he({schema:this,typeName:xe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return fe.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return z.create(this)}promise(){return pe.create(this,this._def)}or(e){return Z.create([this,e],this._def)}and(e){return te.create(this,e,this._def)}transform(e){return new he({...l(this._def),schema:this,typeName:xe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ge({...l(this._def),innerType:this,defaultValue:t,typeName:xe.ZodDefault})}brand(){return new ve({typeName:xe.ZodBranded,type:this,...l(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new be({...l(this._def),innerType:this,catchValue:t,typeName:xe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return _e.create(this,e)}readonly(){return we.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}t.ZodType=d,t.Schema=d,t.ZodSchema=d;const p=/^c[^\s-]{8,}$/i,h=/^[0-9a-z]+$/,f=/^[0-9A-HJKMNP-TV-Z]{26}$/i,m=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,g=/^[a-z0-9_-]{21}$/i,b=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,y=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,v=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let _;const w=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,O=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,S=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,x=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,T=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,P=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,C="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",k=new RegExp(`^${C}$`);function j(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function E(e){return new RegExp(`^${j(e)}$`)}function R(e){let t=`${C}T${j(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function A(e,t){return!("v4"!==t&&t||!w.test(e))||!("v6"!==t&&t||!S.test(e))}function I(e,t){if(!b.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(o));return"object"==typeof r&&null!==r&&((!("typ"in r)||"JWT"===r?.typ)&&(!!r.alg&&(!t||r.alg===t)))}catch{return!1}}function M(e,t){return!("v4"!==t&&t||!O.test(e))||!("v6"!==t&&t||!x.test(e))}class N extends d{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==s.ZodParsedType.string){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.string,received:t.parsedType}),a.INVALID}const t=new a.ParseStatus;let n;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const i=e.data.length>r.value,s=e.data.length<r.value;(i||s)&&(n=this._getOrReturnCtx(e,n),i?(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):s&&(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)v.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"email",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)_||(_=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"emoji",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)m.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"uuid",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)g.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"nanoid",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)p.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"cuid",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)h.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"cuid2",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)f.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"ulid",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"url",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()}else if("regex"===r.kind){r.regex.lastIndex=0;r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"regex",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty())}else if("trim"===r.kind)e.data=e.data.trim();else if("includes"===r.kind)e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty());else if("toLowerCase"===r.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===r.kind)e.data=e.data.toUpperCase();else if("startsWith"===r.kind)e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty());else if("endsWith"===r.kind)e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty());else if("datetime"===r.kind){R(r).test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:"datetime",message:r.message}),t.dirty())}else if("date"===r.kind){k.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:"date",message:r.message}),t.dirty())}else if("time"===r.kind){E(r).test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:"time",message:r.message}),t.dirty())}else"duration"===r.kind?y.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"duration",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?A(e.data,r.version)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"ip",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"jwt"===r.kind?I(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"jwt",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?M(e.data,r.version)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"cidr",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?T.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"base64",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?P.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"base64url",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):s.util.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:o.ZodIssueCode.invalid_string,...i.errorUtil.errToObj(n)})}_addCheck(e){return new N({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...i.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...i.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...i.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...i.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...i.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...i.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...i.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...i.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...i.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...i.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...i.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...i.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...i.errorUtil.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...i.errorUtil.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...i.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...i.errorUtil.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...i.errorUtil.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...i.errorUtil.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...i.errorUtil.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...i.errorUtil.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...i.errorUtil.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...i.errorUtil.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...i.errorUtil.errToObj(t)})}nonempty(e){return this.min(1,i.errorUtil.errToObj(e))}trim(){return new N({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new N({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new N({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function $(e,t){const n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,r=n>o?n:o;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}t.ZodString=N,N.create=e=>new N({checks:[],typeName:xe.ZodString,coerce:e?.coerce??!1,...l(e)});class D extends d{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==s.ZodParsedType.number){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.number,received:t.parsedType}),a.INVALID}let t;const n=new a.ParseStatus;for(const r of this._def.checks)if("int"===r.kind)s.util.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else"multipleOf"===r.kind?0!==$(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.not_finite,message:r.message}),n.dirty()):s.util.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,i.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,i.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,i.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,i.errorUtil.toString(t))}setLimit(e,t,n,o){return new D({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:i.errorUtil.toString(o)}]})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:i.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:i.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:i.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:i.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:i.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:i.errorUtil.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:i.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:i.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:i.errorUtil.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&s.util.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}t.ZodNumber=D,D.create=e=>new D({checks:[],typeName:xe.ZodNumber,coerce:e?.coerce||!1,...l(e)});class U extends d{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==s.ZodParsedType.bigint)return this._getInvalidInput(e);let t;const n=new a.ParseStatus;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):s.util.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.bigint,received:t.parsedType}),a.INVALID}gte(e,t){return this.setLimit("min",e,!0,i.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,i.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,i.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,i.errorUtil.toString(t))}setLimit(e,t,n,o){return new U({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:i.errorUtil.toString(o)}]})}_addCheck(e){return new U({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:i.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:i.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:i.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:i.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:i.errorUtil.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}t.ZodBigInt=U,U.create=e=>new U({checks:[],typeName:xe.ZodBigInt,coerce:e?.coerce??!1,...l(e)});class L extends d{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==s.ZodParsedType.boolean){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.boolean,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodBoolean=L,L.create=e=>new L({typeName:xe.ZodBoolean,coerce:e?.coerce||!1,...l(e)});class q extends d{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==s.ZodParsedType.date){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.date,received:t.parsedType}),a.INVALID}if(Number.isNaN(e.data.getTime())){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_date}),a.INVALID}const t=new a.ParseStatus;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):s.util.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:i.errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:i.errorUtil.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}t.ZodDate=q,q.create=e=>new q({checks:[],coerce:e?.coerce||!1,typeName:xe.ZodDate,...l(e)});class F extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.symbol){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.symbol,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodSymbol=F,F.create=e=>new F({typeName:xe.ZodSymbol,...l(e)});class W extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.undefined){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.undefined,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodUndefined=W,W.create=e=>new W({typeName:xe.ZodUndefined,...l(e)});class J extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.null){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.null,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodNull=J,J.create=e=>new J({typeName:xe.ZodNull,...l(e)});class B extends d{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,a.OK)(e.data)}}t.ZodAny=B,B.create=e=>new B({typeName:xe.ZodAny,...l(e)});class G extends d{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,a.OK)(e.data)}}t.ZodUnknown=G,G.create=e=>new G({typeName:xe.ZodUnknown,...l(e)});class V extends d{_parse(e){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.never,received:t.parsedType}),a.INVALID}}t.ZodNever=V,V.create=e=>new V({typeName:xe.ZodNever,...l(e)});class H extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.undefined){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.void,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodVoid=H,H.create=e=>new H({typeName:xe.ZodVoid,...l(e)});class z extends d{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==s.ZodParsedType.array)return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.array,received:t.parsedType}),a.INVALID;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&((0,a.addIssueToContext)(t,{code:e?o.ZodIssueCode.too_big:o.ZodIssueCode.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&((0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&((0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new c(t,e,t.path,n)))).then(e=>a.ParseStatus.mergeArray(n,e));const i=[...t.data].map((e,n)=>r.type._parseSync(new c(t,e,t.path,n)));return a.ParseStatus.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new z({...this._def,minLength:{value:e,message:i.errorUtil.toString(t)}})}max(e,t){return new z({...this._def,maxLength:{value:e,message:i.errorUtil.toString(t)}})}length(e,t){return new z({...this._def,exactLength:{value:e,message:i.errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}}function K(e){if(e instanceof X){const t={};for(const n in e.shape){const o=e.shape[n];t[n]=fe.create(K(o))}return new X({...e._def,shape:()=>t})}return e instanceof z?new z({...e._def,type:K(e.element)}):e instanceof fe?fe.create(K(e.unwrap())):e instanceof me?me.create(K(e.unwrap())):e instanceof ne?ne.create(e.items.map(e=>K(e))):e}t.ZodArray=z,z.create=(e,t)=>new z({type:e,minLength:null,maxLength:null,exactLength:null,typeName:xe.ZodArray,...l(t)});class X extends d{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=s.util.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==s.ZodParsedType.object){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.object,received:t.parsedType}),a.INVALID}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),u=[];if(!(this._def.catchall instanceof V&&"strip"===this._def.unknownKeys))for(const e in n.data)i.includes(e)||u.push(e);const l=[];for(const e of i){const t=r[e],o=n.data[e];l.push({key:{status:"valid",value:e},value:t._parse(new c(n,o,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof V){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of u)l.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)u.length>0&&((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.unrecognized_keys,keys:u}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of u){const o=n.data[t];l.push({key:{status:"valid",value:t},value:e._parse(new c(n,o,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of l){const n=await t.key,o=await t.value;e.push({key:n,value:o,alwaysSet:t.alwaysSet})}return e}).then(e=>a.ParseStatus.mergeObjectSync(t,e)):a.ParseStatus.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return i.errorUtil.errToObj,new X({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{const o=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:i.errorUtil.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new X({...this._def,unknownKeys:"strip"})}passthrough(){return new X({...this._def,unknownKeys:"passthrough"})}extend(e){return new X({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new X({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:xe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new X({...this._def,catchall:e})}pick(e){const t={};for(const n of s.util.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new X({...this._def,shape:()=>t})}omit(e){const t={};for(const n of s.util.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new X({...this._def,shape:()=>t})}deepPartial(){return K(this)}partial(e){const t={};for(const n of s.util.objectKeys(this.shape)){const o=this.shape[n];e&&!e[n]?t[n]=o:t[n]=o.optional()}return new X({...this._def,shape:()=>t})}required(e){const t={};for(const n of s.util.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof fe;)e=e._def.innerType;t[n]=e}return new X({...this._def,shape:()=>t})}keyof(){return ue(s.util.objectKeys(this.shape))}}t.ZodObject=X,X.create=(e,t)=>new X({shape:()=>e,unknownKeys:"strip",catchall:V.create(),typeName:xe.ZodObject,...l(t)}),X.strictCreate=(e,t)=>new X({shape:()=>e,unknownKeys:"strict",catchall:V.create(),typeName:xe.ZodObject,...l(t)}),X.lazycreate=(e,t)=>new X({shape:e,unknownKeys:"strip",catchall:V.create(),typeName:xe.ZodObject,...l(t)});class Z extends d{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map(e=>new o.ZodError(e.ctx.common.issues));return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_union,unionErrors:n}),a.INVALID});{let e;const r=[];for(const o of n){const n={...t,common:{...t.common,issues:[]},parent:null},i=o._parseSync({data:t.data,path:t.path,parent:n});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=r.map(e=>new o.ZodError(e));return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_union,unionErrors:i}),a.INVALID}}get options(){return this._def.options}}t.ZodUnion=Z,Z.create=(e,t)=>new Z({options:e,typeName:xe.ZodUnion,...l(t)});const Y=e=>e instanceof se?Y(e.schema):e instanceof he?Y(e.innerType()):e instanceof ce?[e.value]:e instanceof le?e.options:e instanceof de?s.util.objectValues(e.enum):e instanceof ge?Y(e._def.innerType):e instanceof W?[void 0]:e instanceof J?[null]:e instanceof fe?[void 0,...Y(e.unwrap())]:e instanceof me?[null,...Y(e.unwrap())]:e instanceof ve||e instanceof we?Y(e.unwrap()):e instanceof be?Y(e._def.innerType):[];class Q extends d{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.ZodParsedType.object)return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.object,received:t.parsedType}),a.INVALID;const n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):((0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),a.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const o=new Map;for(const n of t){const t=Y(n.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const r of t){if(o.has(r))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(r)}`);o.set(r,n)}}return new Q({typeName:xe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:o,...l(n)})}}function ee(e,t){const n=(0,s.getParsedType)(e),o=(0,s.getParsedType)(t);if(e===t)return{valid:!0,data:e};if(n===s.ZodParsedType.object&&o===s.ZodParsedType.object){const n=s.util.objectKeys(t),o=s.util.objectKeys(e).filter(e=>-1!==n.indexOf(e)),r={...e,...t};for(const n of o){const o=ee(e[n],t[n]);if(!o.valid)return{valid:!1};r[n]=o.data}return{valid:!0,data:r}}if(n===s.ZodParsedType.array&&o===s.ZodParsedType.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let o=0;o<e.length;o++){const r=ee(e[o],t[o]);if(!r.valid)return{valid:!1};n.push(r.data)}return{valid:!0,data:n}}return n===s.ZodParsedType.date&&o===s.ZodParsedType.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}t.ZodDiscriminatedUnion=Q;class te extends d{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if((0,a.isAborted)(e)||(0,a.isAborted)(r))return a.INVALID;const i=ee(e.value,r.value);return i.valid?(((0,a.isDirty)(e)||(0,a.isDirty)(r))&&t.dirty(),{status:t.value,value:i.data}):((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_intersection_types}),a.INVALID)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}t.ZodIntersection=te,te.create=(e,t,n)=>new te({left:e,right:t,typeName:xe.ZodIntersection,...l(n)});class ne extends d{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.ZodParsedType.array)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.array,received:n.parsedType}),a.INVALID;if(n.data.length<this._def.items.length)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),a.INVALID;!this._def.rest&&n.data.length>this._def.items.length&&((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((e,t)=>{const o=this._def.items[t]||this._def.rest;return o?o._parse(new c(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>a.ParseStatus.mergeArray(t,e)):a.ParseStatus.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ne({...this._def,rest:e})}}t.ZodTuple=ne,ne.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ne({items:e,typeName:xe.ZodTuple,rest:null,...l(t)})};class oe extends d{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.ZodParsedType.object)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.object,received:n.parsedType}),a.INVALID;const r=[],i=this._def.keyType,u=this._def.valueType;for(const e in n.data)r.push({key:i._parse(new c(n,e,n.path,e)),value:u._parse(new c(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?a.ParseStatus.mergeObjectAsync(t,r):a.ParseStatus.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return new oe(t instanceof d?{keyType:e,valueType:t,typeName:xe.ZodRecord,...l(n)}:{keyType:N.create(),valueType:e,typeName:xe.ZodRecord,...l(t)})}}t.ZodRecord=oe;class re extends d{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.ZodParsedType.map)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.map,received:n.parsedType}),a.INVALID;const r=this._def.keyType,i=this._def.valueType,u=[...n.data.entries()].map(([e,t],o)=>({key:r._parse(new c(n,e,n.path,[o,"key"])),value:i._parse(new c(n,t,n.path,[o,"value"]))}));if(n.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const n of u){const o=await n.key,r=await n.value;if("aborted"===o.status||"aborted"===r.status)return a.INVALID;"dirty"!==o.status&&"dirty"!==r.status||t.dirty(),e.set(o.value,r.value)}return{status:t.value,value:e}})}{const e=new Map;for(const n of u){const o=n.key,r=n.value;if("aborted"===o.status||"aborted"===r.status)return a.INVALID;"dirty"!==o.status&&"dirty"!==r.status||t.dirty(),e.set(o.value,r.value)}return{status:t.value,value:e}}}}t.ZodMap=re,re.create=(e,t,n)=>new re({valueType:t,keyType:e,typeName:xe.ZodMap,...l(n)});class ie extends d{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.ZodParsedType.set)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.set,received:n.parsedType}),a.INVALID;const r=this._def;null!==r.minSize&&n.data.size<r.minSize.value&&((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&n.data.size>r.maxSize.value&&((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function u(e){const n=new Set;for(const o of e){if("aborted"===o.status)return a.INVALID;"dirty"===o.status&&t.dirty(),n.add(o.value)}return{status:t.value,value:n}}const l=[...n.data.values()].map((e,t)=>i._parse(new c(n,e,n.path,t)));return n.common.async?Promise.all(l).then(e=>u(e)):u(l)}min(e,t){return new ie({...this._def,minSize:{value:e,message:i.errorUtil.toString(t)}})}max(e,t){return new ie({...this._def,maxSize:{value:e,message:i.errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}t.ZodSet=ie,ie.create=(e,t)=>new ie({valueType:e,minSize:null,maxSize:null,typeName:xe.ZodSet,...l(t)});class ae extends d{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.ZodParsedType.function)return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.function,received:t.parsedType}),a.INVALID;function n(e,n){return(0,a.makeIssue)({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,r.getErrorMap)(),r.defaultErrorMap].filter(e=>!!e),issueData:{code:o.ZodIssueCode.invalid_arguments,argumentsError:n}})}function i(e,n){return(0,a.makeIssue)({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,r.getErrorMap)(),r.defaultErrorMap].filter(e=>!!e),issueData:{code:o.ZodIssueCode.invalid_return_type,returnTypeError:n}})}const c={errorMap:t.common.contextualErrorMap},u=t.data;if(this._def.returns instanceof pe){const e=this;return(0,a.OK)(async function(...t){const r=new o.ZodError([]),a=await e._def.args.parseAsync(t,c).catch(e=>{throw r.addIssue(n(t,e)),r}),s=await Reflect.apply(u,this,a);return await e._def.returns._def.type.parseAsync(s,c).catch(e=>{throw r.addIssue(i(s,e)),r})})}{const e=this;return(0,a.OK)(function(...t){const r=e._def.args.safeParse(t,c);if(!r.success)throw new o.ZodError([n(t,r.error)]);const a=Reflect.apply(u,this,r.data),s=e._def.returns.safeParse(a,c);if(!s.success)throw new o.ZodError([i(a,s.error)]);return s.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ae({...this._def,args:ne.create(e).rest(G.create())})}returns(e){return new ae({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ae({args:e||ne.create([]).rest(G.create()),returns:t||G.create(),typeName:xe.ZodFunction,...l(n)})}}t.ZodFunction=ae;class se extends d{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}t.ZodLazy=se,se.create=(e,t)=>new se({getter:e,typeName:xe.ZodLazy,...l(t)});class ce extends d{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{received:t.data,code:o.ZodIssueCode.invalid_literal,expected:this._def.value}),a.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ue(e,t){return new le({values:e,typeName:xe.ZodEnum,...l(t)})}t.ZodLiteral=ce,ce.create=(e,t)=>new ce({value:e,typeName:xe.ZodLiteral,...l(t)});class le extends d{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return(0,a.addIssueToContext)(t,{expected:s.util.joinValues(n),received:t.parsedType,code:o.ZodIssueCode.invalid_type}),a.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return(0,a.addIssueToContext)(t,{received:t.data,code:o.ZodIssueCode.invalid_enum_value,options:n}),a.INVALID}return(0,a.OK)(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return le.create(e,{...this._def,...t})}exclude(e,t=this._def){return le.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}t.ZodEnum=le,le.create=ue;class de extends d{_parse(e){const t=s.util.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==s.ZodParsedType.string&&n.parsedType!==s.ZodParsedType.number){const e=s.util.objectValues(t);return(0,a.addIssueToContext)(n,{expected:s.util.joinValues(e),received:n.parsedType,code:o.ZodIssueCode.invalid_type}),a.INVALID}if(this._cache||(this._cache=new Set(s.util.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=s.util.objectValues(t);return(0,a.addIssueToContext)(n,{received:n.data,code:o.ZodIssueCode.invalid_enum_value,options:e}),a.INVALID}return(0,a.OK)(e.data)}get enum(){return this._def.values}}t.ZodNativeEnum=de,de.create=(e,t)=>new de({values:e,typeName:xe.ZodNativeEnum,...l(t)});class pe extends d{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.ZodParsedType.promise&&!1===t.common.async)return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.promise,received:t.parsedType}),a.INVALID;const n=t.parsedType===s.ZodParsedType.promise?t.data:Promise.resolve(t.data);return(0,a.OK)(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}t.ZodPromise=pe,pe.create=(e,t)=>new pe({type:e,typeName:xe.ZodPromise,...l(t)});class he extends d{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),o=this._def.effect||null,r={addIssue:e=>{(0,a.addIssueToContext)(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===o.type){const e=o.transform(n.data,r);if(n.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return a.INVALID;const o=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===o.status?a.INVALID:"dirty"===o.status||"dirty"===t.value?(0,a.DIRTY)(o.value):o});{if("aborted"===t.value)return a.INVALID;const o=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===o.status?a.INVALID:"dirty"===o.status||"dirty"===t.value?(0,a.DIRTY)(o.value):o}}if("refinement"===o.type){const e=e=>{const t=o.refinement(e,r);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===o.status?a.INVALID:("dirty"===o.status&&t.dirty(),e(o.value),{status:t.value,value:o.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>"aborted"===n.status?a.INVALID:("dirty"===n.status&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if("transform"===o.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!(0,a.isValid)(e))return a.INVALID;const i=o.transform(e.value,r);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>(0,a.isValid)(e)?Promise.resolve(o.transform(e.value,r)).then(e=>({status:t.value,value:e})):a.INVALID)}s.util.assertNever(o)}}t.ZodEffects=he,t.ZodTransformer=he,he.create=(e,t,n)=>new he({schema:e,typeName:xe.ZodEffects,effect:t,...l(n)}),he.createWithPreprocess=(e,t,n)=>new he({schema:t,effect:{type:"preprocess",transform:e},typeName:xe.ZodEffects,...l(n)});class fe extends d{_parse(e){return this._getType(e)===s.ZodParsedType.undefined?(0,a.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t.ZodOptional=fe,fe.create=(e,t)=>new fe({innerType:e,typeName:xe.ZodOptional,...l(t)});class me extends d{_parse(e){return this._getType(e)===s.ZodParsedType.null?(0,a.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t.ZodNullable=me,me.create=(e,t)=>new me({innerType:e,typeName:xe.ZodNullable,...l(t)});class ge extends d{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===s.ZodParsedType.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}t.ZodDefault=ge,ge.create=(e,t)=>new ge({innerType:e,typeName:xe.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...l(t)});class be extends d{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return(0,a.isAsync)(r)?r.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new o.ZodError(n.common.issues)},input:n.data})})):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new o.ZodError(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}t.ZodCatch=be,be.create=(e,t)=>new be({innerType:e,typeName:xe.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...l(t)});class ye extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.nan){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.nan,received:t.parsedType}),a.INVALID}return{status:"valid",value:e.data}}}t.ZodNaN=ye,ye.create=e=>new ye({typeName:xe.ZodNaN,...l(e)}),t.BRAND=Symbol("zod_brand");class ve extends d{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}t.ZodBranded=ve;class _e extends d{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?a.INVALID:"dirty"===e.status?(t.dirty(),(0,a.DIRTY)(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?a.INVALID:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new _e({in:e,out:t,typeName:xe.ZodPipeline})}}t.ZodPipeline=_e;class we extends d{_parse(e){const t=this._def.innerType._parse(e),n=e=>((0,a.isValid)(e)&&(e.value=Object.freeze(e.value)),e);return(0,a.isAsync)(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}}function Oe(e,t){const n="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof n?{message:n}:n}function Se(e,t={},n){return e?B.create().superRefine((o,r)=>{const i=e(o);if(i instanceof Promise)return i.then(e=>{if(!e){const e=Oe(t,o),i=e.fatal??n??!0;r.addIssue({code:"custom",...e,fatal:i})}});if(!i){const e=Oe(t,o),i=e.fatal??n??!0;r.addIssue({code:"custom",...e,fatal:i})}}):B.create()}var xe;t.ZodReadonly=we,we.create=(e,t)=>new we({innerType:e,typeName:xe.ZodReadonly,...l(t)}),t.late={object:X.lazycreate},function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(xe||(t.ZodFirstPartyTypeKind=xe={}));t.instanceof=(e,t={message:`Input not instance of ${e.name}`})=>Se(t=>t instanceof e,t);const Te=N.create;t.string=Te;const Pe=D.create;t.number=Pe;const Ce=ye.create;t.nan=Ce;const ke=U.create;t.bigint=ke;const je=L.create;t.boolean=je;const Ee=q.create;t.date=Ee;const Re=F.create;t.symbol=Re;const Ae=W.create;t.undefined=Ae;const Ie=J.create;t.null=Ie;const Me=B.create;t.any=Me;const Ne=G.create;t.unknown=Ne;const $e=V.create;t.never=$e;const De=H.create;t.void=De;const Ue=z.create;t.array=Ue;const Le=X.create;t.object=Le;const qe=X.strictCreate;t.strictObject=qe;const Fe=Z.create;t.union=Fe;const We=Q.create;t.discriminatedUnion=We;const Je=te.create;t.intersection=Je;const Be=ne.create;t.tuple=Be;const Ge=oe.create;t.record=Ge;const Ve=re.create;t.map=Ve;const He=ie.create;t.set=He;const ze=ae.create;t.function=ze;const Ke=se.create;t.lazy=Ke;const Xe=ce.create;t.literal=Xe;const Ze=le.create;t.enum=Ze;const Ye=de.create;t.nativeEnum=Ye;const Qe=pe.create;t.promise=Qe;const et=he.create;t.effect=et,t.transformer=et;const tt=fe.create;t.optional=tt;const nt=me.create;t.nullable=nt;const ot=he.createWithPreprocess;t.preprocess=ot;const rt=_e.create;t.pipeline=rt;t.ostring=()=>Te().optional();t.onumber=()=>Pe().optional();t.oboolean=()=>je().optional(),t.coerce={string:e=>N.create({...e,coerce:!0}),number:e=>D.create({...e,coerce:!0}),boolean:e=>L.create({...e,coerce:!0}),bigint:e=>U.create({...e,coerce:!0}),date:e=>q.create({...e,coerce:!0})},t.NEVER=a.INVALID},99641:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AssistantMessageEventStream:()=>Zn,EventStream:()=>Xn,StringEnum:()=>ab,Type:()=>o.ZU,buildRequest:()=>Hm,calculateCost:()=>S,clearApiProviders:()=>d,complete:()=>eb,completeSimple:()=>nb,convertMessages:()=>dg,createAssistantMessageEventStream:()=>Yn,extractRetryDelay:()=>Lm,getApiProvider:()=>c,getApiProviders:()=>u,getEnvApiKey:()=>b,getModel:()=>_,getModels:()=>O,getOverflowPatterns:()=>ib,getProviders:()=>w,isContextOverflow:()=>rb,modelsAreEqual:()=>T,parseStreamingJson:()=>eo,registerApiProvider:()=>s,registerBuiltInApiProviders:()=>Xg,resetApiProviders:()=>Zg,setBedrockProviderModule:()=>Bg,stream:()=>Qg,streamAnthropic:()=>mo,streamAzureOpenAIResponses:()=>Fc,streamGoogle:()=>jm,streamGoogleGeminiCli:()=>Gm,streamGoogleVertex:()=>Zm,streamMistral:()=>og,streamOpenAICompletions:()=>ug,streamOpenAIResponses:()=>mg,streamSimple:()=>tb,streamSimpleAnthropic:()=>bo,streamSimpleAzureOpenAIResponses:()=>Wc,streamSimpleGoogle:()=>Em,streamSimpleGoogleGeminiCli:()=>Vm,streamSimpleGoogleVertex:()=>Ym,streamSimpleMistral:()=>rg,streamSimpleOpenAICompletions:()=>lg,streamSimpleOpenAIResponses:()=>gg,supportsXhigh:()=>x,unregisterApiProviders:()=>l,validateToolArguments:()=>fb,validateToolCall:()=>hb});var o=n(26788);const r=new Map;function i(e,t){return(n,o,r)=>{if(n.api!==e)throw new Error(`Mismatched api: ${n.api} expected ${e}`);return t(n,o,r)}}function a(e,t){return(n,o,r)=>{if(n.api!==e)throw new Error(`Mismatched api: ${n.api} expected ${e}`);return t(n,o,r)}}function s(e,t){r.set(e.api,{provider:{api:e.api,stream:i(e.api,e.stream),streamSimple:a(e.api,e.streamSimple)},sourceId:t})}function c(e){return r.get(e)?.provider}function u(){return Array.from(r.values(),e=>e.provider)}function l(e){for(const[t,n]of r.entries())n.sourceId===e&&r.delete(t)}function d(){r.clear()}let p=null,h=null,f=null;const m=e=>n(70162)(e);"undefined"!=typeof process&&(process.versions?.node||process.versions?.bun)&&(m("node:fs").then(e=>{p=e.existsSync}),m("node:os").then(e=>{h=e.homedir}),m("node:path").then(e=>{f=e.join}));let g=null;function b(e){if("github-copilot"===e)return process.env.COPILOT_GITHUB_TOKEN||process.env.GH_TOKEN||process.env.GITHUB_TOKEN;if("anthropic"===e)return process.env.ANTHROPIC_OAUTH_TOKEN||process.env.ANTHROPIC_API_KEY;if("google-vertex"===e){const e=function(){if(null===g){if(!p||!h||!f)return"undefined"!=typeof process&&(process.versions?.node||process.versions?.bun)||(g=!1),!1;const e=process.env.GOOGLE_APPLICATION_CREDENTIALS;g=p(e||f(h(),".config","gcloud","application_default_credentials.json"))}return g}(),t=!(!process.env.GOOGLE_CLOUD_PROJECT&&!process.env.GCLOUD_PROJECT),n=!!process.env.GOOGLE_CLOUD_LOCATION;if(e&&t&&n)return"<authenticated>"}if("amazon-bedrock"===e&&(process.env.AWS_PROFILE||process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY||process.env.AWS_BEARER_TOKEN_BEDROCK||process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI||process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI||process.env.AWS_WEB_IDENTITY_TOKEN_FILE))return"<authenticated>";const t={openai:"OPENAI_API_KEY","azure-openai-responses":"AZURE_OPENAI_API_KEY",google:"GEMINI_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",xai:"XAI_API_KEY",openrouter:"OPENROUTER_API_KEY","vercel-ai-gateway":"AI_GATEWAY_API_KEY",zai:"ZAI_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_CN_API_KEY",huggingface:"HF_TOKEN",opencode:"OPENCODE_API_KEY","opencode-go":"OPENCODE_API_KEY","kimi-coding":"KIMI_API_KEY"}[e];return t?process.env[t]:void 0}const y={"amazon-bedrock":{"amazon.nova-2-lite-v1:0":{id:"amazon.nova-2-lite-v1:0",name:"Nova 2 Lite",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.33,output:2.75,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"amazon.nova-lite-v1:0":{id:"amazon.nova-lite-v1:0",name:"Nova Lite",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.06,output:.24,cacheRead:.015,cacheWrite:0},contextWindow:3e5,maxTokens:8192},"amazon.nova-micro-v1:0":{id:"amazon.nova-micro-v1:0",name:"Nova Micro",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.035,output:.14,cacheRead:.00875,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"amazon.nova-premier-v1:0":{id:"amazon.nova-premier-v1:0",name:"Nova Premier",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2.5,output:12.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:16384},"amazon.nova-pro-v1:0":{id:"amazon.nova-pro-v1:0",name:"Nova Pro",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:3e5,maxTokens:8192},"amazon.titan-text-express-v1":{id:"amazon.titan-text-express-v1",name:"Titan Text G1 - Express",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"amazon.titan-text-express-v1:0:8k":{id:"amazon.titan-text-express-v1:0:8k",name:"Titan Text G1 - Express",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"anthropic.claude-3-5-haiku-20241022-v1:0":{id:"anthropic.claude-3-5-haiku-20241022-v1:0",name:"Claude Haiku 3.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"anthropic.claude-3-5-sonnet-20240620-v1:0":{id:"anthropic.claude-3-5-sonnet-20240620-v1:0",name:"Claude Sonnet 3.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic.claude-3-5-sonnet-20241022-v2:0":{id:"anthropic.claude-3-5-sonnet-20241022-v2:0",name:"Claude Sonnet 3.5 v2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic.claude-3-7-sonnet-20250219-v1:0":{id:"anthropic.claude-3-7-sonnet-20250219-v1:0",name:"Claude Sonnet 3.7",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic.claude-3-haiku-20240307-v1:0":{id:"anthropic.claude-3-haiku-20240307-v1:0",name:"Claude Haiku 3",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096},"anthropic.claude-3-opus-20240229-v1:0":{id:"anthropic.claude-3-opus-20240229-v1:0",name:"Claude Opus 3",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:15,output:75,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096},"anthropic.claude-3-sonnet-20240229-v1:0":{id:"anthropic.claude-3-sonnet-20240229-v1:0",name:"Claude Sonnet 3",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096},"anthropic.claude-haiku-4-5-20251001-v1:0":{id:"anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-opus-4-1-20250805-v1:0":{id:"anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic.claude-opus-4-20250514-v1:0":{id:"anthropic.claude-opus-4-20250514-v1:0",name:"Claude Opus 4",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic.claude-opus-4-5-20251101-v1:0":{id:"anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-opus-4-6-v1":{id:"anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"anthropic.claude-sonnet-4-20250514-v1:0":{id:"anthropic.claude-sonnet-4-20250514-v1:0",name:"Claude Sonnet 4",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-sonnet-4-6":{id:"anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"cohere.command-r-plus-v1:0":{id:"cohere.command-r-plus-v1:0",name:"Command R+",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"cohere.command-r-v1:0":{id:"cohere.command-r-v1:0",name:"Command R",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"deepseek.r1-v1:0":{id:"deepseek.r1-v1:0",name:"DeepSeek-R1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32768},"deepseek.v3-v1:0":{id:"deepseek.v3-v1:0",name:"DeepSeek-V3.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.58,output:1.68,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:81920},"deepseek.v3.2-v1:0":{id:"deepseek.v3.2-v1:0",name:"DeepSeek-V3.2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.62,output:1.85,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:81920},"eu.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"eu.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-opus-4-5-20251101-v1:0":{id:"eu.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-opus-4-6-v1":{id:"eu.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"eu.anthropic.claude-sonnet-4-20250514-v1:0":{id:"eu.anthropic.claude-sonnet-4-20250514-v1:0",name:"Claude Sonnet 4 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"eu.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-sonnet-4-6":{id:"eu.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"global.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-opus-4-5-20251101-v1:0":{id:"global.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-opus-4-6-v1":{id:"global.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"global.anthropic.claude-sonnet-4-20250514-v1:0":{id:"global.anthropic.claude-sonnet-4-20250514-v1:0",name:"Claude Sonnet 4 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"global.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-sonnet-4-6":{id:"global.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"google.gemma-3-27b-it":{id:"google.gemma-3-27b-it",name:"Google Gemma 3 27B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.12,output:.2,cacheRead:0,cacheWrite:0},contextWindow:202752,maxTokens:8192},"google.gemma-3-4b-it":{id:"google.gemma-3-4b-it",name:"Gemma 3 4B IT",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.04,output:.08,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-1-70b-instruct-v1:0":{id:"meta.llama3-1-70b-instruct-v1:0",name:"Llama 3.1 70B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-1-8b-instruct-v1:0":{id:"meta.llama3-1-8b-instruct-v1:0",name:"Llama 3.1 8B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:.22,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-2-11b-instruct-v1:0":{id:"meta.llama3-2-11b-instruct-v1:0",name:"Llama 3.2 11B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.16,output:.16,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-2-1b-instruct-v1:0":{id:"meta.llama3-2-1b-instruct-v1:0",name:"Llama 3.2 1B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"meta.llama3-2-3b-instruct-v1:0":{id:"meta.llama3-2-3b-instruct-v1:0",name:"Llama 3.2 3B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"meta.llama3-2-90b-instruct-v1:0":{id:"meta.llama3-2-90b-instruct-v1:0",name:"Llama 3.2 90B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-3-70b-instruct-v1:0":{id:"meta.llama3-3-70b-instruct-v1:0",name:"Llama 3.3 70B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama4-maverick-17b-instruct-v1:0":{id:"meta.llama4-maverick-17b-instruct-v1:0",name:"Llama 4 Maverick 17B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.24,output:.97,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:16384},"meta.llama4-scout-17b-instruct-v1:0":{id:"meta.llama4-scout-17b-instruct-v1:0",name:"Llama 4 Scout 17B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.17,output:.66,cacheRead:0,cacheWrite:0},contextWindow:35e5,maxTokens:16384},"minimax.minimax-m2":{id:"minimax.minimax-m2",name:"MiniMax M2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204608,maxTokens:128e3},"minimax.minimax-m2.1":{id:"minimax.minimax-m2.1",name:"MiniMax M2.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"mistral.ministral-3-14b-instruct":{id:"mistral.ministral-3-14b-instruct",name:"Ministral 14B 3.0",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.2,output:.2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.ministral-3-8b-instruct":{id:"mistral.ministral-3-8b-instruct",name:"Ministral 3 8B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.mistral-large-2402-v1:0":{id:"mistral.mistral-large-2402-v1:0",name:"Mistral Large (24.02)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.voxtral-mini-3b-2507":{id:"mistral.voxtral-mini-3b-2507",name:"Voxtral Mini 3B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.04,output:.04,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.voxtral-small-24b-2507":{id:"mistral.voxtral-small-24b-2507",name:"Voxtral Small 24B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.35,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:8192},"moonshot.kimi-k2-thinking":{id:"moonshot.kimi-k2-thinking",name:"Kimi K2 Thinking",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"moonshotai.kimi-k2.5":{id:"moonshotai.kimi-k2.5",name:"Kimi K2.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"nvidia.nemotron-nano-12b-v2":{id:"nvidia.nemotron-nano-12b-v2",name:"NVIDIA Nemotron Nano 12B v2 VL BF16",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"nvidia.nemotron-nano-9b-v2":{id:"nvidia.nemotron-nano-9b-v2",name:"NVIDIA Nemotron Nano 9B v2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.06,output:.23,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai.gpt-oss-120b-1:0":{id:"openai.gpt-oss-120b-1:0",name:"gpt-oss-120b",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai.gpt-oss-20b-1:0":{id:"openai.gpt-oss-20b-1:0",name:"gpt-oss-20b",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.07,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai.gpt-oss-safeguard-120b":{id:"openai.gpt-oss-safeguard-120b",name:"GPT OSS Safeguard 120B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai.gpt-oss-safeguard-20b":{id:"openai.gpt-oss-safeguard-20b",name:"GPT OSS Safeguard 20B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.07,output:.2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"qwen.qwen3-235b-a22b-2507-v1:0":{id:"qwen.qwen3-235b-a22b-2507-v1:0",name:"Qwen3 235B A22B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:.88,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"qwen.qwen3-32b-v1:0":{id:"qwen.qwen3-32b-v1:0",name:"Qwen3 32B (dense)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:16384,maxTokens:16384},"qwen.qwen3-coder-30b-a3b-v1:0":{id:"qwen.qwen3-coder-30b-a3b-v1:0",name:"Qwen3 Coder 30B A3B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"qwen.qwen3-coder-480b-a35b-v1:0":{id:"qwen.qwen3-coder-480b-a35b-v1:0",name:"Qwen3 Coder 480B A35B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:1.8,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"qwen.qwen3-next-80b-a3b":{id:"qwen.qwen3-next-80b-a3b",name:"Qwen/Qwen3-Next-80B-A3B-Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.14,output:1.4,cacheRead:0,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"qwen.qwen3-vl-235b-a22b":{id:"qwen.qwen3-vl-235b-a22b",name:"Qwen/Qwen3-VL-235B-A22B-Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.3,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"us.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"us.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-opus-4-1-20250805-v1:0":{id:"us.anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"us.anthropic.claude-opus-4-20250514-v1:0":{id:"us.anthropic.claude-opus-4-20250514-v1:0",name:"Claude Opus 4 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"us.anthropic.claude-opus-4-5-20251101-v1:0":{id:"us.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-opus-4-6-v1":{id:"us.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"us.anthropic.claude-sonnet-4-20250514-v1:0":{id:"us.anthropic.claude-sonnet-4-20250514-v1:0",name:"Claude Sonnet 4 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"us.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-sonnet-4-6":{id:"us.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"writer.palmyra-x4-v1:0":{id:"writer.palmyra-x4-v1:0",name:"Palmyra X4",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:122880,maxTokens:8192},"writer.palmyra-x5-v1:0":{id:"writer.palmyra-x5-v1:0",name:"Palmyra X5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:6,cacheRead:0,cacheWrite:0},contextWindow:104e4,maxTokens:8192},"zai.glm-4.7":{id:"zai.glm-4.7",name:"GLM-4.7",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"zai.glm-4.7-flash":{id:"zai.glm-4.7-flash",name:"GLM-4.7-Flash",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.07,output:.4,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:131072}},anthropic:{"claude-3-5-haiku-20241022":{id:"claude-3-5-haiku-20241022",name:"Claude Haiku 3.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"claude-3-5-haiku-latest":{id:"claude-3-5-haiku-latest",name:"Claude Haiku 3.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"claude-3-5-sonnet-20240620":{id:"claude-3-5-sonnet-20240620",name:"Claude Sonnet 3.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"claude-3-5-sonnet-20241022":{id:"claude-3-5-sonnet-20241022",name:"Claude Sonnet 3.5 v2",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"claude-3-7-sonnet-20250219":{id:"claude-3-7-sonnet-20250219",name:"Claude Sonnet 3.7",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-3-7-sonnet-latest":{id:"claude-3-7-sonnet-latest",name:"Claude Sonnet 3.7 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-3-haiku-20240307":{id:"claude-3-haiku-20240307",name:"Claude Haiku 3",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"claude-3-opus-20240229":{id:"claude-3-opus-20240229",name:"Claude Opus 3",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:4096},"claude-3-sonnet-20240229":{id:"claude-3-sonnet-20240229",name:"Claude Sonnet 3",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"claude-haiku-4-5":{id:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-haiku-4-5-20251001":{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-0":{id:"claude-opus-4-0",name:"Claude Opus 4 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-1":{id:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-1-20250805":{id:"claude-opus-4-1-20250805",name:"Claude Opus 4.1",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-20250514":{id:"claude-opus-4-20250514",name:"Claude Opus 4",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-5":{id:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-5-20251101":{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-6":{id:"claude-opus-4-6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"claude-sonnet-4-0":{id:"claude-sonnet-4-0",name:"Claude Sonnet 4 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-20250514":{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5-20250929":{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3}},"azure-openai-responses":{"codex-mini-latest":{id:"codex-mini-latest",name:"Codex Mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.5,output:6,cacheRead:.375,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"gpt-4":{id:"gpt-4",name:"GPT-4",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"gpt-4-turbo":{id:"gpt-4-turbo",name:"GPT-4 Turbo",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-mini":{id:"gpt-4.1-mini",name:"GPT-4.1 mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-nano":{id:"gpt-4.1-nano",name:"GPT-4.1 nano",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.03,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-05-13":{id:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4o-2024-08-06":{id:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-11-20":{id:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-mini":{id:"gpt-4o-mini",name:"GPT-4o mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.08,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-chat-latest":{id:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5-Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5 Mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-pro":{id:"gpt-5-pro",name:"GPT-5 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:272e3},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-chat-latest":{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-chat-latest":{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-pro":{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},o1:{id:"o1",name:"o1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o1-pro":{id:"o1-pro",name:"o1-pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:150,output:600,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},o3:{id:"o3",name:"o3",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-deep-research":{id:"o3-deep-research",name:"o3-deep-research",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-mini":{id:"o3-mini",name:"o3-mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-pro":{id:"o3-pro",name:"o3-pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini":{id:"o4-mini",name:"o4-mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini-deep-research":{id:"o4-mini-deep-research",name:"o4-mini-deep-research",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5}},cerebras:{"gpt-oss-120b":{id:"gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.69,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"llama3.1-8b":{id:"llama3.1-8b",name:"Llama 3.1 8B",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!1,input:["text"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:8e3},"qwen-3-235b-a22b-instruct-2507":{id:"qwen-3-235b-a22b-instruct-2507",name:"Qwen 3 235B Instruct",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!1,input:["text"],cost:{input:.6,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:32e3},"zai-glm-4.7":{id:"zai-glm-4.7",name:"Z.AI GLM-4.7",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!1,input:["text"],cost:{input:2.25,output:2.75,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4e4}},"github-copilot":{"claude-haiku-4.5":{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"claude-opus-4.5":{id:"claude-opus-4.5",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"claude-opus-4.6":{id:"claude-opus-4.6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"claude-sonnet-4":{id:"claude-sonnet-4",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16e3},"claude-sonnet-4.5":{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"claude-sonnet-4.6":{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16384},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16384},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5-mini",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1-Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1-Codex-max",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1-Codex-mini",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2-Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3-Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"grok-code-fast-1":{id:"grok-code-fast-1",name:"Grok Code Fast 1",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3}},google:{"gemini-1.5-flash":{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:.01875,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-1.5-flash-8b":{id:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash-8B",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.0375,output:.15,cacheRead:.01,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-1.5-pro":{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:1.25,output:5,cacheRead:.3125,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-2.0-flash":{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.0-flash-lite":{id:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash Lite",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.5-flash":{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite":{id:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite-preview-06-17":{id:"gemini-2.5-flash-lite-preview-06-17",name:"Gemini 2.5 Flash Lite Preview 06-17",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite-preview-09-2025":{id:"gemini-2.5-flash-lite-preview-09-2025",name:"Gemini 2.5 Flash Lite Preview 09-25",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-preview-04-17":{id:"gemini-2.5-flash-preview-04-17",name:"Gemini 2.5 Flash Preview 04-17",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.0375,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-preview-05-20":{id:"gemini-2.5-flash-preview-05-20",name:"Gemini 2.5 Flash Preview 05-20",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.0375,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-preview-09-2025":{id:"gemini-2.5-flash-preview-09-2025",name:"Gemini 2.5 Flash Preview 09-25",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.31,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro-preview-05-06":{id:"gemini-2.5-pro-preview-05-06",name:"Gemini 2.5 Pro Preview 05-06",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.31,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro-preview-06-05":{id:"gemini-2.5-pro-preview-06-05",name:"Gemini 2.5 Pro Preview 06-05",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.31,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"gemini-3.1-flash-lite-preview":{id:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3.1-pro-preview-customtools":{id:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-flash-latest":{id:"gemini-flash-latest",name:"Gemini Flash Latest",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-flash-lite-latest":{id:"gemini-flash-lite-latest",name:"Gemini Flash-Lite Latest",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-live-2.5-flash":{id:"gemini-live-2.5-flash",name:"Gemini Live 2.5 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.5,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8e3},"gemini-live-2.5-flash-preview-native-audio":{id:"gemini-live-2.5-flash-preview-native-audio",name:"Gemini Live 2.5 Flash Preview Native Audio",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text"],cost:{input:.5,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536}},"google-antigravity":{"claude-opus-4-5-thinking":{id:"claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-6-thinking":{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5-thinking":{id:"claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"gemini-3-flash":{id:"gemini-3-flash",name:"Gemini 3 Flash (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.5,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-3.1-pro-high":{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:2.375},contextWindow:1048576,maxTokens:65535},"gemini-3.1-pro-low":{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro Low (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:2.375},contextWindow:1048576,maxTokens:65535},"gpt-oss-120b-medium":{id:"gpt-oss-120b-medium",name:"GPT-OSS 120B Medium (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!1,input:["text"],cost:{input:.09,output:.36,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768}},"google-gemini-cli":{"gemini-2.0-flash":{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.5-flash":{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535}},"google-vertex":{"gemini-1.5-flash":{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:.01875,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-1.5-flash-8b":{id:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash-8B (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:.0375,output:.15,cacheRead:.01,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-1.5-pro":{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:1.25,output:5,cacheRead:.3125,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-2.0-flash":{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.0375,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.0-flash-lite":{id:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash Lite (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.075,output:.3,cacheRead:.01875,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash":{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite":{id:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite-preview-09-2025":{id:"gemini-2.5-flash-lite-preview-09-2025",name:"Gemini 2.5 Flash Lite Preview 09-25 (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536}},groq:{"deepseek-r1-distill-llama-70b":{id:"deepseek-r1-distill-llama-70b",name:"DeepSeek R1 Distill Llama 70B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.75,output:.99,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"gemma2-9b-it":{id:"gemma2-9b-it",name:"Gemma 2 9B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.2,output:.2,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"llama-3.1-8b-instant":{id:"llama-3.1-8b-instant",name:"Llama 3.1 8B Instant",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.05,output:.08,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"llama-3.3-70b-versatile":{id:"llama-3.3-70b-versatile",name:"Llama 3.3 70B Versatile",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.59,output:.79,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"llama3-70b-8192":{id:"llama3-70b-8192",name:"Llama 3 70B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.59,output:.79,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"llama3-8b-8192":{id:"llama3-8b-8192",name:"Llama 3 8B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.05,output:.08,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"meta-llama/llama-4-maverick-17b-128e-instruct":{id:"meta-llama/llama-4-maverick-17b-128e-instruct",name:"Llama 4 Maverick 17B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text","image"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"meta-llama/llama-4-scout-17b-16e-instruct":{id:"meta-llama/llama-4-scout-17b-16e-instruct",name:"Llama 4 Scout 17B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text","image"],cost:{input:.11,output:.34,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"mistral-saba-24b":{id:"mistral-saba-24b",name:"Mistral Saba 24B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.79,output:.79,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"moonshotai/kimi-k2-instruct":{id:"moonshotai/kimi-k2-instruct",name:"Kimi K2 Instruct",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"moonshotai/kimi-k2-instruct-0905":{id:"moonshotai/kimi-k2-instruct-0905",name:"Kimi K2 Instruct 0905",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"GPT OSS 20B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"qwen-qwq-32b":{id:"qwen-qwq-32b",name:"Qwen QwQ 32B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.29,output:.39,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"qwen/qwen3-32b":{id:"qwen/qwen3-32b",name:"Qwen3 32B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.29,output:.59,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384}},huggingface:{"MiniMaxAI/MiniMax-M2.1":{id:"MiniMaxAI/MiniMax-M2.1",name:"MiniMax-M2.1",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"MiniMaxAI/MiniMax-M2.5":{id:"MiniMaxAI/MiniMax-M2.5",name:"MiniMax-M2.5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:0},contextWindow:204800,maxTokens:131072},"Qwen/Qwen3-235B-A22B-Thinking-2507":{id:"Qwen/Qwen3-235B-A22B-Thinking-2507",name:"Qwen3-235B-A22B-Thinking-2507",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.3,output:3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"Qwen/Qwen3-Coder-480B-A35B-Instruct":{id:"Qwen/Qwen3-Coder-480B-A35B-Instruct",name:"Qwen3-Coder-480B-A35B-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:2,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:66536},"Qwen/Qwen3-Coder-Next":{id:"Qwen/Qwen3-Coder-Next",name:"Qwen3-Coder-Next",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:.2,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3-Next-80B-A3B-Instruct":{id:"Qwen/Qwen3-Next-80B-A3B-Instruct",name:"Qwen3-Next-80B-A3B-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:.25,output:1,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:66536},"Qwen/Qwen3-Next-80B-A3B-Thinking":{id:"Qwen/Qwen3-Next-80B-A3B-Thinking",name:"Qwen3-Next-80B-A3B-Thinking",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:.3,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"Qwen/Qwen3.5-397B-A17B":{id:"Qwen/Qwen3.5-397B-A17B",name:"Qwen3.5-397B-A17B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text","image"],cost:{input:.6,output:3.6,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"XiaomiMiMo/MiMo-V2-Flash":{id:"XiaomiMiMo/MiMo-V2-Flash",name:"MiMo-V2-Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"deepseek-ai/DeepSeek-R1-0528":{id:"deepseek-ai/DeepSeek-R1-0528",name:"DeepSeek-R1-0528",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:3,output:5,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:163840},"deepseek-ai/DeepSeek-V3.2":{id:"deepseek-ai/DeepSeek-V3.2",name:"DeepSeek-V3.2",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.28,output:.4,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:65536},"moonshotai/Kimi-K2-Instruct":{id:"moonshotai/Kimi-K2-Instruct",name:"Kimi-K2-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"moonshotai/Kimi-K2-Instruct-0905":{id:"moonshotai/Kimi-K2-Instruct-0905",name:"Kimi-K2-Instruct-0905",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384},"moonshotai/Kimi-K2-Thinking":{id:"moonshotai/Kimi-K2-Thinking",name:"Kimi-K2-Thinking",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144},"moonshotai/Kimi-K2.5":{id:"moonshotai/Kimi-K2.5",name:"Kimi-K2.5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},contextWindow:262144,maxTokens:262144},"zai-org/GLM-4.7":{id:"zai-org/GLM-4.7",name:"GLM-4.7",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:204800,maxTokens:131072},"zai-org/GLM-4.7-Flash":{id:"zai-org/GLM-4.7-Flash",name:"GLM-4.7-Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"zai-org/GLM-5":{id:"zai-org/GLM-5",name:"GLM-5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:202752,maxTokens:131072}},"kimi-coding":{k2p5:{id:"k2p5",name:"Kimi K2.5",api:"anthropic-messages",provider:"kimi-coding",baseUrl:"https://api.kimi.com/coding",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"kimi-k2-thinking":{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",api:"anthropic-messages",provider:"kimi-coding",baseUrl:"https://api.kimi.com/coding",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768}},minimax:{"MiniMax-M2":{id:"MiniMax-M2",name:"MiniMax-M2",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:196608,maxTokens:128e3},"MiniMax-M2.1":{id:"MiniMax-M2.1",name:"MiniMax-M2.1",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"MiniMax-M2.5":{id:"MiniMax-M2.5",name:"MiniMax-M2.5",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"MiniMax-M2.5-highspeed":{id:"MiniMax-M2.5-highspeed",name:"MiniMax-M2.5-highspeed",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131072}},"minimax-cn":{"MiniMax-M2":{id:"MiniMax-M2",name:"MiniMax-M2",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:196608,maxTokens:128e3},"MiniMax-M2.1":{id:"MiniMax-M2.1",name:"MiniMax-M2.1",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"MiniMax-M2.5":{id:"MiniMax-M2.5",name:"MiniMax-M2.5",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"MiniMax-M2.5-highspeed":{id:"MiniMax-M2.5-highspeed",name:"MiniMax-M2.5-highspeed",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131072}},mistral:{"codestral-latest":{id:"codestral-latest",name:"Codestral (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.3,output:.9,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"devstral-2512":{id:"devstral-2512",name:"Devstral 2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"devstral-medium-2507":{id:"devstral-medium-2507",name:"Devstral Medium",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"devstral-medium-latest":{id:"devstral-medium-latest",name:"Devstral 2 (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"devstral-small-2505":{id:"devstral-small-2505",name:"Devstral Small 2505",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"devstral-small-2507":{id:"devstral-small-2507",name:"Devstral Small",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"labs-devstral-small-2512":{id:"labs-devstral-small-2512",name:"Devstral Small 2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"magistral-medium-latest":{id:"magistral-medium-latest",name:"Magistral Medium (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text"],cost:{input:2,output:5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"magistral-small":{id:"magistral-small",name:"Magistral Small",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"ministral-3b-latest":{id:"ministral-3b-latest",name:"Ministral 3B (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.04,output:.04,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"ministral-8b-latest":{id:"ministral-8b-latest",name:"Ministral 8B (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"mistral-large-2411":{id:"mistral-large-2411",name:"Mistral Large 2.1",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"mistral-large-2512":{id:"mistral-large-2512",name:"Mistral Large 3",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-large-latest":{id:"mistral-large-latest",name:"Mistral Large (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-medium-2505":{id:"mistral-medium-2505",name:"Mistral Medium 3",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"mistral-medium-2508":{id:"mistral-medium-2508",name:"Mistral Medium 3.1",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-medium-latest":{id:"mistral-medium-latest",name:"Mistral Medium (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"mistral-nemo":{id:"mistral-nemo",name:"Mistral Nemo",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"mistral-small-2506":{id:"mistral-small-2506",name:"Mistral Small 3.2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"mistral-small-latest":{id:"mistral-small-latest",name:"Mistral Small (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"open-mistral-7b":{id:"open-mistral-7b",name:"Mistral 7B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.25,output:.25,cacheRead:0,cacheWrite:0},contextWindow:8e3,maxTokens:8e3},"open-mixtral-8x22b":{id:"open-mixtral-8x22b",name:"Mixtral 8x22B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:64e3},"open-mixtral-8x7b":{id:"open-mixtral-8x7b",name:"Mixtral 8x7B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.7,output:.7,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:32e3},"pixtral-12b":{id:"pixtral-12b",name:"Pixtral 12B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"pixtral-large-latest":{id:"pixtral-large-latest",name:"Pixtral Large (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3}},openai:{"codex-mini-latest":{id:"codex-mini-latest",name:"Codex Mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text"],cost:{input:1.5,output:6,cacheRead:.375,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"gpt-4":{id:"gpt-4",name:"GPT-4",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"gpt-4-turbo":{id:"gpt-4-turbo",name:"GPT-4 Turbo",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-mini":{id:"gpt-4.1-mini",name:"GPT-4.1 mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-nano":{id:"gpt-4.1-nano",name:"GPT-4.1 nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.03,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-05-13":{id:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4o-2024-08-06":{id:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-11-20":{id:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-mini":{id:"gpt-4o-mini",name:"GPT-4o mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.08,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-chat-latest":{id:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5-Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5 Mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-pro":{id:"gpt-5-pro",name:"GPT-5 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:272e3},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-chat-latest":{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-chat-latest":{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-pro":{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},o1:{id:"o1",name:"o1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o1-pro":{id:"o1-pro",name:"o1-pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:150,output:600,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},o3:{id:"o3",name:"o3",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-deep-research":{id:"o3-deep-research",name:"o3-deep-research",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-mini":{id:"o3-mini",name:"o3-mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-pro":{id:"o3-pro",name:"o3-pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini":{id:"o4-mini",name:"o4-mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini-deep-research":{id:"o4-mini-deep-research",name:"o4-mini-deep-research",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5}},"openai-codex":{"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3}},opencode:{"big-pickle":{id:"big-pickle",name:"Big Pickle",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"claude-3-5-haiku":{id:"claude-3-5-haiku",name:"Claude Haiku 3.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"claude-haiku-4-5":{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-1":{id:"claude-opus-4-1",name:"Claude Opus 4.1",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-5":{id:"claude-opus-4-5",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-6":{id:"claude-opus-4-6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"claude-sonnet-4":{id:"claude-sonnet-4",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"gemini-3-flash":{id:"gemini-3-flash",name:"Gemini 3 Flash",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-pro":{id:"gemini-3-pro",name:"Gemini 3 Pro",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3.1-pro":{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro Preview",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"glm-4.6":{id:"glm-4.6",name:"GLM-4.6",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.1,cacheWrite:0},contextWindow:204800,maxTokens:131072},"glm-4.7":{id:"glm-4.7",name:"GLM-4.7",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.1,cacheWrite:0},contextWindow:204800,maxTokens:131072},"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:204800,maxTokens:131072},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:30,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.08,cacheWrite:0},contextWindow:262144,maxTokens:65536},"minimax-m2.1":{id:"minimax-m2.1",name:"MiniMax M2.1",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.1,cacheWrite:0},contextWindow:204800,maxTokens:131072},"minimax-m2.5":{id:"minimax-m2.5",name:"MiniMax M2.5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:204800,maxTokens:131072},"minimax-m2.5-free":{id:"minimax-m2.5-free",name:"MiniMax M2.5 Free",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072}},"opencode-go":{"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:204800,maxTokens:131072},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},contextWindow:262144,maxTokens:65536},"minimax-m2.5":{id:"minimax-m2.5",name:"MiniMax M2.5",api:"anthropic-messages",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:0},contextWindow:204800,maxTokens:131072}},openrouter:{"ai21/jamba-large-1.7":{id:"ai21/jamba-large-1.7",name:"AI21: Jamba Large 1.7",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:8,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"alibaba/tongyi-deepresearch-30b-a3b":{id:"alibaba/tongyi-deepresearch-30b-a3b",name:"Tongyi DeepResearch 30B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.09,output:.44999999999999996,cacheRead:.09,cacheWrite:0},contextWindow:131072,maxTokens:131072},"allenai/olmo-3.1-32b-instruct":{id:"allenai/olmo-3.1-32b-instruct",name:"AllenAI: Olmo 3.1 32B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.6,cacheRead:0,cacheWrite:0},contextWindow:65536,maxTokens:4096},"amazon/nova-2-lite-v1":{id:"amazon/nova-2-lite-v1",name:"Amazon: Nova 2 Lite",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65535},"amazon/nova-lite-v1":{id:"amazon/nova-lite-v1",name:"Amazon: Nova Lite 1.0",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:3e5,maxTokens:5120},"amazon/nova-micro-v1":{id:"amazon/nova-micro-v1",name:"Amazon: Nova Micro 1.0",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.035,output:.14,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:5120},"amazon/nova-premier-v1":{id:"amazon/nova-premier-v1",name:"Amazon: Nova Premier 1.0",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:12.5,cacheRead:.625,cacheWrite:0},contextWindow:1e6,maxTokens:32e3},"amazon/nova-pro-v1":{id:"amazon/nova-pro-v1",name:"Amazon: Nova Pro 1.0",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.7999999999999999,output:3.1999999999999997,cacheRead:0,cacheWrite:0},contextWindow:3e5,maxTokens:5120},"anthropic/claude-3-haiku":{id:"anthropic/claude-3-haiku",name:"Anthropic: Claude 3 Haiku",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"anthropic/claude-3.5-haiku":{id:"anthropic/claude-3.5-haiku",name:"Anthropic: Claude 3.5 Haiku",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.7999999999999999,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.5-sonnet":{id:"anthropic/claude-3.5-sonnet",name:"Anthropic: Claude 3.5 Sonnet",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:6,output:30,cacheRead:.6,cacheWrite:7.5},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.7-sonnet":{id:"anthropic/claude-3.7-sonnet",name:"Anthropic: Claude 3.7 Sonnet",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-3.7-sonnet:thinking":{id:"anthropic/claude-3.7-sonnet:thinking",name:"Anthropic: Claude 3.7 Sonnet (thinking)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-haiku-4.5":{id:"anthropic/claude-haiku-4.5",name:"Anthropic: Claude Haiku 4.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.09999999999999999,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4":{id:"anthropic/claude-opus-4",name:"Anthropic: Claude Opus 4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.1":{id:"anthropic/claude-opus-4.1",name:"Anthropic: Claude Opus 4.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.5":{id:"anthropic/claude-opus-4.5",name:"Anthropic: Claude Opus 4.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4.6":{id:"anthropic/claude-opus-4.6",name:"Anthropic: Claude Opus 4.6",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3},"anthropic/claude-sonnet-4":{id:"anthropic/claude-sonnet-4",name:"Anthropic: Claude Sonnet 4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-sonnet-4.5":{id:"anthropic/claude-sonnet-4.5",name:"Anthropic: Claude Sonnet 4.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-sonnet-4.6":{id:"anthropic/claude-sonnet-4.6",name:"Anthropic: Claude Sonnet 4.6",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:128e3},"arcee-ai/trinity-large-preview:free":{id:"arcee-ai/trinity-large-preview:free",name:"Arcee AI: Trinity Large Preview (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"arcee-ai/trinity-mini":{id:"arcee-ai/trinity-mini",name:"Arcee AI: Trinity Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.045,output:.15,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"arcee-ai/trinity-mini:free":{id:"arcee-ai/trinity-mini:free",name:"Arcee AI: Trinity Mini (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"arcee-ai/virtuoso-large":{id:"arcee-ai/virtuoso-large",name:"Arcee AI: Virtuoso Large",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.75,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:64e3},auto:{id:"auto",name:"Auto",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"baidu/ernie-4.5-21b-a3b":{id:"baidu/ernie-4.5-21b-a3b",name:"Baidu: ERNIE 4.5 21B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.07,output:.28,cacheRead:0,cacheWrite:0},contextWindow:12e4,maxTokens:8e3},"baidu/ernie-4.5-vl-28b-a3b":{id:"baidu/ernie-4.5-vl-28b-a3b",name:"Baidu: ERNIE 4.5 VL 28B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.14,output:.56,cacheRead:0,cacheWrite:0},contextWindow:3e4,maxTokens:8e3},"bytedance-seed/seed-1.6":{id:"bytedance-seed/seed-1.6",name:"ByteDance Seed: Seed 1.6",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"bytedance-seed/seed-1.6-flash":{id:"bytedance-seed/seed-1.6-flash",name:"ByteDance Seed: Seed 1.6 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"bytedance-seed/seed-2.0-mini":{id:"bytedance-seed/seed-2.0-mini",name:"ByteDance Seed: Seed-2.0-Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"cohere/command-r-08-2024":{id:"cohere/command-r-08-2024",name:"Cohere: Command R (08-2024)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"cohere/command-r-plus-08-2024":{id:"cohere/command-r-plus-08-2024",name:"Cohere: Command R+ (08-2024)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"deepseek/deepseek-chat":{id:"deepseek/deepseek-chat",name:"DeepSeek: DeepSeek V3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.32,output:.8899999999999999,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:163840},"deepseek/deepseek-chat-v3-0324":{id:"deepseek/deepseek-chat-v3-0324",name:"DeepSeek: DeepSeek V3 0324",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:.77,cacheRead:.13,cacheWrite:0},contextWindow:163840,maxTokens:163840},"deepseek/deepseek-chat-v3.1":{id:"deepseek/deepseek-chat-v3.1",name:"DeepSeek: DeepSeek V3.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.75,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:7168},"deepseek/deepseek-r1":{id:"deepseek/deepseek-r1",name:"DeepSeek: R1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.7,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16e3},"deepseek/deepseek-r1-0528":{id:"deepseek/deepseek-r1-0528",name:"DeepSeek: R1 0528",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.44999999999999996,output:2.1500000000000004,cacheRead:.22499999999999998,cacheWrite:0},contextWindow:163840,maxTokens:65536},"deepseek/deepseek-v3.1-terminus":{id:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek: DeepSeek V3.1 Terminus",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.21,output:.7899999999999999,cacheRead:.1300000002,cacheWrite:0},contextWindow:163840,maxTokens:4096},"deepseek/deepseek-v3.1-terminus:exacto":{id:"deepseek/deepseek-v3.1-terminus:exacto",name:"DeepSeek: DeepSeek V3.1 Terminus (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.21,output:.7899999999999999,cacheRead:.16799999999999998,cacheWrite:0},contextWindow:163840,maxTokens:4096},"deepseek/deepseek-v3.2":{id:"deepseek/deepseek-v3.2",name:"DeepSeek: DeepSeek V3.2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:65536},"deepseek/deepseek-v3.2-exp":{id:"deepseek/deepseek-v3.2-exp",name:"DeepSeek: DeepSeek V3.2 Exp",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.27,output:.41,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:65536},"essentialai/rnj-1-instruct":{id:"essentialai/rnj-1-instruct",name:"EssentialAI: Rnj 1 Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"google/gemini-2.0-flash-001":{id:"google/gemini-2.0-flash-001",name:"Google: Gemini 2.0 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.024999999999999998,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:8192},"google/gemini-2.0-flash-lite-001":{id:"google/gemini-2.0-flash-lite-001",name:"Google: Gemini 2.0 Flash Lite",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"google/gemini-2.5-flash":{id:"google/gemini-2.5-flash",name:"Google: Gemini 2.5 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65535},"google/gemini-2.5-flash-lite":{id:"google/gemini-2.5-flash-lite",name:"Google: Gemini 2.5 Flash Lite",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.01,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65535},"google/gemini-2.5-flash-lite-preview-09-2025":{id:"google/gemini-2.5-flash-lite-preview-09-2025",name:"Google: Gemini 2.5 Flash Lite Preview 09-2025",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.01,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-pro":{id:"google/gemini-2.5-pro",name:"Google: Gemini 2.5 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-pro-preview":{id:"google/gemini-2.5-pro-preview",name:"Google: Gemini 2.5 Pro Preview 06-05",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-pro-preview-05-06":{id:"google/gemini-2.5-pro-preview-05-06",name:"Google: Gemini 2.5 Pro Preview 05-06",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65535},"google/gemini-3-flash-preview":{id:"google/gemini-3-flash-preview",name:"Google: Gemini 3 Flash Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.049999999999999996,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65536},"google/gemini-3-pro-preview":{id:"google/gemini-3-pro-preview",name:"Google: Gemini 3 Pro Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemini-3.1-flash-lite-preview":{id:"google/gemini-3.1-flash-lite-preview",name:"Google: Gemini 3.1 Flash Lite Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.024999999999999998,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65536},"google/gemini-3.1-pro-preview":{id:"google/gemini-3.1-pro-preview",name:"Google: Gemini 3.1 Pro Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemini-3.1-pro-preview-customtools":{id:"google/gemini-3.1-pro-preview-customtools",name:"Google: Gemini 3.1 Pro Preview Custom Tools",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemma-3-27b-it":{id:"google/gemma-3-27b-it",name:"Google: Gemma 3 27B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.04,output:.15,cacheRead:.02,cacheWrite:0},contextWindow:128e3,maxTokens:65536},"google/gemma-3-27b-it:free":{id:"google/gemma-3-27b-it:free",name:"Google: Gemma 3 27B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"inception/mercury":{id:"inception/mercury",name:"Inception: Mercury",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.25,output:.75,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"inception/mercury-2":{id:"inception/mercury-2",name:"Inception: Mercury 2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.75,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:128e3,maxTokens:5e4},"inception/mercury-coder":{id:"inception/mercury-coder",name:"Inception: Mercury Coder",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.25,output:.75,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"kwaipilot/kat-coder-pro":{id:"kwaipilot/kat-coder-pro",name:"Kwaipilot: KAT-Coder-Pro V1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.207,output:.828,cacheRead:.0414,cacheWrite:0},contextWindow:256e3,maxTokens:128e3},"meituan/longcat-flash-chat":{id:"meituan/longcat-flash-chat",name:"Meituan: LongCat Flash Chat",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.7999999999999999,cacheRead:.19999999999999998,cacheWrite:0},contextWindow:131072,maxTokens:131072},"meta-llama/llama-3-8b-instruct":{id:"meta-llama/llama-3-8b-instruct",name:"Meta: Llama 3 8B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.03,output:.04,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:16384},"meta-llama/llama-3.1-405b-instruct":{id:"meta-llama/llama-3.1-405b-instruct",name:"Meta: Llama 3.1 405B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:4,output:4,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"meta-llama/llama-3.1-70b-instruct":{id:"meta-llama/llama-3.1-70b-instruct",name:"Meta: Llama 3.1 70B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"meta-llama/llama-3.1-8b-instruct":{id:"meta-llama/llama-3.1-8b-instruct",name:"Meta: Llama 3.1 8B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.02,output:.049999999999999996,cacheRead:0,cacheWrite:0},contextWindow:16384,maxTokens:16384},"meta-llama/llama-3.3-70b-instruct":{id:"meta-llama/llama-3.3-70b-instruct",name:"Meta: Llama 3.3 70B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.32,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"meta-llama/llama-3.3-70b-instruct:free":{id:"meta-llama/llama-3.3-70b-instruct:free",name:"Meta: Llama 3.3 70B Instruct (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"meta-llama/llama-4-maverick":{id:"meta-llama/llama-4-maverick",name:"Meta: Llama 4 Maverick",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:16384},"meta-llama/llama-4-scout":{id:"meta-llama/llama-4-scout",name:"Meta: Llama 4 Scout",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.08,output:.3,cacheRead:0,cacheWrite:0},contextWindow:327680,maxTokens:16384},"minimax/minimax-m1":{id:"minimax/minimax-m1",name:"MiniMax: MiniMax M1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.39999999999999997,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:4e4},"minimax/minimax-m2":{id:"minimax/minimax-m2",name:"MiniMax: MiniMax M2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.255,output:1,cacheRead:.03,cacheWrite:0},contextWindow:196608,maxTokens:196608},"minimax/minimax-m2.1":{id:"minimax/minimax-m2.1",name:"MiniMax: MiniMax M2.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.27,output:.95,cacheRead:.0290000007,cacheWrite:0},contextWindow:196608,maxTokens:4096},"minimax/minimax-m2.5":{id:"minimax/minimax-m2.5",name:"MiniMax: MiniMax M2.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.295,output:1.2,cacheRead:.03,cacheWrite:0},contextWindow:196608,maxTokens:196608},"mistralai/codestral-2508":{id:"mistralai/codestral-2508",name:"Mistral: Codestral 2508",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.3,output:.8999999999999999,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"mistralai/devstral-2512":{id:"mistralai/devstral-2512",name:"Mistral: Devstral 2 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"mistralai/devstral-medium":{id:"mistralai/devstral-medium",name:"Mistral: Devstral Medium",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/devstral-small":{id:"mistralai/devstral-small",name:"Mistral: Devstral Small 1.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/ministral-14b-2512":{id:"mistralai/ministral-14b-2512",name:"Mistral: Ministral 3 14B 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.19999999999999998,output:.19999999999999998,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"mistralai/ministral-3b-2512":{id:"mistralai/ministral-3b-2512",name:"Mistral: Ministral 3 3B 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/ministral-8b-2512":{id:"mistralai/ministral-8b-2512",name:"Mistral: Ministral 3 8B 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"mistralai/mistral-large":{id:"mistralai/mistral-large",name:"Mistral Large",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistralai/mistral-large-2407":{id:"mistralai/mistral-large-2407",name:"Mistral Large 2407",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/mistral-large-2411":{id:"mistralai/mistral-large-2411",name:"Mistral Large 2411",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/mistral-large-2512":{id:"mistralai/mistral-large-2512",name:"Mistral: Mistral Large 3 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"mistralai/mistral-medium-3":{id:"mistralai/mistral-medium-3",name:"Mistral: Mistral Medium 3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/mistral-medium-3.1":{id:"mistralai/mistral-medium-3.1",name:"Mistral: Mistral Medium 3.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/mistral-nemo":{id:"mistralai/mistral-nemo",name:"Mistral: Mistral Nemo",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.02,output:.04,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"mistralai/mistral-saba":{id:"mistralai/mistral-saba",name:"Mistral: Saba",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.6,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"mistralai/mistral-small-24b-instruct-2501":{id:"mistralai/mistral-small-24b-instruct-2501",name:"Mistral: Mistral Small 3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.049999999999999996,output:.08,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:16384},"mistralai/mistral-small-3.1-24b-instruct:free":{id:"mistralai/mistral-small-3.1-24b-instruct:free",name:"Mistral: Mistral Small 3.1 24B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistralai/mistral-small-3.2-24b-instruct":{id:"mistralai/mistral-small-3.2-24b-instruct",name:"Mistral: Mistral Small 3.2 24B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.06,output:.18,cacheRead:.03,cacheWrite:0},contextWindow:131072,maxTokens:131072},"mistralai/mistral-small-creative":{id:"mistralai/mistral-small-creative",name:"Mistral: Mistral Small Creative",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"mistralai/mixtral-8x22b-instruct":{id:"mistralai/mixtral-8x22b-instruct",name:"Mistral: Mixtral 8x22B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:65536,maxTokens:4096},"mistralai/mixtral-8x7b-instruct":{id:"mistralai/mixtral-8x7b-instruct",name:"Mistral: Mixtral 8x7B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.54,output:.54,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:16384},"mistralai/pixtral-large-2411":{id:"mistralai/pixtral-large-2411",name:"Mistral: Pixtral Large 2411",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/voxtral-small-24b-2507":{id:"mistralai/voxtral-small-24b-2507",name:"Mistral: Voxtral Small 24B 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:4096},"moonshotai/kimi-k2":{id:"moonshotai/kimi-k2",name:"MoonshotAI: Kimi K2 0711",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.55,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"moonshotai/kimi-k2-0905":{id:"moonshotai/kimi-k2-0905",name:"MoonshotAI: Kimi K2 0905",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:2,cacheRead:.15,cacheWrite:0},contextWindow:131072,maxTokens:4096},"moonshotai/kimi-k2-0905:exacto":{id:"moonshotai/kimi-k2-0905:exacto",name:"MoonshotAI: Kimi K2 0905 (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.6,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"moonshotai/kimi-k2-thinking":{id:"moonshotai/kimi-k2-thinking",name:"MoonshotAI: Kimi K2 Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.47,output:2,cacheRead:.14100000000000001,cacheWrite:0},contextWindow:131072,maxTokens:4096},"moonshotai/kimi-k2.5":{id:"moonshotai/kimi-k2.5",name:"MoonshotAI: Kimi K2.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.41,output:2.06,cacheRead:.07,cacheWrite:0},contextWindow:262144,maxTokens:4096},"nex-agi/deepseek-v3.1-nex-n1":{id:"nex-agi/deepseek-v3.1-nex-n1",name:"Nex AGI: DeepSeek V3.1 Nex N1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.27,output:1,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:163840},"nvidia/llama-3.1-nemotron-70b-instruct":{id:"nvidia/llama-3.1-nemotron-70b-instruct",name:"NVIDIA: Llama 3.1 Nemotron 70B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.2,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"nvidia/llama-3.3-nemotron-super-49b-v1.5":{id:"nvidia/llama-3.3-nemotron-super-49b-v1.5",name:"NVIDIA: Llama 3.3 Nemotron Super 49B V1.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"nvidia/nemotron-3-nano-30b-a3b":{id:"nvidia/nemotron-3-nano-30b-a3b",name:"NVIDIA: Nemotron 3 Nano 30B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.049999999999999996,output:.19999999999999998,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"nvidia/nemotron-3-nano-30b-a3b:free":{id:"nvidia/nemotron-3-nano-30b-a3b:free",name:"NVIDIA: Nemotron 3 Nano 30B A3B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"nvidia/nemotron-nano-12b-v2-vl:free":{id:"nvidia/nemotron-nano-12b-v2-vl:free",name:"NVIDIA: Nemotron Nano 12B 2 VL (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"nvidia/nemotron-nano-9b-v2":{id:"nvidia/nemotron-nano-9b-v2",name:"NVIDIA: Nemotron Nano 9B V2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.04,output:.16,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"nvidia/nemotron-nano-9b-v2:free":{id:"nvidia/nemotron-nano-9b-v2:free",name:"NVIDIA: Nemotron Nano 9B V2 (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-3.5-turbo":{id:"openai/gpt-3.5-turbo",name:"OpenAI: GPT-3.5 Turbo",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:16385,maxTokens:4096},"openai/gpt-3.5-turbo-0613":{id:"openai/gpt-3.5-turbo-0613",name:"OpenAI: GPT-3.5 Turbo (older v0613)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1,output:2,cacheRead:0,cacheWrite:0},contextWindow:4095,maxTokens:4096},"openai/gpt-3.5-turbo-16k":{id:"openai/gpt-3.5-turbo-16k",name:"OpenAI: GPT-3.5 Turbo 16k",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:3,output:4,cacheRead:0,cacheWrite:0},contextWindow:16385,maxTokens:4096},"openai/gpt-4":{id:"openai/gpt-4",name:"OpenAI: GPT-4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8191,maxTokens:4096},"openai/gpt-4-0314":{id:"openai/gpt-4-0314",name:"OpenAI: GPT-4 (older v0314)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8191,maxTokens:4096},"openai/gpt-4-1106-preview":{id:"openai/gpt-4-1106-preview",name:"OpenAI: GPT-4 Turbo (older v1106)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4-turbo":{id:"openai/gpt-4-turbo",name:"OpenAI: GPT-4 Turbo",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4-turbo-preview":{id:"openai/gpt-4-turbo-preview",name:"OpenAI: GPT-4 Turbo Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4.1":{id:"openai/gpt-4.1",name:"OpenAI: GPT-4.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-mini":{id:"openai/gpt-4.1-mini",name:"OpenAI: GPT-4.1 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:1.5999999999999999,cacheRead:.09999999999999999,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-nano":{id:"openai/gpt-4.1-nano",name:"OpenAI: GPT-4.1 Nano",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4o":{id:"openai/gpt-4o",name:"OpenAI: GPT-4o",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-2024-05-13":{id:"openai/gpt-4o-2024-05-13",name:"OpenAI: GPT-4o (2024-05-13)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4o-2024-08-06":{id:"openai/gpt-4o-2024-08-06",name:"OpenAI: GPT-4o (2024-08-06)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-2024-11-20":{id:"openai/gpt-4o-2024-11-20",name:"OpenAI: GPT-4o (2024-11-20)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-audio-preview":{id:"openai/gpt-4o-audio-preview",name:"OpenAI: GPT-4o Audio",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-mini":{id:"openai/gpt-4o-mini",name:"OpenAI: GPT-4o-mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-mini-2024-07-18":{id:"openai/gpt-4o-mini-2024-07-18",name:"OpenAI: GPT-4o-mini (2024-07-18)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o:extended":{id:"openai/gpt-4o:extended",name:"OpenAI: GPT-4o (extended)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:6,output:18,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"openai/gpt-5":{id:"openai/gpt-5",name:"OpenAI: GPT-5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-codex":{id:"openai/gpt-5-codex",name:"OpenAI: GPT-5 Codex",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-image":{id:"openai/gpt-5-image",name:"OpenAI: GPT-5 Image",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:10,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-image-mini":{id:"openai/gpt-5-image-mini",name:"OpenAI: GPT-5 Image Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:2,cacheRead:.25,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-mini":{id:"openai/gpt-5-mini",name:"OpenAI: GPT-5 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-nano":{id:"openai/gpt-5-nano",name:"OpenAI: GPT-5 Nano",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.049999999999999996,output:.39999999999999997,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-pro":{id:"openai/gpt-5-pro",name:"OpenAI: GPT-5 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1":{id:"openai/gpt-5.1",name:"OpenAI: GPT-5.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-chat":{id:"openai/gpt-5.1-chat",name:"OpenAI: GPT-5.1 Chat",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.1-codex":{id:"openai/gpt-5.1-codex",name:"OpenAI: GPT-5.1-Codex",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-max":{id:"openai/gpt-5.1-codex-max",name:"OpenAI: GPT-5.1-Codex-Max",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-mini":{id:"openai/gpt-5.1-codex-mini",name:"OpenAI: GPT-5.1-Codex-Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:4e5,maxTokens:1e5},"openai/gpt-5.2":{id:"openai/gpt-5.2",name:"OpenAI: GPT-5.2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2-chat":{id:"openai/gpt-5.2-chat",name:"OpenAI: GPT-5.2 Chat",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.2-codex":{id:"openai/gpt-5.2-codex",name:"OpenAI: GPT-5.2-Codex",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2-pro":{id:"openai/gpt-5.2-pro",name:"OpenAI: GPT-5.2 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.3-chat":{id:"openai/gpt-5.3-chat",name:"OpenAI: GPT-5.3 Chat",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.3-codex":{id:"openai/gpt-5.3-codex",name:"OpenAI: GPT-5.3-Codex",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.4":{id:"openai/gpt-5.4",name:"OpenAI: GPT-5.4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},"openai/gpt-5.4-pro":{id:"openai/gpt-5.4-pro",name:"OpenAI: GPT-5.4 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"OpenAI: gpt-oss-120b",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.039,output:.19,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"openai/gpt-oss-120b:exacto":{id:"openai/gpt-oss-120b:exacto",name:"OpenAI: gpt-oss-120b (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.039,output:.19,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"openai/gpt-oss-120b:free":{id:"openai/gpt-oss-120b:free",name:"OpenAI: gpt-oss-120b (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"OpenAI: gpt-oss-20b",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.03,output:.14,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"openai/gpt-oss-20b:free":{id:"openai/gpt-oss-20b:free",name:"OpenAI: gpt-oss-20b (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-safeguard-20b":{id:"openai/gpt-oss-safeguard-20b",name:"OpenAI: gpt-oss-safeguard-20b",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:.037,cacheWrite:0},contextWindow:131072,maxTokens:65536},"openai/o1":{id:"openai/o1",name:"OpenAI: o1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3":{id:"openai/o3",name:"OpenAI: o3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-deep-research":{id:"openai/o3-deep-research",name:"OpenAI: o3 Deep Research",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-mini":{id:"openai/o3-mini",name:"OpenAI: o3 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-mini-high":{id:"openai/o3-mini-high",name:"OpenAI: o3 Mini High",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-pro":{id:"openai/o3-pro",name:"OpenAI: o3 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini":{id:"openai/o4-mini",name:"OpenAI: o4 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini-deep-research":{id:"openai/o4-mini-deep-research",name:"OpenAI: o4 Mini Deep Research",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini-high":{id:"openai/o4-mini-high",name:"OpenAI: o4 Mini High",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openrouter/auto":{id:"openrouter/auto",name:"Auto Router",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0},contextWindow:2e6,maxTokens:4096},"openrouter/free":{id:"openrouter/free",name:"Free Models Router",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096},"prime-intellect/intellect-3":{id:"prime-intellect/intellect-3",name:"Prime Intellect: INTELLECT-3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.1,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"qwen/qwen-2.5-72b-instruct":{id:"qwen/qwen-2.5-72b-instruct",name:"Qwen2.5 72B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.12,output:.39,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:16384},"qwen/qwen-2.5-7b-instruct":{id:"qwen/qwen-2.5-7b-instruct",name:"Qwen: Qwen2.5 7B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.04,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"qwen/qwen-max":{id:"qwen/qwen-max",name:"Qwen: Qwen-Max ",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.04,output:4.16,cacheRead:.20800000000000002,cacheWrite:0},contextWindow:32768,maxTokens:8192},"qwen/qwen-plus":{id:"qwen/qwen-plus",name:"Qwen: Qwen-Plus",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:1.2,cacheRead:.08,cacheWrite:0},contextWindow:1e6,maxTokens:32768},"qwen/qwen-plus-2025-07-28":{id:"qwen/qwen-plus-2025-07-28",name:"Qwen: Qwen Plus 0728",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.26,output:.78,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:32768},"qwen/qwen-plus-2025-07-28:thinking":{id:"qwen/qwen-plus-2025-07-28:thinking",name:"Qwen: Qwen Plus 0728 (thinking)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.26,output:.78,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:32768},"qwen/qwen-turbo":{id:"qwen/qwen-turbo",name:"Qwen: Qwen-Turbo",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.0325,output:.13,cacheRead:.006500000000000001,cacheWrite:0},contextWindow:131072,maxTokens:8192},"qwen/qwen-vl-max":{id:"qwen/qwen-vl-max",name:"Qwen: Qwen VL Max",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.7999999999999999,output:3.1999999999999997,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-14b":{id:"qwen/qwen3-14b",name:"Qwen: Qwen3 14B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:40960},"qwen/qwen3-235b-a22b":{id:"qwen/qwen3-235b-a22b",name:"Qwen: Qwen3 235B A22B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.45499999999999996,output:1.8199999999999998,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"qwen/qwen3-235b-a22b-2507":{id:"qwen/qwen3-235b-a22b-2507",name:"Qwen: Qwen3 235B A22B Instruct 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.071,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-235b-a22b-thinking-2507":{id:"qwen/qwen3-235b-a22b-thinking-2507",name:"Qwen: Qwen3 235B A22B Thinking 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.11,output:.6,cacheRead:.055,cacheWrite:0},contextWindow:262144,maxTokens:262144},"qwen/qwen3-30b-a3b":{id:"qwen/qwen3-30b-a3b",name:"Qwen: Qwen3 30B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.08,output:.28,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:40960},"qwen/qwen3-30b-a3b-instruct-2507":{id:"qwen/qwen3-30b-a3b-instruct-2507",name:"Qwen: Qwen3 30B A3B Instruct 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"qwen/qwen3-30b-a3b-thinking-2507":{id:"qwen/qwen3-30b-a3b-thinking-2507",name:"Qwen: Qwen3 30B A3B Thinking 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.051,output:.33999999999999997,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"qwen/qwen3-32b":{id:"qwen/qwen3-32b",name:"Qwen: Qwen3 32B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.08,output:.24,cacheRead:.04,cacheWrite:0},contextWindow:40960,maxTokens:40960},"qwen/qwen3-4b:free":{id:"qwen/qwen3-4b:free",name:"Qwen: Qwen3 4B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:4096},"qwen/qwen3-8b":{id:"qwen/qwen3-8b",name:"Qwen: Qwen3 8B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.049999999999999996,output:.39999999999999997,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:40960,maxTokens:8192},"qwen/qwen3-coder":{id:"qwen/qwen3-coder",name:"Qwen: Qwen3 Coder 480B A35B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.22,output:1,cacheRead:.022,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-coder-30b-a3b-instruct":{id:"qwen/qwen3-coder-30b-a3b-instruct",name:"Qwen: Qwen3 Coder 30B A3B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.07,output:.27,cacheRead:0,cacheWrite:0},contextWindow:16e4,maxTokens:32768},"qwen/qwen3-coder-flash":{id:"qwen/qwen3-coder-flash",name:"Qwen: Qwen3 Coder Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.195,output:.975,cacheRead:.039,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen/qwen3-coder-next":{id:"qwen/qwen3-coder-next",name:"Qwen: Qwen3 Coder Next",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.12,output:.75,cacheRead:.06,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3-coder-plus":{id:"qwen/qwen3-coder-plus",name:"Qwen: Qwen3 Coder Plus",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.65,output:3.25,cacheRead:.13,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen/qwen3-coder:exacto":{id:"qwen/qwen3-coder:exacto",name:"Qwen: Qwen3 Coder 480B A35B (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.22,output:1.7999999999999998,cacheRead:.022,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3-coder:free":{id:"qwen/qwen3-coder:free",name:"Qwen: Qwen3 Coder 480B A35B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"qwen/qwen3-max":{id:"qwen/qwen3-max",name:"Qwen: Qwen3 Max",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:262144,maxTokens:32768},"qwen/qwen3-max-thinking":{id:"qwen/qwen3-max-thinking",name:"Qwen: Qwen3 Max Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.78,output:3.9,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"qwen/qwen3-next-80b-a3b-instruct":{id:"qwen/qwen3-next-80b-a3b-instruct",name:"Qwen: Qwen3 Next 80B A3B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09,output:1.1,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-next-80b-a3b-instruct:free":{id:"qwen/qwen3-next-80b-a3b-instruct:free",name:"Qwen: Qwen3 Next 80B A3B Instruct (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-next-80b-a3b-thinking":{id:"qwen/qwen3-next-80b-a3b-thinking",name:"Qwen: Qwen3 Next 80B A3B Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.15,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"qwen/qwen3-vl-235b-a22b-instruct":{id:"qwen/qwen3-vl-235b-a22b-instruct",name:"Qwen: Qwen3 VL 235B A22B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.19999999999999998,output:.88,cacheRead:.11,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-vl-235b-a22b-thinking":{id:"qwen/qwen3-vl-235b-a22b-thinking",name:"Qwen: Qwen3 VL 235B A22B Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-30b-a3b-instruct":{id:"qwen/qwen3-vl-30b-a3b-instruct",name:"Qwen: Qwen3 VL 30B A3B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.13,output:.52,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-30b-a3b-thinking":{id:"qwen/qwen3-vl-30b-a3b-thinking",name:"Qwen: Qwen3 VL 30B A3B Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-32b-instruct":{id:"qwen/qwen3-vl-32b-instruct",name:"Qwen: Qwen3 VL 32B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.10400000000000001,output:.41600000000000004,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-8b-instruct":{id:"qwen/qwen3-vl-8b-instruct",name:"Qwen: Qwen3 VL 8B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.08,output:.5,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-8b-thinking":{id:"qwen/qwen3-vl-8b-thinking",name:"Qwen: Qwen3 VL 8B Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.117,output:1.365,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3.5-122b-a10b":{id:"qwen/qwen3.5-122b-a10b",name:"Qwen: Qwen3.5-122B-A10B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.26,output:2.08,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3.5-27b":{id:"qwen/qwen3.5-27b",name:"Qwen: Qwen3.5-27B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.195,output:1.56,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3.5-35b-a3b":{id:"qwen/qwen3.5-35b-a3b",name:"Qwen: Qwen3.5-35B-A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.1625,output:1.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3.5-397b-a17b":{id:"qwen/qwen3.5-397b-a17b",name:"Qwen: Qwen3.5 397B A17B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.39,output:2.34,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3.5-flash-02-23":{id:"qwen/qwen3.5-flash-02-23",name:"Qwen: Qwen3.5-Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen/qwen3.5-plus-02-15":{id:"qwen/qwen3.5-plus-02-15",name:"Qwen: Qwen3.5 Plus 2026-02-15",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.26,output:1.56,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen/qwq-32b":{id:"qwen/qwq-32b",name:"Qwen: QwQ 32B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"relace/relace-search":{id:"relace/relace-search",name:"Relace: Relace Search",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:128e3},"sao10k/l3-euryale-70b":{id:"sao10k/l3-euryale-70b",name:"Sao10k: Llama 3 Euryale 70B v2.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.48,output:1.48,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"sao10k/l3.1-euryale-70b":{id:"sao10k/l3.1-euryale-70b",name:"Sao10K: Llama 3.1 Euryale 70B v2.2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.65,output:.75,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"stepfun/step-3.5-flash":{id:"stepfun/step-3.5-flash",name:"StepFun: Step 3.5 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"stepfun/step-3.5-flash:free":{id:"stepfun/step-3.5-flash:free",name:"StepFun: Step 3.5 Flash (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"thedrummer/rocinante-12b":{id:"thedrummer/rocinante-12b",name:"TheDrummer: Rocinante 12B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.16999999999999998,output:.43,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"thedrummer/unslopnemo-12b":{id:"thedrummer/unslopnemo-12b",name:"TheDrummer: UnslopNemo 12B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"tngtech/deepseek-r1t2-chimera":{id:"tngtech/deepseek-r1t2-chimera",name:"TNG: DeepSeek R1T2 Chimera",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.85,cacheRead:.125,cacheWrite:0},contextWindow:163840,maxTokens:163840},"upstage/solar-pro-3":{id:"upstage/solar-pro-3",name:"Upstage: Solar Pro 3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:.015,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"x-ai/grok-3":{id:"x-ai/grok-3",name:"xAI: Grok 3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:4096},"x-ai/grok-3-beta":{id:"x-ai/grok-3-beta",name:"xAI: Grok 3 Beta",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:4096},"x-ai/grok-3-mini":{id:"x-ai/grok-3-mini",name:"xAI: Grok 3 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:4096},"x-ai/grok-3-mini-beta":{id:"x-ai/grok-3-mini-beta",name:"xAI: Grok 3 Mini Beta",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:4096},"x-ai/grok-4":{id:"x-ai/grok-4",name:"xAI: Grok 4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"x-ai/grok-4-fast":{id:"x-ai/grok-4-fast",name:"xAI: Grok 4 Fast",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"x-ai/grok-4.1-fast":{id:"x-ai/grok-4.1-fast",name:"xAI: Grok 4.1 Fast",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"x-ai/grok-code-fast-1":{id:"x-ai/grok-code-fast-1",name:"xAI: Grok Code Fast 1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.5,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:1e4},"xiaomi/mimo-v2-flash":{id:"xiaomi/mimo-v2-flash",name:"Xiaomi: MiMo-V2-Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.09,output:.29,cacheRead:.045,cacheWrite:0},contextWindow:262144,maxTokens:65536},"z-ai/glm-4-32b":{id:"z-ai/glm-4-32b",name:"Z.ai: GLM 4 32B ",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"z-ai/glm-4.5":{id:"z-ai/glm-4.5",name:"Z.ai: GLM 4.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:131072,maxTokens:98304},"z-ai/glm-4.5-air":{id:"z-ai/glm-4.5-air",name:"Z.ai: GLM 4.5 Air",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.13,output:.85,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:131072,maxTokens:98304},"z-ai/glm-4.5-air:free":{id:"z-ai/glm-4.5-air:free",name:"Z.ai: GLM 4.5 Air (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:96e3},"z-ai/glm-4.5v":{id:"z-ai/glm-4.5v",name:"Z.ai: GLM 4.5V",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:1.7999999999999998,cacheRead:.11,cacheWrite:0},contextWindow:65536,maxTokens:16384},"z-ai/glm-4.6":{id:"z-ai/glm-4.6",name:"Z.ai: GLM 4.6",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.39,output:1.9,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:204800},"z-ai/glm-4.6:exacto":{id:"z-ai/glm-4.6:exacto",name:"Z.ai: GLM 4.6 (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.44,output:1.76,cacheRead:.11,cacheWrite:0},contextWindow:204800,maxTokens:131072},"z-ai/glm-4.6v":{id:"z-ai/glm-4.6v",name:"Z.ai: GLM 4.6V",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:.8999999999999999,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"z-ai/glm-4.7":{id:"z-ai/glm-4.7",name:"Z.ai: GLM 4.7",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.38,output:1.9800000000000002,cacheRead:.19,cacheWrite:0},contextWindow:202752,maxTokens:4096},"z-ai/glm-4.7-flash":{id:"z-ai/glm-4.7-flash",name:"Z.ai: GLM 4.7 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.06,output:.39999999999999997,cacheRead:.0100000002,cacheWrite:0},contextWindow:202752,maxTokens:4096},"z-ai/glm-5":{id:"z-ai/glm-5",name:"Z.ai: GLM 5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.6,output:1.9,cacheRead:.119,cacheWrite:0},contextWindow:202752,maxTokens:4096}},"vercel-ai-gateway":{"alibaba/qwen-3-14b":{id:"alibaba/qwen-3-14b",name:"Qwen3-14B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen-3-235b":{id:"alibaba/qwen-3-235b",name:"Qwen3-235B-A22B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.071,output:.463,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen-3-30b":{id:"alibaba/qwen-3-30b",name:"Qwen3-30B-A3B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.08,output:.29,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen-3-32b":{id:"alibaba/qwen-3-32b",name:"Qwen 3 32B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen3-235b-a22b-thinking":{id:"alibaba/qwen3-235b-a22b-thinking",name:"Qwen3 235B A22B Thinking 2507",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.9000000000000004,cacheRead:0,cacheWrite:0},contextWindow:262114,maxTokens:262114},"alibaba/qwen3-coder":{id:"alibaba/qwen3-coder",name:"Qwen3 Coder 480B A35B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:1.5999999999999999,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:66536},"alibaba/qwen3-coder-30b-a3b":{id:"alibaba/qwen3-coder-30b-a3b",name:"Qwen 3 Coder 30B A3B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.07,output:.27,cacheRead:0,cacheWrite:0},contextWindow:16e4,maxTokens:32768},"alibaba/qwen3-coder-next":{id:"alibaba/qwen3-coder-next",name:"Qwen3 Coder Next",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.5,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"alibaba/qwen3-coder-plus":{id:"alibaba/qwen3-coder-plus",name:"Qwen3 Coder Plus",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:1,output:5,cacheRead:.19999999999999998,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"alibaba/qwen3-max-preview":{id:"alibaba/qwen3-max-preview",name:"Qwen3 Max Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:262144,maxTokens:32768},"alibaba/qwen3-max-thinking":{id:"alibaba/qwen3-max-thinking",name:"Qwen 3 Max Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:256e3,maxTokens:65536},"alibaba/qwen3-vl-thinking":{id:"alibaba/qwen3-vl-thinking",name:"Qwen3 VL 235B A22B Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.22,output:.88,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"alibaba/qwen3.5-flash":{id:"alibaba/qwen3.5-flash",name:"Qwen 3.5 Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.001,cacheWrite:.125},contextWindow:1e6,maxTokens:64e3},"alibaba/qwen3.5-plus":{id:"alibaba/qwen3.5-plus",name:"Qwen 3.5 Plus",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.39999999999999997,output:2.4,cacheRead:.04,cacheWrite:.5},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-3-haiku":{id:"anthropic/claude-3-haiku",name:"Claude 3 Haiku",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"anthropic/claude-3.5-haiku":{id:"anthropic/claude-3.5-haiku",name:"Claude 3.5 Haiku",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.7999999999999999,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.5-sonnet":{id:"anthropic/claude-3.5-sonnet",name:"Claude 3.5 Sonnet",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.5-sonnet-20240620":{id:"anthropic/claude-3.5-sonnet-20240620",name:"Claude 3.5 Sonnet (2024-06-20)",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.7-sonnet":{id:"anthropic/claude-3.7-sonnet",name:"Claude 3.7 Sonnet",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic/claude-haiku-4.5":{id:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.09999999999999999,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4":{id:"anthropic/claude-opus-4",name:"Claude Opus 4",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.1":{id:"anthropic/claude-opus-4.1",name:"Claude Opus 4.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.5":{id:"anthropic/claude-opus-4.5",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4.6":{id:"anthropic/claude-opus-4.6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3},"anthropic/claude-sonnet-4":{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-sonnet-4.5":{id:"anthropic/claude-sonnet-4.5",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-sonnet-4.6":{id:"anthropic/claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:128e3},"arcee-ai/trinity-large-preview":{id:"arcee-ai/trinity-large-preview",name:"Trinity Large Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.25,output:1,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:131e3},"bytedance/seed-1.6":{id:"bytedance/seed-1.6",name:"Seed 1.6",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.25,output:2,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:256e3,maxTokens:32e3},"cohere/command-a":{id:"cohere/command-a",name:"Command A",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:8e3},"deepseek/deepseek-v3":{id:"deepseek/deepseek-v3",name:"DeepSeek V3 0324",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.77,output:.77,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:16384},"deepseek/deepseek-v3.1":{id:"deepseek/deepseek-v3.1",name:"DeepSeek-V3.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.21,output:.7899999999999999,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:128e3},"deepseek/deepseek-v3.1-terminus":{id:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek V3.1 Terminus",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.27,output:1,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"deepseek/deepseek-v3.2":{id:"deepseek/deepseek-v3.2",name:"DeepSeek V3.2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.26,output:.38,cacheRead:.13,cacheWrite:0},contextWindow:128e3,maxTokens:8e3},"deepseek/deepseek-v3.2-thinking":{id:"deepseek/deepseek-v3.2-thinking",name:"DeepSeek V3.2 Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.28,output:.42,cacheRead:.028,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"google/gemini-2.5-flash":{id:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"google/gemini-2.5-flash-lite":{id:"google/gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-flash-lite-preview-09-2025":{id:"google/gemini-2.5-flash-lite-preview-09-2025",name:"Gemini 2.5 Flash Lite Preview 09-2025",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-flash-preview-09-2025":{id:"google/gemini-2.5-flash-preview-09-2025",name:"Gemini 2.5 Flash Preview 09-2025",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"google/gemini-2.5-pro":{id:"google/gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:1.25,output:10,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"google/gemini-3-flash":{id:"google/gemini-3-flash",name:"Gemini 3 Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"google/gemini-3-pro-preview":{id:"google/gemini-3-pro-preview",name:"Gemini 3 Pro Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"google/gemini-3.1-flash-lite-preview":{id:"google/gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65e3},"google/gemini-3.1-pro-preview":{id:"google/gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"inception/mercury-2":{id:"inception/mercury-2",name:"Mercury 2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.25,output:.75,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"inception/mercury-coder-small":{id:"inception/mercury-coder-small",name:"Mercury Coder Small Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.25,output:1,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:16384},"meituan/longcat-flash-chat":{id:"meituan/longcat-flash-chat",name:"LongCat Flash Chat",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meituan/longcat-flash-thinking":{id:"meituan/longcat-flash-thinking",name:"LongCat Flash Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.15,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-3.1-70b":{id:"meta/llama-3.1-70b",name:"Llama 3.1 70B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"meta/llama-3.1-8b":{id:"meta/llama-3.1-8b",name:"Llama 3.1 8B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.03,output:.049999999999999996,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"meta/llama-3.2-11b":{id:"meta/llama-3.2-11b",name:"Llama 3.2 11B Vision Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.16,output:.16,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-3.2-90b":{id:"meta/llama-3.2-90b",name:"Llama 3.2 90B Vision Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-3.3-70b":{id:"meta/llama-3.3-70b",name:"Llama 3.3 70B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-4-maverick":{id:"meta/llama-4-maverick",name:"Llama 4 Maverick 17B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"meta/llama-4-scout":{id:"meta/llama-4-scout",name:"Llama 4 Scout 17B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.08,output:.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"minimax/minimax-m2":{id:"minimax/minimax-m2",name:"MiniMax M2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:205e3,maxTokens:205e3},"minimax/minimax-m2.1":{id:"minimax/minimax-m2.1",name:"MiniMax M2.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.15,cacheWrite:0},contextWindow:204800,maxTokens:131072},"minimax/minimax-m2.1-lightning":{id:"minimax/minimax-m2.1-lightning",name:"MiniMax M2.1 Lightning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:2.4,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"minimax/minimax-m2.5":{id:"minimax/minimax-m2.5",name:"MiniMax M2.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131e3},"minimax/minimax-m2.5-highspeed":{id:"minimax/minimax-m2.5-highspeed",name:"MiniMax M2.5 High Speed",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.03,cacheWrite:.375},contextWindow:4096,maxTokens:4096},"mistral/codestral":{id:"mistral/codestral",name:"Mistral Codestral",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.3,output:.8999999999999999,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/devstral-2":{id:"mistral/devstral-2",name:"Devstral 2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/devstral-small":{id:"mistral/devstral-small",name:"Devstral Small 1.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"mistral/devstral-small-2":{id:"mistral/devstral-small-2",name:"Devstral Small 2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/ministral-3b":{id:"mistral/ministral-3b",name:"Ministral 3B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.04,output:.04,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/ministral-8b":{id:"mistral/ministral-8b",name:"Ministral 8B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/mistral-medium":{id:"mistral/mistral-medium",name:"Mistral Medium 3.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"mistral/mistral-small":{id:"mistral/mistral-small",name:"Mistral Small",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:4e3},"mistral/pixtral-12b":{id:"mistral/pixtral-12b",name:"Pixtral 12B 2409",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/pixtral-large":{id:"mistral/pixtral-large",name:"Pixtral Large",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"moonshotai/kimi-k2":{id:"moonshotai/kimi-k2",name:"Kimi K2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.5,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"moonshotai/kimi-k2-thinking":{id:"moonshotai/kimi-k2-thinking",name:"Kimi K2 Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.47,output:2,cacheRead:.14100000000000001,cacheWrite:0},contextWindow:216144,maxTokens:216144},"moonshotai/kimi-k2-thinking-turbo":{id:"moonshotai/kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:1.15,output:8,cacheRead:.15,cacheWrite:0},contextWindow:262114,maxTokens:262114},"moonshotai/kimi-k2-turbo":{id:"moonshotai/kimi-k2-turbo",name:"Kimi K2 Turbo",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:2.4,output:10,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:16384},"moonshotai/kimi-k2.5":{id:"moonshotai/kimi-k2.5",name:"Kimi K2.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.5,output:2.8,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"nvidia/nemotron-nano-12b-v2-vl":{id:"nvidia/nemotron-nano-12b-v2-vl",name:"Nvidia Nemotron Nano 12B V2 VL",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.19999999999999998,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"nvidia/nemotron-nano-9b-v2":{id:"nvidia/nemotron-nano-9b-v2",name:"Nvidia Nemotron Nano 9B V2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.04,output:.16,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/codex-mini":{id:"openai/codex-mini",name:"Codex Mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.5,output:6,cacheRead:.375,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/gpt-4-turbo":{id:"openai/gpt-4-turbo",name:"GPT-4 Turbo",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4.1":{id:"openai/gpt-4.1",name:"GPT-4.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-mini":{id:"openai/gpt-4.1-mini",name:"GPT-4.1 mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:1.5999999999999999,cacheRead:.09999999999999999,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-nano":{id:"openai/gpt-4.1-nano",name:"GPT-4.1 nano",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.03,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4o":{id:"openai/gpt-4o",name:"GPT-4o",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-mini":{id:"openai/gpt-4o-mini",name:"GPT-4o mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5":{id:"openai/gpt-5",name:"GPT-5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-chat":{id:"openai/gpt-5-chat",name:"GPT 5 Chat",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5-codex":{id:"openai/gpt-5-codex",name:"GPT-5-Codex",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-mini":{id:"openai/gpt-5-mini",name:"GPT-5 mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.03,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-nano":{id:"openai/gpt-5-nano",name:"GPT-5 nano",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.049999999999999996,output:.39999999999999997,cacheRead:.01,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-pro":{id:"openai/gpt-5-pro",name:"GPT-5 pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:272e3},"openai/gpt-5.1-codex":{id:"openai/gpt-5.1-codex",name:"GPT-5.1-Codex",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-max":{id:"openai/gpt-5.1-codex-max",name:"GPT 5.1 Codex Max",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-mini":{id:"openai/gpt-5.1-codex-mini",name:"GPT 5.1 Codex Mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-instant":{id:"openai/gpt-5.1-instant",name:"GPT-5.1 Instant",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.1-thinking":{id:"openai/gpt-5.1-thinking",name:"GPT 5.1 Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2":{id:"openai/gpt-5.2",name:"GPT 5.2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.18,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2-chat":{id:"openai/gpt-5.2-chat",name:"GPT 5.2 Chat",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.2-codex":{id:"openai/gpt-5.2-codex",name:"GPT 5.2 Codex",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2-pro":{id:"openai/gpt-5.2-pro",name:"GPT 5.2 ",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.3-chat":{id:"openai/gpt-5.3-chat",name:"GPT-5.3 Chat",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.3-codex":{id:"openai/gpt-5.3-codex",name:"GPT 5.3 Codex",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.4":{id:"openai/gpt-5.4",name:"GPT 5.4",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"openai/gpt-5.4-pro":{id:"openai/gpt-5.4-pro",name:"GPT 5.4 Pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"gpt-oss-120b",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.09999999999999999,output:.5,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"gpt-oss-20b",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.07,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"openai/gpt-oss-safeguard-20b":{id:"openai/gpt-oss-safeguard-20b",name:"gpt-oss-safeguard-20b",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:.037,cacheWrite:0},contextWindow:131072,maxTokens:65536},"openai/o1":{id:"openai/o1",name:"o1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3":{id:"openai/o3",name:"o3",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-deep-research":{id:"openai/o3-deep-research",name:"o3-deep-research",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-mini":{id:"openai/o3-mini",name:"o3-mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-pro":{id:"openai/o3-pro",name:"o3 Pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini":{id:"openai/o4-mini",name:"o4-mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"perplexity/sonar":{id:"perplexity/sonar",name:"Sonar",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:1,output:1,cacheRead:0,cacheWrite:0},contextWindow:127e3,maxTokens:8e3},"perplexity/sonar-pro":{id:"perplexity/sonar-pro",name:"Sonar Pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:8e3},"prime-intellect/intellect-3":{id:"prime-intellect/intellect-3",name:"INTELLECT 3",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.1,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"vercel/v0-1.0-md":{id:"vercel/v0-1.0-md",name:"v0-1.0-md",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"vercel/v0-1.5-md":{id:"vercel/v0-1.5-md",name:"v0-1.5-md",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32768},"xai/grok-2-vision":{id:"xai/grok-2-vision",name:"Grok 2 Vision",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:2,output:10,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"xai/grok-3":{id:"xai/grok-3",name:"Grok 3 Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"xai/grok-3-fast":{id:"xai/grok-3-fast",name:"Grok 3 Fast Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:5,output:25,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"xai/grok-3-mini":{id:"xai/grok-3-mini",name:"Grok 3 Mini Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.3,output:.5,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"xai/grok-3-mini-fast":{id:"xai/grok-3-mini-fast",name:"Grok 3 Mini Fast Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.6,output:4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"xai/grok-4":{id:"xai/grok-4",name:"Grok 4",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"xai/grok-4-fast-non-reasoning":{id:"xai/grok-4-fast-non-reasoning",name:"Grok 4 Fast Non-Reasoning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:256e3},"xai/grok-4-fast-reasoning":{id:"xai/grok-4-fast-reasoning",name:"Grok 4 Fast Reasoning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:256e3},"xai/grok-4.1-fast-non-reasoning":{id:"xai/grok-4.1-fast-non-reasoning",name:"Grok 4.1 Fast Non-Reasoning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"xai/grok-4.1-fast-reasoning":{id:"xai/grok-4.1-fast-reasoning",name:"Grok 4.1 Fast Reasoning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"xai/grok-code-fast-1":{id:"xai/grok-code-fast-1",name:"Grok Code Fast 1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.5,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"xiaomi/mimo-v2-flash":{id:"xiaomi/mimo-v2-flash",name:"MiMo V2 Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.09,output:.29,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32e3},"zai/glm-4.5":{id:"zai/glm-4.5",name:"GLM-4.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"zai/glm-4.5-air":{id:"zai/glm-4.5-air",name:"GLM 4.5 Air",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.1,cacheRead:.03,cacheWrite:0},contextWindow:128e3,maxTokens:96e3},"zai/glm-4.5v":{id:"zai/glm-4.5v",name:"GLM 4.5V",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.6,output:1.7999999999999998,cacheRead:0,cacheWrite:0},contextWindow:65536,maxTokens:16384},"zai/glm-4.6":{id:"zai/glm-4.6",name:"GLM 4.6",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.44999999999999996,output:1.7999999999999998,cacheRead:.11,cacheWrite:0},contextWindow:2e5,maxTokens:96e3},"zai/glm-4.6v":{id:"zai/glm-4.6v",name:"GLM-4.6V",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.3,output:.8999999999999999,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:128e3,maxTokens:24e3},"zai/glm-4.6v-flash":{id:"zai/glm-4.6v-flash",name:"GLM-4.6V-Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:24e3},"zai/glm-4.7":{id:"zai/glm-4.7",name:"GLM 4.7",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.43,output:1.75,cacheRead:.08,cacheWrite:0},contextWindow:202752,maxTokens:12e4},"zai/glm-4.7-flashx":{id:"zai/glm-4.7-flashx",name:"GLM 4.7 FlashX",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.06,output:.39999999999999997,cacheRead:.01,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"zai/glm-5":{id:"zai/glm-5",name:"GLM 5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.7999999999999999,output:2.56,cacheRead:.16,cacheWrite:0},contextWindow:202800,maxTokens:131100}},xai:{"grok-2":{id:"grok-2",name:"Grok 2",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-2-1212":{id:"grok-2-1212",name:"Grok 2 (1212)",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-2-latest":{id:"grok-2-latest",name:"Grok 2 Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-2-vision":{id:"grok-2-vision",name:"Grok 2 Vision",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:8192,maxTokens:4096},"grok-2-vision-1212":{id:"grok-2-vision-1212",name:"Grok 2 Vision (1212)",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:8192,maxTokens:4096},"grok-2-vision-latest":{id:"grok-2-vision-latest",name:"Grok 2 Vision Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:8192,maxTokens:4096},"grok-3":{id:"grok-3",name:"Grok 3",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-fast":{id:"grok-3-fast",name:"Grok 3 Fast",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:5,output:25,cacheRead:1.25,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-fast-latest":{id:"grok-3-fast-latest",name:"Grok 3 Fast Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:5,output:25,cacheRead:1.25,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-latest":{id:"grok-3-latest",name:"Grok 3 Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-mini":{id:"grok-3-mini",name:"Grok 3 Mini",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-mini-fast":{id:"grok-3-mini-fast",name:"Grok 3 Mini Fast",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.6,output:4,cacheRead:.15,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-mini-fast-latest":{id:"grok-3-mini-fast-latest",name:"Grok 3 Mini Fast Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.6,output:4,cacheRead:.15,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-mini-latest":{id:"grok-3-mini-latest",name:"Grok 3 Mini Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-4":{id:"grok-4",name:"Grok 4",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:256e3,maxTokens:64e3},"grok-4-1-fast":{id:"grok-4-1-fast",name:"Grok 4.1 Fast",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"grok-4-1-fast-non-reasoning":{id:"grok-4-1-fast-non-reasoning",name:"Grok 4.1 Fast (Non-Reasoning)",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"grok-4-fast":{id:"grok-4-fast",name:"Grok 4 Fast",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"grok-4-fast-non-reasoning":{id:"grok-4-fast-non-reasoning",name:"Grok 4 Fast (Non-Reasoning)",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"grok-beta":{id:"grok-beta",name:"Grok Beta",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:5,output:15,cacheRead:5,cacheWrite:0},contextWindow:131072,maxTokens:4096},"grok-code-fast-1":{id:"grok-code-fast-1",name:"Grok Code Fast 1",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.2,output:1.5,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:1e4},"grok-vision-beta":{id:"grok-vision-beta",name:"Grok Vision Beta",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:5,cacheWrite:0},contextWindow:8192,maxTokens:4096}},zai:{"glm-4.5":{id:"glm-4.5",name:"GLM-4.5",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:131072,maxTokens:98304},"glm-4.5-air":{id:"glm-4.5-air",name:"GLM-4.5-Air",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:.2,output:1.1,cacheRead:.03,cacheWrite:0},contextWindow:131072,maxTokens:98304},"glm-4.5-flash":{id:"glm-4.5-flash",name:"GLM-4.5-Flash",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:98304},"glm-4.5v":{id:"glm-4.5v",name:"GLM-4.5V",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text","image"],cost:{input:.6,output:1.8,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16384},"glm-4.6":{id:"glm-4.6",name:"GLM-4.6",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:204800,maxTokens:131072},"glm-4.6v":{id:"glm-4.6v",name:"GLM-4.6V",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text","image"],cost:{input:.3,output:.9,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32768},"glm-4.7":{id:"glm-4.7",name:"GLM-4.7",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:204800,maxTokens:131072},"glm-4.7-flash":{id:"glm-4.7-flash",name:"GLM-4.7-Flash",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:131072},"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:204800,maxTokens:131072}}},v=new Map;for(const[e,t]of Object.entries(y)){const n=new Map;for(const[e,o]of Object.entries(t))n.set(e,o);v.set(e,n)}function _(e,t){const n=v.get(e);return n?.get(t)}function w(){return Array.from(v.keys())}function O(e){const t=v.get(e);return t?Array.from(t.values()):[]}function S(e,t){return t.cost.input=e.cost.input/1e6*t.input,t.cost.output=e.cost.output/1e6*t.output,t.cost.cacheRead=e.cost.cacheRead/1e6*t.cacheRead,t.cost.cacheWrite=e.cost.cacheWrite/1e6*t.cacheWrite,t.cost.total=t.cost.input+t.cost.output+t.cost.cacheRead+t.cost.cacheWrite,t.cost}function x(e){return!!(e.id.includes("gpt-5.2")||e.id.includes("gpt-5.3")||e.id.includes("gpt-5.4"))||"anthropic-messages"===e.api&&(e.id.includes("opus-4-6")||e.id.includes("opus-4.6"))}function T(e,t){return!(!e||!t)&&(e.id===t.id&&e.provider===t.provider)}function P(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function C(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}let k=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return k=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^n()&15>>+e/4).toString(16))};function j(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const E=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};class R extends Error{}class A extends R{constructor(e,t,n,o){super(`${A.makeMessage(e,t,n)}`),this.status=e,this.headers=o,this.requestID=o?.get("request-id"),this.error=t}static makeMessage(e,t,n){const o=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&o?`${e} ${o}`:e?`${e} status code (no body)`:o||"(no status code or body)"}static generate(e,t,n,o){if(!e||!o)return new M({message:n,cause:E(t)});const r=t;return 400===e?new $(e,r,n,o):401===e?new D(e,r,n,o):403===e?new U(e,r,n,o):404===e?new L(e,r,n,o):409===e?new q(e,r,n,o):422===e?new F(e,r,n,o):429===e?new W(e,r,n,o):e>=500?new J(e,r,n,o):new A(e,r,n,o)}}class I extends A{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class M extends A{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class N extends M{constructor({message:e}={}){super({message:e??"Request timed out."})}}class $ extends A{}class D extends A{}class U extends A{}class L extends A{}class q extends A{}class F extends A{}class W extends A{}class J extends A{}const B=/^[a-z][a-z0-9+.-]*:/i;let G=e=>(G=Array.isArray,G(e)),V=G;function H(e){return"object"!=typeof e?{}:e??{}}const z=e=>{try{return JSON.parse(e)}catch(e){return}},K="0.73.0";const X=()=>{const e="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":Y(Deno.build.os),"X-Stainless-Arch":Z(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":Y(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Z(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const t=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const e=n.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const Z=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",Y=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let Q;function ee(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function te(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ee({start(){},async pull(e){const{done:n,value:o}=await t.next();n?e.close():e.enqueue(o)},async cancel(){await(t.return?.())}})}function ne(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}const oe=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});let re,ie;function ae(e){let t;return(re??(t=new globalThis.TextEncoder,re=t.encode.bind(t)))(e)}function se(e){let t;return(ie??(t=new globalThis.TextDecoder,ie=t.decode.bind(t)))(e)}var ce,ue;class le{constructor(){ce.set(this,void 0),ue.set(this,void 0),P(this,ce,new Uint8Array,"f"),P(this,ue,null,"f")}decode(e){if(null==e)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?ae(e):e;P(this,ce,function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let o=0;for(const t of e)n.set(t,o),o+=t.length;return n}([C(this,ce,"f"),t]),"f");const n=[];let o;for(;null!=(o=de(C(this,ce,"f"),C(this,ue,"f")));){if(o.carriage&&null==C(this,ue,"f")){P(this,ue,o.index,"f");continue}if(null!=C(this,ue,"f")&&(o.index!==C(this,ue,"f")+1||o.carriage)){n.push(se(C(this,ce,"f").subarray(0,C(this,ue,"f")-1))),P(this,ce,C(this,ce,"f").subarray(C(this,ue,"f")),"f"),P(this,ue,null,"f");continue}const e=null!==C(this,ue,"f")?o.preceding-1:o.preceding,t=se(C(this,ce,"f").subarray(0,e));n.push(t),P(this,ce,C(this,ce,"f").subarray(o.index),"f"),P(this,ue,null,"f")}return n}flush(){return C(this,ce,"f").length?this.decode("\n"):[]}}function de(e,t){for(let n=t??0;n<e.length;n++){if(10===e[n])return{preceding:n,index:n+1,carriage:!1};if(13===e[n])return{preceding:n,index:n+1,carriage:!0}}return null}function pe(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1])return t+2;if(13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return-1}ce=new WeakMap,ue=new WeakMap,le.NEWLINE_CHARS=new Set(["\n","\r"]),le.NEWLINE_REGEXP=/\r\n|[\n\r]/g;const he={off:0,error:200,warn:300,info:400,debug:500},fe=(e,t,n)=>{var o,r;if(e)return o=he,r=e,Object.prototype.hasOwnProperty.call(o,r)?e:void ve(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(he))}`)};function me(){}function ge(e,t,n){return!t||he[e]>he[n]?me:t[e].bind(t)}const be={error:me,warn:me,info:me,debug:me};let ye=new WeakMap;function ve(e){const t=e.logger,n=e.logLevel??"off";if(!t)return be;const o=ye.get(t);if(o&&o[0]===n)return o[1];const r={error:ge("error",t,n),warn:ge("warn",t,n),info:ge("info",t,n),debug:ge("debug",t,n)};return ye.set(t,[n,r]),r}const _e=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"x-api-key"===e.toLowerCase()||"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var we,Oe,Se;class xe{constructor(e,t,n){this.iterator=e,we.set(this,void 0),this.controller=t,P(this,we,n,"f")}static fromSSEResponse(e,t,n){let o=!1;const r=n?ve(n):console;return new xe(async function*(){if(o)throw new R("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let n=!1;try{for await(const n of async function*(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new R("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new R("Attempted to iterate over a response with no body")}const n=new Te,o=new le,r=ne(e.body);for await(const e of async function*(e){let t=new Uint8Array;for await(const n of e){if(null==n)continue;const e=n instanceof ArrayBuffer?new Uint8Array(n):"string"==typeof n?ae(n):n;let o,r=new Uint8Array(t.length+e.length);for(r.set(t),r.set(e,t.length),t=r;-1!==(o=pe(t));)yield t.slice(0,o),t=t.slice(o)}t.length>0&&(yield t)}(r))for(const t of o.decode(e)){const e=n.decode(t);e&&(yield e)}for(const e of o.flush()){const t=n.decode(e);t&&(yield t)}}(e,t)){if("completion"===n.event)try{yield JSON.parse(n.data)}catch(e){throw r.error("Could not parse message into JSON:",n.data),r.error("From chunk:",n.raw),e}if("message_start"===n.event||"message_delta"===n.event||"message_stop"===n.event||"content_block_start"===n.event||"content_block_delta"===n.event||"content_block_stop"===n.event)try{yield JSON.parse(n.data)}catch(e){throw r.error("Could not parse message into JSON:",n.data),r.error("From chunk:",n.raw),e}if("ping"!==n.event&&"error"===n.event)throw new A(void 0,z(n.data)??n.data,void 0,e.headers)}n=!0}catch(e){if(j(e))return;throw e}finally{n||t.abort()}},t,n)}static fromReadableStream(e,t,n){let o=!1;return new xe(async function*(){if(o)throw new R("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let n=!1;try{for await(const t of async function*(){const t=new le,n=ne(e);for await(const e of n)for(const n of t.decode(e))yield n;for(const e of t.flush())yield e}())n||t&&(yield JSON.parse(t));n=!0}catch(e){if(j(e))return;throw e}finally{n||t.abort()}},t,n)}[(we=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[],t=[],n=this.iterator(),o=o=>({next:()=>{if(0===o.length){const o=n.next();e.push(o),t.push(o)}return o.shift()}});return[new xe(()=>o(e),this.controller,C(this,we,"f")),new xe(()=>o(t),this.controller,C(this,we,"f"))]}toReadableStream(){const e=this;let t;return ee({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{const{value:n,done:o}=await t.next();if(o)return e.close();const r=ae(JSON.stringify(n)+"\n");e.enqueue(r)}catch(t){e.error(t)}},async cancel(){await(t.return?.())}})}}class Te{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,n,o]=function(e,t){const n=e.indexOf(t);if(-1!==n)return[e.substring(0,n),t,e.substring(n+t.length)];return[e,"",""]}(e,":");return o.startsWith(" ")&&(o=o.substring(1)),"event"===t?this.event=o:"data"===t&&this.data.push(o),null}}async function Pe(e,t){const{response:n,requestLogID:o,retryOfRequestLogID:r,startTime:i}=t,a=await(async()=>{if(t.options.stream)return ve(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller):xe.fromSSEResponse(n,t.controller);if(204===n.status)return null;if(t.options.__binaryResponse)return n;const o=n.headers.get("content-type"),r=o?.split(";")[0]?.trim();if(r?.includes("application/json")||r?.endsWith("+json")){if("0"===n.headers.get("content-length"))return;return Ce(await n.json(),n)}return await n.text()})();return ve(e).debug(`[${o}] response parsed`,_e({retryOfRequestLogID:r,url:n.url,status:n.status,body:a,durationMs:Date.now()-i})),a}function Ce(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("request-id"),enumerable:!1})}class ke extends Promise{constructor(e,t,n=Pe){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,Oe.set(this,void 0),P(this,Oe,e,"f")}_thenUnwrap(e){return new ke(C(this,Oe,"f"),this.responsePromise,async(t,n)=>Ce(e(await this.parseResponse(t,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(C(this,Oe,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}Oe=new WeakMap;class je{constructor(e,t,n,o){Se.set(this,void 0),P(this,Se,e,"f"),this.options=o,this.response=t,this.body=n}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new R("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await C(this,Se,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Se=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const t of e.getPaginatedItems())yield t}}class Ee extends ke{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await Pe(e,t),t.options))}async*[Symbol.asyncIterator](){const e=await(this);for await(const t of e)yield t}}class Re extends je{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.has_more=n.has_more||!1,this.first_id=n.first_id||null,this.last_id=n.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){const e=this.first_id;return e?{...this.options,query:{...H(this.options.query),before_id:e}}:null}const e=this.last_id;return e?{...this.options,query:{...H(this.options.query),after_id:e}}:null}}class Ae extends je{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.has_more=n.has_more||!1,this.next_page=n.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){const e=this.next_page;return e?{...this.options,query:{...H(this.options.query),page:e}}:null}}const Ie=()=>{if("undefined"==typeof File){const{process:e}=globalThis,t="string"==typeof e?.versions?.node&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Me(e,t,n){return Ie(),new File(e,t??"unknown_file",n)}function Ne(e,t){const n="object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"";return t?n.split(/[\\/]/).pop()||void 0:n}const $e=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],De=async(e,t,n=!0)=>({...e,body:await Le(e.body,t,n)}),Ue=new WeakMap;const Le=async(e,t,n=!0)=>{if(!await function(e){const t="function"==typeof e?e:e.fetch,n=Ue.get(t);if(n)return n;const o=(async()=>{try{const e="Response"in t?t.Response:(await t("data:,")).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return Ue.set(t,o),o}(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const o=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>Fe(o,e,t,n))),o},qe=e=>e instanceof Blob&&"name"in e,Fe=async(e,t,n,o)=>{if(void 0!==n){if(null==n)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)e.append(t,String(n));else if(n instanceof Response){let r={};const i=n.headers.get("Content-Type");i&&(r={type:i}),e.append(t,Me([await n.blob()],Ne(n,o),r))}else if($e(n))e.append(t,Me([await new Response(te(n)).blob()],Ne(n,o)));else if(qe(n))e.append(t,Me([n],Ne(n,o),{type:n.type}));else if(Array.isArray(n))await Promise.all(n.map(n=>Fe(e,t+"[]",n,o)));else{if("object"!=typeof n)throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`);await Promise.all(Object.entries(n).map(([n,r])=>Fe(e,`${t}[${n}]`,r,o)))}}},We=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function Je(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(We(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else{if(!$e(e)){const t=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";const t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}for await(const n of e)t.push(...await Je(n))}return t}class Be{constructor(e){this._client=e}}const Ge=Symbol.for("brand.privateNullableHeaders");function*Ve(e){if(!e)return;if(Ge in e){const{values:t,nulls:n}=e;yield*t.entries();for(const e of n)yield[e,null];return}let t,n=!1;e instanceof Headers?t=e.entries():V(e)?t=e:(n=!0,t=Object.entries(e??{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const o=V(e[1])?e[1]:[e[1]];let r=!1;for(const e of o)void 0!==e&&(n&&!r&&(r=!0,yield[t,null]),yield[t,e])}}const He=e=>{const t=new Headers,n=new Set;for(const o of e){const e=new Set;for(const[r,i]of Ve(o)){const o=r.toLowerCase();e.has(o)||(t.delete(r),e.add(o)),null===i?(t.delete(r),n.add(o)):(t.append(r,i),n.delete(o))}}return{[Ge]:!0,values:t,nulls:n}},ze=Symbol("anthropic.sdk.stainlessHelper");function Ke(e){return"object"==typeof e&&null!==e&&ze in e}function Xe(e,t){const n=new Set;if(e)for(const t of e)Ke(t)&&n.add(t[ze]);if(t)for(const e of t)if(Ke(e)&&n.add(e[ze]),Array.isArray(e.content))for(const t of e.content)Ke(t)&&n.add(t[ze]);return Array.from(n)}function Ze(e,t){const n=Xe(e,t);return 0===n.length?{}:{"x-stainless-helper":n.join(", ")}}function Ye(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Qe=Object.freeze(Object.create(null)),et=(e=Ye)=>function(t,...n){if(1===t.length)return t[0];let o=!1;const r=[],i=t.reduce((t,i,a)=>{/[?#]/.test(i)&&(o=!0);const s=n[a];let c=(o?encodeURIComponent:e)(""+s);return a!==n.length&&(null==s||"object"==typeof s&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??Qe)??Qe)?.toString)&&(c=s+"",r.push({start:t.length+i.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+i+(a===n.length?"":c)},""),a=i.split(/[?#]/,1)[0],s=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let c;for(;null!==(c=s.exec(a));)r.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can't be safely passed as a path parameter`});if(r.sort((e,t)=>e.start-t.start),r.length>0){let e=0;const t=r.reduce((t,n)=>{const o=" ".repeat(n.start-e),r="^".repeat(n.length);return e=n.start+n.length,t+o+r},"");throw new R(`Path parameters result in path with invalid segments:\n${r.map(e=>e.error).join("\n")}\n${i}\n${t}`)}return i},tt=et(Ye);class nt extends Be{list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/files",Re,{query:o,...t,headers:He([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},t?.headers])})}delete(e,t={},n){const{betas:o}=t??{};return this._client.delete(tt`/v1/files/${e}`,{...n,headers:He([{"anthropic-beta":[...o??[],"files-api-2025-04-14"].toString()},n?.headers])})}download(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/files/${e}/content`,{...n,headers:He([{"anthropic-beta":[...o??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/files/${e}`,{...n,headers:He([{"anthropic-beta":[...o??[],"files-api-2025-04-14"].toString()},n?.headers])})}upload(e,t){const{betas:n,...o}=e;return this._client.post("/v1/files",De({body:o,...t,headers:He([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},(r=o.file,Ke(r)?{"x-stainless-helper":r[ze]}:{}),t?.headers])},this._client));var r}}class ot extends Be{retrieve(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/models/${e}?beta=true`,{...n,headers:He([{...null!=o?.toString()?{"anthropic-beta":o?.toString()}:void 0},n?.headers])})}list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/models?beta=true",Re,{query:o,...t,headers:He([{...null!=n?.toString()?{"anthropic-beta":n?.toString()}:void 0},t?.headers])})}}const rt={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function it(e){return e?.output_format??e?.output_config?.format}function at(e,t,n){const o=it(t);return t&&"parse"in(o??{})?st(e,t,n):{...e,content:e.content.map(e=>{if("text"===e.type){const t=Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(t,"parsed",{get:()=>(n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null),enumerable:!1})}return e}),parsed_output:null}}function st(e,t,n){let o=null;const r=e.content.map(e=>{if("text"===e.type){const r=function(e,t){const n=it(e);if("json_schema"!==n?.type)return null;try{return"parse"in n?n.parse(t):JSON.parse(t)}catch(e){throw new R(`Failed to parse structured output: ${e}`)}}(t,e.text);null===o&&(o=r);const i=Object.defineProperty({...e},"parsed_output",{value:r,enumerable:!1});return Object.defineProperty(i,"parsed",{get:()=>(n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),r),enumerable:!1})}return e});return{...e,content:r,parsed_output:o}}const ct=e=>{if(0===e.length)return e;let t=e[e.length-1];switch(t.type){case"separator":return e=e.slice(0,e.length-1),ct(e);case"number":let n=t.value[t.value.length-1];if("."===n||"-"===n)return e=e.slice(0,e.length-1),ct(e);case"string":let o=e[e.length-2];if("delimiter"===o?.type)return e=e.slice(0,e.length-1),ct(e);if("brace"===o?.type&&"{"===o.value)return e=e.slice(0,e.length-1),ct(e);break;case"delimiter":return e=e.slice(0,e.length-1),ct(e)}return e},ut=e=>JSON.parse((e=>{let t="";return e.map(e=>{"string"===e.type?t+='"'+e.value+'"':t+=e.value}),t})((e=>{let t=[];return e.map(e=>{"brace"===e.type&&("{"===e.value?t.push("}"):t.splice(t.lastIndexOf("}"),1)),"paren"===e.type&&("["===e.value?t.push("]"):t.splice(t.lastIndexOf("]"),1))}),t.length>0&&t.reverse().map(t=>{"}"===t?e.push({type:"brace",value:"}"}):"]"===t&&e.push({type:"paren",value:"]"})}),e})(ct((e=>{let t=0,n=[];for(;t<e.length;){let o=e[t];if("\\"===o){t++;continue}if("{"===o){n.push({type:"brace",value:"{"}),t++;continue}if("}"===o){n.push({type:"brace",value:"}"}),t++;continue}if("["===o){n.push({type:"paren",value:"["}),t++;continue}if("]"===o){n.push({type:"paren",value:"]"}),t++;continue}if(":"===o){n.push({type:"separator",value:":"}),t++;continue}if(","===o){n.push({type:"delimiter",value:","}),t++;continue}if('"'===o){let r="",i=!1;for(o=e[++t];'"'!==o;){if(t===e.length){i=!0;break}if("\\"===o){if(t++,t===e.length){i=!0;break}r+=o+e[t],o=e[++t]}else r+=o,o=e[++t]}o=e[++t],i||n.push({type:"string",value:r});continue}if(o&&/\s/.test(o)){t++;continue}let r=/[0-9]/;if(o&&r.test(o)||"-"===o||"."===o){let i="";for("-"===o&&(i+=o,o=e[++t]);o&&r.test(o)||"."===o;)i+=o,o=e[++t];n.push({type:"number",value:i});continue}let i=/[a-z]/i;if(o&&i.test(o)){let r="";for(;o&&i.test(o)&&t!==e.length;)r+=o,o=e[++t];if("true"!=r&&"false"!=r&&"null"!==r){t++;continue}n.push({type:"name",value:r});continue}t++}return n})(e)))));var lt,dt,pt,ht,ft,mt,gt,bt,yt,vt,_t,wt,Ot,St,xt,Tt,Pt,Ct,kt,jt,Et,Rt,At,It;const Mt="__json_buf";function Nt(e){return"tool_use"===e.type||"server_tool_use"===e.type||"mcp_tool_use"===e.type}class $t{constructor(e,t){lt.add(this),this.messages=[],this.receivedMessages=[],dt.set(this,void 0),pt.set(this,null),this.controller=new AbortController,ht.set(this,void 0),ft.set(this,()=>{}),mt.set(this,()=>{}),gt.set(this,void 0),bt.set(this,()=>{}),yt.set(this,()=>{}),vt.set(this,{}),_t.set(this,!1),wt.set(this,!1),Ot.set(this,!1),St.set(this,!1),xt.set(this,void 0),Tt.set(this,void 0),Pt.set(this,void 0),jt.set(this,e=>{if(P(this,wt,!0,"f"),j(e)&&(e=new I),e instanceof I)return P(this,Ot,!0,"f"),this._emit("abort",e);if(e instanceof R)return this._emit("error",e);if(e instanceof Error){const t=new R(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new R(String(e)))}),P(this,ht,new Promise((e,t)=>{P(this,ft,e,"f"),P(this,mt,t,"f")}),"f"),P(this,gt,new Promise((e,t)=>{P(this,bt,e,"f"),P(this,yt,t,"f")}),"f"),C(this,ht,"f").catch(()=>{}),C(this,gt,"f").catch(()=>{}),P(this,pt,e,"f"),P(this,Pt,t?.logger??console,"f")}get response(){return C(this,xt,"f")}get request_id(){return C(this,Tt,"f")}async withResponse(){P(this,St,!0,"f");const e=await C(this,ht,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const t=new $t(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,n,{logger:o}={}){const r=new $t(t,{logger:o});for(const e of t.messages)r._addMessageParam(e);return P(r,pt,{...t,stream:!0},"f"),r._run(()=>r._createMessage(e,{...t,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},C(this,jt,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,n){const o=n?.signal;let r;o&&(o.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),o.addEventListener("abort",r));try{C(this,lt,"m",Et).call(this);const{response:o,data:r}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(o);for await(const e of r)C(this,lt,"m",Rt).call(this,e);if(r.controller.signal?.aborted)throw new I;C(this,lt,"m",At).call(this)}finally{o&&r&&o.removeEventListener("abort",r)}}_connected(e){this.ended||(P(this,xt,e,"f"),P(this,Tt,e?.headers.get("request-id"),"f"),C(this,ft,"f").call(this,e),this._emit("connect"))}get ended(){return C(this,_t,"f")}get errored(){return C(this,wt,"f")}get aborted(){return C(this,Ot,"f")}abort(){this.controller.abort()}on(e,t){return(C(this,vt,"f")[e]||(C(this,vt,"f")[e]=[])).push({listener:t}),this}off(e,t){const n=C(this,vt,"f")[e];if(!n)return this;const o=n.findIndex(e=>e.listener===t);return o>=0&&n.splice(o,1),this}once(e,t){return(C(this,vt,"f")[e]||(C(this,vt,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{P(this,St,!0,"f"),"error"!==e&&this.once("error",n),this.once(e,t)})}async done(){P(this,St,!0,"f"),await C(this,gt,"f")}get currentMessage(){return C(this,dt,"f")}async finalMessage(){return await this.done(),C(this,lt,"m",Ct).call(this)}async finalText(){return await this.done(),C(this,lt,"m",kt).call(this)}_emit(e,...t){if(C(this,_t,"f"))return;"end"===e&&(P(this,_t,!0,"f"),C(this,bt,"f").call(this));const n=C(this,vt,"f")[e];if(n&&(C(this,vt,"f")[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),"abort"===e){const e=t[0];return C(this,St,"f")||n?.length||Promise.reject(e),C(this,mt,"f").call(this,e),C(this,yt,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];C(this,St,"f")||n?.length||Promise.reject(e),C(this,mt,"f").call(this,e),C(this,yt,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",C(this,lt,"m",Ct).call(this))}async _fromReadableStream(e,t){const n=t?.signal;let o;n&&(n.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),n.addEventListener("abort",o));try{C(this,lt,"m",Et).call(this),this._connected(null);const t=xe.fromReadableStream(e,this.controller);for await(const e of t)C(this,lt,"m",Rt).call(this,e);if(t.controller.signal?.aborted)throw new I;C(this,lt,"m",At).call(this)}finally{n&&o&&n.removeEventListener("abort",o)}}[(dt=new WeakMap,pt=new WeakMap,ht=new WeakMap,ft=new WeakMap,mt=new WeakMap,gt=new WeakMap,bt=new WeakMap,yt=new WeakMap,vt=new WeakMap,_t=new WeakMap,wt=new WeakMap,Ot=new WeakMap,St=new WeakMap,xt=new WeakMap,Tt=new WeakMap,Pt=new WeakMap,jt=new WeakMap,lt=new WeakSet,Ct=function(){if(0===this.receivedMessages.length)throw new R("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},kt=function(){if(0===this.receivedMessages.length)throw new R("stream ended without producing a Message with role=assistant");const e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new R("stream ended without producing a content block with type=text");return e.join(" ")},Et=function(){this.ended||P(this,dt,void 0,"f")},Rt=function(e){if(this.ended)return;const t=C(this,lt,"m",It).call(this,e);switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{const n=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===n.type&&this._emit("text",e.delta.text,n.text||"");break;case"citations_delta":"text"===n.type&&this._emit("citation",e.delta.citation,n.citations??[]);break;case"input_json_delta":Nt(n)&&n.input&&this._emit("inputJson",e.delta.partial_json,n.input);break;case"thinking_delta":"thinking"===n.type&&this._emit("thinking",e.delta.thinking,n.thinking);break;case"signature_delta":"thinking"===n.type&&this._emit("signature",n.signature);break;case"compaction_delta":"compaction"===n.type&&n.content&&this._emit("compaction",n.content);break;default:e.delta}break}case"message_stop":this._addMessageParam(t),this._addMessage(at(t,C(this,pt,"f"),{logger:C(this,Pt,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":P(this,dt,t,"f")}},At=function(){if(this.ended)throw new R("stream has ended, this shouldn't happen");const e=C(this,dt,"f");if(!e)throw new R("request ended without sending any chunks");return P(this,dt,void 0,"f"),at(e,C(this,pt,"f"),{logger:C(this,Pt,"f")})},It=function(e){let t=C(this,dt,"f");if("message_start"===e.type){if(t)throw new R(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new R(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case"message_stop":case"content_block_stop":return t;case"message_delta":return t.container=e.delta.container,t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,t.context_management=e.context_management,null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),null!=e.usage.iterations&&(t.usage.iterations=e.usage.iterations),t;case"content_block_start":return t.content.push(e.content_block),t;case"content_block_delta":{const n=t.content.at(e.index);switch(e.delta.type){case"text_delta":"text"===n?.type&&(t.content[e.index]={...n,text:(n.text||"")+e.delta.text});break;case"citations_delta":"text"===n?.type&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case"input_json_delta":if(n&&Nt(n)){let o=n[Mt]||"";o+=e.delta.partial_json;const r={...n};if(Object.defineProperty(r,Mt,{value:o,enumerable:!1,writable:!0}),o)try{r.input=ut(o)}catch(e){const t=new R(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${e}. JSON: ${o}`);C(this,jt,"f").call(this,t)}t.content[e.index]=r}break;case"thinking_delta":"thinking"===n?.type&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case"signature_delta":"thinking"===n?.type&&(t.content[e.index]={...n,signature:e.delta.signature});break;case"compaction_delta":"compaction"===n?.type&&(t.content[e.index]={...n,content:(n.content||"")+e.delta.content});break;default:e.delta}return t}}},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("streamEvent",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new xe(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}class Dt extends Error{constructor(e){super("string"==typeof e?e:e.map(e=>"text"===e.type?e.text:`[${e.type}]`).join(" ")),this.name="ToolError",this.content=e}}var Ut,Lt,qt,Ft,Wt,Jt,Bt,Gt,Vt,Ht,zt;function Kt(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}}class Xt{constructor(e,t,n){Ut.add(this),this.client=e,Lt.set(this,!1),qt.set(this,!1),Ft.set(this,void 0),Wt.set(this,void 0),Jt.set(this,void 0),Bt.set(this,void 0),Gt.set(this,void 0),Vt.set(this,0),P(this,Ft,{params:{...t,messages:structuredClone(t.messages)}},"f");const o=["BetaToolRunner",...Xe(t.tools,t.messages)].join(", ");P(this,Wt,{...n,headers:He([{"x-stainless-helper":o},n?.headers])},"f"),P(this,Gt,Kt(),"f")}async*[(Lt=new WeakMap,qt=new WeakMap,Ft=new WeakMap,Wt=new WeakMap,Jt=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,Ut=new WeakSet,Ht=async function(){const e=C(this,Ft,"f").params.compactionControl;if(!e||!e.enabled)return!1;let t=0;if(void 0!==C(this,Jt,"f"))try{const e=await C(this,Jt,"f");t=e.usage.input_tokens+(e.usage.cache_creation_input_tokens??0)+(e.usage.cache_read_input_tokens??0)+e.usage.output_tokens}catch{return!1}if(t<(e.contextTokenThreshold??1e5))return!1;const n=e.model??C(this,Ft,"f").params.model,o=e.summaryPrompt??"You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.",r=C(this,Ft,"f").params.messages;if("assistant"===r[r.length-1].role){const e=r[r.length-1];if(Array.isArray(e.content)){const t=e.content.filter(e=>"tool_use"!==e.type);0===t.length?r.pop():e.content=t}}const i=await this.client.beta.messages.create({model:n,messages:[...r,{role:"user",content:[{type:"text",text:o}]}],max_tokens:C(this,Ft,"f").params.max_tokens},{headers:{"x-stainless-helper":"compaction"}});if("text"!==i.content[0]?.type)throw new R("Expected text response for compaction");return C(this,Ft,"f").params.messages=[{role:"user",content:i.content}],!0},Symbol.asyncIterator)](){var e;if(C(this,Lt,"f"))throw new R("Cannot iterate over a consumed stream");P(this,Lt,!0,"f"),P(this,qt,!0,"f"),P(this,Bt,void 0,"f");try{for(;;){let t;try{if(C(this,Ft,"f").params.max_iterations&&C(this,Vt,"f")>=C(this,Ft,"f").params.max_iterations)break;P(this,qt,!1,"f"),P(this,Bt,void 0,"f"),P(this,Vt,(e=C(this,Vt,"f"),++e),"f"),P(this,Jt,void 0,"f");const{max_iterations:n,compactionControl:o,...r}=C(this,Ft,"f").params;r.stream?(t=this.client.beta.messages.stream({...r},C(this,Wt,"f")),P(this,Jt,t.finalMessage(),"f"),C(this,Jt,"f").catch(()=>{}),yield t):(P(this,Jt,this.client.beta.messages.create({...r,stream:!1},C(this,Wt,"f")),"f"),yield C(this,Jt,"f"));if(!await C(this,Ut,"m",Ht).call(this)){if(!C(this,qt,"f")){const{role:e,content:t}=await C(this,Jt,"f");C(this,Ft,"f").params.messages.push({role:e,content:t})}const e=await C(this,Ut,"m",zt).call(this,C(this,Ft,"f").params.messages.at(-1));if(e)C(this,Ft,"f").params.messages.push(e);else if(!C(this,qt,"f"))break}}finally{t&&t.abort()}}if(!C(this,Jt,"f"))throw new R("ToolRunner concluded without a message from the server");C(this,Gt,"f").resolve(await C(this,Jt,"f"))}catch(e){throw P(this,Lt,!1,"f"),C(this,Gt,"f").promise.catch(()=>{}),C(this,Gt,"f").reject(e),P(this,Gt,Kt(),"f"),e}}setMessagesParams(e){C(this,Ft,"f").params="function"==typeof e?e(C(this,Ft,"f").params):e,P(this,qt,!0,"f"),P(this,Bt,void 0,"f")}async generateToolResponse(){const e=await C(this,Jt,"f")??this.params.messages.at(-1);return e?C(this,Ut,"m",zt).call(this,e):null}done(){return C(this,Gt,"f").promise}async runUntilDone(){if(!C(this,Lt,"f"))for await(const e of this);return this.done()}get params(){return C(this,Ft,"f").params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}}zt=async function(e){return void 0!==C(this,Bt,"f")||P(this,Bt,async function(e,t=e.messages.at(-1)){if(!t||"assistant"!==t.role||!t.content||"string"==typeof t.content)return null;const n=t.content.filter(e=>"tool_use"===e.type);if(0===n.length)return null;return{role:"user",content:await Promise.all(n.map(async t=>{const n=e.tools.find(e=>("name"in e?e.name:e.mcp_server_name)===t.name);if(!n||!("run"in n))return{type:"tool_result",tool_use_id:t.id,content:`Error: Tool '${t.name}' not found`,is_error:!0};try{let e=t.input;"parse"in n&&n.parse&&(e=n.parse(e));const o=await n.run(e);return{type:"tool_result",tool_use_id:t.id,content:o}}catch(e){return{type:"tool_result",tool_use_id:t.id,content:e instanceof Dt?e.content:`Error: ${e instanceof Error?e.message:String(e)}`,is_error:!0}}}))}}(C(this,Ft,"f").params,e),"f"),C(this,Bt,"f")};class Zt{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){const e=new le;for await(const t of this.iterator)for(const n of e.decode(t))yield JSON.parse(n);for(const t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new R("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new R("Attempted to iterate over a response with no body")}return new Zt(ne(e.body),t)}}class Yt extends Be{create(e,t){const{betas:n,...o}=e;return this._client.post("/v1/messages/batches?beta=true",{body:o,...t,headers:He([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},t?.headers])})}retrieve(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/messages/batches/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString()},n?.headers])})}list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",Re,{query:o,...t,headers:He([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},t?.headers])})}delete(e,t={},n){const{betas:o}=t??{};return this._client.delete(tt`/v1/messages/batches/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString()},n?.headers])})}cancel(e,t={},n){const{betas:o}=t??{};return this._client.post(tt`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString()},n?.headers])})}async results(e,t={},n){const o=await this.retrieve(e);if(!o.results_url)throw new R(`No batch \`results_url\`; Has it finished processing? ${o.processing_status} - ${o.id}`);const{betas:r}=t??{};return this._client.get(o.results_url,{...n,headers:He([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Zt.fromResponse(t.response,t.controller))}}const Qt={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"},en=["claude-opus-4-6"];class tn extends Be{constructor(){super(...arguments),this.batches=new Yt(this._client)}create(e,t){const n=nn(e),{betas:o,...r}=n;r.model in Qt&&console.warn(`The model '${r.model}' is deprecated and will reach end-of-life on ${Qt[r.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),r.model in en&&r.thinking&&"enabled"===r.thinking.type&&console.warn(`Using Claude with ${r.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let i=this._client._options.timeout;if(!r.stream&&null==i){const e=rt[r.model]??void 0;i=this._client.calculateNonstreamingTimeout(r.max_tokens,e)}const a=Ze(r.tools,r.messages);return this._client.post("/v1/messages?beta=true",{body:r,timeout:i??6e5,...t,headers:He([{...null!=o?.toString()?{"anthropic-beta":o?.toString()}:void 0},a,t?.headers]),stream:n.stream??!1})}parse(e,t){return t={...t,headers:He([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(t=>st(t,e,{logger:this._client.logger??console}))}stream(e,t){return $t.createMessage(this,e,t)}countTokens(e,t){const n=nn(e),{betas:o,...r}=n;return this._client.post("/v1/messages/count_tokens?beta=true",{body:r,...t,headers:He([{"anthropic-beta":[...o??[],"token-counting-2024-11-01"].toString()},t?.headers])})}toolRunner(e,t){return new Xt(this._client,e,t)}}function nn(e){if(!e.output_format)return e;if(e.output_config?.format)throw new R("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");const{output_format:t,...n}=e;return{...n,output_config:{...e.output_config,format:t}}}tn.Batches=Yt,tn.BetaToolRunner=Xt,tn.ToolError=Dt;class on extends Be{create(e,t={},n){const{betas:o,...r}=t??{};return this._client.post(tt`/v1/skills/${e}/versions?beta=true`,De({body:r,...n,headers:He([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},n?.headers])},this._client))}retrieve(e,t,n){const{skill_id:o,betas:r}=t;return this._client.get(tt`/v1/skills/${o}/versions/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},n?.headers])})}list(e,t={},n){const{betas:o,...r}=t??{};return this._client.getAPIList(tt`/v1/skills/${e}/versions?beta=true`,Ae,{query:r,...n,headers:He([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},n?.headers])})}delete(e,t,n){const{skill_id:o,betas:r}=t;return this._client.delete(tt`/v1/skills/${o}/versions/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},n?.headers])})}}class rn extends Be{constructor(){super(...arguments),this.versions=new on(this._client)}create(e={},t){const{betas:n,...o}=e??{};return this._client.post("/v1/skills?beta=true",De({body:o,...t,headers:He([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},t?.headers])},this._client,!1))}retrieve(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/skills/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},n?.headers])})}list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/skills?beta=true",Ae,{query:o,...t,headers:He([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},t?.headers])})}delete(e,t={},n){const{betas:o}=t??{};return this._client.delete(tt`/v1/skills/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},n?.headers])})}}rn.Versions=on;class an extends Be{constructor(){super(...arguments),this.models=new ot(this._client),this.messages=new tn(this._client),this.files=new nt(this._client),this.skills=new rn(this._client)}}an.Models=ot,an.Messages=tn,an.Files=nt,an.Skills=rn;class sn extends Be{create(e,t){const{betas:n,...o}=e;return this._client.post("/v1/complete",{body:o,timeout:this._client._options.timeout??6e5,...t,headers:He([{...null!=n?.toString()?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),stream:e.stream??!1})}}function cn(e){return e?.output_config?.format}function un(e,t,n){const o=cn(t);return t&&"parse"in(o??{})?ln(e,t,n):{...e,content:e.content.map(e=>{if("text"===e.type){return Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1})}return e}),parsed_output:null}}function ln(e,t,n){let o=null;const r=e.content.map(e=>{if("text"===e.type){const n=function(e,t){const n=cn(e);if("json_schema"!==n?.type)return null;try{return"parse"in n?n.parse(t):JSON.parse(t)}catch(e){throw new R(`Failed to parse structured output: ${e}`)}}(t,e.text);null===o&&(o=n);return Object.defineProperty({...e},"parsed_output",{value:n,enumerable:!1})}return e});return{...e,content:r,parsed_output:o}}var dn,pn,hn,fn,mn,gn,bn,yn,vn,_n,wn,On,Sn,xn,Tn,Pn,Cn,kn,jn,En,Rn,An,In,Mn;const Nn="__json_buf";function $n(e){return"tool_use"===e.type||"server_tool_use"===e.type}class Dn{constructor(e,t){dn.add(this),this.messages=[],this.receivedMessages=[],pn.set(this,void 0),hn.set(this,null),this.controller=new AbortController,fn.set(this,void 0),mn.set(this,()=>{}),gn.set(this,()=>{}),bn.set(this,void 0),yn.set(this,()=>{}),vn.set(this,()=>{}),_n.set(this,{}),wn.set(this,!1),On.set(this,!1),Sn.set(this,!1),xn.set(this,!1),Tn.set(this,void 0),Pn.set(this,void 0),Cn.set(this,void 0),En.set(this,e=>{if(P(this,On,!0,"f"),j(e)&&(e=new I),e instanceof I)return P(this,Sn,!0,"f"),this._emit("abort",e);if(e instanceof R)return this._emit("error",e);if(e instanceof Error){const t=new R(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new R(String(e)))}),P(this,fn,new Promise((e,t)=>{P(this,mn,e,"f"),P(this,gn,t,"f")}),"f"),P(this,bn,new Promise((e,t)=>{P(this,yn,e,"f"),P(this,vn,t,"f")}),"f"),C(this,fn,"f").catch(()=>{}),C(this,bn,"f").catch(()=>{}),P(this,hn,e,"f"),P(this,Cn,t?.logger??console,"f")}get response(){return C(this,Tn,"f")}get request_id(){return C(this,Pn,"f")}async withResponse(){P(this,xn,!0,"f");const e=await C(this,fn,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const t=new Dn(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,n,{logger:o}={}){const r=new Dn(t,{logger:o});for(const e of t.messages)r._addMessageParam(e);return P(r,hn,{...t,stream:!0},"f"),r._run(()=>r._createMessage(e,{...t,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},C(this,En,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,n){const o=n?.signal;let r;o&&(o.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),o.addEventListener("abort",r));try{C(this,dn,"m",Rn).call(this);const{response:o,data:r}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(o);for await(const e of r)C(this,dn,"m",An).call(this,e);if(r.controller.signal?.aborted)throw new I;C(this,dn,"m",In).call(this)}finally{o&&r&&o.removeEventListener("abort",r)}}_connected(e){this.ended||(P(this,Tn,e,"f"),P(this,Pn,e?.headers.get("request-id"),"f"),C(this,mn,"f").call(this,e),this._emit("connect"))}get ended(){return C(this,wn,"f")}get errored(){return C(this,On,"f")}get aborted(){return C(this,Sn,"f")}abort(){this.controller.abort()}on(e,t){return(C(this,_n,"f")[e]||(C(this,_n,"f")[e]=[])).push({listener:t}),this}off(e,t){const n=C(this,_n,"f")[e];if(!n)return this;const o=n.findIndex(e=>e.listener===t);return o>=0&&n.splice(o,1),this}once(e,t){return(C(this,_n,"f")[e]||(C(this,_n,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{P(this,xn,!0,"f"),"error"!==e&&this.once("error",n),this.once(e,t)})}async done(){P(this,xn,!0,"f"),await C(this,bn,"f")}get currentMessage(){return C(this,pn,"f")}async finalMessage(){return await this.done(),C(this,dn,"m",kn).call(this)}async finalText(){return await this.done(),C(this,dn,"m",jn).call(this)}_emit(e,...t){if(C(this,wn,"f"))return;"end"===e&&(P(this,wn,!0,"f"),C(this,yn,"f").call(this));const n=C(this,_n,"f")[e];if(n&&(C(this,_n,"f")[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),"abort"===e){const e=t[0];return C(this,xn,"f")||n?.length||Promise.reject(e),C(this,gn,"f").call(this,e),C(this,vn,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];C(this,xn,"f")||n?.length||Promise.reject(e),C(this,gn,"f").call(this,e),C(this,vn,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",C(this,dn,"m",kn).call(this))}async _fromReadableStream(e,t){const n=t?.signal;let o;n&&(n.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),n.addEventListener("abort",o));try{C(this,dn,"m",Rn).call(this),this._connected(null);const t=xe.fromReadableStream(e,this.controller);for await(const e of t)C(this,dn,"m",An).call(this,e);if(t.controller.signal?.aborted)throw new I;C(this,dn,"m",In).call(this)}finally{n&&o&&n.removeEventListener("abort",o)}}[(pn=new WeakMap,hn=new WeakMap,fn=new WeakMap,mn=new WeakMap,gn=new WeakMap,bn=new WeakMap,yn=new WeakMap,vn=new WeakMap,_n=new WeakMap,wn=new WeakMap,On=new WeakMap,Sn=new WeakMap,xn=new WeakMap,Tn=new WeakMap,Pn=new WeakMap,Cn=new WeakMap,En=new WeakMap,dn=new WeakSet,kn=function(){if(0===this.receivedMessages.length)throw new R("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},jn=function(){if(0===this.receivedMessages.length)throw new R("stream ended without producing a Message with role=assistant");const e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new R("stream ended without producing a content block with type=text");return e.join(" ")},Rn=function(){this.ended||P(this,pn,void 0,"f")},An=function(e){if(this.ended)return;const t=C(this,dn,"m",Mn).call(this,e);switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{const n=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===n.type&&this._emit("text",e.delta.text,n.text||"");break;case"citations_delta":"text"===n.type&&this._emit("citation",e.delta.citation,n.citations??[]);break;case"input_json_delta":$n(n)&&n.input&&this._emit("inputJson",e.delta.partial_json,n.input);break;case"thinking_delta":"thinking"===n.type&&this._emit("thinking",e.delta.thinking,n.thinking);break;case"signature_delta":"thinking"===n.type&&this._emit("signature",n.signature);break;default:e.delta}break}case"message_stop":this._addMessageParam(t),this._addMessage(un(t,C(this,hn,"f"),{logger:C(this,Cn,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":P(this,pn,t,"f")}},In=function(){if(this.ended)throw new R("stream has ended, this shouldn't happen");const e=C(this,pn,"f");if(!e)throw new R("request ended without sending any chunks");return P(this,pn,void 0,"f"),un(e,C(this,hn,"f"),{logger:C(this,Cn,"f")})},Mn=function(e){let t=C(this,pn,"f");if("message_start"===e.type){if(t)throw new R(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new R(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case"message_stop":case"content_block_stop":return t;case"message_delta":return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),t;case"content_block_start":return t.content.push({...e.content_block}),t;case"content_block_delta":{const n=t.content.at(e.index);switch(e.delta.type){case"text_delta":"text"===n?.type&&(t.content[e.index]={...n,text:(n.text||"")+e.delta.text});break;case"citations_delta":"text"===n?.type&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case"input_json_delta":if(n&&$n(n)){let o=n[Nn]||"";o+=e.delta.partial_json;const r={...n};Object.defineProperty(r,Nn,{value:o,enumerable:!1,writable:!0}),o&&(r.input=ut(o)),t.content[e.index]=r}break;case"thinking_delta":"thinking"===n?.type&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case"signature_delta":"thinking"===n?.type&&(t.content[e.index]={...n,signature:e.delta.signature});break;default:e.delta}return t}}},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("streamEvent",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new xe(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}class Un extends Be{create(e,t){return this._client.post("/v1/messages/batches",{body:e,...t})}retrieve(e,t){return this._client.get(tt`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/v1/messages/batches",Re,{query:e,...t})}delete(e,t){return this._client.delete(tt`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(tt`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){const n=await this.retrieve(e);if(!n.results_url)throw new R(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);return this._client.get(n.results_url,{...t,headers:He([{Accept:"application/binary"},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Zt.fromResponse(t.response,t.controller))}}class Ln extends Be{constructor(){super(...arguments),this.batches=new Un(this._client)}create(e,t){e.model in qn&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${qn[e.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in Fn&&e.thinking&&"enabled"===e.thinking.type&&console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let n=this._client._options.timeout;if(!e.stream&&null==n){const t=rt[e.model]??void 0;n=this._client.calculateNonstreamingTimeout(e.max_tokens,t)}const o=Ze(e.tools,e.messages);return this._client.post("/v1/messages",{body:e,timeout:n??6e5,...t,headers:He([o,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>ln(t,e,this._client.logger??console))}stream(e,t){return Dn.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post("/v1/messages/count_tokens",{body:e,...t})}}const qn={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026"},Fn=["claude-opus-4-6"];Ln.Batches=Un;class Wn extends Be{retrieve(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/models/${e}`,{...n,headers:He([{...null!=o?.toString()?{"anthropic-beta":o?.toString()}:void 0},n?.headers])})}list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/models",Re,{query:o,...t,headers:He([{...null!=n?.toString()?{"anthropic-beta":n?.toString()}:void 0},t?.headers])})}}const Jn=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;var Bn,Gn,Vn,Hn;class zn{constructor({baseURL:e=Jn("ANTHROPIC_BASE_URL"),apiKey:t=Jn("ANTHROPIC_API_KEY")??null,authToken:n=Jn("ANTHROPIC_AUTH_TOKEN")??null,...o}={}){Bn.add(this),Vn.set(this,void 0);const r={apiKey:t,authToken:n,...o,baseURL:e||"https://api.anthropic.com"};if(!r.dangerouslyAllowBrowser&&"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator)throw new R("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");this.baseURL=r.baseURL,this.timeout=r.timeout??Gn.DEFAULT_TIMEOUT,this.logger=r.logger??console;const i="warn";this.logLevel=i,this.logLevel=fe(r.logLevel,"ClientOptions.logLevel",this)??fe(Jn("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??i,this.fetchOptions=r.fetchOptions,this.maxRetries=r.maxRetries??2,this.fetch=r.fetch??function(){if("undefined"!=typeof fetch)return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),P(this,Vn,oe,"f"),this._options=r,this.apiKey="string"==typeof t?t:null,this.authToken=n}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!e.get("x-api-key")&&!e.get("authorization")&&!(this.apiKey&&e.get("x-api-key")||t.has("x-api-key")||this.authToken&&e.get("authorization")||t.has("authorization")))throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return He([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(null!=this.apiKey)return He([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(null!=this.authToken)return He([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>void 0!==t).map(([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new R(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${K}`}defaultIdempotencyKey(){return`stainless-node-retry-${k()}`}makeStatusError(e,t,n,o){return A.generate(e,t,n,o)}buildURL(e,t,n){const o=!C(this,Bn,"m",Hn).call(this)&&n||this.baseURL,r=(e=>B.test(e))(e)?new URL(e):new URL(o+(o.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return function(e){if(!e)return!0;for(const t in e)return!1;return!0}(i)||(t={...i,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(r.search=this.stringifyQuery(t)),r.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new R("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 6e5}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new ke(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){const o=await e,r=o.maxRetries??this.maxRetries;null==t&&(t=r),await this.prepareOptions(o);const{req:i,url:a,timeout:s}=await this.buildRequest(o,{retryCount:r-t});await this.prepareRequest(i,{url:a,options:o});const c="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=void 0===n?"":`, retryOf: ${n}`,l=Date.now();if(ve(this).debug(`[${c}] sending request`,_e({retryOfRequestLogID:n,method:o.method,url:a,options:o,headers:i.headers})),o.signal?.aborted)throw new I;const d=new AbortController,p=await this.fetchWithTimeout(a,i,s,d).catch(E),h=Date.now();if(p instanceof globalThis.Error){const e=`retrying, ${t} attempts remaining`;if(o.signal?.aborted)throw new I;const r=j(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(t)return ve(this).info(`[${c}] connection ${r?"timed out":"failed"} - ${e}`),ve(this).debug(`[${c}] connection ${r?"timed out":"failed"} (${e})`,_e({retryOfRequestLogID:n,url:a,durationMs:h-l,message:p.message})),this.retryRequest(o,t,n??c);if(ve(this).info(`[${c}] connection ${r?"timed out":"failed"} - error; no more retries left`),ve(this).debug(`[${c}] connection ${r?"timed out":"failed"} (error; no more retries left)`,_e({retryOfRequestLogID:n,url:a,durationMs:h-l,message:p.message})),r)throw new N;throw new M({cause:p})}const f=`[${c}${u}${[...p.headers.entries()].filter(([e])=>"request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join("")}] ${i.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-l}ms`;if(!p.ok){const e=await this.shouldRetry(p);if(t&&e){const e=`retrying, ${t} attempts remaining`;return await async function(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await(e[Symbol.asyncIterator]().return?.());const t=e.getReader(),n=t.cancel();t.releaseLock(),await n}(p.body),ve(this).info(`${f} - ${e}`),ve(this).debug(`[${c}] response error (${e})`,_e({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-l})),this.retryRequest(o,t,n??c,p.headers)}const r=e?"error; no more retries left":"error; not retryable";ve(this).info(`${f} - ${r}`);const i=await p.text().catch(e=>E(e).message),a=z(i),s=a?void 0:i;ve(this).debug(`[${c}] response error (${r})`,_e({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:s,durationMs:Date.now()-l}));throw this.makeStatusError(p.status,a,s,p.headers)}return ve(this).info(f),ve(this).debug(`[${c}] response start`,_e({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-l})),{response:p,options:o,controller:d,requestLogID:c,retryOfRequestLogID:n,startTime:l}}getAPIList(e,t,n){return this.requestAPIList(t,n&&"then"in n?n.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...n})}requestAPIList(e,t){const n=this.makeRequest(t,null,void 0);return new Ee(this,n,e)}async fetchWithTimeout(e,t,n,o){const{signal:r,method:i,...a}=t||{},s=this._makeAbort(o);r&&r.addEventListener("abort",s,{once:!0});const c=setTimeout(s,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||"object"==typeof a.body&&null!==a.body&&Symbol.asyncIterator in a.body,l={signal:o.signal,...u?{duplex:"half"}:{},method:"GET",...a};i&&(l.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,l)}finally{clearTimeout(c)}}async shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||(409===e.status||(429===e.status||e.status>=500)))}async retryRequest(e,t,n,o){let r;const i=o?.get("retry-after-ms");if(i){const e=parseFloat(i);Number.isNaN(e)||(r=e)}const a=o?.get("retry-after");if(a&&!r){const e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}if(!(r&&0<=r&&r<6e4)){const n=e.maxRetries??this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,n)}var s;return await(s=r,new Promise(e=>setTimeout(e,s))),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){const n=t-e;return Math.min(.5*Math.pow(2,n),8)*(1-.25*Math.random())*1e3}calculateNonstreamingTimeout(e,t){const n=6e5;if(36e5*e/128e3>n||null!=t&&e>t)throw new R("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return n}async buildRequest(e,{retryCount:t=0}={}){const n={...e},{method:o,path:r,query:i,defaultBaseURL:a}=n,s=this.buildURL(r,i,a);"timeout"in n&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new R(`${e} must be an integer`);if(t<0)throw new R(`${e} must be a positive integer`)})("timeout",n.timeout),n.timeout=n.timeout??this.timeout;const{bodyHeaders:c,body:u}=this.buildBody({options:n});return{req:{method:o,headers:await this.buildHeaders({options:e,method:o,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:o}){let r={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);const i=He([r,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(o),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Q??(Q=X()),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(i),i.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};const n=He([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:te(e)}:C(this,Vn,"f").call(this,{body:e,headers:n})}}Gn=zn,Vn=new WeakMap,Bn=new WeakSet,Hn=function(){return"https://api.anthropic.com"!==this.baseURL},zn.Anthropic=Gn,zn.HUMAN_PROMPT="\\n\\nHuman:",zn.AI_PROMPT="\\n\\nAssistant:",zn.DEFAULT_TIMEOUT=6e5,zn.AnthropicError=R,zn.APIError=A,zn.APIConnectionError=M,zn.APIConnectionTimeoutError=N,zn.APIUserAbortError=I,zn.NotFoundError=L,zn.ConflictError=q,zn.RateLimitError=W,zn.BadRequestError=$,zn.AuthenticationError=D,zn.InternalServerError=J,zn.PermissionDeniedError=U,zn.UnprocessableEntityError=F,zn.toFile=async function(e,t,n){if(Ie(),e=await e,t||(t=Ne(e,!0)),(e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&We(e))(e))return e instanceof File&&null==t&&null==n?e:Me([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...n});if((e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob)(e)){const o=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Me(await Je(o),t,n)}const o=await Je(e);if(!n?.type){const e=o.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(n={...n,type:e})}return Me(o,t,n)};class Kn extends zn{constructor(){super(...arguments),this.completions=new sn(this),this.messages=new Ln(this),this.models=new Wn(this),this.beta=new an(this)}}Kn.Completions=sn,Kn.Messages=Ln,Kn.Models=Wn,Kn.Beta=an;class Xn{isComplete;extractResult;queue=[];waiting=[];done=!1;finalResultPromise;resolveFinalResult;constructor(e,t){this.isComplete=e,this.extractResult=t,this.finalResultPromise=new Promise(e=>{this.resolveFinalResult=e})}push(e){if(this.done)return;this.isComplete(e)&&(this.done=!0,this.resolveFinalResult(this.extractResult(e)));const t=this.waiting.shift();t?t({value:e,done:!1}):this.queue.push(e)}end(e){for(this.done=!0,void 0!==e&&this.resolveFinalResult(e);this.waiting.length>0;){this.waiting.shift()({value:void 0,done:!0})}}async*[Symbol.asyncIterator](){for(;;)if(this.queue.length>0)yield this.queue.shift();else{if(this.done)return;{const e=await new Promise(e=>this.waiting.push(e));if(e.done)return;yield e.value}}}result(){return this.finalResultPromise}}class Zn extends Xn{constructor(){super(e=>"done"===e.type||"error"===e.type,e=>{if("done"===e.type)return e.message;if("error"===e.type)return e.error;throw new Error("Unexpected event type for final result")})}}function Yn(){return new Zn}var Qn=n(77227);function eo(e){if(!e||""===e.trim())return{};try{return JSON.parse(e)}catch{try{return(0,Qn.parse)(e)??{}}catch{return{}}}}function to(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}function no(e){const t=e[e.length-1];return t&&"user"!==t.role?"agent":"user"}function oo(e){return e.some(e=>("user"===e.role&&Array.isArray(e.content)||!("toolResult"!==e.role||!Array.isArray(e.content)))&&e.content.some(e=>"image"===e.type))}function ro(e){const t={"X-Initiator":no(e.messages),"Openai-Intent":"conversation-edits"};return e.hasImages&&(t["Copilot-Vision-Request"]="true"),t}function io(e,t,n){return{temperature:t?.temperature,maxTokens:t?.maxTokens||Math.min(e.maxTokens,32e3),signal:t?.signal,apiKey:n||t?.apiKey,cacheRetention:t?.cacheRetention,sessionId:t?.sessionId,headers:t?.headers,onPayload:t?.onPayload,maxRetryDelayMs:t?.maxRetryDelayMs,metadata:t?.metadata}}function ao(e){return"xhigh"===e?"high":e}function so(e,t,n){const o=new Map,r=e.map(e=>{if("user"===e.role)return e;if("toolResult"===e.role){const t=o.get(e.toolCallId);return t&&t!==e.toolCallId?{...e,toolCallId:t}:e}if("assistant"===e.role){const r=e,i=r.provider===t.provider&&r.api===t.api&&r.model===t.id,a=r.content.flatMap(e=>{if("thinking"===e.type)return e.redacted?i?e:[]:i&&e.thinkingSignature?e:e.thinking&&""!==e.thinking.trim()?i?e:{type:"text",text:e.thinking}:[];if("text"===e.type)return i?e:{type:"text",text:e.text};if("toolCall"===e.type){const a=e;let s=a;if(!i&&a.thoughtSignature&&(s={...a},delete s.thoughtSignature),!i&&n){const e=n(a.id,t,r);e!==a.id&&(o.set(a.id,e),s={...s,id:e})}return s}return e});return{...r,content:a}}return e}),i=[];let a=[],s=new Set;for(let e=0;e<r.length;e++){const t=r[e];if("assistant"===t.role){if(a.length>0){for(const e of a)s.has(e.id)||i.push({role:"toolResult",toolCallId:e.id,toolName:e.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});a=[],s=new Set}const e=t;if("error"===e.stopReason||"aborted"===e.stopReason)continue;const n=e.content.filter(e=>"toolCall"===e.type);n.length>0&&(a=n,s=new Set),i.push(t)}else if("toolResult"===t.role)s.add(t.toolCallId),i.push(t);else if("user"===t.role){if(a.length>0){for(const e of a)s.has(e.id)||i.push({role:"toolResult",toolCallId:e.id,toolName:e.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});a=[],s=new Set}i.push(t)}else i.push(t)}return i}function co(e,t){const n=function(e){return e||("undefined"!=typeof process&&"long"===process.env.PI_CACHE_RETENTION?"long":"short")}(t);if("none"===n)return{retention:n};const o="long"===n&&e.includes("api.anthropic.com")?"1h":void 0;return{retention:n,cacheControl:{type:"ephemeral",...o&&{ttl:o}}}}const uo=new Map(["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"].map(e=>[e.toLowerCase(),e])),lo=e=>uo.get(e.toLowerCase())??e,po=(e,t)=>{if(t&&t.length>0){const n=e.toLowerCase(),o=t.find(e=>e.name.toLowerCase()===n);if(o)return o.name}return e};function ho(e){if(!e.some(e=>"image"===e.type))return to(e.map(e=>e.text).join("\n"));const t=e.map(e=>"text"===e.type?{type:"text",text:to(e.text)}:{type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}});return t.some(e=>"text"===e.type)||t.unshift({type:"text",text:"(see attached image)"}),t}function fo(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}const mo=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey??b(e.provider)??"";let a;if("github-copilot"===e.provider){const e=oo(t.messages);a=ro({messages:t.messages,hasImages:e})}const{client:s,isOAuthToken:c}=yo(e,i,n?.interleavedThinking??!0,n?.headers,a);let u=function(e,t,n,o){const{cacheControl:r}=co(e.baseUrl,o?.cacheRetention),i={model:e.id,messages:_o(t.messages,e,n,r),max_tokens:o?.maxTokens||e.maxTokens/3|0,stream:!0};n?(i.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...r?{cache_control:r}:{}}],t.systemPrompt&&i.system.push({type:"text",text:to(t.systemPrompt),...r?{cache_control:r}:{}})):t.systemPrompt&&(i.system=[{type:"text",text:to(t.systemPrompt),...r?{cache_control:r}:{}}]);void 0===o?.temperature||o?.thinkingEnabled||(i.temperature=o.temperature);t.tools&&(i.tools=function(e,t){return e?e.map(e=>{const n=e.parameters;return{name:t?lo(e.name):e.name,description:e.description,input_schema:{type:"object",properties:n.properties||{},required:n.required||[]}}}):[]}(t.tools,n));o?.thinkingEnabled&&e.reasoning&&(go(e.id)?(i.thinking={type:"adaptive"},o.effort&&(i.output_config={effort:o.effort})):i.thinking={type:"enabled",budget_tokens:o.thinkingBudgetTokens||1024});if(o?.metadata){const e=o.metadata.user_id;"string"==typeof e&&(i.metadata={user_id:e})}o?.toolChoice&&("string"==typeof o.toolChoice?i.tool_choice={type:o.toolChoice}:i.tool_choice=o.toolChoice);return i}(e,t,c,n);const l=await(n?.onPayload?.(u,e));void 0!==l&&(u=l);const d=s.messages.stream({...u,stream:!0},{signal:n?.signal});o.push({type:"start",partial:r});const p=r.content;for await(const n of d)if("message_start"===n.type)r.usage.input=n.message.usage.input_tokens||0,r.usage.output=n.message.usage.output_tokens||0,r.usage.cacheRead=n.message.usage.cache_read_input_tokens||0,r.usage.cacheWrite=n.message.usage.cache_creation_input_tokens||0,r.usage.totalTokens=r.usage.input+r.usage.output+r.usage.cacheRead+r.usage.cacheWrite,S(e,r.usage);else if("content_block_start"===n.type){if("text"===n.content_block.type){const e={type:"text",text:"",index:n.index};r.content.push(e),o.push({type:"text_start",contentIndex:r.content.length-1,partial:r})}else if("thinking"===n.content_block.type){const e={type:"thinking",thinking:"",thinkingSignature:"",index:n.index};r.content.push(e),o.push({type:"thinking_start",contentIndex:r.content.length-1,partial:r})}else if("redacted_thinking"===n.content_block.type){const e={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:n.content_block.data,redacted:!0,index:n.index};r.content.push(e),o.push({type:"thinking_start",contentIndex:r.content.length-1,partial:r})}else if("tool_use"===n.content_block.type){const e={type:"toolCall",id:n.content_block.id,name:c?po(n.content_block.name,t.tools):n.content_block.name,arguments:n.content_block.input??{},partialJson:"",index:n.index};r.content.push(e),o.push({type:"toolcall_start",contentIndex:r.content.length-1,partial:r})}}else if("content_block_delta"===n.type){if("text_delta"===n.delta.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&"text"===t.type&&(t.text+=n.delta.text,o.push({type:"text_delta",contentIndex:e,delta:n.delta.text,partial:r}))}else if("thinking_delta"===n.delta.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&"thinking"===t.type&&(t.thinking+=n.delta.thinking,o.push({type:"thinking_delta",contentIndex:e,delta:n.delta.thinking,partial:r}))}else if("input_json_delta"===n.delta.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&"toolCall"===t.type&&(t.partialJson+=n.delta.partial_json,t.arguments=eo(t.partialJson),o.push({type:"toolcall_delta",contentIndex:e,delta:n.delta.partial_json,partial:r}))}else if("signature_delta"===n.delta.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&"thinking"===t.type&&(t.thinkingSignature=t.thinkingSignature||"",t.thinkingSignature+=n.delta.signature)}}else if("content_block_stop"===n.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&(delete t.index,"text"===t.type?o.push({type:"text_end",contentIndex:e,content:t.text,partial:r}):"thinking"===t.type?o.push({type:"thinking_end",contentIndex:e,content:t.thinking,partial:r}):"toolCall"===t.type&&(t.arguments=eo(t.partialJson),delete t.partialJson,o.push({type:"toolcall_end",contentIndex:e,toolCall:t,partial:r})))}else"message_delta"===n.type&&(n.delta.stop_reason&&(r.stopReason=wo(n.delta.stop_reason)),null!=n.usage.input_tokens&&(r.usage.input=n.usage.input_tokens),null!=n.usage.output_tokens&&(r.usage.output=n.usage.output_tokens),null!=n.usage.cache_read_input_tokens&&(r.usage.cacheRead=n.usage.cache_read_input_tokens),null!=n.usage.cache_creation_input_tokens&&(r.usage.cacheWrite=n.usage.cache_creation_input_tokens),r.usage.totalTokens=r.usage.input+r.usage.output+r.usage.cacheRead+r.usage.cacheWrite,S(e,r.usage));if(n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o};function go(e){return e.includes("opus-4-6")||e.includes("opus-4.6")||e.includes("sonnet-4-6")||e.includes("sonnet-4.6")}const bo=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o);if(!n?.reasoning)return mo(e,t,{...r,thinkingEnabled:!1});if(go(e.id)){const o=function(e,t){switch(e){case"minimal":case"low":return"low";case"medium":return"medium";case"high":default:return"high";case"xhigh":return t.includes("opus-4-6")||t.includes("opus-4.6")?"max":"high"}}(n.reasoning,e.id);return mo(e,t,{...r,thinkingEnabled:!0,effort:o})}const i=function(e,t,n,o){let r={minimal:1024,low:2048,medium:8192,high:16384,...o}[ao(n)];const i=Math.min(e+r,t);return i<=r&&(r=Math.max(0,i-1024)),{maxTokens:i,thinkingBudget:r}}(r.maxTokens||0,e.maxTokens,n.reasoning,n.thinkingBudgets);return mo(e,t,{...r,maxTokens:i.maxTokens,thinkingEnabled:!0,thinkingBudgetTokens:i.thinkingBudget})};function yo(e,t,n,o,r){const i=n&&!go(e.id);if("github-copilot"===e.provider){const n=[];i&&n.push("interleaved-thinking-2025-05-14");return{client:new Kn({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:fo({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...n.length>0?{"anthropic-beta":n.join(",")}:{}},e.headers,r,o)}),isOAuthToken:!1}}const a=["fine-grained-tool-streaming-2025-05-14"];if(i&&a.push("interleaved-thinking-2025-05-14"),function(e){return e.includes("sk-ant-oat")}(t)){return{client:new Kn({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:fo({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":`claude-code-20250219,oauth-2025-04-20,${a.join(",")}`,"user-agent":"claude-cli/2.1.62","x-app":"cli"},e.headers,o)}),isOAuthToken:!0}}return{client:new Kn({apiKey:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:fo({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":a.join(",")},e.headers,o)}),isOAuthToken:!1}}function vo(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function _o(e,t,n,o){const r=[],i=so(e,t,vo);for(let e=0;e<i.length;e++){const o=i[e];if("user"===o.role)if("string"==typeof o.content)o.content.trim().length>0&&r.push({role:"user",content:to(o.content)});else{const e=o.content.map(e=>"text"===e.type?{type:"text",text:to(e.text)}:{type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}});let n=t?.input.includes("image")?e:e.filter(e=>"image"!==e.type);if(n=n.filter(e=>"text"!==e.type||e.text.trim().length>0),0===n.length)continue;r.push({role:"user",content:n})}else if("assistant"===o.role){const e=[];for(const t of o.content)if("text"===t.type){if(0===t.text.trim().length)continue;e.push({type:"text",text:to(t.text)})}else if("thinking"===t.type){if(t.redacted){e.push({type:"redacted_thinking",data:t.thinkingSignature});continue}if(0===t.thinking.trim().length)continue;t.thinkingSignature&&0!==t.thinkingSignature.trim().length?e.push({type:"thinking",thinking:to(t.thinking),signature:t.thinkingSignature}):e.push({type:"text",text:to(t.thinking)})}else"toolCall"===t.type&&e.push({type:"tool_use",id:t.id,name:n?lo(t.name):t.name,input:t.arguments??{}});if(0===e.length)continue;r.push({role:"assistant",content:e})}else if("toolResult"===o.role){const t=[];t.push({type:"tool_result",tool_use_id:o.toolCallId,content:ho(o.content),is_error:o.isError});let n=e+1;for(;n<i.length&&"toolResult"===i[n].role;){const e=i[n];t.push({type:"tool_result",tool_use_id:e.toolCallId,content:ho(e.content),is_error:e.isError}),n++}e=n-1,r.push({role:"user",content:t})}}if(o&&r.length>0){const e=r[r.length-1];if("user"===e.role)if(Array.isArray(e.content)){const t=e.content[e.content.length-1];!t||"text"!==t.type&&"image"!==t.type&&"tool_result"!==t.type||(t.cache_control=o)}else"string"==typeof e.content&&(e.content=[{type:"text",text:e.content,cache_control:o}])}return r}function wo(e){switch(e){case"end_turn":case"pause_turn":case"stop_sequence":return"stop";case"max_tokens":return"length";case"tool_use":return"toolUse";case"refusal":case"sensitive":return"error";default:throw new Error(`Unhandled stop reason: ${e}`)}}function Oo(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function So(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}let xo=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return xo=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^n()&15>>+e/4).toString(16))};function To(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const Po=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};class Co extends Error{}class ko extends Co{constructor(e,t,n,o){super(`${ko.makeMessage(e,t,n)}`),this.status=e,this.headers=o,this.requestID=o?.get("x-request-id"),this.error=t;const r=t;this.code=r?.code,this.param=r?.param,this.type=r?.type}static makeMessage(e,t,n){const o=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&o?`${e} ${o}`:e?`${e} status code (no body)`:o||"(no status code or body)"}static generate(e,t,n,o){if(!e||!o)return new Eo({message:n,cause:Po(t)});const r=t?.error;return 400===e?new Ao(e,r,n,o):401===e?new Io(e,r,n,o):403===e?new Mo(e,r,n,o):404===e?new No(e,r,n,o):409===e?new $o(e,r,n,o):422===e?new Do(e,r,n,o):429===e?new Uo(e,r,n,o):e>=500?new Lo(e,r,n,o):new ko(e,r,n,o)}}class jo extends ko{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Eo extends ko{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class Ro extends Eo{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Ao extends ko{}class Io extends ko{}class Mo extends ko{}class No extends ko{}class $o extends ko{}class Do extends ko{}class Uo extends ko{}class Lo extends ko{}class qo extends Co{constructor(){super("Could not parse response content as the length limit was reached")}}class Fo extends Co{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class Wo extends Error{constructor(e){super(e)}}const Jo=/^[a-z][a-z0-9+.-]*:/i;let Bo=e=>(Bo=Array.isArray,Bo(e)),Go=Bo;function Vo(e){return"object"!=typeof e?{}:e??{}}function Ho(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}const zo=e=>new Promise(t=>setTimeout(t,e)),Ko="6.26.0";const Xo=()=>{const e="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":Yo(Deno.build.os),"X-Stainless-Arch":Zo(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":Yo(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Zo(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const t=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const e=n.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const Zo=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",Yo=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let Qo;function er(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function tr(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return er({start(){},async pull(e){const{done:n,value:o}=await t.next();n?e.close():e.enqueue(o)},async cancel(){await(t.return?.())}})}function nr(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}const or=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),rr="RFC3986",ir=e=>String(e),ar={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:ir};let sr=(e,t)=>(sr=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),sr(e,t));const cr=(()=>{const e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();const ur=1024;function lr(e,t){if(Bo(e)){const n=[];for(let o=0;o<e.length;o+=1)n.push(t(e[o]));return n}return t(e)}const dr={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},pr=function(e,t){Array.prototype.push.apply(e,Bo(t)?t:[t])};let hr;const fr={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,n,o,r)=>{if(0===e.length)return e;let i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===n)return escape(i).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});let a="";for(let e=0;e<i.length;e+=ur){const t=i.length>=ur?i.slice(e,e+ur):i,n=[];for(let e=0;e<t.length;++e){let o=t.charCodeAt(e);45===o||46===o||95===o||126===o||o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122||"RFC1738"===r&&(40===o||41===o)?n[n.length]=t.charAt(e):o<128?n[n.length]=cr[o]:o<2048?n[n.length]=cr[192|o>>6]+cr[128|63&o]:o<55296||o>=57344?n[n.length]=cr[224|o>>12]+cr[128|o>>6&63]+cr[128|63&o]:(e+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(e)),n[n.length]=cr[240|o>>18]+cr[128|o>>12&63]+cr[128|o>>6&63]+cr[128|63&o])}a+=n.join("")}return a},encodeValuesOnly:!1,format:rr,formatter:ir,indices:!1,serializeDate:e=>(hr??(hr=Function.prototype.call.bind(Date.prototype.toISOString)))(e),skipNulls:!1,strictNullHandling:!1};const mr={};function gr(e,t,n,o,r,i,a,s,c,u,l,d,p,h,f,m,g,b){let y=e,v=b,_=0,w=!1;for(;void 0!==(v=v.get(mr))&&!w;){const t=v.get(e);if(_+=1,void 0!==t){if(t===_)throw new RangeError("Cyclic object value");w=!0}void 0===v.get(mr)&&(_=0)}if("function"==typeof u?y=u(t,y):y instanceof Date?y=p?.(y):"comma"===n&&Bo(y)&&(y=lr(y,function(e){return e instanceof Date?p?.(e):e})),null===y){if(i)return c&&!m?c(t,fr.encoder,g,"key",h):t;y=""}if("string"==typeof(O=y)||"number"==typeof O||"boolean"==typeof O||"symbol"==typeof O||"bigint"==typeof O||function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))}(y)){if(c){const e=m?t:c(t,fr.encoder,g,"key",h);return[f?.(e)+"="+f?.(c(y,fr.encoder,g,"value",h))]}return[f?.(t)+"="+f?.(String(y))]}var O;const S=[];if(void 0===y)return S;let x;if("comma"===n&&Bo(y))m&&c&&(y=lr(y,c)),x=[{value:y.length>0?y.join(",")||null:void 0}];else if(Bo(u))x=u;else{const e=Object.keys(y);x=l?e.sort(l):e}const T=s?String(t).replace(/\./g,"%2E"):String(t),P=o&&Bo(y)&&1===y.length?T+"[]":T;if(r&&Bo(y)&&0===y.length)return P+"[]";for(let t=0;t<x.length;++t){const v=x[t],w="object"==typeof v&&void 0!==v.value?v.value:y[v];if(a&&null===w)continue;const O=d&&s?v.replace(/\./g,"%2E"):v,T=Bo(y)?"function"==typeof n?n(P,O):P:P+(d?"."+O:"["+O+"]");b.set(e,_);const C=new WeakMap;C.set(mr,b),pr(S,gr(w,T,n,o,r,i,a,s,"comma"===n&&m&&Bo(y)?null:c,u,l,d,p,h,f,m,g,C))}return S}function br(e,t={}){let n=e;const o=function(e=fr){if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");const t=e.charset||fr.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=rr;if(void 0!==e.format){if(!sr(ar,e.format))throw new TypeError("Unknown format option provided.");n=e.format}const o=ar[n];let r,i=fr.filter;if(("function"==typeof e.filter||Bo(e.filter))&&(i=e.filter),r=e.arrayFormat&&e.arrayFormat in dr?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":fr.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const a=void 0===e.allowDots?1==!!e.encodeDotInKeys||fr.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:fr.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:fr.allowEmptyArrays,arrayFormat:r,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:fr.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?fr.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:fr.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:fr.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:fr.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:fr.encodeValuesOnly,filter:i,format:n,formatter:o,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:fr.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:fr.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:fr.strictNullHandling}}(t);let r,i;"function"==typeof o.filter?(i=o.filter,n=i("",n)):Bo(o.filter)&&(i=o.filter,r=i);const a=[];if("object"!=typeof n||null===n)return"";const s=dr[o.arrayFormat],c="comma"===s&&o.commaRoundTrip;r||(r=Object.keys(n)),o.sort&&r.sort(o.sort);const u=new WeakMap;for(let e=0;e<r.length;++e){const t=r[e];o.skipNulls&&null===n[t]||pr(a,gr(n[t],t,s,c,o.allowEmptyArrays,o.strictNullHandling,o.skipNulls,o.encodeDotInKeys,o.encode?o.encoder:null,o.filter,o.sort,o.allowDots,o.serializeDate,o.format,o.formatter,o.encodeValuesOnly,o.charset,u))}const l=a.join(o.delimiter);let d=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&("iso-8859-1"===o.charset?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),l.length>0?d+l:""}let yr,vr;function _r(e){let t;return(yr??(t=new globalThis.TextEncoder,yr=t.encode.bind(t)))(e)}function wr(e){let t;return(vr??(t=new globalThis.TextDecoder,vr=t.decode.bind(t)))(e)}var Or,Sr;class xr{constructor(){Or.set(this,void 0),Sr.set(this,void 0),Oo(this,Or,new Uint8Array,"f"),Oo(this,Sr,null,"f")}decode(e){if(null==e)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?_r(e):e;Oo(this,Or,function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let o=0;for(const t of e)n.set(t,o),o+=t.length;return n}([So(this,Or,"f"),t]),"f");const n=[];let o;for(;null!=(o=Tr(So(this,Or,"f"),So(this,Sr,"f")));){if(o.carriage&&null==So(this,Sr,"f")){Oo(this,Sr,o.index,"f");continue}if(null!=So(this,Sr,"f")&&(o.index!==So(this,Sr,"f")+1||o.carriage)){n.push(wr(So(this,Or,"f").subarray(0,So(this,Sr,"f")-1))),Oo(this,Or,So(this,Or,"f").subarray(So(this,Sr,"f")),"f"),Oo(this,Sr,null,"f");continue}const e=null!==So(this,Sr,"f")?o.preceding-1:o.preceding,t=wr(So(this,Or,"f").subarray(0,e));n.push(t),Oo(this,Or,So(this,Or,"f").subarray(o.index),"f"),Oo(this,Sr,null,"f")}return n}flush(){return So(this,Or,"f").length?this.decode("\n"):[]}}function Tr(e,t){for(let n=t??0;n<e.length;n++){if(10===e[n])return{preceding:n,index:n+1,carriage:!1};if(13===e[n])return{preceding:n,index:n+1,carriage:!0}}return null}function Pr(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1])return t+2;if(13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return-1}Or=new WeakMap,Sr=new WeakMap,xr.NEWLINE_CHARS=new Set(["\n","\r"]),xr.NEWLINE_REGEXP=/\r\n|[\n\r]/g;const Cr={off:0,error:200,warn:300,info:400,debug:500},kr=(e,t,n)=>{var o,r;if(e)return o=Cr,r=e,Object.prototype.hasOwnProperty.call(o,r)?e:void Ir(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Cr))}`)};function jr(){}function Er(e,t,n){return!t||Cr[e]>Cr[n]?jr:t[e].bind(t)}const Rr={error:jr,warn:jr,info:jr,debug:jr};let Ar=new WeakMap;function Ir(e){const t=e.logger,n=e.logLevel??"off";if(!t)return Rr;const o=Ar.get(t);if(o&&o[0]===n)return o[1];const r={error:Er("error",t,n),warn:Er("warn",t,n),info:Er("info",t,n),debug:Er("debug",t,n)};return Ar.set(t,[n,r]),r}const Mr=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var Nr,$r,Dr;class Ur{constructor(e,t,n){this.iterator=e,Nr.set(this,void 0),this.controller=t,Oo(this,Nr,n,"f")}static fromSSEResponse(e,t,n,o){let r=!1;const i=n?Ir(n):console;return new Ur(async function*(){if(r)throw new Co("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let n=!1;try{for await(const r of async function*(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new Co("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new Co("Attempted to iterate over a response with no body")}const n=new Lr,o=new xr,r=nr(e.body);for await(const e of async function*(e){let t=new Uint8Array;for await(const n of e){if(null==n)continue;const e=n instanceof ArrayBuffer?new Uint8Array(n):"string"==typeof n?_r(n):n;let o,r=new Uint8Array(t.length+e.length);for(r.set(t),r.set(e,t.length),t=r;-1!==(o=Pr(t));)yield t.slice(0,o),t=t.slice(o)}t.length>0&&(yield t)}(r))for(const t of o.decode(e)){const e=n.decode(t);e&&(yield e)}for(const e of o.flush()){const t=n.decode(e);t&&(yield t)}}(e,t))if(!n)if(r.data.startsWith("[DONE]"))n=!0;else if(null!==r.event&&r.event.startsWith("thread.")){let e;try{e=JSON.parse(r.data)}catch(e){throw console.error("Could not parse message into JSON:",r.data),console.error("From chunk:",r.raw),e}if("error"==r.event)throw new ko(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}else{let t;try{t=JSON.parse(r.data)}catch(e){throw i.error("Could not parse message into JSON:",r.data),i.error("From chunk:",r.raw),e}if(t&&t.error)throw new ko(void 0,t.error,void 0,e.headers);yield o?{event:r.event,data:t}:t}n=!0}catch(e){if(To(e))return;throw e}finally{n||t.abort()}},t,n)}static fromReadableStream(e,t,n){let o=!1;return new Ur(async function*(){if(o)throw new Co("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let n=!1;try{for await(const t of async function*(){const t=new xr,n=nr(e);for await(const e of n)for(const n of t.decode(e))yield n;for(const e of t.flush())yield e}())n||t&&(yield JSON.parse(t));n=!0}catch(e){if(To(e))return;throw e}finally{n||t.abort()}},t,n)}[(Nr=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[],t=[],n=this.iterator(),o=o=>({next:()=>{if(0===o.length){const o=n.next();e.push(o),t.push(o)}return o.shift()}});return[new Ur(()=>o(e),this.controller,So(this,Nr,"f")),new Ur(()=>o(t),this.controller,So(this,Nr,"f"))]}toReadableStream(){const e=this;let t;return er({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{const{value:n,done:o}=await t.next();if(o)return e.close();const r=_r(JSON.stringify(n)+"\n");e.enqueue(r)}catch(t){e.error(t)}},async cancel(){await(t.return?.())}})}}class Lr{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,n,o]=function(e,t){const n=e.indexOf(t);if(-1!==n)return[e.substring(0,n),t,e.substring(n+t.length)];return[e,"",""]}(e,":");return o.startsWith(" ")&&(o=o.substring(1)),"event"===t?this.event=o:"data"===t&&this.data.push(o),null}}async function qr(e,t){const{response:n,requestLogID:o,retryOfRequestLogID:r,startTime:i}=t,a=await(async()=>{if(t.options.stream)return Ir(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData):Ur.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData);if(204===n.status)return null;if(t.options.__binaryResponse)return n;const o=n.headers.get("content-type"),r=o?.split(";")[0]?.trim();if(r?.includes("application/json")||r?.endsWith("+json")){if("0"===n.headers.get("content-length"))return;return Fr(await n.json(),n)}return await n.text()})();return Ir(e).debug(`[${o}] response parsed`,Mr({retryOfRequestLogID:r,url:n.url,status:n.status,body:a,durationMs:Date.now()-i})),a}function Fr(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}class Wr extends Promise{constructor(e,t,n=qr){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,$r.set(this,void 0),Oo(this,$r,e,"f")}_thenUnwrap(e){return new Wr(So(this,$r,"f"),this.responsePromise,async(t,n)=>Fr(e(await this.parseResponse(t,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(So(this,$r,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}$r=new WeakMap;class Jr{constructor(e,t,n,o){Dr.set(this,void 0),Oo(this,Dr,e,"f"),this.options=o,this.response=t,this.body=n}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new Co("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await So(this,Dr,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Dr=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const t of e.getPaginatedItems())yield t}}class Br extends Wr{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await qr(e,t),t.options))}async*[Symbol.asyncIterator](){const e=await(this);for await(const t of e)yield t}}class Gr extends Jr{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}}class Vr extends Jr{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){const e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...Vo(this.options.query),after:t}}:null}}class Hr extends Jr{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){const e=this.last_id;return e?{...this.options,query:{...Vo(this.options.query),after:e}}:null}}const zr=()=>{if("undefined"==typeof File){const{process:e}=globalThis,t="string"==typeof e?.versions?.node&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Kr(e,t,n){return zr(),new File(e,t??"unknown_file",n)}function Xr(e){return("object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}const Zr=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],Yr=async(e,t)=>oi(e.body)?{...e,body:await ti(e.body,t)}:e,Qr=async(e,t)=>({...e,body:await ti(e.body,t)}),ei=new WeakMap;const ti=async(e,t)=>{if(!await function(e){const t="function"==typeof e?e:e.fetch,n=ei.get(t);if(n)return n;const o=(async()=>{try{const e="Response"in t?t.Response:(await t("data:,")).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return ei.set(t,o),o}(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>ri(n,e,t))),n},ni=e=>e instanceof Blob&&"name"in e,oi=e=>{if((e=>"object"==typeof e&&null!==e&&(e instanceof Response||Zr(e)||ni(e)))(e))return!0;if(Array.isArray(e))return e.some(oi);if(e&&"object"==typeof e)for(const t in e)if(oi(e[t]))return!0;return!1},ri=async(e,t,n)=>{if(void 0!==n){if(null==n)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)e.append(t,String(n));else if(n instanceof Response)e.append(t,Kr([await n.blob()],Xr(n)));else if(Zr(n))e.append(t,Kr([await new Response(tr(n)).blob()],Xr(n)));else if(ni(n))e.append(t,n,Xr(n));else if(Array.isArray(n))await Promise.all(n.map(n=>ri(e,t+"[]",n)));else{if("object"!=typeof n)throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`);await Promise.all(Object.entries(n).map(([n,o])=>ri(e,`${t}[${n}]`,o)))}}},ii=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function ai(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(ii(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else{if(!Zr(e)){const t=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";const t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}for await(const n of e)t.push(...await ai(n))}return t}class si{constructor(e){this._client=e}}function ci(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const ui=Object.freeze(Object.create(null)),li=(e=ci)=>function(t,...n){if(1===t.length)return t[0];let o=!1;const r=[],i=t.reduce((t,i,a)=>{/[?#]/.test(i)&&(o=!0);const s=n[a];let c=(o?encodeURIComponent:e)(""+s);return a!==n.length&&(null==s||"object"==typeof s&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??ui)??ui)?.toString)&&(c=s+"",r.push({start:t.length+i.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+i+(a===n.length?"":c)},""),a=i.split(/[?#]/,1)[0],s=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let c;for(;null!==(c=s.exec(a));)r.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can't be safely passed as a path parameter`});if(r.sort((e,t)=>e.start-t.start),r.length>0){let e=0;const t=r.reduce((t,n)=>{const o=" ".repeat(n.start-e),r="^".repeat(n.length);return e=n.start+n.length,t+o+r},"");throw new Co(`Path parameters result in path with invalid segments:\n${r.map(e=>e.error).join("\n")}\n${i}\n${t}`)}return i},di=li(ci);class pi extends si{list(e,t={},n){return this._client.getAPIList(di`/chat/completions/${e}/messages`,Vr,{query:t,...n})}}function hi(e){return void 0!==e&&"function"in e&&void 0!==e.function}function fi(e){return"auto-parseable-response-format"===e?.$brand}function mi(e){return"auto-parseable-tool"===e?.$brand}function gi(e,t){const n=e.choices.map(e=>{if("length"===e.finish_reason)throw new qo;if("content_filter"===e.finish_reason)throw new Fo;return _i(e.message.tool_calls),{...e,message:{...e.message,...e.message.tool_calls?{tool_calls:e.message.tool_calls?.map(e=>function(e,t){const n=e.tools?.find(e=>hi(e)&&e.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:mi(n)?n.$parseRaw(t.function.arguments):n?.function.strict?JSON.parse(t.function.arguments):null}}}(t,e))??void 0}:void 0,parsed:e.message.content&&!e.message.refusal?bi(t,e.message.content):null}}});return{...e,choices:n}}function bi(e,t){if("json_schema"!==e.response_format?.type)return null;if("json_schema"===e.response_format?.type){if("$parseRaw"in e.response_format){return e.response_format.$parseRaw(t)}return JSON.parse(t)}return null}function yi(e,t){if(!e||!("tools"in e)||!e.tools)return!1;const n=e.tools?.find(e=>hi(e)&&e.function?.name===t.function.name);return hi(n)&&(mi(n)||n?.function.strict||!1)}function vi(e){return!!fi(e.response_format)||(e.tools?.some(e=>mi(e)||"function"===e.type&&!0===e.function.strict)??!1)}function _i(e){for(const t of e||[])if("function"!==t.type)throw new Co(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}const wi=e=>"assistant"===e?.role,Oi=e=>"tool"===e?.role;var Si,xi,Ti,Pi,Ci,ki,ji,Ei,Ri,Ai,Ii,Mi,Ni,$i,Di,Ui,Li,qi,Fi,Wi,Ji;class Bi{constructor(){Si.add(this),this.controller=new AbortController,xi.set(this,void 0),Ti.set(this,()=>{}),Pi.set(this,()=>{}),Ci.set(this,void 0),ki.set(this,()=>{}),ji.set(this,()=>{}),Ei.set(this,{}),Ri.set(this,!1),Ai.set(this,!1),Ii.set(this,!1),Mi.set(this,!1),Oo(this,xi,new Promise((e,t)=>{Oo(this,Ti,e,"f"),Oo(this,Pi,t,"f")}),"f"),Oo(this,Ci,new Promise((e,t)=>{Oo(this,ki,e,"f"),Oo(this,ji,t,"f")}),"f"),So(this,xi,"f").catch(()=>{}),So(this,Ci,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},So(this,Si,"m",Ni).bind(this))},0)}_connected(){this.ended||(So(this,Ti,"f").call(this),this._emit("connect"))}get ended(){return So(this,Ri,"f")}get errored(){return So(this,Ai,"f")}get aborted(){return So(this,Ii,"f")}abort(){this.controller.abort()}on(e,t){return(So(this,Ei,"f")[e]||(So(this,Ei,"f")[e]=[])).push({listener:t}),this}off(e,t){const n=So(this,Ei,"f")[e];if(!n)return this;const o=n.findIndex(e=>e.listener===t);return o>=0&&n.splice(o,1),this}once(e,t){return(So(this,Ei,"f")[e]||(So(this,Ei,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{Oo(this,Mi,!0,"f"),"error"!==e&&this.once("error",n),this.once(e,t)})}async done(){Oo(this,Mi,!0,"f"),await So(this,Ci,"f")}_emit(e,...t){if(So(this,Ri,"f"))return;"end"===e&&(Oo(this,Ri,!0,"f"),So(this,ki,"f").call(this));const n=So(this,Ei,"f")[e];if(n&&(So(this,Ei,"f")[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),"abort"===e){const e=t[0];return So(this,Mi,"f")||n?.length||Promise.reject(e),So(this,Pi,"f").call(this,e),So(this,ji,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];So(this,Mi,"f")||n?.length||Promise.reject(e),So(this,Pi,"f").call(this,e),So(this,ji,"f").call(this,e),this._emit("end")}}_emitFinal(){}}function Gi(e){return"function"==typeof e.parse}xi=new WeakMap,Ti=new WeakMap,Pi=new WeakMap,Ci=new WeakMap,ki=new WeakMap,ji=new WeakMap,Ei=new WeakMap,Ri=new WeakMap,Ai=new WeakMap,Ii=new WeakMap,Mi=new WeakMap,Si=new WeakSet,Ni=function(e){if(Oo(this,Ai,!0,"f"),e instanceof Error&&"AbortError"===e.name&&(e=new jo),e instanceof jo)return Oo(this,Ii,!0,"f"),this._emit("abort",e);if(e instanceof Co)return this._emit("error",e);if(e instanceof Error){const t=new Co(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new Co(String(e)))};const Vi=10;class Hi extends Bi{constructor(){super(...arguments),$i.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);const t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if("content"in e||(e.content=null),this.messages.push(e),t)if(this._emit("message",e),Oi(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(wi(e)&&e.tool_calls)for(const t of e.tool_calls)"function"===t.type&&this._emit("functionToolCall",t.function)}async finalChatCompletion(){await this.done();const e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new Co("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),So(this,$i,"m",Di).call(this)}async finalMessage(){return await this.done(),So(this,$i,"m",Ui).call(this)}async finalFunctionToolCall(){return await this.done(),So(this,$i,"m",Li).call(this)}async finalFunctionToolCallResult(){return await this.done(),So(this,$i,"m",qi).call(this)}async totalUsage(){return await this.done(),So(this,$i,"m",Fi).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){const e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);const t=So(this,$i,"m",Ui).call(this);t&&this._emit("finalMessage",t);const n=So(this,$i,"m",Di).call(this);n&&this._emit("finalContent",n);const o=So(this,$i,"m",Li).call(this);o&&this._emit("finalFunctionToolCall",o);const r=So(this,$i,"m",qi).call(this);null!=r&&this._emit("finalFunctionToolCallResult",r),this._chatCompletions.some(e=>e.usage)&&this._emit("totalUsage",So(this,$i,"m",Fi).call(this))}async _createChatCompletion(e,t,n){const o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort())),So(this,$i,"m",Wi).call(this,t);const r=await e.chat.completions.create({...t,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(gi(r,t))}async _runChatCompletion(e,t,n){for(const e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,n)}async _runTools(e,t,n){const o="tool",{tool_choice:r="auto",stream:i,...a}=t,s="string"!=typeof r&&"function"===r.type&&r?.function?.name,{maxChatCompletions:c=Vi}=n||{},u=t.tools.map(e=>{if(mi(e)){if(!e.$callback)throw new Co("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:e.$callback,name:e.function.name,description:e.function.description||"",parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e}),l={};for(const e of u)"function"===e.type&&(l[e.function.name||e.function.function.name]=e.function);const d="tools"in t?u.map(e=>"function"===e.type?{type:"function",function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e):void 0;for(const e of t.messages)this._addMessage(e,!1);for(let t=0;t<c;++t){const t=await this._createChatCompletion(e,{...a,tool_choice:r,tools:d,messages:[...this.messages]},n),i=t.choices[0]?.message;if(!i)throw new Co("missing message in ChatCompletion response");if(!i.tool_calls?.length)return;for(const e of i.tool_calls){if("function"!==e.type)continue;const t=e.id,{name:n,arguments:r}=e.function,i=l[n];if(!i){const e=`Invalid tool_call: ${JSON.stringify(n)}. Available options are: ${Object.keys(l).map(e=>JSON.stringify(e)).join(", ")}. Please try again`;this._addMessage({role:o,tool_call_id:t,content:e});continue}if(s&&s!==n){const e=`Invalid tool_call: ${JSON.stringify(n)}. ${JSON.stringify(s)} requested. Please try again`;this._addMessage({role:o,tool_call_id:t,content:e});continue}let a;try{a=Gi(i)?await i.parse(r):r}catch(e){const n=e instanceof Error?e.message:String(e);this._addMessage({role:o,tool_call_id:t,content:n});continue}const c=await i.function(a,this),u=So(this,$i,"m",Ji).call(this,c);if(this._addMessage({role:o,tool_call_id:t,content:u}),s)return}}}}$i=new WeakSet,Di=function(){return So(this,$i,"m",Ui).call(this).content??null},Ui=function(){let e=this.messages.length;for(;e-- >0;){const t=this.messages[e];if(wi(t)){return{...t,content:t.content??null,refusal:t.refusal??null}}}throw new Co("stream ended without producing a ChatCompletionMessage with role=assistant")},Li=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(wi(t)&&t?.tool_calls?.length)return t.tool_calls.filter(e=>"function"===e.type).at(-1)?.function}},qi=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(Oi(t)&&null!=t.content&&"string"==typeof t.content&&this.messages.some(e=>"assistant"===e.role&&e.tool_calls?.some(e=>"function"===e.type&&e.id===t.tool_call_id)))return t.content}},Fi=function(){const e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},Wi=function(e){if(null!=e.n&&e.n>1)throw new Co("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},Ji=function(e){return"string"==typeof e?e:void 0===e?"undefined":JSON.stringify(e)};class zi extends Hi{static runTools(e,t,n){const o=new zi,r={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return o._run(()=>o._runTools(e,t,r)),o}_addMessage(e,t=!0){super._addMessage(e,t),wi(e)&&e.content&&this._emit("content",e.content)}}const Ki=1,Xi=2,Zi=4,Yi=8,Qi=16,ea=32,ta=64,na=128,oa=256,ra=511;class ia extends Error{}class aa extends Error{}const sa=(e,t)=>{const n=e.length;let o=0;const r=e=>{throw new ia(`${e} at position ${o}`)},i=e=>{throw new aa(`${e} at position ${o}`)},a=()=>(d(),o>=n&&r("Unexpected end of input"),'"'===e[o]?s():"{"===e[o]?c():"["===e[o]?u():"null"===e.substring(o,o+4)||Qi&t&&n-o<4&&"null".startsWith(e.substring(o))?(o+=4,null):"true"===e.substring(o,o+4)||ea&t&&n-o<4&&"true".startsWith(e.substring(o))?(o+=4,!0):"false"===e.substring(o,o+5)||ea&t&&n-o<5&&"false".startsWith(e.substring(o))?(o+=5,!1):"Infinity"===e.substring(o,o+8)||na&t&&n-o<8&&"Infinity".startsWith(e.substring(o))?(o+=8,1/0):"-Infinity"===e.substring(o,o+9)||oa&t&&1<n-o&&n-o<9&&"-Infinity".startsWith(e.substring(o))?(o+=9,-1/0):"NaN"===e.substring(o,o+3)||ta&t&&n-o<3&&"NaN".startsWith(e.substring(o))?(o+=3,NaN):l()),s=()=>{const a=o;let s=!1;for(o++;o<n&&('"'!==e[o]||s&&"\\"===e[o-1]);)s="\\"===e[o]&&!s,o++;if('"'==e.charAt(o))try{return JSON.parse(e.substring(a,++o-Number(s)))}catch(e){i(String(e))}else if(Ki&t)try{return JSON.parse(e.substring(a,o-Number(s))+'"')}catch(t){return JSON.parse(e.substring(a,e.lastIndexOf("\\"))+'"')}r("Unterminated string literal")},c=()=>{o++,d();const i={};try{for(;"}"!==e[o];){if(d(),o>=n&&Yi&t)return i;const r=s();d(),o++;try{const e=a();Object.defineProperty(i,r,{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){if(Yi&t)return i;throw e}d(),","===e[o]&&o++}}catch(e){if(Yi&t)return i;r("Expected '}' at end of object")}return o++,i},u=()=>{o++;const n=[];try{for(;"]"!==e[o];)n.push(a()),d(),","===e[o]&&o++}catch(e){if(Zi&t)return n;r("Expected ']' at end of array")}return o++,n},l=()=>{if(0===o){"-"===e&&Xi&t&&r("Not sure what '-' is");try{return JSON.parse(e)}catch(n){if(Xi&t)try{return"."===e[e.length-1]?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch(e){}i(String(n))}}const a=o;for("-"===e[o]&&o++;e[o]&&!",]}".includes(e[o]);)o++;o!=n||Xi&t||r("Unterminated number literal");try{return JSON.parse(e.substring(a,o))}catch(n){"-"===e.substring(a,o)&&Xi&t&&r("Not sure what '-' is");try{return JSON.parse(e.substring(a,e.lastIndexOf("e")))}catch(e){i(String(e))}}},d=()=>{for(;o<n&&" \n\r\t".includes(e[o]);)o++};return a()},ca=e=>function(e,t=ra){if("string"!=typeof e)throw new TypeError("expecting str, got "+typeof e);if(!e.trim())throw new Error(`${e} is empty`);return sa(e.trim(),t)}(e,ra^Xi);var ua,la,da,pa,ha,fa,ma,ga,ba,ya,va,_a;class wa extends Hi{constructor(e){super(),ua.add(this),la.set(this,void 0),da.set(this,void 0),pa.set(this,void 0),Oo(this,la,e,"f"),Oo(this,da,[],"f")}get currentChatCompletionSnapshot(){return So(this,pa,"f")}static fromReadableStream(e){const t=new wa(null);return t._run(()=>t._fromReadableStream(e)),t}static createChatCompletion(e,t,n){const o=new wa(t);return o._run(()=>o._runChatCompletion(e,{...t,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}async _createChatCompletion(e,t,n){super._createChatCompletion;const o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort())),So(this,ua,"m",ha).call(this);const r=await e.chat.completions.create({...t,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(const e of r)So(this,ua,"m",ma).call(this,e);if(r.controller.signal?.aborted)throw new jo;return this._addChatCompletion(So(this,ua,"m",ya).call(this))}async _fromReadableStream(e,t){const n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),So(this,ua,"m",ha).call(this),this._connected();const o=Ur.fromReadableStream(e,this.controller);let r;for await(const e of o)r&&r!==e.id&&this._addChatCompletion(So(this,ua,"m",ya).call(this)),So(this,ua,"m",ma).call(this,e),r=e.id;if(o.controller.signal?.aborted)throw new jo;return this._addChatCompletion(So(this,ua,"m",ya).call(this))}[(la=new WeakMap,da=new WeakMap,pa=new WeakMap,ua=new WeakSet,ha=function(){this.ended||Oo(this,pa,void 0,"f")},fa=function(e){let t=So(this,da,"f")[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},So(this,da,"f")[e.index]=t,t)},ma=function(e){if(this.ended)return;const t=So(this,ua,"m",_a).call(this,e);this._emit("chunk",e,t);for(const n of e.choices){const e=t.choices[n.index];null!=n.delta.content&&"assistant"===e.message?.role&&e.message?.content&&(this._emit("content",n.delta.content,e.message.content),this._emit("content.delta",{delta:n.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),null!=n.delta.refusal&&"assistant"===e.message?.role&&e.message?.refusal&&this._emit("refusal.delta",{delta:n.delta.refusal,snapshot:e.message.refusal}),null!=n.logprobs?.content&&"assistant"===e.message?.role&&this._emit("logprobs.content.delta",{content:n.logprobs?.content,snapshot:e.logprobs?.content??[]}),null!=n.logprobs?.refusal&&"assistant"===e.message?.role&&this._emit("logprobs.refusal.delta",{refusal:n.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});const o=So(this,ua,"m",fa).call(this,e);e.finish_reason&&(So(this,ua,"m",ba).call(this,e),null!=o.current_tool_call_index&&So(this,ua,"m",ga).call(this,e,o.current_tool_call_index));for(const t of n.delta.tool_calls??[])o.current_tool_call_index!==t.index&&(So(this,ua,"m",ba).call(this,e),null!=o.current_tool_call_index&&So(this,ua,"m",ga).call(this,e,o.current_tool_call_index)),o.current_tool_call_index=t.index;for(const t of n.delta.tool_calls??[]){const n=e.message.tool_calls?.[t.index];n?.type&&("function"===n?.type?this._emit("tool_calls.function.arguments.delta",{name:n.function?.name,index:t.index,arguments:n.function.arguments,parsed_arguments:n.function.parsed_arguments,arguments_delta:t.function?.arguments??""}):xa(n?.type))}}},ga=function(e,t){if(So(this,ua,"m",fa).call(this,e).done_tool_calls.has(t))return;const n=e.message.tool_calls?.[t];if(!n)throw new Error("no tool call snapshot");if(!n.type)throw new Error("tool call snapshot missing `type`");if("function"===n.type){const e=So(this,la,"f")?.tools?.find(e=>hi(e)&&e.function.name===n.function.name);this._emit("tool_calls.function.arguments.done",{name:n.function.name,index:t,arguments:n.function.arguments,parsed_arguments:mi(e)?e.$parseRaw(n.function.arguments):e?.function.strict?JSON.parse(n.function.arguments):null})}else n.type},ba=function(e){const t=So(this,ua,"m",fa).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;const n=So(this,ua,"m",va).call(this);this._emit("content.done",{content:e.message.content,parsed:n?n.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit("refusal.done",{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:e.logprobs.refusal}))},ya=function(){if(this.ended)throw new Co("stream has ended, this shouldn't happen");const e=So(this,pa,"f");if(!e)throw new Co("request ended without sending any chunks");return Oo(this,pa,void 0,"f"),Oo(this,da,[],"f"),function(e,t){const{id:n,choices:o,created:r,model:i,system_fingerprint:a,...s}=e,c={...s,id:n,choices:o.map(({message:t,finish_reason:n,index:o,logprobs:r,...i})=>{if(!n)throw new Co(`missing finish_reason for choice ${o}`);const{content:a=null,function_call:s,tool_calls:c,...u}=t,l=t.role;if(!l)throw new Co(`missing role for choice ${o}`);if(s){const{arguments:e,name:c}=s;if(null==e)throw new Co(`missing function_call.arguments for choice ${o}`);if(!c)throw new Co(`missing function_call.name for choice ${o}`);return{...i,message:{content:a,function_call:{arguments:e,name:c},role:l,refusal:t.refusal??null},finish_reason:n,index:o,logprobs:r}}return c?{...i,index:o,finish_reason:n,logprobs:r,message:{...u,role:l,content:a,refusal:t.refusal??null,tool_calls:c.map((t,n)=>{const{function:r,type:i,id:a,...s}=t,{arguments:c,name:u,...l}=r||{};if(null==a)throw new Co(`missing choices[${o}].tool_calls[${n}].id\n${Oa(e)}`);if(null==i)throw new Co(`missing choices[${o}].tool_calls[${n}].type\n${Oa(e)}`);if(null==u)throw new Co(`missing choices[${o}].tool_calls[${n}].function.name\n${Oa(e)}`);if(null==c)throw new Co(`missing choices[${o}].tool_calls[${n}].function.arguments\n${Oa(e)}`);return{...s,id:a,type:i,function:{...l,name:u,arguments:c}}})}}:{...i,message:{...u,content:a,role:l,refusal:t.refusal??null},finish_reason:n,index:o,logprobs:r}}),created:r,model:i,object:"chat.completion",...a?{system_fingerprint:a}:{}};return function(e,t){return t&&vi(t)?gi(e,t):{...e,choices:e.choices.map(e=>(_i(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}}(c,t)}(e,So(this,la,"f"))},va=function(){const e=So(this,la,"f")?.response_format;return fi(e)?e:null},_a=function(e){var t,n,o,r;let i=So(this,pa,"f");const{choices:a,...s}=e;i?Object.assign(i,s):i=Oo(this,pa,{...s,choices:[]},"f");for(const{delta:a,finish_reason:s,index:c,logprobs:u=null,...l}of e.choices){let e=i.choices[c];if(e||(e=i.choices[c]={finish_reason:s,index:c,message:{},logprobs:u,...l}),u)if(e.logprobs){const{content:o,refusal:r,...i}=u;Sa(i),Object.assign(e.logprobs,i),o&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...o)),r&&((n=e.logprobs).refusal??(n.refusal=[]),e.logprobs.refusal.push(...r))}else e.logprobs=Object.assign({},u);if(s&&(e.finish_reason=s,So(this,la,"f")&&vi(So(this,la,"f")))){if("length"===s)throw new qo;if("content_filter"===s)throw new Fo}if(Object.assign(e,l),!a)continue;const{content:d,refusal:p,function_call:h,role:f,tool_calls:m,...g}=a;if(Sa(g),Object.assign(e.message,g),p&&(e.message.refusal=(e.message.refusal||"")+p),f&&(e.message.role=f),h&&(e.message.function_call?(h.name&&(e.message.function_call.name=h.name),h.arguments&&((o=e.message.function_call).arguments??(o.arguments=""),e.message.function_call.arguments+=h.arguments)):e.message.function_call=h),d&&(e.message.content=(e.message.content||"")+d,!e.message.refusal&&So(this,ua,"m",va).call(this)&&(e.message.parsed=ca(e.message.content))),m){e.message.tool_calls||(e.message.tool_calls=[]);for(const{index:t,id:n,type:o,function:i,...a}of m){const s=(r=e.message.tool_calls)[t]??(r[t]={});Object.assign(s,a),n&&(s.id=n),o&&(s.type=o),i&&(s.function??(s.function={name:i.name??"",arguments:""})),i?.name&&(s.function.name=i.name),i?.arguments&&(s.function.arguments+=i.arguments,yi(So(this,la,"f"),s)&&(s.function.parsed_arguments=ca(s.function.arguments)))}}}return i},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("chunk",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Ur(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function Oa(e){return JSON.stringify(e)}function Sa(e){}function xa(e){}class Ta extends wa{static fromReadableStream(e){const t=new Ta(null);return t._run(()=>t._fromReadableStream(e)),t}static runTools(e,t,n){const o=new Ta(t),r={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return o._run(()=>o._runTools(e,t,r)),o}}class Pa extends si{constructor(){super(...arguments),this.messages=new pi(this._client)}create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1})}retrieve(e,t){return this._client.get(di`/chat/completions/${e}`,t)}update(e,t,n){return this._client.post(di`/chat/completions/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/chat/completions",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/chat/completions/${e}`,t)}parse(e,t){return function(e){for(const t of e??[]){if("function"!==t.type)throw new Co(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new Co(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(t=>gi(t,e))}runTools(e,t){return e.stream?Ta.runTools(this._client,e,t):zi.runTools(this._client,e,t)}stream(e,t){return wa.createChatCompletion(this._client,e,t)}}Pa.Messages=pi;class Ca extends si{constructor(){super(...arguments),this.completions=new Pa(this._client)}}Ca.Completions=Pa;const ka=Symbol("brand.privateNullableHeaders");function*ja(e){if(!e)return;if(ka in e){const{values:t,nulls:n}=e;yield*t.entries();for(const e of n)yield[e,null];return}let t,n=!1;e instanceof Headers?t=e.entries():Go(e)?t=e:(n=!0,t=Object.entries(e??{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const o=Go(e[1])?e[1]:[e[1]];let r=!1;for(const e of o)void 0!==e&&(n&&!r&&(r=!0,yield[t,null]),yield[t,e])}}const Ea=e=>{const t=new Headers,n=new Set;for(const o of e){const e=new Set;for(const[r,i]of ja(o)){const o=r.toLowerCase();e.has(o)||(t.delete(r),e.add(o)),null===i?(t.delete(r),n.add(o)):(t.append(r,i),n.delete(o))}}return{[ka]:!0,values:t,nulls:n}};class Ra extends si{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:Ea([{Accept:"application/octet-stream"},t?.headers]),__binaryResponse:!0})}}class Aa extends si{create(e,t){return this._client.post("/audio/transcriptions",Qr({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}}class Ia extends si{create(e,t){return this._client.post("/audio/translations",Qr({body:e,...t,__metadata:{model:e.model}},this._client))}}class Ma extends si{constructor(){super(...arguments),this.transcriptions=new Aa(this._client),this.translations=new Ia(this._client),this.speech=new Ra(this._client)}}Ma.Transcriptions=Aa,Ma.Translations=Ia,Ma.Speech=Ra;class Na extends si{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(di`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/batches",Vr,{query:e,...t})}cancel(e,t){return this._client.post(di`/batches/${e}/cancel`,t)}}class $a extends si{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(di`/assistants/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(di`/assistants/${e}`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},t){return this._client.getAPIList("/assistants",Vr,{query:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(di`/assistants/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class Da extends si{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class Ua extends si{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class La extends si{constructor(){super(...arguments),this.sessions=new Da(this._client),this.transcriptionSessions=new Ua(this._client)}}La.Sessions=Da,La.TranscriptionSessions=Ua;class qa extends si{create(e,t){return this._client.post("/chatkit/sessions",{body:e,...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}cancel(e,t){return this._client.post(di`/chatkit/sessions/${e}/cancel`,{...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}}class Fa extends si{retrieve(e,t){return this._client.get(di`/chatkit/threads/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}list(e={},t){return this._client.getAPIList("/chatkit/threads",Hr,{query:e,...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}delete(e,t){return this._client.delete(di`/chatkit/threads/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}listItems(e,t={},n){return this._client.getAPIList(di`/chatkit/threads/${e}/items`,Hr,{query:t,...n,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}}class Wa extends si{constructor(){super(...arguments),this.sessions=new qa(this._client),this.threads=new Fa(this._client)}}Wa.Sessions=qa,Wa.Threads=Fa;class Ja extends si{create(e,t,n){return this._client.post(di`/threads/${e}/messages`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){const{thread_id:o}=t;return this._client.get(di`/threads/${o}/messages/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){const{thread_id:o,...r}=t;return this._client.post(di`/threads/${o}/messages/${e}`,{body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(di`/threads/${e}/messages`,Vr,{query:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t,n){const{thread_id:o}=t;return this._client.delete(di`/threads/${o}/messages/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}class Ba extends si{retrieve(e,t,n){const{thread_id:o,run_id:r,...i}=t;return this._client.get(di`/threads/${o}/runs/${r}/steps/${e}`,{query:i,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t,n){const{thread_id:o,...r}=t;return this._client.getAPIList(di`/threads/${o}/runs/${e}/steps`,Vr,{query:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}const Ga=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;var Va,Ha,za,Ka,Xa,Za,Ya,Qa,es,ts,ns,os,rs,is,as,ss,cs,us,ls,ds,ps,hs,fs,ms,gs,bs,ys,vs,_s,ws,Os;class Ss extends Bi{constructor(){super(...arguments),Va.add(this),za.set(this,[]),Ka.set(this,{}),Xa.set(this,{}),Za.set(this,void 0),Ya.set(this,void 0),Qa.set(this,void 0),es.set(this,void 0),ts.set(this,void 0),ns.set(this,void 0),os.set(this,void 0),rs.set(this,void 0),is.set(this,void 0)}[(za=new WeakMap,Ka=new WeakMap,Xa=new WeakMap,Za=new WeakMap,Ya=new WeakMap,Qa=new WeakMap,es=new WeakMap,ts=new WeakMap,ns=new WeakMap,os=new WeakMap,rs=new WeakMap,is=new WeakMap,Va=new WeakSet,Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("event",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){const t=new Ha;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){const n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),this._connected();const o=Ur.fromReadableStream(e,this.controller);for await(const e of o)So(this,Va,"m",as).call(this,e);if(o.controller.signal?.aborted)throw new jo;return this._addRun(So(this,Va,"m",ss).call(this))}toReadableStream(){return new Ur(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,n,o){const r=new Ha;return r._run(()=>r._runToolAssistantStream(e,t,n,{...o,headers:{...o?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createToolAssistantStream(e,t,n,o){const r=o?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));const i={...n,stream:!0},a=await e.submitToolOutputs(t,i,{...o,signal:this.controller.signal});this._connected();for await(const e of a)So(this,Va,"m",as).call(this,e);if(a.controller.signal?.aborted)throw new jo;return this._addRun(So(this,Va,"m",ss).call(this))}static createThreadAssistantStream(e,t,n){const o=new Ha;return o._run(()=>o._threadAssistantStream(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}static createAssistantStream(e,t,n,o){const r=new Ha;return r._run(()=>r._runAssistantStream(e,t,n,{...o,headers:{...o?.headers,"X-Stainless-Helper-Method":"stream"}})),r}currentEvent(){return So(this,os,"f")}currentRun(){return So(this,rs,"f")}currentMessageSnapshot(){return So(this,Za,"f")}currentRunStepSnapshot(){return So(this,is,"f")}async finalRunSteps(){return await this.done(),Object.values(So(this,Ka,"f"))}async finalMessages(){return await this.done(),Object.values(So(this,Xa,"f"))}async finalRun(){if(await this.done(),!So(this,Ya,"f"))throw Error("Final run was not received.");return So(this,Ya,"f")}async _createThreadAssistantStream(e,t,n){const o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));const r={...t,stream:!0},i=await e.createAndRun(r,{...n,signal:this.controller.signal});this._connected();for await(const e of i)So(this,Va,"m",as).call(this,e);if(i.controller.signal?.aborted)throw new jo;return this._addRun(So(this,Va,"m",ss).call(this))}async _createAssistantStream(e,t,n,o){const r=o?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));const i={...n,stream:!0},a=await e.create(t,i,{...o,signal:this.controller.signal});this._connected();for await(const e of a)So(this,Va,"m",as).call(this,e);if(a.controller.signal?.aborted)throw new jo;return this._addRun(So(this,Va,"m",ss).call(this))}static accumulateDelta(e,t){for(const[n,o]of Object.entries(t)){if(!e.hasOwnProperty(n)){e[n]=o;continue}let t=e[n];if(null!=t)if("index"!==n&&"type"!==n){if("string"==typeof t&&"string"==typeof o)t+=o;else if("number"==typeof t&&"number"==typeof o)t+=o;else{if(!Ho(t)||!Ho(o)){if(Array.isArray(t)&&Array.isArray(o)){if(t.every(e=>"string"==typeof e||"number"==typeof e)){t.push(...o);continue}for(const e of o){if(!Ho(e))throw new Error(`Expected array delta entry to be an object but got: ${e}`);const n=e.index;if(null==n)throw console.error(e),new Error("Expected array delta entry to have an `index` property");if("number"!=typeof n)throw new Error(`Expected array delta entry \`index\` property to be a number but got ${n}`);const o=t[n];null==o?t.push(e):t[n]=this.accumulateDelta(o,e)}continue}throw Error(`Unhandled record type: ${n}, deltaValue: ${o}, accValue: ${t}`)}t=this.accumulateDelta(t,o)}e[n]=t}else e[n]=o;else e[n]=o}return e}_addRun(e){return e}async _threadAssistantStream(e,t,n){return await this._createThreadAssistantStream(t,e,n)}async _runAssistantStream(e,t,n,o){return await this._createAssistantStream(t,e,n,o)}async _runToolAssistantStream(e,t,n,o){return await this._createToolAssistantStream(t,e,n,o)}}Ha=Ss,as=function(e){if(!this.ended)switch(Oo(this,os,e,"f"),So(this,Va,"m",ls).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":So(this,Va,"m",fs).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":So(this,Va,"m",us).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":So(this,Va,"m",cs).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},ss=function(){if(this.ended)throw new Co("stream has ended, this shouldn't happen");if(!So(this,Ya,"f"))throw Error("Final run has not been received");return So(this,Ya,"f")},cs=function(e){const[t,n]=So(this,Va,"m",ps).call(this,e,So(this,Za,"f"));Oo(this,Za,t,"f"),So(this,Xa,"f")[t.id]=t;for(const e of n){const n=t.content[e.index];"text"==n?.type&&this._emit("textCreated",n.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(const n of e.data.delta.content){if("text"==n.type&&n.text){let e=n.text,o=t.content[n.index];if(!o||"text"!=o.type)throw Error("The snapshot associated with this text delta is not text or missing");this._emit("textDelta",e,o.text)}if(n.index!=So(this,Qa,"f")){if(So(this,es,"f"))switch(So(this,es,"f").type){case"text":this._emit("textDone",So(this,es,"f").text,So(this,Za,"f"));break;case"image_file":this._emit("imageFileDone",So(this,es,"f").image_file,So(this,Za,"f"))}Oo(this,Qa,n.index,"f")}Oo(this,es,t.content[n.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==So(this,Qa,"f")){const t=e.data.content[So(this,Qa,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,So(this,Za,"f"));break;case"text":this._emit("textDone",t.text,So(this,Za,"f"))}}So(this,Za,"f")&&this._emit("messageDone",e.data),Oo(this,Za,void 0,"f")}},us=function(e){const t=So(this,Va,"m",ds).call(this,e);switch(Oo(this,is,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":const n=e.data.delta;if(n.step_details&&"tool_calls"==n.step_details.type&&n.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(const e of n.step_details.tool_calls)e.index==So(this,ts,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(So(this,ns,"f")&&this._emit("toolCallDone",So(this,ns,"f")),Oo(this,ts,e.index,"f"),Oo(this,ns,t.step_details.tool_calls[e.index],"f"),So(this,ns,"f")&&this._emit("toolCallCreated",So(this,ns,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":Oo(this,is,void 0,"f");"tool_calls"==e.data.step_details.type&&So(this,ns,"f")&&(this._emit("toolCallDone",So(this,ns,"f")),Oo(this,ns,void 0,"f")),this._emit("runStepDone",e.data,t)}},ls=function(e){So(this,za,"f").push(e),this._emit("event",e)},ds=function(e){switch(e.event){case"thread.run.step.created":return So(this,Ka,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=So(this,Ka,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let n=e.data;if(n.delta){const o=Ha.accumulateDelta(t,n.delta);So(this,Ka,"f")[e.data.id]=o}return So(this,Ka,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":So(this,Ka,"f")[e.data.id]=e.data}if(So(this,Ka,"f")[e.data.id])return So(this,Ka,"f")[e.data.id];throw new Error("No snapshot available")},ps=function(e,t){let n=[];switch(e.event){case"thread.message.created":return[e.data,n];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let o=e.data;if(o.delta.content)for(const e of o.delta.content)if(e.index in t.content){let n=t.content[e.index];t.content[e.index]=So(this,Va,"m",hs).call(this,e,n)}else t.content[e.index]=e,n.push(e);return[t,n];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,n];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},hs=function(e,t){return Ha.accumulateDelta(t,e)},fs=function(e){switch(Oo(this,rs,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.cancelling":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":Oo(this,Ya,e.data,"f"),So(this,ns,"f")&&(this._emit("toolCallDone",So(this,ns,"f")),Oo(this,ns,void 0,"f"))}};class xs extends si{constructor(){super(...arguments),this.steps=new Ba(this._client)}create(e,t,n){const{include:o,...r}=t;return this._client.post(di`/threads/${e}/runs`,{query:{include:o},body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}retrieve(e,t,n){const{thread_id:o}=t;return this._client.get(di`/threads/${o}/runs/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){const{thread_id:o,...r}=t;return this._client.post(di`/threads/${o}/runs/${e}`,{body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(di`/threads/${e}/runs`,Vr,{query:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,t,n){const{thread_id:o}=t;return this._client.post(di`/threads/${o}/runs/${e}/cancel`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){const o=await this.create(e,t,n);return await this.poll(o.id,{thread_id:e},n)}createAndStream(e,t,n){return Ss.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){const o=Ea([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:r,response:i}=await this.retrieve(e,t,{...n,headers:{...n?.headers,...o}}).withResponse();switch(r.status){case"queued":case"in_progress":case"cancelling":let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{const t=i.headers.get("openai-poll-after-ms");if(t){const n=parseInt(t);isNaN(n)||(e=n)}}await zo(e);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return r}}}stream(e,t,n){return Ss.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n){const{thread_id:o,...r}=t;return this._client.post(di`/threads/${o}/runs/${e}/submit_tool_outputs`,{body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(e,t,n){const o=await this.submitToolOutputs(e,t,n);return await this.poll(o.id,t,n)}submitToolOutputsStream(e,t,n){return Ss.createToolAssistantStream(e,this._client.beta.threads.runs,t,n)}}xs.Steps=Ba;class Ts extends si{constructor(){super(...arguments),this.runs=new xs(this._client),this.messages=new Ja(this._client)}create(e={},t){return this._client.post("/threads",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(di`/threads/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(di`/threads/${e}`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t){return this._client.delete(di`/threads/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers]),stream:e.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(e,t){const n=await this.createAndRun(e,t);return await this.runs.poll(n.id,{thread_id:n.thread_id},t)}createAndRunStream(e,t){return Ss.createThreadAssistantStream(e,this._client.beta.threads,t)}}Ts.Runs=xs,Ts.Messages=Ja;class Ps extends si{constructor(){super(...arguments),this.realtime=new La(this._client),this.chatkit=new Wa(this._client),this.assistants=new $a(this._client),this.threads=new Ts(this._client)}}Ps.Realtime=La,Ps.ChatKit=Wa,Ps.Assistants=$a,Ps.Threads=Ts;class Cs extends si{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}class ks extends si{retrieve(e,t,n){const{container_id:o}=t;return this._client.get(di`/containers/${o}/files/${e}/content`,{...n,headers:Ea([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}}class js extends si{constructor(){super(...arguments),this.content=new ks(this._client)}create(e,t,n){return this._client.post(di`/containers/${e}/files`,Yr({body:t,...n},this._client))}retrieve(e,t,n){const{container_id:o}=t;return this._client.get(di`/containers/${o}/files/${e}`,n)}list(e,t={},n){return this._client.getAPIList(di`/containers/${e}/files`,Vr,{query:t,...n})}delete(e,t,n){const{container_id:o}=t;return this._client.delete(di`/containers/${o}/files/${e}`,{...n,headers:Ea([{Accept:"*/*"},n?.headers])})}}js.Content=ks;class Es extends si{constructor(){super(...arguments),this.files=new js(this._client)}create(e,t){return this._client.post("/containers",{body:e,...t})}retrieve(e,t){return this._client.get(di`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList("/containers",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/containers/${e}`,{...t,headers:Ea([{Accept:"*/*"},t?.headers])})}}Es.Files=js;class Rs extends si{create(e,t,n){const{include:o,...r}=t;return this._client.post(di`/conversations/${e}/items`,{query:{include:o},body:r,...n})}retrieve(e,t,n){const{conversation_id:o,...r}=t;return this._client.get(di`/conversations/${o}/items/${e}`,{query:r,...n})}list(e,t={},n){return this._client.getAPIList(di`/conversations/${e}/items`,Hr,{query:t,...n})}delete(e,t,n){const{conversation_id:o}=t;return this._client.delete(di`/conversations/${o}/items/${e}`,n)}}class As extends si{constructor(){super(...arguments),this.items=new Rs(this._client)}create(e={},t){return this._client.post("/conversations",{body:e,...t})}retrieve(e,t){return this._client.get(di`/conversations/${e}`,t)}update(e,t,n){return this._client.post(di`/conversations/${e}`,{body:t,...n})}delete(e,t){return this._client.delete(di`/conversations/${e}`,t)}}As.Items=Rs;class Is extends si{create(e,t){const n=!!e.encoding_format;let o=n?e.encoding_format:"base64";n&&Ir(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);const r=this._client.post("/embeddings",{body:{...e,encoding_format:o},...t});return n?r:(Ir(this._client).debug("embeddings/decoding base64 embeddings from base64"),r._thenUnwrap(e=>(e&&e.data&&e.data.forEach(e=>{const t=e.embedding;e.embedding=(e=>{if("undefined"!=typeof Buffer){const t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}{const t=atob(e),n=t.length,o=new Uint8Array(n);for(let e=0;e<n;e++)o[e]=t.charCodeAt(e);return Array.from(new Float32Array(o.buffer))}})(t)}),e)))}}class Ms extends si{retrieve(e,t,n){const{eval_id:o,run_id:r}=t;return this._client.get(di`/evals/${o}/runs/${r}/output_items/${e}`,n)}list(e,t,n){const{eval_id:o,...r}=t;return this._client.getAPIList(di`/evals/${o}/runs/${e}/output_items`,Vr,{query:r,...n})}}class Ns extends si{constructor(){super(...arguments),this.outputItems=new Ms(this._client)}create(e,t,n){return this._client.post(di`/evals/${e}/runs`,{body:t,...n})}retrieve(e,t,n){const{eval_id:o}=t;return this._client.get(di`/evals/${o}/runs/${e}`,n)}list(e,t={},n){return this._client.getAPIList(di`/evals/${e}/runs`,Vr,{query:t,...n})}delete(e,t,n){const{eval_id:o}=t;return this._client.delete(di`/evals/${o}/runs/${e}`,n)}cancel(e,t,n){const{eval_id:o}=t;return this._client.post(di`/evals/${o}/runs/${e}`,n)}}Ns.OutputItems=Ms;class $s extends si{constructor(){super(...arguments),this.runs=new Ns(this._client)}create(e,t){return this._client.post("/evals",{body:e,...t})}retrieve(e,t){return this._client.get(di`/evals/${e}`,t)}update(e,t,n){return this._client.post(di`/evals/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/evals",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/evals/${e}`,t)}}$s.Runs=Ns;class Ds extends si{create(e,t){return this._client.post("/files",Qr({body:e,...t},this._client))}retrieve(e,t){return this._client.get(di`/files/${e}`,t)}list(e={},t){return this._client.getAPIList("/files",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/files/${e}`,t)}content(e,t){return this._client.get(di`/files/${e}/content`,{...t,headers:Ea([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:n=18e5}={}){const o=new Set(["processed","error","deleted"]),r=Date.now();let i=await this.retrieve(e);for(;!i.status||!o.has(i.status);)if(await zo(t),i=await this.retrieve(e),Date.now()-r>n)throw new Ro({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return i}}class Us extends si{}class Ls extends si{run(e,t){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...t})}validate(e,t){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...t})}}class qs extends si{constructor(){super(...arguments),this.graders=new Ls(this._client)}}qs.Graders=Ls;class Fs extends si{create(e,t,n){return this._client.getAPIList(di`/fine_tuning/checkpoints/${e}/permissions`,Gr,{body:t,method:"post",...n})}retrieve(e,t={},n){return this._client.get(di`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...n})}list(e,t={},n){return this._client.getAPIList(di`/fine_tuning/checkpoints/${e}/permissions`,Hr,{query:t,...n})}delete(e,t,n){const{fine_tuned_model_checkpoint:o}=t;return this._client.delete(di`/fine_tuning/checkpoints/${o}/permissions/${e}`,n)}}class Ws extends si{constructor(){super(...arguments),this.permissions=new Fs(this._client)}}Ws.Permissions=Fs;class Js extends si{list(e,t={},n){return this._client.getAPIList(di`/fine_tuning/jobs/${e}/checkpoints`,Vr,{query:t,...n})}}class Bs extends si{constructor(){super(...arguments),this.checkpoints=new Js(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(di`/fine_tuning/jobs/${e}`,t)}list(e={},t){return this._client.getAPIList("/fine_tuning/jobs",Vr,{query:e,...t})}cancel(e,t){return this._client.post(di`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},n){return this._client.getAPIList(di`/fine_tuning/jobs/${e}/events`,Vr,{query:t,...n})}pause(e,t){return this._client.post(di`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(di`/fine_tuning/jobs/${e}/resume`,t)}}Bs.Checkpoints=Js;class Gs extends si{constructor(){super(...arguments),this.methods=new Us(this._client),this.jobs=new Bs(this._client),this.checkpoints=new Ws(this._client),this.alpha=new qs(this._client)}}Gs.Methods=Us,Gs.Jobs=Bs,Gs.Checkpoints=Ws,Gs.Alpha=qs;class Vs extends si{}class Hs extends si{constructor(){super(...arguments),this.graderModels=new Vs(this._client)}}Hs.GraderModels=Vs;class zs extends si{createVariation(e,t){return this._client.post("/images/variations",Qr({body:e,...t},this._client))}edit(e,t){return this._client.post("/images/edits",Qr({body:e,...t,stream:e.stream??!1},this._client))}generate(e,t){return this._client.post("/images/generations",{body:e,...t,stream:e.stream??!1})}}class Ks extends si{retrieve(e,t){return this._client.get(di`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",Gr,e)}delete(e,t){return this._client.delete(di`/models/${e}`,t)}}class Xs extends si{create(e,t){return this._client.post("/moderations",{body:e,...t})}}class Zs extends si{accept(e,t,n){return this._client.post(di`/realtime/calls/${e}/accept`,{body:t,...n,headers:Ea([{Accept:"*/*"},n?.headers])})}hangup(e,t){return this._client.post(di`/realtime/calls/${e}/hangup`,{...t,headers:Ea([{Accept:"*/*"},t?.headers])})}refer(e,t,n){return this._client.post(di`/realtime/calls/${e}/refer`,{body:t,...n,headers:Ea([{Accept:"*/*"},n?.headers])})}reject(e,t={},n){return this._client.post(di`/realtime/calls/${e}/reject`,{body:t,...n,headers:Ea([{Accept:"*/*"},n?.headers])})}}class Ys extends si{create(e,t){return this._client.post("/realtime/client_secrets",{body:e,...t})}}class Qs extends si{constructor(){super(...arguments),this.clientSecrets=new Ys(this._client),this.calls=new Zs(this._client)}}function ec(e,t){return t&&function(e){if(fi(e.text?.format))return!0;return!1}(t)?tc(e,t):{...e,output_parsed:null,output:e.output.map(e=>"function_call"===e.type?{...e,parsed_arguments:null}:"message"===e.type?{...e,content:e.content.map(e=>({...e,parsed:null}))}:e)}}function tc(e,t){const n=e.output.map(e=>{if("function_call"===e.type)return{...e,parsed_arguments:ic(t,e)};if("message"===e.type){const n=e.content.map(e=>"output_text"===e.type?{...e,parsed:nc(t,e.text)}:e);return{...e,content:n}}return e}),o=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,"output_text")||ac(o),Object.defineProperty(o,"output_parsed",{enumerable:!0,get(){for(const e of o.output)if("message"===e.type)for(const t of e.content)if("output_text"===t.type&&null!==t.parsed)return t.parsed;return null}}),o}function nc(e,t){if("json_schema"!==e.text?.format?.type)return null;if("$parseRaw"in e.text?.format){const n=e.text?.format;return n.$parseRaw(t)}return JSON.parse(t)}function oc(e){return"auto-parseable-tool"===e?.$brand}function rc(e,t){return e.find(e=>"function"===e.type&&e.name===t)}function ic(e,t){const n=rc(e.tools??[],t.name);return{...t,...t,parsed_arguments:oc(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}function ac(e){const t=[];for(const n of e.output)if("message"===n.type)for(const e of n.content)"output_text"===e.type&&t.push(e.text);e.output_text=t.join("")}Qs.ClientSecrets=Ys,Qs.Calls=Zs;class sc extends Bi{constructor(e){super(),ms.add(this),gs.set(this,void 0),bs.set(this,void 0),ys.set(this,void 0),Oo(this,gs,e,"f")}static createResponse(e,t,n){const o=new sc(t);return o._run(()=>o._createOrRetrieveResponse(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}async _createOrRetrieveResponse(e,t,n){const o=n?.signal;let r;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort())),So(this,ms,"m",vs).call(this);let i=null;"response_id"in t?(r=await e.responses.retrieve(t.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),i=t.starting_after??null):r=await e.responses.create({...t,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(const e of r)So(this,ms,"m",_s).call(this,e,i);if(r.controller.signal?.aborted)throw new jo;return So(this,ms,"m",ws).call(this)}[(gs=new WeakMap,bs=new WeakMap,ys=new WeakMap,ms=new WeakSet,vs=function(){this.ended||Oo(this,bs,void 0,"f")},_s=function(e,t){if(this.ended)return;const n=(e,n)=>{(null==t||n.sequence_number>t)&&this._emit(e,n)},o=So(this,ms,"m",Os).call(this,e);switch(n("event",e),e.type){case"response.output_text.delta":{const t=o.output[e.output_index];if(!t)throw new Co(`missing output at index ${e.output_index}`);if("message"===t.type){const o=t.content[e.content_index];if(!o)throw new Co(`missing content at index ${e.content_index}`);if("output_text"!==o.type)throw new Co(`expected content to be 'output_text', got ${o.type}`);n("response.output_text.delta",{...e,snapshot:o.text})}break}case"response.function_call_arguments.delta":{const t=o.output[e.output_index];if(!t)throw new Co(`missing output at index ${e.output_index}`);"function_call"===t.type&&n("response.function_call_arguments.delta",{...e,snapshot:t.arguments});break}default:n(e.type,e)}},ws=function(){if(this.ended)throw new Co("stream has ended, this shouldn't happen");const e=So(this,bs,"f");if(!e)throw new Co("request ended without sending any events");Oo(this,bs,void 0,"f");const t=function(e,t){return ec(e,t)}(e,So(this,gs,"f"));return Oo(this,ys,t,"f"),t},Os=function(e){let t=So(this,bs,"f");if(!t){if("response.created"!==e.type)throw new Co(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return t=Oo(this,bs,e.response,"f"),t}switch(e.type){case"response.output_item.added":t.output.push(e.item);break;case"response.content_part.added":{const n=t.output[e.output_index];if(!n)throw new Co(`missing output at index ${e.output_index}`);const o=n.type,r=e.part;"message"===o&&"reasoning_text"!==r.type?n.content.push(r):"reasoning"===o&&"reasoning_text"===r.type&&(n.content||(n.content=[]),n.content.push(r));break}case"response.output_text.delta":{const n=t.output[e.output_index];if(!n)throw new Co(`missing output at index ${e.output_index}`);if("message"===n.type){const t=n.content[e.content_index];if(!t)throw new Co(`missing content at index ${e.content_index}`);if("output_text"!==t.type)throw new Co(`expected content to be 'output_text', got ${t.type}`);t.text+=e.delta}break}case"response.function_call_arguments.delta":{const n=t.output[e.output_index];if(!n)throw new Co(`missing output at index ${e.output_index}`);"function_call"===n.type&&(n.arguments+=e.delta);break}case"response.reasoning_text.delta":{const n=t.output[e.output_index];if(!n)throw new Co(`missing output at index ${e.output_index}`);if("reasoning"===n.type){const t=n.content?.[e.content_index];if(!t)throw new Co(`missing content at index ${e.content_index}`);if("reasoning_text"!==t.type)throw new Co(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case"response.completed":Oo(this,bs,e.response,"f")}return t},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("event",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();const e=So(this,ys,"f");if(!e)throw new Co("stream ended without producing a ChatCompletion");return e}}class cc extends si{list(e,t={},n){return this._client.getAPIList(di`/responses/${e}/input_items`,Vr,{query:t,...n})}}class uc extends si{count(e={},t){return this._client.post("/responses/input_tokens",{body:e,...t})}}class lc extends si{constructor(){super(...arguments),this.inputItems=new cc(this._client),this.inputTokens=new uc(this._client)}create(e,t){return this._client.post("/responses",{body:e,...t,stream:e.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&ac(e),e))}retrieve(e,t={},n){return this._client.get(di`/responses/${e}`,{query:t,...n,stream:t?.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&ac(e),e))}delete(e,t){return this._client.delete(di`/responses/${e}`,{...t,headers:Ea([{Accept:"*/*"},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>tc(t,e))}stream(e,t){return sc.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(di`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post("/responses/compact",{body:e,...t})}}lc.InputItems=cc,lc.InputTokens=uc;class dc extends si{retrieve(e,t){return this._client.get(di`/skills/${e}/content`,{...t,headers:Ea([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}}class pc extends si{retrieve(e,t,n){const{skill_id:o}=t;return this._client.get(di`/skills/${o}/versions/${e}/content`,{...n,headers:Ea([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}}class hc extends si{constructor(){super(...arguments),this.content=new pc(this._client)}create(e,t={},n){return this._client.post(di`/skills/${e}/versions`,Yr({body:t,...n},this._client))}retrieve(e,t,n){const{skill_id:o}=t;return this._client.get(di`/skills/${o}/versions/${e}`,n)}list(e,t={},n){return this._client.getAPIList(di`/skills/${e}/versions`,Vr,{query:t,...n})}delete(e,t,n){const{skill_id:o}=t;return this._client.delete(di`/skills/${o}/versions/${e}`,n)}}hc.Content=pc;class fc extends si{constructor(){super(...arguments),this.content=new dc(this._client),this.versions=new hc(this._client)}create(e={},t){return this._client.post("/skills",Yr({body:e,...t},this._client))}retrieve(e,t){return this._client.get(di`/skills/${e}`,t)}update(e,t,n){return this._client.post(di`/skills/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/skills",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/skills/${e}`,t)}}fc.Content=dc,fc.Versions=hc;class mc extends si{create(e,t,n){return this._client.post(di`/uploads/${e}/parts`,Qr({body:t,...n},this._client))}}class gc extends si{constructor(){super(...arguments),this.parts=new mc(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(di`/uploads/${e}/cancel`,t)}complete(e,t,n){return this._client.post(di`/uploads/${e}/complete`,{body:t,...n})}}gc.Parts=mc;class bc extends si{create(e,t,n){return this._client.post(di`/vector_stores/${e}/file_batches`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){const{vector_store_id:o}=t;return this._client.get(di`/vector_stores/${o}/file_batches/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,t,n){const{vector_store_id:o}=t;return this._client.post(di`/vector_stores/${o}/file_batches/${e}/cancel`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){const o=await this.create(e,t);return await this.poll(e,o.id,n)}listFiles(e,t,n){const{vector_store_id:o,...r}=t;return this._client.getAPIList(di`/vector_stores/${o}/file_batches/${e}/files`,Vr,{query:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async poll(e,t,n){const o=Ea([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:r,response:i}=await this.retrieve(t,{vector_store_id:e},{...n,headers:o}).withResponse();switch(r.status){case"in_progress":let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{const t=i.headers.get("openai-poll-after-ms");if(t){const n=parseInt(t);isNaN(n)||(e=n)}}await zo(e);break;case"failed":case"cancelled":case"completed":return r}}}async uploadAndPoll(e,{files:t,fileIds:n=[]},o){if(null==t||0==t.length)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");const r=o?.maxConcurrency??5,i=Math.min(r,t.length),a=this._client,s=t.values(),c=[...n];const u=Array(i).fill(s).map(async function(e){for(let t of e){const e=await a.files.create({file:t,purpose:"assistants"},o);c.push(e.id)}});return await(async e=>{const t=await Promise.allSettled(e),n=t.filter(e=>"rejected"===e.status);if(n.length){for(const e of n)console.error(e.reason);throw new Error(`${n.length} promise(s) failed - see the above errors`)}const o=[];for(const e of t)"fulfilled"===e.status&&o.push(e.value);return o})(u),await this.createAndPoll(e,{file_ids:c})}}class yc extends si{create(e,t,n){return this._client.post(di`/vector_stores/${e}/files`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){const{vector_store_id:o}=t;return this._client.get(di`/vector_stores/${o}/files/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){const{vector_store_id:o,...r}=t;return this._client.post(di`/vector_stores/${o}/files/${e}`,{body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(di`/vector_stores/${e}/files`,Vr,{query:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t,n){const{vector_store_id:o}=t;return this._client.delete(di`/vector_stores/${o}/files/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){const o=await this.create(e,t,n);return await this.poll(e,o.id,n)}async poll(e,t,n){const o=Ea([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){const r=await this.retrieve(t,{vector_store_id:e},{...n,headers:o}).withResponse(),i=r.data;switch(i.status){case"in_progress":let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{const t=r.response.headers.get("openai-poll-after-ms");if(t){const n=parseInt(t);isNaN(n)||(e=n)}}await zo(e);break;case"failed":case"completed":return i}}}async upload(e,t,n){const o=await this._client.files.create({file:t,purpose:"assistants"},n);return this.create(e,{file_id:o.id},n)}async uploadAndPoll(e,t,n){const o=await this.upload(e,t,n);return await this.poll(e,o.id,n)}content(e,t,n){const{vector_store_id:o}=t;return this._client.getAPIList(di`/vector_stores/${o}/files/${e}/content`,Gr,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}class vc extends si{constructor(){super(...arguments),this.files=new yc(this._client),this.fileBatches=new bc(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(di`/vector_stores/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(di`/vector_stores/${e}`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},t){return this._client.getAPIList("/vector_stores",Vr,{query:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(di`/vector_stores/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}search(e,t,n){return this._client.getAPIList(di`/vector_stores/${e}/search`,Gr,{body:t,method:"post",...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}vc.Files=yc,vc.FileBatches=bc;class _c extends si{create(e,t){return this._client.post("/videos",Yr({body:e,...t},this._client))}retrieve(e,t){return this._client.get(di`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList("/videos",Hr,{query:e,...t})}delete(e,t){return this._client.delete(di`/videos/${e}`,t)}downloadContent(e,t={},n){return this._client.get(di`/videos/${e}/content`,{query:t,...n,headers:Ea([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}remix(e,t,n){return this._client.post(di`/videos/${e}/remix`,Yr({body:t,...n},this._client))}}var wc,Oc,Sc,xc,Tc,Pc,Cc;class kc extends si{constructor(){super(...arguments),wc.add(this)}async unwrap(e,t,n=this._client.webhookSecret,o=300){return await this.verifySignature(e,t,n,o),JSON.parse(e)}async verifySignature(e,t,n=this._client.webhookSecret,o=300){if("undefined"==typeof crypto||"function"!=typeof crypto.subtle.importKey||"function"!=typeof crypto.subtle.verify)throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");So(this,wc,"m",Oc).call(this,n);const r=Ea([t]).values,i=So(this,wc,"m",Sc).call(this,r,"webhook-signature"),a=So(this,wc,"m",Sc).call(this,r,"webhook-timestamp"),s=So(this,wc,"m",Sc).call(this,r,"webhook-id"),c=parseInt(a,10);if(isNaN(c))throw new Wo("Invalid webhook timestamp format");const u=Math.floor(Date.now()/1e3);if(u-c>o)throw new Wo("Webhook timestamp is too old");if(c>u+o)throw new Wo("Webhook timestamp is too new");const l=i.split(" ").map(e=>e.startsWith("v1,")?e.substring(3):e),d=n.startsWith("whsec_")?Buffer.from(n.replace("whsec_",""),"base64"):Buffer.from(n,"utf-8"),p=s?`${s}.${a}.${e}`:`${a}.${e}`,h=await crypto.subtle.importKey("raw",d,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(const e of l)try{const t=Buffer.from(e,"base64");if(await crypto.subtle.verify("HMAC",h,t,(new TextEncoder).encode(p)))return}catch{continue}throw new Wo("The given webhook signature does not match the expected signature")}}wc=new WeakSet,Oc=function(e){if("string"!=typeof e||0===e.length)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},Sc=function(e,t){if(!e)throw new Error("Headers are required");const n=e.get(t);if(null==n)throw new Error(`Missing required header: ${t}`);return n};class jc{constructor({baseURL:e=Ga("OPENAI_BASE_URL"),apiKey:t=Ga("OPENAI_API_KEY"),organization:n=Ga("OPENAI_ORG_ID")??null,project:o=Ga("OPENAI_PROJECT_ID")??null,webhookSecret:r=Ga("OPENAI_WEBHOOK_SECRET")??null,...i}={}){if(xc.add(this),Pc.set(this,void 0),this.completions=new Cs(this),this.chat=new Ca(this),this.embeddings=new Is(this),this.files=new Ds(this),this.images=new zs(this),this.audio=new Ma(this),this.moderations=new Xs(this),this.models=new Ks(this),this.fineTuning=new Gs(this),this.graders=new Hs(this),this.vectorStores=new vc(this),this.webhooks=new kc(this),this.beta=new Ps(this),this.batches=new Na(this),this.uploads=new gc(this),this.responses=new lc(this),this.realtime=new Qs(this),this.conversations=new As(this),this.evals=new $s(this),this.containers=new Es(this),this.skills=new fc(this),this.videos=new _c(this),void 0===t)throw new Co("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");const a={apiKey:t,organization:n,project:o,webhookSecret:r,...i,baseURL:e||"https://api.openai.com/v1"};if(!a.dangerouslyAllowBrowser&&"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator)throw new Co("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");this.baseURL=a.baseURL,this.timeout=a.timeout??Tc.DEFAULT_TIMEOUT,this.logger=a.logger??console;const s="warn";this.logLevel=s,this.logLevel=kr(a.logLevel,"ClientOptions.logLevel",this)??kr(Ga("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??s,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??function(){if("undefined"!=typeof fetch)return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),Oo(this,Pc,or,"f"),this._options=a,this.apiKey="string"==typeof t?t:"Missing Key",this.organization=n,this.project=o,this.webhookSecret=r}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){}async authHeaders(e){return Ea([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return function(e){return br(e,{arrayFormat:"brackets"})}(e)}getUserAgent(){return`${this.constructor.name}/JS ${Ko}`}defaultIdempotencyKey(){return`stainless-node-retry-${xo()}`}makeStatusError(e,t,n,o){return ko.generate(e,t,n,o)}async _callApiKey(){const e=this._options.apiKey;if("function"!=typeof e)return!1;let t;try{t=await e()}catch(e){if(e instanceof Co)throw e;throw new Co(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if("string"!=typeof t||!t)throw new Co(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,n){const o=!So(this,xc,"m",Cc).call(this)&&n||this.baseURL,r=(e=>Jo.test(e))(e)?new URL(e):new URL(o+(o.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return function(e){if(!e)return!0;for(const t in e)return!1;return!0}(i)||(t={...i,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(r.search=this.stringifyQuery(t)),r.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new Wr(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){const o=await e,r=o.maxRetries??this.maxRetries;null==t&&(t=r),await this.prepareOptions(o);const{req:i,url:a,timeout:s}=await this.buildRequest(o,{retryCount:r-t});await this.prepareRequest(i,{url:a,options:o});const c="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=void 0===n?"":`, retryOf: ${n}`,l=Date.now();if(Ir(this).debug(`[${c}] sending request`,Mr({retryOfRequestLogID:n,method:o.method,url:a,options:o,headers:i.headers})),o.signal?.aborted)throw new jo;const d=new AbortController,p=await this.fetchWithTimeout(a,i,s,d).catch(Po),h=Date.now();if(p instanceof globalThis.Error){const e=`retrying, ${t} attempts remaining`;if(o.signal?.aborted)throw new jo;const r=To(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(t)return Ir(this).info(`[${c}] connection ${r?"timed out":"failed"} - ${e}`),Ir(this).debug(`[${c}] connection ${r?"timed out":"failed"} (${e})`,Mr({retryOfRequestLogID:n,url:a,durationMs:h-l,message:p.message})),this.retryRequest(o,t,n??c);if(Ir(this).info(`[${c}] connection ${r?"timed out":"failed"} - error; no more retries left`),Ir(this).debug(`[${c}] connection ${r?"timed out":"failed"} (error; no more retries left)`,Mr({retryOfRequestLogID:n,url:a,durationMs:h-l,message:p.message})),r)throw new Ro;throw new Eo({cause:p})}const f=`[${c}${u}${[...p.headers.entries()].filter(([e])=>"x-request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join("")}] ${i.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-l}ms`;if(!p.ok){const e=await this.shouldRetry(p);if(t&&e){const e=`retrying, ${t} attempts remaining`;return await async function(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await(e[Symbol.asyncIterator]().return?.());const t=e.getReader(),n=t.cancel();t.releaseLock(),await n}(p.body),Ir(this).info(`${f} - ${e}`),Ir(this).debug(`[${c}] response error (${e})`,Mr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-l})),this.retryRequest(o,t,n??c,p.headers)}const r=e?"error; no more retries left":"error; not retryable";Ir(this).info(`${f} - ${r}`);const i=await p.text().catch(e=>Po(e).message),a=(e=>{try{return JSON.parse(e)}catch(e){return}})(i),s=a?void 0:i;Ir(this).debug(`[${c}] response error (${r})`,Mr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:s,durationMs:Date.now()-l}));throw this.makeStatusError(p.status,a,s,p.headers)}return Ir(this).info(f),Ir(this).debug(`[${c}] response start`,Mr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-l})),{response:p,options:o,controller:d,requestLogID:c,retryOfRequestLogID:n,startTime:l}}getAPIList(e,t,n){return this.requestAPIList(t,n&&"then"in n?n.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...n})}requestAPIList(e,t){const n=this.makeRequest(t,null,void 0);return new Br(this,n,e)}async fetchWithTimeout(e,t,n,o){const{signal:r,method:i,...a}=t||{},s=this._makeAbort(o);r&&r.addEventListener("abort",s,{once:!0});const c=setTimeout(s,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||"object"==typeof a.body&&null!==a.body&&Symbol.asyncIterator in a.body,l={signal:o.signal,...u?{duplex:"half"}:{},method:"GET",...a};i&&(l.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,l)}finally{clearTimeout(c)}}async shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||(409===e.status||(429===e.status||e.status>=500)))}async retryRequest(e,t,n,o){let r;const i=o?.get("retry-after-ms");if(i){const e=parseFloat(i);Number.isNaN(e)||(r=e)}const a=o?.get("retry-after");if(a&&!r){const e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}if(void 0===r){const n=e.maxRetries??this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,n)}return await zo(r),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){const n=t-e;return Math.min(.5*Math.pow(2,n),8)*(1-.25*Math.random())*1e3}async buildRequest(e,{retryCount:t=0}={}){const n={...e},{method:o,path:r,query:i,defaultBaseURL:a}=n,s=this.buildURL(r,i,a);"timeout"in n&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new Co(`${e} must be an integer`);if(t<0)throw new Co(`${e} must be a positive integer`)})("timeout",n.timeout),n.timeout=n.timeout??this.timeout;const{bodyHeaders:c,body:u}=this.buildBody({options:n});return{req:{method:o,headers:await this.buildHeaders({options:e,method:o,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:o}){let r={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);const i=Ea([r,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(o),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Qo??(Qo=Xo()),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(i),i.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};const n=Ea([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:tr(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===n.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:So(this,Pc,"f").call(this,{body:e,headers:n})}}Tc=jc,Pc=new WeakMap,xc=new WeakSet,Cc=function(){return"https://api.openai.com/v1"!==this.baseURL},jc.OpenAI=Tc,jc.DEFAULT_TIMEOUT=6e5,jc.OpenAIError=Co,jc.APIError=ko,jc.APIConnectionError=Eo,jc.APIConnectionTimeoutError=Ro,jc.APIUserAbortError=jo,jc.NotFoundError=No,jc.ConflictError=$o,jc.RateLimitError=Uo,jc.BadRequestError=Ao,jc.AuthenticationError=Io,jc.InternalServerError=Lo,jc.PermissionDeniedError=Mo,jc.UnprocessableEntityError=Do,jc.InvalidWebhookSignatureError=Wo,jc.toFile=async function(e,t,n){if(zr(),(e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&ii(e))(e=await e))return e instanceof File?e:Kr([await e.arrayBuffer()],e.name);if((e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob)(e)){const o=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Kr(await ai(o),t,n)}const o=await ai(e);if(t||(t=Xr(e)),!n?.type){const e=o.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(n={...n,type:e})}return Kr(o,t,n)},jc.Completions=Cs,jc.Chat=Ca,jc.Embeddings=Is,jc.Files=Ds,jc.Images=zs,jc.Audio=Ma,jc.Moderations=Xs,jc.Models=Ks,jc.FineTuning=Gs,jc.Graders=Hs,jc.VectorStores=vc,jc.Webhooks=kc,jc.Beta=Ps,jc.Batches=Na,jc.Uploads=gc,jc.Responses=lc,jc.Realtime=Qs,jc.Conversations=As,jc.Evals=$s,jc.Containers=Es,jc.Skills=fc,jc.Videos=_c;class Ec extends jc{constructor({baseURL:e=Ga("OPENAI_BASE_URL"),apiKey:t=Ga("AZURE_OPENAI_API_KEY"),apiVersion:n=Ga("OPENAI_API_VERSION"),endpoint:o,deployment:r,azureADTokenProvider:i,dangerouslyAllowBrowser:a,...s}={}){if(!n)throw new Co("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if("function"==typeof i&&(a=!0),!i&&!t)throw new Co("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(i&&t)throw new Co("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(s.defaultQuery={...s.defaultQuery,"api-version":n},e){if(o)throw new Co("baseURL and endpoint are mutually exclusive")}else{if(o||(o=process.env.AZURE_OPENAI_ENDPOINT),!o)throw new Co("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");e=`${o}/openai`}super({apiKey:i??t,baseURL:e,...s,...void 0!==a?{dangerouslyAllowBrowser:a}:{}}),this.apiVersion="",this.apiVersion=n,this.deploymentName=r}async buildRequest(e,t={}){if(Rc.has(e.path)&&"post"===e.method&&void 0!==e.body){if(!Ho(e.body))throw new Error("Expected request body to be an object");const t=this.deploymentName||e.body.model||e.__metadata?.model;void 0===t||this.baseURL.includes("/deployments")||(e.path=`/deployments/${t}${e.path}`)}return super.buildRequest(e,t)}async authHeaders(e){return"string"==typeof this._options.apiKey?Ea([{"api-key":this.apiKey}]):super.authHeaders(e)}}const Rc=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);function Ac(e){let t=3735928559,n=1103547991;for(let o=0;o<e.length;o++){const r=e.charCodeAt(o);t=Math.imul(t^r,2654435761),n=Math.imul(n^r,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(n>>>0).toString(36)+(t>>>0).toString(36)}function Ic(e,t){const n={v:1,id:e};return t&&(n.phase=t),JSON.stringify(n)}function Mc(e){if(e){if(e.startsWith("{"))try{const t=JSON.parse(e);if(1===t.v&&"string"==typeof t.id)return"commentary"===t.phase||"final_answer"===t.phase?{id:t.id,phase:t.phase}:{id:t.id}}catch{}return{id:e}}}function Nc(e,t,n,o){const r=[],i=so(t.messages,e,t=>{if(!n.has(e.provider))return t;if(!t.includes("|"))return t;const[o,r]=t.split("|"),i=o.replace(/[^a-zA-Z0-9_-]/g,"_");let a=r.replace(/[^a-zA-Z0-9_-]/g,"_");a.startsWith("fc")||(a=`fc_${a}`);let s=i.length>64?i.slice(0,64):i,c=a.length>64?a.slice(0,64):a;return s=s.replace(/_+$/,""),c=c.replace(/_+$/,""),`${s}|${c}`});if((o?.includeSystemPrompt??!0)&&t.systemPrompt){const n=e.reasoning?"developer":"system";r.push({role:n,content:to(t.systemPrompt)})}let a=0;for(const t of i){if("user"===t.role)if("string"==typeof t.content)r.push({role:"user",content:[{type:"input_text",text:to(t.content)}]});else{const n=t.content.map(e=>"text"===e.type?{type:"input_text",text:to(e.text)}:{type:"input_image",detail:"auto",image_url:`data:${e.mimeType};base64,${e.data}`}),o=e.input.includes("image")?n:n.filter(e=>"input_image"!==e.type);if(0===o.length)continue;r.push({role:"user",content:o})}else if("assistant"===t.role){const n=[],o=t,i=o.model!==e.id&&o.provider===e.provider&&o.api===e.api;for(const e of t.content)if("thinking"===e.type){if(e.thinkingSignature){const t=JSON.parse(e.thinkingSignature);n.push(t)}}else if("text"===e.type){const t=e,o=Mc(t.textSignature);let r=o?.id;r?r.length>64&&(r=`msg_${Ac(r)}`):r=`msg_${a}`,n.push({type:"message",role:"assistant",content:[{type:"output_text",text:to(t.text),annotations:[]}],status:"completed",id:r,phase:o?.phase})}else if("toolCall"===e.type){const t=e,[o,r]=t.id.split("|");let a=r;i&&a?.startsWith("fc_")&&(a=void 0),n.push({type:"function_call",id:a,call_id:o,name:t.name,arguments:JSON.stringify(t.arguments)})}if(0===n.length)continue;r.push(...n)}else if("toolResult"===t.role){const n=t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),o=t.content.some(e=>"image"===e.type),i=n.length>0,[a]=t.toolCallId.split("|");if(r.push({type:"function_call_output",call_id:a,output:to(i?n:"(see attached image)")}),o&&e.input.includes("image")){const e=[];e.push({type:"input_text",text:"Attached image(s) from tool result:"});for(const n of t.content)"image"===n.type&&e.push({type:"input_image",detail:"auto",image_url:`data:${n.mimeType};base64,${n.data}`});r.push({role:"user",content:e})}}a++}return r}function $c(e,t){const n=void 0!==t?.strict&&t.strict;return e.map(e=>({type:"function",name:e.name,description:e.description,parameters:e.parameters,strict:n}))}async function Dc(e,t,n,o,r){let i=null,a=null;const s=t.content,c=()=>s.length-1;for await(const s of e)if("response.output_item.added"===s.type){const e=s.item;"reasoning"===e.type?(i=e,a={type:"thinking",thinking:""},t.content.push(a),n.push({type:"thinking_start",contentIndex:c(),partial:t})):"message"===e.type?(i=e,a={type:"text",text:""},t.content.push(a),n.push({type:"text_start",contentIndex:c(),partial:t})):"function_call"===e.type&&(i=e,a={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},partialJson:e.arguments||""},t.content.push(a),n.push({type:"toolcall_start",contentIndex:c(),partial:t}))}else if("response.reasoning_summary_part.added"===s.type)i&&"reasoning"===i.type&&(i.summary=i.summary||[],i.summary.push(s.part));else if("response.reasoning_summary_text.delta"===s.type){if("reasoning"===i?.type&&"thinking"===a?.type){i.summary=i.summary||[];const e=i.summary[i.summary.length-1];e&&(a.thinking+=s.delta,e.text+=s.delta,n.push({type:"thinking_delta",contentIndex:c(),delta:s.delta,partial:t}))}}else if("response.reasoning_summary_part.done"===s.type){if("reasoning"===i?.type&&"thinking"===a?.type){i.summary=i.summary||[];const e=i.summary[i.summary.length-1];e&&(a.thinking+="\n\n",e.text+="\n\n",n.push({type:"thinking_delta",contentIndex:c(),delta:"\n\n",partial:t}))}}else if("response.content_part.added"===s.type)"message"===i?.type&&(i.content=i.content||[],"output_text"!==s.part.type&&"refusal"!==s.part.type||i.content.push(s.part));else if("response.output_text.delta"===s.type){if("message"===i?.type&&"text"===a?.type){if(!i.content||0===i.content.length)continue;const e=i.content[i.content.length-1];"output_text"===e?.type&&(a.text+=s.delta,e.text+=s.delta,n.push({type:"text_delta",contentIndex:c(),delta:s.delta,partial:t}))}}else if("response.refusal.delta"===s.type){if("message"===i?.type&&"text"===a?.type){if(!i.content||0===i.content.length)continue;const e=i.content[i.content.length-1];"refusal"===e?.type&&(a.text+=s.delta,e.refusal+=s.delta,n.push({type:"text_delta",contentIndex:c(),delta:s.delta,partial:t}))}}else if("response.function_call_arguments.delta"===s.type)"function_call"===i?.type&&"toolCall"===a?.type&&(a.partialJson+=s.delta,a.arguments=eo(a.partialJson),n.push({type:"toolcall_delta",contentIndex:c(),delta:s.delta,partial:t}));else if("response.function_call_arguments.done"===s.type)"function_call"===i?.type&&"toolCall"===a?.type&&(a.partialJson=s.arguments,a.arguments=eo(a.partialJson));else if("response.output_item.done"===s.type){const e=s.item;if("reasoning"===e.type&&"thinking"===a?.type)a.thinking=e.summary?.map(e=>e.text).join("\n\n")||"",a.thinkingSignature=JSON.stringify(e),n.push({type:"thinking_end",contentIndex:c(),content:a.thinking,partial:t}),a=null;else if("message"===e.type&&"text"===a?.type)a.text=e.content.map(e=>"output_text"===e.type?e.text:e.refusal).join(""),a.textSignature=Ic(e.id,e.phase??void 0),n.push({type:"text_end",contentIndex:c(),content:a.text,partial:t}),a=null;else if("function_call"===e.type){const o="toolCall"===a?.type&&a.partialJson?eo(a.partialJson):eo(e.arguments||"{}"),r={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:o};a=null,n.push({type:"toolcall_end",contentIndex:c(),toolCall:r,partial:t})}}else if("response.completed"===s.type){const e=s.response;if(e?.usage){const n=e.usage.input_tokens_details?.cached_tokens||0;t.usage={input:(e.usage.input_tokens||0)-n,output:e.usage.output_tokens||0,cacheRead:n,cacheWrite:0,totalTokens:e.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(S(o,t.usage),r?.applyServiceTierPricing){const n=e?.service_tier??r.serviceTier;r.applyServiceTierPricing(t.usage,n)}t.stopReason=Uc(e?.status),t.content.some(e=>"toolCall"===e.type)&&"stop"===t.stopReason&&(t.stopReason="toolUse")}else{if("error"===s.type)throw new Error(`Error Code ${s.code}: ${s.message}`||"Unknown error");if("response.failed"===s.type)throw new Error("Unknown error")}}function Uc(e){if(!e)return"stop";switch(e){case"completed":case"in_progress":case"queued":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";default:throw new Error(`Unhandled stop reason: ${e}`)}}const Lc=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function qc(e,t){if(t?.azureDeploymentName)return t.azureDeploymentName;return function(e){const t=new Map;if(!e)return t;for(const n of e.split(",")){const e=n.trim();if(!e)continue;const[o,r]=e.split("=",2);o&&r&&t.set(o.trim(),r.trim())}return t}(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}const Fc=(e,t,n)=>{const o=new Zn;return(async()=>{const r=qc(e,n),i={role:"assistant",content:[],api:"azure-openai-responses",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const a=n?.apiKey||b(e.provider)||"",s=function(e,t,n){if(!t){if(!process.env.AZURE_OPENAI_API_KEY)throw new Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");t=process.env.AZURE_OPENAI_API_KEY}const o={...e.headers};n?.headers&&Object.assign(o,n.headers);const{baseUrl:r,apiVersion:i}=function(e,t){const n=t?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||"v1",o=t?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,r=t?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME;let i=o;!i&&r&&(i=function(e){return`https://${e}.openai.azure.com/openai/v1`}(r));!i&&e.baseUrl&&(i=e.baseUrl);if(!i)throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:Jc(i),apiVersion:n}}(e,n);return new Ec({apiKey:t,apiVersion:i,dangerouslyAllowBrowser:!0,defaultHeaders:o,baseURL:r})}(e,a,n);let c=function(e,t,n,o){const r=Nc(e,t,Lc),i={model:o,input:r,stream:!0,prompt_cache_key:n?.sessionId};n?.maxTokens&&(i.max_output_tokens=n?.maxTokens);void 0!==n?.temperature&&(i.temperature=n?.temperature);t.tools&&(i.tools=$c(t.tools));e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||"medium",summary:n?.reasoningSummary||"auto"},i.include=["reasoning.encrypted_content"]):e.name.toLowerCase().startsWith("gpt-5")&&r.push({role:"developer",content:[{type:"input_text",text:"# Juice: 0 !important"}]}));return i}(e,t,n,r);const u=await(n?.onPayload?.(c,e));void 0!==u&&(c=u);const l=await s.responses.create(c,n?.signal?{signal:n.signal}:void 0);if(o.push({type:"start",partial:i}),await Dc(l,i,o,e),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===i.stopReason||"error"===i.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:i.stopReason,message:i}),o.end()}catch(e){for(const e of i.content)delete e.index;i.stopReason=n?.signal?.aborted?"aborted":"error",i.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:i.stopReason,error:i}),o.end()}})(),o},Wc=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=x(e)?n?.reasoning:ao(n?.reasoning);return Fc(e,t,{...r,reasoningEffort:i})};function Jc(e){return e.replace(/\/+$/,"")}var Bc=n(12103),Gc=n(492),Vc=n(79896),Hc=n(91943),zc=n(57075),Kc=n(46466),Xc=(n(86412),n(20893),n(7389),n(56681));n(70129);var Zc=n(16928);
|
|
9
|
+
var o=n(20181),r=o.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return r(e,t,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?e.exports=o:(i(o,t),t.Buffer=a),a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return r(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=r(e);return void 0!==t?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o.SlowBuffer(e)}},95803:(e,t,n)=>{"use strict";const{EMPTY_BUFFER:o}=n(71791),r=Buffer[Symbol.species];function i(e,t,n,o,r){for(let i=0;i<r;i++)n[o+i]=e[i]^t[3&i]}function a(e,t){for(let n=0;n<e.length;n++)e[n]^=t[3&n]}if(e.exports={concat:function(e,t){if(0===e.length)return o;if(1===e.length)return e[0];const n=Buffer.allocUnsafe(t);let i=0;for(let t=0;t<e.length;t++){const o=e[t];n.set(o,i),i+=o.length}return i<t?new r(n.buffer,n.byteOffset,i):n},mask:i,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let n;return t instanceof ArrayBuffer?n=new r(t):ArrayBuffer.isView(t)?n=new r(t.buffer,t.byteOffset,t.byteLength):(n=Buffer.from(t),e.readOnly=!1),n},unmask:a},!process.env.WS_NO_BUFFER_UTIL)try{const t=n(18327);e.exports.mask=function(e,n,o,r,a){a<48?i(e,n,o,r,a):t.mask(e,n,o,r,a)},e.exports.unmask=function(e,n){e.length<32?a(e,n):t.unmask(e,n)}}catch(e){}},71791:e=>{"use strict";const t=["nodebuffer","arraybuffer","fragments"],n="undefined"!=typeof Blob;n&&t.push("blob"),e.exports={BINARY_TYPES:t,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:n,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},34634:(e,t,n)=>{"use strict";const{kForOnEventAttribute:o,kListener:r}=n(71791),i=Symbol("kCode"),a=Symbol("kData"),s=Symbol("kError"),c=Symbol("kMessage"),u=Symbol("kReason"),l=Symbol("kTarget"),d=Symbol("kType"),p=Symbol("kWasClean");class h{constructor(e){this[l]=null,this[d]=e}get target(){return this[l]}get type(){return this[d]}}Object.defineProperty(h.prototype,"target",{enumerable:!0}),Object.defineProperty(h.prototype,"type",{enumerable:!0});class f extends h{constructor(e,t={}){super(e),this[i]=void 0===t.code?0:t.code,this[u]=void 0===t.reason?"":t.reason,this[p]=void 0!==t.wasClean&&t.wasClean}get code(){return this[i]}get reason(){return this[u]}get wasClean(){return this[p]}}Object.defineProperty(f.prototype,"code",{enumerable:!0}),Object.defineProperty(f.prototype,"reason",{enumerable:!0}),Object.defineProperty(f.prototype,"wasClean",{enumerable:!0});class m extends h{constructor(e,t={}){super(e),this[s]=void 0===t.error?null:t.error,this[c]=void 0===t.message?"":t.message}get error(){return this[s]}get message(){return this[c]}}Object.defineProperty(m.prototype,"error",{enumerable:!0}),Object.defineProperty(m.prototype,"message",{enumerable:!0});class g extends h{constructor(e,t={}){super(e),this[a]=void 0===t.data?null:t.data}get data(){return this[a]}}Object.defineProperty(g.prototype,"data",{enumerable:!0});const b={addEventListener(e,t,n={}){for(const i of this.listeners(e))if(!n[o]&&i[r]===t&&!i[o])return;let i;if("message"===e)i=function(e,n){const o=new g("message",{data:n?e:e.toString()});o[l]=this,y(t,this,o)};else if("close"===e)i=function(e,n){const o=new f("close",{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});o[l]=this,y(t,this,o)};else if("error"===e)i=function(e){const n=new m("error",{error:e,message:e.message});n[l]=this,y(t,this,n)};else{if("open"!==e)return;i=function(){const e=new h("open");e[l]=this,y(t,this,e)}}i[o]=!!n[o],i[r]=t,n.once?this.once(e,i):this.on(e,i)},removeEventListener(e,t){for(const n of this.listeners(e))if(n[r]===t&&!n[o]){this.removeListener(e,n);break}}};function y(e,t,n){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}e.exports={CloseEvent:f,ErrorEvent:m,Event:h,EventTarget:b,MessageEvent:g}},61335:(e,t,n)=>{"use strict";const{tokenChars:o}=n(26615);function r(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}e.exports={format:function(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>!0===e?t:`${t}=${e}`).join("; ")})).join("; ")).join(", ")}).join(", ")},parse:function(e){const t=Object.create(null);let n,i,a=Object.create(null),s=!1,c=!1,u=!1,l=-1,d=-1,p=-1,h=0;for(;h<e.length;h++)if(d=e.charCodeAt(h),void 0===n)if(-1===p&&1===o[d])-1===l&&(l=h);else if(0===h||32!==d&&9!==d){if(59!==d&&44!==d)throw new SyntaxError(`Unexpected character at index ${h}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h);const o=e.slice(l,p);44===d?(r(t,o,a),a=Object.create(null)):n=o,l=p=-1}}else-1===p&&-1!==l&&(p=h);else if(void 0===i)if(-1===p&&1===o[d])-1===l&&(l=h);else if(32===d||9===d)-1===p&&-1!==l&&(p=h);else if(59===d||44===d){if(-1===l)throw new SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h),r(a,e.slice(l,p),!0),44===d&&(r(t,n,a),a=Object.create(null),n=void 0),l=p=-1}else{if(61!==d||-1===l||-1!==p)throw new SyntaxError(`Unexpected character at index ${h}`);i=e.slice(l,h),l=p=-1}else if(c){if(1!==o[d])throw new SyntaxError(`Unexpected character at index ${h}`);-1===l?l=h:s||(s=!0),c=!1}else if(u)if(1===o[d])-1===l&&(l=h);else if(34===d&&-1!==l)u=!1,p=h;else{if(92!==d)throw new SyntaxError(`Unexpected character at index ${h}`);c=!0}else if(34===d&&61===e.charCodeAt(h-1))u=!0;else if(-1===p&&1===o[d])-1===l&&(l=h);else if(-1===l||32!==d&&9!==d){if(59!==d&&44!==d)throw new SyntaxError(`Unexpected character at index ${h}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h);let o=e.slice(l,p);s&&(o=o.replace(/\\/g,""),s=!1),r(a,i,o),44===d&&(r(t,n,a),a=Object.create(null),n=void 0),i=void 0,l=p=-1}}else-1===p&&(p=h);if(-1===l||u||32===d||9===d)throw new SyntaxError("Unexpected end of input");-1===p&&(p=h);const f=e.slice(l,p);return void 0===n?r(t,f,a):(void 0===i?r(a,f,!0):r(a,i,s?f.replace(/\\/g,""):f),r(t,n,a)),t}}},10958:e=>{"use strict";const t=Symbol("kDone"),n=Symbol("kRun");e.exports=class{constructor(e){this[t]=()=>{this.pending--,this[n]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[n]()}[n](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[t])}}}},4376:(e,t,n)=>{"use strict";const o=n(43106),r=n(95803),i=n(10958),{kStatusCode:a}=n(71791),s=Buffer[Symbol.species],c=Buffer.from([0,0,255,255]),u=Symbol("permessage-deflate"),l=Symbol("total-length"),d=Symbol("callback"),p=Symbol("buffers"),h=Symbol("error");let f;function m(e){this[p].push(e),this[l]+=e.length}function g(e){this[l]+=e.length,this[u]._maxPayload<1||this[l]<=this[u]._maxPayload?this[p].push(e):(this[h]=new RangeError("Max payload size exceeded"),this[h].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[h][a]=1009,this.removeListener("data",g),this.reset())}function b(e){this[u]._inflate=null,this[h]?this[d](this[h]):(e[a]=1007,this[d](e))}e.exports=class{constructor(e,t,n){if(this._maxPayload=0|n,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!f){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;f=new i(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,n=e.find(e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(n.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?n.client_max_window_bits=t.clientMaxWindowBits:!0!==n.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete n.client_max_window_bits,n}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(n=n[0],"client_max_window_bits"===t){if(!0!==n){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}else if("server_max_window_bits"===t){const e=+n;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==n)throw new TypeError(`Invalid value for parameter "${t}": ${n}`)}e[t]=n})}),e}decompress(e,t,n){f.add(o=>{this._decompress(e,t,(e,t)=>{o(),n(e,t)})})}compress(e,t,n){f.add(o=>{this._compress(e,t,(e,t)=>{o(),n(e,t)})})}_decompress(e,t,n){const i=this._isServer?"client":"server";if(!this._inflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?o.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=o.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[u]=this,this._inflate[l]=0,this._inflate[p]=[],this._inflate.on("error",b),this._inflate.on("data",g)}this._inflate[d]=n,this._inflate.write(e),t&&this._inflate.write(c),this._inflate.flush(()=>{const e=this._inflate[h];if(e)return this._inflate.close(),this._inflate=null,void n(e);const o=r.concat(this._inflate[p],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[p]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,o)})}_compress(e,t,n){const i=this._isServer?"server":"client";if(!this._deflate){const e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?o.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=o.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[p]=[],this._deflate.on("data",m)}this._deflate[d]=n,this._deflate.write(e),this._deflate.flush(o.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=r.concat(this._deflate[p],this._deflate[l]);t&&(e=new s(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[l]=0,this._deflate[p]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,e)})}}},20893:(e,t,n)=>{"use strict";const{Writable:o}=n(2203),r=n(4376),{BINARY_TYPES:i,EMPTY_BUFFER:a,kStatusCode:s,kWebSocket:c}=n(71791),{concat:u,toArrayBuffer:l,unmask:d}=n(95803),{isValidStatusCode:p,isValidUTF8:h}=n(26615),f=Buffer[Symbol.species];e.exports=class extends o{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||i[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[c]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(8===this._opcode&&0==this._state)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new f(t.buffer,t.byteOffset+e,t.length-e),new f(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const n=this._buffers[0],o=t.length-e;e>=n.length?t.set(this._buffers.shift(),o):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new f(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do{switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:return void(this._loop=!1)}}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2)return void(this._loop=!1);const t=this.consume(2);if(48&t[0]){return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"))}const n=!(64&~t[0]);if(n&&!this._extensions[r.extensionName]){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._fin=!(128&~t[0]),this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(!this._fragmented){return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"))}this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}this._compressed=n}else{if(!(this._opcode>7&&this._opcode<11)){return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"))}if(!this._fin){return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"))}if(n){return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"))}if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength){return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=!(128&~t[1]),this._isServer){if(!this._masked){return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}}else if(this._masked){return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"))}126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}getPayloadLength16(e){this._bufferedBytes<2?this._loop=!1:(this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e))}getPayloadLength64(e){if(this._bufferedBytes<8)return void(this._loop=!1);const t=this.consume(8),n=t.readUInt32BE(0);if(n>Math.pow(2,21)-1){return void e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"))}this._payloadLength=n*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){return void e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=a;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&0!==(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])&&d(t,this._mask)}if(this._opcode>7)this.controlMessage(t,e);else{if(this._compressed)return this._state=5,void this.decompress(t,e);t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}}decompress(e,t){this._extensions[r.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");return void t(e)}this._fragments.push(n)}this.dataMessage(t),0===this._state&&this.startLoop(t)})}dataMessage(e){if(!this._fin)return void(this._state=0);const t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let o;o="nodebuffer"===this._binaryType?u(n,t):"arraybuffer"===this._binaryType?l(u(n,t)):"blob"===this._binaryType?new Blob(n):n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",o,!0),this._state=0,this.startLoop(e)}))}else{const o=u(n,t);if(!this._skipUTF8Validation&&!h(o)){const t=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void e(t)}5===this._state||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",o,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(8!==this._opcode)this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)}));else{if(0===e.length)this._loop=!1,this.emit("conclude",1005,a),this.end();else{const n=e.readUInt16BE(0);if(!p(n)){const e=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");return void t(e)}const o=new f(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!h(o)){const e=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");return void t(e)}this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=0}}createError(e,t,n,o,r){this._loop=!1,this._errored=!0;const i=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,this.createError),i.code=r,i[s]=o,i}}},7389:(e,t,n)=>{"use strict";const{Duplex:o}=n(2203),{randomFillSync:r}=n(76982),i=n(4376),{EMPTY_BUFFER:a,kWebSocket:s,NOOP:c}=n(71791),{isBlob:u,isValidStatusCode:l}=n(26615),{mask:d,toBuffer:p}=n(95803),h=Symbol("kByteLength"),f=Buffer.alloc(4),m=8192;let g,b=m;class y{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=c,this[s]=void 0}static frame(e,t){let n,o,i=!1,a=2,s=!1;t.mask&&(n=t.maskBuffer||f,t.generateMask?t.generateMask(n):(b===m&&(void 0===g&&(g=Buffer.alloc(m)),r(g,0,m),b=0),n[0]=g[b++],n[1]=g[b++],n[2]=g[b++],n[3]=g[b++]),s=0===(n[0]|n[1]|n[2]|n[3]),a=6),"string"==typeof e?o=t.mask&&!s||void 0===t[h]?(e=Buffer.from(e)).length:t[h]:(o=e.length,i=t.mask&&t.readOnly&&!s);let c=o;o>=65536?(a+=8,c=127):o>125&&(a+=2,c=126);const u=Buffer.allocUnsafe(i?o+a:a);return u[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(u[0]|=64),u[1]=c,126===c?u.writeUInt16BE(o,2):127===c&&(u[2]=u[3]=0,u.writeUIntBE(o,4,6)),t.mask?(u[1]|=128,u[a-4]=n[0],u[a-3]=n[1],u[a-2]=n[2],u[a-1]=n[3],s?[u,e]:i?(d(e,n,u,a,o),[u]):(d(e,n,e,0,o),[u,e])):[u,e]}close(e,t,n,o){let r;if(void 0===e)r=a;else{if("number"!=typeof e||!l(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const n=Buffer.byteLength(t);if(n>123)throw new RangeError("The message must not be greater than 123 bytes");r=Buffer.allocUnsafe(2+n),r.writeUInt16BE(e,0),"string"==typeof t?r.write(t,2):r.set(t,2)}else r=Buffer.allocUnsafe(2),r.writeUInt16BE(e,0)}const i={[h]:r.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,r,!1,i,o]):this.sendFrame(y.frame(r,i),o)}ping(e,t,n){let o,r;if("string"==typeof e?(o=Buffer.byteLength(e),r=!1):u(e)?(o=e.size,r=!1):(o=(e=p(e)).length,r=p.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");const i={[h]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:r,rsv1:!1};u(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):0!==this._state?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(y.frame(e,i),n)}pong(e,t,n){let o,r;if("string"==typeof e?(o=Buffer.byteLength(e),r=!1):u(e)?(o=e.size,r=!1):(o=(e=p(e)).length,r=p.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");const i={[h]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:r,rsv1:!1};u(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):0!==this._state?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(y.frame(e,i),n)}send(e,t,n){const o=this._extensions[i.extensionName];let r,a,s=t.binary?2:1,c=t.compress;"string"==typeof e?(r=Buffer.byteLength(e),a=!1):u(e)?(r=e.size,a=!1):(r=(e=p(e)).length,a=p.readOnly),this._firstFragment?(this._firstFragment=!1,c&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(c=r>=o._threshold),this._compress=c):(c=!1,s=0),t.fin&&(this._firstFragment=!0);const l={[h]:r,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:a,rsv1:c};u(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,l,n]):this.getBlobData(e,this._compress,l,n):0!==this._state?this.enqueue([this.dispatch,e,this._compress,l,n]):this.dispatch(e,this._compress,l,n)}getBlobData(e,t,n,o){this._bufferedBytes+=n[h],this._state=2,e.arrayBuffer().then(e=>{if(this._socket.destroyed){const e=new Error("The socket was closed while the blob was being read");return void process.nextTick(v,this,e,o)}this._bufferedBytes-=n[h];const r=p(e);t?this.dispatch(r,t,n,o):(this._state=0,this.sendFrame(y.frame(r,n),o),this.dequeue())}).catch(e=>{process.nextTick(_,this,e,o)})}dispatch(e,t,n,o){if(!t)return void this.sendFrame(y.frame(e,n),o);const r=this._extensions[i.extensionName];this._bufferedBytes+=n[h],this._state=1,r.compress(e,n.fin,(e,t)=>{if(this._socket.destroyed){return void v(this,new Error("The socket was closed while data was being compressed"),o)}this._bufferedBytes-=n[h],this._state=0,n.readOnly=!1,this.sendFrame(y.frame(t,n),o),this.dequeue()})}dequeue(){for(;0===this._state&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][h],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][h],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}function v(e,t,n){"function"==typeof n&&n(t);for(let n=0;n<e._queue.length;n++){const o=e._queue[n],r=o[o.length-1];"function"==typeof r&&r(t)}}function _(e,t,n){v(e,t,n),e.onerror(t)}e.exports=y},86412:(e,t,n)=>{"use strict";n(56681);const{Duplex:o}=n(2203);function r(e){e.emit("close")}function i(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a(e){this.removeListener("error",a),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}e.exports=function(e,t){let n=!0;const s=new o({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(t,n){const o=!n&&s._readableState.objectMode?t.toString():t;s.push(o)||e.pause()}),e.once("error",function(e){s.destroyed||(n=!1,s.destroy(e))}),e.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(t,o){if(e.readyState===e.CLOSED)return o(t),void process.nextTick(r,s);let i=!1;e.once("error",function(e){i=!0,o(e)}),e.once("close",function(){i||o(t),process.nextTick(r,s)}),n&&e.terminate()},s._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once("finish",function(){t()}),e.close())):e.once("open",function(){s._final(t)})},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,o){e.readyState!==e.CONNECTING?e.send(t,o):e.once("open",function(){s._write(t,n,o)})},s.on("end",i),s.on("error",a),s}},43332:(e,t,n)=>{"use strict";const{tokenChars:o}=n(26615);e.exports={parse:function(e){const t=new Set;let n=-1,r=-1,i=0;for(;i<e.length;i++){const a=e.charCodeAt(i);if(-1===r&&1===o[a])-1===n&&(n=i);else if(0===i||32!==a&&9!==a){if(44!==a)throw new SyntaxError(`Unexpected character at index ${i}`);{if(-1===n)throw new SyntaxError(`Unexpected character at index ${i}`);-1===r&&(r=i);const o=e.slice(n,r);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);t.add(o),n=r=-1}}else-1===r&&-1!==n&&(r=i)}if(-1===n||-1!==r)throw new SyntaxError("Unexpected end of input");const a=e.slice(n,i);if(t.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);return t.add(a),t}}},26615:(e,t,n)=>{"use strict";const{isUtf8:o}=n(20181),{hasBlob:r}=n(71791);function i(e){const t=e.length;let n=0;for(;n<t;)if(128&e[n])if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}else n++;return!0}if(e.exports={isBlob:function(e){return r&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:i,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},o)e.exports.isValidUTF8=function(e){return e.length<24?i(e):o(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=n(62414);e.exports.isValidUTF8=function(e){return e.length<32?i(e):t(e)}}catch(e){}},70129:(e,t,n)=>{"use strict";const o=n(24434),r=n(58611),{Duplex:i}=n(2203),{createHash:a}=n(76982),s=n(61335),c=n(4376),u=n(43332),l=n(56681),{CLOSE_TIMEOUT:d,GUID:p,kWebSocket:h}=n(71791),f=/^[+/0-9A-Za-z]{22}==$/;function m(e){e._state=2,e.emit("close")}function g(){this.destroy()}function b(e,t,n,o){n=n||r.STATUS_CODES[t],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...o},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${r.STATUS_CODES[t]}\r\n`+Object.keys(o).map(e=>`${e}: ${o[e]}`).join("\r\n")+"\r\n\r\n"+n)}function y(e,t,n,o,r,i){if(e.listenerCount("wsClientError")){const o=new Error(r);Error.captureStackTrace(o,y),e.emit("wsClientError",o,n,t)}else b(n,o,r,i)}e.exports=class extends o{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:d,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:l,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=r.createServer((e,t)=>{const n=r.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const n of Object.keys(t))e.on(n,t[n]);return function(){for(const n of Object.keys(t))e.removeListener(n,t[n])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,n,o)=>{this.handleUpgrade(t,n,o,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",()=>{e(new Error("The server is not running"))}),void process.nextTick(m,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(m,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{m(this)})}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,o){t.on("error",g);const r=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void y(this,e,t,405,"Invalid HTTP method")}if(void 0===i||"websocket"!==i.toLowerCase()){return void y(this,e,t,400,"Invalid Upgrade header")}if(void 0===r||!f.test(r)){return void y(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(13!==a&&8!==a){return void y(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"})}if(!this.shouldHandle(e))return void b(t,400);const l=e.headers["sec-websocket-protocol"];let d=new Set;if(void 0!==l)try{d=u.parse(l)}catch(n){return void y(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const p=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&void 0!==p){const n=new c(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=s.parse(p);e[c.extensionName]&&(n.accept(e[c.extensionName]),h[c.extensionName]=n)}catch(n){return void y(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const i={origin:e.headers[""+(8===a?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(i,(i,a,s,c)=>{if(!i)return b(t,a||401,s,c);this.completeUpgrade(h,r,d,e,t,n,o)});if(!this.options.verifyClient(i))return b(t,401)}this.completeUpgrade(h,r,d,e,t,n,o)}completeUpgrade(e,t,n,o,r,i,u){if(!r.readable||!r.writable)return r.destroy();if(r[h])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return b(r,503);const l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${a("sha1").update(t+p).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(n.size){const e=this.options.handleProtocols?this.options.handleProtocols(n,o):n.values().next().value;e&&(l.push(`Sec-WebSocket-Protocol: ${e}`),d._protocol=e)}if(e[c.extensionName]){const t=e[c.extensionName].params,n=s.format({[c.extensionName]:[t]});l.push(`Sec-WebSocket-Extensions: ${n}`),d._extensions=e}this.emit("headers",l,o),r.write(l.concat("\r\n").join("\r\n")),r.removeListener("error",g),d.setSocket(r,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on("close",()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(m,this)})),u(d,o)}}},56681:(e,t,n)=>{"use strict";const o=n(24434),r=n(65692),i=n(58611),a=n(69278),s=n(64756),{randomBytes:c,createHash:u}=n(76982),{Duplex:l,Readable:d}=n(2203),{URL:p}=n(87016),h=n(4376),f=n(20893),m=n(7389),{isBlob:g}=n(26615),{BINARY_TYPES:b,CLOSE_TIMEOUT:y,EMPTY_BUFFER:v,GUID:_,kForOnEventAttribute:w,kListener:O,kStatusCode:S,kWebSocket:x,NOOP:T}=n(71791),{EventTarget:{addEventListener:P,removeEventListener:C}}=n(34634),{format:k,parse:j}=n(61335),{toBuffer:E}=n(95803),R=Symbol("kAborted"),A=[8,13],I=["CONNECTING","OPEN","CLOSING","CLOSED"],M=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class N extends o{constructor(e,t,n){super(),this._binaryType=b[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=v,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=N.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(n=t,t=[]):t=[t]),$(this,e,t,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){b.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,n){const o=new f({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),r=new m(e,this._extensions,n.generateMask);this._receiver=o,this._sender=r,this._socket=e,o[x]=this,r[x]=this,e[x]=this,o.on("conclude",W),o.on("drain",J),o.on("error",B),o.on("message",V),o.on("ping",H),o.on("pong",z),r.onerror=X,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Y),e.on("data",Q),e.on("end",ee),e.on("error",te),this._readyState=N.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=N.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[h.extensionName]&&this._extensions[h.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=N.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==N.CLOSED){if(this.readyState===N.CONNECTING){const e="WebSocket was closed before the connection was established";return void q(this,this._req,e)}this.readyState!==N.CLOSING?(this._readyState=N.CLOSING,this._sender.close(e,t,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Z(this)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end()}}pause(){this.readyState!==N.CONNECTING&&this.readyState!==N.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,n){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(n=e,e=t=void 0):"function"==typeof t&&(n=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===N.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||v,t,n)):F(this,e,n)}pong(e,t,n){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(n=e,e=t=void 0):"function"==typeof t&&(n=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===N.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||v,t,n)):F(this,e,n)}resume(){this.readyState!==N.CONNECTING&&this.readyState!==N.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,n){if(this.readyState===N.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(n=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==N.OPEN)return void F(this,e,n);const o={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[h.extensionName]||(o.compress=!1),this._sender.send(e||v,o,n)}terminate(){if(this.readyState!==N.CLOSED){if(this.readyState===N.CONNECTING){const e="WebSocket was closed before the connection was established";return void q(this,this._req,e)}this._socket&&(this._readyState=N.CLOSING,this._socket.destroy())}}}function $(e,t,n,o){const a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:y,protocolVersion:A[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=a.autoPong,e._closeTimeout=a.closeTimeout,!A.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${A.join(", ")})`);let s;if(t instanceof p)s=t;else try{s=new p(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}"http:"===s.protocol?s.protocol="ws:":"https:"===s.protocol&&(s.protocol="wss:"),e._url=s.href;const l="wss:"===s.protocol,d="ws+unix:"===s.protocol;let f;if("ws:"===s.protocol||l||d?d&&!s.pathname?f="The URL's pathname is empty":s.hash&&(f="The URL contains a fragment identifier"):f='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"',f){const t=new SyntaxError(f);if(0===e._redirects)throw t;return void D(e,t)}const m=l?443:80,g=c(16).toString("base64"),b=l?r.request:i.request,v=new Set;let w,O;if(a.createConnection=a.createConnection||(l?L:U),a.defaultPort=a.defaultPort||m,a.port=s.port||m,a.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":g,Connection:"Upgrade",Upgrade:"websocket"},a.path=s.pathname+s.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(w=new h(!0!==a.perMessageDeflate?a.perMessageDeflate:{},!1,a.maxPayload),a.headers["Sec-WebSocket-Extensions"]=k({[h.extensionName]:w.offer()})),n.length){for(const e of n){if("string"!=typeof e||!M.test(e)||v.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");v.add(e)}a.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(s.username||s.password)&&(a.auth=`${s.username}:${s.password}`),d){const e=a.path.split(":");a.socketPath=e[0],a.path=e[1]}if(a.followRedirects){if(0===e._redirects){e._originalIpc=d,e._originalSecure=l,e._originalHostOrSocketPath=d?a.socketPath:s.host;const t=o&&o.headers;if(o={...o,headers:{}},t)for(const[e,n]of Object.entries(t))o.headers[e.toLowerCase()]=n}else if(0===e.listenerCount("redirect")){const t=d?!!e._originalIpc&&a.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!l)&&(delete a.headers.authorization,delete a.headers.cookie,t||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),O=e._req=b(a),e._redirects&&e.emit("redirect",e.url,O)}else O=e._req=b(a);a.timeout&&O.on("timeout",()=>{q(e,O,"Opening handshake has timed out")}),O.on("error",t=>{null===O||O[R]||(O=e._req=null,D(e,t))}),O.on("response",r=>{const i=r.headers.location,s=r.statusCode;if(i&&a.followRedirects&&s>=300&&s<400){if(++e._redirects>a.maxRedirects)return void q(e,O,"Maximum redirects exceeded");let r;O.abort();try{r=new p(i,t)}catch(t){const n=new SyntaxError(`Invalid URL: ${i}`);return void D(e,n)}$(e,r,n,o)}else e.emit("unexpected-response",O,r)||q(e,O,`Unexpected server response: ${r.statusCode}`)}),O.on("upgrade",(t,n,o)=>{if(e.emit("upgrade",t),e.readyState!==N.CONNECTING)return;O=e._req=null;const r=t.headers.upgrade;if(void 0===r||"websocket"!==r.toLowerCase())return void q(e,n,"Invalid Upgrade header");const i=u("sha1").update(g+_).digest("base64");if(t.headers["sec-websocket-accept"]!==i)return void q(e,n,"Invalid Sec-WebSocket-Accept header");const s=t.headers["sec-websocket-protocol"];let c;if(void 0!==s?v.size?v.has(s)||(c="Server sent an invalid subprotocol"):c="Server sent a subprotocol but none was requested":v.size&&(c="Server sent no subprotocol"),c)return void q(e,n,c);s&&(e._protocol=s);const l=t.headers["sec-websocket-extensions"];if(void 0!==l){if(!w){return void q(e,n,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=j(l)}catch(t){return void q(e,n,"Invalid Sec-WebSocket-Extensions header")}const o=Object.keys(t);if(1!==o.length||o[0]!==h.extensionName){return void q(e,n,"Server indicated an extension that was not requested")}try{w.accept(t[h.extensionName])}catch(t){return void q(e,n,"Invalid Sec-WebSocket-Extensions header")}e._extensions[h.extensionName]=w}e.setSocket(n,o,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(O,e):O.end()}function D(e,t){e._readyState=N.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function U(e){return e.path=e.socketPath,a.connect(e)}function L(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=a.isIP(e.host)?"":e.host),s.connect(e)}function q(e,t,n){e._readyState=N.CLOSING;const o=new Error(n);Error.captureStackTrace(o,q),t.setHeader?(t[R]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(D,e,o)):(t.destroy(o),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function F(e,t,n){if(t){const n=g(t)?t.size:E(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${I[e.readyState]})`);process.nextTick(n,t)}}function W(e,t){const n=this[x];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,void 0!==n._socket[x]&&(n._socket.removeListener("data",Q),process.nextTick(K,n._socket),1005===e?n.close():n.close(e,t))}function J(){const e=this[x];e.isPaused||e._socket.resume()}function B(e){const t=this[x];void 0!==t._socket[x]&&(t._socket.removeListener("data",Q),process.nextTick(K,t._socket),t.close(e[S])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function G(){this[x].emitClose()}function V(e,t){this[x].emit("message",e,t)}function H(e){const t=this[x];t._autoPong&&t.pong(e,!this._isServer,T),t.emit("ping",e)}function z(e){this[x].emit("pong",e)}function K(e){e.resume()}function X(e){const t=this[x];t.readyState!==N.CLOSED&&(t.readyState===N.OPEN&&(t._readyState=N.CLOSING,Z(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function Z(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function Y(){const e=this[x];if(this.removeListener("close",Y),this.removeListener("data",Q),this.removeListener("end",ee),e._readyState=N.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&0!==this._readableState.length){const t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[x]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",G),e._receiver.on("finish",G))}function Q(e){this[x]._receiver.write(e)||this.pause()}function ee(){const e=this[x];e._readyState=N.CLOSING,e._receiver.end(),this.end()}function te(){const e=this[x];this.removeListener("error",te),this.on("error",T),e&&(e._readyState=N.CLOSING,this.destroy())}Object.defineProperty(N,"CONNECTING",{enumerable:!0,value:I.indexOf("CONNECTING")}),Object.defineProperty(N.prototype,"CONNECTING",{enumerable:!0,value:I.indexOf("CONNECTING")}),Object.defineProperty(N,"OPEN",{enumerable:!0,value:I.indexOf("OPEN")}),Object.defineProperty(N.prototype,"OPEN",{enumerable:!0,value:I.indexOf("OPEN")}),Object.defineProperty(N,"CLOSING",{enumerable:!0,value:I.indexOf("CLOSING")}),Object.defineProperty(N.prototype,"CLOSING",{enumerable:!0,value:I.indexOf("CLOSING")}),Object.defineProperty(N,"CLOSED",{enumerable:!0,value:I.indexOf("CLOSED")}),Object.defineProperty(N.prototype,"CLOSED",{enumerable:!0,value:I.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(N.prototype,e,{enumerable:!0})}),["open","error","close","message"].forEach(e=>{Object.defineProperty(N.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[w])return t[O];return null},set(t){for(const t of this.listeners(e))if(t[w]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[w]:!0})}})}),N.prototype.addEventListener=P,N.prototype.removeEventListener=C,e.exports=N},18327:module=>{module.exports=eval("require")("bufferutil")},62414:module=>{module.exports=eval("require")("utf-8-validate")},24352:(e,t,n)=>{"use strict";const{normalizeIPv6:o,removeDotSegments:r,recomposeAuthority:i,normalizeComponentEncoding:a,isIPv4:s,nonSimpleDomain:c}=n(15077),{SCHEMES:u,getSchemeHandler:l}=n(75300);function d(e,t,n,o){const i={};return o||(e=f(p(e,n),n),t=f(p(t,n),n)),!(n=n||{}).tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=r(t.path||""),i.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=r(t.path||""),i.query=t.query):(t.path?("/"===t.path[0]?i.path=r(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path:i.path="/"+t.path,i.path=r(i.path)),i.query=t.query):(i.path=e.path,void 0!==t.query?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function p(e,t){const n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},o=Object.assign({},t),a=[],s=l(o.scheme||n.scheme);s&&s.serialize&&s.serialize(n,o),void 0!==n.path&&(o.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),void 0!==n.scheme&&(n.path=n.path.split("%3A").join(":")))),"suffix"!==o.reference&&n.scheme&&a.push(n.scheme,":");const c=i(n);if(void 0!==c&&("suffix"!==o.reference&&a.push("//"),a.push(c),n.path&&"/"!==n.path[0]&&a.push("/")),void 0!==n.path){let e=n.path;o.absolutePath||s&&s.absolutePath||(e=r(e)),void 0===c&&"/"===e[0]&&"/"===e[1]&&(e="/%2F"+e.slice(2)),a.push(e)}return void 0!==n.query&&a.push("?",n.query),void 0!==n.fragment&&a.push("#",n.fragment),a.join("")}const h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function f(e,t){const n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let i=!1;"suffix"===n.reference&&(e=n.scheme?n.scheme+":"+e:"//"+e);const a=e.match(h);if(a){if(r.scheme=a[1],r.userinfo=a[3],r.host=a[4],r.port=parseInt(a[5],10),r.path=a[6]||"",r.query=a[7],r.fragment=a[8],isNaN(r.port)&&(r.port=a[5]),r.host){if(!1===s(r.host)){const e=o(r.host);r.host=e.host.toLowerCase(),i=e.isIPV6}else i=!0}void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||void 0!==r.query||r.path?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const t=l(n.scheme||r.scheme);if(!(n.unicodeSupport||t&&t.unicodeSupport)&&r.host&&(n.domainHost||t&&t.domainHost)&&!1===i&&c(r.host))try{r.host=URL.domainToASCII(r.host.toLowerCase())}catch(e){r.error=r.error||"Host's domain name can not be converted to ASCII: "+e}(!t||t&&!t.skipNormalize)&&(-1!==e.indexOf("%")&&(void 0!==r.scheme&&(r.scheme=unescape(r.scheme)),void 0!==r.host&&(r.host=unescape(r.host))),r.path&&(r.path=escape(unescape(r.path))),r.fragment&&(r.fragment=encodeURI(decodeURIComponent(r.fragment)))),t&&t.parse&&t.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return r}const m={SCHEMES:u,normalize:function(e,t){return"string"==typeof e?e=p(f(e,t),t):"object"==typeof e&&(e=f(p(e,t),t)),e},resolve:function(e,t,n){const o=n?Object.assign({scheme:"null"},n):{scheme:"null"},r=d(f(e,o),f(t,o),o,!0);return o.skipEscape=!0,p(r,o)},resolveComponent:d,equal:function(e,t,n){return"string"==typeof e?(e=unescape(e),e=p(a(f(e,n),!0),{...n,skipEscape:!0})):"object"==typeof e&&(e=p(a(e,!0),{...n,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=p(a(f(t,n),!0),{...n,skipEscape:!0})):"object"==typeof t&&(t=p(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:p,parse:f};e.exports=m,e.exports.default=m,e.exports.fastUri=m},75300:(e,t,n)=>{"use strict";const{isUUID:o}=n(15077),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=["http","https","ws","wss","urn","urn:uuid"];function a(e){return!0===e.secure||!1!==e.secure&&(!!e.scheme&&!(3!==e.scheme.length||"w"!==e.scheme[0]&&"W"!==e.scheme[0]||"s"!==e.scheme[1]&&"S"!==e.scheme[1]||"s"!==e.scheme[2]&&"S"!==e.scheme[2]))}function s(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function c(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const u={scheme:"http",domainHost:!0,parse:s,serialize:c},l={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=a(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(a(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,n]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}},d={http:u,https:{scheme:"https",domainHost:u.domainHost,parse:s,serialize:c},ws:l,wss:{scheme:"wss",domainHost:l.domainHost,parse:l.parse,serialize:l.serialize},urn:{scheme:"urn",parse:function(e,t){if(!e.path)return e.error="URN can not be parsed",e;const n=e.path.match(r);if(n){const o=t.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];const r=p(`${o}:${t.nid||e.nid}`);e.path=void 0,r&&(e=r.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){if(void 0===e.nid)throw new Error("URN without nid cannot be serialized");const n=t.scheme||e.scheme||"urn",o=e.nid.toLowerCase(),r=p(`${n}:${t.nid||o}`);r&&(e=r.serialize(e,t));const i=e,a=e.nss;return i.path=`${o||t.nid}:${a}`,t.skipEscape=!0,i},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(e,t){const n=e;return n.uuid=n.nss,n.nss=void 0,t.tolerant||n.uuid&&o(n.uuid)||(n.error=n.error||"UUID is not valid."),n},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};function p(e){return e&&(d[e]||d[e.toLowerCase()])||void 0}Object.setPrototypeOf(d,null),e.exports={wsIsSecure:a,SCHEMES:d,isValidSchemeName:function(e){return-1!==i.indexOf(e)},getSchemeHandler:p}},15077:e=>{"use strict";const t=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),n=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function o(e){let t="",n=0,o=0;for(o=0;o<e.length;o++)if(n=e[o].charCodeAt(0),48!==n){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[o];break}for(o+=1;o<e.length;o++){if(n=e[o].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[o]}return t}const r=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function i(e){return e.length=0,!0}function a(e,t,n){if(e.length){const r=o(e);if(""===r)return n.error=!0,!1;t.push(r),e.length=0}return!0}function s(e){if(function(e,t){let n=0;for(let o=0;o<e.length;o++)e[o]===t&&n++;return n}(e,":")<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const n={error:!1,address:"",zone:""},r=[],s=[];let c=!1,u=!1,l=a;for(let o=0;o<e.length;o++){const a=e[o];if("["!==a&&"]"!==a)if(":"!==a)if("%"===a){if(!l(s,r,n))break;l=i}else s.push(a);else{if(!0===c&&(u=!0),!l(s,r,n))break;if(++t>7){n.error=!0;break}o>0&&":"===e[o-1]&&(c=!0),r.push(":")}}return s.length&&(l===i?n.zone=s.join(""):u?r.push(s.join("")):r.push(o(s))),n.address=r.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+="%"+t.zone,n+="%25"+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}e.exports={nonSimpleDomain:r,recomposeAuthority:function(e){const t=[];if(void 0!==e.userinfo&&(t.push(e.userinfo),t.push("@")),void 0!==e.host){let o=unescape(e.host);if(!n(o)){const t=s(o);o=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}t.push(o)}return"number"!=typeof e.port&&"string"!=typeof e.port||(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0},normalizeComponentEncoding:function(e,t){const n=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=n(e.scheme)),void 0!==e.userinfo&&(e.userinfo=n(e.userinfo)),void 0!==e.host&&(e.host=n(e.host)),void 0!==e.path&&(e.path=n(e.path)),void 0!==e.query&&(e.query=n(e.query)),void 0!==e.fragment&&(e.fragment=n(e.fragment)),e},removeDotSegments:function(e){let t=e;const n=[];let o=-1,r=0;for(;r=t.length;){if(1===r){if("."===t)break;if("/"===t){n.push("/");break}n.push(t);break}if(2===r){if("."===t[0]){if("."===t[1])break;if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&("."===t[1]||"/"===t[1])){n.push("/");break}}else if(3===r&&"/.."===t){0!==n.length&&n.pop(),n.push("/");break}if("."===t[0]){if("."===t[1]){if("/"===t[2]){t=t.slice(3);continue}}else if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&"."===t[1]){if("/"===t[2]){t=t.slice(2);continue}if("."===t[2]&&"/"===t[3]){t=t.slice(3),0!==n.length&&n.pop();continue}}if(-1===(o=t.indexOf("/",1))){n.push(t);break}n.push(t.slice(0,o)),t=t.slice(o)}return n.join("")},isIPv4:n,isUUID:t,normalizeIPv6:s,stringArrayToHexStripped:o}},36128:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GCE_LINUX_BIOS_PATHS=void 0,t.isGoogleCloudServerless=a,t.isGoogleComputeEngineLinux=s,t.isGoogleComputeEngineMACAddress=c,t.isGoogleComputeEngine=u,t.detectGCPResidency=function(){return a()||u()};const o=n(79896),r=n(70857);t.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};const i=/^42:01/;function a(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function s(){if("linux"!==(0,r.platform)())return!1;try{(0,o.statSync)(t.GCE_LINUX_BIOS_PATHS.BIOS_DATE);const e=(0,o.readFileSync)(t.GCE_LINUX_BIOS_PATHS.BIOS_VENDOR,"utf8");return/Google/.test(e)}catch{return!1}}function c(){const e=(0,r.networkInterfaces)();for(const t of Object.values(e))if(t)for(const{mac:e}of t)if(i.test(e))return!0;return!1}function u(){return s()||c()}},69595:function(e,t,n){"use strict";var o,r=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return i(t,e),t}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.gcpResidencyCache=t.METADATA_SERVER_DETECTION=t.HEADERS=t.HEADER_VALUE=t.HEADER_NAME=t.SECONDARY_HOST_ADDRESS=t.HOST_ADDRESS=t.BASE_PATH=void 0,t.instance=function(e){return f("instance",e)},t.project=function(e){return f("project",e)},t.universe=function(e){return f("universe",e)},t.bulk=async function(e){const t={};return await Promise.all(e.map(e=>(async()=>{const n=await f(e),o=e.metadataKey;t[o]=n})())),t},t.isAvailable=async function(){if(process.env.METADATA_SERVER_DETECTION){const e=process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();if(!(e in t.METADATA_SERVER_DETECTION))throw new RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${e}\`, but it should be \`${Object.keys(t.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);switch(e){case"assume-present":return!0;case"none":return!1;case"bios-only":return b()}}try{return void 0===g&&(g=f("instance",void 0,process.env.DETECT_GCP_RETRIES?Number(process.env.DETECT_GCP_RETRIES):0,!(process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST))),await g,!0}catch(e){const t=e;if(process.env.DEBUG_AUTH&&console.info(t),"request-timeout"===t.type)return!1;if(t.response&&404===t.response.status)return!1;if(!(t.response&&404===t.response.status||t.code&&["EHOSTDOWN","EHOSTUNREACH","ENETUNREACH","ENOENT","ENOTFOUND","ECONNREFUSED"].includes(t.code.toString()))){let e="UNKNOWN";t.code&&(e=t.code.toString()),process.emitWarning(`received unexpected error = ${t.message} code = ${e}`,"MetadataLookupWarning")}return!1}},t.resetIsAvailableCache=function(){g=void 0},t.getGCPResidency=b,t.setGCPResidency=y,t.requestTimeout=v;const c=n(17842),u=n(14826),l=n(36128),d=a(n(81577));t.BASE_PATH="/computeMetadata/v1",t.HOST_ADDRESS="http://169.254.169.254",t.SECONDARY_HOST_ADDRESS="http://metadata.google.internal.",t.HEADER_NAME="Metadata-Flavor",t.HEADER_VALUE="Google",t.HEADERS=Object.freeze({[t.HEADER_NAME]:t.HEADER_VALUE});const p=d.log("gcp-metadata");function h(e){return e||(e=process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST||t.HOST_ADDRESS),/^https?:\/\//.test(e)||(e=`http://${e}`),new URL(t.BASE_PATH,e).href}async function f(e,n={},o=3,r=!1){const i=new Headers(t.HEADERS);let a="",s={};if("object"==typeof e){const t=e;new Headers(t.headers).forEach((e,t)=>i.set(t,e)),a=t.metadataKey,s=t.params||s,o=t.noResponseRetries||o,r=t.fastFail||r}else a=e;"string"==typeof n?a+=`/${n}`:(!function(e){Object.keys(e).forEach(e=>{switch(e){case"params":case"property":case"headers":break;case"qs":throw new Error("'qs' is not a valid configuration option. Please use 'params' instead.");default:throw new Error(`'${e}' is not a valid configuration option.`)}})}(n),n.property&&(a+=`/${n.property}`),new Headers(n.headers).forEach((e,t)=>i.set(t,e)),s=n.params||s);const l=r?m:c.request,d={url:`${h()}/${a}`,headers:i,retryConfig:{noResponseRetries:o},params:s,responseType:"text",timeout:v()};p.info("instance request %j",d);const f=await l(d);p.info("instance metadata is %s",f.data);const g=f.headers.get(t.HEADER_NAME);if(g!==t.HEADER_VALUE)throw new RangeError(`Invalid response from metadata service: incorrect ${t.HEADER_NAME} header. Expected '${t.HEADER_VALUE}', got ${g?`'${g}'`:"no header"}`);if("string"==typeof f.data)try{return u.parse(f.data)}catch{}return f.data}async function m(e){const n={...e,url:e.url?.toString().replace(h(),h(t.SECONDARY_HOST_ADDRESS))},o=(0,c.request)(e),r=(0,c.request)(n);return Promise.any([o,r])}let g;function b(){return null===t.gcpResidencyCache&&y(),t.gcpResidencyCache}function y(e=null){t.gcpResidencyCache=null!==e?e:(0,l.detectGCPResidency)()}function v(){return b()?0:3e3}t.METADATA_SERVER_DETECTION=Object.freeze({"assume-present":"don't try to ping the metadata server, but assume it's present",none:"don't try to ping the metadata server, but don't try to use it either","bios-only":"treat the result of a BIOS probe as canonical (don't fall back to pinging)","ping-only":"skip the BIOS probe, and go straight to pinging"}),t.gcpResidencyCache=null,s(n(36128),t)},50199:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDefaultOptions=t.defaultOptions=t.jsonDescription=t.ignoreOverride=void 0,t.ignoreOverride=Symbol("Let zodToJsonSchema decide on which parser to use");t.jsonDescription=(e,t)=>{if(t.description)try{return{...e,...JSON.parse(t.description)}}catch{}return e},t.defaultOptions={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"};t.getDefaultOptions=e=>"string"==typeof e?{...t.defaultOptions,name:e}:{...t.defaultOptions,...e}},29195:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRefs=void 0;const o=n(50199);t.getRefs=e=>{const t=(0,o.getDefaultOptions)(e),n=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}}},22691:(e,t)=>{"use strict";function n(e,t,n,o){o?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}Object.defineProperty(t,"__esModule",{value:!0}),t.setResponseValueAndErrors=t.addErrorMessage=void 0,t.addErrorMessage=n,t.setResponseValueAndErrors=function(e,t,o,r,i){e[t]=o,n(e,t,r,i)}},90946:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRelativePath=void 0;t.getRelativePath=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")}},76885:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(50199),t),r(n(29195),t),r(n(22691),t),r(n(90946),t),r(n(41607),t),r(n(23361),t),r(n(59624),t),r(n(95663),t),r(n(41107),t),r(n(10282),t),r(n(93406),t),r(n(2201),t),r(n(13148),t),r(n(45635),t),r(n(23468),t),r(n(53981),t),r(n(51057),t),r(n(49197),t),r(n(12136),t),r(n(92302),t),r(n(90108),t),r(n(58465),t),r(n(99549),t),r(n(57717),t),r(n(29935),t),r(n(77488),t),r(n(93246),t),r(n(91119),t),r(n(44394),t),r(n(69549),t),r(n(22706),t),r(n(63481),t),r(n(8448),t),r(n(8426),t),r(n(8013),t),r(n(6960),t),r(n(40402),t),r(n(71484),t);const i=n(71484);t.default=i.zodToJsonSchema},41607:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDef=void 0;const o=n(50199),r=n(40402),i=n(90946),a=n(59624);t.parseDef=function e(t,n,i=!1){const a=n.seen.get(t);if(n.override){const e=n.override?.(t,n,a,i);if(e!==o.ignoreOverride)return e}if(a&&!i){const e=s(a,n);if(void 0!==e)return e}const u={def:t,path:n.currentPath,jsonSchema:void 0};n.seen.set(t,u);const l=(0,r.selectParser)(t,t.typeName,n),d="function"==typeof l?e(l(),n):l;if(d&&c(t,n,d),n.postProcess){const e=n.postProcess(d,t,n);return u.jsonSchema=d,e}return u.jsonSchema=d,d};const s=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:(0,i.getRelativePath)(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),(0,a.parseAnyDef)(t)):"seen"===t.$refStrategy?(0,a.parseAnyDef)(t):void 0}},c=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n)},23361:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},59624:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseAnyDef=void 0;const o=n(90946);t.parseAnyDef=function(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?(0,o.getRelativePath)(t,e.currentPath):t.join("/")}}},95663:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseArrayDef=void 0;const o=n(19968),r=n(22691),i=n(41607);t.parseArrayDef=function(e,t){const n={type:"array"};return e.type?._def&&e.type?._def?.typeName!==o.ZodFirstPartyTypeKind.ZodAny&&(n.items=(0,i.parseDef)(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(0,r.setResponseValueAndErrors)(n,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&(0,r.setResponseValueAndErrors)(n,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&((0,r.setResponseValueAndErrors)(n,"minItems",e.exactLength.value,e.exactLength.message,t),(0,r.setResponseValueAndErrors)(n,"maxItems",e.exactLength.value,e.exactLength.message,t)),n}},41107:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBigintDef=void 0;const o=n(22691);t.parseBigintDef=function(e,t){const n={type:"integer",format:"int64"};if(!e.checks)return n;for(const r of e.checks)switch(r.kind){case"min":"jsonSchema7"===t.target?r.inclusive?(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t):(0,o.setResponseValueAndErrors)(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t));break;case"max":"jsonSchema7"===t.target?r.inclusive?(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t):(0,o.setResponseValueAndErrors)(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t));break;case"multipleOf":(0,o.setResponseValueAndErrors)(n,"multipleOf",r.value,r.message,t)}return n}},10282:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBooleanDef=void 0,t.parseBooleanDef=function(){return{type:"boolean"}}},93406:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBrandedDef=void 0;const o=n(41607);t.parseBrandedDef=function(e,t){return(0,o.parseDef)(e.type._def,t)}},2201:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseCatchDef=void 0;const o=n(41607);t.parseCatchDef=(e,t)=>(0,o.parseDef)(e.innerType._def,t)},13148:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDateDef=void 0;const o=n(22691);t.parseDateDef=function e(t,n,o){const i=o??n.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((o,r)=>e(t,n,o))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return r(t,n)}};const r=(e,t)=>{const n={type:"integer",format:"unix-time"};if("openApi3"===t.target)return n;for(const r of e.checks)switch(r.kind){case"min":(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t);break;case"max":(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t)}return n}},45635:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDefaultDef=void 0;const o=n(41607);t.parseDefaultDef=function(e,t){return{...(0,o.parseDef)(e.innerType._def,t),default:e.defaultValue()}}},23468:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEffectsDef=void 0;const o=n(41607),r=n(59624);t.parseEffectsDef=function(e,t){return"input"===t.effectStrategy?(0,o.parseDef)(e.schema._def,t):(0,r.parseAnyDef)(t)}},53981:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnumDef=void 0,t.parseEnumDef=function(e){return{type:"string",enum:Array.from(e.values)}}},51057:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseIntersectionDef=void 0;const o=n(41607);t.parseIntersectionDef=function(e,t){const n=[(0,o.parseDef)(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),(0,o.parseDef)(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let r="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const i=[];return n.forEach(e=>{if("type"in(t=e)&&"string"===t.type||!("allOf"in t)){let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:n,...o}=e;t=o}else r=void 0;i.push(t)}else i.push(...e.allOf),void 0===e.unevaluatedProperties&&(r=void 0);var t}),i.length?{allOf:i,...r}:void 0}},49197:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseLiteralDef=void 0,t.parseLiteralDef=function(e,t){const n=typeof e.value;return"bigint"!==n&&"number"!==n&&"boolean"!==n&&"string"!==n?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===n?"integer":n,enum:[e.value]}:{type:"bigint"===n?"integer":n,const:e.value}}},12136:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseMapDef=void 0;const o=n(41607),r=n(69549),i=n(59624);t.parseMapDef=function(e,t){return"record"===t.mapStrategy?(0,r.parseRecordDef)(e,t):{type:"array",maxItems:125,items:{type:"array",items:[(0,o.parseDef)(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||(0,i.parseAnyDef)(t),(0,o.parseDef)(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||(0,i.parseAnyDef)(t)],minItems:2,maxItems:2}}}},92302:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNativeEnumDef=void 0,t.parseNativeEnumDef=function(e){const t=e.values,n=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),o=Array.from(new Set(n.map(e=>typeof e)));return{type:1===o.length?"string"===o[0]?"string":"number":["string","number"],enum:n}}},90108:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNeverDef=void 0;const o=n(59624);t.parseNeverDef=function(e){return"openAi"===e.target?void 0:{not:(0,o.parseAnyDef)({...e,currentPath:[...e.currentPath,"not"]})}}},58465:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNullDef=void 0,t.parseNullDef=function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}},99549:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNullableDef=void 0;const o=n(41607),r=n(8013);t.parseNullableDef=function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:r.primitiveMappings[e.innerType._def.typeName],nullable:!0}:{type:[r.primitiveMappings[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const n=(0,o.parseDef)(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const n=(0,o.parseDef)(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}},57717:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNumberDef=void 0;const o=n(22691);t.parseNumberDef=function(e,t){const n={type:"number"};if(!e.checks)return n;for(const r of e.checks)switch(r.kind){case"int":n.type="integer",(0,o.addErrorMessage)(n,"type",r.message,t);break;case"min":"jsonSchema7"===t.target?r.inclusive?(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t):(0,o.setResponseValueAndErrors)(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),(0,o.setResponseValueAndErrors)(n,"minimum",r.value,r.message,t));break;case"max":"jsonSchema7"===t.target?r.inclusive?(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t):(0,o.setResponseValueAndErrors)(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),(0,o.setResponseValueAndErrors)(n,"maximum",r.value,r.message,t));break;case"multipleOf":(0,o.setResponseValueAndErrors)(n,"multipleOf",r.value,r.message,t)}return n}},29935:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseObjectDef=void 0;const o=n(41607);function r(e){try{return e.isOptional()}catch{return!0}}t.parseObjectDef=function(e,t){const n="openAi"===t.target,i={type:"object",properties:{}},a=[],s=e.shape();for(const e in s){let c=s[e];if(void 0===c||void 0===c._def)continue;let u=r(c);u&&n&&("ZodOptional"===c._def.typeName&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);const l=(0,o.parseDef)(c._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==l&&(i.properties[e]=l,u||a.push(e))}a.length&&(i.required=a);const c=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return(0,o.parseDef)(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==c&&(i.additionalProperties=c),i}},77488:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseOptionalDef=void 0;const o=n(41607),r=n(59624);t.parseOptionalDef=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return(0,o.parseDef)(e.innerType._def,t);const n=(0,o.parseDef)(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return n?{anyOf:[{not:(0,r.parseAnyDef)(t)},n]}:(0,r.parseAnyDef)(t)}},93246:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parsePipelineDef=void 0;const o=n(41607);t.parsePipelineDef=(e,t)=>{if("input"===t.pipeStrategy)return(0,o.parseDef)(e.in._def,t);if("output"===t.pipeStrategy)return(0,o.parseDef)(e.out._def,t);const n=(0,o.parseDef)(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[n,(0,o.parseDef)(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]})].filter(e=>void 0!==e)}}},91119:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parsePromiseDef=void 0;const o=n(41607);t.parsePromiseDef=function(e,t){return(0,o.parseDef)(e.type._def,t)}},44394:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseReadonlyDef=void 0;const o=n(41607);t.parseReadonlyDef=(e,t)=>(0,o.parseDef)(e.innerType._def,t)},69549:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRecordDef=void 0;const o=n(19968),r=n(41607),i=n(63481),a=n(93406),s=n(59624);t.parseRecordDef=function(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===o.ZodFirstPartyTypeKind.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,o)=>({...n,[o]:(0,r.parseDef)(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",o]})??(0,s.parseAnyDef)(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const n={type:"object",additionalProperties:(0,r.parseDef)(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return n;if(e.keyType?._def.typeName===o.ZodFirstPartyTypeKind.ZodString&&e.keyType._def.checks?.length){const{type:o,...r}=(0,i.parseStringDef)(e.keyType._def,t);return{...n,propertyNames:r}}if(e.keyType?._def.typeName===o.ZodFirstPartyTypeKind.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===o.ZodFirstPartyTypeKind.ZodBranded&&e.keyType._def.type._def.typeName===o.ZodFirstPartyTypeKind.ZodString&&e.keyType._def.type._def.checks?.length){const{type:o,...r}=(0,a.parseBrandedDef)(e.keyType._def,t);return{...n,propertyNames:r}}return n}},22706:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseSetDef=void 0;const o=n(22691),r=n(41607);t.parseSetDef=function(e,t){const n={type:"array",uniqueItems:!0,items:(0,r.parseDef)(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(0,o.setResponseValueAndErrors)(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&(0,o.setResponseValueAndErrors)(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}},63481:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseStringDef=t.zodPatterns=void 0;const o=n(22691);let r;function i(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let n=0;n<e.length;n++)a.has(e[n])||(t+="\\"),t+=e[n];return t}(e):e}t.zodPatterns={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===r&&(r=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),r),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/},t.parseStringDef=function(e,n){const r={type:"string"};if(e.checks)for(const a of e.checks)switch(a.kind){case"min":(0,o.setResponseValueAndErrors)(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value,a.message,n);break;case"max":(0,o.setResponseValueAndErrors)(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value,a.message,n);break;case"email":switch(n.emailStrategy){case"format:email":s(r,"email",a.message,n);break;case"format:idn-email":s(r,"idn-email",a.message,n);break;case"pattern:zod":c(r,t.zodPatterns.email,a.message,n)}break;case"url":s(r,"uri",a.message,n);break;case"uuid":s(r,"uuid",a.message,n);break;case"regex":c(r,a.regex,a.message,n);break;case"cuid":c(r,t.zodPatterns.cuid,a.message,n);break;case"cuid2":c(r,t.zodPatterns.cuid2,a.message,n);break;case"startsWith":c(r,RegExp(`^${i(a.value,n)}`),a.message,n);break;case"endsWith":c(r,RegExp(`${i(a.value,n)}$`),a.message,n);break;case"datetime":s(r,"date-time",a.message,n);break;case"date":s(r,"date",a.message,n);break;case"time":s(r,"time",a.message,n);break;case"duration":s(r,"duration",a.message,n);break;case"length":(0,o.setResponseValueAndErrors)(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value,a.message,n),(0,o.setResponseValueAndErrors)(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value,a.message,n);break;case"includes":c(r,RegExp(i(a.value,n)),a.message,n);break;case"ip":"v6"!==a.version&&s(r,"ipv4",a.message,n),"v4"!==a.version&&s(r,"ipv6",a.message,n);break;case"base64url":c(r,t.zodPatterns.base64url,a.message,n);break;case"jwt":c(r,t.zodPatterns.jwt,a.message,n);break;case"cidr":"v6"!==a.version&&c(r,t.zodPatterns.ipv4Cidr,a.message,n),"v4"!==a.version&&c(r,t.zodPatterns.ipv6Cidr,a.message,n);break;case"emoji":c(r,t.zodPatterns.emoji(),a.message,n);break;case"ulid":c(r,t.zodPatterns.ulid,a.message,n);break;case"base64":switch(n.base64Strategy){case"format:binary":s(r,"binary",a.message,n);break;case"contentEncoding:base64":(0,o.setResponseValueAndErrors)(r,"contentEncoding","base64",a.message,n);break;case"pattern:zod":c(r,t.zodPatterns.base64,a.message,n)}break;case"nanoid":c(r,t.zodPatterns.nanoid,a.message,n);case"toLowerCase":case"toUpperCase":case"trim":break;default:(()=>{})()}return r};const a=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function s(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):(0,o.setResponseValueAndErrors)(e,"format",t,n,r)}function c(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:u(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):(0,o.setResponseValueAndErrors)(e,"pattern",u(t,r),n,r)}function u(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;const n=e.flags.includes("i"),o=e.flags.includes("m"),r=e.flags.includes("s"),i=n?e.source.toLowerCase():e.source;let a="",s=!1,c=!1,u=!1;for(let e=0;e<i.length;e++)if(s)a+=i[e],s=!1;else{if(n)if(c){if(i[e].match(/[a-z]/)){u?(a+=i[e],a+=`${i[e-2]}-${i[e]}`.toUpperCase(),u=!1):"-"===i[e+1]&&i[e+2]?.match(/[a-z]/)?(a+=i[e],u=!0):a+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){a+=`[${i[e]}${i[e].toUpperCase()}]`;continue}if(o){if("^"===i[e]){a+="(^|(?<=[\r\n]))";continue}if("$"===i[e]){a+="($|(?=[\r\n]))";continue}}r&&"."===i[e]?a+=c?`${i[e]}\r\n`:`[${i[e]}\r\n]`:(a+=i[e],"\\"===i[e]?s=!0:c&&"]"===i[e]?c=!1:c||"["!==i[e]||(c=!0))}try{new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return a}},8448:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseTupleDef=void 0;const o=n(41607);t.parseTupleDef=function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,n)=>(0,o.parseDef)(e._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:(0,o.parseDef)(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>(0,o.parseDef)(e._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}},8426:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUndefinedDef=void 0;const o=n(59624);t.parseUndefinedDef=function(e){return{not:(0,o.parseAnyDef)(e)}}},8013:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUnionDef=t.primitiveMappings=void 0;const o=n(41607);t.primitiveMappings={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},t.parseUnionDef=function(e,n){if("openApi3"===n.target)return r(e,n);const o=e.options instanceof Map?Array.from(e.options.values()):e.options;if(o.every(e=>e._def.typeName in t.primitiveMappings&&(!e._def.checks||!e._def.checks.length))){const e=o.reduce((e,n)=>{const o=t.primitiveMappings[n._def.typeName];return o&&!e.includes(o)?[...e,o]:e},[]);return{type:e.length>1?e:e[0]}}if(o.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=o.reduce((e,t)=>{const n=typeof t._def.value;switch(n){case"string":case"number":case"boolean":return[...e,n];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===o.length){const t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:o.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(o.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:o.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return r(e,n)};const r=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>(0,o.parseDef)(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0}},6960:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUnknownDef=void 0;const o=n(59624);t.parseUnknownDef=function(e){return(0,o.parseAnyDef)(e)}},40402:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.selectParser=void 0;const o=n(19968),r=n(59624),i=n(95663),a=n(41107),s=n(10282),c=n(93406),u=n(2201),l=n(13148),d=n(45635),p=n(23468),h=n(53981),f=n(51057),m=n(49197),g=n(12136),b=n(92302),y=n(90108),v=n(58465),_=n(99549),w=n(57717),O=n(29935),S=n(77488),x=n(93246),T=n(91119),P=n(69549),C=n(22706),k=n(63481),j=n(8448),E=n(8426),R=n(8013),A=n(6960),I=n(44394);t.selectParser=(e,t,n)=>{switch(t){case o.ZodFirstPartyTypeKind.ZodString:return(0,k.parseStringDef)(e,n);case o.ZodFirstPartyTypeKind.ZodNumber:return(0,w.parseNumberDef)(e,n);case o.ZodFirstPartyTypeKind.ZodObject:return(0,O.parseObjectDef)(e,n);case o.ZodFirstPartyTypeKind.ZodBigInt:return(0,a.parseBigintDef)(e,n);case o.ZodFirstPartyTypeKind.ZodBoolean:return(0,s.parseBooleanDef)();case o.ZodFirstPartyTypeKind.ZodDate:return(0,l.parseDateDef)(e,n);case o.ZodFirstPartyTypeKind.ZodUndefined:return(0,E.parseUndefinedDef)(n);case o.ZodFirstPartyTypeKind.ZodNull:return(0,v.parseNullDef)(n);case o.ZodFirstPartyTypeKind.ZodArray:return(0,i.parseArrayDef)(e,n);case o.ZodFirstPartyTypeKind.ZodUnion:case o.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return(0,R.parseUnionDef)(e,n);case o.ZodFirstPartyTypeKind.ZodIntersection:return(0,f.parseIntersectionDef)(e,n);case o.ZodFirstPartyTypeKind.ZodTuple:return(0,j.parseTupleDef)(e,n);case o.ZodFirstPartyTypeKind.ZodRecord:return(0,P.parseRecordDef)(e,n);case o.ZodFirstPartyTypeKind.ZodLiteral:return(0,m.parseLiteralDef)(e,n);case o.ZodFirstPartyTypeKind.ZodEnum:return(0,h.parseEnumDef)(e);case o.ZodFirstPartyTypeKind.ZodNativeEnum:return(0,b.parseNativeEnumDef)(e);case o.ZodFirstPartyTypeKind.ZodNullable:return(0,_.parseNullableDef)(e,n);case o.ZodFirstPartyTypeKind.ZodOptional:return(0,S.parseOptionalDef)(e,n);case o.ZodFirstPartyTypeKind.ZodMap:return(0,g.parseMapDef)(e,n);case o.ZodFirstPartyTypeKind.ZodSet:return(0,C.parseSetDef)(e,n);case o.ZodFirstPartyTypeKind.ZodLazy:return()=>e.getter()._def;case o.ZodFirstPartyTypeKind.ZodPromise:return(0,T.parsePromiseDef)(e,n);case o.ZodFirstPartyTypeKind.ZodNaN:case o.ZodFirstPartyTypeKind.ZodNever:return(0,y.parseNeverDef)(n);case o.ZodFirstPartyTypeKind.ZodEffects:return(0,p.parseEffectsDef)(e,n);case o.ZodFirstPartyTypeKind.ZodAny:return(0,r.parseAnyDef)(n);case o.ZodFirstPartyTypeKind.ZodUnknown:return(0,A.parseUnknownDef)(n);case o.ZodFirstPartyTypeKind.ZodDefault:return(0,d.parseDefaultDef)(e,n);case o.ZodFirstPartyTypeKind.ZodBranded:return(0,c.parseBrandedDef)(e,n);case o.ZodFirstPartyTypeKind.ZodReadonly:return(0,I.parseReadonlyDef)(e,n);case o.ZodFirstPartyTypeKind.ZodCatch:return(0,u.parseCatchDef)(e,n);case o.ZodFirstPartyTypeKind.ZodPipeline:return(0,x.parsePipelineDef)(e,n);case o.ZodFirstPartyTypeKind.ZodFunction:case o.ZodFirstPartyTypeKind.ZodVoid:case o.ZodFirstPartyTypeKind.ZodSymbol:default:return}}},71484:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zodToJsonSchema=void 0;const o=n(41607),r=n(29195),i=n(59624);t.zodToJsonSchema=(e,t)=>{const n=(0,r.getRefs)(t);let a="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:(0,o.parseDef)(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??(0,i.parseAnyDef)(n)}),{}):void 0;const s="string"==typeof t?t:"title"===t?.nameStrategy?void 0:t?.name,c=(0,o.parseDef)(e._def,void 0===s?n:{...n,currentPath:[...n.basePath,n.definitionPath,s]},!1)??(0,i.parseAnyDef)(n),u="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==u&&(c.title=u),n.flags.hasReferencedOpenAiAnyType&&(a||(a={}),a[n.openAiAnyTypeName]||(a[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===n.$refStrategy?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));const l=void 0===s?a?{...c,[n.definitionPath]:a}:c:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,s].join("/"),[n.definitionPath]:{...a,[s]:c}};return"jsonSchema7"===n.target?l.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==n.target&&"openAi"!==n.target||(l.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===n.target&&("anyOf"in l||"oneOf"in l||"allOf"in l||"type"in l&&Array.isArray(l.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),l}},38823:(e,t,n)=>{"use strict";const o=n(66495);e.exports={pkg:o}},65470:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.USER_AGENT=t.PRODUCT_NAME=t.pkg=void 0;const o=n(96066);t.pkg=o;const r="google-api-nodejs-client";t.PRODUCT_NAME=r;const i=`${r}/${o.version}`;t.USER_AGENT=i},91087:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ZodError=t.quotelessJson=t.ZodIssueCode=void 0;const o=n(22046);t.ZodIssueCode=o.util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);t.quotelessJson=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},n={_errors:[]},o=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(o);else if("invalid_return_type"===r.code)o(r.returnTypeError);else if("invalid_arguments"===r.code)o(r.argumentsError);else if(0===r.path.length)n._errors.push(t(r));else{let e=n,o=0;for(;o<r.path.length;){const n=r.path[o];o===r.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(r))):e[n]=e[n]||{_errors:[]},e=e[n],o++}}};return o(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,o.util.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t=Object.create(null),n=[];for(const o of this.issues)if(o.path.length>0){const n=o.path[0];t[n]=t[n]||[],t[n].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}t.ZodError=r,r.create=e=>new r(e)},11977:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.defaultErrorMap=void 0,t.setErrorMap=function(e){i=e},t.getErrorMap=function(){return i};const r=o(n(44097));t.defaultErrorMap=r.default;let i=r.default},68953:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(11977),t),r(n(991),t),r(n(43006),t),r(n(22046),t),r(n(15063),t),r(n(91087),t)},58508:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.errorUtil=void 0,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(n||(t.errorUtil=n={}))},991:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isAsync=t.isValid=t.isDirty=t.isAborted=t.OK=t.DIRTY=t.INVALID=t.ParseStatus=t.EMPTY_PATH=t.makeIssue=void 0,t.addIssueToContext=function(e,n){const o=(0,r.getErrorMap)(),a=(0,t.makeIssue)({issueData:n,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,o,o===i.default?void 0:i.default].filter(e=>!!e)});e.common.issues.push(a)};const r=n(11977),i=o(n(44097));t.makeIssue=e=>{const{data:t,path:n,errorMaps:o,issueData:r}=e,i=[...n,...r.path||[]],a={...r,path:i};if(void 0!==r.message)return{...r,path:i,message:r.message};let s="";const c=o.filter(e=>!!e).slice().reverse();for(const e of c)s=e(a,{data:t,defaultError:s}).message;return{...r,path:i,message:s}},t.EMPTY_PATH=[];class a{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,n){const o=[];for(const r of n){if("aborted"===r.status)return t.INVALID;"dirty"===r.status&&e.dirty(),o.push(r.value)}return{status:e.value,value:o}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,o=await e.value;n.push({key:t,value:o})}return a.mergeObjectSync(e,n)}static mergeObjectSync(e,n){const o={};for(const r of n){const{key:n,value:i}=r;if("aborted"===n.status)return t.INVALID;if("aborted"===i.status)return t.INVALID;"dirty"===n.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"===n.value||void 0===i.value&&!r.alwaysSet||(o[n.value]=i.value)}return{status:e.value,value:o}}}t.ParseStatus=a,t.INVALID=Object.freeze({status:"aborted"});t.DIRTY=e=>({status:"dirty",value:e});t.OK=e=>({status:"valid",value:e});t.isAborted=e=>"aborted"===e.status;t.isDirty=e=>"dirty"===e.status;t.isValid=e=>"valid"===e.status;t.isAsync=e=>"undefined"!=typeof Promise&&e instanceof Promise},43006:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},22046:(e,t)=>{"use strict";var n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.getParsedType=t.ZodParsedType=t.objectUtil=t.util=void 0,function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),o={};for(const e of n)o[e]=t[e];return e.objectValues(o)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(n||(t.util=n={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(o||(t.objectUtil=o={})),t.ZodParsedType=n.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);t.getParsedType=e=>{switch(typeof e){case"undefined":return t.ZodParsedType.undefined;case"string":return t.ZodParsedType.string;case"number":return Number.isNaN(e)?t.ZodParsedType.nan:t.ZodParsedType.number;case"boolean":return t.ZodParsedType.boolean;case"function":return t.ZodParsedType.function;case"bigint":return t.ZodParsedType.bigint;case"symbol":return t.ZodParsedType.symbol;case"object":return Array.isArray(e)?t.ZodParsedType.array:null===e?t.ZodParsedType.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?t.ZodParsedType.promise:"undefined"!=typeof Map&&e instanceof Map?t.ZodParsedType.map:"undefined"!=typeof Set&&e instanceof Set?t.ZodParsedType.set:"undefined"!=typeof Date&&e instanceof Date?t.ZodParsedType.date:t.ZodParsedType.object;default:return t.ZodParsedType.unknown}}},19968:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return r(t,e),t},a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.z=void 0;const s=i(n(68953));t.z=s,a(n(68953),t),t.default=s},44097:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(91087),r=n(22046);t.default=(e,t)=>{let n;switch(e.code){case o.ZodIssueCode.invalid_type:n=e.received===r.ZodParsedType.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case o.ZodIssueCode.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,r.util.jsonStringifyReplacer)}`;break;case o.ZodIssueCode.unrecognized_keys:n=`Unrecognized key(s) in object: ${r.util.joinValues(e.keys,", ")}`;break;case o.ZodIssueCode.invalid_union:n="Invalid input";break;case o.ZodIssueCode.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${r.util.joinValues(e.options)}`;break;case o.ZodIssueCode.invalid_enum_value:n=`Invalid enum value. Expected ${r.util.joinValues(e.options)}, received '${e.received}'`;break;case o.ZodIssueCode.invalid_arguments:n="Invalid function arguments";break;case o.ZodIssueCode.invalid_return_type:n="Invalid function return type";break;case o.ZodIssueCode.invalid_date:n="Invalid date";break;case o.ZodIssueCode.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:r.util.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case o.ZodIssueCode.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case o.ZodIssueCode.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case o.ZodIssueCode.custom:n="Invalid input";break;case o.ZodIssueCode.invalid_intersection_types:n="Intersection results could not be merged";break;case o.ZodIssueCode.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case o.ZodIssueCode.not_finite:n="Number must be finite";break;default:n=t.defaultError,r.util.assertNever(e)}return{message:n}},e.exports=t.default},15063:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.discriminatedUnion=t.date=t.boolean=t.bigint=t.array=t.any=t.coerce=t.ZodFirstPartyTypeKind=t.late=t.ZodSchema=t.Schema=t.ZodReadonly=t.ZodPipeline=t.ZodBranded=t.BRAND=t.ZodNaN=t.ZodCatch=t.ZodDefault=t.ZodNullable=t.ZodOptional=t.ZodTransformer=t.ZodEffects=t.ZodPromise=t.ZodNativeEnum=t.ZodEnum=t.ZodLiteral=t.ZodLazy=t.ZodFunction=t.ZodSet=t.ZodMap=t.ZodRecord=t.ZodTuple=t.ZodIntersection=t.ZodDiscriminatedUnion=t.ZodUnion=t.ZodObject=t.ZodArray=t.ZodVoid=t.ZodNever=t.ZodUnknown=t.ZodAny=t.ZodNull=t.ZodUndefined=t.ZodSymbol=t.ZodDate=t.ZodBoolean=t.ZodBigInt=t.ZodNumber=t.ZodString=t.ZodType=void 0,t.NEVER=t.void=t.unknown=t.union=t.undefined=t.tuple=t.transformer=t.symbol=t.string=t.strictObject=t.set=t.record=t.promise=t.preprocess=t.pipeline=t.ostring=t.optional=t.onumber=t.oboolean=t.object=t.number=t.nullable=t.null=t.never=t.nativeEnum=t.nan=t.map=t.literal=t.lazy=t.intersection=t.instanceof=t.function=t.enum=t.effect=void 0,t.datetimeRegex=R,t.custom=Se;const o=n(91087),r=n(11977),i=n(58508),a=n(991),s=n(22046);class c{constructor(e,t,n,o){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const u=(e,t)=>{if((0,a.isValid)(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new o.ZodError(e.common.issues);return this._error=t,this._error}}};function l(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:o,description:r}=e;if(t&&(n||o))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:r};return{errorMap:(t,r)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??r.defaultError}:void 0===r.data?{message:i??o??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:i??n??r.defaultError}},description:r}}class d{get description(){return this._def.description}_getType(e){return(0,s.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0,s.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new a.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,s.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if((0,a.isAsync)(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,s.getParsedType)(e)},o=this._parseSync({data:e,path:n.path,parent:n});return u(n,o)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,s.getParsedType)(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return(0,a.isValid)(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>(0,a.isValid)(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,s.getParsedType)(e)},o=this._parse({data:e,path:n.path,parent:n}),r=await((0,a.isAsync)(o)?o:Promise.resolve(o));return u(n,r)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,r)=>{const i=e(t),a=()=>r.addIssue({code:o.ZodIssueCode.custom,...n(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(e=>!!e||(a(),!1)):!!i||(a(),!1)})}refinement(e,t){return this._refinement((n,o)=>!!e(n)||(o.addIssue("function"==typeof t?t(n,o):t),!1))}_refinement(e){return new he({schema:this,typeName:xe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return fe.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return z.create(this)}promise(){return pe.create(this,this._def)}or(e){return Z.create([this,e],this._def)}and(e){return te.create(this,e,this._def)}transform(e){return new he({...l(this._def),schema:this,typeName:xe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ge({...l(this._def),innerType:this,defaultValue:t,typeName:xe.ZodDefault})}brand(){return new ve({typeName:xe.ZodBranded,type:this,...l(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new be({...l(this._def),innerType:this,catchValue:t,typeName:xe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return _e.create(this,e)}readonly(){return we.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}t.ZodType=d,t.Schema=d,t.ZodSchema=d;const p=/^c[^\s-]{8,}$/i,h=/^[0-9a-z]+$/,f=/^[0-9A-HJKMNP-TV-Z]{26}$/i,m=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,g=/^[a-z0-9_-]{21}$/i,b=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,y=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,v=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let _;const w=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,O=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,S=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,x=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,T=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,P=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,C="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",k=new RegExp(`^${C}$`);function j(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function E(e){return new RegExp(`^${j(e)}$`)}function R(e){let t=`${C}T${j(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function A(e,t){return!("v4"!==t&&t||!w.test(e))||!("v6"!==t&&t||!S.test(e))}function I(e,t){if(!b.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(o));return"object"==typeof r&&null!==r&&((!("typ"in r)||"JWT"===r?.typ)&&(!!r.alg&&(!t||r.alg===t)))}catch{return!1}}function M(e,t){return!("v4"!==t&&t||!O.test(e))||!("v6"!==t&&t||!x.test(e))}class N extends d{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==s.ZodParsedType.string){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.string,received:t.parsedType}),a.INVALID}const t=new a.ParseStatus;let n;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const i=e.data.length>r.value,s=e.data.length<r.value;(i||s)&&(n=this._getOrReturnCtx(e,n),i?(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):s&&(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)v.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"email",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)_||(_=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"emoji",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)m.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"uuid",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)g.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"nanoid",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)p.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"cuid",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)h.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"cuid2",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)f.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"ulid",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"url",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()}else if("regex"===r.kind){r.regex.lastIndex=0;r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"regex",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty())}else if("trim"===r.kind)e.data=e.data.trim();else if("includes"===r.kind)e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty());else if("toLowerCase"===r.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===r.kind)e.data=e.data.toUpperCase();else if("startsWith"===r.kind)e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty());else if("endsWith"===r.kind)e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty());else if("datetime"===r.kind){R(r).test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:"datetime",message:r.message}),t.dirty())}else if("date"===r.kind){k.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:"date",message:r.message}),t.dirty())}else if("time"===r.kind){E(r).test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_string,validation:"time",message:r.message}),t.dirty())}else"duration"===r.kind?y.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"duration",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?A(e.data,r.version)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"ip",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"jwt"===r.kind?I(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"jwt",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?M(e.data,r.version)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"cidr",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?T.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"base64",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?P.test(e.data)||(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{validation:"base64url",code:o.ZodIssueCode.invalid_string,message:r.message}),t.dirty()):s.util.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:o.ZodIssueCode.invalid_string,...i.errorUtil.errToObj(n)})}_addCheck(e){return new N({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...i.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...i.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...i.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...i.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...i.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...i.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...i.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...i.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...i.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...i.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...i.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...i.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...i.errorUtil.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...i.errorUtil.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...i.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...i.errorUtil.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...i.errorUtil.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...i.errorUtil.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...i.errorUtil.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...i.errorUtil.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...i.errorUtil.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...i.errorUtil.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...i.errorUtil.errToObj(t)})}nonempty(e){return this.min(1,i.errorUtil.errToObj(e))}trim(){return new N({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new N({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new N({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function $(e,t){const n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,r=n>o?n:o;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}t.ZodString=N,N.create=e=>new N({checks:[],typeName:xe.ZodString,coerce:e?.coerce??!1,...l(e)});class D extends d{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==s.ZodParsedType.number){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.number,received:t.parsedType}),a.INVALID}let t;const n=new a.ParseStatus;for(const r of this._def.checks)if("int"===r.kind)s.util.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else"multipleOf"===r.kind?0!==$(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.not_finite,message:r.message}),n.dirty()):s.util.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,i.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,i.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,i.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,i.errorUtil.toString(t))}setLimit(e,t,n,o){return new D({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:i.errorUtil.toString(o)}]})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:i.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:i.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:i.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:i.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:i.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:i.errorUtil.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:i.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:i.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:i.errorUtil.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&s.util.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}t.ZodNumber=D,D.create=e=>new D({checks:[],typeName:xe.ZodNumber,coerce:e?.coerce||!1,...l(e)});class U extends d{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==s.ZodParsedType.bigint)return this._getInvalidInput(e);let t;const n=new a.ParseStatus;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):s.util.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.bigint,received:t.parsedType}),a.INVALID}gte(e,t){return this.setLimit("min",e,!0,i.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,i.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,i.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,i.errorUtil.toString(t))}setLimit(e,t,n,o){return new U({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:i.errorUtil.toString(o)}]})}_addCheck(e){return new U({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:i.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:i.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:i.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:i.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:i.errorUtil.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}t.ZodBigInt=U,U.create=e=>new U({checks:[],typeName:xe.ZodBigInt,coerce:e?.coerce??!1,...l(e)});class L extends d{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==s.ZodParsedType.boolean){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.boolean,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodBoolean=L,L.create=e=>new L({typeName:xe.ZodBoolean,coerce:e?.coerce||!1,...l(e)});class q extends d{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==s.ZodParsedType.date){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.date,received:t.parsedType}),a.INVALID}if(Number.isNaN(e.data.getTime())){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_date}),a.INVALID}const t=new a.ParseStatus;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):s.util.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:i.errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:i.errorUtil.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}t.ZodDate=q,q.create=e=>new q({checks:[],coerce:e?.coerce||!1,typeName:xe.ZodDate,...l(e)});class F extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.symbol){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.symbol,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodSymbol=F,F.create=e=>new F({typeName:xe.ZodSymbol,...l(e)});class W extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.undefined){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.undefined,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodUndefined=W,W.create=e=>new W({typeName:xe.ZodUndefined,...l(e)});class J extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.null){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.null,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodNull=J,J.create=e=>new J({typeName:xe.ZodNull,...l(e)});class B extends d{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,a.OK)(e.data)}}t.ZodAny=B,B.create=e=>new B({typeName:xe.ZodAny,...l(e)});class G extends d{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,a.OK)(e.data)}}t.ZodUnknown=G,G.create=e=>new G({typeName:xe.ZodUnknown,...l(e)});class V extends d{_parse(e){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.never,received:t.parsedType}),a.INVALID}}t.ZodNever=V,V.create=e=>new V({typeName:xe.ZodNever,...l(e)});class H extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.undefined){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.void,received:t.parsedType}),a.INVALID}return(0,a.OK)(e.data)}}t.ZodVoid=H,H.create=e=>new H({typeName:xe.ZodVoid,...l(e)});class z extends d{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==s.ZodParsedType.array)return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.array,received:t.parsedType}),a.INVALID;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&((0,a.addIssueToContext)(t,{code:e?o.ZodIssueCode.too_big:o.ZodIssueCode.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&((0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&((0,a.addIssueToContext)(t,{code:o.ZodIssueCode.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new c(t,e,t.path,n)))).then(e=>a.ParseStatus.mergeArray(n,e));const i=[...t.data].map((e,n)=>r.type._parseSync(new c(t,e,t.path,n)));return a.ParseStatus.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new z({...this._def,minLength:{value:e,message:i.errorUtil.toString(t)}})}max(e,t){return new z({...this._def,maxLength:{value:e,message:i.errorUtil.toString(t)}})}length(e,t){return new z({...this._def,exactLength:{value:e,message:i.errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}}function K(e){if(e instanceof X){const t={};for(const n in e.shape){const o=e.shape[n];t[n]=fe.create(K(o))}return new X({...e._def,shape:()=>t})}return e instanceof z?new z({...e._def,type:K(e.element)}):e instanceof fe?fe.create(K(e.unwrap())):e instanceof me?me.create(K(e.unwrap())):e instanceof ne?ne.create(e.items.map(e=>K(e))):e}t.ZodArray=z,z.create=(e,t)=>new z({type:e,minLength:null,maxLength:null,exactLength:null,typeName:xe.ZodArray,...l(t)});class X extends d{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=s.util.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==s.ZodParsedType.object){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.object,received:t.parsedType}),a.INVALID}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),u=[];if(!(this._def.catchall instanceof V&&"strip"===this._def.unknownKeys))for(const e in n.data)i.includes(e)||u.push(e);const l=[];for(const e of i){const t=r[e],o=n.data[e];l.push({key:{status:"valid",value:e},value:t._parse(new c(n,o,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof V){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of u)l.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)u.length>0&&((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.unrecognized_keys,keys:u}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of u){const o=n.data[t];l.push({key:{status:"valid",value:t},value:e._parse(new c(n,o,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of l){const n=await t.key,o=await t.value;e.push({key:n,value:o,alwaysSet:t.alwaysSet})}return e}).then(e=>a.ParseStatus.mergeObjectSync(t,e)):a.ParseStatus.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return i.errorUtil.errToObj,new X({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{const o=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:i.errorUtil.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new X({...this._def,unknownKeys:"strip"})}passthrough(){return new X({...this._def,unknownKeys:"passthrough"})}extend(e){return new X({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new X({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:xe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new X({...this._def,catchall:e})}pick(e){const t={};for(const n of s.util.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new X({...this._def,shape:()=>t})}omit(e){const t={};for(const n of s.util.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new X({...this._def,shape:()=>t})}deepPartial(){return K(this)}partial(e){const t={};for(const n of s.util.objectKeys(this.shape)){const o=this.shape[n];e&&!e[n]?t[n]=o:t[n]=o.optional()}return new X({...this._def,shape:()=>t})}required(e){const t={};for(const n of s.util.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof fe;)e=e._def.innerType;t[n]=e}return new X({...this._def,shape:()=>t})}keyof(){return ue(s.util.objectKeys(this.shape))}}t.ZodObject=X,X.create=(e,t)=>new X({shape:()=>e,unknownKeys:"strip",catchall:V.create(),typeName:xe.ZodObject,...l(t)}),X.strictCreate=(e,t)=>new X({shape:()=>e,unknownKeys:"strict",catchall:V.create(),typeName:xe.ZodObject,...l(t)}),X.lazycreate=(e,t)=>new X({shape:e,unknownKeys:"strip",catchall:V.create(),typeName:xe.ZodObject,...l(t)});class Z extends d{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map(e=>new o.ZodError(e.ctx.common.issues));return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_union,unionErrors:n}),a.INVALID});{let e;const r=[];for(const o of n){const n={...t,common:{...t.common,issues:[]},parent:null},i=o._parseSync({data:t.data,path:t.path,parent:n});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=r.map(e=>new o.ZodError(e));return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_union,unionErrors:i}),a.INVALID}}get options(){return this._def.options}}t.ZodUnion=Z,Z.create=(e,t)=>new Z({options:e,typeName:xe.ZodUnion,...l(t)});const Y=e=>e instanceof se?Y(e.schema):e instanceof he?Y(e.innerType()):e instanceof ce?[e.value]:e instanceof le?e.options:e instanceof de?s.util.objectValues(e.enum):e instanceof ge?Y(e._def.innerType):e instanceof W?[void 0]:e instanceof J?[null]:e instanceof fe?[void 0,...Y(e.unwrap())]:e instanceof me?[null,...Y(e.unwrap())]:e instanceof ve||e instanceof we?Y(e.unwrap()):e instanceof be?Y(e._def.innerType):[];class Q extends d{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.ZodParsedType.object)return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.object,received:t.parsedType}),a.INVALID;const n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):((0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),a.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const o=new Map;for(const n of t){const t=Y(n.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const r of t){if(o.has(r))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(r)}`);o.set(r,n)}}return new Q({typeName:xe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:o,...l(n)})}}function ee(e,t){const n=(0,s.getParsedType)(e),o=(0,s.getParsedType)(t);if(e===t)return{valid:!0,data:e};if(n===s.ZodParsedType.object&&o===s.ZodParsedType.object){const n=s.util.objectKeys(t),o=s.util.objectKeys(e).filter(e=>-1!==n.indexOf(e)),r={...e,...t};for(const n of o){const o=ee(e[n],t[n]);if(!o.valid)return{valid:!1};r[n]=o.data}return{valid:!0,data:r}}if(n===s.ZodParsedType.array&&o===s.ZodParsedType.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let o=0;o<e.length;o++){const r=ee(e[o],t[o]);if(!r.valid)return{valid:!1};n.push(r.data)}return{valid:!0,data:n}}return n===s.ZodParsedType.date&&o===s.ZodParsedType.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}t.ZodDiscriminatedUnion=Q;class te extends d{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if((0,a.isAborted)(e)||(0,a.isAborted)(r))return a.INVALID;const i=ee(e.value,r.value);return i.valid?(((0,a.isDirty)(e)||(0,a.isDirty)(r))&&t.dirty(),{status:t.value,value:i.data}):((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_intersection_types}),a.INVALID)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}t.ZodIntersection=te,te.create=(e,t,n)=>new te({left:e,right:t,typeName:xe.ZodIntersection,...l(n)});class ne extends d{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.ZodParsedType.array)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.array,received:n.parsedType}),a.INVALID;if(n.data.length<this._def.items.length)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),a.INVALID;!this._def.rest&&n.data.length>this._def.items.length&&((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((e,t)=>{const o=this._def.items[t]||this._def.rest;return o?o._parse(new c(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>a.ParseStatus.mergeArray(t,e)):a.ParseStatus.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ne({...this._def,rest:e})}}t.ZodTuple=ne,ne.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ne({items:e,typeName:xe.ZodTuple,rest:null,...l(t)})};class oe extends d{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.ZodParsedType.object)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.object,received:n.parsedType}),a.INVALID;const r=[],i=this._def.keyType,u=this._def.valueType;for(const e in n.data)r.push({key:i._parse(new c(n,e,n.path,e)),value:u._parse(new c(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?a.ParseStatus.mergeObjectAsync(t,r):a.ParseStatus.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return new oe(t instanceof d?{keyType:e,valueType:t,typeName:xe.ZodRecord,...l(n)}:{keyType:N.create(),valueType:e,typeName:xe.ZodRecord,...l(t)})}}t.ZodRecord=oe;class re extends d{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.ZodParsedType.map)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.map,received:n.parsedType}),a.INVALID;const r=this._def.keyType,i=this._def.valueType,u=[...n.data.entries()].map(([e,t],o)=>({key:r._parse(new c(n,e,n.path,[o,"key"])),value:i._parse(new c(n,t,n.path,[o,"value"]))}));if(n.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const n of u){const o=await n.key,r=await n.value;if("aborted"===o.status||"aborted"===r.status)return a.INVALID;"dirty"!==o.status&&"dirty"!==r.status||t.dirty(),e.set(o.value,r.value)}return{status:t.value,value:e}})}{const e=new Map;for(const n of u){const o=n.key,r=n.value;if("aborted"===o.status||"aborted"===r.status)return a.INVALID;"dirty"!==o.status&&"dirty"!==r.status||t.dirty(),e.set(o.value,r.value)}return{status:t.value,value:e}}}}t.ZodMap=re,re.create=(e,t,n)=>new re({valueType:t,keyType:e,typeName:xe.ZodMap,...l(n)});class ie extends d{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.ZodParsedType.set)return(0,a.addIssueToContext)(n,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.set,received:n.parsedType}),a.INVALID;const r=this._def;null!==r.minSize&&n.data.size<r.minSize.value&&((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&n.data.size>r.maxSize.value&&((0,a.addIssueToContext)(n,{code:o.ZodIssueCode.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function u(e){const n=new Set;for(const o of e){if("aborted"===o.status)return a.INVALID;"dirty"===o.status&&t.dirty(),n.add(o.value)}return{status:t.value,value:n}}const l=[...n.data.values()].map((e,t)=>i._parse(new c(n,e,n.path,t)));return n.common.async?Promise.all(l).then(e=>u(e)):u(l)}min(e,t){return new ie({...this._def,minSize:{value:e,message:i.errorUtil.toString(t)}})}max(e,t){return new ie({...this._def,maxSize:{value:e,message:i.errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}t.ZodSet=ie,ie.create=(e,t)=>new ie({valueType:e,minSize:null,maxSize:null,typeName:xe.ZodSet,...l(t)});class ae extends d{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.ZodParsedType.function)return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.function,received:t.parsedType}),a.INVALID;function n(e,n){return(0,a.makeIssue)({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,r.getErrorMap)(),r.defaultErrorMap].filter(e=>!!e),issueData:{code:o.ZodIssueCode.invalid_arguments,argumentsError:n}})}function i(e,n){return(0,a.makeIssue)({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,r.getErrorMap)(),r.defaultErrorMap].filter(e=>!!e),issueData:{code:o.ZodIssueCode.invalid_return_type,returnTypeError:n}})}const c={errorMap:t.common.contextualErrorMap},u=t.data;if(this._def.returns instanceof pe){const e=this;return(0,a.OK)(async function(...t){const r=new o.ZodError([]),a=await e._def.args.parseAsync(t,c).catch(e=>{throw r.addIssue(n(t,e)),r}),s=await Reflect.apply(u,this,a);return await e._def.returns._def.type.parseAsync(s,c).catch(e=>{throw r.addIssue(i(s,e)),r})})}{const e=this;return(0,a.OK)(function(...t){const r=e._def.args.safeParse(t,c);if(!r.success)throw new o.ZodError([n(t,r.error)]);const a=Reflect.apply(u,this,r.data),s=e._def.returns.safeParse(a,c);if(!s.success)throw new o.ZodError([i(a,s.error)]);return s.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ae({...this._def,args:ne.create(e).rest(G.create())})}returns(e){return new ae({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ae({args:e||ne.create([]).rest(G.create()),returns:t||G.create(),typeName:xe.ZodFunction,...l(n)})}}t.ZodFunction=ae;class se extends d{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}t.ZodLazy=se,se.create=(e,t)=>new se({getter:e,typeName:xe.ZodLazy,...l(t)});class ce extends d{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{received:t.data,code:o.ZodIssueCode.invalid_literal,expected:this._def.value}),a.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ue(e,t){return new le({values:e,typeName:xe.ZodEnum,...l(t)})}t.ZodLiteral=ce,ce.create=(e,t)=>new ce({value:e,typeName:xe.ZodLiteral,...l(t)});class le extends d{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return(0,a.addIssueToContext)(t,{expected:s.util.joinValues(n),received:t.parsedType,code:o.ZodIssueCode.invalid_type}),a.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return(0,a.addIssueToContext)(t,{received:t.data,code:o.ZodIssueCode.invalid_enum_value,options:n}),a.INVALID}return(0,a.OK)(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return le.create(e,{...this._def,...t})}exclude(e,t=this._def){return le.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}t.ZodEnum=le,le.create=ue;class de extends d{_parse(e){const t=s.util.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==s.ZodParsedType.string&&n.parsedType!==s.ZodParsedType.number){const e=s.util.objectValues(t);return(0,a.addIssueToContext)(n,{expected:s.util.joinValues(e),received:n.parsedType,code:o.ZodIssueCode.invalid_type}),a.INVALID}if(this._cache||(this._cache=new Set(s.util.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=s.util.objectValues(t);return(0,a.addIssueToContext)(n,{received:n.data,code:o.ZodIssueCode.invalid_enum_value,options:e}),a.INVALID}return(0,a.OK)(e.data)}get enum(){return this._def.values}}t.ZodNativeEnum=de,de.create=(e,t)=>new de({values:e,typeName:xe.ZodNativeEnum,...l(t)});class pe extends d{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.ZodParsedType.promise&&!1===t.common.async)return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.promise,received:t.parsedType}),a.INVALID;const n=t.parsedType===s.ZodParsedType.promise?t.data:Promise.resolve(t.data);return(0,a.OK)(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}t.ZodPromise=pe,pe.create=(e,t)=>new pe({type:e,typeName:xe.ZodPromise,...l(t)});class he extends d{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),o=this._def.effect||null,r={addIssue:e=>{(0,a.addIssueToContext)(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===o.type){const e=o.transform(n.data,r);if(n.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return a.INVALID;const o=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===o.status?a.INVALID:"dirty"===o.status||"dirty"===t.value?(0,a.DIRTY)(o.value):o});{if("aborted"===t.value)return a.INVALID;const o=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===o.status?a.INVALID:"dirty"===o.status||"dirty"===t.value?(0,a.DIRTY)(o.value):o}}if("refinement"===o.type){const e=e=>{const t=o.refinement(e,r);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===o.status?a.INVALID:("dirty"===o.status&&t.dirty(),e(o.value),{status:t.value,value:o.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>"aborted"===n.status?a.INVALID:("dirty"===n.status&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if("transform"===o.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!(0,a.isValid)(e))return a.INVALID;const i=o.transform(e.value,r);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>(0,a.isValid)(e)?Promise.resolve(o.transform(e.value,r)).then(e=>({status:t.value,value:e})):a.INVALID)}s.util.assertNever(o)}}t.ZodEffects=he,t.ZodTransformer=he,he.create=(e,t,n)=>new he({schema:e,typeName:xe.ZodEffects,effect:t,...l(n)}),he.createWithPreprocess=(e,t,n)=>new he({schema:t,effect:{type:"preprocess",transform:e},typeName:xe.ZodEffects,...l(n)});class fe extends d{_parse(e){return this._getType(e)===s.ZodParsedType.undefined?(0,a.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t.ZodOptional=fe,fe.create=(e,t)=>new fe({innerType:e,typeName:xe.ZodOptional,...l(t)});class me extends d{_parse(e){return this._getType(e)===s.ZodParsedType.null?(0,a.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t.ZodNullable=me,me.create=(e,t)=>new me({innerType:e,typeName:xe.ZodNullable,...l(t)});class ge extends d{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===s.ZodParsedType.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}t.ZodDefault=ge,ge.create=(e,t)=>new ge({innerType:e,typeName:xe.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...l(t)});class be extends d{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return(0,a.isAsync)(r)?r.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new o.ZodError(n.common.issues)},input:n.data})})):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new o.ZodError(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}t.ZodCatch=be,be.create=(e,t)=>new be({innerType:e,typeName:xe.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...l(t)});class ye extends d{_parse(e){if(this._getType(e)!==s.ZodParsedType.nan){const t=this._getOrReturnCtx(e);return(0,a.addIssueToContext)(t,{code:o.ZodIssueCode.invalid_type,expected:s.ZodParsedType.nan,received:t.parsedType}),a.INVALID}return{status:"valid",value:e.data}}}t.ZodNaN=ye,ye.create=e=>new ye({typeName:xe.ZodNaN,...l(e)}),t.BRAND=Symbol("zod_brand");class ve extends d{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}t.ZodBranded=ve;class _e extends d{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?a.INVALID:"dirty"===e.status?(t.dirty(),(0,a.DIRTY)(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?a.INVALID:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new _e({in:e,out:t,typeName:xe.ZodPipeline})}}t.ZodPipeline=_e;class we extends d{_parse(e){const t=this._def.innerType._parse(e),n=e=>((0,a.isValid)(e)&&(e.value=Object.freeze(e.value)),e);return(0,a.isAsync)(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}}function Oe(e,t){const n="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof n?{message:n}:n}function Se(e,t={},n){return e?B.create().superRefine((o,r)=>{const i=e(o);if(i instanceof Promise)return i.then(e=>{if(!e){const e=Oe(t,o),i=e.fatal??n??!0;r.addIssue({code:"custom",...e,fatal:i})}});if(!i){const e=Oe(t,o),i=e.fatal??n??!0;r.addIssue({code:"custom",...e,fatal:i})}}):B.create()}var xe;t.ZodReadonly=we,we.create=(e,t)=>new we({innerType:e,typeName:xe.ZodReadonly,...l(t)}),t.late={object:X.lazycreate},function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(xe||(t.ZodFirstPartyTypeKind=xe={}));t.instanceof=(e,t={message:`Input not instance of ${e.name}`})=>Se(t=>t instanceof e,t);const Te=N.create;t.string=Te;const Pe=D.create;t.number=Pe;const Ce=ye.create;t.nan=Ce;const ke=U.create;t.bigint=ke;const je=L.create;t.boolean=je;const Ee=q.create;t.date=Ee;const Re=F.create;t.symbol=Re;const Ae=W.create;t.undefined=Ae;const Ie=J.create;t.null=Ie;const Me=B.create;t.any=Me;const Ne=G.create;t.unknown=Ne;const $e=V.create;t.never=$e;const De=H.create;t.void=De;const Ue=z.create;t.array=Ue;const Le=X.create;t.object=Le;const qe=X.strictCreate;t.strictObject=qe;const Fe=Z.create;t.union=Fe;const We=Q.create;t.discriminatedUnion=We;const Je=te.create;t.intersection=Je;const Be=ne.create;t.tuple=Be;const Ge=oe.create;t.record=Ge;const Ve=re.create;t.map=Ve;const He=ie.create;t.set=He;const ze=ae.create;t.function=ze;const Ke=se.create;t.lazy=Ke;const Xe=ce.create;t.literal=Xe;const Ze=le.create;t.enum=Ze;const Ye=de.create;t.nativeEnum=Ye;const Qe=pe.create;t.promise=Qe;const et=he.create;t.effect=et,t.transformer=et;const tt=fe.create;t.optional=tt;const nt=me.create;t.nullable=nt;const ot=he.createWithPreprocess;t.preprocess=ot;const rt=_e.create;t.pipeline=rt;t.ostring=()=>Te().optional();t.onumber=()=>Pe().optional();t.oboolean=()=>je().optional(),t.coerce={string:e=>N.create({...e,coerce:!0}),number:e=>D.create({...e,coerce:!0}),boolean:e=>L.create({...e,coerce:!0}),bigint:e=>U.create({...e,coerce:!0}),date:e=>q.create({...e,coerce:!0})},t.NEVER=a.INVALID},99641:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AssistantMessageEventStream:()=>Zn,EventStream:()=>Xn,StringEnum:()=>ab,Type:()=>o.ZU,buildRequest:()=>Hm,calculateCost:()=>S,clearApiProviders:()=>d,complete:()=>eb,completeSimple:()=>nb,convertMessages:()=>dg,createAssistantMessageEventStream:()=>Yn,extractRetryDelay:()=>Lm,getApiProvider:()=>c,getApiProviders:()=>u,getEnvApiKey:()=>b,getModel:()=>_,getModels:()=>O,getOverflowPatterns:()=>ib,getProviders:()=>w,isContextOverflow:()=>rb,modelsAreEqual:()=>T,parseStreamingJson:()=>eo,registerApiProvider:()=>s,registerBuiltInApiProviders:()=>Xg,resetApiProviders:()=>Zg,setBedrockProviderModule:()=>Bg,stream:()=>Qg,streamAnthropic:()=>mo,streamAzureOpenAIResponses:()=>Fc,streamGoogle:()=>jm,streamGoogleGeminiCli:()=>Gm,streamGoogleVertex:()=>Zm,streamMistral:()=>og,streamOpenAICompletions:()=>ug,streamOpenAIResponses:()=>mg,streamSimple:()=>tb,streamSimpleAnthropic:()=>bo,streamSimpleAzureOpenAIResponses:()=>Wc,streamSimpleGoogle:()=>Em,streamSimpleGoogleGeminiCli:()=>Vm,streamSimpleGoogleVertex:()=>Ym,streamSimpleMistral:()=>rg,streamSimpleOpenAICompletions:()=>lg,streamSimpleOpenAIResponses:()=>gg,supportsXhigh:()=>x,unregisterApiProviders:()=>l,validateToolArguments:()=>fb,validateToolCall:()=>hb});var o=n(26788);const r=new Map;function i(e,t){return(n,o,r)=>{if(n.api!==e)throw new Error(`Mismatched api: ${n.api} expected ${e}`);return t(n,o,r)}}function a(e,t){return(n,o,r)=>{if(n.api!==e)throw new Error(`Mismatched api: ${n.api} expected ${e}`);return t(n,o,r)}}function s(e,t){r.set(e.api,{provider:{api:e.api,stream:i(e.api,e.stream),streamSimple:a(e.api,e.streamSimple)},sourceId:t})}function c(e){return r.get(e)?.provider}function u(){return Array.from(r.values(),e=>e.provider)}function l(e){for(const[t,n]of r.entries())n.sourceId===e&&r.delete(t)}function d(){r.clear()}let p=null,h=null,f=null;const m=e=>n(70162)(e);"undefined"!=typeof process&&(process.versions?.node||process.versions?.bun)&&(m("fs").then(e=>{p=e.existsSync}),m("os").then(e=>{h=e.homedir}),m("path").then(e=>{f=e.join}));let g=null;function b(e){if("github-copilot"===e)return process.env.COPILOT_GITHUB_TOKEN||process.env.GH_TOKEN||process.env.GITHUB_TOKEN;if("anthropic"===e)return process.env.ANTHROPIC_OAUTH_TOKEN||process.env.ANTHROPIC_API_KEY;if("google-vertex"===e){const e=function(){if(null===g){if(!p||!h||!f)return"undefined"!=typeof process&&(process.versions?.node||process.versions?.bun)||(g=!1),!1;const e=process.env.GOOGLE_APPLICATION_CREDENTIALS;g=p(e||f(h(),".config","gcloud","application_default_credentials.json"))}return g}(),t=!(!process.env.GOOGLE_CLOUD_PROJECT&&!process.env.GCLOUD_PROJECT),n=!!process.env.GOOGLE_CLOUD_LOCATION;if(e&&t&&n)return"<authenticated>"}if("amazon-bedrock"===e&&(process.env.AWS_PROFILE||process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY||process.env.AWS_BEARER_TOKEN_BEDROCK||process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI||process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI||process.env.AWS_WEB_IDENTITY_TOKEN_FILE))return"<authenticated>";const t={openai:"OPENAI_API_KEY","azure-openai-responses":"AZURE_OPENAI_API_KEY",google:"GEMINI_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",xai:"XAI_API_KEY",openrouter:"OPENROUTER_API_KEY","vercel-ai-gateway":"AI_GATEWAY_API_KEY",zai:"ZAI_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_CN_API_KEY",huggingface:"HF_TOKEN",opencode:"OPENCODE_API_KEY","opencode-go":"OPENCODE_API_KEY","kimi-coding":"KIMI_API_KEY"}[e];return t?process.env[t]:void 0}const y={"amazon-bedrock":{"amazon.nova-2-lite-v1:0":{id:"amazon.nova-2-lite-v1:0",name:"Nova 2 Lite",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.33,output:2.75,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"amazon.nova-lite-v1:0":{id:"amazon.nova-lite-v1:0",name:"Nova Lite",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.06,output:.24,cacheRead:.015,cacheWrite:0},contextWindow:3e5,maxTokens:8192},"amazon.nova-micro-v1:0":{id:"amazon.nova-micro-v1:0",name:"Nova Micro",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.035,output:.14,cacheRead:.00875,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"amazon.nova-premier-v1:0":{id:"amazon.nova-premier-v1:0",name:"Nova Premier",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:2.5,output:12.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:16384},"amazon.nova-pro-v1:0":{id:"amazon.nova-pro-v1:0",name:"Nova Pro",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:3e5,maxTokens:8192},"amazon.titan-text-express-v1":{id:"amazon.titan-text-express-v1",name:"Titan Text G1 - Express",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"amazon.titan-text-express-v1:0:8k":{id:"amazon.titan-text-express-v1:0:8k",name:"Titan Text G1 - Express",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"anthropic.claude-3-5-haiku-20241022-v1:0":{id:"anthropic.claude-3-5-haiku-20241022-v1:0",name:"Claude Haiku 3.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"anthropic.claude-3-5-sonnet-20240620-v1:0":{id:"anthropic.claude-3-5-sonnet-20240620-v1:0",name:"Claude Sonnet 3.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic.claude-3-5-sonnet-20241022-v2:0":{id:"anthropic.claude-3-5-sonnet-20241022-v2:0",name:"Claude Sonnet 3.5 v2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic.claude-3-7-sonnet-20250219-v1:0":{id:"anthropic.claude-3-7-sonnet-20250219-v1:0",name:"Claude Sonnet 3.7",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic.claude-3-haiku-20240307-v1:0":{id:"anthropic.claude-3-haiku-20240307-v1:0",name:"Claude Haiku 3",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096},"anthropic.claude-3-opus-20240229-v1:0":{id:"anthropic.claude-3-opus-20240229-v1:0",name:"Claude Opus 3",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:15,output:75,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096},"anthropic.claude-3-sonnet-20240229-v1:0":{id:"anthropic.claude-3-sonnet-20240229-v1:0",name:"Claude Sonnet 3",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096},"anthropic.claude-haiku-4-5-20251001-v1:0":{id:"anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-opus-4-1-20250805-v1:0":{id:"anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic.claude-opus-4-20250514-v1:0":{id:"anthropic.claude-opus-4-20250514-v1:0",name:"Claude Opus 4",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic.claude-opus-4-5-20251101-v1:0":{id:"anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-opus-4-6-v1":{id:"anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"anthropic.claude-sonnet-4-20250514-v1:0":{id:"anthropic.claude-sonnet-4-20250514-v1:0",name:"Claude Sonnet 4",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic.claude-sonnet-4-6":{id:"anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"cohere.command-r-plus-v1:0":{id:"cohere.command-r-plus-v1:0",name:"Command R+",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"cohere.command-r-v1:0":{id:"cohere.command-r-v1:0",name:"Command R",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"deepseek.r1-v1:0":{id:"deepseek.r1-v1:0",name:"DeepSeek-R1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32768},"deepseek.v3-v1:0":{id:"deepseek.v3-v1:0",name:"DeepSeek-V3.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.58,output:1.68,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:81920},"deepseek.v3.2-v1:0":{id:"deepseek.v3.2-v1:0",name:"DeepSeek-V3.2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.62,output:1.85,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:81920},"eu.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"eu.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-opus-4-5-20251101-v1:0":{id:"eu.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-opus-4-6-v1":{id:"eu.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"eu.anthropic.claude-sonnet-4-20250514-v1:0":{id:"eu.anthropic.claude-sonnet-4-20250514-v1:0",name:"Claude Sonnet 4 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"eu.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"eu.anthropic.claude-sonnet-4-6":{id:"eu.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (EU)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"global.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-opus-4-5-20251101-v1:0":{id:"global.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-opus-4-6-v1":{id:"global.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"global.anthropic.claude-sonnet-4-20250514-v1:0":{id:"global.anthropic.claude-sonnet-4-20250514-v1:0",name:"Claude Sonnet 4 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"global.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"global.anthropic.claude-sonnet-4-6":{id:"global.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Global)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"google.gemma-3-27b-it":{id:"google.gemma-3-27b-it",name:"Google Gemma 3 27B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.12,output:.2,cacheRead:0,cacheWrite:0},contextWindow:202752,maxTokens:8192},"google.gemma-3-4b-it":{id:"google.gemma-3-4b-it",name:"Gemma 3 4B IT",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.04,output:.08,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-1-70b-instruct-v1:0":{id:"meta.llama3-1-70b-instruct-v1:0",name:"Llama 3.1 70B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-1-8b-instruct-v1:0":{id:"meta.llama3-1-8b-instruct-v1:0",name:"Llama 3.1 8B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:.22,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-2-11b-instruct-v1:0":{id:"meta.llama3-2-11b-instruct-v1:0",name:"Llama 3.2 11B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.16,output:.16,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-2-1b-instruct-v1:0":{id:"meta.llama3-2-1b-instruct-v1:0",name:"Llama 3.2 1B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"meta.llama3-2-3b-instruct-v1:0":{id:"meta.llama3-2-3b-instruct-v1:0",name:"Llama 3.2 3B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"meta.llama3-2-90b-instruct-v1:0":{id:"meta.llama3-2-90b-instruct-v1:0",name:"Llama 3.2 90B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama3-3-70b-instruct-v1:0":{id:"meta.llama3-3-70b-instruct-v1:0",name:"Llama 3.3 70B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"meta.llama4-maverick-17b-instruct-v1:0":{id:"meta.llama4-maverick-17b-instruct-v1:0",name:"Llama 4 Maverick 17B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.24,output:.97,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:16384},"meta.llama4-scout-17b-instruct-v1:0":{id:"meta.llama4-scout-17b-instruct-v1:0",name:"Llama 4 Scout 17B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.17,output:.66,cacheRead:0,cacheWrite:0},contextWindow:35e5,maxTokens:16384},"minimax.minimax-m2":{id:"minimax.minimax-m2",name:"MiniMax M2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204608,maxTokens:128e3},"minimax.minimax-m2.1":{id:"minimax.minimax-m2.1",name:"MiniMax M2.1",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"mistral.ministral-3-14b-instruct":{id:"mistral.ministral-3-14b-instruct",name:"Ministral 14B 3.0",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.2,output:.2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.ministral-3-8b-instruct":{id:"mistral.ministral-3-8b-instruct",name:"Ministral 3 8B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.mistral-large-2402-v1:0":{id:"mistral.mistral-large-2402-v1:0",name:"Mistral Large (24.02)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.voxtral-mini-3b-2507":{id:"mistral.voxtral-mini-3b-2507",name:"Voxtral Mini 3B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.04,output:.04,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistral.voxtral-small-24b-2507":{id:"mistral.voxtral-small-24b-2507",name:"Voxtral Small 24B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.35,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:8192},"moonshot.kimi-k2-thinking":{id:"moonshot.kimi-k2-thinking",name:"Kimi K2 Thinking",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"moonshotai.kimi-k2.5":{id:"moonshotai.kimi-k2.5",name:"Kimi K2.5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"nvidia.nemotron-nano-12b-v2":{id:"nvidia.nemotron-nano-12b-v2",name:"NVIDIA Nemotron Nano 12B v2 VL BF16",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"nvidia.nemotron-nano-9b-v2":{id:"nvidia.nemotron-nano-9b-v2",name:"NVIDIA Nemotron Nano 9B v2",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.06,output:.23,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai.gpt-oss-120b-1:0":{id:"openai.gpt-oss-120b-1:0",name:"gpt-oss-120b",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai.gpt-oss-20b-1:0":{id:"openai.gpt-oss-20b-1:0",name:"gpt-oss-20b",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.07,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai.gpt-oss-safeguard-120b":{id:"openai.gpt-oss-safeguard-120b",name:"GPT OSS Safeguard 120B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai.gpt-oss-safeguard-20b":{id:"openai.gpt-oss-safeguard-20b",name:"GPT OSS Safeguard 20B",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.07,output:.2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"qwen.qwen3-235b-a22b-2507-v1:0":{id:"qwen.qwen3-235b-a22b-2507-v1:0",name:"Qwen3 235B A22B 2507",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:.88,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"qwen.qwen3-32b-v1:0":{id:"qwen.qwen3-32b-v1:0",name:"Qwen3 32B (dense)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:16384,maxTokens:16384},"qwen.qwen3-coder-30b-a3b-v1:0":{id:"qwen.qwen3-coder-30b-a3b-v1:0",name:"Qwen3 Coder 30B A3B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"qwen.qwen3-coder-480b-a35b-v1:0":{id:"qwen.qwen3-coder-480b-a35b-v1:0",name:"Qwen3 Coder 480B A35B Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.22,output:1.8,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"qwen.qwen3-next-80b-a3b":{id:"qwen.qwen3-next-80b-a3b",name:"Qwen/Qwen3-Next-80B-A3B-Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text"],cost:{input:.14,output:1.4,cacheRead:0,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"qwen.qwen3-vl-235b-a22b":{id:"qwen.qwen3-vl-235b-a22b",name:"Qwen/Qwen3-VL-235B-A22B-Instruct",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!1,input:["text","image"],cost:{input:.3,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"us.anthropic.claude-haiku-4-5-20251001-v1:0":{id:"us.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-opus-4-1-20250805-v1:0":{id:"us.anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"us.anthropic.claude-opus-4-20250514-v1:0":{id:"us.anthropic.claude-opus-4-20250514-v1:0",name:"Claude Opus 4 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"us.anthropic.claude-opus-4-5-20251101-v1:0":{id:"us.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-opus-4-6-v1":{id:"us.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"us.anthropic.claude-sonnet-4-20250514-v1:0":{id:"us.anthropic.claude-sonnet-4-20250514-v1:0",name:"Claude Sonnet 4 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-sonnet-4-5-20250929-v1:0":{id:"us.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"us.anthropic.claude-sonnet-4-6":{id:"us.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (US)",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"writer.palmyra-x4-v1:0":{id:"writer.palmyra-x4-v1:0",name:"Palmyra X4",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:122880,maxTokens:8192},"writer.palmyra-x5-v1:0":{id:"writer.palmyra-x5-v1:0",name:"Palmyra X5",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:6,cacheRead:0,cacheWrite:0},contextWindow:104e4,maxTokens:8192},"zai.glm-4.7":{id:"zai.glm-4.7",name:"GLM-4.7",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"zai.glm-4.7-flash":{id:"zai.glm-4.7-flash",name:"GLM-4.7-Flash",api:"bedrock-converse-stream",provider:"amazon-bedrock",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",reasoning:!0,input:["text"],cost:{input:.07,output:.4,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:131072}},anthropic:{"claude-3-5-haiku-20241022":{id:"claude-3-5-haiku-20241022",name:"Claude Haiku 3.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"claude-3-5-haiku-latest":{id:"claude-3-5-haiku-latest",name:"Claude Haiku 3.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"claude-3-5-sonnet-20240620":{id:"claude-3-5-sonnet-20240620",name:"Claude Sonnet 3.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"claude-3-5-sonnet-20241022":{id:"claude-3-5-sonnet-20241022",name:"Claude Sonnet 3.5 v2",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"claude-3-7-sonnet-20250219":{id:"claude-3-7-sonnet-20250219",name:"Claude Sonnet 3.7",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-3-7-sonnet-latest":{id:"claude-3-7-sonnet-latest",name:"Claude Sonnet 3.7 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-3-haiku-20240307":{id:"claude-3-haiku-20240307",name:"Claude Haiku 3",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"claude-3-opus-20240229":{id:"claude-3-opus-20240229",name:"Claude Opus 3",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:4096},"claude-3-sonnet-20240229":{id:"claude-3-sonnet-20240229",name:"Claude Sonnet 3",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"claude-haiku-4-5":{id:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-haiku-4-5-20251001":{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-0":{id:"claude-opus-4-0",name:"Claude Opus 4 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-1":{id:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-1-20250805":{id:"claude-opus-4-1-20250805",name:"Claude Opus 4.1",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-20250514":{id:"claude-opus-4-20250514",name:"Claude Opus 4",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-5":{id:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-5-20251101":{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-6":{id:"claude-opus-4-6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"claude-sonnet-4-0":{id:"claude-sonnet-4-0",name:"Claude Sonnet 4 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-20250514":{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5-20250929":{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"anthropic",baseUrl:"https://api.anthropic.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3}},"azure-openai-responses":{"codex-mini-latest":{id:"codex-mini-latest",name:"Codex Mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.5,output:6,cacheRead:.375,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"gpt-4":{id:"gpt-4",name:"GPT-4",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"gpt-4-turbo":{id:"gpt-4-turbo",name:"GPT-4 Turbo",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-mini":{id:"gpt-4.1-mini",name:"GPT-4.1 mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-nano":{id:"gpt-4.1-nano",name:"GPT-4.1 nano",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.03,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-05-13":{id:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4o-2024-08-06":{id:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-11-20":{id:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-mini":{id:"gpt-4o-mini",name:"GPT-4o mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.08,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-chat-latest":{id:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5-Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5 Mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-pro":{id:"gpt-5-pro",name:"GPT-5 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:272e3},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-chat-latest":{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-chat-latest":{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-pro":{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},o1:{id:"o1",name:"o1",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o1-pro":{id:"o1-pro",name:"o1-pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:150,output:600,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},o3:{id:"o3",name:"o3",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-deep-research":{id:"o3-deep-research",name:"o3-deep-research",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-mini":{id:"o3-mini",name:"o3-mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-pro":{id:"o3-pro",name:"o3-pro",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini":{id:"o4-mini",name:"o4-mini",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini-deep-research":{id:"o4-mini-deep-research",name:"o4-mini-deep-research",api:"azure-openai-responses",provider:"azure-openai-responses",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5}},cerebras:{"gpt-oss-120b":{id:"gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.69,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"llama3.1-8b":{id:"llama3.1-8b",name:"Llama 3.1 8B",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!1,input:["text"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:8e3},"qwen-3-235b-a22b-instruct-2507":{id:"qwen-3-235b-a22b-instruct-2507",name:"Qwen 3 235B Instruct",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!1,input:["text"],cost:{input:.6,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:32e3},"zai-glm-4.7":{id:"zai-glm-4.7",name:"Z.AI GLM-4.7",api:"openai-completions",provider:"cerebras",baseUrl:"https://api.cerebras.ai/v1",reasoning:!1,input:["text"],cost:{input:2.25,output:2.75,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4e4}},"github-copilot":{"claude-haiku-4.5":{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"claude-opus-4.5":{id:"claude-opus-4.5",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"claude-opus-4.6":{id:"claude-opus-4.6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"claude-sonnet-4":{id:"claude-sonnet-4",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16e3},"claude-sonnet-4.5":{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"claude-sonnet-4.6":{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16384},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16384},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5-mini",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1-Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1-Codex-max",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1-Codex-mini",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2-Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3-Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"grok-code-fast-1":{id:"grok-code-fast-1",name:"Grok Code Fast 1",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3}},google:{"gemini-1.5-flash":{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:.01875,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-1.5-flash-8b":{id:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash-8B",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.0375,output:.15,cacheRead:.01,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-1.5-pro":{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:1.25,output:5,cacheRead:.3125,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-2.0-flash":{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.0-flash-lite":{id:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash Lite",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.5-flash":{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite":{id:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite-preview-06-17":{id:"gemini-2.5-flash-lite-preview-06-17",name:"Gemini 2.5 Flash Lite Preview 06-17",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite-preview-09-2025":{id:"gemini-2.5-flash-lite-preview-09-2025",name:"Gemini 2.5 Flash Lite Preview 09-25",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-preview-04-17":{id:"gemini-2.5-flash-preview-04-17",name:"Gemini 2.5 Flash Preview 04-17",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.0375,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-preview-05-20":{id:"gemini-2.5-flash-preview-05-20",name:"Gemini 2.5 Flash Preview 05-20",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.0375,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-preview-09-2025":{id:"gemini-2.5-flash-preview-09-2025",name:"Gemini 2.5 Flash Preview 09-25",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.31,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro-preview-05-06":{id:"gemini-2.5-pro-preview-05-06",name:"Gemini 2.5 Pro Preview 05-06",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.31,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro-preview-06-05":{id:"gemini-2.5-pro-preview-06-05",name:"Gemini 2.5 Pro Preview 06-05",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.31,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"gemini-3.1-flash-lite-preview":{id:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3.1-pro-preview-customtools":{id:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-flash-latest":{id:"gemini-flash-latest",name:"Gemini Flash Latest",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-flash-lite-latest":{id:"gemini-flash-lite-latest",name:"Gemini Flash-Lite Latest",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.025,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-live-2.5-flash":{id:"gemini-live-2.5-flash",name:"Gemini Live 2.5 Flash",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text","image"],cost:{input:.5,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8e3},"gemini-live-2.5-flash-preview-native-audio":{id:"gemini-live-2.5-flash-preview-native-audio",name:"Gemini Live 2.5 Flash Preview Native Audio",api:"google-generative-ai",provider:"google",baseUrl:"https://generativelanguage.googleapis.com/v1beta",reasoning:!0,input:["text"],cost:{input:.5,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536}},"google-antigravity":{"claude-opus-4-5-thinking":{id:"claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-6-thinking":{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5-thinking":{id:"claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"gemini-3-flash":{id:"gemini-3-flash",name:"Gemini 3 Flash (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.5,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-3.1-pro-high":{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:2.375},contextWindow:1048576,maxTokens:65535},"gemini-3.1-pro-low":{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro Low (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:2.375},contextWindow:1048576,maxTokens:65535},"gpt-oss-120b-medium":{id:"gpt-oss-120b-medium",name:"GPT-OSS 120B Medium (Antigravity)",api:"google-gemini-cli",provider:"google-antigravity",baseUrl:"https://daily-cloudcode-pa.sandbox.googleapis.com",reasoning:!1,input:["text"],cost:{input:.09,output:.36,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768}},"google-gemini-cli":{"gemini-2.0-flash":{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.5-flash":{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview (Cloud Code Assist)",api:"google-gemini-cli",provider:"google-gemini-cli",baseUrl:"https://cloudcode-pa.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65535}},"google-vertex":{"gemini-1.5-flash":{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:.01875,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-1.5-flash-8b":{id:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash-8B (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:.0375,output:.15,cacheRead:.01,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-1.5-pro":{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:1.25,output:5,cacheRead:.3125,cacheWrite:0},contextWindow:1e6,maxTokens:8192},"gemini-2.0-flash":{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.0375,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"gemini-2.0-flash-lite":{id:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash Lite (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.075,output:.3,cacheRead:.01875,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash":{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite":{id:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-flash-lite-preview-09-2025":{id:"gemini-2.5-flash-lite-preview-09-2025",name:"Gemini 2.5 Flash Lite Preview 09-25 (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-2.5-pro":{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-flash-preview":{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-pro-preview":{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"gemini-3.1-pro-preview":{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview (Vertex)",api:"google-vertex",provider:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536}},groq:{"deepseek-r1-distill-llama-70b":{id:"deepseek-r1-distill-llama-70b",name:"DeepSeek R1 Distill Llama 70B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.75,output:.99,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"gemma2-9b-it":{id:"gemma2-9b-it",name:"Gemma 2 9B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.2,output:.2,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"llama-3.1-8b-instant":{id:"llama-3.1-8b-instant",name:"Llama 3.1 8B Instant",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.05,output:.08,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"llama-3.3-70b-versatile":{id:"llama-3.3-70b-versatile",name:"Llama 3.3 70B Versatile",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.59,output:.79,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"llama3-70b-8192":{id:"llama3-70b-8192",name:"Llama 3 70B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.59,output:.79,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"llama3-8b-8192":{id:"llama3-8b-8192",name:"Llama 3 8B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.05,output:.08,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"meta-llama/llama-4-maverick-17b-128e-instruct":{id:"meta-llama/llama-4-maverick-17b-128e-instruct",name:"Llama 4 Maverick 17B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text","image"],cost:{input:.2,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"meta-llama/llama-4-scout-17b-16e-instruct":{id:"meta-llama/llama-4-scout-17b-16e-instruct",name:"Llama 4 Scout 17B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text","image"],cost:{input:.11,output:.34,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"mistral-saba-24b":{id:"mistral-saba-24b",name:"Mistral Saba 24B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:.79,output:.79,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"moonshotai/kimi-k2-instruct":{id:"moonshotai/kimi-k2-instruct",name:"Kimi K2 Instruct",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"moonshotai/kimi-k2-instruct-0905":{id:"moonshotai/kimi-k2-instruct-0905",name:"Kimi K2 Instruct 0905",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"GPT OSS 120B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"GPT OSS 20B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"qwen-qwq-32b":{id:"qwen-qwq-32b",name:"Qwen QwQ 32B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.29,output:.39,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"qwen/qwen3-32b":{id:"qwen/qwen3-32b",name:"Qwen3 32B",api:"openai-completions",provider:"groq",baseUrl:"https://api.groq.com/openai/v1",reasoning:!0,input:["text"],cost:{input:.29,output:.59,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384}},huggingface:{"MiniMaxAI/MiniMax-M2.1":{id:"MiniMaxAI/MiniMax-M2.1",name:"MiniMax-M2.1",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"MiniMaxAI/MiniMax-M2.5":{id:"MiniMaxAI/MiniMax-M2.5",name:"MiniMax-M2.5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:0},contextWindow:204800,maxTokens:131072},"Qwen/Qwen3-235B-A22B-Thinking-2507":{id:"Qwen/Qwen3-235B-A22B-Thinking-2507",name:"Qwen3-235B-A22B-Thinking-2507",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.3,output:3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"Qwen/Qwen3-Coder-480B-A35B-Instruct":{id:"Qwen/Qwen3-Coder-480B-A35B-Instruct",name:"Qwen3-Coder-480B-A35B-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:2,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:66536},"Qwen/Qwen3-Coder-Next":{id:"Qwen/Qwen3-Coder-Next",name:"Qwen3-Coder-Next",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:.2,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"Qwen/Qwen3-Next-80B-A3B-Instruct":{id:"Qwen/Qwen3-Next-80B-A3B-Instruct",name:"Qwen3-Next-80B-A3B-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:.25,output:1,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:66536},"Qwen/Qwen3-Next-80B-A3B-Thinking":{id:"Qwen/Qwen3-Next-80B-A3B-Thinking",name:"Qwen3-Next-80B-A3B-Thinking",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:.3,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"Qwen/Qwen3.5-397B-A17B":{id:"Qwen/Qwen3.5-397B-A17B",name:"Qwen3.5-397B-A17B",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text","image"],cost:{input:.6,output:3.6,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"XiaomiMiMo/MiMo-V2-Flash":{id:"XiaomiMiMo/MiMo-V2-Flash",name:"MiMo-V2-Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"deepseek-ai/DeepSeek-R1-0528":{id:"deepseek-ai/DeepSeek-R1-0528",name:"DeepSeek-R1-0528",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:3,output:5,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:163840},"deepseek-ai/DeepSeek-V3.2":{id:"deepseek-ai/DeepSeek-V3.2",name:"DeepSeek-V3.2",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.28,output:.4,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:65536},"moonshotai/Kimi-K2-Instruct":{id:"moonshotai/Kimi-K2-Instruct",name:"Kimi-K2-Instruct",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"moonshotai/Kimi-K2-Instruct-0905":{id:"moonshotai/Kimi-K2-Instruct-0905",name:"Kimi-K2-Instruct-0905",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:16384},"moonshotai/Kimi-K2-Thinking":{id:"moonshotai/Kimi-K2-Thinking",name:"Kimi-K2-Thinking",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.6,output:2.5,cacheRead:.15,cacheWrite:0},contextWindow:262144,maxTokens:262144},"moonshotai/Kimi-K2.5":{id:"moonshotai/Kimi-K2.5",name:"Kimi-K2.5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},contextWindow:262144,maxTokens:262144},"zai-org/GLM-4.7":{id:"zai-org/GLM-4.7",name:"GLM-4.7",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:204800,maxTokens:131072},"zai-org/GLM-4.7-Flash":{id:"zai-org/GLM-4.7-Flash",name:"GLM-4.7-Flash",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"zai-org/GLM-5":{id:"zai-org/GLM-5",name:"GLM-5",api:"openai-completions",provider:"huggingface",baseUrl:"https://router.huggingface.co/v1",compat:{supportsDeveloperRole:!1},reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:202752,maxTokens:131072}},"kimi-coding":{k2p5:{id:"k2p5",name:"Kimi K2.5",api:"anthropic-messages",provider:"kimi-coding",baseUrl:"https://api.kimi.com/coding",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"kimi-k2-thinking":{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",api:"anthropic-messages",provider:"kimi-coding",baseUrl:"https://api.kimi.com/coding",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768}},minimax:{"MiniMax-M2":{id:"MiniMax-M2",name:"MiniMax-M2",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:196608,maxTokens:128e3},"MiniMax-M2.1":{id:"MiniMax-M2.1",name:"MiniMax-M2.1",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"MiniMax-M2.5":{id:"MiniMax-M2.5",name:"MiniMax-M2.5",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"MiniMax-M2.5-highspeed":{id:"MiniMax-M2.5-highspeed",name:"MiniMax-M2.5-highspeed",api:"anthropic-messages",provider:"minimax",baseUrl:"https://api.minimax.io/anthropic",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131072}},"minimax-cn":{"MiniMax-M2":{id:"MiniMax-M2",name:"MiniMax-M2",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:196608,maxTokens:128e3},"MiniMax-M2.1":{id:"MiniMax-M2.1",name:"MiniMax-M2.1",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072},"MiniMax-M2.5":{id:"MiniMax-M2.5",name:"MiniMax-M2.5",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"MiniMax-M2.5-highspeed":{id:"MiniMax-M2.5-highspeed",name:"MiniMax-M2.5-highspeed",api:"anthropic-messages",provider:"minimax-cn",baseUrl:"https://api.minimaxi.com/anthropic",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},contextWindow:204800,maxTokens:131072}},mistral:{"codestral-latest":{id:"codestral-latest",name:"Codestral (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.3,output:.9,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"devstral-2512":{id:"devstral-2512",name:"Devstral 2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"devstral-medium-2507":{id:"devstral-medium-2507",name:"Devstral Medium",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"devstral-medium-latest":{id:"devstral-medium-latest",name:"Devstral 2 (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"devstral-small-2505":{id:"devstral-small-2505",name:"Devstral Small 2505",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"devstral-small-2507":{id:"devstral-small-2507",name:"Devstral Small",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"labs-devstral-small-2512":{id:"labs-devstral-small-2512",name:"Devstral Small 2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"magistral-medium-latest":{id:"magistral-medium-latest",name:"Magistral Medium (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text"],cost:{input:2,output:5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"magistral-small":{id:"magistral-small",name:"Magistral Small",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!0,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"ministral-3b-latest":{id:"ministral-3b-latest",name:"Ministral 3B (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.04,output:.04,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"ministral-8b-latest":{id:"ministral-8b-latest",name:"Ministral 8B (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.1,output:.1,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"mistral-large-2411":{id:"mistral-large-2411",name:"Mistral Large 2.1",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"mistral-large-2512":{id:"mistral-large-2512",name:"Mistral Large 3",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-large-latest":{id:"mistral-large-latest",name:"Mistral Large (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-medium-2505":{id:"mistral-medium-2505",name:"Mistral Medium 3",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"mistral-medium-2508":{id:"mistral-medium-2508",name:"Mistral Medium 3.1",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"mistral-medium-latest":{id:"mistral-medium-latest",name:"Mistral Medium (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.4,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"mistral-nemo":{id:"mistral-nemo",name:"Mistral Nemo",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"mistral-small-2506":{id:"mistral-small-2506",name:"Mistral Small 3.2",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"mistral-small-latest":{id:"mistral-small-latest",name:"Mistral Small (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.1,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"open-mistral-7b":{id:"open-mistral-7b",name:"Mistral 7B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.25,output:.25,cacheRead:0,cacheWrite:0},contextWindow:8e3,maxTokens:8e3},"open-mixtral-8x22b":{id:"open-mixtral-8x22b",name:"Mixtral 8x22B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:64e3},"open-mixtral-8x7b":{id:"open-mixtral-8x7b",name:"Mixtral 8x7B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text"],cost:{input:.7,output:.7,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:32e3},"pixtral-12b":{id:"pixtral-12b",name:"Pixtral 12B",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"pixtral-large-latest":{id:"pixtral-large-latest",name:"Pixtral Large (latest)",api:"mistral-conversations",provider:"mistral",baseUrl:"https://api.mistral.ai",reasoning:!1,input:["text","image"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3}},openai:{"codex-mini-latest":{id:"codex-mini-latest",name:"Codex Mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text"],cost:{input:1.5,output:6,cacheRead:.375,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"gpt-4":{id:"gpt-4",name:"GPT-4",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"gpt-4-turbo":{id:"gpt-4-turbo",name:"GPT-4 Turbo",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4.1":{id:"gpt-4.1",name:"GPT-4.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-mini":{id:"gpt-4.1-mini",name:"GPT-4.1 mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.4,output:1.6,cacheRead:.1,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4.1-nano":{id:"gpt-4.1-nano",name:"GPT-4.1 nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.1,output:.4,cacheRead:.03,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"gpt-4o":{id:"gpt-4o",name:"GPT-4o",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-05-13":{id:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"gpt-4o-2024-08-06":{id:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-2024-11-20":{id:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-4o-mini":{id:"gpt-4o-mini",name:"GPT-4o mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.08,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-chat-latest":{id:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5-Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-mini":{id:"gpt-5-mini",name:"GPT-5 Mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-pro":{id:"gpt-5-pro",name:"GPT-5 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:272e3},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-chat-latest":{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-chat-latest":{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-pro":{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},o1:{id:"o1",name:"o1",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o1-pro":{id:"o1-pro",name:"o1-pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:150,output:600,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},o3:{id:"o3",name:"o3",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-deep-research":{id:"o3-deep-research",name:"o3-deep-research",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-mini":{id:"o3-mini",name:"o3-mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o3-pro":{id:"o3-pro",name:"o3-pro",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini":{id:"o4-mini",name:"o4-mini",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"o4-mini-deep-research":{id:"o4-mini-deep-research",name:"o4-mini-deep-research",api:"openai-responses",provider:"openai",baseUrl:"https://api.openai.com/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5}},"openai-codex":{"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.3-codex-spark":{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-codex-responses",provider:"openai-codex",baseUrl:"https://chatgpt.com/backend-api",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3}},opencode:{"big-pickle":{id:"big-pickle",name:"Big Pickle",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"claude-3-5-haiku":{id:"claude-3-5-haiku",name:"Claude Haiku 3.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!1,input:["text","image"],cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"claude-haiku-4-5":{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-1":{id:"claude-opus-4-1",name:"Claude Opus 4.1",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"claude-opus-4-5":{id:"claude-opus-4-5",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"claude-opus-4-6":{id:"claude-opus-4-6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:128e3},"claude-sonnet-4":{id:"claude-sonnet-4",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-5":{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"claude-sonnet-4-6":{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"gemini-3-flash":{id:"gemini-3-flash",name:"Gemini 3 Flash",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.05,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3-pro":{id:"gemini-3-pro",name:"Gemini 3 Pro",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"gemini-3.1-pro":{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro Preview",api:"google-generative-ai",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"glm-4.6":{id:"glm-4.6",name:"GLM-4.6",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.1,cacheWrite:0},contextWindow:204800,maxTokens:131072},"glm-4.7":{id:"glm-4.7",name:"GLM-4.7",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.1,cacheWrite:0},contextWindow:204800,maxTokens:131072},"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:204800,maxTokens:131072},"gpt-5":{id:"gpt-5",name:"GPT-5",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-codex":{id:"gpt-5-codex",name:"GPT-5 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5-nano":{id:"gpt-5-nano",name:"GPT-5 Nano",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1":{id:"gpt-5.1",name:"GPT-5.1",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex":{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.07,output:8.5,cacheRead:.107,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-max":{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.1-codex-mini":{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2":{id:"gpt-5.2",name:"GPT-5.2",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.2-codex":{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"gpt-5.4":{id:"gpt-5.4",name:"GPT-5.4",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3},"gpt-5.4-pro":{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",api:"openai-responses",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:30,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.08,cacheWrite:0},contextWindow:262144,maxTokens:65536},"minimax-m2.1":{id:"minimax-m2.1",name:"MiniMax M2.1",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.1,cacheWrite:0},contextWindow:204800,maxTokens:131072},"minimax-m2.5":{id:"minimax-m2.5",name:"MiniMax M2.5",api:"openai-completions",provider:"opencode",baseUrl:"https://opencode.ai/zen/v1",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:0},contextWindow:204800,maxTokens:131072},"minimax-m2.5-free":{id:"minimax-m2.5-free",name:"MiniMax M2.5 Free",api:"anthropic-messages",provider:"opencode",baseUrl:"https://opencode.ai/zen",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:131072}},"opencode-go":{"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:204800,maxTokens:131072},"kimi-k2.5":{id:"kimi-k2.5",name:"Kimi K2.5",api:"openai-completions",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:3,cacheRead:.1,cacheWrite:0},contextWindow:262144,maxTokens:65536},"minimax-m2.5":{id:"minimax-m2.5",name:"MiniMax M2.5",api:"anthropic-messages",provider:"opencode-go",baseUrl:"https://opencode.ai/zen/go",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:0},contextWindow:204800,maxTokens:131072}},openrouter:{"ai21/jamba-large-1.7":{id:"ai21/jamba-large-1.7",name:"AI21: Jamba Large 1.7",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:8,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"alibaba/tongyi-deepresearch-30b-a3b":{id:"alibaba/tongyi-deepresearch-30b-a3b",name:"Tongyi DeepResearch 30B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.09,output:.44999999999999996,cacheRead:.09,cacheWrite:0},contextWindow:131072,maxTokens:131072},"allenai/olmo-3.1-32b-instruct":{id:"allenai/olmo-3.1-32b-instruct",name:"AllenAI: Olmo 3.1 32B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.6,cacheRead:0,cacheWrite:0},contextWindow:65536,maxTokens:4096},"amazon/nova-2-lite-v1":{id:"amazon/nova-2-lite-v1",name:"Amazon: Nova 2 Lite",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65535},"amazon/nova-lite-v1":{id:"amazon/nova-lite-v1",name:"Amazon: Nova Lite 1.0",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:3e5,maxTokens:5120},"amazon/nova-micro-v1":{id:"amazon/nova-micro-v1",name:"Amazon: Nova Micro 1.0",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.035,output:.14,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:5120},"amazon/nova-premier-v1":{id:"amazon/nova-premier-v1",name:"Amazon: Nova Premier 1.0",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:12.5,cacheRead:.625,cacheWrite:0},contextWindow:1e6,maxTokens:32e3},"amazon/nova-pro-v1":{id:"amazon/nova-pro-v1",name:"Amazon: Nova Pro 1.0",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.7999999999999999,output:3.1999999999999997,cacheRead:0,cacheWrite:0},contextWindow:3e5,maxTokens:5120},"anthropic/claude-3-haiku":{id:"anthropic/claude-3-haiku",name:"Anthropic: Claude 3 Haiku",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"anthropic/claude-3.5-haiku":{id:"anthropic/claude-3.5-haiku",name:"Anthropic: Claude 3.5 Haiku",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.7999999999999999,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.5-sonnet":{id:"anthropic/claude-3.5-sonnet",name:"Anthropic: Claude 3.5 Sonnet",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:6,output:30,cacheRead:.6,cacheWrite:7.5},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.7-sonnet":{id:"anthropic/claude-3.7-sonnet",name:"Anthropic: Claude 3.7 Sonnet",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-3.7-sonnet:thinking":{id:"anthropic/claude-3.7-sonnet:thinking",name:"Anthropic: Claude 3.7 Sonnet (thinking)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-haiku-4.5":{id:"anthropic/claude-haiku-4.5",name:"Anthropic: Claude Haiku 4.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.09999999999999999,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4":{id:"anthropic/claude-opus-4",name:"Anthropic: Claude Opus 4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.1":{id:"anthropic/claude-opus-4.1",name:"Anthropic: Claude Opus 4.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.5":{id:"anthropic/claude-opus-4.5",name:"Anthropic: Claude Opus 4.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4.6":{id:"anthropic/claude-opus-4.6",name:"Anthropic: Claude Opus 4.6",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3},"anthropic/claude-sonnet-4":{id:"anthropic/claude-sonnet-4",name:"Anthropic: Claude Sonnet 4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-sonnet-4.5":{id:"anthropic/claude-sonnet-4.5",name:"Anthropic: Claude Sonnet 4.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-sonnet-4.6":{id:"anthropic/claude-sonnet-4.6",name:"Anthropic: Claude Sonnet 4.6",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:128e3},"arcee-ai/trinity-large-preview:free":{id:"arcee-ai/trinity-large-preview:free",name:"Arcee AI: Trinity Large Preview (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"arcee-ai/trinity-mini":{id:"arcee-ai/trinity-mini",name:"Arcee AI: Trinity Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.045,output:.15,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"arcee-ai/trinity-mini:free":{id:"arcee-ai/trinity-mini:free",name:"Arcee AI: Trinity Mini (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"arcee-ai/virtuoso-large":{id:"arcee-ai/virtuoso-large",name:"Arcee AI: Virtuoso Large",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.75,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:64e3},auto:{id:"auto",name:"Auto",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"baidu/ernie-4.5-21b-a3b":{id:"baidu/ernie-4.5-21b-a3b",name:"Baidu: ERNIE 4.5 21B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.07,output:.28,cacheRead:0,cacheWrite:0},contextWindow:12e4,maxTokens:8e3},"baidu/ernie-4.5-vl-28b-a3b":{id:"baidu/ernie-4.5-vl-28b-a3b",name:"Baidu: ERNIE 4.5 VL 28B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.14,output:.56,cacheRead:0,cacheWrite:0},contextWindow:3e4,maxTokens:8e3},"bytedance-seed/seed-1.6":{id:"bytedance-seed/seed-1.6",name:"ByteDance Seed: Seed 1.6",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"bytedance-seed/seed-1.6-flash":{id:"bytedance-seed/seed-1.6-flash",name:"ByteDance Seed: Seed 1.6 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"bytedance-seed/seed-2.0-mini":{id:"bytedance-seed/seed-2.0-mini",name:"ByteDance Seed: Seed-2.0-Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:131072},"cohere/command-r-08-2024":{id:"cohere/command-r-08-2024",name:"Cohere: Command R (08-2024)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"cohere/command-r-plus-08-2024":{id:"cohere/command-r-plus-08-2024",name:"Cohere: Command R+ (08-2024)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"deepseek/deepseek-chat":{id:"deepseek/deepseek-chat",name:"DeepSeek: DeepSeek V3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.32,output:.8899999999999999,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:163840},"deepseek/deepseek-chat-v3-0324":{id:"deepseek/deepseek-chat-v3-0324",name:"DeepSeek: DeepSeek V3 0324",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:.77,cacheRead:.13,cacheWrite:0},contextWindow:163840,maxTokens:163840},"deepseek/deepseek-chat-v3.1":{id:"deepseek/deepseek-chat-v3.1",name:"DeepSeek: DeepSeek V3.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.75,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:7168},"deepseek/deepseek-r1":{id:"deepseek/deepseek-r1",name:"DeepSeek: R1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.7,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16e3},"deepseek/deepseek-r1-0528":{id:"deepseek/deepseek-r1-0528",name:"DeepSeek: R1 0528",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.44999999999999996,output:2.1500000000000004,cacheRead:.22499999999999998,cacheWrite:0},contextWindow:163840,maxTokens:65536},"deepseek/deepseek-v3.1-terminus":{id:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek: DeepSeek V3.1 Terminus",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.21,output:.7899999999999999,cacheRead:.1300000002,cacheWrite:0},contextWindow:163840,maxTokens:4096},"deepseek/deepseek-v3.1-terminus:exacto":{id:"deepseek/deepseek-v3.1-terminus:exacto",name:"DeepSeek: DeepSeek V3.1 Terminus (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.21,output:.7899999999999999,cacheRead:.16799999999999998,cacheWrite:0},contextWindow:163840,maxTokens:4096},"deepseek/deepseek-v3.2":{id:"deepseek/deepseek-v3.2",name:"DeepSeek: DeepSeek V3.2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:65536},"deepseek/deepseek-v3.2-exp":{id:"deepseek/deepseek-v3.2-exp",name:"DeepSeek: DeepSeek V3.2 Exp",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.27,output:.41,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:65536},"essentialai/rnj-1-instruct":{id:"essentialai/rnj-1-instruct",name:"EssentialAI: Rnj 1 Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"google/gemini-2.0-flash-001":{id:"google/gemini-2.0-flash-001",name:"Google: Gemini 2.0 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.024999999999999998,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:8192},"google/gemini-2.0-flash-lite-001":{id:"google/gemini-2.0-flash-lite-001",name:"Google: Gemini 2.0 Flash Lite",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.075,output:.3,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:8192},"google/gemini-2.5-flash":{id:"google/gemini-2.5-flash",name:"Google: Gemini 2.5 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65535},"google/gemini-2.5-flash-lite":{id:"google/gemini-2.5-flash-lite",name:"Google: Gemini 2.5 Flash Lite",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.01,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65535},"google/gemini-2.5-flash-lite-preview-09-2025":{id:"google/gemini-2.5-flash-lite-preview-09-2025",name:"Google: Gemini 2.5 Flash Lite Preview 09-2025",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.01,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-pro":{id:"google/gemini-2.5-pro",name:"Google: Gemini 2.5 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-pro-preview":{id:"google/gemini-2.5-pro-preview",name:"Google: Gemini 2.5 Pro Preview 06-05",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-pro-preview-05-06":{id:"google/gemini-2.5-pro-preview-05-06",name:"Google: Gemini 2.5 Pro Preview 05-06",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:.375},contextWindow:1048576,maxTokens:65535},"google/gemini-3-flash-preview":{id:"google/gemini-3-flash-preview",name:"Google: Gemini 3 Flash Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.049999999999999996,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65536},"google/gemini-3-pro-preview":{id:"google/gemini-3-pro-preview",name:"Google: Gemini 3 Pro Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemini-3.1-flash-lite-preview":{id:"google/gemini-3.1-flash-lite-preview",name:"Google: Gemini 3.1 Flash Lite Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:.024999999999999998,cacheWrite:.08333333333333334},contextWindow:1048576,maxTokens:65536},"google/gemini-3.1-pro-preview":{id:"google/gemini-3.1-pro-preview",name:"Google: Gemini 3.1 Pro Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemini-3.1-pro-preview-customtools":{id:"google/gemini-3.1-pro-preview-customtools",name:"Google: Gemini 3.1 Pro Preview Custom Tools",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:.375},contextWindow:1048576,maxTokens:65536},"google/gemma-3-27b-it":{id:"google/gemma-3-27b-it",name:"Google: Gemma 3 27B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.04,output:.15,cacheRead:.02,cacheWrite:0},contextWindow:128e3,maxTokens:65536},"google/gemma-3-27b-it:free":{id:"google/gemma-3-27b-it:free",name:"Google: Gemma 3 27B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"inception/mercury":{id:"inception/mercury",name:"Inception: Mercury",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.25,output:.75,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"inception/mercury-2":{id:"inception/mercury-2",name:"Inception: Mercury 2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.75,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:128e3,maxTokens:5e4},"inception/mercury-coder":{id:"inception/mercury-coder",name:"Inception: Mercury Coder",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.25,output:.75,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"kwaipilot/kat-coder-pro":{id:"kwaipilot/kat-coder-pro",name:"Kwaipilot: KAT-Coder-Pro V1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.207,output:.828,cacheRead:.0414,cacheWrite:0},contextWindow:256e3,maxTokens:128e3},"meituan/longcat-flash-chat":{id:"meituan/longcat-flash-chat",name:"Meituan: LongCat Flash Chat",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.7999999999999999,cacheRead:.19999999999999998,cacheWrite:0},contextWindow:131072,maxTokens:131072},"meta-llama/llama-3-8b-instruct":{id:"meta-llama/llama-3-8b-instruct",name:"Meta: Llama 3 8B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.03,output:.04,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:16384},"meta-llama/llama-3.1-405b-instruct":{id:"meta-llama/llama-3.1-405b-instruct",name:"Meta: Llama 3.1 405B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:4,output:4,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"meta-llama/llama-3.1-70b-instruct":{id:"meta-llama/llama-3.1-70b-instruct",name:"Meta: Llama 3.1 70B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"meta-llama/llama-3.1-8b-instruct":{id:"meta-llama/llama-3.1-8b-instruct",name:"Meta: Llama 3.1 8B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.02,output:.049999999999999996,cacheRead:0,cacheWrite:0},contextWindow:16384,maxTokens:16384},"meta-llama/llama-3.3-70b-instruct":{id:"meta-llama/llama-3.3-70b-instruct",name:"Meta: Llama 3.3 70B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.32,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"meta-llama/llama-3.3-70b-instruct:free":{id:"meta-llama/llama-3.3-70b-instruct:free",name:"Meta: Llama 3.3 70B Instruct (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"meta-llama/llama-4-maverick":{id:"meta-llama/llama-4-maverick",name:"Meta: Llama 4 Maverick",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:16384},"meta-llama/llama-4-scout":{id:"meta-llama/llama-4-scout",name:"Meta: Llama 4 Scout",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.08,output:.3,cacheRead:0,cacheWrite:0},contextWindow:327680,maxTokens:16384},"minimax/minimax-m1":{id:"minimax/minimax-m1",name:"MiniMax: MiniMax M1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.39999999999999997,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:4e4},"minimax/minimax-m2":{id:"minimax/minimax-m2",name:"MiniMax: MiniMax M2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.255,output:1,cacheRead:.03,cacheWrite:0},contextWindow:196608,maxTokens:196608},"minimax/minimax-m2.1":{id:"minimax/minimax-m2.1",name:"MiniMax: MiniMax M2.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.27,output:.95,cacheRead:.0290000007,cacheWrite:0},contextWindow:196608,maxTokens:4096},"minimax/minimax-m2.5":{id:"minimax/minimax-m2.5",name:"MiniMax: MiniMax M2.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.295,output:1.2,cacheRead:.03,cacheWrite:0},contextWindow:196608,maxTokens:196608},"mistralai/codestral-2508":{id:"mistralai/codestral-2508",name:"Mistral: Codestral 2508",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.3,output:.8999999999999999,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"mistralai/devstral-2512":{id:"mistralai/devstral-2512",name:"Mistral: Devstral 2 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"mistralai/devstral-medium":{id:"mistralai/devstral-medium",name:"Mistral: Devstral Medium",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/devstral-small":{id:"mistralai/devstral-small",name:"Mistral: Devstral Small 1.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/ministral-14b-2512":{id:"mistralai/ministral-14b-2512",name:"Mistral: Ministral 3 14B 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.19999999999999998,output:.19999999999999998,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"mistralai/ministral-3b-2512":{id:"mistralai/ministral-3b-2512",name:"Mistral: Ministral 3 3B 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/ministral-8b-2512":{id:"mistralai/ministral-8b-2512",name:"Mistral: Ministral 3 8B 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"mistralai/mistral-large":{id:"mistralai/mistral-large",name:"Mistral Large",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistralai/mistral-large-2407":{id:"mistralai/mistral-large-2407",name:"Mistral Large 2407",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/mistral-large-2411":{id:"mistralai/mistral-large-2411",name:"Mistral Large 2411",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/mistral-large-2512":{id:"mistralai/mistral-large-2512",name:"Mistral: Mistral Large 3 2512",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"mistralai/mistral-medium-3":{id:"mistralai/mistral-medium-3",name:"Mistral: Mistral Medium 3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/mistral-medium-3.1":{id:"mistralai/mistral-medium-3.1",name:"Mistral: Mistral Medium 3.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/mistral-nemo":{id:"mistralai/mistral-nemo",name:"Mistral: Mistral Nemo",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.02,output:.04,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"mistralai/mistral-saba":{id:"mistralai/mistral-saba",name:"Mistral: Saba",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.6,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"mistralai/mistral-small-24b-instruct-2501":{id:"mistralai/mistral-small-24b-instruct-2501",name:"Mistral: Mistral Small 3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.049999999999999996,output:.08,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:16384},"mistralai/mistral-small-3.1-24b-instruct:free":{id:"mistralai/mistral-small-3.1-24b-instruct:free",name:"Mistral: Mistral Small 3.1 24B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"mistralai/mistral-small-3.2-24b-instruct":{id:"mistralai/mistral-small-3.2-24b-instruct",name:"Mistral: Mistral Small 3.2 24B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.06,output:.18,cacheRead:.03,cacheWrite:0},contextWindow:131072,maxTokens:131072},"mistralai/mistral-small-creative":{id:"mistralai/mistral-small-creative",name:"Mistral: Mistral Small Creative",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"mistralai/mixtral-8x22b-instruct":{id:"mistralai/mixtral-8x22b-instruct",name:"Mistral: Mixtral 8x22B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:65536,maxTokens:4096},"mistralai/mixtral-8x7b-instruct":{id:"mistralai/mixtral-8x7b-instruct",name:"Mistral: Mixtral 8x7B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.54,output:.54,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:16384},"mistralai/pixtral-large-2411":{id:"mistralai/pixtral-large-2411",name:"Mistral: Pixtral Large 2411",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"mistralai/voxtral-small-24b-2507":{id:"mistralai/voxtral-small-24b-2507",name:"Mistral: Voxtral Small 24B 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:4096},"moonshotai/kimi-k2":{id:"moonshotai/kimi-k2",name:"MoonshotAI: Kimi K2 0711",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.55,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:4096},"moonshotai/kimi-k2-0905":{id:"moonshotai/kimi-k2-0905",name:"MoonshotAI: Kimi K2 0905",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:2,cacheRead:.15,cacheWrite:0},contextWindow:131072,maxTokens:4096},"moonshotai/kimi-k2-0905:exacto":{id:"moonshotai/kimi-k2-0905:exacto",name:"MoonshotAI: Kimi K2 0905 (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.6,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"moonshotai/kimi-k2-thinking":{id:"moonshotai/kimi-k2-thinking",name:"MoonshotAI: Kimi K2 Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.47,output:2,cacheRead:.14100000000000001,cacheWrite:0},contextWindow:131072,maxTokens:4096},"moonshotai/kimi-k2.5":{id:"moonshotai/kimi-k2.5",name:"MoonshotAI: Kimi K2.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.41,output:2.06,cacheRead:.07,cacheWrite:0},contextWindow:262144,maxTokens:4096},"nex-agi/deepseek-v3.1-nex-n1":{id:"nex-agi/deepseek-v3.1-nex-n1",name:"Nex AGI: DeepSeek V3.1 Nex N1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.27,output:1,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:163840},"nvidia/llama-3.1-nemotron-70b-instruct":{id:"nvidia/llama-3.1-nemotron-70b-instruct",name:"NVIDIA: Llama 3.1 Nemotron 70B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.2,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"nvidia/llama-3.3-nemotron-super-49b-v1.5":{id:"nvidia/llama-3.3-nemotron-super-49b-v1.5",name:"NVIDIA: Llama 3.3 Nemotron Super 49B V1.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"nvidia/nemotron-3-nano-30b-a3b":{id:"nvidia/nemotron-3-nano-30b-a3b",name:"NVIDIA: Nemotron 3 Nano 30B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.049999999999999996,output:.19999999999999998,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"nvidia/nemotron-3-nano-30b-a3b:free":{id:"nvidia/nemotron-3-nano-30b-a3b:free",name:"NVIDIA: Nemotron 3 Nano 30B A3B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"nvidia/nemotron-nano-12b-v2-vl:free":{id:"nvidia/nemotron-nano-12b-v2-vl:free",name:"NVIDIA: Nemotron Nano 12B 2 VL (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"nvidia/nemotron-nano-9b-v2":{id:"nvidia/nemotron-nano-9b-v2",name:"NVIDIA: Nemotron Nano 9B V2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.04,output:.16,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"nvidia/nemotron-nano-9b-v2:free":{id:"nvidia/nemotron-nano-9b-v2:free",name:"NVIDIA: Nemotron Nano 9B V2 (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-3.5-turbo":{id:"openai/gpt-3.5-turbo",name:"OpenAI: GPT-3.5 Turbo",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.5,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:16385,maxTokens:4096},"openai/gpt-3.5-turbo-0613":{id:"openai/gpt-3.5-turbo-0613",name:"OpenAI: GPT-3.5 Turbo (older v0613)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1,output:2,cacheRead:0,cacheWrite:0},contextWindow:4095,maxTokens:4096},"openai/gpt-3.5-turbo-16k":{id:"openai/gpt-3.5-turbo-16k",name:"OpenAI: GPT-3.5 Turbo 16k",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:3,output:4,cacheRead:0,cacheWrite:0},contextWindow:16385,maxTokens:4096},"openai/gpt-4":{id:"openai/gpt-4",name:"OpenAI: GPT-4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8191,maxTokens:4096},"openai/gpt-4-0314":{id:"openai/gpt-4-0314",name:"OpenAI: GPT-4 (older v0314)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:30,output:60,cacheRead:0,cacheWrite:0},contextWindow:8191,maxTokens:4096},"openai/gpt-4-1106-preview":{id:"openai/gpt-4-1106-preview",name:"OpenAI: GPT-4 Turbo (older v1106)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4-turbo":{id:"openai/gpt-4-turbo",name:"OpenAI: GPT-4 Turbo",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4-turbo-preview":{id:"openai/gpt-4-turbo-preview",name:"OpenAI: GPT-4 Turbo Preview",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4.1":{id:"openai/gpt-4.1",name:"OpenAI: GPT-4.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-mini":{id:"openai/gpt-4.1-mini",name:"OpenAI: GPT-4.1 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:1.5999999999999999,cacheRead:.09999999999999999,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-nano":{id:"openai/gpt-4.1-nano",name:"OpenAI: GPT-4.1 Nano",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4o":{id:"openai/gpt-4o",name:"OpenAI: GPT-4o",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-2024-05-13":{id:"openai/gpt-4o-2024-05-13",name:"OpenAI: GPT-4o (2024-05-13)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4o-2024-08-06":{id:"openai/gpt-4o-2024-08-06",name:"OpenAI: GPT-4o (2024-08-06)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-2024-11-20":{id:"openai/gpt-4o-2024-11-20",name:"OpenAI: GPT-4o (2024-11-20)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-audio-preview":{id:"openai/gpt-4o-audio-preview",name:"OpenAI: GPT-4o Audio",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-mini":{id:"openai/gpt-4o-mini",name:"OpenAI: GPT-4o-mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-mini-2024-07-18":{id:"openai/gpt-4o-mini-2024-07-18",name:"OpenAI: GPT-4o-mini (2024-07-18)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o:extended":{id:"openai/gpt-4o:extended",name:"OpenAI: GPT-4o (extended)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:6,output:18,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"openai/gpt-5":{id:"openai/gpt-5",name:"OpenAI: GPT-5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-codex":{id:"openai/gpt-5-codex",name:"OpenAI: GPT-5 Codex",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-image":{id:"openai/gpt-5-image",name:"OpenAI: GPT-5 Image",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:10,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-image-mini":{id:"openai/gpt-5-image-mini",name:"OpenAI: GPT-5 Image Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:2,cacheRead:.25,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-mini":{id:"openai/gpt-5-mini",name:"OpenAI: GPT-5 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-nano":{id:"openai/gpt-5-nano",name:"OpenAI: GPT-5 Nano",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.049999999999999996,output:.39999999999999997,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-pro":{id:"openai/gpt-5-pro",name:"OpenAI: GPT-5 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1":{id:"openai/gpt-5.1",name:"OpenAI: GPT-5.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-chat":{id:"openai/gpt-5.1-chat",name:"OpenAI: GPT-5.1 Chat",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.1-codex":{id:"openai/gpt-5.1-codex",name:"OpenAI: GPT-5.1-Codex",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-max":{id:"openai/gpt-5.1-codex-max",name:"OpenAI: GPT-5.1-Codex-Max",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-mini":{id:"openai/gpt-5.1-codex-mini",name:"OpenAI: GPT-5.1-Codex-Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:4e5,maxTokens:1e5},"openai/gpt-5.2":{id:"openai/gpt-5.2",name:"OpenAI: GPT-5.2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2-chat":{id:"openai/gpt-5.2-chat",name:"OpenAI: GPT-5.2 Chat",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.2-codex":{id:"openai/gpt-5.2-codex",name:"OpenAI: GPT-5.2-Codex",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2-pro":{id:"openai/gpt-5.2-pro",name:"OpenAI: GPT-5.2 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.3-chat":{id:"openai/gpt-5.3-chat",name:"OpenAI: GPT-5.3 Chat",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.3-codex":{id:"openai/gpt-5.3-codex",name:"OpenAI: GPT-5.3-Codex",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.4":{id:"openai/gpt-5.4",name:"OpenAI: GPT-5.4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},"openai/gpt-5.4-pro":{id:"openai/gpt-5.4-pro",name:"OpenAI: GPT-5.4 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:105e4,maxTokens:128e3},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"OpenAI: gpt-oss-120b",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.039,output:.19,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"openai/gpt-oss-120b:exacto":{id:"openai/gpt-oss-120b:exacto",name:"OpenAI: gpt-oss-120b (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.039,output:.19,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"openai/gpt-oss-120b:free":{id:"openai/gpt-oss-120b:free",name:"OpenAI: gpt-oss-120b (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"OpenAI: gpt-oss-20b",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.03,output:.14,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:4096},"openai/gpt-oss-20b:free":{id:"openai/gpt-oss-20b:free",name:"OpenAI: gpt-oss-20b (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-safeguard-20b":{id:"openai/gpt-oss-safeguard-20b",name:"OpenAI: gpt-oss-safeguard-20b",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:.037,cacheWrite:0},contextWindow:131072,maxTokens:65536},"openai/o1":{id:"openai/o1",name:"OpenAI: o1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3":{id:"openai/o3",name:"OpenAI: o3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-deep-research":{id:"openai/o3-deep-research",name:"OpenAI: o3 Deep Research",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-mini":{id:"openai/o3-mini",name:"OpenAI: o3 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-mini-high":{id:"openai/o3-mini-high",name:"OpenAI: o3 Mini High",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-pro":{id:"openai/o3-pro",name:"OpenAI: o3 Pro",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini":{id:"openai/o4-mini",name:"OpenAI: o4 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini-deep-research":{id:"openai/o4-mini-deep-research",name:"OpenAI: o4 Mini Deep Research",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini-high":{id:"openai/o4-mini-high",name:"OpenAI: o4 Mini High",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openrouter/auto":{id:"openrouter/auto",name:"Auto Router",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0},contextWindow:2e6,maxTokens:4096},"openrouter/free":{id:"openrouter/free",name:"Free Models Router",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:4096},"prime-intellect/intellect-3":{id:"prime-intellect/intellect-3",name:"Prime Intellect: INTELLECT-3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.1,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"qwen/qwen-2.5-72b-instruct":{id:"qwen/qwen-2.5-72b-instruct",name:"Qwen2.5 72B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.12,output:.39,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:16384},"qwen/qwen-2.5-7b-instruct":{id:"qwen/qwen-2.5-7b-instruct",name:"Qwen: Qwen2.5 7B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.04,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"qwen/qwen-max":{id:"qwen/qwen-max",name:"Qwen: Qwen-Max ",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.04,output:4.16,cacheRead:.20800000000000002,cacheWrite:0},contextWindow:32768,maxTokens:8192},"qwen/qwen-plus":{id:"qwen/qwen-plus",name:"Qwen: Qwen-Plus",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:1.2,cacheRead:.08,cacheWrite:0},contextWindow:1e6,maxTokens:32768},"qwen/qwen-plus-2025-07-28":{id:"qwen/qwen-plus-2025-07-28",name:"Qwen: Qwen Plus 0728",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.26,output:.78,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:32768},"qwen/qwen-plus-2025-07-28:thinking":{id:"qwen/qwen-plus-2025-07-28:thinking",name:"Qwen: Qwen Plus 0728 (thinking)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.26,output:.78,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:32768},"qwen/qwen-turbo":{id:"qwen/qwen-turbo",name:"Qwen: Qwen-Turbo",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.0325,output:.13,cacheRead:.006500000000000001,cacheWrite:0},contextWindow:131072,maxTokens:8192},"qwen/qwen-vl-max":{id:"qwen/qwen-vl-max",name:"Qwen: Qwen VL Max",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.7999999999999999,output:3.1999999999999997,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-14b":{id:"qwen/qwen3-14b",name:"Qwen: Qwen3 14B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:40960},"qwen/qwen3-235b-a22b":{id:"qwen/qwen3-235b-a22b",name:"Qwen: Qwen3 235B A22B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.45499999999999996,output:1.8199999999999998,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"qwen/qwen3-235b-a22b-2507":{id:"qwen/qwen3-235b-a22b-2507",name:"Qwen: Qwen3 235B A22B Instruct 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.071,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-235b-a22b-thinking-2507":{id:"qwen/qwen3-235b-a22b-thinking-2507",name:"Qwen: Qwen3 235B A22B Thinking 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.11,output:.6,cacheRead:.055,cacheWrite:0},contextWindow:262144,maxTokens:262144},"qwen/qwen3-30b-a3b":{id:"qwen/qwen3-30b-a3b",name:"Qwen: Qwen3 30B A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.08,output:.28,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:40960},"qwen/qwen3-30b-a3b-instruct-2507":{id:"qwen/qwen3-30b-a3b-instruct-2507",name:"Qwen: Qwen3 30B A3B Instruct 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09,output:.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:262144},"qwen/qwen3-30b-a3b-thinking-2507":{id:"qwen/qwen3-30b-a3b-thinking-2507",name:"Qwen: Qwen3 30B A3B Thinking 2507",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.051,output:.33999999999999997,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:4096},"qwen/qwen3-32b":{id:"qwen/qwen3-32b",name:"Qwen: Qwen3 32B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.08,output:.24,cacheRead:.04,cacheWrite:0},contextWindow:40960,maxTokens:40960},"qwen/qwen3-4b:free":{id:"qwen/qwen3-4b:free",name:"Qwen: Qwen3 4B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:4096},"qwen/qwen3-8b":{id:"qwen/qwen3-8b",name:"Qwen: Qwen3 8B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.049999999999999996,output:.39999999999999997,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:40960,maxTokens:8192},"qwen/qwen3-coder":{id:"qwen/qwen3-coder",name:"Qwen: Qwen3 Coder 480B A35B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.22,output:1,cacheRead:.022,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-coder-30b-a3b-instruct":{id:"qwen/qwen3-coder-30b-a3b-instruct",name:"Qwen: Qwen3 Coder 30B A3B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.07,output:.27,cacheRead:0,cacheWrite:0},contextWindow:16e4,maxTokens:32768},"qwen/qwen3-coder-flash":{id:"qwen/qwen3-coder-flash",name:"Qwen: Qwen3 Coder Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.195,output:.975,cacheRead:.039,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen/qwen3-coder-next":{id:"qwen/qwen3-coder-next",name:"Qwen: Qwen3 Coder Next",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.12,output:.75,cacheRead:.06,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3-coder-plus":{id:"qwen/qwen3-coder-plus",name:"Qwen: Qwen3 Coder Plus",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.65,output:3.25,cacheRead:.13,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen/qwen3-coder:exacto":{id:"qwen/qwen3-coder:exacto",name:"Qwen: Qwen3 Coder 480B A35B (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.22,output:1.7999999999999998,cacheRead:.022,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3-coder:free":{id:"qwen/qwen3-coder:free",name:"Qwen: Qwen3 Coder 480B A35B (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262e3,maxTokens:262e3},"qwen/qwen3-max":{id:"qwen/qwen3-max",name:"Qwen: Qwen3 Max",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:262144,maxTokens:32768},"qwen/qwen3-max-thinking":{id:"qwen/qwen3-max-thinking",name:"Qwen: Qwen3 Max Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.78,output:3.9,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32768},"qwen/qwen3-next-80b-a3b-instruct":{id:"qwen/qwen3-next-80b-a3b-instruct",name:"Qwen: Qwen3 Next 80B A3B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09,output:1.1,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-next-80b-a3b-instruct:free":{id:"qwen/qwen3-next-80b-a3b-instruct:free",name:"Qwen: Qwen3 Next 80B A3B Instruct (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-next-80b-a3b-thinking":{id:"qwen/qwen3-next-80b-a3b-thinking",name:"Qwen: Qwen3 Next 80B A3B Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.15,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"qwen/qwen3-vl-235b-a22b-instruct":{id:"qwen/qwen3-vl-235b-a22b-instruct",name:"Qwen: Qwen3 VL 235B A22B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.19999999999999998,output:.88,cacheRead:.11,cacheWrite:0},contextWindow:262144,maxTokens:4096},"qwen/qwen3-vl-235b-a22b-thinking":{id:"qwen/qwen3-vl-235b-a22b-thinking",name:"Qwen: Qwen3 VL 235B A22B Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-30b-a3b-instruct":{id:"qwen/qwen3-vl-30b-a3b-instruct",name:"Qwen: Qwen3 VL 30B A3B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.13,output:.52,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-30b-a3b-thinking":{id:"qwen/qwen3-vl-30b-a3b-thinking",name:"Qwen: Qwen3 VL 30B A3B Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-32b-instruct":{id:"qwen/qwen3-vl-32b-instruct",name:"Qwen: Qwen3 VL 32B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.10400000000000001,output:.41600000000000004,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-8b-instruct":{id:"qwen/qwen3-vl-8b-instruct",name:"Qwen: Qwen3 VL 8B Instruct",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text","image"],cost:{input:.08,output:.5,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3-vl-8b-thinking":{id:"qwen/qwen3-vl-8b-thinking",name:"Qwen: Qwen3 VL 8B Thinking",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.117,output:1.365,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:32768},"qwen/qwen3.5-122b-a10b":{id:"qwen/qwen3.5-122b-a10b",name:"Qwen: Qwen3.5-122B-A10B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.26,output:2.08,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3.5-27b":{id:"qwen/qwen3.5-27b",name:"Qwen: Qwen3.5-27B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.195,output:1.56,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3.5-35b-a3b":{id:"qwen/qwen3.5-35b-a3b",name:"Qwen: Qwen3.5-35B-A3B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.1625,output:1.3,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3.5-397b-a17b":{id:"qwen/qwen3.5-397b-a17b",name:"Qwen: Qwen3.5 397B A17B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.39,output:2.34,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:65536},"qwen/qwen3.5-flash-02-23":{id:"qwen/qwen3.5-flash-02-23",name:"Qwen: Qwen3.5-Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen/qwen3.5-plus-02-15":{id:"qwen/qwen3.5-plus-02-15",name:"Qwen: Qwen3.5 Plus 2026-02-15",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.26,output:1.56,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"qwen/qwq-32b":{id:"qwen/qwq-32b",name:"Qwen: QwQ 32B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"relace/relace-search":{id:"relace/relace-search",name:"Relace: Relace Search",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1,output:3,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:128e3},"sao10k/l3-euryale-70b":{id:"sao10k/l3-euryale-70b",name:"Sao10k: Llama 3 Euryale 70B v2.1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:1.48,output:1.48,cacheRead:0,cacheWrite:0},contextWindow:8192,maxTokens:8192},"sao10k/l3.1-euryale-70b":{id:"sao10k/l3.1-euryale-70b",name:"Sao10K: Llama 3.1 Euryale 70B v2.2",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.65,output:.75,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"stepfun/step-3.5-flash":{id:"stepfun/step-3.5-flash",name:"StepFun: Step 3.5 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"stepfun/step-3.5-flash:free":{id:"stepfun/step-3.5-flash:free",name:"StepFun: Step 3.5 Flash (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"thedrummer/rocinante-12b":{id:"thedrummer/rocinante-12b",name:"TheDrummer: Rocinante 12B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.16999999999999998,output:.43,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"thedrummer/unslopnemo-12b":{id:"thedrummer/unslopnemo-12b",name:"TheDrummer: UnslopNemo 12B",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"tngtech/deepseek-r1t2-chimera":{id:"tngtech/deepseek-r1t2-chimera",name:"TNG: DeepSeek R1T2 Chimera",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.25,output:.85,cacheRead:.125,cacheWrite:0},contextWindow:163840,maxTokens:163840},"upstage/solar-pro-3":{id:"upstage/solar-pro-3",name:"Upstage: Solar Pro 3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.15,output:.6,cacheRead:.015,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"x-ai/grok-3":{id:"x-ai/grok-3",name:"xAI: Grok 3",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:4096},"x-ai/grok-3-beta":{id:"x-ai/grok-3-beta",name:"xAI: Grok 3 Beta",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:4096},"x-ai/grok-3-mini":{id:"x-ai/grok-3-mini",name:"xAI: Grok 3 Mini",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:4096},"x-ai/grok-3-mini-beta":{id:"x-ai/grok-3-mini-beta",name:"xAI: Grok 3 Mini Beta",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:4096},"x-ai/grok-4":{id:"x-ai/grok-4",name:"xAI: Grok 4",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:256e3,maxTokens:4096},"x-ai/grok-4-fast":{id:"x-ai/grok-4-fast",name:"xAI: Grok 4 Fast",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"x-ai/grok-4.1-fast":{id:"x-ai/grok-4.1-fast",name:"xAI: Grok 4.1 Fast",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"x-ai/grok-code-fast-1":{id:"x-ai/grok-code-fast-1",name:"xAI: Grok Code Fast 1",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.5,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:1e4},"xiaomi/mimo-v2-flash":{id:"xiaomi/mimo-v2-flash",name:"Xiaomi: MiMo-V2-Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.09,output:.29,cacheRead:.045,cacheWrite:0},contextWindow:262144,maxTokens:65536},"z-ai/glm-4-32b":{id:"z-ai/glm-4-32b",name:"Z.ai: GLM 4 32B ",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"z-ai/glm-4.5":{id:"z-ai/glm-4.5",name:"Z.ai: GLM 4.5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:131072,maxTokens:98304},"z-ai/glm-4.5-air":{id:"z-ai/glm-4.5-air",name:"Z.ai: GLM 4.5 Air",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.13,output:.85,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:131072,maxTokens:98304},"z-ai/glm-4.5-air:free":{id:"z-ai/glm-4.5-air:free",name:"Z.ai: GLM 4.5 Air (free)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:96e3},"z-ai/glm-4.5v":{id:"z-ai/glm-4.5v",name:"Z.ai: GLM 4.5V",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.6,output:1.7999999999999998,cacheRead:.11,cacheWrite:0},contextWindow:65536,maxTokens:16384},"z-ai/glm-4.6":{id:"z-ai/glm-4.6",name:"Z.ai: GLM 4.6",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.39,output:1.9,cacheRead:0,cacheWrite:0},contextWindow:204800,maxTokens:204800},"z-ai/glm-4.6:exacto":{id:"z-ai/glm-4.6:exacto",name:"Z.ai: GLM 4.6 (exacto)",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.44,output:1.76,cacheRead:.11,cacheWrite:0},contextWindow:204800,maxTokens:131072},"z-ai/glm-4.6v":{id:"z-ai/glm-4.6v",name:"Z.ai: GLM 4.6V",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text","image"],cost:{input:.3,output:.8999999999999999,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"z-ai/glm-4.7":{id:"z-ai/glm-4.7",name:"Z.ai: GLM 4.7",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.38,output:1.9800000000000002,cacheRead:.19,cacheWrite:0},contextWindow:202752,maxTokens:4096},"z-ai/glm-4.7-flash":{id:"z-ai/glm-4.7-flash",name:"Z.ai: GLM 4.7 Flash",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.06,output:.39999999999999997,cacheRead:.0100000002,cacheWrite:0},contextWindow:202752,maxTokens:4096},"z-ai/glm-5":{id:"z-ai/glm-5",name:"Z.ai: GLM 5",api:"openai-completions",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",reasoning:!0,input:["text"],cost:{input:.6,output:1.9,cacheRead:.119,cacheWrite:0},contextWindow:202752,maxTokens:4096}},"vercel-ai-gateway":{"alibaba/qwen-3-14b":{id:"alibaba/qwen-3-14b",name:"Qwen3-14B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.06,output:.24,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen-3-235b":{id:"alibaba/qwen-3-235b",name:"Qwen3-235B-A22B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.071,output:.463,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen-3-30b":{id:"alibaba/qwen-3-30b",name:"Qwen3-30B-A3B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.08,output:.29,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen-3-32b":{id:"alibaba/qwen-3-32b",name:"Qwen 3 32B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:40960,maxTokens:16384},"alibaba/qwen3-235b-a22b-thinking":{id:"alibaba/qwen3-235b-a22b-thinking",name:"Qwen3 235B A22B Thinking 2507",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.9000000000000004,cacheRead:0,cacheWrite:0},contextWindow:262114,maxTokens:262114},"alibaba/qwen3-coder":{id:"alibaba/qwen3-coder",name:"Qwen3 Coder 480B A35B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:1.5999999999999999,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:66536},"alibaba/qwen3-coder-30b-a3b":{id:"alibaba/qwen3-coder-30b-a3b",name:"Qwen 3 Coder 30B A3B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.07,output:.27,cacheRead:0,cacheWrite:0},contextWindow:16e4,maxTokens:32768},"alibaba/qwen3-coder-next":{id:"alibaba/qwen3-coder-next",name:"Qwen3 Coder Next",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.5,output:1.2,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"alibaba/qwen3-coder-plus":{id:"alibaba/qwen3-coder-plus",name:"Qwen3 Coder Plus",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:1,output:5,cacheRead:.19999999999999998,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"alibaba/qwen3-max-preview":{id:"alibaba/qwen3-max-preview",name:"Qwen3 Max Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:262144,maxTokens:32768},"alibaba/qwen3-max-thinking":{id:"alibaba/qwen3-max-thinking",name:"Qwen 3 Max Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:1.2,output:6,cacheRead:.24,cacheWrite:0},contextWindow:256e3,maxTokens:65536},"alibaba/qwen3-vl-thinking":{id:"alibaba/qwen3-vl-thinking",name:"Qwen3 VL 235B A22B Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.22,output:.88,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"alibaba/qwen3.5-flash":{id:"alibaba/qwen3.5-flash",name:"Qwen 3.5 Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.001,cacheWrite:.125},contextWindow:1e6,maxTokens:64e3},"alibaba/qwen3.5-plus":{id:"alibaba/qwen3.5-plus",name:"Qwen 3.5 Plus",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.39999999999999997,output:2.4,cacheRead:.04,cacheWrite:.5},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-3-haiku":{id:"anthropic/claude-3-haiku",name:"Claude 3 Haiku",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},contextWindow:2e5,maxTokens:4096},"anthropic/claude-3.5-haiku":{id:"anthropic/claude-3.5-haiku",name:"Claude 3.5 Haiku",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.7999999999999999,output:4,cacheRead:.08,cacheWrite:1},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.5-sonnet":{id:"anthropic/claude-3.5-sonnet",name:"Claude 3.5 Sonnet",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.5-sonnet-20240620":{id:"anthropic/claude-3.5-sonnet-20240620",name:"Claude 3.5 Sonnet (2024-06-20)",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:8192},"anthropic/claude-3.7-sonnet":{id:"anthropic/claude-3.7-sonnet",name:"Claude 3.7 Sonnet",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:8192},"anthropic/claude-haiku-4.5":{id:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.09999999999999999,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4":{id:"anthropic/claude-opus-4",name:"Claude Opus 4",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.1":{id:"anthropic/claude-opus-4.1",name:"Claude Opus 4.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3},"anthropic/claude-opus-4.5":{id:"anthropic/claude-opus-4.5",name:"Claude Opus 4.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:2e5,maxTokens:64e3},"anthropic/claude-opus-4.6":{id:"anthropic/claude-opus-4.6",name:"Claude Opus 4.6",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3},"anthropic/claude-sonnet-4":{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-sonnet-4.5":{id:"anthropic/claude-sonnet-4.5",name:"Claude Sonnet 4.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3},"anthropic/claude-sonnet-4.6":{id:"anthropic/claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:128e3},"arcee-ai/trinity-large-preview":{id:"arcee-ai/trinity-large-preview",name:"Trinity Large Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.25,output:1,cacheRead:0,cacheWrite:0},contextWindow:131e3,maxTokens:131e3},"bytedance/seed-1.6":{id:"bytedance/seed-1.6",name:"Seed 1.6",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.25,output:2,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:256e3,maxTokens:32e3},"cohere/command-a":{id:"cohere/command-a",name:"Command A",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:8e3},"deepseek/deepseek-v3":{id:"deepseek/deepseek-v3",name:"DeepSeek V3 0324",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.77,output:.77,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:16384},"deepseek/deepseek-v3.1":{id:"deepseek/deepseek-v3.1",name:"DeepSeek-V3.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.21,output:.7899999999999999,cacheRead:0,cacheWrite:0},contextWindow:163840,maxTokens:128e3},"deepseek/deepseek-v3.1-terminus":{id:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek V3.1 Terminus",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.27,output:1,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:65536},"deepseek/deepseek-v3.2":{id:"deepseek/deepseek-v3.2",name:"DeepSeek V3.2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.26,output:.38,cacheRead:.13,cacheWrite:0},contextWindow:128e3,maxTokens:8e3},"deepseek/deepseek-v3.2-thinking":{id:"deepseek/deepseek-v3.2-thinking",name:"DeepSeek V3.2 Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.28,output:.42,cacheRead:.028,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"google/gemini-2.5-flash":{id:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:2.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"google/gemini-2.5-flash-lite":{id:"google/gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-flash-lite-preview-09-2025":{id:"google/gemini-2.5-flash-lite-preview-09-2025",name:"Gemini 2.5 Flash Lite Preview 09-2025",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.01,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"google/gemini-2.5-flash-preview-09-2025":{id:"google/gemini-2.5-flash-preview-09-2025",name:"Gemini 2.5 Flash Preview 09-2025",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:0},contextWindow:1e6,maxTokens:65536},"google/gemini-2.5-pro":{id:"google/gemini-2.5-pro",name:"Gemini 2.5 Pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:1.25,output:10,cacheRead:0,cacheWrite:0},contextWindow:1048576,maxTokens:65536},"google/gemini-3-flash":{id:"google/gemini-3-flash",name:"Gemini 3 Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.5,output:3,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"google/gemini-3-pro-preview":{id:"google/gemini-3-pro-preview",name:"Gemini 3 Pro Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"google/gemini-3.1-flash-lite-preview":{id:"google/gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.25,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:1e6,maxTokens:65e3},"google/gemini-3.1-pro-preview":{id:"google/gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:0},contextWindow:1e6,maxTokens:64e3},"inception/mercury-2":{id:"inception/mercury-2",name:"Mercury 2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.25,output:.75,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:128e3,maxTokens:128e3},"inception/mercury-coder-small":{id:"inception/mercury-coder-small",name:"Mercury Coder Small Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.25,output:1,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:16384},"meituan/longcat-flash-chat":{id:"meituan/longcat-flash-chat",name:"LongCat Flash Chat",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meituan/longcat-flash-thinking":{id:"meituan/longcat-flash-thinking",name:"LongCat Flash Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.15,output:1.5,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-3.1-70b":{id:"meta/llama-3.1-70b",name:"Llama 3.1 70B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.39999999999999997,output:.39999999999999997,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"meta/llama-3.1-8b":{id:"meta/llama-3.1-8b",name:"Llama 3.1 8B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.03,output:.049999999999999996,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"meta/llama-3.2-11b":{id:"meta/llama-3.2-11b",name:"Llama 3.2 11B Vision Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.16,output:.16,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-3.2-90b":{id:"meta/llama-3.2-90b",name:"Llama 3.2 90B Vision Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-3.3-70b":{id:"meta/llama-3.3-70b",name:"Llama 3.3 70B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.72,output:.72,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"meta/llama-4-maverick":{id:"meta/llama-4-maverick",name:"Llama 4 Maverick 17B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"meta/llama-4-scout":{id:"meta/llama-4-scout",name:"Llama 4 Scout 17B Instruct",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.08,output:.3,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:8192},"minimax/minimax-m2":{id:"minimax/minimax-m2",name:"MiniMax M2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:205e3,maxTokens:205e3},"minimax/minimax-m2.1":{id:"minimax/minimax-m2.1",name:"MiniMax M2.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.15,cacheWrite:0},contextWindow:204800,maxTokens:131072},"minimax/minimax-m2.1-lightning":{id:"minimax/minimax-m2.1-lightning",name:"MiniMax M2.1 Lightning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:2.4,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131072},"minimax/minimax-m2.5":{id:"minimax/minimax-m2.5",name:"MiniMax M2.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},contextWindow:204800,maxTokens:131e3},"minimax/minimax-m2.5-highspeed":{id:"minimax/minimax-m2.5-highspeed",name:"MiniMax M2.5 High Speed",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.6,output:2.4,cacheRead:.03,cacheWrite:.375},contextWindow:4096,maxTokens:4096},"mistral/codestral":{id:"mistral/codestral",name:"Mistral Codestral",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.3,output:.8999999999999999,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/devstral-2":{id:"mistral/devstral-2",name:"Devstral 2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/devstral-small":{id:"mistral/devstral-small",name:"Devstral Small 1.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"mistral/devstral-small-2":{id:"mistral/devstral-small-2",name:"Devstral Small 2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"mistral/ministral-3b":{id:"mistral/ministral-3b",name:"Ministral 3B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.04,output:.04,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/ministral-8b":{id:"mistral/ministral-8b",name:"Ministral 8B",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.09999999999999999,output:.09999999999999999,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/mistral-medium":{id:"mistral/mistral-medium",name:"Mistral Medium 3.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:2,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:64e3},"mistral/mistral-small":{id:"mistral/mistral-small",name:"Mistral Small",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.3,cacheRead:0,cacheWrite:0},contextWindow:32e3,maxTokens:4e3},"mistral/pixtral-12b":{id:"mistral/pixtral-12b",name:"Pixtral 12B 2409",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.15,output:.15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"mistral/pixtral-large":{id:"mistral/pixtral-large",name:"Pixtral Large",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:2,output:6,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4e3},"moonshotai/kimi-k2":{id:"moonshotai/kimi-k2",name:"Kimi K2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.5,output:2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:16384},"moonshotai/kimi-k2-thinking":{id:"moonshotai/kimi-k2-thinking",name:"Kimi K2 Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.47,output:2,cacheRead:.14100000000000001,cacheWrite:0},contextWindow:216144,maxTokens:216144},"moonshotai/kimi-k2-thinking-turbo":{id:"moonshotai/kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:1.15,output:8,cacheRead:.15,cacheWrite:0},contextWindow:262114,maxTokens:262114},"moonshotai/kimi-k2-turbo":{id:"moonshotai/kimi-k2-turbo",name:"Kimi K2 Turbo",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:2.4,output:10,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:16384},"moonshotai/kimi-k2.5":{id:"moonshotai/kimi-k2.5",name:"Kimi K2.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.5,output:2.8,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"nvidia/nemotron-nano-12b-v2-vl":{id:"nvidia/nemotron-nano-12b-v2-vl",name:"Nvidia Nemotron Nano 12B V2 VL",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.19999999999999998,output:.6,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"nvidia/nemotron-nano-9b-v2":{id:"nvidia/nemotron-nano-9b-v2",name:"Nvidia Nemotron Nano 9B V2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.04,output:.16,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/codex-mini":{id:"openai/codex-mini",name:"Codex Mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.5,output:6,cacheRead:.375,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/gpt-4-turbo":{id:"openai/gpt-4-turbo",name:"GPT-4 Turbo",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:10,output:30,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:4096},"openai/gpt-4.1":{id:"openai/gpt-4.1",name:"GPT-4.1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-mini":{id:"openai/gpt-4.1-mini",name:"GPT-4.1 mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.39999999999999997,output:1.5999999999999999,cacheRead:.09999999999999999,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4.1-nano":{id:"openai/gpt-4.1-nano",name:"GPT-4.1 nano",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.09999999999999999,output:.39999999999999997,cacheRead:.03,cacheWrite:0},contextWindow:1047576,maxTokens:32768},"openai/gpt-4o":{id:"openai/gpt-4o",name:"GPT-4o",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-4o-mini":{id:"openai/gpt-4o-mini",name:"GPT-4o mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:.15,output:.6,cacheRead:.075,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5":{id:"openai/gpt-5",name:"GPT-5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-chat":{id:"openai/gpt-5-chat",name:"GPT 5 Chat",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5-codex":{id:"openai/gpt-5-codex",name:"GPT-5-Codex",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-mini":{id:"openai/gpt-5-mini",name:"GPT-5 mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.03,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-nano":{id:"openai/gpt-5-nano",name:"GPT-5 nano",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.049999999999999996,output:.39999999999999997,cacheRead:.01,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5-pro":{id:"openai/gpt-5-pro",name:"GPT-5 pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:15,output:120,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:272e3},"openai/gpt-5.1-codex":{id:"openai/gpt-5.1-codex",name:"GPT-5.1-Codex",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-max":{id:"openai/gpt-5.1-codex-max",name:"GPT 5.1 Codex Max",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-codex-mini":{id:"openai/gpt-5.1-codex-mini",name:"GPT 5.1 Codex Mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.024999999999999998,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.1-instant":{id:"openai/gpt-5.1-instant",name:"GPT-5.1 Instant",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.1-thinking":{id:"openai/gpt-5.1-thinking",name:"GPT 5.1 Thinking",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2":{id:"openai/gpt-5.2",name:"GPT 5.2",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.18,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2-chat":{id:"openai/gpt-5.2-chat",name:"GPT 5.2 Chat",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.2-codex":{id:"openai/gpt-5.2-codex",name:"GPT 5.2 Codex",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.2-pro":{id:"openai/gpt-5.2-pro",name:"GPT 5.2 ",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:21,output:168,cacheRead:0,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.3-chat":{id:"openai/gpt-5.3-chat",name:"GPT-5.3 Chat",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:128e3,maxTokens:16384},"openai/gpt-5.3-codex":{id:"openai/gpt-5.3-codex",name:"GPT 5.3 Codex",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3},"openai/gpt-5.4":{id:"openai/gpt-5.4",name:"GPT 5.4",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"openai/gpt-5.4-pro":{id:"openai/gpt-5.4-pro",name:"GPT 5.4 Pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:30,output:180,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"openai/gpt-oss-120b":{id:"openai/gpt-oss-120b",name:"gpt-oss-120b",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.09999999999999999,output:.5,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"openai/gpt-oss-20b":{id:"openai/gpt-oss-20b",name:"gpt-oss-20b",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.07,output:.3,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192},"openai/gpt-oss-safeguard-20b":{id:"openai/gpt-oss-safeguard-20b",name:"gpt-oss-safeguard-20b",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.075,output:.3,cacheRead:.037,cacheWrite:0},contextWindow:131072,maxTokens:65536},"openai/o1":{id:"openai/o1",name:"o1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3":{id:"openai/o3",name:"o3",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-deep-research":{id:"openai/o3-deep-research",name:"o3-deep-research",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-mini":{id:"openai/o3-mini",name:"o3-mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o3-pro":{id:"openai/o3-pro",name:"o3 Pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:20,output:80,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"openai/o4-mini":{id:"openai/o4-mini",name:"o4-mini",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0},contextWindow:2e5,maxTokens:1e5},"perplexity/sonar":{id:"perplexity/sonar",name:"Sonar",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:1,output:1,cacheRead:0,cacheWrite:0},contextWindow:127e3,maxTokens:8e3},"perplexity/sonar-pro":{id:"perplexity/sonar-pro",name:"Sonar Pro",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:8e3},"prime-intellect/intellect-3":{id:"prime-intellect/intellect-3",name:"INTELLECT 3",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.1,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"vercel/v0-1.0-md":{id:"vercel/v0-1.0-md",name:"v0-1.0-md",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32e3},"vercel/v0-1.5-md":{id:"vercel/v0-1.5-md",name:"v0-1.5-md",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32768},"xai/grok-2-vision":{id:"xai/grok-2-vision",name:"Grok 2 Vision",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text","image"],cost:{input:2,output:10,cacheRead:0,cacheWrite:0},contextWindow:32768,maxTokens:32768},"xai/grok-3":{id:"xai/grok-3",name:"Grok 3 Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"xai/grok-3-fast":{id:"xai/grok-3-fast",name:"Grok 3 Fast Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:5,output:25,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"xai/grok-3-mini":{id:"xai/grok-3-mini",name:"Grok 3 Mini Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.3,output:.5,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"xai/grok-3-mini-fast":{id:"xai/grok-3-mini-fast",name:"Grok 3 Mini Fast Beta",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.6,output:4,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"xai/grok-4":{id:"xai/grok-4",name:"Grok 4",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:0,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"xai/grok-4-fast-non-reasoning":{id:"xai/grok-4-fast-non-reasoning",name:"Grok 4 Fast Non-Reasoning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:256e3},"xai/grok-4-fast-reasoning":{id:"xai/grok-4-fast-reasoning",name:"Grok 4 Fast Reasoning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:256e3},"xai/grok-4.1-fast-non-reasoning":{id:"xai/grok-4.1-fast-non-reasoning",name:"Grok 4.1 Fast Non-Reasoning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!1,input:["text"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"xai/grok-4.1-fast-reasoning":{id:"xai/grok-4.1-fast-reasoning",name:"Grok 4.1 Fast Reasoning",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:.5,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"xai/grok-code-fast-1":{id:"xai/grok-code-fast-1",name:"Grok Code Fast 1",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.5,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:256e3},"xiaomi/mimo-v2-flash":{id:"xiaomi/mimo-v2-flash",name:"MiMo V2 Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.09,output:.29,cacheRead:0,cacheWrite:0},contextWindow:262144,maxTokens:32e3},"zai/glm-4.5":{id:"zai/glm-4.5",name:"GLM-4.5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:131072},"zai/glm-4.5-air":{id:"zai/glm-4.5-air",name:"GLM 4.5 Air",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.19999999999999998,output:1.1,cacheRead:.03,cacheWrite:0},contextWindow:128e3,maxTokens:96e3},"zai/glm-4.5v":{id:"zai/glm-4.5v",name:"GLM 4.5V",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.6,output:1.7999999999999998,cacheRead:0,cacheWrite:0},contextWindow:65536,maxTokens:16384},"zai/glm-4.6":{id:"zai/glm-4.6",name:"GLM 4.6",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.44999999999999996,output:1.7999999999999998,cacheRead:.11,cacheWrite:0},contextWindow:2e5,maxTokens:96e3},"zai/glm-4.6v":{id:"zai/glm-4.6v",name:"GLM-4.6V",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:.3,output:.8999999999999999,cacheRead:.049999999999999996,cacheWrite:0},contextWindow:128e3,maxTokens:24e3},"zai/glm-4.6v-flash":{id:"zai/glm-4.6v-flash",name:"GLM-4.6V-Flash",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:24e3},"zai/glm-4.7":{id:"zai/glm-4.7",name:"GLM 4.7",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.43,output:1.75,cacheRead:.08,cacheWrite:0},contextWindow:202752,maxTokens:12e4},"zai/glm-4.7-flashx":{id:"zai/glm-4.7-flashx",name:"GLM 4.7 FlashX",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.06,output:.39999999999999997,cacheRead:.01,cacheWrite:0},contextWindow:2e5,maxTokens:128e3},"zai/glm-5":{id:"zai/glm-5",name:"GLM 5",api:"anthropic-messages",provider:"vercel-ai-gateway",baseUrl:"https://ai-gateway.vercel.sh",reasoning:!0,input:["text"],cost:{input:.7999999999999999,output:2.56,cacheRead:.16,cacheWrite:0},contextWindow:202800,maxTokens:131100}},xai:{"grok-2":{id:"grok-2",name:"Grok 2",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-2-1212":{id:"grok-2-1212",name:"Grok 2 (1212)",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-2-latest":{id:"grok-2-latest",name:"Grok 2 Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-2-vision":{id:"grok-2-vision",name:"Grok 2 Vision",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:8192,maxTokens:4096},"grok-2-vision-1212":{id:"grok-2-vision-1212",name:"Grok 2 Vision (1212)",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:8192,maxTokens:4096},"grok-2-vision-latest":{id:"grok-2-vision-latest",name:"Grok 2 Vision Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:2,output:10,cacheRead:2,cacheWrite:0},contextWindow:8192,maxTokens:4096},"grok-3":{id:"grok-3",name:"Grok 3",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-fast":{id:"grok-3-fast",name:"Grok 3 Fast",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:5,output:25,cacheRead:1.25,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-fast-latest":{id:"grok-3-fast-latest",name:"Grok 3 Fast Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:5,output:25,cacheRead:1.25,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-latest":{id:"grok-3-latest",name:"Grok 3 Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-mini":{id:"grok-3-mini",name:"Grok 3 Mini",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-mini-fast":{id:"grok-3-mini-fast",name:"Grok 3 Mini Fast",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.6,output:4,cacheRead:.15,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-mini-fast-latest":{id:"grok-3-mini-fast-latest",name:"Grok 3 Mini Fast Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.6,output:4,cacheRead:.15,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-3-mini-latest":{id:"grok-3-mini-latest",name:"Grok 3 Mini Latest",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:0},contextWindow:131072,maxTokens:8192},"grok-4":{id:"grok-4",name:"Grok 4",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:3,output:15,cacheRead:.75,cacheWrite:0},contextWindow:256e3,maxTokens:64e3},"grok-4-1-fast":{id:"grok-4-1-fast",name:"Grok 4.1 Fast",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"grok-4-1-fast-non-reasoning":{id:"grok-4-1-fast-non-reasoning",name:"Grok 4.1 Fast (Non-Reasoning)",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"grok-4-fast":{id:"grok-4-fast",name:"Grok 4 Fast",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"grok-4-fast-non-reasoning":{id:"grok-4-fast-non-reasoning",name:"Grok 4 Fast (Non-Reasoning)",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:0},contextWindow:2e6,maxTokens:3e4},"grok-beta":{id:"grok-beta",name:"Grok Beta",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text"],cost:{input:5,output:15,cacheRead:5,cacheWrite:0},contextWindow:131072,maxTokens:4096},"grok-code-fast-1":{id:"grok-code-fast-1",name:"Grok Code Fast 1",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!0,input:["text"],cost:{input:.2,output:1.5,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:1e4},"grok-vision-beta":{id:"grok-vision-beta",name:"Grok Vision Beta",api:"openai-completions",provider:"xai",baseUrl:"https://api.x.ai/v1",reasoning:!1,input:["text","image"],cost:{input:5,output:15,cacheRead:5,cacheWrite:0},contextWindow:8192,maxTokens:4096}},zai:{"glm-4.5":{id:"glm-4.5",name:"GLM-4.5",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:131072,maxTokens:98304},"glm-4.5-air":{id:"glm-4.5-air",name:"GLM-4.5-Air",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:.2,output:1.1,cacheRead:.03,cacheWrite:0},contextWindow:131072,maxTokens:98304},"glm-4.5-flash":{id:"glm-4.5-flash",name:"GLM-4.5-Flash",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:131072,maxTokens:98304},"glm-4.5v":{id:"glm-4.5v",name:"GLM-4.5V",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text","image"],cost:{input:.6,output:1.8,cacheRead:0,cacheWrite:0},contextWindow:64e3,maxTokens:16384},"glm-4.6":{id:"glm-4.6",name:"GLM-4.6",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:204800,maxTokens:131072},"glm-4.6v":{id:"glm-4.6v",name:"GLM-4.6V",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text","image"],cost:{input:.3,output:.9,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:32768},"glm-4.7":{id:"glm-4.7",name:"GLM-4.7",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},contextWindow:204800,maxTokens:131072},"glm-4.7-flash":{id:"glm-4.7-flash",name:"GLM-4.7-Flash",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:2e5,maxTokens:131072},"glm-5":{id:"glm-5",name:"GLM-5",api:"openai-completions",provider:"zai",baseUrl:"https://api.z.ai/api/coding/paas/v4",compat:{supportsDeveloperRole:!1,thinkingFormat:"zai"},reasoning:!0,input:["text"],cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},contextWindow:204800,maxTokens:131072}}},v=new Map;for(const[e,t]of Object.entries(y)){const n=new Map;for(const[e,o]of Object.entries(t))n.set(e,o);v.set(e,n)}function _(e,t){const n=v.get(e);return n?.get(t)}function w(){return Array.from(v.keys())}function O(e){const t=v.get(e);return t?Array.from(t.values()):[]}function S(e,t){return t.cost.input=e.cost.input/1e6*t.input,t.cost.output=e.cost.output/1e6*t.output,t.cost.cacheRead=e.cost.cacheRead/1e6*t.cacheRead,t.cost.cacheWrite=e.cost.cacheWrite/1e6*t.cacheWrite,t.cost.total=t.cost.input+t.cost.output+t.cost.cacheRead+t.cost.cacheWrite,t.cost}function x(e){return!!(e.id.includes("gpt-5.2")||e.id.includes("gpt-5.3")||e.id.includes("gpt-5.4"))||"anthropic-messages"===e.api&&(e.id.includes("opus-4-6")||e.id.includes("opus-4.6"))}function T(e,t){return!(!e||!t)&&(e.id===t.id&&e.provider===t.provider)}function P(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function C(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}let k=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return k=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^n()&15>>+e/4).toString(16))};function j(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const E=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};class R extends Error{}class A extends R{constructor(e,t,n,o){super(`${A.makeMessage(e,t,n)}`),this.status=e,this.headers=o,this.requestID=o?.get("request-id"),this.error=t}static makeMessage(e,t,n){const o=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&o?`${e} ${o}`:e?`${e} status code (no body)`:o||"(no status code or body)"}static generate(e,t,n,o){if(!e||!o)return new M({message:n,cause:E(t)});const r=t;return 400===e?new $(e,r,n,o):401===e?new D(e,r,n,o):403===e?new U(e,r,n,o):404===e?new L(e,r,n,o):409===e?new q(e,r,n,o):422===e?new F(e,r,n,o):429===e?new W(e,r,n,o):e>=500?new J(e,r,n,o):new A(e,r,n,o)}}class I extends A{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class M extends A{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class N extends M{constructor({message:e}={}){super({message:e??"Request timed out."})}}class $ extends A{}class D extends A{}class U extends A{}class L extends A{}class q extends A{}class F extends A{}class W extends A{}class J extends A{}const B=/^[a-z][a-z0-9+.-]*:/i;let G=e=>(G=Array.isArray,G(e)),V=G;function H(e){return"object"!=typeof e?{}:e??{}}const z=e=>{try{return JSON.parse(e)}catch(e){return}},K="0.73.0";const X=()=>{const e="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":Y(Deno.build.os),"X-Stainless-Arch":Z(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":Y(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Z(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const t=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const e=n.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":K,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const Z=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",Y=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let Q;function ee(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function te(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ee({start(){},async pull(e){const{done:n,value:o}=await t.next();n?e.close():e.enqueue(o)},async cancel(){await(t.return?.())}})}function ne(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}const oe=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});let re,ie;function ae(e){let t;return(re??(t=new globalThis.TextEncoder,re=t.encode.bind(t)))(e)}function se(e){let t;return(ie??(t=new globalThis.TextDecoder,ie=t.decode.bind(t)))(e)}var ce,ue;class le{constructor(){ce.set(this,void 0),ue.set(this,void 0),P(this,ce,new Uint8Array,"f"),P(this,ue,null,"f")}decode(e){if(null==e)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?ae(e):e;P(this,ce,function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let o=0;for(const t of e)n.set(t,o),o+=t.length;return n}([C(this,ce,"f"),t]),"f");const n=[];let o;for(;null!=(o=de(C(this,ce,"f"),C(this,ue,"f")));){if(o.carriage&&null==C(this,ue,"f")){P(this,ue,o.index,"f");continue}if(null!=C(this,ue,"f")&&(o.index!==C(this,ue,"f")+1||o.carriage)){n.push(se(C(this,ce,"f").subarray(0,C(this,ue,"f")-1))),P(this,ce,C(this,ce,"f").subarray(C(this,ue,"f")),"f"),P(this,ue,null,"f");continue}const e=null!==C(this,ue,"f")?o.preceding-1:o.preceding,t=se(C(this,ce,"f").subarray(0,e));n.push(t),P(this,ce,C(this,ce,"f").subarray(o.index),"f"),P(this,ue,null,"f")}return n}flush(){return C(this,ce,"f").length?this.decode("\n"):[]}}function de(e,t){for(let n=t??0;n<e.length;n++){if(10===e[n])return{preceding:n,index:n+1,carriage:!1};if(13===e[n])return{preceding:n,index:n+1,carriage:!0}}return null}function pe(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1])return t+2;if(13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return-1}ce=new WeakMap,ue=new WeakMap,le.NEWLINE_CHARS=new Set(["\n","\r"]),le.NEWLINE_REGEXP=/\r\n|[\n\r]/g;const he={off:0,error:200,warn:300,info:400,debug:500},fe=(e,t,n)=>{var o,r;if(e)return o=he,r=e,Object.prototype.hasOwnProperty.call(o,r)?e:void ve(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(he))}`)};function me(){}function ge(e,t,n){return!t||he[e]>he[n]?me:t[e].bind(t)}const be={error:me,warn:me,info:me,debug:me};let ye=new WeakMap;function ve(e){const t=e.logger,n=e.logLevel??"off";if(!t)return be;const o=ye.get(t);if(o&&o[0]===n)return o[1];const r={error:ge("error",t,n),warn:ge("warn",t,n),info:ge("info",t,n),debug:ge("debug",t,n)};return ye.set(t,[n,r]),r}const _e=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"x-api-key"===e.toLowerCase()||"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var we,Oe,Se;class xe{constructor(e,t,n){this.iterator=e,we.set(this,void 0),this.controller=t,P(this,we,n,"f")}static fromSSEResponse(e,t,n){let o=!1;const r=n?ve(n):console;return new xe(async function*(){if(o)throw new R("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let n=!1;try{for await(const n of async function*(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new R("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new R("Attempted to iterate over a response with no body")}const n=new Te,o=new le,r=ne(e.body);for await(const e of async function*(e){let t=new Uint8Array;for await(const n of e){if(null==n)continue;const e=n instanceof ArrayBuffer?new Uint8Array(n):"string"==typeof n?ae(n):n;let o,r=new Uint8Array(t.length+e.length);for(r.set(t),r.set(e,t.length),t=r;-1!==(o=pe(t));)yield t.slice(0,o),t=t.slice(o)}t.length>0&&(yield t)}(r))for(const t of o.decode(e)){const e=n.decode(t);e&&(yield e)}for(const e of o.flush()){const t=n.decode(e);t&&(yield t)}}(e,t)){if("completion"===n.event)try{yield JSON.parse(n.data)}catch(e){throw r.error("Could not parse message into JSON:",n.data),r.error("From chunk:",n.raw),e}if("message_start"===n.event||"message_delta"===n.event||"message_stop"===n.event||"content_block_start"===n.event||"content_block_delta"===n.event||"content_block_stop"===n.event)try{yield JSON.parse(n.data)}catch(e){throw r.error("Could not parse message into JSON:",n.data),r.error("From chunk:",n.raw),e}if("ping"!==n.event&&"error"===n.event)throw new A(void 0,z(n.data)??n.data,void 0,e.headers)}n=!0}catch(e){if(j(e))return;throw e}finally{n||t.abort()}},t,n)}static fromReadableStream(e,t,n){let o=!1;return new xe(async function*(){if(o)throw new R("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let n=!1;try{for await(const t of async function*(){const t=new le,n=ne(e);for await(const e of n)for(const n of t.decode(e))yield n;for(const e of t.flush())yield e}())n||t&&(yield JSON.parse(t));n=!0}catch(e){if(j(e))return;throw e}finally{n||t.abort()}},t,n)}[(we=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[],t=[],n=this.iterator(),o=o=>({next:()=>{if(0===o.length){const o=n.next();e.push(o),t.push(o)}return o.shift()}});return[new xe(()=>o(e),this.controller,C(this,we,"f")),new xe(()=>o(t),this.controller,C(this,we,"f"))]}toReadableStream(){const e=this;let t;return ee({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{const{value:n,done:o}=await t.next();if(o)return e.close();const r=ae(JSON.stringify(n)+"\n");e.enqueue(r)}catch(t){e.error(t)}},async cancel(){await(t.return?.())}})}}class Te{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,n,o]=function(e,t){const n=e.indexOf(t);if(-1!==n)return[e.substring(0,n),t,e.substring(n+t.length)];return[e,"",""]}(e,":");return o.startsWith(" ")&&(o=o.substring(1)),"event"===t?this.event=o:"data"===t&&this.data.push(o),null}}async function Pe(e,t){const{response:n,requestLogID:o,retryOfRequestLogID:r,startTime:i}=t,a=await(async()=>{if(t.options.stream)return ve(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller):xe.fromSSEResponse(n,t.controller);if(204===n.status)return null;if(t.options.__binaryResponse)return n;const o=n.headers.get("content-type"),r=o?.split(";")[0]?.trim();if(r?.includes("application/json")||r?.endsWith("+json")){if("0"===n.headers.get("content-length"))return;return Ce(await n.json(),n)}return await n.text()})();return ve(e).debug(`[${o}] response parsed`,_e({retryOfRequestLogID:r,url:n.url,status:n.status,body:a,durationMs:Date.now()-i})),a}function Ce(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("request-id"),enumerable:!1})}class ke extends Promise{constructor(e,t,n=Pe){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,Oe.set(this,void 0),P(this,Oe,e,"f")}_thenUnwrap(e){return new ke(C(this,Oe,"f"),this.responsePromise,async(t,n)=>Ce(e(await this.parseResponse(t,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(C(this,Oe,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}Oe=new WeakMap;class je{constructor(e,t,n,o){Se.set(this,void 0),P(this,Se,e,"f"),this.options=o,this.response=t,this.body=n}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new R("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await C(this,Se,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Se=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const t of e.getPaginatedItems())yield t}}class Ee extends ke{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await Pe(e,t),t.options))}async*[Symbol.asyncIterator](){const e=await(this);for await(const t of e)yield t}}class Re extends je{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.has_more=n.has_more||!1,this.first_id=n.first_id||null,this.last_id=n.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){const e=this.first_id;return e?{...this.options,query:{...H(this.options.query),before_id:e}}:null}const e=this.last_id;return e?{...this.options,query:{...H(this.options.query),after_id:e}}:null}}class Ae extends je{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.has_more=n.has_more||!1,this.next_page=n.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){const e=this.next_page;return e?{...this.options,query:{...H(this.options.query),page:e}}:null}}const Ie=()=>{if("undefined"==typeof File){const{process:e}=globalThis,t="string"==typeof e?.versions?.node&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Me(e,t,n){return Ie(),new File(e,t??"unknown_file",n)}function Ne(e,t){const n="object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"";return t?n.split(/[\\/]/).pop()||void 0:n}const $e=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],De=async(e,t,n=!0)=>({...e,body:await Le(e.body,t,n)}),Ue=new WeakMap;const Le=async(e,t,n=!0)=>{if(!await function(e){const t="function"==typeof e?e:e.fetch,n=Ue.get(t);if(n)return n;const o=(async()=>{try{const e="Response"in t?t.Response:(await t("data:,")).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return Ue.set(t,o),o}(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const o=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>Fe(o,e,t,n))),o},qe=e=>e instanceof Blob&&"name"in e,Fe=async(e,t,n,o)=>{if(void 0!==n){if(null==n)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)e.append(t,String(n));else if(n instanceof Response){let r={};const i=n.headers.get("Content-Type");i&&(r={type:i}),e.append(t,Me([await n.blob()],Ne(n,o),r))}else if($e(n))e.append(t,Me([await new Response(te(n)).blob()],Ne(n,o)));else if(qe(n))e.append(t,Me([n],Ne(n,o),{type:n.type}));else if(Array.isArray(n))await Promise.all(n.map(n=>Fe(e,t+"[]",n,o)));else{if("object"!=typeof n)throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`);await Promise.all(Object.entries(n).map(([n,r])=>Fe(e,`${t}[${n}]`,r,o)))}}},We=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function Je(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(We(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else{if(!$e(e)){const t=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";const t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}for await(const n of e)t.push(...await Je(n))}return t}class Be{constructor(e){this._client=e}}const Ge=Symbol.for("brand.privateNullableHeaders");function*Ve(e){if(!e)return;if(Ge in e){const{values:t,nulls:n}=e;yield*t.entries();for(const e of n)yield[e,null];return}let t,n=!1;e instanceof Headers?t=e.entries():V(e)?t=e:(n=!0,t=Object.entries(e??{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const o=V(e[1])?e[1]:[e[1]];let r=!1;for(const e of o)void 0!==e&&(n&&!r&&(r=!0,yield[t,null]),yield[t,e])}}const He=e=>{const t=new Headers,n=new Set;for(const o of e){const e=new Set;for(const[r,i]of Ve(o)){const o=r.toLowerCase();e.has(o)||(t.delete(r),e.add(o)),null===i?(t.delete(r),n.add(o)):(t.append(r,i),n.delete(o))}}return{[Ge]:!0,values:t,nulls:n}},ze=Symbol("anthropic.sdk.stainlessHelper");function Ke(e){return"object"==typeof e&&null!==e&&ze in e}function Xe(e,t){const n=new Set;if(e)for(const t of e)Ke(t)&&n.add(t[ze]);if(t)for(const e of t)if(Ke(e)&&n.add(e[ze]),Array.isArray(e.content))for(const t of e.content)Ke(t)&&n.add(t[ze]);return Array.from(n)}function Ze(e,t){const n=Xe(e,t);return 0===n.length?{}:{"x-stainless-helper":n.join(", ")}}function Ye(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Qe=Object.freeze(Object.create(null)),et=(e=Ye)=>function(t,...n){if(1===t.length)return t[0];let o=!1;const r=[],i=t.reduce((t,i,a)=>{/[?#]/.test(i)&&(o=!0);const s=n[a];let c=(o?encodeURIComponent:e)(""+s);return a!==n.length&&(null==s||"object"==typeof s&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??Qe)??Qe)?.toString)&&(c=s+"",r.push({start:t.length+i.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+i+(a===n.length?"":c)},""),a=i.split(/[?#]/,1)[0],s=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let c;for(;null!==(c=s.exec(a));)r.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can't be safely passed as a path parameter`});if(r.sort((e,t)=>e.start-t.start),r.length>0){let e=0;const t=r.reduce((t,n)=>{const o=" ".repeat(n.start-e),r="^".repeat(n.length);return e=n.start+n.length,t+o+r},"");throw new R(`Path parameters result in path with invalid segments:\n${r.map(e=>e.error).join("\n")}\n${i}\n${t}`)}return i},tt=et(Ye);class nt extends Be{list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/files",Re,{query:o,...t,headers:He([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},t?.headers])})}delete(e,t={},n){const{betas:o}=t??{};return this._client.delete(tt`/v1/files/${e}`,{...n,headers:He([{"anthropic-beta":[...o??[],"files-api-2025-04-14"].toString()},n?.headers])})}download(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/files/${e}/content`,{...n,headers:He([{"anthropic-beta":[...o??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/files/${e}`,{...n,headers:He([{"anthropic-beta":[...o??[],"files-api-2025-04-14"].toString()},n?.headers])})}upload(e,t){const{betas:n,...o}=e;return this._client.post("/v1/files",De({body:o,...t,headers:He([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},(r=o.file,Ke(r)?{"x-stainless-helper":r[ze]}:{}),t?.headers])},this._client));var r}}class ot extends Be{retrieve(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/models/${e}?beta=true`,{...n,headers:He([{...null!=o?.toString()?{"anthropic-beta":o?.toString()}:void 0},n?.headers])})}list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/models?beta=true",Re,{query:o,...t,headers:He([{...null!=n?.toString()?{"anthropic-beta":n?.toString()}:void 0},t?.headers])})}}const rt={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function it(e){return e?.output_format??e?.output_config?.format}function at(e,t,n){const o=it(t);return t&&"parse"in(o??{})?st(e,t,n):{...e,content:e.content.map(e=>{if("text"===e.type){const t=Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(t,"parsed",{get:()=>(n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null),enumerable:!1})}return e}),parsed_output:null}}function st(e,t,n){let o=null;const r=e.content.map(e=>{if("text"===e.type){const r=function(e,t){const n=it(e);if("json_schema"!==n?.type)return null;try{return"parse"in n?n.parse(t):JSON.parse(t)}catch(e){throw new R(`Failed to parse structured output: ${e}`)}}(t,e.text);null===o&&(o=r);const i=Object.defineProperty({...e},"parsed_output",{value:r,enumerable:!1});return Object.defineProperty(i,"parsed",{get:()=>(n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),r),enumerable:!1})}return e});return{...e,content:r,parsed_output:o}}const ct=e=>{if(0===e.length)return e;let t=e[e.length-1];switch(t.type){case"separator":return e=e.slice(0,e.length-1),ct(e);case"number":let n=t.value[t.value.length-1];if("."===n||"-"===n)return e=e.slice(0,e.length-1),ct(e);case"string":let o=e[e.length-2];if("delimiter"===o?.type)return e=e.slice(0,e.length-1),ct(e);if("brace"===o?.type&&"{"===o.value)return e=e.slice(0,e.length-1),ct(e);break;case"delimiter":return e=e.slice(0,e.length-1),ct(e)}return e},ut=e=>JSON.parse((e=>{let t="";return e.map(e=>{"string"===e.type?t+='"'+e.value+'"':t+=e.value}),t})((e=>{let t=[];return e.map(e=>{"brace"===e.type&&("{"===e.value?t.push("}"):t.splice(t.lastIndexOf("}"),1)),"paren"===e.type&&("["===e.value?t.push("]"):t.splice(t.lastIndexOf("]"),1))}),t.length>0&&t.reverse().map(t=>{"}"===t?e.push({type:"brace",value:"}"}):"]"===t&&e.push({type:"paren",value:"]"})}),e})(ct((e=>{let t=0,n=[];for(;t<e.length;){let o=e[t];if("\\"===o){t++;continue}if("{"===o){n.push({type:"brace",value:"{"}),t++;continue}if("}"===o){n.push({type:"brace",value:"}"}),t++;continue}if("["===o){n.push({type:"paren",value:"["}),t++;continue}if("]"===o){n.push({type:"paren",value:"]"}),t++;continue}if(":"===o){n.push({type:"separator",value:":"}),t++;continue}if(","===o){n.push({type:"delimiter",value:","}),t++;continue}if('"'===o){let r="",i=!1;for(o=e[++t];'"'!==o;){if(t===e.length){i=!0;break}if("\\"===o){if(t++,t===e.length){i=!0;break}r+=o+e[t],o=e[++t]}else r+=o,o=e[++t]}o=e[++t],i||n.push({type:"string",value:r});continue}if(o&&/\s/.test(o)){t++;continue}let r=/[0-9]/;if(o&&r.test(o)||"-"===o||"."===o){let i="";for("-"===o&&(i+=o,o=e[++t]);o&&r.test(o)||"."===o;)i+=o,o=e[++t];n.push({type:"number",value:i});continue}let i=/[a-z]/i;if(o&&i.test(o)){let r="";for(;o&&i.test(o)&&t!==e.length;)r+=o,o=e[++t];if("true"!=r&&"false"!=r&&"null"!==r){t++;continue}n.push({type:"name",value:r});continue}t++}return n})(e)))));var lt,dt,pt,ht,ft,mt,gt,bt,yt,vt,_t,wt,Ot,St,xt,Tt,Pt,Ct,kt,jt,Et,Rt,At,It;const Mt="__json_buf";function Nt(e){return"tool_use"===e.type||"server_tool_use"===e.type||"mcp_tool_use"===e.type}class $t{constructor(e,t){lt.add(this),this.messages=[],this.receivedMessages=[],dt.set(this,void 0),pt.set(this,null),this.controller=new AbortController,ht.set(this,void 0),ft.set(this,()=>{}),mt.set(this,()=>{}),gt.set(this,void 0),bt.set(this,()=>{}),yt.set(this,()=>{}),vt.set(this,{}),_t.set(this,!1),wt.set(this,!1),Ot.set(this,!1),St.set(this,!1),xt.set(this,void 0),Tt.set(this,void 0),Pt.set(this,void 0),jt.set(this,e=>{if(P(this,wt,!0,"f"),j(e)&&(e=new I),e instanceof I)return P(this,Ot,!0,"f"),this._emit("abort",e);if(e instanceof R)return this._emit("error",e);if(e instanceof Error){const t=new R(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new R(String(e)))}),P(this,ht,new Promise((e,t)=>{P(this,ft,e,"f"),P(this,mt,t,"f")}),"f"),P(this,gt,new Promise((e,t)=>{P(this,bt,e,"f"),P(this,yt,t,"f")}),"f"),C(this,ht,"f").catch(()=>{}),C(this,gt,"f").catch(()=>{}),P(this,pt,e,"f"),P(this,Pt,t?.logger??console,"f")}get response(){return C(this,xt,"f")}get request_id(){return C(this,Tt,"f")}async withResponse(){P(this,St,!0,"f");const e=await C(this,ht,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const t=new $t(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,n,{logger:o}={}){const r=new $t(t,{logger:o});for(const e of t.messages)r._addMessageParam(e);return P(r,pt,{...t,stream:!0},"f"),r._run(()=>r._createMessage(e,{...t,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},C(this,jt,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,n){const o=n?.signal;let r;o&&(o.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),o.addEventListener("abort",r));try{C(this,lt,"m",Et).call(this);const{response:o,data:r}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(o);for await(const e of r)C(this,lt,"m",Rt).call(this,e);if(r.controller.signal?.aborted)throw new I;C(this,lt,"m",At).call(this)}finally{o&&r&&o.removeEventListener("abort",r)}}_connected(e){this.ended||(P(this,xt,e,"f"),P(this,Tt,e?.headers.get("request-id"),"f"),C(this,ft,"f").call(this,e),this._emit("connect"))}get ended(){return C(this,_t,"f")}get errored(){return C(this,wt,"f")}get aborted(){return C(this,Ot,"f")}abort(){this.controller.abort()}on(e,t){return(C(this,vt,"f")[e]||(C(this,vt,"f")[e]=[])).push({listener:t}),this}off(e,t){const n=C(this,vt,"f")[e];if(!n)return this;const o=n.findIndex(e=>e.listener===t);return o>=0&&n.splice(o,1),this}once(e,t){return(C(this,vt,"f")[e]||(C(this,vt,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{P(this,St,!0,"f"),"error"!==e&&this.once("error",n),this.once(e,t)})}async done(){P(this,St,!0,"f"),await C(this,gt,"f")}get currentMessage(){return C(this,dt,"f")}async finalMessage(){return await this.done(),C(this,lt,"m",Ct).call(this)}async finalText(){return await this.done(),C(this,lt,"m",kt).call(this)}_emit(e,...t){if(C(this,_t,"f"))return;"end"===e&&(P(this,_t,!0,"f"),C(this,bt,"f").call(this));const n=C(this,vt,"f")[e];if(n&&(C(this,vt,"f")[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),"abort"===e){const e=t[0];return C(this,St,"f")||n?.length||Promise.reject(e),C(this,mt,"f").call(this,e),C(this,yt,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];C(this,St,"f")||n?.length||Promise.reject(e),C(this,mt,"f").call(this,e),C(this,yt,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",C(this,lt,"m",Ct).call(this))}async _fromReadableStream(e,t){const n=t?.signal;let o;n&&(n.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),n.addEventListener("abort",o));try{C(this,lt,"m",Et).call(this),this._connected(null);const t=xe.fromReadableStream(e,this.controller);for await(const e of t)C(this,lt,"m",Rt).call(this,e);if(t.controller.signal?.aborted)throw new I;C(this,lt,"m",At).call(this)}finally{n&&o&&n.removeEventListener("abort",o)}}[(dt=new WeakMap,pt=new WeakMap,ht=new WeakMap,ft=new WeakMap,mt=new WeakMap,gt=new WeakMap,bt=new WeakMap,yt=new WeakMap,vt=new WeakMap,_t=new WeakMap,wt=new WeakMap,Ot=new WeakMap,St=new WeakMap,xt=new WeakMap,Tt=new WeakMap,Pt=new WeakMap,jt=new WeakMap,lt=new WeakSet,Ct=function(){if(0===this.receivedMessages.length)throw new R("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},kt=function(){if(0===this.receivedMessages.length)throw new R("stream ended without producing a Message with role=assistant");const e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new R("stream ended without producing a content block with type=text");return e.join(" ")},Et=function(){this.ended||P(this,dt,void 0,"f")},Rt=function(e){if(this.ended)return;const t=C(this,lt,"m",It).call(this,e);switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{const n=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===n.type&&this._emit("text",e.delta.text,n.text||"");break;case"citations_delta":"text"===n.type&&this._emit("citation",e.delta.citation,n.citations??[]);break;case"input_json_delta":Nt(n)&&n.input&&this._emit("inputJson",e.delta.partial_json,n.input);break;case"thinking_delta":"thinking"===n.type&&this._emit("thinking",e.delta.thinking,n.thinking);break;case"signature_delta":"thinking"===n.type&&this._emit("signature",n.signature);break;case"compaction_delta":"compaction"===n.type&&n.content&&this._emit("compaction",n.content);break;default:e.delta}break}case"message_stop":this._addMessageParam(t),this._addMessage(at(t,C(this,pt,"f"),{logger:C(this,Pt,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":P(this,dt,t,"f")}},At=function(){if(this.ended)throw new R("stream has ended, this shouldn't happen");const e=C(this,dt,"f");if(!e)throw new R("request ended without sending any chunks");return P(this,dt,void 0,"f"),at(e,C(this,pt,"f"),{logger:C(this,Pt,"f")})},It=function(e){let t=C(this,dt,"f");if("message_start"===e.type){if(t)throw new R(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new R(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case"message_stop":case"content_block_stop":return t;case"message_delta":return t.container=e.delta.container,t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,t.context_management=e.context_management,null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),null!=e.usage.iterations&&(t.usage.iterations=e.usage.iterations),t;case"content_block_start":return t.content.push(e.content_block),t;case"content_block_delta":{const n=t.content.at(e.index);switch(e.delta.type){case"text_delta":"text"===n?.type&&(t.content[e.index]={...n,text:(n.text||"")+e.delta.text});break;case"citations_delta":"text"===n?.type&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case"input_json_delta":if(n&&Nt(n)){let o=n[Mt]||"";o+=e.delta.partial_json;const r={...n};if(Object.defineProperty(r,Mt,{value:o,enumerable:!1,writable:!0}),o)try{r.input=ut(o)}catch(e){const t=new R(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${e}. JSON: ${o}`);C(this,jt,"f").call(this,t)}t.content[e.index]=r}break;case"thinking_delta":"thinking"===n?.type&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case"signature_delta":"thinking"===n?.type&&(t.content[e.index]={...n,signature:e.delta.signature});break;case"compaction_delta":"compaction"===n?.type&&(t.content[e.index]={...n,content:(n.content||"")+e.delta.content});break;default:e.delta}return t}}},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("streamEvent",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new xe(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}class Dt extends Error{constructor(e){super("string"==typeof e?e:e.map(e=>"text"===e.type?e.text:`[${e.type}]`).join(" ")),this.name="ToolError",this.content=e}}var Ut,Lt,qt,Ft,Wt,Jt,Bt,Gt,Vt,Ht,zt;function Kt(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}}class Xt{constructor(e,t,n){Ut.add(this),this.client=e,Lt.set(this,!1),qt.set(this,!1),Ft.set(this,void 0),Wt.set(this,void 0),Jt.set(this,void 0),Bt.set(this,void 0),Gt.set(this,void 0),Vt.set(this,0),P(this,Ft,{params:{...t,messages:structuredClone(t.messages)}},"f");const o=["BetaToolRunner",...Xe(t.tools,t.messages)].join(", ");P(this,Wt,{...n,headers:He([{"x-stainless-helper":o},n?.headers])},"f"),P(this,Gt,Kt(),"f")}async*[(Lt=new WeakMap,qt=new WeakMap,Ft=new WeakMap,Wt=new WeakMap,Jt=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,Ut=new WeakSet,Ht=async function(){const e=C(this,Ft,"f").params.compactionControl;if(!e||!e.enabled)return!1;let t=0;if(void 0!==C(this,Jt,"f"))try{const e=await C(this,Jt,"f");t=e.usage.input_tokens+(e.usage.cache_creation_input_tokens??0)+(e.usage.cache_read_input_tokens??0)+e.usage.output_tokens}catch{return!1}if(t<(e.contextTokenThreshold??1e5))return!1;const n=e.model??C(this,Ft,"f").params.model,o=e.summaryPrompt??"You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.",r=C(this,Ft,"f").params.messages;if("assistant"===r[r.length-1].role){const e=r[r.length-1];if(Array.isArray(e.content)){const t=e.content.filter(e=>"tool_use"!==e.type);0===t.length?r.pop():e.content=t}}const i=await this.client.beta.messages.create({model:n,messages:[...r,{role:"user",content:[{type:"text",text:o}]}],max_tokens:C(this,Ft,"f").params.max_tokens},{headers:{"x-stainless-helper":"compaction"}});if("text"!==i.content[0]?.type)throw new R("Expected text response for compaction");return C(this,Ft,"f").params.messages=[{role:"user",content:i.content}],!0},Symbol.asyncIterator)](){var e;if(C(this,Lt,"f"))throw new R("Cannot iterate over a consumed stream");P(this,Lt,!0,"f"),P(this,qt,!0,"f"),P(this,Bt,void 0,"f");try{for(;;){let t;try{if(C(this,Ft,"f").params.max_iterations&&C(this,Vt,"f")>=C(this,Ft,"f").params.max_iterations)break;P(this,qt,!1,"f"),P(this,Bt,void 0,"f"),P(this,Vt,(e=C(this,Vt,"f"),++e),"f"),P(this,Jt,void 0,"f");const{max_iterations:n,compactionControl:o,...r}=C(this,Ft,"f").params;r.stream?(t=this.client.beta.messages.stream({...r},C(this,Wt,"f")),P(this,Jt,t.finalMessage(),"f"),C(this,Jt,"f").catch(()=>{}),yield t):(P(this,Jt,this.client.beta.messages.create({...r,stream:!1},C(this,Wt,"f")),"f"),yield C(this,Jt,"f"));if(!await C(this,Ut,"m",Ht).call(this)){if(!C(this,qt,"f")){const{role:e,content:t}=await C(this,Jt,"f");C(this,Ft,"f").params.messages.push({role:e,content:t})}const e=await C(this,Ut,"m",zt).call(this,C(this,Ft,"f").params.messages.at(-1));if(e)C(this,Ft,"f").params.messages.push(e);else if(!C(this,qt,"f"))break}}finally{t&&t.abort()}}if(!C(this,Jt,"f"))throw new R("ToolRunner concluded without a message from the server");C(this,Gt,"f").resolve(await C(this,Jt,"f"))}catch(e){throw P(this,Lt,!1,"f"),C(this,Gt,"f").promise.catch(()=>{}),C(this,Gt,"f").reject(e),P(this,Gt,Kt(),"f"),e}}setMessagesParams(e){C(this,Ft,"f").params="function"==typeof e?e(C(this,Ft,"f").params):e,P(this,qt,!0,"f"),P(this,Bt,void 0,"f")}async generateToolResponse(){const e=await C(this,Jt,"f")??this.params.messages.at(-1);return e?C(this,Ut,"m",zt).call(this,e):null}done(){return C(this,Gt,"f").promise}async runUntilDone(){if(!C(this,Lt,"f"))for await(const e of this);return this.done()}get params(){return C(this,Ft,"f").params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}}zt=async function(e){return void 0!==C(this,Bt,"f")||P(this,Bt,async function(e,t=e.messages.at(-1)){if(!t||"assistant"!==t.role||!t.content||"string"==typeof t.content)return null;const n=t.content.filter(e=>"tool_use"===e.type);if(0===n.length)return null;return{role:"user",content:await Promise.all(n.map(async t=>{const n=e.tools.find(e=>("name"in e?e.name:e.mcp_server_name)===t.name);if(!n||!("run"in n))return{type:"tool_result",tool_use_id:t.id,content:`Error: Tool '${t.name}' not found`,is_error:!0};try{let e=t.input;"parse"in n&&n.parse&&(e=n.parse(e));const o=await n.run(e);return{type:"tool_result",tool_use_id:t.id,content:o}}catch(e){return{type:"tool_result",tool_use_id:t.id,content:e instanceof Dt?e.content:`Error: ${e instanceof Error?e.message:String(e)}`,is_error:!0}}}))}}(C(this,Ft,"f").params,e),"f"),C(this,Bt,"f")};class Zt{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){const e=new le;for await(const t of this.iterator)for(const n of e.decode(t))yield JSON.parse(n);for(const t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new R("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new R("Attempted to iterate over a response with no body")}return new Zt(ne(e.body),t)}}class Yt extends Be{create(e,t){const{betas:n,...o}=e;return this._client.post("/v1/messages/batches?beta=true",{body:o,...t,headers:He([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},t?.headers])})}retrieve(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/messages/batches/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString()},n?.headers])})}list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",Re,{query:o,...t,headers:He([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},t?.headers])})}delete(e,t={},n){const{betas:o}=t??{};return this._client.delete(tt`/v1/messages/batches/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString()},n?.headers])})}cancel(e,t={},n){const{betas:o}=t??{};return this._client.post(tt`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString()},n?.headers])})}async results(e,t={},n){const o=await this.retrieve(e);if(!o.results_url)throw new R(`No batch \`results_url\`; Has it finished processing? ${o.processing_status} - ${o.id}`);const{betas:r}=t??{};return this._client.get(o.results_url,{...n,headers:He([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Zt.fromResponse(t.response,t.controller))}}const Qt={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"},en=["claude-opus-4-6"];class tn extends Be{constructor(){super(...arguments),this.batches=new Yt(this._client)}create(e,t){const n=nn(e),{betas:o,...r}=n;r.model in Qt&&console.warn(`The model '${r.model}' is deprecated and will reach end-of-life on ${Qt[r.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),r.model in en&&r.thinking&&"enabled"===r.thinking.type&&console.warn(`Using Claude with ${r.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let i=this._client._options.timeout;if(!r.stream&&null==i){const e=rt[r.model]??void 0;i=this._client.calculateNonstreamingTimeout(r.max_tokens,e)}const a=Ze(r.tools,r.messages);return this._client.post("/v1/messages?beta=true",{body:r,timeout:i??6e5,...t,headers:He([{...null!=o?.toString()?{"anthropic-beta":o?.toString()}:void 0},a,t?.headers]),stream:n.stream??!1})}parse(e,t){return t={...t,headers:He([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(t=>st(t,e,{logger:this._client.logger??console}))}stream(e,t){return $t.createMessage(this,e,t)}countTokens(e,t){const n=nn(e),{betas:o,...r}=n;return this._client.post("/v1/messages/count_tokens?beta=true",{body:r,...t,headers:He([{"anthropic-beta":[...o??[],"token-counting-2024-11-01"].toString()},t?.headers])})}toolRunner(e,t){return new Xt(this._client,e,t)}}function nn(e){if(!e.output_format)return e;if(e.output_config?.format)throw new R("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");const{output_format:t,...n}=e;return{...n,output_config:{...e.output_config,format:t}}}tn.Batches=Yt,tn.BetaToolRunner=Xt,tn.ToolError=Dt;class on extends Be{create(e,t={},n){const{betas:o,...r}=t??{};return this._client.post(tt`/v1/skills/${e}/versions?beta=true`,De({body:r,...n,headers:He([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},n?.headers])},this._client))}retrieve(e,t,n){const{skill_id:o,betas:r}=t;return this._client.get(tt`/v1/skills/${o}/versions/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},n?.headers])})}list(e,t={},n){const{betas:o,...r}=t??{};return this._client.getAPIList(tt`/v1/skills/${e}/versions?beta=true`,Ae,{query:r,...n,headers:He([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},n?.headers])})}delete(e,t,n){const{skill_id:o,betas:r}=t;return this._client.delete(tt`/v1/skills/${o}/versions/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},n?.headers])})}}class rn extends Be{constructor(){super(...arguments),this.versions=new on(this._client)}create(e={},t){const{betas:n,...o}=e??{};return this._client.post("/v1/skills?beta=true",De({body:o,...t,headers:He([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},t?.headers])},this._client,!1))}retrieve(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/skills/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},n?.headers])})}list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/skills?beta=true",Ae,{query:o,...t,headers:He([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},t?.headers])})}delete(e,t={},n){const{betas:o}=t??{};return this._client.delete(tt`/v1/skills/${e}?beta=true`,{...n,headers:He([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},n?.headers])})}}rn.Versions=on;class an extends Be{constructor(){super(...arguments),this.models=new ot(this._client),this.messages=new tn(this._client),this.files=new nt(this._client),this.skills=new rn(this._client)}}an.Models=ot,an.Messages=tn,an.Files=nt,an.Skills=rn;class sn extends Be{create(e,t){const{betas:n,...o}=e;return this._client.post("/v1/complete",{body:o,timeout:this._client._options.timeout??6e5,...t,headers:He([{...null!=n?.toString()?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),stream:e.stream??!1})}}function cn(e){return e?.output_config?.format}function un(e,t,n){const o=cn(t);return t&&"parse"in(o??{})?ln(e,t,n):{...e,content:e.content.map(e=>{if("text"===e.type){return Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1})}return e}),parsed_output:null}}function ln(e,t,n){let o=null;const r=e.content.map(e=>{if("text"===e.type){const n=function(e,t){const n=cn(e);if("json_schema"!==n?.type)return null;try{return"parse"in n?n.parse(t):JSON.parse(t)}catch(e){throw new R(`Failed to parse structured output: ${e}`)}}(t,e.text);null===o&&(o=n);return Object.defineProperty({...e},"parsed_output",{value:n,enumerable:!1})}return e});return{...e,content:r,parsed_output:o}}var dn,pn,hn,fn,mn,gn,bn,yn,vn,_n,wn,On,Sn,xn,Tn,Pn,Cn,kn,jn,En,Rn,An,In,Mn;const Nn="__json_buf";function $n(e){return"tool_use"===e.type||"server_tool_use"===e.type}class Dn{constructor(e,t){dn.add(this),this.messages=[],this.receivedMessages=[],pn.set(this,void 0),hn.set(this,null),this.controller=new AbortController,fn.set(this,void 0),mn.set(this,()=>{}),gn.set(this,()=>{}),bn.set(this,void 0),yn.set(this,()=>{}),vn.set(this,()=>{}),_n.set(this,{}),wn.set(this,!1),On.set(this,!1),Sn.set(this,!1),xn.set(this,!1),Tn.set(this,void 0),Pn.set(this,void 0),Cn.set(this,void 0),En.set(this,e=>{if(P(this,On,!0,"f"),j(e)&&(e=new I),e instanceof I)return P(this,Sn,!0,"f"),this._emit("abort",e);if(e instanceof R)return this._emit("error",e);if(e instanceof Error){const t=new R(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new R(String(e)))}),P(this,fn,new Promise((e,t)=>{P(this,mn,e,"f"),P(this,gn,t,"f")}),"f"),P(this,bn,new Promise((e,t)=>{P(this,yn,e,"f"),P(this,vn,t,"f")}),"f"),C(this,fn,"f").catch(()=>{}),C(this,bn,"f").catch(()=>{}),P(this,hn,e,"f"),P(this,Cn,t?.logger??console,"f")}get response(){return C(this,Tn,"f")}get request_id(){return C(this,Pn,"f")}async withResponse(){P(this,xn,!0,"f");const e=await C(this,fn,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){const t=new Dn(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,n,{logger:o}={}){const r=new Dn(t,{logger:o});for(const e of t.messages)r._addMessageParam(e);return P(r,hn,{...t,stream:!0},"f"),r._run(()=>r._createMessage(e,{...t,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),r}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},C(this,En,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,n){const o=n?.signal;let r;o&&(o.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),o.addEventListener("abort",r));try{C(this,dn,"m",Rn).call(this);const{response:o,data:r}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(o);for await(const e of r)C(this,dn,"m",An).call(this,e);if(r.controller.signal?.aborted)throw new I;C(this,dn,"m",In).call(this)}finally{o&&r&&o.removeEventListener("abort",r)}}_connected(e){this.ended||(P(this,Tn,e,"f"),P(this,Pn,e?.headers.get("request-id"),"f"),C(this,mn,"f").call(this,e),this._emit("connect"))}get ended(){return C(this,wn,"f")}get errored(){return C(this,On,"f")}get aborted(){return C(this,Sn,"f")}abort(){this.controller.abort()}on(e,t){return(C(this,_n,"f")[e]||(C(this,_n,"f")[e]=[])).push({listener:t}),this}off(e,t){const n=C(this,_n,"f")[e];if(!n)return this;const o=n.findIndex(e=>e.listener===t);return o>=0&&n.splice(o,1),this}once(e,t){return(C(this,_n,"f")[e]||(C(this,_n,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{P(this,xn,!0,"f"),"error"!==e&&this.once("error",n),this.once(e,t)})}async done(){P(this,xn,!0,"f"),await C(this,bn,"f")}get currentMessage(){return C(this,pn,"f")}async finalMessage(){return await this.done(),C(this,dn,"m",kn).call(this)}async finalText(){return await this.done(),C(this,dn,"m",jn).call(this)}_emit(e,...t){if(C(this,wn,"f"))return;"end"===e&&(P(this,wn,!0,"f"),C(this,yn,"f").call(this));const n=C(this,_n,"f")[e];if(n&&(C(this,_n,"f")[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),"abort"===e){const e=t[0];return C(this,xn,"f")||n?.length||Promise.reject(e),C(this,gn,"f").call(this,e),C(this,vn,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];C(this,xn,"f")||n?.length||Promise.reject(e),C(this,gn,"f").call(this,e),C(this,vn,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",C(this,dn,"m",kn).call(this))}async _fromReadableStream(e,t){const n=t?.signal;let o;n&&(n.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),n.addEventListener("abort",o));try{C(this,dn,"m",Rn).call(this),this._connected(null);const t=xe.fromReadableStream(e,this.controller);for await(const e of t)C(this,dn,"m",An).call(this,e);if(t.controller.signal?.aborted)throw new I;C(this,dn,"m",In).call(this)}finally{n&&o&&n.removeEventListener("abort",o)}}[(pn=new WeakMap,hn=new WeakMap,fn=new WeakMap,mn=new WeakMap,gn=new WeakMap,bn=new WeakMap,yn=new WeakMap,vn=new WeakMap,_n=new WeakMap,wn=new WeakMap,On=new WeakMap,Sn=new WeakMap,xn=new WeakMap,Tn=new WeakMap,Pn=new WeakMap,Cn=new WeakMap,En=new WeakMap,dn=new WeakSet,kn=function(){if(0===this.receivedMessages.length)throw new R("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},jn=function(){if(0===this.receivedMessages.length)throw new R("stream ended without producing a Message with role=assistant");const e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new R("stream ended without producing a content block with type=text");return e.join(" ")},Rn=function(){this.ended||P(this,pn,void 0,"f")},An=function(e){if(this.ended)return;const t=C(this,dn,"m",Mn).call(this,e);switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{const n=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===n.type&&this._emit("text",e.delta.text,n.text||"");break;case"citations_delta":"text"===n.type&&this._emit("citation",e.delta.citation,n.citations??[]);break;case"input_json_delta":$n(n)&&n.input&&this._emit("inputJson",e.delta.partial_json,n.input);break;case"thinking_delta":"thinking"===n.type&&this._emit("thinking",e.delta.thinking,n.thinking);break;case"signature_delta":"thinking"===n.type&&this._emit("signature",n.signature);break;default:e.delta}break}case"message_stop":this._addMessageParam(t),this._addMessage(un(t,C(this,hn,"f"),{logger:C(this,Cn,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":P(this,pn,t,"f")}},In=function(){if(this.ended)throw new R("stream has ended, this shouldn't happen");const e=C(this,pn,"f");if(!e)throw new R("request ended without sending any chunks");return P(this,pn,void 0,"f"),un(e,C(this,hn,"f"),{logger:C(this,Cn,"f")})},Mn=function(e){let t=C(this,pn,"f");if("message_start"===e.type){if(t)throw new R(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new R(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case"message_stop":case"content_block_stop":return t;case"message_delta":return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),t;case"content_block_start":return t.content.push({...e.content_block}),t;case"content_block_delta":{const n=t.content.at(e.index);switch(e.delta.type){case"text_delta":"text"===n?.type&&(t.content[e.index]={...n,text:(n.text||"")+e.delta.text});break;case"citations_delta":"text"===n?.type&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case"input_json_delta":if(n&&$n(n)){let o=n[Nn]||"";o+=e.delta.partial_json;const r={...n};Object.defineProperty(r,Nn,{value:o,enumerable:!1,writable:!0}),o&&(r.input=ut(o)),t.content[e.index]=r}break;case"thinking_delta":"thinking"===n?.type&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case"signature_delta":"thinking"===n?.type&&(t.content[e.index]={...n,signature:e.delta.signature});break;default:e.delta}return t}}},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("streamEvent",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new xe(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}class Un extends Be{create(e,t){return this._client.post("/v1/messages/batches",{body:e,...t})}retrieve(e,t){return this._client.get(tt`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/v1/messages/batches",Re,{query:e,...t})}delete(e,t){return this._client.delete(tt`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(tt`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){const n=await this.retrieve(e);if(!n.results_url)throw new R(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);return this._client.get(n.results_url,{...t,headers:He([{Accept:"application/binary"},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Zt.fromResponse(t.response,t.controller))}}class Ln extends Be{constructor(){super(...arguments),this.batches=new Un(this._client)}create(e,t){e.model in qn&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${qn[e.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in Fn&&e.thinking&&"enabled"===e.thinking.type&&console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let n=this._client._options.timeout;if(!e.stream&&null==n){const t=rt[e.model]??void 0;n=this._client.calculateNonstreamingTimeout(e.max_tokens,t)}const o=Ze(e.tools,e.messages);return this._client.post("/v1/messages",{body:e,timeout:n??6e5,...t,headers:He([o,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>ln(t,e,this._client.logger??console))}stream(e,t){return Dn.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post("/v1/messages/count_tokens",{body:e,...t})}}const qn={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026"},Fn=["claude-opus-4-6"];Ln.Batches=Un;class Wn extends Be{retrieve(e,t={},n){const{betas:o}=t??{};return this._client.get(tt`/v1/models/${e}`,{...n,headers:He([{...null!=o?.toString()?{"anthropic-beta":o?.toString()}:void 0},n?.headers])})}list(e={},t){const{betas:n,...o}=e??{};return this._client.getAPIList("/v1/models",Re,{query:o,...t,headers:He([{...null!=n?.toString()?{"anthropic-beta":n?.toString()}:void 0},t?.headers])})}}const Jn=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;var Bn,Gn,Vn,Hn;class zn{constructor({baseURL:e=Jn("ANTHROPIC_BASE_URL"),apiKey:t=Jn("ANTHROPIC_API_KEY")??null,authToken:n=Jn("ANTHROPIC_AUTH_TOKEN")??null,...o}={}){Bn.add(this),Vn.set(this,void 0);const r={apiKey:t,authToken:n,...o,baseURL:e||"https://api.anthropic.com"};if(!r.dangerouslyAllowBrowser&&"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator)throw new R("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");this.baseURL=r.baseURL,this.timeout=r.timeout??Gn.DEFAULT_TIMEOUT,this.logger=r.logger??console;const i="warn";this.logLevel=i,this.logLevel=fe(r.logLevel,"ClientOptions.logLevel",this)??fe(Jn("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??i,this.fetchOptions=r.fetchOptions,this.maxRetries=r.maxRetries??2,this.fetch=r.fetch??function(){if("undefined"!=typeof fetch)return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),P(this,Vn,oe,"f"),this._options=r,this.apiKey="string"==typeof t?t:null,this.authToken=n}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!e.get("x-api-key")&&!e.get("authorization")&&!(this.apiKey&&e.get("x-api-key")||t.has("x-api-key")||this.authToken&&e.get("authorization")||t.has("authorization")))throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return He([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(null!=this.apiKey)return He([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(null!=this.authToken)return He([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>void 0!==t).map(([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new R(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${K}`}defaultIdempotencyKey(){return`stainless-node-retry-${k()}`}makeStatusError(e,t,n,o){return A.generate(e,t,n,o)}buildURL(e,t,n){const o=!C(this,Bn,"m",Hn).call(this)&&n||this.baseURL,r=(e=>B.test(e))(e)?new URL(e):new URL(o+(o.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return function(e){if(!e)return!0;for(const t in e)return!1;return!0}(i)||(t={...i,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(r.search=this.stringifyQuery(t)),r.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new R("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 6e5}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new ke(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){const o=await e,r=o.maxRetries??this.maxRetries;null==t&&(t=r),await this.prepareOptions(o);const{req:i,url:a,timeout:s}=await this.buildRequest(o,{retryCount:r-t});await this.prepareRequest(i,{url:a,options:o});const c="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=void 0===n?"":`, retryOf: ${n}`,l=Date.now();if(ve(this).debug(`[${c}] sending request`,_e({retryOfRequestLogID:n,method:o.method,url:a,options:o,headers:i.headers})),o.signal?.aborted)throw new I;const d=new AbortController,p=await this.fetchWithTimeout(a,i,s,d).catch(E),h=Date.now();if(p instanceof globalThis.Error){const e=`retrying, ${t} attempts remaining`;if(o.signal?.aborted)throw new I;const r=j(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(t)return ve(this).info(`[${c}] connection ${r?"timed out":"failed"} - ${e}`),ve(this).debug(`[${c}] connection ${r?"timed out":"failed"} (${e})`,_e({retryOfRequestLogID:n,url:a,durationMs:h-l,message:p.message})),this.retryRequest(o,t,n??c);if(ve(this).info(`[${c}] connection ${r?"timed out":"failed"} - error; no more retries left`),ve(this).debug(`[${c}] connection ${r?"timed out":"failed"} (error; no more retries left)`,_e({retryOfRequestLogID:n,url:a,durationMs:h-l,message:p.message})),r)throw new N;throw new M({cause:p})}const f=`[${c}${u}${[...p.headers.entries()].filter(([e])=>"request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join("")}] ${i.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-l}ms`;if(!p.ok){const e=await this.shouldRetry(p);if(t&&e){const e=`retrying, ${t} attempts remaining`;return await async function(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await(e[Symbol.asyncIterator]().return?.());const t=e.getReader(),n=t.cancel();t.releaseLock(),await n}(p.body),ve(this).info(`${f} - ${e}`),ve(this).debug(`[${c}] response error (${e})`,_e({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-l})),this.retryRequest(o,t,n??c,p.headers)}const r=e?"error; no more retries left":"error; not retryable";ve(this).info(`${f} - ${r}`);const i=await p.text().catch(e=>E(e).message),a=z(i),s=a?void 0:i;ve(this).debug(`[${c}] response error (${r})`,_e({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:s,durationMs:Date.now()-l}));throw this.makeStatusError(p.status,a,s,p.headers)}return ve(this).info(f),ve(this).debug(`[${c}] response start`,_e({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-l})),{response:p,options:o,controller:d,requestLogID:c,retryOfRequestLogID:n,startTime:l}}getAPIList(e,t,n){return this.requestAPIList(t,n&&"then"in n?n.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...n})}requestAPIList(e,t){const n=this.makeRequest(t,null,void 0);return new Ee(this,n,e)}async fetchWithTimeout(e,t,n,o){const{signal:r,method:i,...a}=t||{},s=this._makeAbort(o);r&&r.addEventListener("abort",s,{once:!0});const c=setTimeout(s,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||"object"==typeof a.body&&null!==a.body&&Symbol.asyncIterator in a.body,l={signal:o.signal,...u?{duplex:"half"}:{},method:"GET",...a};i&&(l.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,l)}finally{clearTimeout(c)}}async shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||(409===e.status||(429===e.status||e.status>=500)))}async retryRequest(e,t,n,o){let r;const i=o?.get("retry-after-ms");if(i){const e=parseFloat(i);Number.isNaN(e)||(r=e)}const a=o?.get("retry-after");if(a&&!r){const e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}if(!(r&&0<=r&&r<6e4)){const n=e.maxRetries??this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,n)}var s;return await(s=r,new Promise(e=>setTimeout(e,s))),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){const n=t-e;return Math.min(.5*Math.pow(2,n),8)*(1-.25*Math.random())*1e3}calculateNonstreamingTimeout(e,t){const n=6e5;if(36e5*e/128e3>n||null!=t&&e>t)throw new R("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return n}async buildRequest(e,{retryCount:t=0}={}){const n={...e},{method:o,path:r,query:i,defaultBaseURL:a}=n,s=this.buildURL(r,i,a);"timeout"in n&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new R(`${e} must be an integer`);if(t<0)throw new R(`${e} must be a positive integer`)})("timeout",n.timeout),n.timeout=n.timeout??this.timeout;const{bodyHeaders:c,body:u}=this.buildBody({options:n});return{req:{method:o,headers:await this.buildHeaders({options:e,method:o,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:o}){let r={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);const i=He([r,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(o),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Q??(Q=X()),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(i),i.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};const n=He([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:te(e)}:C(this,Vn,"f").call(this,{body:e,headers:n})}}Gn=zn,Vn=new WeakMap,Bn=new WeakSet,Hn=function(){return"https://api.anthropic.com"!==this.baseURL},zn.Anthropic=Gn,zn.HUMAN_PROMPT="\\n\\nHuman:",zn.AI_PROMPT="\\n\\nAssistant:",zn.DEFAULT_TIMEOUT=6e5,zn.AnthropicError=R,zn.APIError=A,zn.APIConnectionError=M,zn.APIConnectionTimeoutError=N,zn.APIUserAbortError=I,zn.NotFoundError=L,zn.ConflictError=q,zn.RateLimitError=W,zn.BadRequestError=$,zn.AuthenticationError=D,zn.InternalServerError=J,zn.PermissionDeniedError=U,zn.UnprocessableEntityError=F,zn.toFile=async function(e,t,n){if(Ie(),e=await e,t||(t=Ne(e,!0)),(e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&We(e))(e))return e instanceof File&&null==t&&null==n?e:Me([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...n});if((e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob)(e)){const o=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Me(await Je(o),t,n)}const o=await Je(e);if(!n?.type){const e=o.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(n={...n,type:e})}return Me(o,t,n)};class Kn extends zn{constructor(){super(...arguments),this.completions=new sn(this),this.messages=new Ln(this),this.models=new Wn(this),this.beta=new an(this)}}Kn.Completions=sn,Kn.Messages=Ln,Kn.Models=Wn,Kn.Beta=an;class Xn{isComplete;extractResult;queue=[];waiting=[];done=!1;finalResultPromise;resolveFinalResult;constructor(e,t){this.isComplete=e,this.extractResult=t,this.finalResultPromise=new Promise(e=>{this.resolveFinalResult=e})}push(e){if(this.done)return;this.isComplete(e)&&(this.done=!0,this.resolveFinalResult(this.extractResult(e)));const t=this.waiting.shift();t?t({value:e,done:!1}):this.queue.push(e)}end(e){for(this.done=!0,void 0!==e&&this.resolveFinalResult(e);this.waiting.length>0;){this.waiting.shift()({value:void 0,done:!0})}}async*[Symbol.asyncIterator](){for(;;)if(this.queue.length>0)yield this.queue.shift();else{if(this.done)return;{const e=await new Promise(e=>this.waiting.push(e));if(e.done)return;yield e.value}}}result(){return this.finalResultPromise}}class Zn extends Xn{constructor(){super(e=>"done"===e.type||"error"===e.type,e=>{if("done"===e.type)return e.message;if("error"===e.type)return e.error;throw new Error("Unexpected event type for final result")})}}function Yn(){return new Zn}var Qn=n(77227);function eo(e){if(!e||""===e.trim())return{};try{return JSON.parse(e)}catch{try{return(0,Qn.parse)(e)??{}}catch{return{}}}}function to(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}function no(e){const t=e[e.length-1];return t&&"user"!==t.role?"agent":"user"}function oo(e){return e.some(e=>("user"===e.role&&Array.isArray(e.content)||!("toolResult"!==e.role||!Array.isArray(e.content)))&&e.content.some(e=>"image"===e.type))}function ro(e){const t={"X-Initiator":no(e.messages),"Openai-Intent":"conversation-edits"};return e.hasImages&&(t["Copilot-Vision-Request"]="true"),t}function io(e,t,n){return{temperature:t?.temperature,maxTokens:t?.maxTokens||Math.min(e.maxTokens,32e3),signal:t?.signal,apiKey:n||t?.apiKey,cacheRetention:t?.cacheRetention,sessionId:t?.sessionId,headers:t?.headers,onPayload:t?.onPayload,maxRetryDelayMs:t?.maxRetryDelayMs,metadata:t?.metadata}}function ao(e){return"xhigh"===e?"high":e}function so(e,t,n){const o=new Map,r=e.map(e=>{if("user"===e.role)return e;if("toolResult"===e.role){const t=o.get(e.toolCallId);return t&&t!==e.toolCallId?{...e,toolCallId:t}:e}if("assistant"===e.role){const r=e,i=r.provider===t.provider&&r.api===t.api&&r.model===t.id,a=r.content.flatMap(e=>{if("thinking"===e.type)return e.redacted?i?e:[]:i&&e.thinkingSignature?e:e.thinking&&""!==e.thinking.trim()?i?e:{type:"text",text:e.thinking}:[];if("text"===e.type)return i?e:{type:"text",text:e.text};if("toolCall"===e.type){const a=e;let s=a;if(!i&&a.thoughtSignature&&(s={...a},delete s.thoughtSignature),!i&&n){const e=n(a.id,t,r);e!==a.id&&(o.set(a.id,e),s={...s,id:e})}return s}return e});return{...r,content:a}}return e}),i=[];let a=[],s=new Set;for(let e=0;e<r.length;e++){const t=r[e];if("assistant"===t.role){if(a.length>0){for(const e of a)s.has(e.id)||i.push({role:"toolResult",toolCallId:e.id,toolName:e.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});a=[],s=new Set}const e=t;if("error"===e.stopReason||"aborted"===e.stopReason)continue;const n=e.content.filter(e=>"toolCall"===e.type);n.length>0&&(a=n,s=new Set),i.push(t)}else if("toolResult"===t.role)s.add(t.toolCallId),i.push(t);else if("user"===t.role){if(a.length>0){for(const e of a)s.has(e.id)||i.push({role:"toolResult",toolCallId:e.id,toolName:e.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});a=[],s=new Set}i.push(t)}else i.push(t)}return i}function co(e,t){const n=function(e){return e||("undefined"!=typeof process&&"long"===process.env.PI_CACHE_RETENTION?"long":"short")}(t);if("none"===n)return{retention:n};const o="long"===n&&e.includes("api.anthropic.com")?"1h":void 0;return{retention:n,cacheControl:{type:"ephemeral",...o&&{ttl:o}}}}const uo=new Map(["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"].map(e=>[e.toLowerCase(),e])),lo=e=>uo.get(e.toLowerCase())??e,po=(e,t)=>{if(t&&t.length>0){const n=e.toLowerCase(),o=t.find(e=>e.name.toLowerCase()===n);if(o)return o.name}return e};function ho(e){if(!e.some(e=>"image"===e.type))return to(e.map(e=>e.text).join("\n"));const t=e.map(e=>"text"===e.type?{type:"text",text:to(e.text)}:{type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}});return t.some(e=>"text"===e.type)||t.unshift({type:"text",text:"(see attached image)"}),t}function fo(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}const mo=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey??b(e.provider)??"";let a;if("github-copilot"===e.provider){const e=oo(t.messages);a=ro({messages:t.messages,hasImages:e})}const{client:s,isOAuthToken:c}=yo(e,i,n?.interleavedThinking??!0,n?.headers,a);let u=function(e,t,n,o){const{cacheControl:r}=co(e.baseUrl,o?.cacheRetention),i={model:e.id,messages:_o(t.messages,e,n,r),max_tokens:o?.maxTokens||e.maxTokens/3|0,stream:!0};n?(i.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...r?{cache_control:r}:{}}],t.systemPrompt&&i.system.push({type:"text",text:to(t.systemPrompt),...r?{cache_control:r}:{}})):t.systemPrompt&&(i.system=[{type:"text",text:to(t.systemPrompt),...r?{cache_control:r}:{}}]);void 0===o?.temperature||o?.thinkingEnabled||(i.temperature=o.temperature);t.tools&&(i.tools=function(e,t){return e?e.map(e=>{const n=e.parameters;return{name:t?lo(e.name):e.name,description:e.description,input_schema:{type:"object",properties:n.properties||{},required:n.required||[]}}}):[]}(t.tools,n));o?.thinkingEnabled&&e.reasoning&&(go(e.id)?(i.thinking={type:"adaptive"},o.effort&&(i.output_config={effort:o.effort})):i.thinking={type:"enabled",budget_tokens:o.thinkingBudgetTokens||1024});if(o?.metadata){const e=o.metadata.user_id;"string"==typeof e&&(i.metadata={user_id:e})}o?.toolChoice&&("string"==typeof o.toolChoice?i.tool_choice={type:o.toolChoice}:i.tool_choice=o.toolChoice);return i}(e,t,c,n);const l=await(n?.onPayload?.(u,e));void 0!==l&&(u=l);const d=s.messages.stream({...u,stream:!0},{signal:n?.signal});o.push({type:"start",partial:r});const p=r.content;for await(const n of d)if("message_start"===n.type)r.usage.input=n.message.usage.input_tokens||0,r.usage.output=n.message.usage.output_tokens||0,r.usage.cacheRead=n.message.usage.cache_read_input_tokens||0,r.usage.cacheWrite=n.message.usage.cache_creation_input_tokens||0,r.usage.totalTokens=r.usage.input+r.usage.output+r.usage.cacheRead+r.usage.cacheWrite,S(e,r.usage);else if("content_block_start"===n.type){if("text"===n.content_block.type){const e={type:"text",text:"",index:n.index};r.content.push(e),o.push({type:"text_start",contentIndex:r.content.length-1,partial:r})}else if("thinking"===n.content_block.type){const e={type:"thinking",thinking:"",thinkingSignature:"",index:n.index};r.content.push(e),o.push({type:"thinking_start",contentIndex:r.content.length-1,partial:r})}else if("redacted_thinking"===n.content_block.type){const e={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:n.content_block.data,redacted:!0,index:n.index};r.content.push(e),o.push({type:"thinking_start",contentIndex:r.content.length-1,partial:r})}else if("tool_use"===n.content_block.type){const e={type:"toolCall",id:n.content_block.id,name:c?po(n.content_block.name,t.tools):n.content_block.name,arguments:n.content_block.input??{},partialJson:"",index:n.index};r.content.push(e),o.push({type:"toolcall_start",contentIndex:r.content.length-1,partial:r})}}else if("content_block_delta"===n.type){if("text_delta"===n.delta.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&"text"===t.type&&(t.text+=n.delta.text,o.push({type:"text_delta",contentIndex:e,delta:n.delta.text,partial:r}))}else if("thinking_delta"===n.delta.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&"thinking"===t.type&&(t.thinking+=n.delta.thinking,o.push({type:"thinking_delta",contentIndex:e,delta:n.delta.thinking,partial:r}))}else if("input_json_delta"===n.delta.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&"toolCall"===t.type&&(t.partialJson+=n.delta.partial_json,t.arguments=eo(t.partialJson),o.push({type:"toolcall_delta",contentIndex:e,delta:n.delta.partial_json,partial:r}))}else if("signature_delta"===n.delta.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&"thinking"===t.type&&(t.thinkingSignature=t.thinkingSignature||"",t.thinkingSignature+=n.delta.signature)}}else if("content_block_stop"===n.type){const e=p.findIndex(e=>e.index===n.index),t=p[e];t&&(delete t.index,"text"===t.type?o.push({type:"text_end",contentIndex:e,content:t.text,partial:r}):"thinking"===t.type?o.push({type:"thinking_end",contentIndex:e,content:t.thinking,partial:r}):"toolCall"===t.type&&(t.arguments=eo(t.partialJson),delete t.partialJson,o.push({type:"toolcall_end",contentIndex:e,toolCall:t,partial:r})))}else"message_delta"===n.type&&(n.delta.stop_reason&&(r.stopReason=wo(n.delta.stop_reason)),null!=n.usage.input_tokens&&(r.usage.input=n.usage.input_tokens),null!=n.usage.output_tokens&&(r.usage.output=n.usage.output_tokens),null!=n.usage.cache_read_input_tokens&&(r.usage.cacheRead=n.usage.cache_read_input_tokens),null!=n.usage.cache_creation_input_tokens&&(r.usage.cacheWrite=n.usage.cache_creation_input_tokens),r.usage.totalTokens=r.usage.input+r.usage.output+r.usage.cacheRead+r.usage.cacheWrite,S(e,r.usage));if(n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o};function go(e){return e.includes("opus-4-6")||e.includes("opus-4.6")||e.includes("sonnet-4-6")||e.includes("sonnet-4.6")}const bo=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o);if(!n?.reasoning)return mo(e,t,{...r,thinkingEnabled:!1});if(go(e.id)){const o=function(e,t){switch(e){case"minimal":case"low":return"low";case"medium":return"medium";case"high":default:return"high";case"xhigh":return t.includes("opus-4-6")||t.includes("opus-4.6")?"max":"high"}}(n.reasoning,e.id);return mo(e,t,{...r,thinkingEnabled:!0,effort:o})}const i=function(e,t,n,o){let r={minimal:1024,low:2048,medium:8192,high:16384,...o}[ao(n)];const i=Math.min(e+r,t);return i<=r&&(r=Math.max(0,i-1024)),{maxTokens:i,thinkingBudget:r}}(r.maxTokens||0,e.maxTokens,n.reasoning,n.thinkingBudgets);return mo(e,t,{...r,maxTokens:i.maxTokens,thinkingEnabled:!0,thinkingBudgetTokens:i.thinkingBudget})};function yo(e,t,n,o,r){const i=n&&!go(e.id);if("github-copilot"===e.provider){const n=[];i&&n.push("interleaved-thinking-2025-05-14");return{client:new Kn({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:fo({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...n.length>0?{"anthropic-beta":n.join(",")}:{}},e.headers,r,o)}),isOAuthToken:!1}}const a=["fine-grained-tool-streaming-2025-05-14"];if(i&&a.push("interleaved-thinking-2025-05-14"),function(e){return e.includes("sk-ant-oat")}(t)){return{client:new Kn({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:fo({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":`claude-code-20250219,oauth-2025-04-20,${a.join(",")}`,"user-agent":"claude-cli/2.1.62","x-app":"cli"},e.headers,o)}),isOAuthToken:!0}}return{client:new Kn({apiKey:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:fo({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":a.join(",")},e.headers,o)}),isOAuthToken:!1}}function vo(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function _o(e,t,n,o){const r=[],i=so(e,t,vo);for(let e=0;e<i.length;e++){const o=i[e];if("user"===o.role)if("string"==typeof o.content)o.content.trim().length>0&&r.push({role:"user",content:to(o.content)});else{const e=o.content.map(e=>"text"===e.type?{type:"text",text:to(e.text)}:{type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}});let n=t?.input.includes("image")?e:e.filter(e=>"image"!==e.type);if(n=n.filter(e=>"text"!==e.type||e.text.trim().length>0),0===n.length)continue;r.push({role:"user",content:n})}else if("assistant"===o.role){const e=[];for(const t of o.content)if("text"===t.type){if(0===t.text.trim().length)continue;e.push({type:"text",text:to(t.text)})}else if("thinking"===t.type){if(t.redacted){e.push({type:"redacted_thinking",data:t.thinkingSignature});continue}if(0===t.thinking.trim().length)continue;t.thinkingSignature&&0!==t.thinkingSignature.trim().length?e.push({type:"thinking",thinking:to(t.thinking),signature:t.thinkingSignature}):e.push({type:"text",text:to(t.thinking)})}else"toolCall"===t.type&&e.push({type:"tool_use",id:t.id,name:n?lo(t.name):t.name,input:t.arguments??{}});if(0===e.length)continue;r.push({role:"assistant",content:e})}else if("toolResult"===o.role){const t=[];t.push({type:"tool_result",tool_use_id:o.toolCallId,content:ho(o.content),is_error:o.isError});let n=e+1;for(;n<i.length&&"toolResult"===i[n].role;){const e=i[n];t.push({type:"tool_result",tool_use_id:e.toolCallId,content:ho(e.content),is_error:e.isError}),n++}e=n-1,r.push({role:"user",content:t})}}if(o&&r.length>0){const e=r[r.length-1];if("user"===e.role)if(Array.isArray(e.content)){const t=e.content[e.content.length-1];!t||"text"!==t.type&&"image"!==t.type&&"tool_result"!==t.type||(t.cache_control=o)}else"string"==typeof e.content&&(e.content=[{type:"text",text:e.content,cache_control:o}])}return r}function wo(e){switch(e){case"end_turn":case"pause_turn":case"stop_sequence":return"stop";case"max_tokens":return"length";case"tool_use":return"toolUse";case"refusal":case"sensitive":return"error";default:throw new Error(`Unhandled stop reason: ${e}`)}}function Oo(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}function So(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}let xo=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return xo=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^n()&15>>+e/4).toString(16))};function To(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const Po=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};class Co extends Error{}class ko extends Co{constructor(e,t,n,o){super(`${ko.makeMessage(e,t,n)}`),this.status=e,this.headers=o,this.requestID=o?.get("x-request-id"),this.error=t;const r=t;this.code=r?.code,this.param=r?.param,this.type=r?.type}static makeMessage(e,t,n){const o=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&o?`${e} ${o}`:e?`${e} status code (no body)`:o||"(no status code or body)"}static generate(e,t,n,o){if(!e||!o)return new Eo({message:n,cause:Po(t)});const r=t?.error;return 400===e?new Ao(e,r,n,o):401===e?new Io(e,r,n,o):403===e?new Mo(e,r,n,o):404===e?new No(e,r,n,o):409===e?new $o(e,r,n,o):422===e?new Do(e,r,n,o):429===e?new Uo(e,r,n,o):e>=500?new Lo(e,r,n,o):new ko(e,r,n,o)}}class jo extends ko{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Eo extends ko{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class Ro extends Eo{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Ao extends ko{}class Io extends ko{}class Mo extends ko{}class No extends ko{}class $o extends ko{}class Do extends ko{}class Uo extends ko{}class Lo extends ko{}class qo extends Co{constructor(){super("Could not parse response content as the length limit was reached")}}class Fo extends Co{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class Wo extends Error{constructor(e){super(e)}}const Jo=/^[a-z][a-z0-9+.-]*:/i;let Bo=e=>(Bo=Array.isArray,Bo(e)),Go=Bo;function Vo(e){return"object"!=typeof e?{}:e??{}}function Ho(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}const zo=e=>new Promise(t=>setTimeout(t,e)),Ko="6.26.0";const Xo=()=>{const e="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":Yo(Deno.build.os),"X-Stainless-Arch":Zo(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":Yo(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Zo(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const t=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const e=n.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ko,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const Zo=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",Yo=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let Qo;function er(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function tr(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return er({start(){},async pull(e){const{done:n,value:o}=await t.next();n?e.close():e.enqueue(o)},async cancel(){await(t.return?.())}})}function nr(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}const or=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),rr="RFC3986",ir=e=>String(e),ar={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:ir};let sr=(e,t)=>(sr=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),sr(e,t));const cr=(()=>{const e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();const ur=1024;function lr(e,t){if(Bo(e)){const n=[];for(let o=0;o<e.length;o+=1)n.push(t(e[o]));return n}return t(e)}const dr={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},pr=function(e,t){Array.prototype.push.apply(e,Bo(t)?t:[t])};let hr;const fr={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,n,o,r)=>{if(0===e.length)return e;let i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===n)return escape(i).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});let a="";for(let e=0;e<i.length;e+=ur){const t=i.length>=ur?i.slice(e,e+ur):i,n=[];for(let e=0;e<t.length;++e){let o=t.charCodeAt(e);45===o||46===o||95===o||126===o||o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122||"RFC1738"===r&&(40===o||41===o)?n[n.length]=t.charAt(e):o<128?n[n.length]=cr[o]:o<2048?n[n.length]=cr[192|o>>6]+cr[128|63&o]:o<55296||o>=57344?n[n.length]=cr[224|o>>12]+cr[128|o>>6&63]+cr[128|63&o]:(e+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(e)),n[n.length]=cr[240|o>>18]+cr[128|o>>12&63]+cr[128|o>>6&63]+cr[128|63&o])}a+=n.join("")}return a},encodeValuesOnly:!1,format:rr,formatter:ir,indices:!1,serializeDate:e=>(hr??(hr=Function.prototype.call.bind(Date.prototype.toISOString)))(e),skipNulls:!1,strictNullHandling:!1};const mr={};function gr(e,t,n,o,r,i,a,s,c,u,l,d,p,h,f,m,g,b){let y=e,v=b,_=0,w=!1;for(;void 0!==(v=v.get(mr))&&!w;){const t=v.get(e);if(_+=1,void 0!==t){if(t===_)throw new RangeError("Cyclic object value");w=!0}void 0===v.get(mr)&&(_=0)}if("function"==typeof u?y=u(t,y):y instanceof Date?y=p?.(y):"comma"===n&&Bo(y)&&(y=lr(y,function(e){return e instanceof Date?p?.(e):e})),null===y){if(i)return c&&!m?c(t,fr.encoder,g,"key",h):t;y=""}if("string"==typeof(O=y)||"number"==typeof O||"boolean"==typeof O||"symbol"==typeof O||"bigint"==typeof O||function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))}(y)){if(c){const e=m?t:c(t,fr.encoder,g,"key",h);return[f?.(e)+"="+f?.(c(y,fr.encoder,g,"value",h))]}return[f?.(t)+"="+f?.(String(y))]}var O;const S=[];if(void 0===y)return S;let x;if("comma"===n&&Bo(y))m&&c&&(y=lr(y,c)),x=[{value:y.length>0?y.join(",")||null:void 0}];else if(Bo(u))x=u;else{const e=Object.keys(y);x=l?e.sort(l):e}const T=s?String(t).replace(/\./g,"%2E"):String(t),P=o&&Bo(y)&&1===y.length?T+"[]":T;if(r&&Bo(y)&&0===y.length)return P+"[]";for(let t=0;t<x.length;++t){const v=x[t],w="object"==typeof v&&void 0!==v.value?v.value:y[v];if(a&&null===w)continue;const O=d&&s?v.replace(/\./g,"%2E"):v,T=Bo(y)?"function"==typeof n?n(P,O):P:P+(d?"."+O:"["+O+"]");b.set(e,_);const C=new WeakMap;C.set(mr,b),pr(S,gr(w,T,n,o,r,i,a,s,"comma"===n&&m&&Bo(y)?null:c,u,l,d,p,h,f,m,g,C))}return S}function br(e,t={}){let n=e;const o=function(e=fr){if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");const t=e.charset||fr.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=rr;if(void 0!==e.format){if(!sr(ar,e.format))throw new TypeError("Unknown format option provided.");n=e.format}const o=ar[n];let r,i=fr.filter;if(("function"==typeof e.filter||Bo(e.filter))&&(i=e.filter),r=e.arrayFormat&&e.arrayFormat in dr?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":fr.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const a=void 0===e.allowDots?1==!!e.encodeDotInKeys||fr.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:fr.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:fr.allowEmptyArrays,arrayFormat:r,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:fr.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?fr.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:fr.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:fr.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:fr.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:fr.encodeValuesOnly,filter:i,format:n,formatter:o,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:fr.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:fr.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:fr.strictNullHandling}}(t);let r,i;"function"==typeof o.filter?(i=o.filter,n=i("",n)):Bo(o.filter)&&(i=o.filter,r=i);const a=[];if("object"!=typeof n||null===n)return"";const s=dr[o.arrayFormat],c="comma"===s&&o.commaRoundTrip;r||(r=Object.keys(n)),o.sort&&r.sort(o.sort);const u=new WeakMap;for(let e=0;e<r.length;++e){const t=r[e];o.skipNulls&&null===n[t]||pr(a,gr(n[t],t,s,c,o.allowEmptyArrays,o.strictNullHandling,o.skipNulls,o.encodeDotInKeys,o.encode?o.encoder:null,o.filter,o.sort,o.allowDots,o.serializeDate,o.format,o.formatter,o.encodeValuesOnly,o.charset,u))}const l=a.join(o.delimiter);let d=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&("iso-8859-1"===o.charset?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),l.length>0?d+l:""}let yr,vr;function _r(e){let t;return(yr??(t=new globalThis.TextEncoder,yr=t.encode.bind(t)))(e)}function wr(e){let t;return(vr??(t=new globalThis.TextDecoder,vr=t.decode.bind(t)))(e)}var Or,Sr;class xr{constructor(){Or.set(this,void 0),Sr.set(this,void 0),Oo(this,Or,new Uint8Array,"f"),Oo(this,Sr,null,"f")}decode(e){if(null==e)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?_r(e):e;Oo(this,Or,function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let o=0;for(const t of e)n.set(t,o),o+=t.length;return n}([So(this,Or,"f"),t]),"f");const n=[];let o;for(;null!=(o=Tr(So(this,Or,"f"),So(this,Sr,"f")));){if(o.carriage&&null==So(this,Sr,"f")){Oo(this,Sr,o.index,"f");continue}if(null!=So(this,Sr,"f")&&(o.index!==So(this,Sr,"f")+1||o.carriage)){n.push(wr(So(this,Or,"f").subarray(0,So(this,Sr,"f")-1))),Oo(this,Or,So(this,Or,"f").subarray(So(this,Sr,"f")),"f"),Oo(this,Sr,null,"f");continue}const e=null!==So(this,Sr,"f")?o.preceding-1:o.preceding,t=wr(So(this,Or,"f").subarray(0,e));n.push(t),Oo(this,Or,So(this,Or,"f").subarray(o.index),"f"),Oo(this,Sr,null,"f")}return n}flush(){return So(this,Or,"f").length?this.decode("\n"):[]}}function Tr(e,t){for(let n=t??0;n<e.length;n++){if(10===e[n])return{preceding:n,index:n+1,carriage:!1};if(13===e[n])return{preceding:n,index:n+1,carriage:!0}}return null}function Pr(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1])return t+2;if(13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return-1}Or=new WeakMap,Sr=new WeakMap,xr.NEWLINE_CHARS=new Set(["\n","\r"]),xr.NEWLINE_REGEXP=/\r\n|[\n\r]/g;const Cr={off:0,error:200,warn:300,info:400,debug:500},kr=(e,t,n)=>{var o,r;if(e)return o=Cr,r=e,Object.prototype.hasOwnProperty.call(o,r)?e:void Ir(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Cr))}`)};function jr(){}function Er(e,t,n){return!t||Cr[e]>Cr[n]?jr:t[e].bind(t)}const Rr={error:jr,warn:jr,info:jr,debug:jr};let Ar=new WeakMap;function Ir(e){const t=e.logger,n=e.logLevel??"off";if(!t)return Rr;const o=Ar.get(t);if(o&&o[0]===n)return o[1];const r={error:Er("error",t,n),warn:Er("warn",t,n),info:Er("info",t,n),debug:Er("debug",t,n)};return Ar.set(t,[n,r]),r}const Mr=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var Nr,$r,Dr;class Ur{constructor(e,t,n){this.iterator=e,Nr.set(this,void 0),this.controller=t,Oo(this,Nr,n,"f")}static fromSSEResponse(e,t,n,o){let r=!1;const i=n?Ir(n):console;return new Ur(async function*(){if(r)throw new Co("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let n=!1;try{for await(const r of async function*(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new Co("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new Co("Attempted to iterate over a response with no body")}const n=new Lr,o=new xr,r=nr(e.body);for await(const e of async function*(e){let t=new Uint8Array;for await(const n of e){if(null==n)continue;const e=n instanceof ArrayBuffer?new Uint8Array(n):"string"==typeof n?_r(n):n;let o,r=new Uint8Array(t.length+e.length);for(r.set(t),r.set(e,t.length),t=r;-1!==(o=Pr(t));)yield t.slice(0,o),t=t.slice(o)}t.length>0&&(yield t)}(r))for(const t of o.decode(e)){const e=n.decode(t);e&&(yield e)}for(const e of o.flush()){const t=n.decode(e);t&&(yield t)}}(e,t))if(!n)if(r.data.startsWith("[DONE]"))n=!0;else if(null!==r.event&&r.event.startsWith("thread.")){let e;try{e=JSON.parse(r.data)}catch(e){throw console.error("Could not parse message into JSON:",r.data),console.error("From chunk:",r.raw),e}if("error"==r.event)throw new ko(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}else{let t;try{t=JSON.parse(r.data)}catch(e){throw i.error("Could not parse message into JSON:",r.data),i.error("From chunk:",r.raw),e}if(t&&t.error)throw new ko(void 0,t.error,void 0,e.headers);yield o?{event:r.event,data:t}:t}n=!0}catch(e){if(To(e))return;throw e}finally{n||t.abort()}},t,n)}static fromReadableStream(e,t,n){let o=!1;return new Ur(async function*(){if(o)throw new Co("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let n=!1;try{for await(const t of async function*(){const t=new xr,n=nr(e);for await(const e of n)for(const n of t.decode(e))yield n;for(const e of t.flush())yield e}())n||t&&(yield JSON.parse(t));n=!0}catch(e){if(To(e))return;throw e}finally{n||t.abort()}},t,n)}[(Nr=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[],t=[],n=this.iterator(),o=o=>({next:()=>{if(0===o.length){const o=n.next();e.push(o),t.push(o)}return o.shift()}});return[new Ur(()=>o(e),this.controller,So(this,Nr,"f")),new Ur(()=>o(t),this.controller,So(this,Nr,"f"))]}toReadableStream(){const e=this;let t;return er({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{const{value:n,done:o}=await t.next();if(o)return e.close();const r=_r(JSON.stringify(n)+"\n");e.enqueue(r)}catch(t){e.error(t)}},async cancel(){await(t.return?.())}})}}class Lr{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,n,o]=function(e,t){const n=e.indexOf(t);if(-1!==n)return[e.substring(0,n),t,e.substring(n+t.length)];return[e,"",""]}(e,":");return o.startsWith(" ")&&(o=o.substring(1)),"event"===t?this.event=o:"data"===t&&this.data.push(o),null}}async function qr(e,t){const{response:n,requestLogID:o,retryOfRequestLogID:r,startTime:i}=t,a=await(async()=>{if(t.options.stream)return Ir(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData):Ur.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData);if(204===n.status)return null;if(t.options.__binaryResponse)return n;const o=n.headers.get("content-type"),r=o?.split(";")[0]?.trim();if(r?.includes("application/json")||r?.endsWith("+json")){if("0"===n.headers.get("content-length"))return;return Fr(await n.json(),n)}return await n.text()})();return Ir(e).debug(`[${o}] response parsed`,Mr({retryOfRequestLogID:r,url:n.url,status:n.status,body:a,durationMs:Date.now()-i})),a}function Fr(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}class Wr extends Promise{constructor(e,t,n=qr){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,$r.set(this,void 0),Oo(this,$r,e,"f")}_thenUnwrap(e){return new Wr(So(this,$r,"f"),this.responsePromise,async(t,n)=>Fr(e(await this.parseResponse(t,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(So(this,$r,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}$r=new WeakMap;class Jr{constructor(e,t,n,o){Dr.set(this,void 0),Oo(this,Dr,e,"f"),this.options=o,this.response=t,this.body=n}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new Co("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await So(this,Dr,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Dr=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const t of e.getPaginatedItems())yield t}}class Br extends Wr{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await qr(e,t),t.options))}async*[Symbol.asyncIterator](){const e=await(this);for await(const t of e)yield t}}class Gr extends Jr{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}}class Vr extends Jr{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){const e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...Vo(this.options.query),after:t}}:null}}class Hr extends Jr{constructor(e,t,n,o){super(e,t,n,o),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){const e=this.last_id;return e?{...this.options,query:{...Vo(this.options.query),after:e}}:null}}const zr=()=>{if("undefined"==typeof File){const{process:e}=globalThis,t="string"==typeof e?.versions?.node&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Kr(e,t,n){return zr(),new File(e,t??"unknown_file",n)}function Xr(e){return("object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}const Zr=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],Yr=async(e,t)=>oi(e.body)?{...e,body:await ti(e.body,t)}:e,Qr=async(e,t)=>({...e,body:await ti(e.body,t)}),ei=new WeakMap;const ti=async(e,t)=>{if(!await function(e){const t="function"==typeof e?e:e.fetch,n=ei.get(t);if(n)return n;const o=(async()=>{try{const e="Response"in t?t.Response:(await t("data:,")).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return ei.set(t,o),o}(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>ri(n,e,t))),n},ni=e=>e instanceof Blob&&"name"in e,oi=e=>{if((e=>"object"==typeof e&&null!==e&&(e instanceof Response||Zr(e)||ni(e)))(e))return!0;if(Array.isArray(e))return e.some(oi);if(e&&"object"==typeof e)for(const t in e)if(oi(e[t]))return!0;return!1},ri=async(e,t,n)=>{if(void 0!==n){if(null==n)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)e.append(t,String(n));else if(n instanceof Response)e.append(t,Kr([await n.blob()],Xr(n)));else if(Zr(n))e.append(t,Kr([await new Response(tr(n)).blob()],Xr(n)));else if(ni(n))e.append(t,n,Xr(n));else if(Array.isArray(n))await Promise.all(n.map(n=>ri(e,t+"[]",n)));else{if("object"!=typeof n)throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`);await Promise.all(Object.entries(n).map(([n,o])=>ri(e,`${t}[${n}]`,o)))}}},ii=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function ai(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(ii(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else{if(!Zr(e)){const t=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";const t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}for await(const n of e)t.push(...await ai(n))}return t}class si{constructor(e){this._client=e}}function ci(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const ui=Object.freeze(Object.create(null)),li=(e=ci)=>function(t,...n){if(1===t.length)return t[0];let o=!1;const r=[],i=t.reduce((t,i,a)=>{/[?#]/.test(i)&&(o=!0);const s=n[a];let c=(o?encodeURIComponent:e)(""+s);return a!==n.length&&(null==s||"object"==typeof s&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??ui)??ui)?.toString)&&(c=s+"",r.push({start:t.length+i.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+i+(a===n.length?"":c)},""),a=i.split(/[?#]/,1)[0],s=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let c;for(;null!==(c=s.exec(a));)r.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can't be safely passed as a path parameter`});if(r.sort((e,t)=>e.start-t.start),r.length>0){let e=0;const t=r.reduce((t,n)=>{const o=" ".repeat(n.start-e),r="^".repeat(n.length);return e=n.start+n.length,t+o+r},"");throw new Co(`Path parameters result in path with invalid segments:\n${r.map(e=>e.error).join("\n")}\n${i}\n${t}`)}return i},di=li(ci);class pi extends si{list(e,t={},n){return this._client.getAPIList(di`/chat/completions/${e}/messages`,Vr,{query:t,...n})}}function hi(e){return void 0!==e&&"function"in e&&void 0!==e.function}function fi(e){return"auto-parseable-response-format"===e?.$brand}function mi(e){return"auto-parseable-tool"===e?.$brand}function gi(e,t){const n=e.choices.map(e=>{if("length"===e.finish_reason)throw new qo;if("content_filter"===e.finish_reason)throw new Fo;return _i(e.message.tool_calls),{...e,message:{...e.message,...e.message.tool_calls?{tool_calls:e.message.tool_calls?.map(e=>function(e,t){const n=e.tools?.find(e=>hi(e)&&e.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:mi(n)?n.$parseRaw(t.function.arguments):n?.function.strict?JSON.parse(t.function.arguments):null}}}(t,e))??void 0}:void 0,parsed:e.message.content&&!e.message.refusal?bi(t,e.message.content):null}}});return{...e,choices:n}}function bi(e,t){if("json_schema"!==e.response_format?.type)return null;if("json_schema"===e.response_format?.type){if("$parseRaw"in e.response_format){return e.response_format.$parseRaw(t)}return JSON.parse(t)}return null}function yi(e,t){if(!e||!("tools"in e)||!e.tools)return!1;const n=e.tools?.find(e=>hi(e)&&e.function?.name===t.function.name);return hi(n)&&(mi(n)||n?.function.strict||!1)}function vi(e){return!!fi(e.response_format)||(e.tools?.some(e=>mi(e)||"function"===e.type&&!0===e.function.strict)??!1)}function _i(e){for(const t of e||[])if("function"!==t.type)throw new Co(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}const wi=e=>"assistant"===e?.role,Oi=e=>"tool"===e?.role;var Si,xi,Ti,Pi,Ci,ki,ji,Ei,Ri,Ai,Ii,Mi,Ni,$i,Di,Ui,Li,qi,Fi,Wi,Ji;class Bi{constructor(){Si.add(this),this.controller=new AbortController,xi.set(this,void 0),Ti.set(this,()=>{}),Pi.set(this,()=>{}),Ci.set(this,void 0),ki.set(this,()=>{}),ji.set(this,()=>{}),Ei.set(this,{}),Ri.set(this,!1),Ai.set(this,!1),Ii.set(this,!1),Mi.set(this,!1),Oo(this,xi,new Promise((e,t)=>{Oo(this,Ti,e,"f"),Oo(this,Pi,t,"f")}),"f"),Oo(this,Ci,new Promise((e,t)=>{Oo(this,ki,e,"f"),Oo(this,ji,t,"f")}),"f"),So(this,xi,"f").catch(()=>{}),So(this,Ci,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},So(this,Si,"m",Ni).bind(this))},0)}_connected(){this.ended||(So(this,Ti,"f").call(this),this._emit("connect"))}get ended(){return So(this,Ri,"f")}get errored(){return So(this,Ai,"f")}get aborted(){return So(this,Ii,"f")}abort(){this.controller.abort()}on(e,t){return(So(this,Ei,"f")[e]||(So(this,Ei,"f")[e]=[])).push({listener:t}),this}off(e,t){const n=So(this,Ei,"f")[e];if(!n)return this;const o=n.findIndex(e=>e.listener===t);return o>=0&&n.splice(o,1),this}once(e,t){return(So(this,Ei,"f")[e]||(So(this,Ei,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{Oo(this,Mi,!0,"f"),"error"!==e&&this.once("error",n),this.once(e,t)})}async done(){Oo(this,Mi,!0,"f"),await So(this,Ci,"f")}_emit(e,...t){if(So(this,Ri,"f"))return;"end"===e&&(Oo(this,Ri,!0,"f"),So(this,ki,"f").call(this));const n=So(this,Ei,"f")[e];if(n&&(So(this,Ei,"f")[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),"abort"===e){const e=t[0];return So(this,Mi,"f")||n?.length||Promise.reject(e),So(this,Pi,"f").call(this,e),So(this,ji,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];So(this,Mi,"f")||n?.length||Promise.reject(e),So(this,Pi,"f").call(this,e),So(this,ji,"f").call(this,e),this._emit("end")}}_emitFinal(){}}function Gi(e){return"function"==typeof e.parse}xi=new WeakMap,Ti=new WeakMap,Pi=new WeakMap,Ci=new WeakMap,ki=new WeakMap,ji=new WeakMap,Ei=new WeakMap,Ri=new WeakMap,Ai=new WeakMap,Ii=new WeakMap,Mi=new WeakMap,Si=new WeakSet,Ni=function(e){if(Oo(this,Ai,!0,"f"),e instanceof Error&&"AbortError"===e.name&&(e=new jo),e instanceof jo)return Oo(this,Ii,!0,"f"),this._emit("abort",e);if(e instanceof Co)return this._emit("error",e);if(e instanceof Error){const t=new Co(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new Co(String(e)))};const Vi=10;class Hi extends Bi{constructor(){super(...arguments),$i.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);const t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if("content"in e||(e.content=null),this.messages.push(e),t)if(this._emit("message",e),Oi(e)&&e.content)this._emit("functionToolCallResult",e.content);else if(wi(e)&&e.tool_calls)for(const t of e.tool_calls)"function"===t.type&&this._emit("functionToolCall",t.function)}async finalChatCompletion(){await this.done();const e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new Co("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),So(this,$i,"m",Di).call(this)}async finalMessage(){return await this.done(),So(this,$i,"m",Ui).call(this)}async finalFunctionToolCall(){return await this.done(),So(this,$i,"m",Li).call(this)}async finalFunctionToolCallResult(){return await this.done(),So(this,$i,"m",qi).call(this)}async totalUsage(){return await this.done(),So(this,$i,"m",Fi).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){const e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);const t=So(this,$i,"m",Ui).call(this);t&&this._emit("finalMessage",t);const n=So(this,$i,"m",Di).call(this);n&&this._emit("finalContent",n);const o=So(this,$i,"m",Li).call(this);o&&this._emit("finalFunctionToolCall",o);const r=So(this,$i,"m",qi).call(this);null!=r&&this._emit("finalFunctionToolCallResult",r),this._chatCompletions.some(e=>e.usage)&&this._emit("totalUsage",So(this,$i,"m",Fi).call(this))}async _createChatCompletion(e,t,n){const o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort())),So(this,$i,"m",Wi).call(this,t);const r=await e.chat.completions.create({...t,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(gi(r,t))}async _runChatCompletion(e,t,n){for(const e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,n)}async _runTools(e,t,n){const o="tool",{tool_choice:r="auto",stream:i,...a}=t,s="string"!=typeof r&&"function"===r.type&&r?.function?.name,{maxChatCompletions:c=Vi}=n||{},u=t.tools.map(e=>{if(mi(e)){if(!e.$callback)throw new Co("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:e.$callback,name:e.function.name,description:e.function.description||"",parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e}),l={};for(const e of u)"function"===e.type&&(l[e.function.name||e.function.function.name]=e.function);const d="tools"in t?u.map(e=>"function"===e.type?{type:"function",function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e):void 0;for(const e of t.messages)this._addMessage(e,!1);for(let t=0;t<c;++t){const t=await this._createChatCompletion(e,{...a,tool_choice:r,tools:d,messages:[...this.messages]},n),i=t.choices[0]?.message;if(!i)throw new Co("missing message in ChatCompletion response");if(!i.tool_calls?.length)return;for(const e of i.tool_calls){if("function"!==e.type)continue;const t=e.id,{name:n,arguments:r}=e.function,i=l[n];if(!i){const e=`Invalid tool_call: ${JSON.stringify(n)}. Available options are: ${Object.keys(l).map(e=>JSON.stringify(e)).join(", ")}. Please try again`;this._addMessage({role:o,tool_call_id:t,content:e});continue}if(s&&s!==n){const e=`Invalid tool_call: ${JSON.stringify(n)}. ${JSON.stringify(s)} requested. Please try again`;this._addMessage({role:o,tool_call_id:t,content:e});continue}let a;try{a=Gi(i)?await i.parse(r):r}catch(e){const n=e instanceof Error?e.message:String(e);this._addMessage({role:o,tool_call_id:t,content:n});continue}const c=await i.function(a,this),u=So(this,$i,"m",Ji).call(this,c);if(this._addMessage({role:o,tool_call_id:t,content:u}),s)return}}}}$i=new WeakSet,Di=function(){return So(this,$i,"m",Ui).call(this).content??null},Ui=function(){let e=this.messages.length;for(;e-- >0;){const t=this.messages[e];if(wi(t)){return{...t,content:t.content??null,refusal:t.refusal??null}}}throw new Co("stream ended without producing a ChatCompletionMessage with role=assistant")},Li=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(wi(t)&&t?.tool_calls?.length)return t.tool_calls.filter(e=>"function"===e.type).at(-1)?.function}},qi=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(Oi(t)&&null!=t.content&&"string"==typeof t.content&&this.messages.some(e=>"assistant"===e.role&&e.tool_calls?.some(e=>"function"===e.type&&e.id===t.tool_call_id)))return t.content}},Fi=function(){const e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},Wi=function(e){if(null!=e.n&&e.n>1)throw new Co("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},Ji=function(e){return"string"==typeof e?e:void 0===e?"undefined":JSON.stringify(e)};class zi extends Hi{static runTools(e,t,n){const o=new zi,r={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return o._run(()=>o._runTools(e,t,r)),o}_addMessage(e,t=!0){super._addMessage(e,t),wi(e)&&e.content&&this._emit("content",e.content)}}const Ki=1,Xi=2,Zi=4,Yi=8,Qi=16,ea=32,ta=64,na=128,oa=256,ra=511;class ia extends Error{}class aa extends Error{}const sa=(e,t)=>{const n=e.length;let o=0;const r=e=>{throw new ia(`${e} at position ${o}`)},i=e=>{throw new aa(`${e} at position ${o}`)},a=()=>(d(),o>=n&&r("Unexpected end of input"),'"'===e[o]?s():"{"===e[o]?c():"["===e[o]?u():"null"===e.substring(o,o+4)||Qi&t&&n-o<4&&"null".startsWith(e.substring(o))?(o+=4,null):"true"===e.substring(o,o+4)||ea&t&&n-o<4&&"true".startsWith(e.substring(o))?(o+=4,!0):"false"===e.substring(o,o+5)||ea&t&&n-o<5&&"false".startsWith(e.substring(o))?(o+=5,!1):"Infinity"===e.substring(o,o+8)||na&t&&n-o<8&&"Infinity".startsWith(e.substring(o))?(o+=8,1/0):"-Infinity"===e.substring(o,o+9)||oa&t&&1<n-o&&n-o<9&&"-Infinity".startsWith(e.substring(o))?(o+=9,-1/0):"NaN"===e.substring(o,o+3)||ta&t&&n-o<3&&"NaN".startsWith(e.substring(o))?(o+=3,NaN):l()),s=()=>{const a=o;let s=!1;for(o++;o<n&&('"'!==e[o]||s&&"\\"===e[o-1]);)s="\\"===e[o]&&!s,o++;if('"'==e.charAt(o))try{return JSON.parse(e.substring(a,++o-Number(s)))}catch(e){i(String(e))}else if(Ki&t)try{return JSON.parse(e.substring(a,o-Number(s))+'"')}catch(t){return JSON.parse(e.substring(a,e.lastIndexOf("\\"))+'"')}r("Unterminated string literal")},c=()=>{o++,d();const i={};try{for(;"}"!==e[o];){if(d(),o>=n&&Yi&t)return i;const r=s();d(),o++;try{const e=a();Object.defineProperty(i,r,{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){if(Yi&t)return i;throw e}d(),","===e[o]&&o++}}catch(e){if(Yi&t)return i;r("Expected '}' at end of object")}return o++,i},u=()=>{o++;const n=[];try{for(;"]"!==e[o];)n.push(a()),d(),","===e[o]&&o++}catch(e){if(Zi&t)return n;r("Expected ']' at end of array")}return o++,n},l=()=>{if(0===o){"-"===e&&Xi&t&&r("Not sure what '-' is");try{return JSON.parse(e)}catch(n){if(Xi&t)try{return"."===e[e.length-1]?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch(e){}i(String(n))}}const a=o;for("-"===e[o]&&o++;e[o]&&!",]}".includes(e[o]);)o++;o!=n||Xi&t||r("Unterminated number literal");try{return JSON.parse(e.substring(a,o))}catch(n){"-"===e.substring(a,o)&&Xi&t&&r("Not sure what '-' is");try{return JSON.parse(e.substring(a,e.lastIndexOf("e")))}catch(e){i(String(e))}}},d=()=>{for(;o<n&&" \n\r\t".includes(e[o]);)o++};return a()},ca=e=>function(e,t=ra){if("string"!=typeof e)throw new TypeError("expecting str, got "+typeof e);if(!e.trim())throw new Error(`${e} is empty`);return sa(e.trim(),t)}(e,ra^Xi);var ua,la,da,pa,ha,fa,ma,ga,ba,ya,va,_a;class wa extends Hi{constructor(e){super(),ua.add(this),la.set(this,void 0),da.set(this,void 0),pa.set(this,void 0),Oo(this,la,e,"f"),Oo(this,da,[],"f")}get currentChatCompletionSnapshot(){return So(this,pa,"f")}static fromReadableStream(e){const t=new wa(null);return t._run(()=>t._fromReadableStream(e)),t}static createChatCompletion(e,t,n){const o=new wa(t);return o._run(()=>o._runChatCompletion(e,{...t,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}async _createChatCompletion(e,t,n){super._createChatCompletion;const o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort())),So(this,ua,"m",ha).call(this);const r=await e.chat.completions.create({...t,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(const e of r)So(this,ua,"m",ma).call(this,e);if(r.controller.signal?.aborted)throw new jo;return this._addChatCompletion(So(this,ua,"m",ya).call(this))}async _fromReadableStream(e,t){const n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),So(this,ua,"m",ha).call(this),this._connected();const o=Ur.fromReadableStream(e,this.controller);let r;for await(const e of o)r&&r!==e.id&&this._addChatCompletion(So(this,ua,"m",ya).call(this)),So(this,ua,"m",ma).call(this,e),r=e.id;if(o.controller.signal?.aborted)throw new jo;return this._addChatCompletion(So(this,ua,"m",ya).call(this))}[(la=new WeakMap,da=new WeakMap,pa=new WeakMap,ua=new WeakSet,ha=function(){this.ended||Oo(this,pa,void 0,"f")},fa=function(e){let t=So(this,da,"f")[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},So(this,da,"f")[e.index]=t,t)},ma=function(e){if(this.ended)return;const t=So(this,ua,"m",_a).call(this,e);this._emit("chunk",e,t);for(const n of e.choices){const e=t.choices[n.index];null!=n.delta.content&&"assistant"===e.message?.role&&e.message?.content&&(this._emit("content",n.delta.content,e.message.content),this._emit("content.delta",{delta:n.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),null!=n.delta.refusal&&"assistant"===e.message?.role&&e.message?.refusal&&this._emit("refusal.delta",{delta:n.delta.refusal,snapshot:e.message.refusal}),null!=n.logprobs?.content&&"assistant"===e.message?.role&&this._emit("logprobs.content.delta",{content:n.logprobs?.content,snapshot:e.logprobs?.content??[]}),null!=n.logprobs?.refusal&&"assistant"===e.message?.role&&this._emit("logprobs.refusal.delta",{refusal:n.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});const o=So(this,ua,"m",fa).call(this,e);e.finish_reason&&(So(this,ua,"m",ba).call(this,e),null!=o.current_tool_call_index&&So(this,ua,"m",ga).call(this,e,o.current_tool_call_index));for(const t of n.delta.tool_calls??[])o.current_tool_call_index!==t.index&&(So(this,ua,"m",ba).call(this,e),null!=o.current_tool_call_index&&So(this,ua,"m",ga).call(this,e,o.current_tool_call_index)),o.current_tool_call_index=t.index;for(const t of n.delta.tool_calls??[]){const n=e.message.tool_calls?.[t.index];n?.type&&("function"===n?.type?this._emit("tool_calls.function.arguments.delta",{name:n.function?.name,index:t.index,arguments:n.function.arguments,parsed_arguments:n.function.parsed_arguments,arguments_delta:t.function?.arguments??""}):xa(n?.type))}}},ga=function(e,t){if(So(this,ua,"m",fa).call(this,e).done_tool_calls.has(t))return;const n=e.message.tool_calls?.[t];if(!n)throw new Error("no tool call snapshot");if(!n.type)throw new Error("tool call snapshot missing `type`");if("function"===n.type){const e=So(this,la,"f")?.tools?.find(e=>hi(e)&&e.function.name===n.function.name);this._emit("tool_calls.function.arguments.done",{name:n.function.name,index:t,arguments:n.function.arguments,parsed_arguments:mi(e)?e.$parseRaw(n.function.arguments):e?.function.strict?JSON.parse(n.function.arguments):null})}else n.type},ba=function(e){const t=So(this,ua,"m",fa).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;const n=So(this,ua,"m",va).call(this);this._emit("content.done",{content:e.message.content,parsed:n?n.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit("refusal.done",{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:e.logprobs.refusal}))},ya=function(){if(this.ended)throw new Co("stream has ended, this shouldn't happen");const e=So(this,pa,"f");if(!e)throw new Co("request ended without sending any chunks");return Oo(this,pa,void 0,"f"),Oo(this,da,[],"f"),function(e,t){const{id:n,choices:o,created:r,model:i,system_fingerprint:a,...s}=e,c={...s,id:n,choices:o.map(({message:t,finish_reason:n,index:o,logprobs:r,...i})=>{if(!n)throw new Co(`missing finish_reason for choice ${o}`);const{content:a=null,function_call:s,tool_calls:c,...u}=t,l=t.role;if(!l)throw new Co(`missing role for choice ${o}`);if(s){const{arguments:e,name:c}=s;if(null==e)throw new Co(`missing function_call.arguments for choice ${o}`);if(!c)throw new Co(`missing function_call.name for choice ${o}`);return{...i,message:{content:a,function_call:{arguments:e,name:c},role:l,refusal:t.refusal??null},finish_reason:n,index:o,logprobs:r}}return c?{...i,index:o,finish_reason:n,logprobs:r,message:{...u,role:l,content:a,refusal:t.refusal??null,tool_calls:c.map((t,n)=>{const{function:r,type:i,id:a,...s}=t,{arguments:c,name:u,...l}=r||{};if(null==a)throw new Co(`missing choices[${o}].tool_calls[${n}].id\n${Oa(e)}`);if(null==i)throw new Co(`missing choices[${o}].tool_calls[${n}].type\n${Oa(e)}`);if(null==u)throw new Co(`missing choices[${o}].tool_calls[${n}].function.name\n${Oa(e)}`);if(null==c)throw new Co(`missing choices[${o}].tool_calls[${n}].function.arguments\n${Oa(e)}`);return{...s,id:a,type:i,function:{...l,name:u,arguments:c}}})}}:{...i,message:{...u,content:a,role:l,refusal:t.refusal??null},finish_reason:n,index:o,logprobs:r}}),created:r,model:i,object:"chat.completion",...a?{system_fingerprint:a}:{}};return function(e,t){return t&&vi(t)?gi(e,t):{...e,choices:e.choices.map(e=>(_i(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}}(c,t)}(e,So(this,la,"f"))},va=function(){const e=So(this,la,"f")?.response_format;return fi(e)?e:null},_a=function(e){var t,n,o,r;let i=So(this,pa,"f");const{choices:a,...s}=e;i?Object.assign(i,s):i=Oo(this,pa,{...s,choices:[]},"f");for(const{delta:a,finish_reason:s,index:c,logprobs:u=null,...l}of e.choices){let e=i.choices[c];if(e||(e=i.choices[c]={finish_reason:s,index:c,message:{},logprobs:u,...l}),u)if(e.logprobs){const{content:o,refusal:r,...i}=u;Sa(i),Object.assign(e.logprobs,i),o&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...o)),r&&((n=e.logprobs).refusal??(n.refusal=[]),e.logprobs.refusal.push(...r))}else e.logprobs=Object.assign({},u);if(s&&(e.finish_reason=s,So(this,la,"f")&&vi(So(this,la,"f")))){if("length"===s)throw new qo;if("content_filter"===s)throw new Fo}if(Object.assign(e,l),!a)continue;const{content:d,refusal:p,function_call:h,role:f,tool_calls:m,...g}=a;if(Sa(g),Object.assign(e.message,g),p&&(e.message.refusal=(e.message.refusal||"")+p),f&&(e.message.role=f),h&&(e.message.function_call?(h.name&&(e.message.function_call.name=h.name),h.arguments&&((o=e.message.function_call).arguments??(o.arguments=""),e.message.function_call.arguments+=h.arguments)):e.message.function_call=h),d&&(e.message.content=(e.message.content||"")+d,!e.message.refusal&&So(this,ua,"m",va).call(this)&&(e.message.parsed=ca(e.message.content))),m){e.message.tool_calls||(e.message.tool_calls=[]);for(const{index:t,id:n,type:o,function:i,...a}of m){const s=(r=e.message.tool_calls)[t]??(r[t]={});Object.assign(s,a),n&&(s.id=n),o&&(s.type=o),i&&(s.function??(s.function={name:i.name??"",arguments:""})),i?.name&&(s.function.name=i.name),i?.arguments&&(s.function.arguments+=i.arguments,yi(So(this,la,"f"),s)&&(s.function.parsed_arguments=ca(s.function.arguments)))}}}return i},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("chunk",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Ur(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function Oa(e){return JSON.stringify(e)}function Sa(e){}function xa(e){}class Ta extends wa{static fromReadableStream(e){const t=new Ta(null);return t._run(()=>t._fromReadableStream(e)),t}static runTools(e,t,n){const o=new Ta(t),r={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return o._run(()=>o._runTools(e,t,r)),o}}class Pa extends si{constructor(){super(...arguments),this.messages=new pi(this._client)}create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1})}retrieve(e,t){return this._client.get(di`/chat/completions/${e}`,t)}update(e,t,n){return this._client.post(di`/chat/completions/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/chat/completions",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/chat/completions/${e}`,t)}parse(e,t){return function(e){for(const t of e??[]){if("function"!==t.type)throw new Co(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new Co(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(t=>gi(t,e))}runTools(e,t){return e.stream?Ta.runTools(this._client,e,t):zi.runTools(this._client,e,t)}stream(e,t){return wa.createChatCompletion(this._client,e,t)}}Pa.Messages=pi;class Ca extends si{constructor(){super(...arguments),this.completions=new Pa(this._client)}}Ca.Completions=Pa;const ka=Symbol("brand.privateNullableHeaders");function*ja(e){if(!e)return;if(ka in e){const{values:t,nulls:n}=e;yield*t.entries();for(const e of n)yield[e,null];return}let t,n=!1;e instanceof Headers?t=e.entries():Go(e)?t=e:(n=!0,t=Object.entries(e??{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const o=Go(e[1])?e[1]:[e[1]];let r=!1;for(const e of o)void 0!==e&&(n&&!r&&(r=!0,yield[t,null]),yield[t,e])}}const Ea=e=>{const t=new Headers,n=new Set;for(const o of e){const e=new Set;for(const[r,i]of ja(o)){const o=r.toLowerCase();e.has(o)||(t.delete(r),e.add(o)),null===i?(t.delete(r),n.add(o)):(t.append(r,i),n.delete(o))}}return{[ka]:!0,values:t,nulls:n}};class Ra extends si{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:Ea([{Accept:"application/octet-stream"},t?.headers]),__binaryResponse:!0})}}class Aa extends si{create(e,t){return this._client.post("/audio/transcriptions",Qr({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}}class Ia extends si{create(e,t){return this._client.post("/audio/translations",Qr({body:e,...t,__metadata:{model:e.model}},this._client))}}class Ma extends si{constructor(){super(...arguments),this.transcriptions=new Aa(this._client),this.translations=new Ia(this._client),this.speech=new Ra(this._client)}}Ma.Transcriptions=Aa,Ma.Translations=Ia,Ma.Speech=Ra;class Na extends si{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(di`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/batches",Vr,{query:e,...t})}cancel(e,t){return this._client.post(di`/batches/${e}/cancel`,t)}}class $a extends si{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(di`/assistants/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(di`/assistants/${e}`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},t){return this._client.getAPIList("/assistants",Vr,{query:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(di`/assistants/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class Da extends si{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class Ua extends si{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}}class La extends si{constructor(){super(...arguments),this.sessions=new Da(this._client),this.transcriptionSessions=new Ua(this._client)}}La.Sessions=Da,La.TranscriptionSessions=Ua;class qa extends si{create(e,t){return this._client.post("/chatkit/sessions",{body:e,...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}cancel(e,t){return this._client.post(di`/chatkit/sessions/${e}/cancel`,{...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}}class Fa extends si{retrieve(e,t){return this._client.get(di`/chatkit/threads/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}list(e={},t){return this._client.getAPIList("/chatkit/threads",Hr,{query:e,...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}delete(e,t){return this._client.delete(di`/chatkit/threads/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers])})}listItems(e,t={},n){return this._client.getAPIList(di`/chatkit/threads/${e}/items`,Hr,{query:t,...n,headers:Ea([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}}class Wa extends si{constructor(){super(...arguments),this.sessions=new qa(this._client),this.threads=new Fa(this._client)}}Wa.Sessions=qa,Wa.Threads=Fa;class Ja extends si{create(e,t,n){return this._client.post(di`/threads/${e}/messages`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){const{thread_id:o}=t;return this._client.get(di`/threads/${o}/messages/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){const{thread_id:o,...r}=t;return this._client.post(di`/threads/${o}/messages/${e}`,{body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(di`/threads/${e}/messages`,Vr,{query:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t,n){const{thread_id:o}=t;return this._client.delete(di`/threads/${o}/messages/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}class Ba extends si{retrieve(e,t,n){const{thread_id:o,run_id:r,...i}=t;return this._client.get(di`/threads/${o}/runs/${r}/steps/${e}`,{query:i,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t,n){const{thread_id:o,...r}=t;return this._client.getAPIList(di`/threads/${o}/runs/${e}/steps`,Vr,{query:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}const Ga=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;var Va,Ha,za,Ka,Xa,Za,Ya,Qa,es,ts,ns,os,rs,is,as,ss,cs,us,ls,ds,ps,hs,fs,ms,gs,bs,ys,vs,_s,ws,Os;class Ss extends Bi{constructor(){super(...arguments),Va.add(this),za.set(this,[]),Ka.set(this,{}),Xa.set(this,{}),Za.set(this,void 0),Ya.set(this,void 0),Qa.set(this,void 0),es.set(this,void 0),ts.set(this,void 0),ns.set(this,void 0),os.set(this,void 0),rs.set(this,void 0),is.set(this,void 0)}[(za=new WeakMap,Ka=new WeakMap,Xa=new WeakMap,Za=new WeakMap,Ya=new WeakMap,Qa=new WeakMap,es=new WeakMap,ts=new WeakMap,ns=new WeakMap,os=new WeakMap,rs=new WeakMap,is=new WeakMap,Va=new WeakSet,Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("event",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){const t=new Ha;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){const n=t?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),this._connected();const o=Ur.fromReadableStream(e,this.controller);for await(const e of o)So(this,Va,"m",as).call(this,e);if(o.controller.signal?.aborted)throw new jo;return this._addRun(So(this,Va,"m",ss).call(this))}toReadableStream(){return new Ur(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,n,o){const r=new Ha;return r._run(()=>r._runToolAssistantStream(e,t,n,{...o,headers:{...o?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createToolAssistantStream(e,t,n,o){const r=o?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));const i={...n,stream:!0},a=await e.submitToolOutputs(t,i,{...o,signal:this.controller.signal});this._connected();for await(const e of a)So(this,Va,"m",as).call(this,e);if(a.controller.signal?.aborted)throw new jo;return this._addRun(So(this,Va,"m",ss).call(this))}static createThreadAssistantStream(e,t,n){const o=new Ha;return o._run(()=>o._threadAssistantStream(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}static createAssistantStream(e,t,n,o){const r=new Ha;return r._run(()=>r._runAssistantStream(e,t,n,{...o,headers:{...o?.headers,"X-Stainless-Helper-Method":"stream"}})),r}currentEvent(){return So(this,os,"f")}currentRun(){return So(this,rs,"f")}currentMessageSnapshot(){return So(this,Za,"f")}currentRunStepSnapshot(){return So(this,is,"f")}async finalRunSteps(){return await this.done(),Object.values(So(this,Ka,"f"))}async finalMessages(){return await this.done(),Object.values(So(this,Xa,"f"))}async finalRun(){if(await this.done(),!So(this,Ya,"f"))throw Error("Final run was not received.");return So(this,Ya,"f")}async _createThreadAssistantStream(e,t,n){const o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));const r={...t,stream:!0},i=await e.createAndRun(r,{...n,signal:this.controller.signal});this._connected();for await(const e of i)So(this,Va,"m",as).call(this,e);if(i.controller.signal?.aborted)throw new jo;return this._addRun(So(this,Va,"m",ss).call(this))}async _createAssistantStream(e,t,n,o){const r=o?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));const i={...n,stream:!0},a=await e.create(t,i,{...o,signal:this.controller.signal});this._connected();for await(const e of a)So(this,Va,"m",as).call(this,e);if(a.controller.signal?.aborted)throw new jo;return this._addRun(So(this,Va,"m",ss).call(this))}static accumulateDelta(e,t){for(const[n,o]of Object.entries(t)){if(!e.hasOwnProperty(n)){e[n]=o;continue}let t=e[n];if(null!=t)if("index"!==n&&"type"!==n){if("string"==typeof t&&"string"==typeof o)t+=o;else if("number"==typeof t&&"number"==typeof o)t+=o;else{if(!Ho(t)||!Ho(o)){if(Array.isArray(t)&&Array.isArray(o)){if(t.every(e=>"string"==typeof e||"number"==typeof e)){t.push(...o);continue}for(const e of o){if(!Ho(e))throw new Error(`Expected array delta entry to be an object but got: ${e}`);const n=e.index;if(null==n)throw console.error(e),new Error("Expected array delta entry to have an `index` property");if("number"!=typeof n)throw new Error(`Expected array delta entry \`index\` property to be a number but got ${n}`);const o=t[n];null==o?t.push(e):t[n]=this.accumulateDelta(o,e)}continue}throw Error(`Unhandled record type: ${n}, deltaValue: ${o}, accValue: ${t}`)}t=this.accumulateDelta(t,o)}e[n]=t}else e[n]=o;else e[n]=o}return e}_addRun(e){return e}async _threadAssistantStream(e,t,n){return await this._createThreadAssistantStream(t,e,n)}async _runAssistantStream(e,t,n,o){return await this._createAssistantStream(t,e,n,o)}async _runToolAssistantStream(e,t,n,o){return await this._createToolAssistantStream(t,e,n,o)}}Ha=Ss,as=function(e){if(!this.ended)switch(Oo(this,os,e,"f"),So(this,Va,"m",ls).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":So(this,Va,"m",fs).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":So(this,Va,"m",us).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":So(this,Va,"m",cs).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},ss=function(){if(this.ended)throw new Co("stream has ended, this shouldn't happen");if(!So(this,Ya,"f"))throw Error("Final run has not been received");return So(this,Ya,"f")},cs=function(e){const[t,n]=So(this,Va,"m",ps).call(this,e,So(this,Za,"f"));Oo(this,Za,t,"f"),So(this,Xa,"f")[t.id]=t;for(const e of n){const n=t.content[e.index];"text"==n?.type&&this._emit("textCreated",n.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(const n of e.data.delta.content){if("text"==n.type&&n.text){let e=n.text,o=t.content[n.index];if(!o||"text"!=o.type)throw Error("The snapshot associated with this text delta is not text or missing");this._emit("textDelta",e,o.text)}if(n.index!=So(this,Qa,"f")){if(So(this,es,"f"))switch(So(this,es,"f").type){case"text":this._emit("textDone",So(this,es,"f").text,So(this,Za,"f"));break;case"image_file":this._emit("imageFileDone",So(this,es,"f").image_file,So(this,Za,"f"))}Oo(this,Qa,n.index,"f")}Oo(this,es,t.content[n.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==So(this,Qa,"f")){const t=e.data.content[So(this,Qa,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,So(this,Za,"f"));break;case"text":this._emit("textDone",t.text,So(this,Za,"f"))}}So(this,Za,"f")&&this._emit("messageDone",e.data),Oo(this,Za,void 0,"f")}},us=function(e){const t=So(this,Va,"m",ds).call(this,e);switch(Oo(this,is,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":const n=e.data.delta;if(n.step_details&&"tool_calls"==n.step_details.type&&n.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(const e of n.step_details.tool_calls)e.index==So(this,ts,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(So(this,ns,"f")&&this._emit("toolCallDone",So(this,ns,"f")),Oo(this,ts,e.index,"f"),Oo(this,ns,t.step_details.tool_calls[e.index],"f"),So(this,ns,"f")&&this._emit("toolCallCreated",So(this,ns,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":Oo(this,is,void 0,"f");"tool_calls"==e.data.step_details.type&&So(this,ns,"f")&&(this._emit("toolCallDone",So(this,ns,"f")),Oo(this,ns,void 0,"f")),this._emit("runStepDone",e.data,t)}},ls=function(e){So(this,za,"f").push(e),this._emit("event",e)},ds=function(e){switch(e.event){case"thread.run.step.created":return So(this,Ka,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=So(this,Ka,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let n=e.data;if(n.delta){const o=Ha.accumulateDelta(t,n.delta);So(this,Ka,"f")[e.data.id]=o}return So(this,Ka,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":So(this,Ka,"f")[e.data.id]=e.data}if(So(this,Ka,"f")[e.data.id])return So(this,Ka,"f")[e.data.id];throw new Error("No snapshot available")},ps=function(e,t){let n=[];switch(e.event){case"thread.message.created":return[e.data,n];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let o=e.data;if(o.delta.content)for(const e of o.delta.content)if(e.index in t.content){let n=t.content[e.index];t.content[e.index]=So(this,Va,"m",hs).call(this,e,n)}else t.content[e.index]=e,n.push(e);return[t,n];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,n];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},hs=function(e,t){return Ha.accumulateDelta(t,e)},fs=function(e){switch(Oo(this,rs,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.cancelling":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":Oo(this,Ya,e.data,"f"),So(this,ns,"f")&&(this._emit("toolCallDone",So(this,ns,"f")),Oo(this,ns,void 0,"f"))}};class xs extends si{constructor(){super(...arguments),this.steps=new Ba(this._client)}create(e,t,n){const{include:o,...r}=t;return this._client.post(di`/threads/${e}/runs`,{query:{include:o},body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}retrieve(e,t,n){const{thread_id:o}=t;return this._client.get(di`/threads/${o}/runs/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){const{thread_id:o,...r}=t;return this._client.post(di`/threads/${o}/runs/${e}`,{body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(di`/threads/${e}/runs`,Vr,{query:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,t,n){const{thread_id:o}=t;return this._client.post(di`/threads/${o}/runs/${e}/cancel`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){const o=await this.create(e,t,n);return await this.poll(o.id,{thread_id:e},n)}createAndStream(e,t,n){return Ss.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){const o=Ea([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:r,response:i}=await this.retrieve(e,t,{...n,headers:{...n?.headers,...o}}).withResponse();switch(r.status){case"queued":case"in_progress":case"cancelling":let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{const t=i.headers.get("openai-poll-after-ms");if(t){const n=parseInt(t);isNaN(n)||(e=n)}}await zo(e);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return r}}}stream(e,t,n){return Ss.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n){const{thread_id:o,...r}=t;return this._client.post(di`/threads/${o}/runs/${e}/submit_tool_outputs`,{body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(e,t,n){const o=await this.submitToolOutputs(e,t,n);return await this.poll(o.id,t,n)}submitToolOutputsStream(e,t,n){return Ss.createToolAssistantStream(e,this._client.beta.threads.runs,t,n)}}xs.Steps=Ba;class Ts extends si{constructor(){super(...arguments),this.runs=new xs(this._client),this.messages=new Ja(this._client)}create(e={},t){return this._client.post("/threads",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(di`/threads/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(di`/threads/${e}`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t){return this._client.delete(di`/threads/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers]),stream:e.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(e,t){const n=await this.createAndRun(e,t);return await this.runs.poll(n.id,{thread_id:n.thread_id},t)}createAndRunStream(e,t){return Ss.createThreadAssistantStream(e,this._client.beta.threads,t)}}Ts.Runs=xs,Ts.Messages=Ja;class Ps extends si{constructor(){super(...arguments),this.realtime=new La(this._client),this.chatkit=new Wa(this._client),this.assistants=new $a(this._client),this.threads=new Ts(this._client)}}Ps.Realtime=La,Ps.ChatKit=Wa,Ps.Assistants=$a,Ps.Threads=Ts;class Cs extends si{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}class ks extends si{retrieve(e,t,n){const{container_id:o}=t;return this._client.get(di`/containers/${o}/files/${e}/content`,{...n,headers:Ea([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}}class js extends si{constructor(){super(...arguments),this.content=new ks(this._client)}create(e,t,n){return this._client.post(di`/containers/${e}/files`,Yr({body:t,...n},this._client))}retrieve(e,t,n){const{container_id:o}=t;return this._client.get(di`/containers/${o}/files/${e}`,n)}list(e,t={},n){return this._client.getAPIList(di`/containers/${e}/files`,Vr,{query:t,...n})}delete(e,t,n){const{container_id:o}=t;return this._client.delete(di`/containers/${o}/files/${e}`,{...n,headers:Ea([{Accept:"*/*"},n?.headers])})}}js.Content=ks;class Es extends si{constructor(){super(...arguments),this.files=new js(this._client)}create(e,t){return this._client.post("/containers",{body:e,...t})}retrieve(e,t){return this._client.get(di`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList("/containers",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/containers/${e}`,{...t,headers:Ea([{Accept:"*/*"},t?.headers])})}}Es.Files=js;class Rs extends si{create(e,t,n){const{include:o,...r}=t;return this._client.post(di`/conversations/${e}/items`,{query:{include:o},body:r,...n})}retrieve(e,t,n){const{conversation_id:o,...r}=t;return this._client.get(di`/conversations/${o}/items/${e}`,{query:r,...n})}list(e,t={},n){return this._client.getAPIList(di`/conversations/${e}/items`,Hr,{query:t,...n})}delete(e,t,n){const{conversation_id:o}=t;return this._client.delete(di`/conversations/${o}/items/${e}`,n)}}class As extends si{constructor(){super(...arguments),this.items=new Rs(this._client)}create(e={},t){return this._client.post("/conversations",{body:e,...t})}retrieve(e,t){return this._client.get(di`/conversations/${e}`,t)}update(e,t,n){return this._client.post(di`/conversations/${e}`,{body:t,...n})}delete(e,t){return this._client.delete(di`/conversations/${e}`,t)}}As.Items=Rs;class Is extends si{create(e,t){const n=!!e.encoding_format;let o=n?e.encoding_format:"base64";n&&Ir(this._client).debug("embeddings/user defined encoding_format:",e.encoding_format);const r=this._client.post("/embeddings",{body:{...e,encoding_format:o},...t});return n?r:(Ir(this._client).debug("embeddings/decoding base64 embeddings from base64"),r._thenUnwrap(e=>(e&&e.data&&e.data.forEach(e=>{const t=e.embedding;e.embedding=(e=>{if("undefined"!=typeof Buffer){const t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}{const t=atob(e),n=t.length,o=new Uint8Array(n);for(let e=0;e<n;e++)o[e]=t.charCodeAt(e);return Array.from(new Float32Array(o.buffer))}})(t)}),e)))}}class Ms extends si{retrieve(e,t,n){const{eval_id:o,run_id:r}=t;return this._client.get(di`/evals/${o}/runs/${r}/output_items/${e}`,n)}list(e,t,n){const{eval_id:o,...r}=t;return this._client.getAPIList(di`/evals/${o}/runs/${e}/output_items`,Vr,{query:r,...n})}}class Ns extends si{constructor(){super(...arguments),this.outputItems=new Ms(this._client)}create(e,t,n){return this._client.post(di`/evals/${e}/runs`,{body:t,...n})}retrieve(e,t,n){const{eval_id:o}=t;return this._client.get(di`/evals/${o}/runs/${e}`,n)}list(e,t={},n){return this._client.getAPIList(di`/evals/${e}/runs`,Vr,{query:t,...n})}delete(e,t,n){const{eval_id:o}=t;return this._client.delete(di`/evals/${o}/runs/${e}`,n)}cancel(e,t,n){const{eval_id:o}=t;return this._client.post(di`/evals/${o}/runs/${e}`,n)}}Ns.OutputItems=Ms;class $s extends si{constructor(){super(...arguments),this.runs=new Ns(this._client)}create(e,t){return this._client.post("/evals",{body:e,...t})}retrieve(e,t){return this._client.get(di`/evals/${e}`,t)}update(e,t,n){return this._client.post(di`/evals/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/evals",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/evals/${e}`,t)}}$s.Runs=Ns;class Ds extends si{create(e,t){return this._client.post("/files",Qr({body:e,...t},this._client))}retrieve(e,t){return this._client.get(di`/files/${e}`,t)}list(e={},t){return this._client.getAPIList("/files",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/files/${e}`,t)}content(e,t){return this._client.get(di`/files/${e}/content`,{...t,headers:Ea([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:n=18e5}={}){const o=new Set(["processed","error","deleted"]),r=Date.now();let i=await this.retrieve(e);for(;!i.status||!o.has(i.status);)if(await zo(t),i=await this.retrieve(e),Date.now()-r>n)throw new Ro({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return i}}class Us extends si{}class Ls extends si{run(e,t){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...t})}validate(e,t){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...t})}}class qs extends si{constructor(){super(...arguments),this.graders=new Ls(this._client)}}qs.Graders=Ls;class Fs extends si{create(e,t,n){return this._client.getAPIList(di`/fine_tuning/checkpoints/${e}/permissions`,Gr,{body:t,method:"post",...n})}retrieve(e,t={},n){return this._client.get(di`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...n})}list(e,t={},n){return this._client.getAPIList(di`/fine_tuning/checkpoints/${e}/permissions`,Hr,{query:t,...n})}delete(e,t,n){const{fine_tuned_model_checkpoint:o}=t;return this._client.delete(di`/fine_tuning/checkpoints/${o}/permissions/${e}`,n)}}class Ws extends si{constructor(){super(...arguments),this.permissions=new Fs(this._client)}}Ws.Permissions=Fs;class Js extends si{list(e,t={},n){return this._client.getAPIList(di`/fine_tuning/jobs/${e}/checkpoints`,Vr,{query:t,...n})}}class Bs extends si{constructor(){super(...arguments),this.checkpoints=new Js(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(di`/fine_tuning/jobs/${e}`,t)}list(e={},t){return this._client.getAPIList("/fine_tuning/jobs",Vr,{query:e,...t})}cancel(e,t){return this._client.post(di`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},n){return this._client.getAPIList(di`/fine_tuning/jobs/${e}/events`,Vr,{query:t,...n})}pause(e,t){return this._client.post(di`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(di`/fine_tuning/jobs/${e}/resume`,t)}}Bs.Checkpoints=Js;class Gs extends si{constructor(){super(...arguments),this.methods=new Us(this._client),this.jobs=new Bs(this._client),this.checkpoints=new Ws(this._client),this.alpha=new qs(this._client)}}Gs.Methods=Us,Gs.Jobs=Bs,Gs.Checkpoints=Ws,Gs.Alpha=qs;class Vs extends si{}class Hs extends si{constructor(){super(...arguments),this.graderModels=new Vs(this._client)}}Hs.GraderModels=Vs;class zs extends si{createVariation(e,t){return this._client.post("/images/variations",Qr({body:e,...t},this._client))}edit(e,t){return this._client.post("/images/edits",Qr({body:e,...t,stream:e.stream??!1},this._client))}generate(e,t){return this._client.post("/images/generations",{body:e,...t,stream:e.stream??!1})}}class Ks extends si{retrieve(e,t){return this._client.get(di`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",Gr,e)}delete(e,t){return this._client.delete(di`/models/${e}`,t)}}class Xs extends si{create(e,t){return this._client.post("/moderations",{body:e,...t})}}class Zs extends si{accept(e,t,n){return this._client.post(di`/realtime/calls/${e}/accept`,{body:t,...n,headers:Ea([{Accept:"*/*"},n?.headers])})}hangup(e,t){return this._client.post(di`/realtime/calls/${e}/hangup`,{...t,headers:Ea([{Accept:"*/*"},t?.headers])})}refer(e,t,n){return this._client.post(di`/realtime/calls/${e}/refer`,{body:t,...n,headers:Ea([{Accept:"*/*"},n?.headers])})}reject(e,t={},n){return this._client.post(di`/realtime/calls/${e}/reject`,{body:t,...n,headers:Ea([{Accept:"*/*"},n?.headers])})}}class Ys extends si{create(e,t){return this._client.post("/realtime/client_secrets",{body:e,...t})}}class Qs extends si{constructor(){super(...arguments),this.clientSecrets=new Ys(this._client),this.calls=new Zs(this._client)}}function ec(e,t){return t&&function(e){if(fi(e.text?.format))return!0;return!1}(t)?tc(e,t):{...e,output_parsed:null,output:e.output.map(e=>"function_call"===e.type?{...e,parsed_arguments:null}:"message"===e.type?{...e,content:e.content.map(e=>({...e,parsed:null}))}:e)}}function tc(e,t){const n=e.output.map(e=>{if("function_call"===e.type)return{...e,parsed_arguments:ic(t,e)};if("message"===e.type){const n=e.content.map(e=>"output_text"===e.type?{...e,parsed:nc(t,e.text)}:e);return{...e,content:n}}return e}),o=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,"output_text")||ac(o),Object.defineProperty(o,"output_parsed",{enumerable:!0,get(){for(const e of o.output)if("message"===e.type)for(const t of e.content)if("output_text"===t.type&&null!==t.parsed)return t.parsed;return null}}),o}function nc(e,t){if("json_schema"!==e.text?.format?.type)return null;if("$parseRaw"in e.text?.format){const n=e.text?.format;return n.$parseRaw(t)}return JSON.parse(t)}function oc(e){return"auto-parseable-tool"===e?.$brand}function rc(e,t){return e.find(e=>"function"===e.type&&e.name===t)}function ic(e,t){const n=rc(e.tools??[],t.name);return{...t,...t,parsed_arguments:oc(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}function ac(e){const t=[];for(const n of e.output)if("message"===n.type)for(const e of n.content)"output_text"===e.type&&t.push(e.text);e.output_text=t.join("")}Qs.ClientSecrets=Ys,Qs.Calls=Zs;class sc extends Bi{constructor(e){super(),ms.add(this),gs.set(this,void 0),bs.set(this,void 0),ys.set(this,void 0),Oo(this,gs,e,"f")}static createResponse(e,t,n){const o=new sc(t);return o._run(()=>o._createOrRetrieveResponse(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}async _createOrRetrieveResponse(e,t,n){const o=n?.signal;let r;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort())),So(this,ms,"m",vs).call(this);let i=null;"response_id"in t?(r=await e.responses.retrieve(t.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),i=t.starting_after??null):r=await e.responses.create({...t,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(const e of r)So(this,ms,"m",_s).call(this,e,i);if(r.controller.signal?.aborted)throw new jo;return So(this,ms,"m",ws).call(this)}[(gs=new WeakMap,bs=new WeakMap,ys=new WeakMap,ms=new WeakSet,vs=function(){this.ended||Oo(this,bs,void 0,"f")},_s=function(e,t){if(this.ended)return;const n=(e,n)=>{(null==t||n.sequence_number>t)&&this._emit(e,n)},o=So(this,ms,"m",Os).call(this,e);switch(n("event",e),e.type){case"response.output_text.delta":{const t=o.output[e.output_index];if(!t)throw new Co(`missing output at index ${e.output_index}`);if("message"===t.type){const o=t.content[e.content_index];if(!o)throw new Co(`missing content at index ${e.content_index}`);if("output_text"!==o.type)throw new Co(`expected content to be 'output_text', got ${o.type}`);n("response.output_text.delta",{...e,snapshot:o.text})}break}case"response.function_call_arguments.delta":{const t=o.output[e.output_index];if(!t)throw new Co(`missing output at index ${e.output_index}`);"function_call"===t.type&&n("response.function_call_arguments.delta",{...e,snapshot:t.arguments});break}default:n(e.type,e)}},ws=function(){if(this.ended)throw new Co("stream has ended, this shouldn't happen");const e=So(this,bs,"f");if(!e)throw new Co("request ended without sending any events");Oo(this,bs,void 0,"f");const t=function(e,t){return ec(e,t)}(e,So(this,gs,"f"));return Oo(this,ys,t,"f"),t},Os=function(e){let t=So(this,bs,"f");if(!t){if("response.created"!==e.type)throw new Co(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return t=Oo(this,bs,e.response,"f"),t}switch(e.type){case"response.output_item.added":t.output.push(e.item);break;case"response.content_part.added":{const n=t.output[e.output_index];if(!n)throw new Co(`missing output at index ${e.output_index}`);const o=n.type,r=e.part;"message"===o&&"reasoning_text"!==r.type?n.content.push(r):"reasoning"===o&&"reasoning_text"===r.type&&(n.content||(n.content=[]),n.content.push(r));break}case"response.output_text.delta":{const n=t.output[e.output_index];if(!n)throw new Co(`missing output at index ${e.output_index}`);if("message"===n.type){const t=n.content[e.content_index];if(!t)throw new Co(`missing content at index ${e.content_index}`);if("output_text"!==t.type)throw new Co(`expected content to be 'output_text', got ${t.type}`);t.text+=e.delta}break}case"response.function_call_arguments.delta":{const n=t.output[e.output_index];if(!n)throw new Co(`missing output at index ${e.output_index}`);"function_call"===n.type&&(n.arguments+=e.delta);break}case"response.reasoning_text.delta":{const n=t.output[e.output_index];if(!n)throw new Co(`missing output at index ${e.output_index}`);if("reasoning"===n.type){const t=n.content?.[e.content_index];if(!t)throw new Co(`missing content at index ${e.content_index}`);if("reasoning_text"!==t.type)throw new Co(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case"response.completed":Oo(this,bs,e.response,"f")}return t},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("event",n=>{const o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{n=!0;for(const e of t)e.resolve(void 0);t.length=0}),this.on("abort",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),this.on("error",e=>{n=!0;for(const n of t)n.reject(e);t.length=0}),{next:async()=>{if(!e.length)return n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0});return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();const e=So(this,ys,"f");if(!e)throw new Co("stream ended without producing a ChatCompletion");return e}}class cc extends si{list(e,t={},n){return this._client.getAPIList(di`/responses/${e}/input_items`,Vr,{query:t,...n})}}class uc extends si{count(e={},t){return this._client.post("/responses/input_tokens",{body:e,...t})}}class lc extends si{constructor(){super(...arguments),this.inputItems=new cc(this._client),this.inputTokens=new uc(this._client)}create(e,t){return this._client.post("/responses",{body:e,...t,stream:e.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&ac(e),e))}retrieve(e,t={},n){return this._client.get(di`/responses/${e}`,{query:t,...n,stream:t?.stream??!1})._thenUnwrap(e=>("object"in e&&"response"===e.object&&ac(e),e))}delete(e,t){return this._client.delete(di`/responses/${e}`,{...t,headers:Ea([{Accept:"*/*"},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>tc(t,e))}stream(e,t){return sc.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(di`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post("/responses/compact",{body:e,...t})}}lc.InputItems=cc,lc.InputTokens=uc;class dc extends si{retrieve(e,t){return this._client.get(di`/skills/${e}/content`,{...t,headers:Ea([{Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}}class pc extends si{retrieve(e,t,n){const{skill_id:o}=t;return this._client.get(di`/skills/${o}/versions/${e}/content`,{...n,headers:Ea([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}}class hc extends si{constructor(){super(...arguments),this.content=new pc(this._client)}create(e,t={},n){return this._client.post(di`/skills/${e}/versions`,Yr({body:t,...n},this._client))}retrieve(e,t,n){const{skill_id:o}=t;return this._client.get(di`/skills/${o}/versions/${e}`,n)}list(e,t={},n){return this._client.getAPIList(di`/skills/${e}/versions`,Vr,{query:t,...n})}delete(e,t,n){const{skill_id:o}=t;return this._client.delete(di`/skills/${o}/versions/${e}`,n)}}hc.Content=pc;class fc extends si{constructor(){super(...arguments),this.content=new dc(this._client),this.versions=new hc(this._client)}create(e={},t){return this._client.post("/skills",Yr({body:e,...t},this._client))}retrieve(e,t){return this._client.get(di`/skills/${e}`,t)}update(e,t,n){return this._client.post(di`/skills/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList("/skills",Vr,{query:e,...t})}delete(e,t){return this._client.delete(di`/skills/${e}`,t)}}fc.Content=dc,fc.Versions=hc;class mc extends si{create(e,t,n){return this._client.post(di`/uploads/${e}/parts`,Qr({body:t,...n},this._client))}}class gc extends si{constructor(){super(...arguments),this.parts=new mc(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(di`/uploads/${e}/cancel`,t)}complete(e,t,n){return this._client.post(di`/uploads/${e}/complete`,{body:t,...n})}}gc.Parts=mc;class bc extends si{create(e,t,n){return this._client.post(di`/vector_stores/${e}/file_batches`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){const{vector_store_id:o}=t;return this._client.get(di`/vector_stores/${o}/file_batches/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(e,t,n){const{vector_store_id:o}=t;return this._client.post(di`/vector_stores/${o}/file_batches/${e}/cancel`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){const o=await this.create(e,t);return await this.poll(e,o.id,n)}listFiles(e,t,n){const{vector_store_id:o,...r}=t;return this._client.getAPIList(di`/vector_stores/${o}/file_batches/${e}/files`,Vr,{query:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async poll(e,t,n){const o=Ea([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:r,response:i}=await this.retrieve(t,{vector_store_id:e},{...n,headers:o}).withResponse();switch(r.status){case"in_progress":let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{const t=i.headers.get("openai-poll-after-ms");if(t){const n=parseInt(t);isNaN(n)||(e=n)}}await zo(e);break;case"failed":case"cancelled":case"completed":return r}}}async uploadAndPoll(e,{files:t,fileIds:n=[]},o){if(null==t||0==t.length)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");const r=o?.maxConcurrency??5,i=Math.min(r,t.length),a=this._client,s=t.values(),c=[...n];const u=Array(i).fill(s).map(async function(e){for(let t of e){const e=await a.files.create({file:t,purpose:"assistants"},o);c.push(e.id)}});return await(async e=>{const t=await Promise.allSettled(e),n=t.filter(e=>"rejected"===e.status);if(n.length){for(const e of n)console.error(e.reason);throw new Error(`${n.length} promise(s) failed - see the above errors`)}const o=[];for(const e of t)"fulfilled"===e.status&&o.push(e.value);return o})(u),await this.createAndPoll(e,{file_ids:c})}}class yc extends si{create(e,t,n){return this._client.post(di`/vector_stores/${e}/files`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(e,t,n){const{vector_store_id:o}=t;return this._client.get(di`/vector_stores/${o}/files/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(e,t,n){const{vector_store_id:o,...r}=t;return this._client.post(di`/vector_stores/${o}/files/${e}`,{body:r,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e,t={},n){return this._client.getAPIList(di`/vector_stores/${e}/files`,Vr,{query:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(e,t,n){const{vector_store_id:o}=t;return this._client.delete(di`/vector_stores/${o}/files/${e}`,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(e,t,n){const o=await this.create(e,t,n);return await this.poll(e,o.id,n)}async poll(e,t,n){const o=Ea([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){const r=await this.retrieve(t,{vector_store_id:e},{...n,headers:o}).withResponse(),i=r.data;switch(i.status){case"in_progress":let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{const t=r.response.headers.get("openai-poll-after-ms");if(t){const n=parseInt(t);isNaN(n)||(e=n)}}await zo(e);break;case"failed":case"completed":return i}}}async upload(e,t,n){const o=await this._client.files.create({file:t,purpose:"assistants"},n);return this.create(e,{file_id:o.id},n)}async uploadAndPoll(e,t,n){const o=await this.upload(e,t,n);return await this.poll(e,o.id,n)}content(e,t,n){const{vector_store_id:o}=t;return this._client.getAPIList(di`/vector_stores/${o}/files/${e}/content`,Gr,{...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}class vc extends si{constructor(){super(...arguments),this.files=new yc(this._client),this.fileBatches=new bc(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}retrieve(e,t){return this._client.get(di`/vector_stores/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}update(e,t,n){return this._client.post(di`/vector_stores/${e}`,{body:t,...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(e={},t){return this._client.getAPIList("/vector_stores",Vr,{query:e,...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}delete(e,t){return this._client.delete(di`/vector_stores/${e}`,{...t,headers:Ea([{"OpenAI-Beta":"assistants=v2"},t?.headers])})}search(e,t,n){return this._client.getAPIList(di`/vector_stores/${e}/search`,Gr,{body:t,method:"post",...n,headers:Ea([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}}vc.Files=yc,vc.FileBatches=bc;class _c extends si{create(e,t){return this._client.post("/videos",Yr({body:e,...t},this._client))}retrieve(e,t){return this._client.get(di`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList("/videos",Hr,{query:e,...t})}delete(e,t){return this._client.delete(di`/videos/${e}`,t)}downloadContent(e,t={},n){return this._client.get(di`/videos/${e}/content`,{query:t,...n,headers:Ea([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}remix(e,t,n){return this._client.post(di`/videos/${e}/remix`,Yr({body:t,...n},this._client))}}var wc,Oc,Sc,xc,Tc,Pc,Cc;class kc extends si{constructor(){super(...arguments),wc.add(this)}async unwrap(e,t,n=this._client.webhookSecret,o=300){return await this.verifySignature(e,t,n,o),JSON.parse(e)}async verifySignature(e,t,n=this._client.webhookSecret,o=300){if("undefined"==typeof crypto||"function"!=typeof crypto.subtle.importKey||"function"!=typeof crypto.subtle.verify)throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");So(this,wc,"m",Oc).call(this,n);const r=Ea([t]).values,i=So(this,wc,"m",Sc).call(this,r,"webhook-signature"),a=So(this,wc,"m",Sc).call(this,r,"webhook-timestamp"),s=So(this,wc,"m",Sc).call(this,r,"webhook-id"),c=parseInt(a,10);if(isNaN(c))throw new Wo("Invalid webhook timestamp format");const u=Math.floor(Date.now()/1e3);if(u-c>o)throw new Wo("Webhook timestamp is too old");if(c>u+o)throw new Wo("Webhook timestamp is too new");const l=i.split(" ").map(e=>e.startsWith("v1,")?e.substring(3):e),d=n.startsWith("whsec_")?Buffer.from(n.replace("whsec_",""),"base64"):Buffer.from(n,"utf-8"),p=s?`${s}.${a}.${e}`:`${a}.${e}`,h=await crypto.subtle.importKey("raw",d,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(const e of l)try{const t=Buffer.from(e,"base64");if(await crypto.subtle.verify("HMAC",h,t,(new TextEncoder).encode(p)))return}catch{continue}throw new Wo("The given webhook signature does not match the expected signature")}}wc=new WeakSet,Oc=function(e){if("string"!=typeof e||0===e.length)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},Sc=function(e,t){if(!e)throw new Error("Headers are required");const n=e.get(t);if(null==n)throw new Error(`Missing required header: ${t}`);return n};class jc{constructor({baseURL:e=Ga("OPENAI_BASE_URL"),apiKey:t=Ga("OPENAI_API_KEY"),organization:n=Ga("OPENAI_ORG_ID")??null,project:o=Ga("OPENAI_PROJECT_ID")??null,webhookSecret:r=Ga("OPENAI_WEBHOOK_SECRET")??null,...i}={}){if(xc.add(this),Pc.set(this,void 0),this.completions=new Cs(this),this.chat=new Ca(this),this.embeddings=new Is(this),this.files=new Ds(this),this.images=new zs(this),this.audio=new Ma(this),this.moderations=new Xs(this),this.models=new Ks(this),this.fineTuning=new Gs(this),this.graders=new Hs(this),this.vectorStores=new vc(this),this.webhooks=new kc(this),this.beta=new Ps(this),this.batches=new Na(this),this.uploads=new gc(this),this.responses=new lc(this),this.realtime=new Qs(this),this.conversations=new As(this),this.evals=new $s(this),this.containers=new Es(this),this.skills=new fc(this),this.videos=new _c(this),void 0===t)throw new Co("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");const a={apiKey:t,organization:n,project:o,webhookSecret:r,...i,baseURL:e||"https://api.openai.com/v1"};if(!a.dangerouslyAllowBrowser&&"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator)throw new Co("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");this.baseURL=a.baseURL,this.timeout=a.timeout??Tc.DEFAULT_TIMEOUT,this.logger=a.logger??console;const s="warn";this.logLevel=s,this.logLevel=kr(a.logLevel,"ClientOptions.logLevel",this)??kr(Ga("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??s,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??function(){if("undefined"!=typeof fetch)return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),Oo(this,Pc,or,"f"),this._options=a,this.apiKey="string"==typeof t?t:"Missing Key",this.organization=n,this.project=o,this.webhookSecret=r}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){}async authHeaders(e){return Ea([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return function(e){return br(e,{arrayFormat:"brackets"})}(e)}getUserAgent(){return`${this.constructor.name}/JS ${Ko}`}defaultIdempotencyKey(){return`stainless-node-retry-${xo()}`}makeStatusError(e,t,n,o){return ko.generate(e,t,n,o)}async _callApiKey(){const e=this._options.apiKey;if("function"!=typeof e)return!1;let t;try{t=await e()}catch(e){if(e instanceof Co)throw e;throw new Co(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if("string"!=typeof t||!t)throw new Co(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,n){const o=!So(this,xc,"m",Cc).call(this)&&n||this.baseURL,r=(e=>Jo.test(e))(e)?new URL(e):new URL(o+(o.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),i=this.defaultQuery();return function(e){if(!e)return!0;for(const t in e)return!1;return!0}(i)||(t={...i,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(r.search=this.stringifyQuery(t)),r.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new Wr(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){const o=await e,r=o.maxRetries??this.maxRetries;null==t&&(t=r),await this.prepareOptions(o);const{req:i,url:a,timeout:s}=await this.buildRequest(o,{retryCount:r-t});await this.prepareRequest(i,{url:a,options:o});const c="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=void 0===n?"":`, retryOf: ${n}`,l=Date.now();if(Ir(this).debug(`[${c}] sending request`,Mr({retryOfRequestLogID:n,method:o.method,url:a,options:o,headers:i.headers})),o.signal?.aborted)throw new jo;const d=new AbortController,p=await this.fetchWithTimeout(a,i,s,d).catch(Po),h=Date.now();if(p instanceof globalThis.Error){const e=`retrying, ${t} attempts remaining`;if(o.signal?.aborted)throw new jo;const r=To(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(t)return Ir(this).info(`[${c}] connection ${r?"timed out":"failed"} - ${e}`),Ir(this).debug(`[${c}] connection ${r?"timed out":"failed"} (${e})`,Mr({retryOfRequestLogID:n,url:a,durationMs:h-l,message:p.message})),this.retryRequest(o,t,n??c);if(Ir(this).info(`[${c}] connection ${r?"timed out":"failed"} - error; no more retries left`),Ir(this).debug(`[${c}] connection ${r?"timed out":"failed"} (error; no more retries left)`,Mr({retryOfRequestLogID:n,url:a,durationMs:h-l,message:p.message})),r)throw new Ro;throw new Eo({cause:p})}const f=`[${c}${u}${[...p.headers.entries()].filter(([e])=>"x-request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join("")}] ${i.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-l}ms`;if(!p.ok){const e=await this.shouldRetry(p);if(t&&e){const e=`retrying, ${t} attempts remaining`;return await async function(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await(e[Symbol.asyncIterator]().return?.());const t=e.getReader(),n=t.cancel();t.releaseLock(),await n}(p.body),Ir(this).info(`${f} - ${e}`),Ir(this).debug(`[${c}] response error (${e})`,Mr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-l})),this.retryRequest(o,t,n??c,p.headers)}const r=e?"error; no more retries left":"error; not retryable";Ir(this).info(`${f} - ${r}`);const i=await p.text().catch(e=>Po(e).message),a=(e=>{try{return JSON.parse(e)}catch(e){return}})(i),s=a?void 0:i;Ir(this).debug(`[${c}] response error (${r})`,Mr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:s,durationMs:Date.now()-l}));throw this.makeStatusError(p.status,a,s,p.headers)}return Ir(this).info(f),Ir(this).debug(`[${c}] response start`,Mr({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-l})),{response:p,options:o,controller:d,requestLogID:c,retryOfRequestLogID:n,startTime:l}}getAPIList(e,t,n){return this.requestAPIList(t,n&&"then"in n?n.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...n})}requestAPIList(e,t){const n=this.makeRequest(t,null,void 0);return new Br(this,n,e)}async fetchWithTimeout(e,t,n,o){const{signal:r,method:i,...a}=t||{},s=this._makeAbort(o);r&&r.addEventListener("abort",s,{once:!0});const c=setTimeout(s,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||"object"==typeof a.body&&null!==a.body&&Symbol.asyncIterator in a.body,l={signal:o.signal,...u?{duplex:"half"}:{},method:"GET",...a};i&&(l.method=i.toUpperCase());try{return await this.fetch.call(void 0,e,l)}finally{clearTimeout(c)}}async shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||(409===e.status||(429===e.status||e.status>=500)))}async retryRequest(e,t,n,o){let r;const i=o?.get("retry-after-ms");if(i){const e=parseFloat(i);Number.isNaN(e)||(r=e)}const a=o?.get("retry-after");if(a&&!r){const e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():1e3*e}if(void 0===r){const n=e.maxRetries??this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,n)}return await zo(r),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){const n=t-e;return Math.min(.5*Math.pow(2,n),8)*(1-.25*Math.random())*1e3}async buildRequest(e,{retryCount:t=0}={}){const n={...e},{method:o,path:r,query:i,defaultBaseURL:a}=n,s=this.buildURL(r,i,a);"timeout"in n&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new Co(`${e} must be an integer`);if(t<0)throw new Co(`${e} must be a positive integer`)})("timeout",n.timeout),n.timeout=n.timeout??this.timeout;const{bodyHeaders:c,body:u}=this.buildBody({options:n});return{req:{method:o,headers:await this.buildHeaders({options:e,method:o,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:o}){let r={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);const i=Ea([r,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(o),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Qo??(Qo=Xo()),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(i),i.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};const n=Ea([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:tr(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===n.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:So(this,Pc,"f").call(this,{body:e,headers:n})}}Tc=jc,Pc=new WeakMap,xc=new WeakSet,Cc=function(){return"https://api.openai.com/v1"!==this.baseURL},jc.OpenAI=Tc,jc.DEFAULT_TIMEOUT=6e5,jc.OpenAIError=Co,jc.APIError=ko,jc.APIConnectionError=Eo,jc.APIConnectionTimeoutError=Ro,jc.APIUserAbortError=jo,jc.NotFoundError=No,jc.ConflictError=$o,jc.RateLimitError=Uo,jc.BadRequestError=Ao,jc.AuthenticationError=Io,jc.InternalServerError=Lo,jc.PermissionDeniedError=Mo,jc.UnprocessableEntityError=Do,jc.InvalidWebhookSignatureError=Wo,jc.toFile=async function(e,t,n){if(zr(),(e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&ii(e))(e=await e))return e instanceof File?e:Kr([await e.arrayBuffer()],e.name);if((e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob)(e)){const o=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Kr(await ai(o),t,n)}const o=await ai(e);if(t||(t=Xr(e)),!n?.type){const e=o.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(n={...n,type:e})}return Kr(o,t,n)},jc.Completions=Cs,jc.Chat=Ca,jc.Embeddings=Is,jc.Files=Ds,jc.Images=zs,jc.Audio=Ma,jc.Moderations=Xs,jc.Models=Ks,jc.FineTuning=Gs,jc.Graders=Hs,jc.VectorStores=vc,jc.Webhooks=kc,jc.Beta=Ps,jc.Batches=Na,jc.Uploads=gc,jc.Responses=lc,jc.Realtime=Qs,jc.Conversations=As,jc.Evals=$s,jc.Containers=Es,jc.Skills=fc,jc.Videos=_c;class Ec extends jc{constructor({baseURL:e=Ga("OPENAI_BASE_URL"),apiKey:t=Ga("AZURE_OPENAI_API_KEY"),apiVersion:n=Ga("OPENAI_API_VERSION"),endpoint:o,deployment:r,azureADTokenProvider:i,dangerouslyAllowBrowser:a,...s}={}){if(!n)throw new Co("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if("function"==typeof i&&(a=!0),!i&&!t)throw new Co("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(i&&t)throw new Co("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(s.defaultQuery={...s.defaultQuery,"api-version":n},e){if(o)throw new Co("baseURL and endpoint are mutually exclusive")}else{if(o||(o=process.env.AZURE_OPENAI_ENDPOINT),!o)throw new Co("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");e=`${o}/openai`}super({apiKey:i??t,baseURL:e,...s,...void 0!==a?{dangerouslyAllowBrowser:a}:{}}),this.apiVersion="",this.apiVersion=n,this.deploymentName=r}async buildRequest(e,t={}){if(Rc.has(e.path)&&"post"===e.method&&void 0!==e.body){if(!Ho(e.body))throw new Error("Expected request body to be an object");const t=this.deploymentName||e.body.model||e.__metadata?.model;void 0===t||this.baseURL.includes("/deployments")||(e.path=`/deployments/${t}${e.path}`)}return super.buildRequest(e,t)}async authHeaders(e){return"string"==typeof this._options.apiKey?Ea([{"api-key":this.apiKey}]):super.authHeaders(e)}}const Rc=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);function Ac(e){let t=3735928559,n=1103547991;for(let o=0;o<e.length;o++){const r=e.charCodeAt(o);t=Math.imul(t^r,2654435761),n=Math.imul(n^r,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(n>>>0).toString(36)+(t>>>0).toString(36)}function Ic(e,t){const n={v:1,id:e};return t&&(n.phase=t),JSON.stringify(n)}function Mc(e){if(e){if(e.startsWith("{"))try{const t=JSON.parse(e);if(1===t.v&&"string"==typeof t.id)return"commentary"===t.phase||"final_answer"===t.phase?{id:t.id,phase:t.phase}:{id:t.id}}catch{}return{id:e}}}function Nc(e,t,n,o){const r=[],i=so(t.messages,e,t=>{if(!n.has(e.provider))return t;if(!t.includes("|"))return t;const[o,r]=t.split("|"),i=o.replace(/[^a-zA-Z0-9_-]/g,"_");let a=r.replace(/[^a-zA-Z0-9_-]/g,"_");a.startsWith("fc")||(a=`fc_${a}`);let s=i.length>64?i.slice(0,64):i,c=a.length>64?a.slice(0,64):a;return s=s.replace(/_+$/,""),c=c.replace(/_+$/,""),`${s}|${c}`});if((o?.includeSystemPrompt??!0)&&t.systemPrompt){const n=e.reasoning?"developer":"system";r.push({role:n,content:to(t.systemPrompt)})}let a=0;for(const t of i){if("user"===t.role)if("string"==typeof t.content)r.push({role:"user",content:[{type:"input_text",text:to(t.content)}]});else{const n=t.content.map(e=>"text"===e.type?{type:"input_text",text:to(e.text)}:{type:"input_image",detail:"auto",image_url:`data:${e.mimeType};base64,${e.data}`}),o=e.input.includes("image")?n:n.filter(e=>"input_image"!==e.type);if(0===o.length)continue;r.push({role:"user",content:o})}else if("assistant"===t.role){const n=[],o=t,i=o.model!==e.id&&o.provider===e.provider&&o.api===e.api;for(const e of t.content)if("thinking"===e.type){if(e.thinkingSignature){const t=JSON.parse(e.thinkingSignature);n.push(t)}}else if("text"===e.type){const t=e,o=Mc(t.textSignature);let r=o?.id;r?r.length>64&&(r=`msg_${Ac(r)}`):r=`msg_${a}`,n.push({type:"message",role:"assistant",content:[{type:"output_text",text:to(t.text),annotations:[]}],status:"completed",id:r,phase:o?.phase})}else if("toolCall"===e.type){const t=e,[o,r]=t.id.split("|");let a=r;i&&a?.startsWith("fc_")&&(a=void 0),n.push({type:"function_call",id:a,call_id:o,name:t.name,arguments:JSON.stringify(t.arguments)})}if(0===n.length)continue;r.push(...n)}else if("toolResult"===t.role){const n=t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),o=t.content.some(e=>"image"===e.type),i=n.length>0,[a]=t.toolCallId.split("|");if(r.push({type:"function_call_output",call_id:a,output:to(i?n:"(see attached image)")}),o&&e.input.includes("image")){const e=[];e.push({type:"input_text",text:"Attached image(s) from tool result:"});for(const n of t.content)"image"===n.type&&e.push({type:"input_image",detail:"auto",image_url:`data:${n.mimeType};base64,${n.data}`});r.push({role:"user",content:e})}}a++}return r}function $c(e,t){const n=void 0!==t?.strict&&t.strict;return e.map(e=>({type:"function",name:e.name,description:e.description,parameters:e.parameters,strict:n}))}async function Dc(e,t,n,o,r){let i=null,a=null;const s=t.content,c=()=>s.length-1;for await(const s of e)if("response.output_item.added"===s.type){const e=s.item;"reasoning"===e.type?(i=e,a={type:"thinking",thinking:""},t.content.push(a),n.push({type:"thinking_start",contentIndex:c(),partial:t})):"message"===e.type?(i=e,a={type:"text",text:""},t.content.push(a),n.push({type:"text_start",contentIndex:c(),partial:t})):"function_call"===e.type&&(i=e,a={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},partialJson:e.arguments||""},t.content.push(a),n.push({type:"toolcall_start",contentIndex:c(),partial:t}))}else if("response.reasoning_summary_part.added"===s.type)i&&"reasoning"===i.type&&(i.summary=i.summary||[],i.summary.push(s.part));else if("response.reasoning_summary_text.delta"===s.type){if("reasoning"===i?.type&&"thinking"===a?.type){i.summary=i.summary||[];const e=i.summary[i.summary.length-1];e&&(a.thinking+=s.delta,e.text+=s.delta,n.push({type:"thinking_delta",contentIndex:c(),delta:s.delta,partial:t}))}}else if("response.reasoning_summary_part.done"===s.type){if("reasoning"===i?.type&&"thinking"===a?.type){i.summary=i.summary||[];const e=i.summary[i.summary.length-1];e&&(a.thinking+="\n\n",e.text+="\n\n",n.push({type:"thinking_delta",contentIndex:c(),delta:"\n\n",partial:t}))}}else if("response.content_part.added"===s.type)"message"===i?.type&&(i.content=i.content||[],"output_text"!==s.part.type&&"refusal"!==s.part.type||i.content.push(s.part));else if("response.output_text.delta"===s.type){if("message"===i?.type&&"text"===a?.type){if(!i.content||0===i.content.length)continue;const e=i.content[i.content.length-1];"output_text"===e?.type&&(a.text+=s.delta,e.text+=s.delta,n.push({type:"text_delta",contentIndex:c(),delta:s.delta,partial:t}))}}else if("response.refusal.delta"===s.type){if("message"===i?.type&&"text"===a?.type){if(!i.content||0===i.content.length)continue;const e=i.content[i.content.length-1];"refusal"===e?.type&&(a.text+=s.delta,e.refusal+=s.delta,n.push({type:"text_delta",contentIndex:c(),delta:s.delta,partial:t}))}}else if("response.function_call_arguments.delta"===s.type)"function_call"===i?.type&&"toolCall"===a?.type&&(a.partialJson+=s.delta,a.arguments=eo(a.partialJson),n.push({type:"toolcall_delta",contentIndex:c(),delta:s.delta,partial:t}));else if("response.function_call_arguments.done"===s.type)"function_call"===i?.type&&"toolCall"===a?.type&&(a.partialJson=s.arguments,a.arguments=eo(a.partialJson));else if("response.output_item.done"===s.type){const e=s.item;if("reasoning"===e.type&&"thinking"===a?.type)a.thinking=e.summary?.map(e=>e.text).join("\n\n")||"",a.thinkingSignature=JSON.stringify(e),n.push({type:"thinking_end",contentIndex:c(),content:a.thinking,partial:t}),a=null;else if("message"===e.type&&"text"===a?.type)a.text=e.content.map(e=>"output_text"===e.type?e.text:e.refusal).join(""),a.textSignature=Ic(e.id,e.phase??void 0),n.push({type:"text_end",contentIndex:c(),content:a.text,partial:t}),a=null;else if("function_call"===e.type){const o="toolCall"===a?.type&&a.partialJson?eo(a.partialJson):eo(e.arguments||"{}"),r={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:o};a=null,n.push({type:"toolcall_end",contentIndex:c(),toolCall:r,partial:t})}}else if("response.completed"===s.type){const e=s.response;if(e?.usage){const n=e.usage.input_tokens_details?.cached_tokens||0;t.usage={input:(e.usage.input_tokens||0)-n,output:e.usage.output_tokens||0,cacheRead:n,cacheWrite:0,totalTokens:e.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(S(o,t.usage),r?.applyServiceTierPricing){const n=e?.service_tier??r.serviceTier;r.applyServiceTierPricing(t.usage,n)}t.stopReason=Uc(e?.status),t.content.some(e=>"toolCall"===e.type)&&"stop"===t.stopReason&&(t.stopReason="toolUse")}else{if("error"===s.type)throw new Error(`Error Code ${s.code}: ${s.message}`||"Unknown error");if("response.failed"===s.type)throw new Error("Unknown error")}}function Uc(e){if(!e)return"stop";switch(e){case"completed":case"in_progress":case"queued":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";default:throw new Error(`Unhandled stop reason: ${e}`)}}const Lc=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function qc(e,t){if(t?.azureDeploymentName)return t.azureDeploymentName;return function(e){const t=new Map;if(!e)return t;for(const n of e.split(",")){const e=n.trim();if(!e)continue;const[o,r]=e.split("=",2);o&&r&&t.set(o.trim(),r.trim())}return t}(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}const Fc=(e,t,n)=>{const o=new Zn;return(async()=>{const r=qc(e,n),i={role:"assistant",content:[],api:"azure-openai-responses",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const a=n?.apiKey||b(e.provider)||"",s=function(e,t,n){if(!t){if(!process.env.AZURE_OPENAI_API_KEY)throw new Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");t=process.env.AZURE_OPENAI_API_KEY}const o={...e.headers};n?.headers&&Object.assign(o,n.headers);const{baseUrl:r,apiVersion:i}=function(e,t){const n=t?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||"v1",o=t?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,r=t?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME;let i=o;!i&&r&&(i=function(e){return`https://${e}.openai.azure.com/openai/v1`}(r));!i&&e.baseUrl&&(i=e.baseUrl);if(!i)throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:Jc(i),apiVersion:n}}(e,n);return new Ec({apiKey:t,apiVersion:i,dangerouslyAllowBrowser:!0,defaultHeaders:o,baseURL:r})}(e,a,n);let c=function(e,t,n,o){const r=Nc(e,t,Lc),i={model:o,input:r,stream:!0,prompt_cache_key:n?.sessionId};n?.maxTokens&&(i.max_output_tokens=n?.maxTokens);void 0!==n?.temperature&&(i.temperature=n?.temperature);t.tools&&(i.tools=$c(t.tools));e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||"medium",summary:n?.reasoningSummary||"auto"},i.include=["reasoning.encrypted_content"]):e.name.toLowerCase().startsWith("gpt-5")&&r.push({role:"developer",content:[{type:"input_text",text:"# Juice: 0 !important"}]}));return i}(e,t,n,r);const u=await(n?.onPayload?.(c,e));void 0!==u&&(c=u);const l=await s.responses.create(c,n?.signal?{signal:n.signal}:void 0);if(o.push({type:"start",partial:i}),await Dc(l,i,o,e),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===i.stopReason||"error"===i.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:i.stopReason,message:i}),o.end()}catch(e){for(const e of i.content)delete e.index;i.stopReason=n?.signal?.aborted?"aborted":"error",i.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:i.stopReason,error:i}),o.end()}})(),o},Wc=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=x(e)?n?.reasoning:ao(n?.reasoning);return Fc(e,t,{...r,reasoningEffort:i})};function Jc(e){return e.replace(/\/+$/,"")}var Bc=n(12103),Gc=n(492),Vc=n(79896),Hc=n(91943),zc=n(57075),Kc=n(46466),Xc=(n(86412),n(20893),n(7389),n(56681));n(70129);var Zc=n(16928);
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
12
12
|
* Copyright 2025 Google LLC
|
|
@@ -321,4 +321,4 @@ const Kf="x-goog-api-key",Xf="https://www.googleapis.com/auth/cloud-platform";cl
|
|
|
321
321
|
* @license
|
|
322
322
|
* Copyright 2025 Google LLC
|
|
323
323
|
* SPDX-License-Identifier: Apache-2.0
|
|
324
|
-
*/class mm{get interactions(){var e;if(void 0!==this._interactions)return this._interactions;console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.");const t=this.httpOptions;(null==t?void 0:t.extraBody)&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const n=new zf({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:null==t?void 0:t.timeout,maxRetries:null===(e=null==t?void 0:t.retryOptions)||void 0===e?void 0:e.attempts});return this._interactions=n.interactions,this._interactions}constructor(e){var t,n,o,r,i,a;if((e.project||e.location)&&e.apiKey)throw new Error("Project/location and API key are mutually exclusive in the client initializer.");this.vertexai=null!==(n=null!==(t=e.vertexai)&&void 0!==t?t:function(e){return void 0!==e&&"true"===e.toLowerCase()}(gm("GOOGLE_GENAI_USE_VERTEXAI")))&&void 0!==n&&n;const s=function(){const e=gm("GOOGLE_API_KEY"),t=gm("GEMINI_API_KEY");e&&t&&console.warn("Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.");return e||t||void 0}(),c=gm("GOOGLE_CLOUD_PROJECT"),u=gm("GOOGLE_CLOUD_LOCATION");this.apiKey=null!==(o=e.apiKey)&&void 0!==o?o:s,this.project=null!==(r=e.project)&&void 0!==r?r:c,this.location=null!==(i=e.location)&&void 0!==i?i:u,this.vertexai||this.apiKey||console.warn("API key should be set when using the Gemini API."),e.vertexai&&((null===(a=e.googleAuthOptions)||void 0===a?void 0:a.credentials)&&(console.debug("The user provided Google Cloud credentials will take precedence over the API key from the environment variable."),this.apiKey=void 0),(c||u)&&e.apiKey?(console.debug("The user provided Vertex AI API key will take precedence over the project/location from the environment variables."),this.project=void 0,this.location=void 0):(e.project||e.location)&&s?(console.debug("The user provided project/location will take precedence over the API key from the environment variables."),this.apiKey=void 0):(c||u)&&s&&(console.debug("The project/location from the environment variables will take precedence over the API key from the environment variables."),this.apiKey=void 0),this.location||this.apiKey||(this.location="global"));const l=eu(e.httpOptions,e.vertexai,gm("GOOGLE_VERTEX_BASE_URL"),gm("GOOGLE_GEMINI_BASE_URL"));l&&(e.httpOptions?e.httpOptions.baseUrl=l:e.httpOptions={baseUrl:l}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const d=new Zf({apiKey:this.apiKey,googleAuthOptions:e.googleAuthOptions});this.apiClient=new fh({auth:d,project:this.project,location:this.location,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/"+process.version,uploader:new hm,downloader:new Yf}),this.models=new Rh(this.apiClient),this.live=new xh(this.apiClient,d,new Qf),this.batches=new Fd(this.apiClient),this.chats=new rp(this.models,this.apiClient),this.caches=new Kd(this.apiClient),this.files=new fm(this.apiClient),this.operations=new Ah(this.apiClient),this.authTokens=new Dh(this.apiClient),this.tunings=new cm(this.apiClient),this.fileSearchStores=new Fh(this.apiClient)}}function gm(e){var t,n,o;return null!==(o=null===(n=null===(t=null===process||void 0===process?void 0:process.env)||void 0===t?void 0:t[e])||void 0===n?void 0:n.trim())&&void 0!==o?o:void 0}function bm(e){return!0===e.thought}function ym(e,t){return"string"==typeof t&&t.length>0?t:e}const vm=/^[A-Za-z0-9+/]+={0,2}$/,_m="skip_thought_signature_validator";function wm(e,t){return e&&function(e){return!!e&&e.length%4==0&&vm.test(e)}(t)?t:void 0}function Om(e){return e.startsWith("claude-")||e.startsWith("gpt-oss-")}function Sm(e,t){const n=[],o=so(t.messages,e,t=>Om(e.id)?t.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64):t);for(const t of o)if("user"===t.role)if("string"==typeof t.content)n.push({role:"user",parts:[{text:to(t.content)}]});else{const o=t.content.map(e=>"text"===e.type?{text:to(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}}),r=e.input.includes("image")?o:o.filter(e=>void 0!==e.text);if(0===r.length)continue;n.push({role:"user",parts:r})}else if("assistant"===t.role){const o=[],r=t.provider===e.provider&&t.model===e.id;for(const n of t.content)if("text"===n.type){if(!n.text||""===n.text.trim())continue;const e=wm(r,n.textSignature);o.push({text:to(n.text),...e&&{thoughtSignature:e}})}else if("thinking"===n.type){if(!n.thinking||""===n.thinking.trim())continue;if(r){const e=wm(r,n.thinkingSignature);o.push({thought:!0,text:to(n.thinking),...e&&{thoughtSignature:e}})}else o.push({text:to(n.thinking)})}else if("toolCall"===n.type){const t=wm(r,n.thoughtSignature),i=e.id.toLowerCase().includes("gemini-3"),a=t||(i?_m:void 0),s={functionCall:{name:n.name,args:n.arguments??{},...Om(e.id)?{id:n.id}:{}},...a&&{thoughtSignature:a}};o.push(s)}if(0===o.length)continue;n.push({role:"model",parts:o})}else if("toolResult"===t.role){const o=t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),r=e.input.includes("image")?t.content.filter(e=>"image"===e.type):[],i=o.length>0,a=r.length>0,s=e.id.includes("gemini-3"),c=i?to(o):a?"(see attached image)":"",u=r.map(e=>({inlineData:{mimeType:e.mimeType,data:e.data}})),l=Om(e.id),d={functionResponse:{name:t.toolName,response:t.isError?{error:c}:{output:c},...a&&s&&{parts:u},...l?{id:t.toolCallId}:{}}},p=n[n.length-1];"user"===p?.role&&p.parts?.some(e=>e.functionResponse)?p.parts.push(d):n.push({role:"user",parts:[d]}),a&&!s&&n.push({role:"user",parts:[{text:"Tool result image:"},...u]})}return n}function xm(e,t=!1){if(0!==e.length)return[{functionDeclarations:e.map(e=>({name:e.name,description:e.description,...t?{parameters:e.parameters}:{parametersJsonSchema:e.parameters}}))}]}function Tm(e){switch(e){case"auto":default:return wu.AUTO;case"none":return wu.NONE;case"any":return wu.ANY}}function Pm(e){switch(e){case Cu.STOP:return"stop";case Cu.MAX_TOKENS:return"length";case Cu.BLOCKLIST:case Cu.PROHIBITED_CONTENT:case Cu.SPII:case Cu.SAFETY:case Cu.IMAGE_SAFETY:case Cu.IMAGE_PROHIBITED_CONTENT:case Cu.IMAGE_RECITATION:case Cu.IMAGE_OTHER:case Cu.RECITATION:case Cu.FINISH_REASON_UNSPECIFIED:case Cu.OTHER:case Cu.LANGUAGE:case Cu.MALFORMED_FUNCTION_CALL:case Cu.UNEXPECTED_TOOL_CALL:case Cu.NO_IMAGE:return"error";default:throw new Error(`Unhandled stop reason: ${e}`)}}function Cm(e){switch(e){case"STOP":return"stop";case"MAX_TOKENS":return"length";default:return"error"}}let km=0;const jm=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:"google-generative-ai",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey||b(e.provider)||"",a=function(e,t,n){const o={};e.baseUrl&&(o.baseUrl=e.baseUrl,o.apiVersion="");(e.headers||n)&&(o.headers={...e.headers,...n});return new mm({apiKey:t,httpOptions:Object.keys(o).length>0?o:void 0})}(e,i,n?.headers);let s=function(e,t,n={}){const o=Sm(e,t),r={};void 0!==n.temperature&&(r.temperature=n.temperature);void 0!==n.maxTokens&&(r.maxOutputTokens=n.maxTokens);const i={...Object.keys(r).length>0&&r,...t.systemPrompt&&{systemInstruction:to(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:xm(t.tools)}};t.tools&&t.tools.length>0&&n.toolChoice?i.toolConfig={functionCallingConfig:{mode:Tm(n.toolChoice)}}:i.toolConfig=void 0;if(n.thinking?.enabled&&e.reasoning){const e={includeThoughts:!0};void 0!==n.thinking.level?e.thinkingLevel=n.thinking.level:void 0!==n.thinking.budgetTokens&&(e.thinkingBudget=n.thinking.budgetTokens),i.thinkingConfig=e}if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");i.abortSignal=n.signal}const a={model:e.id,contents:o,config:i};return a}(e,t,n);const c=await(n?.onPayload?.(s,e));void 0!==c&&(s=c);const u=await a.models.generateContentStream(s);o.push({type:"start",partial:r});let l=null;const d=r.content,p=()=>d.length-1;for await(const t of u){const n=t.candidates?.[0];if(n?.content?.parts)for(const e of n.content.parts){if(void 0!==e.text){const t=bm(e);(!l||t&&"thinking"!==l.type||!t&&"text"!==l.type)&&(l&&("text"===l.type?o.push({type:"text_end",contentIndex:d.length-1,content:l.text,partial:r}):o.push({type:"thinking_end",contentIndex:p(),content:l.thinking,partial:r})),t?(l={type:"thinking",thinking:"",thinkingSignature:void 0},r.content.push(l),o.push({type:"thinking_start",contentIndex:p(),partial:r})):(l={type:"text",text:""},r.content.push(l),o.push({type:"text_start",contentIndex:p(),partial:r}))),"thinking"===l.type?(l.thinking+=e.text,l.thinkingSignature=ym(l.thinkingSignature,e.thoughtSignature),o.push({type:"thinking_delta",contentIndex:p(),delta:e.text,partial:r})):(l.text+=e.text,l.textSignature=ym(l.textSignature,e.thoughtSignature),o.push({type:"text_delta",contentIndex:p(),delta:e.text,partial:r}))}if(e.functionCall){l&&("text"===l.type?o.push({type:"text_end",contentIndex:p(),content:l.text,partial:r}):o.push({type:"thinking_end",contentIndex:p(),content:l.thinking,partial:r}),l=null);const t=e.functionCall.id,n=!t||r.content.some(e=>"toolCall"===e.type&&e.id===t),i={type:"toolCall",id:n?`${e.functionCall.name}_${Date.now()}_${++km}`:t,name:e.functionCall.name||"",arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(i),o.push({type:"toolcall_start",contentIndex:p(),partial:r}),o.push({type:"toolcall_delta",contentIndex:p(),delta:JSON.stringify(i.arguments),partial:r}),o.push({type:"toolcall_end",contentIndex:p(),toolCall:i,partial:r})}}n?.finishReason&&(r.stopReason=Pm(n.finishReason),r.content.some(e=>"toolCall"===e.type)&&(r.stopReason="toolUse")),t.usageMetadata&&(r.usage={input:t.usageMetadata.promptTokenCount||0,output:(t.usageMetadata.candidatesTokenCount||0)+(t.usageMetadata.thoughtsTokenCount||0),cacheRead:t.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:t.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},S(e,r.usage))}if(l&&("text"===l.type?o.push({type:"text_end",contentIndex:p(),content:l.text,partial:r}):o.push({type:"thinking_end",contentIndex:p(),content:l.thinking,partial:r})),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)"index"in e&&delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},Em=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o);if(!n?.reasoning)return jm(e,t,{...r,thinking:{enabled:!1}});const i=ao(n.reasoning),a=e;return Rm(a)||function(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}(a)?jm(e,t,{...r,thinking:{enabled:!0,level:Am(i,a)}}):jm(e,t,{...r,thinking:{enabled:!0,budgetTokens:Im(a,i,n.thinkingBudgets)}})};function Rm(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function Am(e,t){if(Rm(t))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(e){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function Im(e,t,n){if(void 0!==n?.[t])return n[t];if(e.id.includes("2.5-pro")){return{minimal:128,low:2048,medium:8192,high:32768}[t]}if(e.id.includes("2.5-flash")){return{minimal:128,low:2048,medium:8192,high:24576}[t]}return-1}const Mm="https://cloudcode-pa.googleapis.com",Nm=["https://daily-cloudcode-pa.sandbox.googleapis.com","https://autopush-cloudcode-pa.sandbox.googleapis.com",Mm],$m={"User-Agent":"google-cloud-sdk vscode_cloudshelleditor/0.1","X-Goog-Api-Client":"gl-node/22.17.0","Client-Metadata":JSON.stringify({ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"})};const Dm="You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.**Absolute paths only****Proactiveness**";let Um=0;function Lm(e,t){const n=e=>e>0?Math.ceil(e+1e3):void 0,o=t instanceof Headers?t:t?.headers;if(o){const e=o.get("retry-after");if(e){const t=Number(e);if(Number.isFinite(t)){const e=n(1e3*t);if(void 0!==e)return e}const o=new Date(e).getTime();if(!Number.isNaN(o)){const e=n(o-Date.now());if(void 0!==e)return e}}const t=o.get("x-ratelimit-reset");if(t){const e=Number.parseInt(t,10);if(!Number.isNaN(e)){const t=n(1e3*e-Date.now());if(void 0!==t)return t}}const r=o.get("x-ratelimit-reset-after");if(r){const e=Number(r);if(Number.isFinite(e)){const t=n(1e3*e);if(void 0!==t)return t}}}const r=e.match(/reset after (?:(\d+)h)?(?:(\d+)m)?(\d+(?:\.\d+)?)s/i);if(r){const e=r[1]?parseInt(r[1],10):0,t=r[2]?parseInt(r[2],10):0,o=parseFloat(r[3]);if(!Number.isNaN(o)){const r=n(1e3*(60*(60*e+t)+o));if(void 0!==r)return r}}const i=e.match(/Please retry in ([0-9.]+)(ms|s)/i);if(i?.[1]){const e=parseFloat(i[1]);if(!Number.isNaN(e)&&e>0){const t=n("ms"===i[2].toLowerCase()?e:1e3*e);if(void 0!==t)return t}}const a=e.match(/"retryDelay":\s*"([0-9.]+)(ms|s)"/i);if(a?.[1]){const e=parseFloat(a[1]);if(!Number.isNaN(e)&&e>0){const t=n("ms"===a[2].toLowerCase()?e:1e3*e);if(void 0!==t)return t}}}function qm(e){return"google-antigravity"===e.provider&&e.id.startsWith("claude-")&&e.reasoning}function Fm(e){return/gemini-3(?:\.1)?-pro/.test(e.toLowerCase())}function Wm(e,t){return 429===e||500===e||502===e||503===e||504===e||/resource.?exhausted|rate.?limit|overloaded|service.?unavailable|other.?side.?closed/i.test(t)}function Jm(e){try{const t=JSON.parse(e);if(t.error?.message)return t.error.message}catch{}return e}function Bm(e,t){return new Promise((n,o)=>{if(t?.aborted)return void o(new Error("Request was aborted"));const r=setTimeout(n,e);t?.addEventListener("abort",()=>{clearTimeout(r),o(new Error("Request was aborted"))})})}const Gm=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:"google-gemini-cli",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey;if(!i)throw new Error("Google Cloud Code Assist requires OAuth authentication. Use /login to authenticate.");let a,s;try{const e=JSON.parse(i);a=e.token,s=e.projectId}catch{throw new Error("Invalid Google Cloud Code Assist credentials. Use /login to re-authenticate.")}if(!a||!s)throw new Error("Missing token or projectId in Google Cloud credentials. Use /login to re-authenticate.");const c="google-antigravity"===e.provider,u=e.baseUrl?.trim(),l=u?[u]:c?Nm:[Mm];let d=Hm(e,t,s,n,c);const p=await(n?.onPayload?.(d,e));void 0!==p&&(d=p);const h={Authorization:`Bearer ${a}`,"Content-Type":"application/json",Accept:"text/event-stream",...c?{"User-Agent":`antigravity/${process.env.PI_AI_ANTIGRAVITY_VERSION||"1.18.4"} darwin/arm64`}:$m,...qm(e)?{"anthropic-beta":"interleaved-thinking-2025-05-14"}:{},...n?.headers},f=JSON.stringify(d);let m,g,b,y=0;for(let e=0;e<=3;e++){if(n?.signal?.aborted)throw new Error("Request was aborted");try{if(b=`${l[y]}/v1internal:streamGenerateContent?alt=sse`,m=await fetch(b,{method:"POST",headers:h,body:f,signal:n?.signal}),m.ok)break;const t=await m.text();if((403===m.status||404===m.status)&&y<l.length-1){y++;continue}if(e<3&&Wm(m.status,t)){y<l.length-1&&y++;const o=Lm(t,m),r=o??1e3*2**e,i=n?.maxRetryDelayMs??6e4;if(i>0&&o&&o>i){const e=Math.ceil(o/1e3);throw new Error(`Server requested ${e}s retry delay (max: ${Math.ceil(i/1e3)}s). ${Jm(t)}`)}await Bm(r,n?.signal);continue}throw new Error(`Cloud Code Assist API error (${m.status}): ${Jm(t)}`)}catch(t){if(t instanceof Error&&("AbortError"===t.name||"Request was aborted"===t.message))throw new Error("Request was aborted");if(g=t instanceof Error?t:new Error(String(t)),"fetch failed"===g.message&&g.cause instanceof Error&&(g=new Error(`Network error: ${g.cause.message}`)),e<3){const t=1e3*2**e;await Bm(t,n?.signal);continue}throw g}}if(!m||!m.ok)throw g??new Error("Failed to get response after retries");let v=!1;const _=()=>{v||(o.push({type:"start",partial:r}),v=!0)},w=()=>{r.content=[],r.usage={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},r.stopReason="stop",r.errorMessage=void 0,r.timestamp=Date.now(),v=!1},O=async t=>{if(!t.body)throw new Error("No response body");let i=!1,a=null;const s=r.content,c=()=>s.length-1,u=t.body.getReader(),l=new TextDecoder;let d="";const p=()=>{u.cancel().catch(()=>{})};n?.signal?.addEventListener("abort",p);try{for(;;){if(n?.signal?.aborted)throw new Error("Request was aborted");const{done:t,value:p}=await u.read();if(t)break;d+=l.decode(p,{stream:!0});const h=d.split("\n");d=h.pop()||"";for(const t of h){if(!t.startsWith("data:"))continue;const n=t.slice(5).trim();if(!n)continue;let u;try{u=JSON.parse(n)}catch{continue}const l=u.response;if(!l)continue;const d=l.candidates?.[0];if(d?.content?.parts)for(const e of d.content.parts){if(void 0!==e.text){i=!0;const t=bm(e);(!a||t&&"thinking"!==a.type||!t&&"text"!==a.type)&&(a&&("text"===a.type?o.push({type:"text_end",contentIndex:s.length-1,content:a.text,partial:r}):o.push({type:"thinking_end",contentIndex:c(),content:a.thinking,partial:r})),t?(a={type:"thinking",thinking:"",thinkingSignature:void 0},r.content.push(a),_(),o.push({type:"thinking_start",contentIndex:c(),partial:r})):(a={type:"text",text:""},r.content.push(a),_(),o.push({type:"text_start",contentIndex:c(),partial:r}))),"thinking"===a.type?(a.thinking+=e.text,a.thinkingSignature=ym(a.thinkingSignature,e.thoughtSignature),o.push({type:"thinking_delta",contentIndex:c(),delta:e.text,partial:r})):(a.text+=e.text,a.textSignature=ym(a.textSignature,e.thoughtSignature),o.push({type:"text_delta",contentIndex:c(),delta:e.text,partial:r}))}if(e.functionCall){i=!0,a&&("text"===a.type?o.push({type:"text_end",contentIndex:c(),content:a.text,partial:r}):o.push({type:"thinking_end",contentIndex:c(),content:a.thinking,partial:r}),a=null);const t=e.functionCall.id,n=!t||r.content.some(e=>"toolCall"===e.type&&e.id===t),s={type:"toolCall",id:n?`${e.functionCall.name}_${Date.now()}_${++Um}`:t,name:e.functionCall.name||"",arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(s),_(),o.push({type:"toolcall_start",contentIndex:c(),partial:r}),o.push({type:"toolcall_delta",contentIndex:c(),delta:JSON.stringify(s.arguments),partial:r}),o.push({type:"toolcall_end",contentIndex:c(),toolCall:s,partial:r})}}if(d?.finishReason&&(r.stopReason=Cm(d.finishReason),r.content.some(e=>"toolCall"===e.type)&&(r.stopReason="toolUse")),l.usageMetadata){const t=l.usageMetadata.promptTokenCount||0,n=l.usageMetadata.cachedContentTokenCount||0;r.usage={input:t-n,output:(l.usageMetadata.candidatesTokenCount||0)+(l.usageMetadata.thoughtsTokenCount||0),cacheRead:n,cacheWrite:0,totalTokens:l.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},S(e,r.usage)}}}}finally{n?.signal?.removeEventListener("abort",p)}return a&&("text"===a.type?o.push({type:"text_end",contentIndex:c(),content:a.text,partial:r}):o.push({type:"thinking_end",contentIndex:c(),content:a.thinking,partial:r})),i};let x=!1,T=m;for(let e=0;e<=2;e++){if(n?.signal?.aborted)throw new Error("Request was aborted");if(e>0){const t=500*2**(e-1);if(await Bm(t,n?.signal),!b)throw new Error("Missing request URL");if(T=await fetch(b,{method:"POST",headers:h,body:f,signal:n?.signal}),!T.ok){const e=await T.text();throw new Error(`Cloud Code Assist API error (${T.status}): ${e}`)}}if(await O(T)){x=!0;break}e<2&&w()}if(!x)throw new Error("Cloud Code Assist API returned an empty response");if(n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)"index"in e&&delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},Vm=(e,t,n)=>{const o=n?.apiKey;if(!o)throw new Error("Google Cloud Code Assist requires OAuth authentication. Use /login to authenticate.");const r=io(e,n,o);if(!n?.reasoning)return Gm(e,t,{...r,thinking:{enabled:!1}});const i=ao(n.reasoning);if(Fm(a=e.id)||function(e){return/gemini-3(?:\.1)?-flash/.test(e.toLowerCase())}(a))return Gm(e,t,{...r,thinking:{enabled:!0,level:zm(i,e.id)}});var a;let s={minimal:1024,low:2048,medium:8192,high:16384,...n.thinkingBudgets}[i];const c=Math.min((r.maxTokens||0)+s,e.maxTokens);return c<=s&&(s=Math.max(0,c-1024)),Gm(e,t,{...r,maxTokens:c,thinking:{enabled:!0,budgetTokens:s}})};function Hm(e,t,n,o={},r=!1){const i=Sm(e,t),a={};void 0!==o.temperature&&(a.temperature=o.temperature),void 0!==o.maxTokens&&(a.maxOutputTokens=o.maxTokens),o.thinking?.enabled&&e.reasoning&&(a.thinkingConfig={includeThoughts:!0},void 0!==o.thinking.level?a.thinkingConfig.thinkingLevel=o.thinking.level:void 0!==o.thinking.budgetTokens&&(a.thinkingConfig.thinkingBudget=o.thinking.budgetTokens));const s={contents:i};if(s.sessionId=o.sessionId,t.systemPrompt&&(s.systemInstruction={parts:[{text:to(t.systemPrompt)}]}),Object.keys(a).length>0&&(s.generationConfig=a),t.tools&&t.tools.length>0){const n=e.id.startsWith("claude-");s.tools=xm(t.tools,n),o.toolChoice&&(s.toolConfig={functionCallingConfig:{mode:Tm(o.toolChoice)}})}if(r){const e=s.systemInstruction?.parts??[];s.systemInstruction={role:"user",parts:[{text:Dm},{text:`Please ignore following [ignore]${Dm}[/ignore]`},...e]}}return{project:n,model:e.id,request:s,...r?{requestType:"agent"}:{},userAgent:r?"antigravity":"pi-coding-agent",requestId:`${r?"agent":"pi"}-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}}function zm(e,t){if(Fm(t))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(e){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}const Km={THINKING_LEVEL_UNSPECIFIED:Ou.THINKING_LEVEL_UNSPECIFIED,MINIMAL:Ou.MINIMAL,LOW:Ou.LOW,MEDIUM:Ou.MEDIUM,HIGH:Ou.HIGH};let Xm=0;const Zm=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:"google-vertex",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=function(e){const t=e?.project||process.env.GOOGLE_CLOUD_PROJECT||process.env.GCLOUD_PROJECT;if(!t)throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return t}(n),a=function(e){const t=e?.location||process.env.GOOGLE_CLOUD_LOCATION;if(!t)throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return t}(n),s=function(e,t,n,o){const r={};(e.headers||o)&&(r.headers={...e.headers,...o});const i=Object.values(r).some(Boolean);return new mm({vertexai:!0,project:t,location:n,apiVersion:"v1",httpOptions:i?r:void 0})}(e,i,a,n?.headers);let c=function(e,t,n={}){const o=Sm(e,t),r={};void 0!==n.temperature&&(r.temperature=n.temperature);void 0!==n.maxTokens&&(r.maxOutputTokens=n.maxTokens);const i={...Object.keys(r).length>0&&r,...t.systemPrompt&&{systemInstruction:to(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:xm(t.tools)}};t.tools&&t.tools.length>0&&n.toolChoice?i.toolConfig={functionCallingConfig:{mode:Tm(n.toolChoice)}}:i.toolConfig=void 0;if(n.thinking?.enabled&&e.reasoning){const e={includeThoughts:!0};void 0!==n.thinking.level?e.thinkingLevel=Km[n.thinking.level]:void 0!==n.thinking.budgetTokens&&(e.thinkingBudget=n.thinking.budgetTokens),i.thinkingConfig=e}if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");i.abortSignal=n.signal}const a={model:e.id,contents:o,config:i};return a}(e,t,n);const u=await(n?.onPayload?.(c,e));void 0!==u&&(c=u);const l=await s.models.generateContentStream(c);o.push({type:"start",partial:r});let d=null;const p=r.content,h=()=>p.length-1;for await(const t of l){const n=t.candidates?.[0];if(n?.content?.parts)for(const e of n.content.parts){if(void 0!==e.text){const t=bm(e);(!d||t&&"thinking"!==d.type||!t&&"text"!==d.type)&&(d&&("text"===d.type?o.push({type:"text_end",contentIndex:p.length-1,content:d.text,partial:r}):o.push({type:"thinking_end",contentIndex:h(),content:d.thinking,partial:r})),t?(d={type:"thinking",thinking:"",thinkingSignature:void 0},r.content.push(d),o.push({type:"thinking_start",contentIndex:h(),partial:r})):(d={type:"text",text:""},r.content.push(d),o.push({type:"text_start",contentIndex:h(),partial:r}))),"thinking"===d.type?(d.thinking+=e.text,d.thinkingSignature=ym(d.thinkingSignature,e.thoughtSignature),o.push({type:"thinking_delta",contentIndex:h(),delta:e.text,partial:r})):(d.text+=e.text,d.textSignature=ym(d.textSignature,e.thoughtSignature),o.push({type:"text_delta",contentIndex:h(),delta:e.text,partial:r}))}if(e.functionCall){d&&("text"===d.type?o.push({type:"text_end",contentIndex:h(),content:d.text,partial:r}):o.push({type:"thinking_end",contentIndex:h(),content:d.thinking,partial:r}),d=null);const t=e.functionCall.id,n=!t||r.content.some(e=>"toolCall"===e.type&&e.id===t),i={type:"toolCall",id:n?`${e.functionCall.name}_${Date.now()}_${++Xm}`:t,name:e.functionCall.name||"",arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(i),o.push({type:"toolcall_start",contentIndex:h(),partial:r}),o.push({type:"toolcall_delta",contentIndex:h(),delta:JSON.stringify(i.arguments),partial:r}),o.push({type:"toolcall_end",contentIndex:h(),toolCall:i,partial:r})}}n?.finishReason&&(r.stopReason=Pm(n.finishReason),r.content.some(e=>"toolCall"===e.type)&&(r.stopReason="toolUse")),t.usageMetadata&&(r.usage={input:t.usageMetadata.promptTokenCount||0,output:(t.usageMetadata.candidatesTokenCount||0)+(t.usageMetadata.thoughtsTokenCount||0),cacheRead:t.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:t.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},S(e,r.usage))}if(d&&("text"===d.type?o.push({type:"text_end",contentIndex:h(),content:d.text,partial:r}):o.push({type:"thinking_end",contentIndex:h(),content:d.thinking,partial:r})),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)"index"in e&&delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},Ym=(e,t,n)=>{const o=io(e,n,void 0);if(!n?.reasoning)return Zm(e,t,{...o,thinking:{enabled:!1}});const r=ao(n.reasoning),i=e;return Qm(i)||function(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}(i)?Zm(e,t,{...o,thinking:{enabled:!0,level:eg(r,i)}}):Zm(e,t,{...o,thinking:{enabled:!0,budgetTokens:tg(i,r,n.thinkingBudgets)}})};function Qm(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function eg(e,t){if(Qm(t))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(e){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function tg(e,t,n){if(void 0!==n?.[t])return n[t];if(e.id.includes("2.5-pro")){return{minimal:128,low:2048,medium:8192,high:32768}[t]}if(e.id.includes("2.5-flash")){return{minimal:128,low:2048,medium:8192,high:24576}[t]}return-1}var ng=n(36611);const og=(e,t,n)=>{const o=new Zn;return(async()=>{const r=function(e){return{role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()}}(e);try{const i=n?.apiKey||b(e.provider);if(!i)throw new Error(`No API key for provider: ${e.provider}`);const a=new ng.Mistral({apiKey:i,serverURL:e.baseUrl}),s=function(){const e=new Map,t=new Map;return n=>{const o=e.get(n);if(o)return o;let r=0;for(;;){const o=ig(n,r),i=t.get(o);if(!i||i===n)return e.set(n,o),t.set(o,n),o;r++}}}(),c=so(t.messages,e,e=>s(e));let u=function(e,t,n,o){const r={model:e.id,stream:!0,messages:ag(n,e.input.includes("image"))};t.tools?.length&&(r.tools=(i=t.tools,i.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.parameters,strict:!1}}))));var i;void 0!==o?.temperature&&(r.temperature=o.temperature);void 0!==o?.maxTokens&&(r.maxTokens=o.maxTokens);o?.toolChoice&&(r.toolChoice=function(e){if(!e)return;if("auto"===e||"none"===e||"any"===e||"required"===e)return e;return{type:"function",function:{name:e.function.name}}}(o.toolChoice));o?.promptMode&&(r.promptMode=o.promptMode);t.systemPrompt&&r.messages.unshift({role:"system",content:to(t.systemPrompt)});return r}(e,t,c,n);const l=await(n?.onPayload?.(u,e));void 0!==l&&(u=l);const d=await a.chat.stream(u,function(e,t){const n={};t?.signal&&(n.signal=t.signal);n.retries={strategy:"none"};const o={};e.headers&&Object.assign(o,e.headers);t?.headers&&Object.assign(o,t.headers);t?.sessionId&&!o["x-affinity"]&&(o["x-affinity"]=t.sessionId);Object.keys(o).length>0&&(n.headers=o);return n}(e,n));if(o.push({type:"start",partial:r}),await async function(e,t,n,o){let r=null;const i=t.content,a=()=>i.length-1,s=new Map,c=e=>{e&&("text"!==e.type?"thinking"===e.type&&n.push({type:"thinking_end",contentIndex:a(),content:e.thinking,partial:t}):n.push({type:"text_end",contentIndex:a(),content:e.text,partial:t}))};for await(const i of o){const o=i.data;o.usage&&(t.usage.input=o.usage.promptTokens||0,t.usage.output=o.usage.completionTokens||0,t.usage.cacheRead=0,t.usage.cacheWrite=0,t.usage.totalTokens=o.usage.totalTokens||t.usage.input+t.usage.output,S(e,t.usage));const u=o.choices[0];if(!u)continue;u.finishReason&&(t.stopReason=cg(u.finishReason));const l=u.delta;if(null!==l.content&&void 0!==l.content){const e="string"==typeof l.content?[l.content]:l.content;for(const o of e){if("string"==typeof o){const e=to(o);r&&"text"===r.type||(c(r),r={type:"text",text:""},t.content.push(r),n.push({type:"text_start",contentIndex:a(),partial:t})),r.text+=e,n.push({type:"text_delta",contentIndex:a(),delta:e,partial:t});continue}if("thinking"===o.type){const e=to(o.thinking.map(e=>"text"in e?e.text:"").filter(e=>e.length>0).join(""));if(!e)continue;r&&"thinking"===r.type||(c(r),r={type:"thinking",thinking:""},t.content.push(r),n.push({type:"thinking_start",contentIndex:a(),partial:t})),r.thinking+=e,n.push({type:"thinking_delta",contentIndex:a(),delta:e,partial:t});continue}if("text"===o.type){const e=to(o.text);r&&"text"===r.type||(c(r),r={type:"text",text:""},t.content.push(r),n.push({type:"text_start",contentIndex:a(),partial:t})),r.text+=e,n.push({type:"text_delta",contentIndex:a(),delta:e,partial:t})}}}const d=l.toolCalls||[];for(const e of d){r&&(c(r),r=null);const o=e.id&&"null"!==e.id?e.id:ig(`toolcall:${e.index??0}`,0),i=`${o}:${e.index||0}`,a=s.get(i);let u;if(void 0!==a){const e=t.content[a];"toolCall"===e?.type&&(u=e)}u||(u={type:"toolCall",id:o,name:e.function.name,arguments:{},partialArgs:""},t.content.push(u),s.set(i,t.content.length-1),n.push({type:"toolcall_start",contentIndex:t.content.length-1,partial:t}));const l="string"==typeof e.function.arguments?e.function.arguments:JSON.stringify(e.function.arguments||{});u.partialArgs=(u.partialArgs||"")+l,u.arguments=eo(u.partialArgs),n.push({type:"toolcall_delta",contentIndex:s.get(i),delta:l,partial:t})}}c(r);for(const e of s.values()){const o=t.content[e];if("toolCall"!==o.type)continue;const r=o;r.arguments=eo(r.partialArgs),delete r.partialArgs,n.push({type:"toolcall_end",contentIndex:e,toolCall:r,partial:t})}}(e,r,o,d),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=function(e){if(e instanceof Error){const o=e,r="number"==typeof o.statusCode?o.statusCode:void 0,i="string"==typeof o.body?o.body.trim():void 0;return void 0!==r&&i?`Mistral API error (${r}): ${t=i,n=4e3,t.length<=n?t:`${t.slice(0,n)}... [truncated ${t.length-n} chars]`}`:void 0!==r?`Mistral API error (${r}): ${e.message}`:e.message}var t,n;return function(e){try{const t=JSON.stringify(e);return void 0===t?String(e):t}catch{return String(e)}}(e)}(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},rg=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=ao(n?.reasoning);return og(e,t,{...r,promptMode:e.reasoning&&i?"reasoning":void 0})};function ig(e,t){const n=e.replace(/[^a-zA-Z0-9]/g,"");if(0===t&&9===n.length)return n;const o=n||e;return Ac(0===t?o:`${o}:${t}`).replace(/[^a-zA-Z0-9]/g,"").slice(0,9)}function ag(e,t){const n=[];for(const o of e){if("user"===o.role){if("string"==typeof o.content){n.push({role:"user",content:to(o.content)});continue}const e=o.content.some(e=>"image"===e.type),r=o.content.filter(e=>"text"===e.type||t).map(e=>"text"===e.type?{type:"text",text:to(e.text)}:{type:"image_url",imageUrl:`data:${e.mimeType};base64,${e.data}`});if(r.length>0){n.push({role:"user",content:r});continue}e&&!t&&n.push({role:"user",content:"(image omitted: model does not support images)"});continue}if("assistant"===o.role){const e=[],t=[];for(const n of o.content)"text"!==n.type?"thinking"!==n.type?t.push({id:n.id,type:"function",function:{name:n.name,arguments:JSON.stringify(n.arguments||{})}}):n.thinking.trim().length>0&&e.push({type:"thinking",thinking:[{type:"text",text:to(n.thinking)}]}):n.text.trim().length>0&&e.push({type:"text",text:to(n.text)});const r={role:"assistant"};e.length>0&&(r.content=e),t.length>0&&(r.toolCalls=t),(e.length>0||t.length>0)&&n.push(r);continue}const e=[],r=sg(o.content.filter(e=>"text"===e.type).map(e=>"text"===e.type?to(e.text):"").join("\n"),o.content.some(e=>"image"===e.type),t,o.isError);e.push({type:"text",text:r});for(const n of o.content)t&&"image"===n.type&&e.push({type:"image_url",imageUrl:`data:${n.mimeType};base64,${n.data}`});n.push({role:"tool",toolCallId:o.toolCallId,name:o.toolName,content:e})}return n}function sg(e,t,n,o){const r=e.trim(),i=o?"[tool error] ":"";if(r.length>0){return`${i}${r}${t&&!n?"\n[tool image omitted: model does not support images]":""}`}return t?n?o?"[tool error] (see attached image)":"(see attached image)":o?"[tool error] (image omitted: model does not support images)":"(image omitted: model does not support images)":o?"[tool error] (no tool output)":"(no tool output)"}function cg(e){if(null===e)return"stop";switch(e){case"stop":default:return"stop";case"length":case"model_length":return"length";case"tool_calls":return"toolUse";case"error":return"error"}}const ug=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey||b(e.provider)||"",a=function(e,t,n,o){if(!n){if(!process.env.OPENAI_API_KEY)throw new Error("OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.");n=process.env.OPENAI_API_KEY}const r={...e.headers};if("github-copilot"===e.provider){const e=oo(t.messages),n=ro({messages:t.messages,hasImages:e});Object.assign(r,n)}o&&Object.assign(r,o);return new jc({apiKey:n,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:r})}(e,t,i,n?.headers);let s=function(e,t,n){const o=function(e){const t=function(e){const t=e.provider,n=e.baseUrl,o="zai"===t||n.includes("api.z.ai"),r="cerebras"===t||n.includes("cerebras.ai")||"xai"===t||n.includes("api.x.ai")||n.includes("chutes.ai")||n.includes("deepseek.com")||o||"opencode"===t||n.includes("opencode.ai"),i=n.includes("chutes.ai"),a="xai"===t||n.includes("api.x.ai"),s="groq"!==t&&!n.includes("groq.com")||"qwen/qwen3-32b"!==e.id?{}:{minimal:"default",low:"default",medium:"default",high:"default",xhigh:"default"};return{supportsStore:!r,supportsDeveloperRole:!r,supportsReasoningEffort:!a&&!o,reasoningEffortMap:s,supportsUsageInStreaming:!0,maxTokensField:i?"max_tokens":"max_completion_tokens",requiresToolResultName:!1,requiresAssistantAfterToolResult:!1,requiresThinkingAsText:!1,thinkingFormat:o?"zai":"openai",openRouterRouting:{},vercelGatewayRouting:{},supportsStrictMode:!0}}(e);return e.compat?{supportsStore:e.compat.supportsStore??t.supportsStore,supportsDeveloperRole:e.compat.supportsDeveloperRole??t.supportsDeveloperRole,supportsReasoningEffort:e.compat.supportsReasoningEffort??t.supportsReasoningEffort,reasoningEffortMap:e.compat.reasoningEffortMap??t.reasoningEffortMap,supportsUsageInStreaming:e.compat.supportsUsageInStreaming??t.supportsUsageInStreaming,maxTokensField:e.compat.maxTokensField??t.maxTokensField,requiresToolResultName:e.compat.requiresToolResultName??t.requiresToolResultName,requiresAssistantAfterToolResult:e.compat.requiresAssistantAfterToolResult??t.requiresAssistantAfterToolResult,requiresThinkingAsText:e.compat.requiresThinkingAsText??t.requiresThinkingAsText,thinkingFormat:e.compat.thinkingFormat??t.thinkingFormat,openRouterRouting:e.compat.openRouterRouting??{},vercelGatewayRouting:e.compat.vercelGatewayRouting??t.vercelGatewayRouting,supportsStrictMode:e.compat.supportsStrictMode??t.supportsStrictMode}:t}(e),r=dg(e,t,o);!function(e,t){if("openrouter"!==e.provider||!e.id.startsWith("anthropic/"))return;for(let e=t.length-1;e>=0;e--){const n=t[e];if("user"!==n.role&&"assistant"!==n.role)continue;const o=n.content;if("string"==typeof o)return void(n.content=[Object.assign({type:"text",text:o},{cache_control:{type:"ephemeral"}})]);if(Array.isArray(o))for(let e=o.length-1;e>=0;e--){const t=o[e];if("text"===t?.type)return void Object.assign(t,{cache_control:{type:"ephemeral"}})}}}(e,r);const i={model:e.id,messages:r,stream:!0};!1!==o.supportsUsageInStreaming&&(i.stream_options={include_usage:!0});o.supportsStore&&(i.store=!1);n?.maxTokens&&("max_tokens"===o.maxTokensField?i.max_tokens=n.maxTokens:i.max_completion_tokens=n.maxTokens);void 0!==n?.temperature&&(i.temperature=n.temperature);t.tools?i.tools=function(e,t){return e.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.parameters,...!1!==t.supportsStrictMode&&{strict:!1}}}))}(t.tools,o):function(e){for(const t of e){if("toolResult"===t.role)return!0;if("assistant"===t.role&&t.content.some(e=>"toolCall"===e.type))return!0}return!1}(t.messages)&&(i.tools=[]);n?.toolChoice&&(i.tool_choice=n.toolChoice);"zai"!==o.thinkingFormat&&"qwen"!==o.thinkingFormat||!e.reasoning?n?.reasoningEffort&&e.reasoning&&o.supportsReasoningEffort&&(i.reasoning_effort=(a=n.reasoningEffort,o.reasoningEffortMap[a]??a)):i.enable_thinking=!!n?.reasoningEffort;var a;e.baseUrl.includes("openrouter.ai")&&e.compat?.openRouterRouting&&(i.provider=e.compat.openRouterRouting);if(e.baseUrl.includes("ai-gateway.vercel.sh")&&e.compat?.vercelGatewayRouting){const t=e.compat.vercelGatewayRouting;if(t.only||t.order){const e={};t.only&&(e.only=t.only),t.order&&(e.order=t.order),i.providerOptions={gateway:e}}}return i}(e,t,n);const c=await(n?.onPayload?.(s,e));void 0!==c&&(s=c);const u=await a.chat.completions.create(s,{signal:n?.signal});o.push({type:"start",partial:r});let l=null;const d=r.content,p=()=>d.length-1,h=e=>{e&&("text"===e.type?o.push({type:"text_end",contentIndex:p(),content:e.text,partial:r}):"thinking"===e.type?o.push({type:"thinking_end",contentIndex:p(),content:e.thinking,partial:r}):"toolCall"===e.type&&(e.arguments=eo(e.partialArgs),delete e.partialArgs,o.push({type:"toolcall_end",contentIndex:p(),toolCall:e,partial:r})))};for await(const t of u){if(t.usage){const n=t.usage.prompt_tokens_details?.cached_tokens||0,o=t.usage.completion_tokens_details?.reasoning_tokens||0,i=(t.usage.prompt_tokens||0)-n,a=(t.usage.completion_tokens||0)+o;r.usage={input:i,output:a,cacheRead:n,cacheWrite:0,totalTokens:i+a+n,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},S(e,r.usage)}const n=t.choices?.[0];if(n&&(n.finish_reason&&(r.stopReason=pg(n.finish_reason)),n.delta)){null!==n.delta.content&&void 0!==n.delta.content&&n.delta.content.length>0&&(l&&"text"===l.type||(h(l),l={type:"text",text:""},r.content.push(l),o.push({type:"text_start",contentIndex:p(),partial:r})),"text"===l.type&&(l.text+=n.delta.content,o.push({type:"text_delta",contentIndex:p(),delta:n.delta.content,partial:r})));const e=["reasoning_content","reasoning","reasoning_text"];let t=null;for(const o of e)if(null!==n.delta[o]&&void 0!==n.delta[o]&&n.delta[o].length>0&&!t){t=o;break}if(t&&(l&&"thinking"===l.type||(h(l),l={type:"thinking",thinking:"",thinkingSignature:t},r.content.push(l),o.push({type:"thinking_start",contentIndex:p(),partial:r})),"thinking"===l.type)){const e=n.delta[t];l.thinking+=e,o.push({type:"thinking_delta",contentIndex:p(),delta:e,partial:r})}if(n?.delta?.tool_calls)for(const e of n.delta.tool_calls)if((!l||"toolCall"!==l.type||e.id&&l.id!==e.id)&&(h(l),l={type:"toolCall",id:e.id||"",name:e.function?.name||"",arguments:{},partialArgs:""},r.content.push(l),o.push({type:"toolcall_start",contentIndex:p(),partial:r})),"toolCall"===l.type){e.id&&(l.id=e.id),e.function?.name&&(l.name=e.function.name);let t="";e.function?.arguments&&(t=e.function.arguments,l.partialArgs+=e.function.arguments,l.arguments=eo(l.partialArgs)),o.push({type:"toolcall_delta",contentIndex:p(),delta:t,partial:r})}const i=n.delta.reasoning_details;if(i&&Array.isArray(i))for(const e of i)if("reasoning.encrypted"===e.type&&e.id&&e.data){const t=r.content.find(t=>"toolCall"===t.type&&t.id===e.id);t&&(t.thoughtSignature=JSON.stringify(e))}}}if(h(l),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e);const t=e?.error?.metadata?.raw;t&&(r.errorMessage+=`\n${t}`),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},lg=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=x(e)?n?.reasoning:ao(n?.reasoning),a=n?.toolChoice;return ug(e,t,{...r,reasoningEffort:i,toolChoice:a})};function dg(e,t,n){const o=[],r=so(t.messages,e,t=>(t=>{if(t.includes("|")){const[e]=t.split("|");return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,40)}return"openai"===e.provider&&t.length>40?t.slice(0,40):t})(t));if(t.systemPrompt){const r=e.reasoning&&n.supportsDeveloperRole?"developer":"system";o.push({role:r,content:to(t.systemPrompt)})}let i=null;for(let t=0;t<r.length;t++){const a=r[t];if(n.requiresAssistantAfterToolResult&&"toolResult"===i&&"user"===a.role&&o.push({role:"assistant",content:"I have processed the tool results."}),"user"===a.role)if("string"==typeof a.content)o.push({role:"user",content:to(a.content)});else{const t=a.content.map(e=>"text"===e.type?{type:"text",text:to(e.text)}:{type:"image_url",image_url:{url:`data:${e.mimeType};base64,${e.data}`}}),n=e.input.includes("image")?t:t.filter(e=>"image_url"!==e.type);if(0===n.length)continue;o.push({role:"user",content:n})}else if("assistant"===a.role){const t={role:"assistant",content:n.requiresAssistantAfterToolResult?"":null},r=a.content.filter(e=>"text"===e.type).filter(e=>e.text&&e.text.trim().length>0);r.length>0&&("github-copilot"===e.provider?t.content=r.map(e=>to(e.text)).join(""):t.content=r.map(e=>({type:"text",text:to(e.text)})));const i=a.content.filter(e=>"thinking"===e.type).filter(e=>e.thinking&&e.thinking.trim().length>0);if(i.length>0)if(n.requiresThinkingAsText){const e=i.map(e=>e.thinking).join("\n\n"),n=t.content;n?n.unshift({type:"text",text:e}):t.content=[{type:"text",text:e}]}else{const e=i[0].thinkingSignature;e&&e.length>0&&(t[e]=i.map(e=>e.thinking).join("\n"))}const s=a.content.filter(e=>"toolCall"===e.type);if(s.length>0){t.tool_calls=s.map(e=>({id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.arguments)}}));const e=s.filter(e=>e.thoughtSignature).map(e=>{try{return JSON.parse(e.thoughtSignature)}catch{return null}}).filter(Boolean);e.length>0&&(t.reasoning_details=e)}const c=t.content;if(!(null!=c&&c.length>0)&&!t.tool_calls)continue;o.push(t)}else if("toolResult"===a.role){const a=[];let s=t;for(;s<r.length&&"toolResult"===r[s].role;s++){const t=r[s],i=t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),c=t.content.some(e=>"image"===e.type),u={role:"tool",content:to(i.length>0?i:"(see attached image)"),tool_call_id:t.toolCallId};if(n.requiresToolResultName&&t.toolName&&(u.name=t.toolName),o.push(u),c&&e.input.includes("image"))for(const e of t.content)"image"===e.type&&a.push({type:"image_url",image_url:{url:`data:${e.mimeType};base64,${e.data}`}})}t=s-1,a.length>0?(n.requiresAssistantAfterToolResult&&o.push({role:"assistant",content:"I have processed the tool results."}),o.push({role:"user",content:[{type:"text",text:"Attached image(s) from tool result:"},...a]}),i="user"):i="toolResult";continue}i=a.role}return o}function pg(e){if(null===e)return"stop";switch(e){case"stop":return"stop";case"length":return"length";case"function_call":case"tool_calls":return"toolUse";case"content_filter":return"error";default:throw new Error(`Unhandled stop reason: ${e}`)}}const hg=new Set(["openai","openai-codex","opencode"]);function fg(e,t){if("long"===t)return e.includes("api.openai.com")?"24h":void 0}const mg=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey||b(e.provider)||"",a=function(e,t,n,o){if(!n){if(!process.env.OPENAI_API_KEY)throw new Error("OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.");n=process.env.OPENAI_API_KEY}const r={...e.headers};if("github-copilot"===e.provider){const e=oo(t.messages),n=ro({messages:t.messages,hasImages:e});Object.assign(r,n)}o&&Object.assign(r,o);return new jc({apiKey:n,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:r})}(e,t,i,n?.headers);let s=function(e,t,n){const o=Nc(e,t,hg),r=function(e){return e||("undefined"!=typeof process&&"long"===process.env.PI_CACHE_RETENTION?"long":"short")}(n?.cacheRetention),i={model:e.id,input:o,stream:!0,prompt_cache_key:"none"===r?void 0:n?.sessionId,prompt_cache_retention:fg(e.baseUrl,r),store:!1};n?.maxTokens&&(i.max_output_tokens=n?.maxTokens);void 0!==n?.temperature&&(i.temperature=n?.temperature);void 0!==n?.serviceTier&&(i.service_tier=n.serviceTier);t.tools&&(i.tools=$c(t.tools));e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||"medium",summary:n?.reasoningSummary||"auto"},i.include=["reasoning.encrypted_content"]):e.name.startsWith("gpt-5")&&o.push({role:"developer",content:[{type:"input_text",text:"# Juice: 0 !important"}]}));return i}(e,t,n);const c=await(n?.onPayload?.(s,e));void 0!==c&&(s=c);const u=await a.responses.create(s,n?.signal?{signal:n.signal}:void 0);if(o.push({type:"start",partial:r}),await Dc(u,r,o,e,{serviceTier:n?.serviceTier,applyServiceTierPricing:bg}),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},gg=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=x(e)?n?.reasoning:ao(n?.reasoning);return mg(e,t,{...r,reasoningEffort:i})};function bg(e,t){const n=function(e){switch(e){case"flex":return.5;case"priority":return 2;default:return 1}}(t);1!==n&&(e.cost.input*=n,e.cost.output*=n,e.cost.cacheRead*=n,e.cost.cacheWrite*=n,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite)}let yg=null;var vg;"undefined"!=typeof process&&(process.versions?.node||process.versions?.bun)&&(vg="node:os",n(84005)(vg)).then(e=>{yg=e});const _g="https://api.openai.com/auth",wg=new Set(["openai","openai-codex","opencode"]),Og=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function Sg(e,t){return 429===e||500===e||502===e||503===e||504===e||/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(t)}function xg(e,t){return new Promise((n,o)=>{if(t?.aborted)return void o(new Error("Request was aborted"));const r=setTimeout(n,e);t?.addEventListener("abort",()=>{clearTimeout(r),o(new Error("Request was aborted"))})})}const Tg=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:"openai-codex-responses",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey||b(e.provider)||"";if(!i)throw new Error(`No API key for provider: ${e.provider}`);const a=function(e){try{const t=e.split(".");if(3!==t.length)throw new Error("Invalid token");const n=JSON.parse(atob(t[1])),o=n?.[_g]?.chatgpt_account_id;if(!o)throw new Error("No account ID in token");return o}catch{throw new Error("Failed to extract accountId from token")}}(i);let s=function(e,t,n){const o=Nc(e,t,wg,{includeSystemPrompt:!1}),r={model:e.id,store:!1,stream:!0,instructions:t.systemPrompt,input:o,text:{verbosity:n?.textVerbosity||"medium"},include:["reasoning.encrypted_content"],prompt_cache_key:n?.sessionId,tool_choice:"auto",parallel_tool_calls:!0};void 0!==n?.temperature&&(r.temperature=n.temperature);t.tools&&(r.tools=$c(t.tools,{strict:null}));void 0!==n?.reasoningEffort&&(r.reasoning={effort:Cg(e.id,n.reasoningEffort),summary:n.reasoningSummary??"auto"});return r}(e,t,n);const c=await(n?.onPayload?.(s,e));void 0!==c&&(s=c);const u=function(e,t,n,o,r){const i=new Headers(e);i.set("Authorization",`Bearer ${o}`),i.set("chatgpt-account-id",n),i.set("OpenAI-Beta","responses=experimental"),i.set("originator","pi");const a=yg?`pi (${yg.platform()} ${yg.release()}; ${yg.arch()})`:"pi (browser)";i.set("User-Agent",a),i.set("accept","text/event-stream"),i.set("content-type","application/json");for(const[e,n]of Object.entries(t||{}))i.set(e,n);r&&i.set("session_id",r);return i}(e.headers,n?.headers,a,i,n?.sessionId),l=JSON.stringify(s),d=n?.transport||"sse";if("sse"!==d){let t=!1;try{if(await async function(e,t,n,o,r,i,a,s){const{socket:c,release:u}=await async function(e,t,n,o){if(!n){const n=await Dg(e,t,o);return{socket:n,release:({keep:e}={})=>{Ng(n)}}}const r=Ig.get(n);if(r){if(r.idleTimer&&(clearTimeout(r.idleTimer),r.idleTimer=void 0),!r.busy&&Mg(r.socket))return r.busy=!0,{socket:r.socket,release:({keep:e}={})=>{if(!e||!Mg(r.socket))return Ng(r.socket),void Ig.delete(n);r.busy=!1,$g(n,r)}};if(r.busy){const n=await Dg(e,t,o);return{socket:n,release:()=>{Ng(n)}}}Mg(r.socket)||(Ng(r.socket),Ig.delete(n))}const i=await Dg(e,t,o),a={socket:i,busy:!0};return Ig.set(n,a),{socket:i,release:({keep:e}={})=>{if(!e||!Mg(a.socket))return Ng(a.socket),a.idleTimer&&clearTimeout(a.idleTimer),void(Ig.get(n)===a&&Ig.delete(n));a.busy=!1,$g(n,a)}}}(e,n,s?.sessionId,s?.signal);let l=!0;try{c.send(JSON.stringify({type:"response.create",...t})),a(),r.push({type:"start",partial:o}),await Dc(jg(async function*(e,t){const n=[];let o=null,r=!1,i=null,a=!1;const s=()=>{if(!o)return;const e=o;o=null,e()},c=e=>{(async()=>{if(!e||"object"!=typeof e||!("data"in e))return;const t=await async function(e){if("string"==typeof e)return e;if(e instanceof ArrayBuffer)return(new TextDecoder).decode(new Uint8Array(e));if(ArrayBuffer.isView(e)){const t=e;return(new TextDecoder).decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}if(e&&"object"==typeof e&&"arrayBuffer"in e){const t=e,n=await t.arrayBuffer();return(new TextDecoder).decode(new Uint8Array(n))}return null}(e.data);if(t)try{const e=JSON.parse(t),o="string"==typeof e.type?e.type:"";"response.completed"!==o&&"response.done"!==o||(a=!0,r=!0),n.push(e),s()}catch{}})()},u=e=>{i=Ug(e),r=!0,s()},l=e=>{if(a)return r=!0,void s();i||(i=Lg(e)),r=!0,s()},d=()=>{i=new Error("Request was aborted"),r=!0,s()};e.addEventListener("message",c),e.addEventListener("error",u),e.addEventListener("close",l),t?.addEventListener("abort",d);try{for(;;){if(t?.aborted)throw new Error("Request was aborted");if(n.length>0)yield n.shift();else{if(r)break;await new Promise(e=>{o=e})}}if(i)throw i;if(!a)throw new Error("WebSocket stream closed before response.completed")}finally{e.removeEventListener("message",c),e.removeEventListener("error",u),e.removeEventListener("close",l),t?.removeEventListener("abort",d)}}(c,s?.signal)),o,r,i),s?.signal?.aborted&&(l=!1)}catch(e){throw l=!1,e}finally{u({keep:l})}}(function(e){const t=new URL(kg(e));"https:"===t.protocol&&(t.protocol="wss:");"http:"===t.protocol&&(t.protocol="ws:");return t.toString()}(e.baseUrl),s,u,r,o,e,()=>{t=!0},n),n?.signal?.aborted)throw new Error("Request was aborted");return o.push({type:"done",reason:r.stopReason,message:r}),void o.end()}catch(e){if("websocket"===d||t)throw e}}let p,h;for(let t=0;t<=3;t++){if(n?.signal?.aborted)throw new Error("Request was aborted");try{if(p=await fetch(kg(e.baseUrl),{method:"POST",headers:u,body:l,signal:n?.signal}),p.ok)break;const o=await p.text();if(t<3&&Sg(p.status,o)){const e=1e3*2**t;await xg(e,n?.signal);continue}const r=new Response(o,{status:p.status,statusText:p.statusText}),i=await qg(r);throw new Error(i.friendlyMessage||i.message)}catch(e){if(e instanceof Error&&("AbortError"===e.name||"Request was aborted"===e.message))throw new Error("Request was aborted");if(h=e instanceof Error?e:new Error(String(e)),t<3&&!h.message.includes("usage limit")){const e=1e3*2**t;await xg(e,n?.signal);continue}throw h}}if(!p?.ok)throw h??new Error("Failed after retries");if(!p.body)throw new Error("No response body");if(o.push({type:"start",partial:r}),await async function(e,t,n,o){await Dc(jg(async function*(e){if(!e.body)return;const t=e.body.getReader(),n=new TextDecoder;let o="";for(;;){const{done:e,value:r}=await t.read();if(e)break;o+=n.decode(r,{stream:!0});let i=o.indexOf("\n\n");for(;-1!==i;){const e=o.slice(0,i);o=o.slice(i+2);const t=e.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trim());if(t.length>0){const e=t.join("\n").trim();if(e&&"[DONE]"!==e)try{yield JSON.parse(e)}catch{}}i=o.indexOf("\n\n")}}}(e)),t,n,o)}(p,r,o,e),n?.signal?.aborted)throw new Error("Request was aborted");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:String(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},Pg=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=x(e)?n?.reasoning:ao(n?.reasoning);return Tg(e,t,{...r,reasoningEffort:i})};function Cg(e,t){const n=e.includes("/")?e.split("/").pop():e;return(n.startsWith("gpt-5.2")||n.startsWith("gpt-5.3")||n.startsWith("gpt-5.4"))&&"minimal"===t?"low":"gpt-5.1"===n&&"xhigh"===t?"high":"gpt-5.1-codex-mini"===n?"high"===t||"xhigh"===t?"high":"medium":t}function kg(e){const t=(e&&e.trim().length>0?e:"https://chatgpt.com/backend-api").replace(/\/+$/,"");return t.endsWith("/codex/responses")?t:t.endsWith("/codex")?`${t}/responses`:`${t}/codex/responses`}async function*jg(e){for await(const t of e){const e="string"==typeof t.type?t.type:void 0;if(e){if("error"===e){const e=t.code||"",n=t.message||"";throw new Error(`Codex error: ${n||e||JSON.stringify(t)}`)}if("response.failed"===e){const e=t.response?.error?.message;throw new Error(e||"Codex response failed")}if("response.done"===e||"response.completed"===e){const e=t.response,n=e?{...e,status:Eg(e.status)}:e;yield{...t,type:"response.completed",response:n};continue}yield t}}}function Eg(e){if("string"==typeof e)return Og.has(e)?e:void 0}const Rg="responses_websockets=2026-02-06",Ag=3e5,Ig=new Map;function Mg(e){const t=function(e){const t=e.readyState;return"number"==typeof t?t:void 0}(e);return void 0===t||1===t}function Ng(e,t=1e3,n="done"){try{e.close(t,n)}catch{}}function $g(e,t){t.idleTimer&&clearTimeout(t.idleTimer),t.idleTimer=setTimeout(()=>{t.busy||(Ng(t.socket,1e3,"idle_timeout"),Ig.delete(e))},Ag)}async function Dg(e,t,n){const o=function(){const e=globalThis.WebSocket;return"function"!=typeof e?null:e}();if(!o)throw new Error("WebSocket transport is not available in this runtime");const r=function(e){const t={};for(const[n,o]of e.entries())t[n]=o;return t}(t);return r["OpenAI-Beta"]=Rg,new Promise((t,i)=>{let a,s=!1;try{a=new o(e,{headers:r})}catch(e){return void i(e instanceof Error?e:new Error(String(e)))}const c=()=>{s||(s=!0,p(),t(a))},u=e=>{s||(s=!0,p(),i(Ug(e)))},l=e=>{s||(s=!0,p(),i(Lg(e)))},d=()=>{s||(s=!0,p(),a.close(1e3,"aborted"),i(new Error("Request was aborted")))},p=()=>{a.removeEventListener("open",c),a.removeEventListener("error",u),a.removeEventListener("close",l),n?.removeEventListener("abort",d)};a.addEventListener("open",c),a.addEventListener("error",u),a.addEventListener("close",l),n?.addEventListener("abort",d)})}function Ug(e){if(e&&"object"==typeof e&&"message"in e){const t=e.message;if("string"==typeof t&&t.length>0)return new Error(t)}return new Error("WebSocket error")}function Lg(e){if(e&&"object"==typeof e){const t="code"in e?e.code:void 0,n="reason"in e?e.reason:void 0,o="number"==typeof t?` ${t}`:"",r="string"==typeof n&&n.length>0?` ${n}`:"";return new Error(`WebSocket closed${o}${r}`.trim())}return new Error("WebSocket closed")}async function qg(e){const t=await e.text();let n,o=t||e.statusText||"Request failed";try{const r=JSON.parse(t),i=r?.error;if(i){const t=i.code||i.type||"";if(/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(t)||429===e.status){const e=i.plan_type?` (${i.plan_type.toLowerCase()} plan)`:"",t=i.resets_at?Math.max(0,Math.round((1e3*i.resets_at-Date.now())/6e4)):void 0;n=`You have hit your ChatGPT usage limit${e}.${void 0!==t?` Try again in ~${t} min.`:""}`.trim()}o=i.message||n||o}}catch{}return{message:o,friendlyMessage:n}}const Fg=e=>n(84005)(e),Wg="./amazon-bedrock.js";let Jg;function Bg(e){Jg=e}async function Gg(){if(Jg)return Jg;return await Fg(Wg)}function Vg(e,t){(async()=>{for await(const n of t)e.push(n);e.end()})()}function Hg(e,t){return{role:"assistant",content:[],api:"bedrock-converse-stream",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function zg(e,t,n){const o=new Zn;return Gg().then(r=>{const i=r.streamBedrock(e,t,n);Vg(o,i)}).catch(t=>{const n=Hg(e,t);o.push({type:"error",reason:"error",error:n}),o.end(n)}),o}function Kg(e,t,n){const o=new Zn;return Gg().then(r=>{const i=r.streamSimpleBedrock(e,t,n);Vg(o,i)}).catch(t=>{const n=Hg(e,t);o.push({type:"error",reason:"error",error:n}),o.end(n)}),o}function Xg(){s({api:"anthropic-messages",stream:mo,streamSimple:bo}),s({api:"openai-completions",stream:ug,streamSimple:lg}),s({api:"mistral-conversations",stream:og,streamSimple:rg}),s({api:"openai-responses",stream:mg,streamSimple:gg}),s({api:"azure-openai-responses",stream:Fc,streamSimple:Wc}),s({api:"openai-codex-responses",stream:Tg,streamSimple:Pg}),s({api:"google-generative-ai",stream:jm,streamSimple:Em}),s({api:"google-gemini-cli",stream:Gm,streamSimple:Vm}),s({api:"google-vertex",stream:Zm,streamSimple:Ym}),s({api:"bedrock-converse-stream",stream:zg,streamSimple:Kg})}function Zg(){d(),Xg()}function Yg(e){const t=c(e);if(!t)throw new Error(`No API provider registered for api: ${e}`);return t}function Qg(e,t,n){return Yg(e.api).stream(e,t,n)}async function eb(e,t,n){return Qg(e,t,n).result()}function tb(e,t,n){return Yg(e.api).streamSimple(e,t,n)}async function nb(e,t,n){return tb(e,t,n).result()}Xg();const ob=[/prompt is too long/i,/input is too long for requested model/i,/exceeds the context window/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/model_context_window_exceeded/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i];function rb(e,t){if("error"===e.stopReason&&e.errorMessage){if(ob.some(t=>t.test(e.errorMessage)))return!0;if(/^4(00|13)\s*(status code)?\s*\(no body\)/i.test(e.errorMessage))return!0}if(t&&"stop"===e.stopReason){if(e.usage.input+e.usage.cacheRead>t)return!0}return!1}function ib(){return[...ob]}function ab(e,t){return o.ZU.Unsafe({type:"string",enum:e,...t?.description&&{description:t.description},...t?.default&&{default:t.default}})}var sb=n(42463),cb=n(82815);const ub=sb.default||sb,lb=cb.default||cb,db="undefined"!=typeof globalThis&&void 0!==globalThis.chrome?.runtime?.id;let pb=null;if(!db)try{pb=new ub({allErrors:!0,strict:!1,coerceTypes:!0}),lb(pb)}catch(e){console.warn("AJV validation disabled due to CSP restrictions")}function hb(e,t){const n=e.find(e=>e.name===t.name);if(!n)throw new Error(`Tool "${t.name}" not found`);return fb(n,t)}function fb(e,t){if(!pb||db)return t.arguments;const n=pb.compile(e.parameters),o=structuredClone(t.arguments);if(n(o))return o;const r=n.errors?.map(e=>` - ${e.instancePath?e.instancePath.substring(1):e.params.missingProperty||"root"}: ${e.message}`).join("\n")||"Unknown validation error",i=`Validation failed for tool "${t.name}":\n${r}\n\nReceived arguments:\n${JSON.stringify(t.arguments,null,2)}`;throw new Error(i)}},63837:e=>{"use strict";e.exports=JSON.parse('{"$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON AnySchema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},72079:e=>{"use strict";e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')},66495:e=>{"use strict";e.exports=JSON.parse('{"name":"gaxios","version":"7.1.3","description":"A simple common HTTP client specifically for Google APIs and services.","main":"build/cjs/src/index.js","types":"build/cjs/src/index.d.ts","files":["build/"],"exports":{".":{"import":{"types":"./build/esm/src/index.d.ts","default":"./build/esm/src/index.js"},"require":{"types":"./build/cjs/src/index.d.ts","default":"./build/cjs/src/index.js"}}},"scripts":{"lint":"gts check --no-inline-config","test":"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000","compile":"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs","fix":"gts fix","prepare":"npm run compile","pretest":"npm run compile","webpack":"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js","docs":"jsdoc -c .jsdoc.js","docs-test":"linkinator docs","predocs-test":"npm run docs","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","prelint":"cd samples; npm link ../; npm install","clean":"gts clean"},"repository":{"type":"git","directory":"packages/gaxios","url":"https://github.com/googleapis/google-cloud-node-core.git"},"keywords":["google"],"engines":{"node":">=18"},"author":"Google, LLC","license":"Apache-2.0","devDependencies":{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.1","@types/node":"^22.0.0","@types/sinon":"^17.0.0","@types/tmp":"0.2.6","assert":"^2.0.0","browserify":"^17.0.0","c8":"^10.0.0","cors":"^2.8.5","express":"^5.0.0","gts":"^6.0.0","is-docker":"^3.0.0","jsdoc":"^4.0.0","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0","karma":"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1","linkinator":"^6.1.2","mocha":"^11.1.0","multiparty":"^4.2.1","mv":"^2.1.1","ncp":"^2.0.0","nock":"^14.0.0-beta.13","null-loader":"^4.0.0","pack-n-play":"^4.0.0","puppeteer":"^24.0.0","sinon":"^21.0.0","stream-browserify":"^3.0.0","tmp":"0.2.5","ts-loader":"^9.5.2","typescript":"^5.8.3","webpack":"^5.35.0","webpack-cli":"^6.0.1"},"dependencies":{"extend":"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2","rimraf":"^5.0.1"},"homepage":"https://github.com/googleapis/google-cloud-node-core/tree/main/packages/gaxios"}')},96066:e=>{"use strict";e.exports=JSON.parse('{"name":"google-auth-library","version":"10.6.1","author":"Google Inc.","description":"Google APIs Authentication Client Library for Node.js","engines":{"node":">=18"},"main":"./build/src/index.js","types":"./build/src/index.d.ts","repository":{"type":"git","directory":"packages/google-auth-library-nodejs","url":"https://github.com/googleapis/google-cloud-node-core.git"},"keywords":["google","api","google apis","client","client library"],"dependencies":{"base64-js":"^1.3.0","ecdsa-sig-formatter":"^1.0.11","gaxios":"7.1.3","gcp-metadata":"8.1.2","google-logging-utils":"1.1.3","jws":"^4.0.0"},"devDependencies":{"@types/base64-js":"^1.2.5","@types/jws":"^3.1.0","@types/mocha":"^10.0.10","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","assert-rejects":"^1.0.0","c8":"^10.1.3","codecov":"^3.8.3","gts":"^6.0.2","is-docker":"^3.0.0","jsdoc":"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0","karma":"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1","keypair":"^1.0.4","mocha":"^11.1.0","mv":"^2.1.1","ncp":"^2.0.0","nock":"^14.0.5","null-loader":"^4.0.1","puppeteer":"^24.0.0","sinon":"^21.0.0","ts-loader":"^9.5.2","typescript":"5.8.3","webpack":"^5.97.1","webpack-cli":"^6.0.1"},"files":["build/src","!build/src/**/*.map"],"scripts":{"test":"c8 mocha build/test","clean":"gts clean","prepare":"npm run compile","lint":"gts check --no-inline-config","compile":"tsc -p .","fix":"gts fix","pretest":"npm run compile -- --sourceMap","docs":"jsdoc -c .jsdoc.js","samples-setup":"cd samples/ && npm link ../ && npm run setup && cd ../","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","system-test":"mocha build/system-test --timeout 60000","presystem-test":"npm run compile -- --sourceMap","webpack":"webpack","browser-test":"karma start","docs-test":"echo \'disabled until linkinator is fixed\'","predocs-test":"npm run docs","prelint":"cd samples; npm link ../; npm install"},"license":"Apache-2.0","homepage":"https://github.com/googleapis/google-cloud-node-core/tree/main/packages/google-auth-library-nodejs"}')}};
|
|
324
|
+
*/class mm{get interactions(){var e;if(void 0!==this._interactions)return this._interactions;console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.");const t=this.httpOptions;(null==t?void 0:t.extraBody)&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const n=new zf({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:null==t?void 0:t.timeout,maxRetries:null===(e=null==t?void 0:t.retryOptions)||void 0===e?void 0:e.attempts});return this._interactions=n.interactions,this._interactions}constructor(e){var t,n,o,r,i,a;if((e.project||e.location)&&e.apiKey)throw new Error("Project/location and API key are mutually exclusive in the client initializer.");this.vertexai=null!==(n=null!==(t=e.vertexai)&&void 0!==t?t:function(e){return void 0!==e&&"true"===e.toLowerCase()}(gm("GOOGLE_GENAI_USE_VERTEXAI")))&&void 0!==n&&n;const s=function(){const e=gm("GOOGLE_API_KEY"),t=gm("GEMINI_API_KEY");e&&t&&console.warn("Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.");return e||t||void 0}(),c=gm("GOOGLE_CLOUD_PROJECT"),u=gm("GOOGLE_CLOUD_LOCATION");this.apiKey=null!==(o=e.apiKey)&&void 0!==o?o:s,this.project=null!==(r=e.project)&&void 0!==r?r:c,this.location=null!==(i=e.location)&&void 0!==i?i:u,this.vertexai||this.apiKey||console.warn("API key should be set when using the Gemini API."),e.vertexai&&((null===(a=e.googleAuthOptions)||void 0===a?void 0:a.credentials)&&(console.debug("The user provided Google Cloud credentials will take precedence over the API key from the environment variable."),this.apiKey=void 0),(c||u)&&e.apiKey?(console.debug("The user provided Vertex AI API key will take precedence over the project/location from the environment variables."),this.project=void 0,this.location=void 0):(e.project||e.location)&&s?(console.debug("The user provided project/location will take precedence over the API key from the environment variables."),this.apiKey=void 0):(c||u)&&s&&(console.debug("The project/location from the environment variables will take precedence over the API key from the environment variables."),this.apiKey=void 0),this.location||this.apiKey||(this.location="global"));const l=eu(e.httpOptions,e.vertexai,gm("GOOGLE_VERTEX_BASE_URL"),gm("GOOGLE_GEMINI_BASE_URL"));l&&(e.httpOptions?e.httpOptions.baseUrl=l:e.httpOptions={baseUrl:l}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const d=new Zf({apiKey:this.apiKey,googleAuthOptions:e.googleAuthOptions});this.apiClient=new fh({auth:d,project:this.project,location:this.location,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/"+process.version,uploader:new hm,downloader:new Yf}),this.models=new Rh(this.apiClient),this.live=new xh(this.apiClient,d,new Qf),this.batches=new Fd(this.apiClient),this.chats=new rp(this.models,this.apiClient),this.caches=new Kd(this.apiClient),this.files=new fm(this.apiClient),this.operations=new Ah(this.apiClient),this.authTokens=new Dh(this.apiClient),this.tunings=new cm(this.apiClient),this.fileSearchStores=new Fh(this.apiClient)}}function gm(e){var t,n,o;return null!==(o=null===(n=null===(t=null===process||void 0===process?void 0:process.env)||void 0===t?void 0:t[e])||void 0===n?void 0:n.trim())&&void 0!==o?o:void 0}function bm(e){return!0===e.thought}function ym(e,t){return"string"==typeof t&&t.length>0?t:e}const vm=/^[A-Za-z0-9+/]+={0,2}$/,_m="skip_thought_signature_validator";function wm(e,t){return e&&function(e){return!!e&&e.length%4==0&&vm.test(e)}(t)?t:void 0}function Om(e){return e.startsWith("claude-")||e.startsWith("gpt-oss-")}function Sm(e,t){const n=[],o=so(t.messages,e,t=>Om(e.id)?t.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64):t);for(const t of o)if("user"===t.role)if("string"==typeof t.content)n.push({role:"user",parts:[{text:to(t.content)}]});else{const o=t.content.map(e=>"text"===e.type?{text:to(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}}),r=e.input.includes("image")?o:o.filter(e=>void 0!==e.text);if(0===r.length)continue;n.push({role:"user",parts:r})}else if("assistant"===t.role){const o=[],r=t.provider===e.provider&&t.model===e.id;for(const n of t.content)if("text"===n.type){if(!n.text||""===n.text.trim())continue;const e=wm(r,n.textSignature);o.push({text:to(n.text),...e&&{thoughtSignature:e}})}else if("thinking"===n.type){if(!n.thinking||""===n.thinking.trim())continue;if(r){const e=wm(r,n.thinkingSignature);o.push({thought:!0,text:to(n.thinking),...e&&{thoughtSignature:e}})}else o.push({text:to(n.thinking)})}else if("toolCall"===n.type){const t=wm(r,n.thoughtSignature),i=e.id.toLowerCase().includes("gemini-3"),a=t||(i?_m:void 0),s={functionCall:{name:n.name,args:n.arguments??{},...Om(e.id)?{id:n.id}:{}},...a&&{thoughtSignature:a}};o.push(s)}if(0===o.length)continue;n.push({role:"model",parts:o})}else if("toolResult"===t.role){const o=t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),r=e.input.includes("image")?t.content.filter(e=>"image"===e.type):[],i=o.length>0,a=r.length>0,s=e.id.includes("gemini-3"),c=i?to(o):a?"(see attached image)":"",u=r.map(e=>({inlineData:{mimeType:e.mimeType,data:e.data}})),l=Om(e.id),d={functionResponse:{name:t.toolName,response:t.isError?{error:c}:{output:c},...a&&s&&{parts:u},...l?{id:t.toolCallId}:{}}},p=n[n.length-1];"user"===p?.role&&p.parts?.some(e=>e.functionResponse)?p.parts.push(d):n.push({role:"user",parts:[d]}),a&&!s&&n.push({role:"user",parts:[{text:"Tool result image:"},...u]})}return n}function xm(e,t=!1){if(0!==e.length)return[{functionDeclarations:e.map(e=>({name:e.name,description:e.description,...t?{parameters:e.parameters}:{parametersJsonSchema:e.parameters}}))}]}function Tm(e){switch(e){case"auto":default:return wu.AUTO;case"none":return wu.NONE;case"any":return wu.ANY}}function Pm(e){switch(e){case Cu.STOP:return"stop";case Cu.MAX_TOKENS:return"length";case Cu.BLOCKLIST:case Cu.PROHIBITED_CONTENT:case Cu.SPII:case Cu.SAFETY:case Cu.IMAGE_SAFETY:case Cu.IMAGE_PROHIBITED_CONTENT:case Cu.IMAGE_RECITATION:case Cu.IMAGE_OTHER:case Cu.RECITATION:case Cu.FINISH_REASON_UNSPECIFIED:case Cu.OTHER:case Cu.LANGUAGE:case Cu.MALFORMED_FUNCTION_CALL:case Cu.UNEXPECTED_TOOL_CALL:case Cu.NO_IMAGE:return"error";default:throw new Error(`Unhandled stop reason: ${e}`)}}function Cm(e){switch(e){case"STOP":return"stop";case"MAX_TOKENS":return"length";default:return"error"}}let km=0;const jm=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:"google-generative-ai",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey||b(e.provider)||"",a=function(e,t,n){const o={};e.baseUrl&&(o.baseUrl=e.baseUrl,o.apiVersion="");(e.headers||n)&&(o.headers={...e.headers,...n});return new mm({apiKey:t,httpOptions:Object.keys(o).length>0?o:void 0})}(e,i,n?.headers);let s=function(e,t,n={}){const o=Sm(e,t),r={};void 0!==n.temperature&&(r.temperature=n.temperature);void 0!==n.maxTokens&&(r.maxOutputTokens=n.maxTokens);const i={...Object.keys(r).length>0&&r,...t.systemPrompt&&{systemInstruction:to(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:xm(t.tools)}};t.tools&&t.tools.length>0&&n.toolChoice?i.toolConfig={functionCallingConfig:{mode:Tm(n.toolChoice)}}:i.toolConfig=void 0;if(n.thinking?.enabled&&e.reasoning){const e={includeThoughts:!0};void 0!==n.thinking.level?e.thinkingLevel=n.thinking.level:void 0!==n.thinking.budgetTokens&&(e.thinkingBudget=n.thinking.budgetTokens),i.thinkingConfig=e}if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");i.abortSignal=n.signal}const a={model:e.id,contents:o,config:i};return a}(e,t,n);const c=await(n?.onPayload?.(s,e));void 0!==c&&(s=c);const u=await a.models.generateContentStream(s);o.push({type:"start",partial:r});let l=null;const d=r.content,p=()=>d.length-1;for await(const t of u){const n=t.candidates?.[0];if(n?.content?.parts)for(const e of n.content.parts){if(void 0!==e.text){const t=bm(e);(!l||t&&"thinking"!==l.type||!t&&"text"!==l.type)&&(l&&("text"===l.type?o.push({type:"text_end",contentIndex:d.length-1,content:l.text,partial:r}):o.push({type:"thinking_end",contentIndex:p(),content:l.thinking,partial:r})),t?(l={type:"thinking",thinking:"",thinkingSignature:void 0},r.content.push(l),o.push({type:"thinking_start",contentIndex:p(),partial:r})):(l={type:"text",text:""},r.content.push(l),o.push({type:"text_start",contentIndex:p(),partial:r}))),"thinking"===l.type?(l.thinking+=e.text,l.thinkingSignature=ym(l.thinkingSignature,e.thoughtSignature),o.push({type:"thinking_delta",contentIndex:p(),delta:e.text,partial:r})):(l.text+=e.text,l.textSignature=ym(l.textSignature,e.thoughtSignature),o.push({type:"text_delta",contentIndex:p(),delta:e.text,partial:r}))}if(e.functionCall){l&&("text"===l.type?o.push({type:"text_end",contentIndex:p(),content:l.text,partial:r}):o.push({type:"thinking_end",contentIndex:p(),content:l.thinking,partial:r}),l=null);const t=e.functionCall.id,n=!t||r.content.some(e=>"toolCall"===e.type&&e.id===t),i={type:"toolCall",id:n?`${e.functionCall.name}_${Date.now()}_${++km}`:t,name:e.functionCall.name||"",arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(i),o.push({type:"toolcall_start",contentIndex:p(),partial:r}),o.push({type:"toolcall_delta",contentIndex:p(),delta:JSON.stringify(i.arguments),partial:r}),o.push({type:"toolcall_end",contentIndex:p(),toolCall:i,partial:r})}}n?.finishReason&&(r.stopReason=Pm(n.finishReason),r.content.some(e=>"toolCall"===e.type)&&(r.stopReason="toolUse")),t.usageMetadata&&(r.usage={input:t.usageMetadata.promptTokenCount||0,output:(t.usageMetadata.candidatesTokenCount||0)+(t.usageMetadata.thoughtsTokenCount||0),cacheRead:t.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:t.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},S(e,r.usage))}if(l&&("text"===l.type?o.push({type:"text_end",contentIndex:p(),content:l.text,partial:r}):o.push({type:"thinking_end",contentIndex:p(),content:l.thinking,partial:r})),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)"index"in e&&delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},Em=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o);if(!n?.reasoning)return jm(e,t,{...r,thinking:{enabled:!1}});const i=ao(n.reasoning),a=e;return Rm(a)||function(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}(a)?jm(e,t,{...r,thinking:{enabled:!0,level:Am(i,a)}}):jm(e,t,{...r,thinking:{enabled:!0,budgetTokens:Im(a,i,n.thinkingBudgets)}})};function Rm(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function Am(e,t){if(Rm(t))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(e){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function Im(e,t,n){if(void 0!==n?.[t])return n[t];if(e.id.includes("2.5-pro")){return{minimal:128,low:2048,medium:8192,high:32768}[t]}if(e.id.includes("2.5-flash")){return{minimal:128,low:2048,medium:8192,high:24576}[t]}return-1}const Mm="https://cloudcode-pa.googleapis.com",Nm=["https://daily-cloudcode-pa.sandbox.googleapis.com","https://autopush-cloudcode-pa.sandbox.googleapis.com",Mm],$m={"User-Agent":"google-cloud-sdk vscode_cloudshelleditor/0.1","X-Goog-Api-Client":"gl-node/22.17.0","Client-Metadata":JSON.stringify({ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"})};const Dm="You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.**Absolute paths only****Proactiveness**";let Um=0;function Lm(e,t){const n=e=>e>0?Math.ceil(e+1e3):void 0,o=t instanceof Headers?t:t?.headers;if(o){const e=o.get("retry-after");if(e){const t=Number(e);if(Number.isFinite(t)){const e=n(1e3*t);if(void 0!==e)return e}const o=new Date(e).getTime();if(!Number.isNaN(o)){const e=n(o-Date.now());if(void 0!==e)return e}}const t=o.get("x-ratelimit-reset");if(t){const e=Number.parseInt(t,10);if(!Number.isNaN(e)){const t=n(1e3*e-Date.now());if(void 0!==t)return t}}const r=o.get("x-ratelimit-reset-after");if(r){const e=Number(r);if(Number.isFinite(e)){const t=n(1e3*e);if(void 0!==t)return t}}}const r=e.match(/reset after (?:(\d+)h)?(?:(\d+)m)?(\d+(?:\.\d+)?)s/i);if(r){const e=r[1]?parseInt(r[1],10):0,t=r[2]?parseInt(r[2],10):0,o=parseFloat(r[3]);if(!Number.isNaN(o)){const r=n(1e3*(60*(60*e+t)+o));if(void 0!==r)return r}}const i=e.match(/Please retry in ([0-9.]+)(ms|s)/i);if(i?.[1]){const e=parseFloat(i[1]);if(!Number.isNaN(e)&&e>0){const t=n("ms"===i[2].toLowerCase()?e:1e3*e);if(void 0!==t)return t}}const a=e.match(/"retryDelay":\s*"([0-9.]+)(ms|s)"/i);if(a?.[1]){const e=parseFloat(a[1]);if(!Number.isNaN(e)&&e>0){const t=n("ms"===a[2].toLowerCase()?e:1e3*e);if(void 0!==t)return t}}}function qm(e){return"google-antigravity"===e.provider&&e.id.startsWith("claude-")&&e.reasoning}function Fm(e){return/gemini-3(?:\.1)?-pro/.test(e.toLowerCase())}function Wm(e,t){return 429===e||500===e||502===e||503===e||504===e||/resource.?exhausted|rate.?limit|overloaded|service.?unavailable|other.?side.?closed/i.test(t)}function Jm(e){try{const t=JSON.parse(e);if(t.error?.message)return t.error.message}catch{}return e}function Bm(e,t){return new Promise((n,o)=>{if(t?.aborted)return void o(new Error("Request was aborted"));const r=setTimeout(n,e);t?.addEventListener("abort",()=>{clearTimeout(r),o(new Error("Request was aborted"))})})}const Gm=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:"google-gemini-cli",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey;if(!i)throw new Error("Google Cloud Code Assist requires OAuth authentication. Use /login to authenticate.");let a,s;try{const e=JSON.parse(i);a=e.token,s=e.projectId}catch{throw new Error("Invalid Google Cloud Code Assist credentials. Use /login to re-authenticate.")}if(!a||!s)throw new Error("Missing token or projectId in Google Cloud credentials. Use /login to re-authenticate.");const c="google-antigravity"===e.provider,u=e.baseUrl?.trim(),l=u?[u]:c?Nm:[Mm];let d=Hm(e,t,s,n,c);const p=await(n?.onPayload?.(d,e));void 0!==p&&(d=p);const h={Authorization:`Bearer ${a}`,"Content-Type":"application/json",Accept:"text/event-stream",...c?{"User-Agent":`antigravity/${process.env.PI_AI_ANTIGRAVITY_VERSION||"1.18.4"} darwin/arm64`}:$m,...qm(e)?{"anthropic-beta":"interleaved-thinking-2025-05-14"}:{},...n?.headers},f=JSON.stringify(d);let m,g,b,y=0;for(let e=0;e<=3;e++){if(n?.signal?.aborted)throw new Error("Request was aborted");try{if(b=`${l[y]}/v1internal:streamGenerateContent?alt=sse`,m=await fetch(b,{method:"POST",headers:h,body:f,signal:n?.signal}),m.ok)break;const t=await m.text();if((403===m.status||404===m.status)&&y<l.length-1){y++;continue}if(e<3&&Wm(m.status,t)){y<l.length-1&&y++;const o=Lm(t,m),r=o??1e3*2**e,i=n?.maxRetryDelayMs??6e4;if(i>0&&o&&o>i){const e=Math.ceil(o/1e3);throw new Error(`Server requested ${e}s retry delay (max: ${Math.ceil(i/1e3)}s). ${Jm(t)}`)}await Bm(r,n?.signal);continue}throw new Error(`Cloud Code Assist API error (${m.status}): ${Jm(t)}`)}catch(t){if(t instanceof Error&&("AbortError"===t.name||"Request was aborted"===t.message))throw new Error("Request was aborted");if(g=t instanceof Error?t:new Error(String(t)),"fetch failed"===g.message&&g.cause instanceof Error&&(g=new Error(`Network error: ${g.cause.message}`)),e<3){const t=1e3*2**e;await Bm(t,n?.signal);continue}throw g}}if(!m||!m.ok)throw g??new Error("Failed to get response after retries");let v=!1;const _=()=>{v||(o.push({type:"start",partial:r}),v=!0)},w=()=>{r.content=[],r.usage={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},r.stopReason="stop",r.errorMessage=void 0,r.timestamp=Date.now(),v=!1},O=async t=>{if(!t.body)throw new Error("No response body");let i=!1,a=null;const s=r.content,c=()=>s.length-1,u=t.body.getReader(),l=new TextDecoder;let d="";const p=()=>{u.cancel().catch(()=>{})};n?.signal?.addEventListener("abort",p);try{for(;;){if(n?.signal?.aborted)throw new Error("Request was aborted");const{done:t,value:p}=await u.read();if(t)break;d+=l.decode(p,{stream:!0});const h=d.split("\n");d=h.pop()||"";for(const t of h){if(!t.startsWith("data:"))continue;const n=t.slice(5).trim();if(!n)continue;let u;try{u=JSON.parse(n)}catch{continue}const l=u.response;if(!l)continue;const d=l.candidates?.[0];if(d?.content?.parts)for(const e of d.content.parts){if(void 0!==e.text){i=!0;const t=bm(e);(!a||t&&"thinking"!==a.type||!t&&"text"!==a.type)&&(a&&("text"===a.type?o.push({type:"text_end",contentIndex:s.length-1,content:a.text,partial:r}):o.push({type:"thinking_end",contentIndex:c(),content:a.thinking,partial:r})),t?(a={type:"thinking",thinking:"",thinkingSignature:void 0},r.content.push(a),_(),o.push({type:"thinking_start",contentIndex:c(),partial:r})):(a={type:"text",text:""},r.content.push(a),_(),o.push({type:"text_start",contentIndex:c(),partial:r}))),"thinking"===a.type?(a.thinking+=e.text,a.thinkingSignature=ym(a.thinkingSignature,e.thoughtSignature),o.push({type:"thinking_delta",contentIndex:c(),delta:e.text,partial:r})):(a.text+=e.text,a.textSignature=ym(a.textSignature,e.thoughtSignature),o.push({type:"text_delta",contentIndex:c(),delta:e.text,partial:r}))}if(e.functionCall){i=!0,a&&("text"===a.type?o.push({type:"text_end",contentIndex:c(),content:a.text,partial:r}):o.push({type:"thinking_end",contentIndex:c(),content:a.thinking,partial:r}),a=null);const t=e.functionCall.id,n=!t||r.content.some(e=>"toolCall"===e.type&&e.id===t),s={type:"toolCall",id:n?`${e.functionCall.name}_${Date.now()}_${++Um}`:t,name:e.functionCall.name||"",arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(s),_(),o.push({type:"toolcall_start",contentIndex:c(),partial:r}),o.push({type:"toolcall_delta",contentIndex:c(),delta:JSON.stringify(s.arguments),partial:r}),o.push({type:"toolcall_end",contentIndex:c(),toolCall:s,partial:r})}}if(d?.finishReason&&(r.stopReason=Cm(d.finishReason),r.content.some(e=>"toolCall"===e.type)&&(r.stopReason="toolUse")),l.usageMetadata){const t=l.usageMetadata.promptTokenCount||0,n=l.usageMetadata.cachedContentTokenCount||0;r.usage={input:t-n,output:(l.usageMetadata.candidatesTokenCount||0)+(l.usageMetadata.thoughtsTokenCount||0),cacheRead:n,cacheWrite:0,totalTokens:l.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},S(e,r.usage)}}}}finally{n?.signal?.removeEventListener("abort",p)}return a&&("text"===a.type?o.push({type:"text_end",contentIndex:c(),content:a.text,partial:r}):o.push({type:"thinking_end",contentIndex:c(),content:a.thinking,partial:r})),i};let x=!1,T=m;for(let e=0;e<=2;e++){if(n?.signal?.aborted)throw new Error("Request was aborted");if(e>0){const t=500*2**(e-1);if(await Bm(t,n?.signal),!b)throw new Error("Missing request URL");if(T=await fetch(b,{method:"POST",headers:h,body:f,signal:n?.signal}),!T.ok){const e=await T.text();throw new Error(`Cloud Code Assist API error (${T.status}): ${e}`)}}if(await O(T)){x=!0;break}e<2&&w()}if(!x)throw new Error("Cloud Code Assist API returned an empty response");if(n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)"index"in e&&delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},Vm=(e,t,n)=>{const o=n?.apiKey;if(!o)throw new Error("Google Cloud Code Assist requires OAuth authentication. Use /login to authenticate.");const r=io(e,n,o);if(!n?.reasoning)return Gm(e,t,{...r,thinking:{enabled:!1}});const i=ao(n.reasoning);if(Fm(a=e.id)||function(e){return/gemini-3(?:\.1)?-flash/.test(e.toLowerCase())}(a))return Gm(e,t,{...r,thinking:{enabled:!0,level:zm(i,e.id)}});var a;let s={minimal:1024,low:2048,medium:8192,high:16384,...n.thinkingBudgets}[i];const c=Math.min((r.maxTokens||0)+s,e.maxTokens);return c<=s&&(s=Math.max(0,c-1024)),Gm(e,t,{...r,maxTokens:c,thinking:{enabled:!0,budgetTokens:s}})};function Hm(e,t,n,o={},r=!1){const i=Sm(e,t),a={};void 0!==o.temperature&&(a.temperature=o.temperature),void 0!==o.maxTokens&&(a.maxOutputTokens=o.maxTokens),o.thinking?.enabled&&e.reasoning&&(a.thinkingConfig={includeThoughts:!0},void 0!==o.thinking.level?a.thinkingConfig.thinkingLevel=o.thinking.level:void 0!==o.thinking.budgetTokens&&(a.thinkingConfig.thinkingBudget=o.thinking.budgetTokens));const s={contents:i};if(s.sessionId=o.sessionId,t.systemPrompt&&(s.systemInstruction={parts:[{text:to(t.systemPrompt)}]}),Object.keys(a).length>0&&(s.generationConfig=a),t.tools&&t.tools.length>0){const n=e.id.startsWith("claude-");s.tools=xm(t.tools,n),o.toolChoice&&(s.toolConfig={functionCallingConfig:{mode:Tm(o.toolChoice)}})}if(r){const e=s.systemInstruction?.parts??[];s.systemInstruction={role:"user",parts:[{text:Dm},{text:`Please ignore following [ignore]${Dm}[/ignore]`},...e]}}return{project:n,model:e.id,request:s,...r?{requestType:"agent"}:{},userAgent:r?"antigravity":"pi-coding-agent",requestId:`${r?"agent":"pi"}-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}}function zm(e,t){if(Fm(t))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(e){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}const Km={THINKING_LEVEL_UNSPECIFIED:Ou.THINKING_LEVEL_UNSPECIFIED,MINIMAL:Ou.MINIMAL,LOW:Ou.LOW,MEDIUM:Ou.MEDIUM,HIGH:Ou.HIGH};let Xm=0;const Zm=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:"google-vertex",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=function(e){const t=e?.project||process.env.GOOGLE_CLOUD_PROJECT||process.env.GCLOUD_PROJECT;if(!t)throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return t}(n),a=function(e){const t=e?.location||process.env.GOOGLE_CLOUD_LOCATION;if(!t)throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return t}(n),s=function(e,t,n,o){const r={};(e.headers||o)&&(r.headers={...e.headers,...o});const i=Object.values(r).some(Boolean);return new mm({vertexai:!0,project:t,location:n,apiVersion:"v1",httpOptions:i?r:void 0})}(e,i,a,n?.headers);let c=function(e,t,n={}){const o=Sm(e,t),r={};void 0!==n.temperature&&(r.temperature=n.temperature);void 0!==n.maxTokens&&(r.maxOutputTokens=n.maxTokens);const i={...Object.keys(r).length>0&&r,...t.systemPrompt&&{systemInstruction:to(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:xm(t.tools)}};t.tools&&t.tools.length>0&&n.toolChoice?i.toolConfig={functionCallingConfig:{mode:Tm(n.toolChoice)}}:i.toolConfig=void 0;if(n.thinking?.enabled&&e.reasoning){const e={includeThoughts:!0};void 0!==n.thinking.level?e.thinkingLevel=Km[n.thinking.level]:void 0!==n.thinking.budgetTokens&&(e.thinkingBudget=n.thinking.budgetTokens),i.thinkingConfig=e}if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");i.abortSignal=n.signal}const a={model:e.id,contents:o,config:i};return a}(e,t,n);const u=await(n?.onPayload?.(c,e));void 0!==u&&(c=u);const l=await s.models.generateContentStream(c);o.push({type:"start",partial:r});let d=null;const p=r.content,h=()=>p.length-1;for await(const t of l){const n=t.candidates?.[0];if(n?.content?.parts)for(const e of n.content.parts){if(void 0!==e.text){const t=bm(e);(!d||t&&"thinking"!==d.type||!t&&"text"!==d.type)&&(d&&("text"===d.type?o.push({type:"text_end",contentIndex:p.length-1,content:d.text,partial:r}):o.push({type:"thinking_end",contentIndex:h(),content:d.thinking,partial:r})),t?(d={type:"thinking",thinking:"",thinkingSignature:void 0},r.content.push(d),o.push({type:"thinking_start",contentIndex:h(),partial:r})):(d={type:"text",text:""},r.content.push(d),o.push({type:"text_start",contentIndex:h(),partial:r}))),"thinking"===d.type?(d.thinking+=e.text,d.thinkingSignature=ym(d.thinkingSignature,e.thoughtSignature),o.push({type:"thinking_delta",contentIndex:h(),delta:e.text,partial:r})):(d.text+=e.text,d.textSignature=ym(d.textSignature,e.thoughtSignature),o.push({type:"text_delta",contentIndex:h(),delta:e.text,partial:r}))}if(e.functionCall){d&&("text"===d.type?o.push({type:"text_end",contentIndex:h(),content:d.text,partial:r}):o.push({type:"thinking_end",contentIndex:h(),content:d.thinking,partial:r}),d=null);const t=e.functionCall.id,n=!t||r.content.some(e=>"toolCall"===e.type&&e.id===t),i={type:"toolCall",id:n?`${e.functionCall.name}_${Date.now()}_${++Xm}`:t,name:e.functionCall.name||"",arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(i),o.push({type:"toolcall_start",contentIndex:h(),partial:r}),o.push({type:"toolcall_delta",contentIndex:h(),delta:JSON.stringify(i.arguments),partial:r}),o.push({type:"toolcall_end",contentIndex:h(),toolCall:i,partial:r})}}n?.finishReason&&(r.stopReason=Pm(n.finishReason),r.content.some(e=>"toolCall"===e.type)&&(r.stopReason="toolUse")),t.usageMetadata&&(r.usage={input:t.usageMetadata.promptTokenCount||0,output:(t.usageMetadata.candidatesTokenCount||0)+(t.usageMetadata.thoughtsTokenCount||0),cacheRead:t.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:t.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},S(e,r.usage))}if(d&&("text"===d.type?o.push({type:"text_end",contentIndex:h(),content:d.text,partial:r}):o.push({type:"thinking_end",contentIndex:h(),content:d.thinking,partial:r})),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)"index"in e&&delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},Ym=(e,t,n)=>{const o=io(e,n,void 0);if(!n?.reasoning)return Zm(e,t,{...o,thinking:{enabled:!1}});const r=ao(n.reasoning),i=e;return Qm(i)||function(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}(i)?Zm(e,t,{...o,thinking:{enabled:!0,level:eg(r,i)}}):Zm(e,t,{...o,thinking:{enabled:!0,budgetTokens:tg(i,r,n.thinkingBudgets)}})};function Qm(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function eg(e,t){if(Qm(t))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(e){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function tg(e,t,n){if(void 0!==n?.[t])return n[t];if(e.id.includes("2.5-pro")){return{minimal:128,low:2048,medium:8192,high:32768}[t]}if(e.id.includes("2.5-flash")){return{minimal:128,low:2048,medium:8192,high:24576}[t]}return-1}var ng=n(36611);const og=(e,t,n)=>{const o=new Zn;return(async()=>{const r=function(e){return{role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()}}(e);try{const i=n?.apiKey||b(e.provider);if(!i)throw new Error(`No API key for provider: ${e.provider}`);const a=new ng.Mistral({apiKey:i,serverURL:e.baseUrl}),s=function(){const e=new Map,t=new Map;return n=>{const o=e.get(n);if(o)return o;let r=0;for(;;){const o=ig(n,r),i=t.get(o);if(!i||i===n)return e.set(n,o),t.set(o,n),o;r++}}}(),c=so(t.messages,e,e=>s(e));let u=function(e,t,n,o){const r={model:e.id,stream:!0,messages:ag(n,e.input.includes("image"))};t.tools?.length&&(r.tools=(i=t.tools,i.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.parameters,strict:!1}}))));var i;void 0!==o?.temperature&&(r.temperature=o.temperature);void 0!==o?.maxTokens&&(r.maxTokens=o.maxTokens);o?.toolChoice&&(r.toolChoice=function(e){if(!e)return;if("auto"===e||"none"===e||"any"===e||"required"===e)return e;return{type:"function",function:{name:e.function.name}}}(o.toolChoice));o?.promptMode&&(r.promptMode=o.promptMode);t.systemPrompt&&r.messages.unshift({role:"system",content:to(t.systemPrompt)});return r}(e,t,c,n);const l=await(n?.onPayload?.(u,e));void 0!==l&&(u=l);const d=await a.chat.stream(u,function(e,t){const n={};t?.signal&&(n.signal=t.signal);n.retries={strategy:"none"};const o={};e.headers&&Object.assign(o,e.headers);t?.headers&&Object.assign(o,t.headers);t?.sessionId&&!o["x-affinity"]&&(o["x-affinity"]=t.sessionId);Object.keys(o).length>0&&(n.headers=o);return n}(e,n));if(o.push({type:"start",partial:r}),await async function(e,t,n,o){let r=null;const i=t.content,a=()=>i.length-1,s=new Map,c=e=>{e&&("text"!==e.type?"thinking"===e.type&&n.push({type:"thinking_end",contentIndex:a(),content:e.thinking,partial:t}):n.push({type:"text_end",contentIndex:a(),content:e.text,partial:t}))};for await(const i of o){const o=i.data;o.usage&&(t.usage.input=o.usage.promptTokens||0,t.usage.output=o.usage.completionTokens||0,t.usage.cacheRead=0,t.usage.cacheWrite=0,t.usage.totalTokens=o.usage.totalTokens||t.usage.input+t.usage.output,S(e,t.usage));const u=o.choices[0];if(!u)continue;u.finishReason&&(t.stopReason=cg(u.finishReason));const l=u.delta;if(null!==l.content&&void 0!==l.content){const e="string"==typeof l.content?[l.content]:l.content;for(const o of e){if("string"==typeof o){const e=to(o);r&&"text"===r.type||(c(r),r={type:"text",text:""},t.content.push(r),n.push({type:"text_start",contentIndex:a(),partial:t})),r.text+=e,n.push({type:"text_delta",contentIndex:a(),delta:e,partial:t});continue}if("thinking"===o.type){const e=to(o.thinking.map(e=>"text"in e?e.text:"").filter(e=>e.length>0).join(""));if(!e)continue;r&&"thinking"===r.type||(c(r),r={type:"thinking",thinking:""},t.content.push(r),n.push({type:"thinking_start",contentIndex:a(),partial:t})),r.thinking+=e,n.push({type:"thinking_delta",contentIndex:a(),delta:e,partial:t});continue}if("text"===o.type){const e=to(o.text);r&&"text"===r.type||(c(r),r={type:"text",text:""},t.content.push(r),n.push({type:"text_start",contentIndex:a(),partial:t})),r.text+=e,n.push({type:"text_delta",contentIndex:a(),delta:e,partial:t})}}}const d=l.toolCalls||[];for(const e of d){r&&(c(r),r=null);const o=e.id&&"null"!==e.id?e.id:ig(`toolcall:${e.index??0}`,0),i=`${o}:${e.index||0}`,a=s.get(i);let u;if(void 0!==a){const e=t.content[a];"toolCall"===e?.type&&(u=e)}u||(u={type:"toolCall",id:o,name:e.function.name,arguments:{},partialArgs:""},t.content.push(u),s.set(i,t.content.length-1),n.push({type:"toolcall_start",contentIndex:t.content.length-1,partial:t}));const l="string"==typeof e.function.arguments?e.function.arguments:JSON.stringify(e.function.arguments||{});u.partialArgs=(u.partialArgs||"")+l,u.arguments=eo(u.partialArgs),n.push({type:"toolcall_delta",contentIndex:s.get(i),delta:l,partial:t})}}c(r);for(const e of s.values()){const o=t.content[e];if("toolCall"!==o.type)continue;const r=o;r.arguments=eo(r.partialArgs),delete r.partialArgs,n.push({type:"toolcall_end",contentIndex:e,toolCall:r,partial:t})}}(e,r,o,d),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=function(e){if(e instanceof Error){const o=e,r="number"==typeof o.statusCode?o.statusCode:void 0,i="string"==typeof o.body?o.body.trim():void 0;return void 0!==r&&i?`Mistral API error (${r}): ${t=i,n=4e3,t.length<=n?t:`${t.slice(0,n)}... [truncated ${t.length-n} chars]`}`:void 0!==r?`Mistral API error (${r}): ${e.message}`:e.message}var t,n;return function(e){try{const t=JSON.stringify(e);return void 0===t?String(e):t}catch{return String(e)}}(e)}(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},rg=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=ao(n?.reasoning);return og(e,t,{...r,promptMode:e.reasoning&&i?"reasoning":void 0})};function ig(e,t){const n=e.replace(/[^a-zA-Z0-9]/g,"");if(0===t&&9===n.length)return n;const o=n||e;return Ac(0===t?o:`${o}:${t}`).replace(/[^a-zA-Z0-9]/g,"").slice(0,9)}function ag(e,t){const n=[];for(const o of e){if("user"===o.role){if("string"==typeof o.content){n.push({role:"user",content:to(o.content)});continue}const e=o.content.some(e=>"image"===e.type),r=o.content.filter(e=>"text"===e.type||t).map(e=>"text"===e.type?{type:"text",text:to(e.text)}:{type:"image_url",imageUrl:`data:${e.mimeType};base64,${e.data}`});if(r.length>0){n.push({role:"user",content:r});continue}e&&!t&&n.push({role:"user",content:"(image omitted: model does not support images)"});continue}if("assistant"===o.role){const e=[],t=[];for(const n of o.content)"text"!==n.type?"thinking"!==n.type?t.push({id:n.id,type:"function",function:{name:n.name,arguments:JSON.stringify(n.arguments||{})}}):n.thinking.trim().length>0&&e.push({type:"thinking",thinking:[{type:"text",text:to(n.thinking)}]}):n.text.trim().length>0&&e.push({type:"text",text:to(n.text)});const r={role:"assistant"};e.length>0&&(r.content=e),t.length>0&&(r.toolCalls=t),(e.length>0||t.length>0)&&n.push(r);continue}const e=[],r=sg(o.content.filter(e=>"text"===e.type).map(e=>"text"===e.type?to(e.text):"").join("\n"),o.content.some(e=>"image"===e.type),t,o.isError);e.push({type:"text",text:r});for(const n of o.content)t&&"image"===n.type&&e.push({type:"image_url",imageUrl:`data:${n.mimeType};base64,${n.data}`});n.push({role:"tool",toolCallId:o.toolCallId,name:o.toolName,content:e})}return n}function sg(e,t,n,o){const r=e.trim(),i=o?"[tool error] ":"";if(r.length>0){return`${i}${r}${t&&!n?"\n[tool image omitted: model does not support images]":""}`}return t?n?o?"[tool error] (see attached image)":"(see attached image)":o?"[tool error] (image omitted: model does not support images)":"(image omitted: model does not support images)":o?"[tool error] (no tool output)":"(no tool output)"}function cg(e){if(null===e)return"stop";switch(e){case"stop":default:return"stop";case"length":case"model_length":return"length";case"tool_calls":return"toolUse";case"error":return"error"}}const ug=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey||b(e.provider)||"",a=function(e,t,n,o){if(!n){if(!process.env.OPENAI_API_KEY)throw new Error("OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.");n=process.env.OPENAI_API_KEY}const r={...e.headers};if("github-copilot"===e.provider){const e=oo(t.messages),n=ro({messages:t.messages,hasImages:e});Object.assign(r,n)}o&&Object.assign(r,o);return new jc({apiKey:n,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:r})}(e,t,i,n?.headers);let s=function(e,t,n){const o=function(e){const t=function(e){const t=e.provider,n=e.baseUrl,o="zai"===t||n.includes("api.z.ai"),r="cerebras"===t||n.includes("cerebras.ai")||"xai"===t||n.includes("api.x.ai")||n.includes("chutes.ai")||n.includes("deepseek.com")||o||"opencode"===t||n.includes("opencode.ai"),i=n.includes("chutes.ai"),a="xai"===t||n.includes("api.x.ai"),s="groq"!==t&&!n.includes("groq.com")||"qwen/qwen3-32b"!==e.id?{}:{minimal:"default",low:"default",medium:"default",high:"default",xhigh:"default"};return{supportsStore:!r,supportsDeveloperRole:!r,supportsReasoningEffort:!a&&!o,reasoningEffortMap:s,supportsUsageInStreaming:!0,maxTokensField:i?"max_tokens":"max_completion_tokens",requiresToolResultName:!1,requiresAssistantAfterToolResult:!1,requiresThinkingAsText:!1,thinkingFormat:o?"zai":"openai",openRouterRouting:{},vercelGatewayRouting:{},supportsStrictMode:!0}}(e);return e.compat?{supportsStore:e.compat.supportsStore??t.supportsStore,supportsDeveloperRole:e.compat.supportsDeveloperRole??t.supportsDeveloperRole,supportsReasoningEffort:e.compat.supportsReasoningEffort??t.supportsReasoningEffort,reasoningEffortMap:e.compat.reasoningEffortMap??t.reasoningEffortMap,supportsUsageInStreaming:e.compat.supportsUsageInStreaming??t.supportsUsageInStreaming,maxTokensField:e.compat.maxTokensField??t.maxTokensField,requiresToolResultName:e.compat.requiresToolResultName??t.requiresToolResultName,requiresAssistantAfterToolResult:e.compat.requiresAssistantAfterToolResult??t.requiresAssistantAfterToolResult,requiresThinkingAsText:e.compat.requiresThinkingAsText??t.requiresThinkingAsText,thinkingFormat:e.compat.thinkingFormat??t.thinkingFormat,openRouterRouting:e.compat.openRouterRouting??{},vercelGatewayRouting:e.compat.vercelGatewayRouting??t.vercelGatewayRouting,supportsStrictMode:e.compat.supportsStrictMode??t.supportsStrictMode}:t}(e),r=dg(e,t,o);!function(e,t){if("openrouter"!==e.provider||!e.id.startsWith("anthropic/"))return;for(let e=t.length-1;e>=0;e--){const n=t[e];if("user"!==n.role&&"assistant"!==n.role)continue;const o=n.content;if("string"==typeof o)return void(n.content=[Object.assign({type:"text",text:o},{cache_control:{type:"ephemeral"}})]);if(Array.isArray(o))for(let e=o.length-1;e>=0;e--){const t=o[e];if("text"===t?.type)return void Object.assign(t,{cache_control:{type:"ephemeral"}})}}}(e,r);const i={model:e.id,messages:r,stream:!0};!1!==o.supportsUsageInStreaming&&(i.stream_options={include_usage:!0});o.supportsStore&&(i.store=!1);n?.maxTokens&&("max_tokens"===o.maxTokensField?i.max_tokens=n.maxTokens:i.max_completion_tokens=n.maxTokens);void 0!==n?.temperature&&(i.temperature=n.temperature);t.tools?i.tools=function(e,t){return e.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.parameters,...!1!==t.supportsStrictMode&&{strict:!1}}}))}(t.tools,o):function(e){for(const t of e){if("toolResult"===t.role)return!0;if("assistant"===t.role&&t.content.some(e=>"toolCall"===e.type))return!0}return!1}(t.messages)&&(i.tools=[]);n?.toolChoice&&(i.tool_choice=n.toolChoice);"zai"!==o.thinkingFormat&&"qwen"!==o.thinkingFormat||!e.reasoning?n?.reasoningEffort&&e.reasoning&&o.supportsReasoningEffort&&(i.reasoning_effort=(a=n.reasoningEffort,o.reasoningEffortMap[a]??a)):i.enable_thinking=!!n?.reasoningEffort;var a;e.baseUrl.includes("openrouter.ai")&&e.compat?.openRouterRouting&&(i.provider=e.compat.openRouterRouting);if(e.baseUrl.includes("ai-gateway.vercel.sh")&&e.compat?.vercelGatewayRouting){const t=e.compat.vercelGatewayRouting;if(t.only||t.order){const e={};t.only&&(e.only=t.only),t.order&&(e.order=t.order),i.providerOptions={gateway:e}}}return i}(e,t,n);const c=await(n?.onPayload?.(s,e));void 0!==c&&(s=c);const u=await a.chat.completions.create(s,{signal:n?.signal});o.push({type:"start",partial:r});let l=null;const d=r.content,p=()=>d.length-1,h=e=>{e&&("text"===e.type?o.push({type:"text_end",contentIndex:p(),content:e.text,partial:r}):"thinking"===e.type?o.push({type:"thinking_end",contentIndex:p(),content:e.thinking,partial:r}):"toolCall"===e.type&&(e.arguments=eo(e.partialArgs),delete e.partialArgs,o.push({type:"toolcall_end",contentIndex:p(),toolCall:e,partial:r})))};for await(const t of u){if(t.usage){const n=t.usage.prompt_tokens_details?.cached_tokens||0,o=t.usage.completion_tokens_details?.reasoning_tokens||0,i=(t.usage.prompt_tokens||0)-n,a=(t.usage.completion_tokens||0)+o;r.usage={input:i,output:a,cacheRead:n,cacheWrite:0,totalTokens:i+a+n,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},S(e,r.usage)}const n=t.choices?.[0];if(n&&(n.finish_reason&&(r.stopReason=pg(n.finish_reason)),n.delta)){null!==n.delta.content&&void 0!==n.delta.content&&n.delta.content.length>0&&(l&&"text"===l.type||(h(l),l={type:"text",text:""},r.content.push(l),o.push({type:"text_start",contentIndex:p(),partial:r})),"text"===l.type&&(l.text+=n.delta.content,o.push({type:"text_delta",contentIndex:p(),delta:n.delta.content,partial:r})));const e=["reasoning_content","reasoning","reasoning_text"];let t=null;for(const o of e)if(null!==n.delta[o]&&void 0!==n.delta[o]&&n.delta[o].length>0&&!t){t=o;break}if(t&&(l&&"thinking"===l.type||(h(l),l={type:"thinking",thinking:"",thinkingSignature:t},r.content.push(l),o.push({type:"thinking_start",contentIndex:p(),partial:r})),"thinking"===l.type)){const e=n.delta[t];l.thinking+=e,o.push({type:"thinking_delta",contentIndex:p(),delta:e,partial:r})}if(n?.delta?.tool_calls)for(const e of n.delta.tool_calls)if((!l||"toolCall"!==l.type||e.id&&l.id!==e.id)&&(h(l),l={type:"toolCall",id:e.id||"",name:e.function?.name||"",arguments:{},partialArgs:""},r.content.push(l),o.push({type:"toolcall_start",contentIndex:p(),partial:r})),"toolCall"===l.type){e.id&&(l.id=e.id),e.function?.name&&(l.name=e.function.name);let t="";e.function?.arguments&&(t=e.function.arguments,l.partialArgs+=e.function.arguments,l.arguments=eo(l.partialArgs)),o.push({type:"toolcall_delta",contentIndex:p(),delta:t,partial:r})}const i=n.delta.reasoning_details;if(i&&Array.isArray(i))for(const e of i)if("reasoning.encrypted"===e.type&&e.id&&e.data){const t=r.content.find(t=>"toolCall"===t.type&&t.id===e.id);t&&(t.thoughtSignature=JSON.stringify(e))}}}if(h(l),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e);const t=e?.error?.metadata?.raw;t&&(r.errorMessage+=`\n${t}`),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},lg=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=x(e)?n?.reasoning:ao(n?.reasoning),a=n?.toolChoice;return ug(e,t,{...r,reasoningEffort:i,toolChoice:a})};function dg(e,t,n){const o=[],r=so(t.messages,e,t=>(t=>{if(t.includes("|")){const[e]=t.split("|");return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,40)}return"openai"===e.provider&&t.length>40?t.slice(0,40):t})(t));if(t.systemPrompt){const r=e.reasoning&&n.supportsDeveloperRole?"developer":"system";o.push({role:r,content:to(t.systemPrompt)})}let i=null;for(let t=0;t<r.length;t++){const a=r[t];if(n.requiresAssistantAfterToolResult&&"toolResult"===i&&"user"===a.role&&o.push({role:"assistant",content:"I have processed the tool results."}),"user"===a.role)if("string"==typeof a.content)o.push({role:"user",content:to(a.content)});else{const t=a.content.map(e=>"text"===e.type?{type:"text",text:to(e.text)}:{type:"image_url",image_url:{url:`data:${e.mimeType};base64,${e.data}`}}),n=e.input.includes("image")?t:t.filter(e=>"image_url"!==e.type);if(0===n.length)continue;o.push({role:"user",content:n})}else if("assistant"===a.role){const t={role:"assistant",content:n.requiresAssistantAfterToolResult?"":null},r=a.content.filter(e=>"text"===e.type).filter(e=>e.text&&e.text.trim().length>0);r.length>0&&("github-copilot"===e.provider?t.content=r.map(e=>to(e.text)).join(""):t.content=r.map(e=>({type:"text",text:to(e.text)})));const i=a.content.filter(e=>"thinking"===e.type).filter(e=>e.thinking&&e.thinking.trim().length>0);if(i.length>0)if(n.requiresThinkingAsText){const e=i.map(e=>e.thinking).join("\n\n"),n=t.content;n?n.unshift({type:"text",text:e}):t.content=[{type:"text",text:e}]}else{const e=i[0].thinkingSignature;e&&e.length>0&&(t[e]=i.map(e=>e.thinking).join("\n"))}const s=a.content.filter(e=>"toolCall"===e.type);if(s.length>0){t.tool_calls=s.map(e=>({id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.arguments)}}));const e=s.filter(e=>e.thoughtSignature).map(e=>{try{return JSON.parse(e.thoughtSignature)}catch{return null}}).filter(Boolean);e.length>0&&(t.reasoning_details=e)}const c=t.content;if(!(null!=c&&c.length>0)&&!t.tool_calls)continue;o.push(t)}else if("toolResult"===a.role){const a=[];let s=t;for(;s<r.length&&"toolResult"===r[s].role;s++){const t=r[s],i=t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),c=t.content.some(e=>"image"===e.type),u={role:"tool",content:to(i.length>0?i:"(see attached image)"),tool_call_id:t.toolCallId};if(n.requiresToolResultName&&t.toolName&&(u.name=t.toolName),o.push(u),c&&e.input.includes("image"))for(const e of t.content)"image"===e.type&&a.push({type:"image_url",image_url:{url:`data:${e.mimeType};base64,${e.data}`}})}t=s-1,a.length>0?(n.requiresAssistantAfterToolResult&&o.push({role:"assistant",content:"I have processed the tool results."}),o.push({role:"user",content:[{type:"text",text:"Attached image(s) from tool result:"},...a]}),i="user"):i="toolResult";continue}i=a.role}return o}function pg(e){if(null===e)return"stop";switch(e){case"stop":return"stop";case"length":return"length";case"function_call":case"tool_calls":return"toolUse";case"content_filter":return"error";default:throw new Error(`Unhandled stop reason: ${e}`)}}const hg=new Set(["openai","openai-codex","opencode"]);function fg(e,t){if("long"===t)return e.includes("api.openai.com")?"24h":void 0}const mg=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey||b(e.provider)||"",a=function(e,t,n,o){if(!n){if(!process.env.OPENAI_API_KEY)throw new Error("OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.");n=process.env.OPENAI_API_KEY}const r={...e.headers};if("github-copilot"===e.provider){const e=oo(t.messages),n=ro({messages:t.messages,hasImages:e});Object.assign(r,n)}o&&Object.assign(r,o);return new jc({apiKey:n,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:r})}(e,t,i,n?.headers);let s=function(e,t,n){const o=Nc(e,t,hg),r=function(e){return e||("undefined"!=typeof process&&"long"===process.env.PI_CACHE_RETENTION?"long":"short")}(n?.cacheRetention),i={model:e.id,input:o,stream:!0,prompt_cache_key:"none"===r?void 0:n?.sessionId,prompt_cache_retention:fg(e.baseUrl,r),store:!1};n?.maxTokens&&(i.max_output_tokens=n?.maxTokens);void 0!==n?.temperature&&(i.temperature=n?.temperature);void 0!==n?.serviceTier&&(i.service_tier=n.serviceTier);t.tools&&(i.tools=$c(t.tools));e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||"medium",summary:n?.reasoningSummary||"auto"},i.include=["reasoning.encrypted_content"]):e.name.startsWith("gpt-5")&&o.push({role:"developer",content:[{type:"input_text",text:"# Juice: 0 !important"}]}));return i}(e,t,n);const c=await(n?.onPayload?.(s,e));void 0!==c&&(s=c);const u=await a.responses.create(s,n?.signal?{signal:n.signal}:void 0);if(o.push({type:"start",partial:r}),await Dc(u,r,o,e,{serviceTier:n?.serviceTier,applyServiceTierPricing:bg}),n?.signal?.aborted)throw new Error("Request was aborted");if("aborted"===r.stopReason||"error"===r.stopReason)throw new Error("An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){for(const e of r.content)delete e.index;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},gg=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=x(e)?n?.reasoning:ao(n?.reasoning);return mg(e,t,{...r,reasoningEffort:i})};function bg(e,t){const n=function(e){switch(e){case"flex":return.5;case"priority":return 2;default:return 1}}(t);1!==n&&(e.cost.input*=n,e.cost.output*=n,e.cost.cacheRead*=n,e.cost.cacheWrite*=n,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite)}let yg=null;var vg;"undefined"!=typeof process&&(process.versions?.node||process.versions?.bun)&&(vg="os",n(84005)(vg)).then(e=>{yg=e});const _g="https://api.openai.com/auth",wg=new Set(["openai","openai-codex","opencode"]),Og=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function Sg(e,t){return 429===e||500===e||502===e||503===e||504===e||/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(t)}function xg(e,t){return new Promise((n,o)=>{if(t?.aborted)return void o(new Error("Request was aborted"));const r=setTimeout(n,e);t?.addEventListener("abort",()=>{clearTimeout(r),o(new Error("Request was aborted"))})})}const Tg=(e,t,n)=>{const o=new Zn;return(async()=>{const r={role:"assistant",content:[],api:"openai-codex-responses",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const i=n?.apiKey||b(e.provider)||"";if(!i)throw new Error(`No API key for provider: ${e.provider}`);const a=function(e){try{const t=e.split(".");if(3!==t.length)throw new Error("Invalid token");const n=JSON.parse(atob(t[1])),o=n?.[_g]?.chatgpt_account_id;if(!o)throw new Error("No account ID in token");return o}catch{throw new Error("Failed to extract accountId from token")}}(i);let s=function(e,t,n){const o=Nc(e,t,wg,{includeSystemPrompt:!1}),r={model:e.id,store:!1,stream:!0,instructions:t.systemPrompt,input:o,text:{verbosity:n?.textVerbosity||"medium"},include:["reasoning.encrypted_content"],prompt_cache_key:n?.sessionId,tool_choice:"auto",parallel_tool_calls:!0};void 0!==n?.temperature&&(r.temperature=n.temperature);t.tools&&(r.tools=$c(t.tools,{strict:null}));void 0!==n?.reasoningEffort&&(r.reasoning={effort:Cg(e.id,n.reasoningEffort),summary:n.reasoningSummary??"auto"});return r}(e,t,n);const c=await(n?.onPayload?.(s,e));void 0!==c&&(s=c);const u=function(e,t,n,o,r){const i=new Headers(e);i.set("Authorization",`Bearer ${o}`),i.set("chatgpt-account-id",n),i.set("OpenAI-Beta","responses=experimental"),i.set("originator","pi");const a=yg?`pi (${yg.platform()} ${yg.release()}; ${yg.arch()})`:"pi (browser)";i.set("User-Agent",a),i.set("accept","text/event-stream"),i.set("content-type","application/json");for(const[e,n]of Object.entries(t||{}))i.set(e,n);r&&i.set("session_id",r);return i}(e.headers,n?.headers,a,i,n?.sessionId),l=JSON.stringify(s),d=n?.transport||"sse";if("sse"!==d){let t=!1;try{if(await async function(e,t,n,o,r,i,a,s){const{socket:c,release:u}=await async function(e,t,n,o){if(!n){const n=await Dg(e,t,o);return{socket:n,release:({keep:e}={})=>{Ng(n)}}}const r=Ig.get(n);if(r){if(r.idleTimer&&(clearTimeout(r.idleTimer),r.idleTimer=void 0),!r.busy&&Mg(r.socket))return r.busy=!0,{socket:r.socket,release:({keep:e}={})=>{if(!e||!Mg(r.socket))return Ng(r.socket),void Ig.delete(n);r.busy=!1,$g(n,r)}};if(r.busy){const n=await Dg(e,t,o);return{socket:n,release:()=>{Ng(n)}}}Mg(r.socket)||(Ng(r.socket),Ig.delete(n))}const i=await Dg(e,t,o),a={socket:i,busy:!0};return Ig.set(n,a),{socket:i,release:({keep:e}={})=>{if(!e||!Mg(a.socket))return Ng(a.socket),a.idleTimer&&clearTimeout(a.idleTimer),void(Ig.get(n)===a&&Ig.delete(n));a.busy=!1,$g(n,a)}}}(e,n,s?.sessionId,s?.signal);let l=!0;try{c.send(JSON.stringify({type:"response.create",...t})),a(),r.push({type:"start",partial:o}),await Dc(jg(async function*(e,t){const n=[];let o=null,r=!1,i=null,a=!1;const s=()=>{if(!o)return;const e=o;o=null,e()},c=e=>{(async()=>{if(!e||"object"!=typeof e||!("data"in e))return;const t=await async function(e){if("string"==typeof e)return e;if(e instanceof ArrayBuffer)return(new TextDecoder).decode(new Uint8Array(e));if(ArrayBuffer.isView(e)){const t=e;return(new TextDecoder).decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}if(e&&"object"==typeof e&&"arrayBuffer"in e){const t=e,n=await t.arrayBuffer();return(new TextDecoder).decode(new Uint8Array(n))}return null}(e.data);if(t)try{const e=JSON.parse(t),o="string"==typeof e.type?e.type:"";"response.completed"!==o&&"response.done"!==o||(a=!0,r=!0),n.push(e),s()}catch{}})()},u=e=>{i=Ug(e),r=!0,s()},l=e=>{if(a)return r=!0,void s();i||(i=Lg(e)),r=!0,s()},d=()=>{i=new Error("Request was aborted"),r=!0,s()};e.addEventListener("message",c),e.addEventListener("error",u),e.addEventListener("close",l),t?.addEventListener("abort",d);try{for(;;){if(t?.aborted)throw new Error("Request was aborted");if(n.length>0)yield n.shift();else{if(r)break;await new Promise(e=>{o=e})}}if(i)throw i;if(!a)throw new Error("WebSocket stream closed before response.completed")}finally{e.removeEventListener("message",c),e.removeEventListener("error",u),e.removeEventListener("close",l),t?.removeEventListener("abort",d)}}(c,s?.signal)),o,r,i),s?.signal?.aborted&&(l=!1)}catch(e){throw l=!1,e}finally{u({keep:l})}}(function(e){const t=new URL(kg(e));"https:"===t.protocol&&(t.protocol="wss:");"http:"===t.protocol&&(t.protocol="ws:");return t.toString()}(e.baseUrl),s,u,r,o,e,()=>{t=!0},n),n?.signal?.aborted)throw new Error("Request was aborted");return o.push({type:"done",reason:r.stopReason,message:r}),void o.end()}catch(e){if("websocket"===d||t)throw e}}let p,h;for(let t=0;t<=3;t++){if(n?.signal?.aborted)throw new Error("Request was aborted");try{if(p=await fetch(kg(e.baseUrl),{method:"POST",headers:u,body:l,signal:n?.signal}),p.ok)break;const o=await p.text();if(t<3&&Sg(p.status,o)){const e=1e3*2**t;await xg(e,n?.signal);continue}const r=new Response(o,{status:p.status,statusText:p.statusText}),i=await qg(r);throw new Error(i.friendlyMessage||i.message)}catch(e){if(e instanceof Error&&("AbortError"===e.name||"Request was aborted"===e.message))throw new Error("Request was aborted");if(h=e instanceof Error?e:new Error(String(e)),t<3&&!h.message.includes("usage limit")){const e=1e3*2**t;await xg(e,n?.signal);continue}throw h}}if(!p?.ok)throw h??new Error("Failed after retries");if(!p.body)throw new Error("No response body");if(o.push({type:"start",partial:r}),await async function(e,t,n,o){await Dc(jg(async function*(e){if(!e.body)return;const t=e.body.getReader(),n=new TextDecoder;let o="";for(;;){const{done:e,value:r}=await t.read();if(e)break;o+=n.decode(r,{stream:!0});let i=o.indexOf("\n\n");for(;-1!==i;){const e=o.slice(0,i);o=o.slice(i+2);const t=e.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trim());if(t.length>0){const e=t.join("\n").trim();if(e&&"[DONE]"!==e)try{yield JSON.parse(e)}catch{}}i=o.indexOf("\n\n")}}}(e)),t,n,o)}(p,r,o,e),n?.signal?.aborted)throw new Error("Request was aborted");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=e instanceof Error?e.message:String(e),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},Pg=(e,t,n)=>{const o=n?.apiKey||b(e.provider);if(!o)throw new Error(`No API key for provider: ${e.provider}`);const r=io(e,n,o),i=x(e)?n?.reasoning:ao(n?.reasoning);return Tg(e,t,{...r,reasoningEffort:i})};function Cg(e,t){const n=e.includes("/")?e.split("/").pop():e;return(n.startsWith("gpt-5.2")||n.startsWith("gpt-5.3")||n.startsWith("gpt-5.4"))&&"minimal"===t?"low":"gpt-5.1"===n&&"xhigh"===t?"high":"gpt-5.1-codex-mini"===n?"high"===t||"xhigh"===t?"high":"medium":t}function kg(e){const t=(e&&e.trim().length>0?e:"https://chatgpt.com/backend-api").replace(/\/+$/,"");return t.endsWith("/codex/responses")?t:t.endsWith("/codex")?`${t}/responses`:`${t}/codex/responses`}async function*jg(e){for await(const t of e){const e="string"==typeof t.type?t.type:void 0;if(e){if("error"===e){const e=t.code||"",n=t.message||"";throw new Error(`Codex error: ${n||e||JSON.stringify(t)}`)}if("response.failed"===e){const e=t.response?.error?.message;throw new Error(e||"Codex response failed")}if("response.done"===e||"response.completed"===e){const e=t.response,n=e?{...e,status:Eg(e.status)}:e;yield{...t,type:"response.completed",response:n};continue}yield t}}}function Eg(e){if("string"==typeof e)return Og.has(e)?e:void 0}const Rg="responses_websockets=2026-02-06",Ag=3e5,Ig=new Map;function Mg(e){const t=function(e){const t=e.readyState;return"number"==typeof t?t:void 0}(e);return void 0===t||1===t}function Ng(e,t=1e3,n="done"){try{e.close(t,n)}catch{}}function $g(e,t){t.idleTimer&&clearTimeout(t.idleTimer),t.idleTimer=setTimeout(()=>{t.busy||(Ng(t.socket,1e3,"idle_timeout"),Ig.delete(e))},Ag)}async function Dg(e,t,n){const o=function(){const e=globalThis.WebSocket;return"function"!=typeof e?null:e}();if(!o)throw new Error("WebSocket transport is not available in this runtime");const r=function(e){const t={};for(const[n,o]of e.entries())t[n]=o;return t}(t);return r["OpenAI-Beta"]=Rg,new Promise((t,i)=>{let a,s=!1;try{a=new o(e,{headers:r})}catch(e){return void i(e instanceof Error?e:new Error(String(e)))}const c=()=>{s||(s=!0,p(),t(a))},u=e=>{s||(s=!0,p(),i(Ug(e)))},l=e=>{s||(s=!0,p(),i(Lg(e)))},d=()=>{s||(s=!0,p(),a.close(1e3,"aborted"),i(new Error("Request was aborted")))},p=()=>{a.removeEventListener("open",c),a.removeEventListener("error",u),a.removeEventListener("close",l),n?.removeEventListener("abort",d)};a.addEventListener("open",c),a.addEventListener("error",u),a.addEventListener("close",l),n?.addEventListener("abort",d)})}function Ug(e){if(e&&"object"==typeof e&&"message"in e){const t=e.message;if("string"==typeof t&&t.length>0)return new Error(t)}return new Error("WebSocket error")}function Lg(e){if(e&&"object"==typeof e){const t="code"in e?e.code:void 0,n="reason"in e?e.reason:void 0,o="number"==typeof t?` ${t}`:"",r="string"==typeof n&&n.length>0?` ${n}`:"";return new Error(`WebSocket closed${o}${r}`.trim())}return new Error("WebSocket closed")}async function qg(e){const t=await e.text();let n,o=t||e.statusText||"Request failed";try{const r=JSON.parse(t),i=r?.error;if(i){const t=i.code||i.type||"";if(/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(t)||429===e.status){const e=i.plan_type?` (${i.plan_type.toLowerCase()} plan)`:"",t=i.resets_at?Math.max(0,Math.round((1e3*i.resets_at-Date.now())/6e4)):void 0;n=`You have hit your ChatGPT usage limit${e}.${void 0!==t?` Try again in ~${t} min.`:""}`.trim()}o=i.message||n||o}}catch{}return{message:o,friendlyMessage:n}}const Fg=e=>n(84005)(e),Wg="./amazon-bedrock.js";let Jg;function Bg(e){Jg=e}async function Gg(){if(Jg)return Jg;return await Fg(Wg)}function Vg(e,t){(async()=>{for await(const n of t)e.push(n);e.end()})()}function Hg(e,t){return{role:"assistant",content:[],api:"bedrock-converse-stream",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function zg(e,t,n){const o=new Zn;return Gg().then(r=>{const i=r.streamBedrock(e,t,n);Vg(o,i)}).catch(t=>{const n=Hg(e,t);o.push({type:"error",reason:"error",error:n}),o.end(n)}),o}function Kg(e,t,n){const o=new Zn;return Gg().then(r=>{const i=r.streamSimpleBedrock(e,t,n);Vg(o,i)}).catch(t=>{const n=Hg(e,t);o.push({type:"error",reason:"error",error:n}),o.end(n)}),o}function Xg(){s({api:"anthropic-messages",stream:mo,streamSimple:bo}),s({api:"openai-completions",stream:ug,streamSimple:lg}),s({api:"mistral-conversations",stream:og,streamSimple:rg}),s({api:"openai-responses",stream:mg,streamSimple:gg}),s({api:"azure-openai-responses",stream:Fc,streamSimple:Wc}),s({api:"openai-codex-responses",stream:Tg,streamSimple:Pg}),s({api:"google-generative-ai",stream:jm,streamSimple:Em}),s({api:"google-gemini-cli",stream:Gm,streamSimple:Vm}),s({api:"google-vertex",stream:Zm,streamSimple:Ym}),s({api:"bedrock-converse-stream",stream:zg,streamSimple:Kg})}function Zg(){d(),Xg()}function Yg(e){const t=c(e);if(!t)throw new Error(`No API provider registered for api: ${e}`);return t}function Qg(e,t,n){return Yg(e.api).stream(e,t,n)}async function eb(e,t,n){return Qg(e,t,n).result()}function tb(e,t,n){return Yg(e.api).streamSimple(e,t,n)}async function nb(e,t,n){return tb(e,t,n).result()}Xg();const ob=[/prompt is too long/i,/input is too long for requested model/i,/exceeds the context window/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/model_context_window_exceeded/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i];function rb(e,t){if("error"===e.stopReason&&e.errorMessage){if(ob.some(t=>t.test(e.errorMessage)))return!0;if(/^4(00|13)\s*(status code)?\s*\(no body\)/i.test(e.errorMessage))return!0}if(t&&"stop"===e.stopReason){if(e.usage.input+e.usage.cacheRead>t)return!0}return!1}function ib(){return[...ob]}function ab(e,t){return o.ZU.Unsafe({type:"string",enum:e,...t?.description&&{description:t.description},...t?.default&&{default:t.default}})}var sb=n(42463),cb=n(82815);const ub=sb.default||sb,lb=cb.default||cb,db="undefined"!=typeof globalThis&&void 0!==globalThis.chrome?.runtime?.id;let pb=null;if(!db)try{pb=new ub({allErrors:!0,strict:!1,coerceTypes:!0}),lb(pb)}catch(e){console.warn("AJV validation disabled due to CSP restrictions")}function hb(e,t){const n=e.find(e=>e.name===t.name);if(!n)throw new Error(`Tool "${t.name}" not found`);return fb(n,t)}function fb(e,t){if(!pb||db)return t.arguments;const n=pb.compile(e.parameters),o=structuredClone(t.arguments);if(n(o))return o;const r=n.errors?.map(e=>` - ${e.instancePath?e.instancePath.substring(1):e.params.missingProperty||"root"}: ${e.message}`).join("\n")||"Unknown validation error",i=`Validation failed for tool "${t.name}":\n${r}\n\nReceived arguments:\n${JSON.stringify(t.arguments,null,2)}`;throw new Error(i)}},63837:e=>{"use strict";e.exports=JSON.parse('{"$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON AnySchema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},72079:e=>{"use strict";e.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')},66495:e=>{"use strict";e.exports=JSON.parse('{"name":"gaxios","version":"7.1.3","description":"A simple common HTTP client specifically for Google APIs and services.","main":"build/cjs/src/index.js","types":"build/cjs/src/index.d.ts","files":["build/"],"exports":{".":{"import":{"types":"./build/esm/src/index.d.ts","default":"./build/esm/src/index.js"},"require":{"types":"./build/cjs/src/index.d.ts","default":"./build/cjs/src/index.js"}}},"scripts":{"lint":"gts check --no-inline-config","test":"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000","compile":"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs","fix":"gts fix","prepare":"npm run compile","pretest":"npm run compile","webpack":"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js","docs":"jsdoc -c .jsdoc.js","docs-test":"linkinator docs","predocs-test":"npm run docs","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","prelint":"cd samples; npm link ../; npm install","clean":"gts clean"},"repository":{"type":"git","directory":"packages/gaxios","url":"https://github.com/googleapis/google-cloud-node-core.git"},"keywords":["google"],"engines":{"node":">=18"},"author":"Google, LLC","license":"Apache-2.0","devDependencies":{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.1","@types/node":"^22.0.0","@types/sinon":"^17.0.0","@types/tmp":"0.2.6","assert":"^2.0.0","browserify":"^17.0.0","c8":"^10.0.0","cors":"^2.8.5","express":"^5.0.0","gts":"^6.0.0","is-docker":"^3.0.0","jsdoc":"^4.0.0","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0","karma":"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1","linkinator":"^6.1.2","mocha":"^11.1.0","multiparty":"^4.2.1","mv":"^2.1.1","ncp":"^2.0.0","nock":"^14.0.0-beta.13","null-loader":"^4.0.0","pack-n-play":"^4.0.0","puppeteer":"^24.0.0","sinon":"^21.0.0","stream-browserify":"^3.0.0","tmp":"0.2.5","ts-loader":"^9.5.2","typescript":"^5.8.3","webpack":"^5.35.0","webpack-cli":"^6.0.1"},"dependencies":{"extend":"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2","rimraf":"^5.0.1"},"homepage":"https://github.com/googleapis/google-cloud-node-core/tree/main/packages/gaxios"}')},96066:e=>{"use strict";e.exports=JSON.parse('{"name":"google-auth-library","version":"10.6.1","author":"Google Inc.","description":"Google APIs Authentication Client Library for Node.js","engines":{"node":">=18"},"main":"./build/src/index.js","types":"./build/src/index.d.ts","repository":{"type":"git","directory":"packages/google-auth-library-nodejs","url":"https://github.com/googleapis/google-cloud-node-core.git"},"keywords":["google","api","google apis","client","client library"],"dependencies":{"base64-js":"^1.3.0","ecdsa-sig-formatter":"^1.0.11","gaxios":"7.1.3","gcp-metadata":"8.1.2","google-logging-utils":"1.1.3","jws":"^4.0.0"},"devDependencies":{"@types/base64-js":"^1.2.5","@types/jws":"^3.1.0","@types/mocha":"^10.0.10","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","assert-rejects":"^1.0.0","c8":"^10.1.3","codecov":"^3.8.3","gts":"^6.0.2","is-docker":"^3.0.0","jsdoc":"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0","karma":"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1","keypair":"^1.0.4","mocha":"^11.1.0","mv":"^2.1.1","ncp":"^2.0.0","nock":"^14.0.5","null-loader":"^4.0.1","puppeteer":"^24.0.0","sinon":"^21.0.0","ts-loader":"^9.5.2","typescript":"5.8.3","webpack":"^5.97.1","webpack-cli":"^6.0.1"},"files":["build/src","!build/src/**/*.map"],"scripts":{"test":"c8 mocha build/test","clean":"gts clean","prepare":"npm run compile","lint":"gts check --no-inline-config","compile":"tsc -p .","fix":"gts fix","pretest":"npm run compile -- --sourceMap","docs":"jsdoc -c .jsdoc.js","samples-setup":"cd samples/ && npm link ../ && npm run setup && cd ../","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","system-test":"mocha build/system-test --timeout 60000","presystem-test":"npm run compile -- --sourceMap","webpack":"webpack","browser-test":"karma start","docs-test":"echo \'disabled until linkinator is fixed\'","predocs-test":"npm run docs","prelint":"cd samples; npm link ../; npm install"},"license":"Apache-2.0","homepage":"https://github.com/googleapis/google-cloud-node-core/tree/main/packages/google-auth-library-nodejs"}')}};
|