@schematichq/schematic-typescript-node 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Client.d.ts +3 -0
- package/dist/api/resources/accounts/client/Client.d.ts +2 -0
- package/dist/api/resources/accounts/client/requests/CountAccountMembersRequest.d.ts +4 -0
- package/dist/api/resources/accounts/client/requests/ListAccountMembersRequest.d.ts +4 -0
- package/dist/api/resources/accounts/types/CountAccountMembersParams.d.ts +3 -0
- package/dist/api/resources/accounts/types/ListAccountMembersParams.d.ts +3 -0
- package/dist/api/resources/checkout/client/Client.d.ts +35 -0
- package/dist/api/resources/checkout/client/requests/UpdateCompanyBillingDetailsRequestBody.d.ts +16 -0
- package/dist/api/resources/checkout/client/requests/index.d.ts +1 -0
- package/dist/api/resources/checkout/types/GetCompanyBillingDetailsResponse.d.ts +6 -0
- package/dist/api/resources/checkout/types/UpdateCompanyBillingDetailsResponse.d.ts +6 -0
- package/dist/api/resources/checkout/types/index.d.ts +2 -0
- package/dist/api/resources/index.d.ts +3 -0
- package/dist/api/resources/licenses/client/Client.d.ts +69 -0
- package/dist/api/resources/licenses/client/index.d.ts +1 -0
- package/dist/api/resources/licenses/client/requests/CountLicensesRequest.d.ts +19 -0
- package/dist/api/resources/licenses/client/requests/ListLicensesRequest.d.ts +19 -0
- package/dist/api/resources/licenses/client/requests/index.d.ts +2 -0
- package/dist/api/resources/licenses/exports.d.ts +2 -0
- package/dist/api/resources/licenses/index.d.ts +2 -0
- package/dist/api/resources/licenses/types/CountLicensesParams.d.ts +12 -0
- package/dist/api/resources/licenses/types/CountLicensesResponse.d.ts +6 -0
- package/dist/api/resources/licenses/types/GetSingleLicenseResponse.d.ts +6 -0
- package/dist/api/resources/licenses/types/ListLicensesParams.d.ts +12 -0
- package/dist/api/resources/licenses/types/ListLicensesResponse.d.ts +6 -0
- package/dist/api/resources/licenses/types/index.d.ts +5 -0
- package/dist/api/resources/planmigrations/client/Client.d.ts +20 -0
- package/dist/api/resources/planmigrations/client/requests/PreviewMigrationRequestBody.d.ts +16 -0
- package/dist/api/resources/planmigrations/client/requests/index.d.ts +1 -0
- package/dist/api/resources/planmigrations/types/PreviewMigrationResponse.d.ts +6 -0
- package/dist/api/resources/planmigrations/types/index.d.ts +1 -0
- package/dist/api/types/BillingCreditGrantZeroedOutReason.d.ts +1 -0
- package/dist/api/types/CompanyBillingAddressView.d.ts +8 -0
- package/dist/api/types/CompanyBillingCheckoutSettings.d.ts +5 -0
- package/dist/api/types/CompanyBillingDetailsResponseData.d.ts +8 -0
- package/dist/api/types/CompanyBillingDetailsView.d.ts +8 -0
- package/dist/api/types/CreateEntitlementInBundleRequestBody.d.ts +1 -0
- package/dist/api/types/CreditsAutoTopupSuccess.d.ts +7 -0
- package/dist/api/types/CreditsCreditPurchaseSuccess.d.ts +9 -0
- package/dist/api/types/CreditsWebhookCompanySummary.d.ts +4 -0
- package/dist/api/types/CreditsWebhookCreditSummary.d.ts +4 -0
- package/dist/api/types/CustomerBillingAddress.d.ts +8 -0
- package/dist/api/types/FeatureDetailResponseData.d.ts +6 -0
- package/dist/api/types/FeatureInPlanResponseData.d.ts +4 -0
- package/dist/api/types/FeatureResponseData.d.ts +4 -0
- package/dist/api/types/FeatureType.d.ts +1 -0
- package/dist/api/types/FeatureView.d.ts +2 -0
- package/dist/api/types/LicenseResponseData.d.ts +6 -0
- package/dist/api/types/PlanVersionMigrationPreviewCompanyResponseData.d.ts +8 -0
- package/dist/api/types/PlanVersionMigrationPreviewResponseData.d.ts +4 -0
- package/dist/api/types/WebhookRequestType.d.ts +2 -0
- package/dist/api/types/index.d.ts +12 -0
- package/dist/index.js +9 -9
- package/dist/serialization/resources/accounts/types/CountAccountMembersParams.d.ts +2 -0
- package/dist/serialization/resources/accounts/types/ListAccountMembersParams.d.ts +2 -0
- package/dist/serialization/resources/checkout/client/requests/UpdateCompanyBillingDetailsRequestBody.d.ts +14 -0
- package/dist/serialization/resources/checkout/client/requests/index.d.ts +1 -0
- package/dist/serialization/resources/checkout/types/GetCompanyBillingDetailsResponse.d.ts +11 -0
- package/dist/serialization/resources/checkout/types/UpdateCompanyBillingDetailsResponse.d.ts +11 -0
- package/dist/serialization/resources/checkout/types/index.d.ts +2 -0
- package/dist/serialization/resources/index.d.ts +2 -0
- package/dist/serialization/resources/licenses/index.d.ts +1 -0
- package/dist/serialization/resources/licenses/types/CountLicensesParams.d.ts +13 -0
- package/dist/serialization/resources/licenses/types/CountLicensesResponse.d.ts +12 -0
- package/dist/serialization/resources/licenses/types/GetSingleLicenseResponse.d.ts +11 -0
- package/dist/serialization/resources/licenses/types/ListLicensesParams.d.ts +13 -0
- package/dist/serialization/resources/licenses/types/ListLicensesResponse.d.ts +12 -0
- package/dist/serialization/resources/licenses/types/index.d.ts +5 -0
- package/dist/serialization/resources/planmigrations/client/requests/PreviewMigrationRequestBody.d.ts +13 -0
- package/dist/serialization/resources/planmigrations/client/requests/index.d.ts +1 -0
- package/dist/serialization/resources/planmigrations/types/PreviewMigrationResponse.d.ts +11 -0
- package/dist/serialization/resources/planmigrations/types/index.d.ts +1 -0
- package/dist/serialization/types/BillingCreditGrantZeroedOutReason.d.ts +1 -1
- package/dist/serialization/types/CompanyBillingAddressView.d.ts +14 -0
- package/dist/serialization/types/CompanyBillingCheckoutSettings.d.ts +11 -0
- package/dist/serialization/types/CompanyBillingDetailsResponseData.d.ts +16 -0
- package/dist/serialization/types/CompanyBillingDetailsView.d.ts +16 -0
- package/dist/serialization/types/CreateEntitlementInBundleRequestBody.d.ts +2 -0
- package/dist/serialization/types/CreditsAutoTopupSuccess.d.ts +14 -0
- package/dist/serialization/types/CreditsCreditPurchaseSuccess.d.ts +16 -0
- package/dist/serialization/types/CreditsWebhookCompanySummary.d.ts +10 -0
- package/dist/serialization/types/CreditsWebhookCreditSummary.d.ts +10 -0
- package/dist/serialization/types/CustomerBillingAddress.d.ts +14 -0
- package/dist/serialization/types/FeatureDetailResponseData.d.ts +4 -0
- package/dist/serialization/types/FeatureInPlanResponseData.d.ts +2 -0
- package/dist/serialization/types/FeatureResponseData.d.ts +2 -0
- package/dist/serialization/types/FeatureType.d.ts +1 -1
- package/dist/serialization/types/FeatureView.d.ts +3 -0
- package/dist/serialization/types/LicenseResponseData.d.ts +12 -0
- package/dist/serialization/types/PlanVersionMigrationPreviewCompanyResponseData.d.ts +14 -0
- package/dist/serialization/types/PlanVersionMigrationPreviewResponseData.d.ts +10 -0
- package/dist/serialization/types/WebhookRequestType.d.ts +1 -1
- package/dist/serialization/types/index.d.ts +12 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var Eb=Object.create;var To=Object.defineProperty;var Cb=Object.getOwnPropertyDescriptor;var Ub=Object.getOwnPropertyNames;var vb=Object.getPrototypeOf,Tb=Object.prototype.hasOwnProperty;var pi=(p,o)=>()=>(p&&(o=p(p=0)),o);var Ob=(p,o)=>()=>(o||p((o={exports:{}}).exports,o),o.exports),Rr=(p,o)=>{for(var i in o)To(p,i,{get:o[i],enumerable:!0})},js=(p,o,i,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of Ub(o))!Tb.call(p,s)&&s!==i&&To(p,s,{get:()=>o[s],enumerable:!(t=Cb(o,s))||t.enumerable});return p};var no=(p,o,i)=>(i=p!=null?Eb(vb(p)):{},js(o||!p||!p.__esModule?To(i,"default",{value:p,enumerable:!0}):i,p)),As=p=>js(To({},"__esModule",{value:!0}),p);var ac={};Rr(ac,{Node18UniversalStreamWrapper:()=>Aa});var Aa,nc=pi(()=>{"use strict";Aa=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",async i=>{if(o instanceof p)o._write(i);else if(o instanceof WritableStream){let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}else o.write(i)}),this.on("end",async()=>{o instanceof p?o._end():o instanceof WritableStream?o.getWriter().close():o.end()}),this.on("error",async i=>{o instanceof p?o._error(i):o instanceof WritableStream?o.getWriter().abort(i):o.destroy(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",async i=>{if(o instanceof p)o._write(i);else if(o instanceof WritableStream){let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}else o.write(i)}),this.off("end",async()=>{o instanceof p?o._end():o instanceof WritableStream?o.getWriter().close():o.end()}),this.off("error",async i=>{o instanceof p?o._error(i):o instanceof WritableStream?o.getWriter().abort(i):o.destroy(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var sc={};Rr(sc,{UndiciStreamWrapper:()=>Va});var Va,cc=pi(()=>{"use strict";Va=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.on("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.on("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.off("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.off("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var lc={};Rr(lc,{NodePre18StreamWrapper:()=>qa});var qa,pc=pi(()=>{"use strict";qa=class{constructor(o){this.readableStream=o}on(o,i){this.readableStream.on(o,i)}off(o,i){this.readableStream.off(o,i)}pipe(o){return this.readableStream.pipe(o),o}pipeTo(o){return this.pipe(o)}unpipe(o){o?this.readableStream.unpipe(o):this.readableStream.unpipe()}destroy(o){this.readableStream.destroy(o)}pause(){this.readableStream.pause()}resume(){this.readableStream.resume()}get isPaused(){return this.readableStream.isPaused()}async read(){return new Promise((o,i)=>{let t=this.readableStream.read();t?o(t):(this.readableStream.once("readable",()=>{let s=this.readableStream.read();o(s)}),this.readableStream.once("error",i))})}setEncoding(o){this.readableStream.setEncoding(o),this.encoding=o}async text(){let o=[],i=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let s of this.readableStream)o.push(i.encode(s));return new TextDecoder(this.encoding||"utf-8").decode(Buffer.concat(o))}async json(){let o=await this.text();return JSON.parse(o)}[Symbol.asyncIterator](){let i=this.readableStream[Symbol.asyncIterator]();return{async next(){let{value:t,done:s}=await i.next();return{value:t,done:s}},[Symbol.asyncIterator](){return this}}}}});var ao,Ss=pi(()=>{"use strict";ao=class{constructor(){this._emitter=null}ensureEmitter(){if(!this._emitter){let{EventEmitter:o}=require("events");this._emitter=new o}return this._emitter}on(o,i){return this.ensureEmitter().on(o,i),this}emit(o,...i){return this._emitter?.emit(o,...i)??!1}removeAllListeners(o){return this._emitter?.removeAllListeners(o),this}}});var rb=Ob((aae,XR)=>{XR.exports={name:"@schematichq/schematic-typescript-node",version:"1.5.5",private:!1,repository:{type:"git",url:"git+https://github.com/schematichq/schematic-node.git"},main:"./dist/index.js",types:"./dist/index.d.ts",scripts:{format:"biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","format:check":"biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",lint:"biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","lint:fix":"biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",check:"biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","check:fix":"biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",build:"node build.js",prepack:"",test:"jest --config jest.config.mjs","test:unit":"jest --selectProjects unit","test:wire":"jest --selectProjects wire","build:legacy":"tsc","test:cloudflare":"node scripts/test-cloudflare.mjs"},dependencies:{"form-data":"^4.0.4","formdata-node":"^6.0.3","node-fetch":"^2.7.0","readable-stream":"^4.7.0",ws:"^8.18.1"},devDependencies:{"@types/node-fetch":"^2.6.12","@types/readable-stream":"^4.0.23",webpack:"^5.105.4","ts-loader":"^9.5.4",jest:"^29.7.0","@jest/globals":"^29.7.0","@types/jest":"^29.5.14","ts-jest":"^29.3.4","jest-environment-jsdom":"^29.7.0",msw:"2.11.2","@types/node":"^20.0.0",typescript:"~5.9.3","@biomejs/biome":"2.4.10",esbuild:"^0.25.9",miniflare:"^4.20260421.0",redis:"^4.7.0","@types/ws":"^8.18.1"},browser:{fs:!1,os:!1,path:!1,stream:!1,crypto:!1,timers:!1},packageManager:"yarn@1.22.22",engines:{node:">=18.0.0"},sideEffects:!1,license:"MIT",files:["dist/**/*.js","dist/**/*.d.ts","dist/**/*.wasm","!dist/**/*.js.map","!dist/**/*.test.*","README.md"]}});var ib,ob,tb,ab=pi(()=>{"use strict";ib=rb(),ob=ib.name,tb=ib.version});var cb={};Rr(cb,{DatastreamWSClient:()=>Es});function af(p){let o=new URL(p);switch(o.protocol){case"https:":o.protocol="wss:";break;case"http:":o.protocol="ws:";break;default:throw new Error(`Unsupported scheme: ${o.protocol} (must be http: or https:)`)}if(o.hostname){let i=o.hostname.split(".");i.length>1&&i[0]==="api"&&(i[0]="datastream",o.hostname=i.join("."))}return o.pathname="/datastream",o.toString()}var nb,QR,sb,ef,rf,of,tf,Es,lb=pi(()=>{"use strict";nb=no(require("ws"));ab();Ss();QR=10*1e3,sb=60*1e3,ef=sb*9/10,rf=10,of=1*1e3,tf=30*1e3;Es=class extends ao{constructor(i){super();this.connected=!1;this.ready=!1;this.shouldReconnect=!0;this.reconnectAttempts=0;if(!i.url)throw new Error("URL is required");if(!i.apiKey)throw new Error("ApiKey is required");if(!i.messageHandler)throw new Error("MessageHandler is required");i.url.startsWith("http://")||i.url.startsWith("https://")?this.url=af(i.url):this.url=i.url,this.headers={"X-Schematic-Api-Key":i.apiKey,"X-Schematic-Client":ob,"X-Schematic-Client-Version":tb,"X-Schematic-Datastream-Mode":"datastream"},this.logger=i.logger,this.messageHandler=i.messageHandler,this.connectionReadyHandler=i.connectionReadyHandler,this.maxReconnectAttempts=i.maxReconnectAttempts??rf,this.minReconnectDelay=i.minReconnectDelay??of,this.maxReconnectDelay=i.maxReconnectDelay??tf}start(){this.shouldReconnect=!0,this.reconnectAttempts=0,this.connectAndRead()}isConnected(){return this.connected}isReady(){return this.ready&&this.connected}async sendMessage(i){if(!this.isConnected()||!this.ws)throw new Error("WebSocket connection is not available!");return new Promise((t,s)=>{if(!this.ws){s(new Error("WebSocket connection is not available!"));return}let r=setTimeout(()=>{s(new Error("Write timeout"))},QR);try{this.ws.send(JSON.stringify(i),a=>{clearTimeout(r),a?s(a):t()})}catch(a){clearTimeout(r),s(a)}})}close(){this.logger.info("Closing WebSocket connection"),this.shouldReconnect=!1,this.setReady(!1),this.setConnected(!1),this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.ws&&(this.ws.close(),this.ws=void 0)}async connectAndRead(){try{for(;this.shouldReconnect;)try{let i=await this.connect();if(this.reconnectAttempts=0,this.ws=i,this.setConnected(!0),this.setupWebSocketHandlers(i),this.connectionReadyHandler)try{await this.connectionReadyHandler(),this.logger.debug("Connection ready handler completed successfully")}catch(t){this.logger.error(`Connection ready handler failed: ${t}`),this.setConnected(!1),this.setReady(!1),i.close();continue}if(this.setReady(!0),this.logger.debug("WebSocket client is ready"),this.startPingPong(),await new Promise(t=>{let s=()=>{this.logger.info("WebSocket connection closed"),this.cleanup(),t()},r=a=>{this.logger.error(`WebSocket error: ${a.message}`),this.emit("error",a),this.cleanup(),t()};i.on("close",s),i.on("error",r)}),!this.shouldReconnect)break}catch(i){this.reconnectAttempts++,this.setConnected(!1),this.setReady(!1);let t=i instanceof Error?i.message:String(i);if(this.logger.warn(`WebSocket connection failed: ${t}, attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts}`),this.reconnectAttempts>=this.maxReconnectAttempts){this.logger.error("Max reconnection attempts reached"),this.emit("error",new Error("Max reconnection attempts reached"));break}let s=this.calculateBackoffDelay(this.reconnectAttempts);this.logger.debug(`Waiting ${s}ms before reconnecting...`),await new Promise(r=>{this.reconnectTimeout=setTimeout(r,s),this.reconnectTimeout.unref()})}}catch(i){this.emit("error",i)}}connect(){return new Promise((i,t)=>{this.logger.debug(`Connecting to WebSocket: ${this.url}`);let s=new nb.default(this.url,{headers:this.headers,handshakeTimeout:3e4}),r=setTimeout(()=>{s.close(),t(new Error("Connection timeout"))},3e4);s.on("open",()=>{clearTimeout(r),i(s)}),s.on("error",a=>{clearTimeout(r),t(a)})})}setupWebSocketHandlers(i){i.on("message",t=>{this.handleMessage(t)}),i.on("pong",()=>{this.handlePong()}),i.on("close",t=>{this.handleClose(t)}),i.on("error",t=>{this.handleError(t)})}async handleMessage(i){try{let t;Buffer.isBuffer(i)?t=i.toString():Array.isArray(i)?t=Buffer.concat(i).toString():t=String(i);let s;try{s=JSON.parse(t)}catch(r){this.emit("error",new Error(`Failed to parse datastream message: ${r}`));return}try{await this.messageHandler(s)}catch(r){this.emit("error",new Error(`Message handler error: ${r}`))}}catch(t){this.emit("error",t)}}handleClose(i){this.logger.info(`WebSocket connection closed with code ${i}`),this.setConnected(!1),this.setReady(!1),this.cleanup()}handleError(i){this.logger.error(`WebSocket error: ${i.message}`),this.setConnected(!1),this.setReady(!1),this.cleanup()}startPingPong(){this.logger.debug("Starting ping/pong keepalive mechanism"),this.pingInterval=setInterval(()=>{this.sendPing()},ef),this.pingInterval.unref()}sendPing(){if(this.ws){this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0),this.pongTimeout=setTimeout(()=>{this.logger.warn("Pong timeout - closing connection"),this.setConnected(!1),this.ws&&this.ws.close()},sb),this.pongTimeout.unref();try{this.ws.ping()}catch(i){this.logger.error(`Failed to send ping: ${i}`),this.setConnected(!1)}}}handlePong(){this.logger.debug("Received pong from server"),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0)}calculateBackoffDelay(i){let t=Math.floor(Math.random()*this.minReconnectDelay),s=Math.pow(2,i-1)*this.minReconnectDelay+t;return Math.min(s,this.maxReconnectDelay+t)}setConnected(i){let t=this.connected;this.connected=i,i||(this.ready=!1),t!==i&&(this.logger.debug(`Connection state changed: ${i}`),i?this.emit("connected"):this.emit("disconnected"))}setReady(i){let t=this.ready;this.ready=i,t!==i&&(this.logger.debug(`Ready state changed: ${i}`),i?this.emit("ready"):this.emit("not-ready"))}cleanup(){this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0)}}});var Bf={};Rr(Bf,{ConsoleLogger:()=>oi,LocalCache:()=>rr,LogLevel:()=>er,RedisCacheProvider:()=>ni,RulesEngineClient:()=>to,Schematic:()=>ie,SchematicClient:()=>Ua,SchematicEnvironment:()=>z,SchematicError:()=>b,SchematicTimeoutError:()=>ai,WEBHOOK_SIGNATURE_HEADER:()=>Ts,WEBHOOK_TIMESTAMP_HEADER:()=>Os,WebhookSignatureError:()=>wr,computeHexSignature:()=>_b,computeSignature:()=>Ta,verifySignature:()=>ks,verifyWebhookSignature:()=>Sb});module.exports=As(Bf);var ie={};Rr(ie,{AccountMemberPermission:()=>Bb,AccountMemberRole:()=>jb,ActorType:()=>Ab,ApiKeyScope:()=>Vb,BadRequestError:()=>v,BillingCreditAutoTopupAvailability:()=>qb,BillingCreditBundleStatus:()=>Db,BillingCreditBurnStrategy:()=>Mb,BillingCreditExpiryType:()=>Ib,BillingCreditExpiryUnit:()=>Fb,BillingCreditGrantReason:()=>Kb,BillingCreditGrantZeroedOutReason:()=>Lb,BillingCreditLedgerAuthority:()=>Gb,BillingCreditRolloverPolicy:()=>Wb,BillingPlanCreditGrantResetCadence:()=>Hb,BillingPlanCreditGrantResetStart:()=>Nb,BillingPlanCreditGrantResetType:()=>$b,BillingPriceScheme:()=>Jb,BillingPriceUsageType:()=>Yb,BillingProductPriceInterval:()=>Zb,BillingProviderType:()=>Xb,BillingStrategy:()=>Qb,BillingSubscriptionTrialEndSetting:()=>ez,BillingTiersMode:()=>rz,ChargeType:()=>iz,CompanyMatchingCriteria:()=>oz,CompanyPlanInvalidReason:()=>tz,ComparableOperator:()=>az,ComponentEntityType:()=>nz,ComponentState:()=>sz,ConditionType:()=>cz,CreditEventType:()=>lz,CreditGrantSortOrder:()=>pz,CreditUsageReason:()=>uz,CustomPlanActivationStrategy:()=>dz,CustomPlanBillingStatus:()=>mz,DataExportOutputFileType:()=>hz,DataExportStatus:()=>gz,DataExportType:()=>yz,EntitlementPriceBehavior:()=>wz,EntitlementType:()=>bz,EntitlementValueType:()=>zz,EntityType:()=>Rz,EnvironmentType:()=>fz,EventStatus:()=>_z,EventType:()=>Oo,FeatureLifecyclePhase:()=>Sz,FeatureType:()=>Pz,ForbiddenError:()=>_,IntegrationState:()=>xz,IntegrationType:()=>Ez,InternalServerError:()=>S,InvoiceStatus:()=>Cz,MetricPeriod:()=>Uz,MetricPeriodMonthReset:()=>vz,MigrationErrorCode:()=>Tz,NotFoundError:()=>P,PlanBundleAction:()=>Oz,PlanChangeAction:()=>kz,PlanChangeBasePlanAction:()=>Bz,PlanChangeSubscriptionAction:()=>jz,PlanIcon:()=>Az,PlanPriceCadence:()=>Vz,PlanType:()=>qz,PlanVersionCompanyMigrationStatus:()=>Dz,PlanVersionMigrationStatus:()=>Mz,PlanVersionMigrationStrategy:()=>Iz,PlanVersionStatus:()=>Fz,ProrationBehavior:()=>Kz,RuleType:()=>Yz,RulesEngineSchemaVersion:()=>Lz,RulesengineConditionType:()=>Gz,RulesengineEntitlementValueType:()=>Oa,RulesengineEntityType:()=>Wz,RulesengineMetricPeriod:()=>Hz,RulesengineMetricPeriodMonthReset:()=>Nz,RulesengineRuleType:()=>$z,RulesengineTraitDefinitionComparableType:()=>Jz,ScheduledCheckoutStatus:()=>Zz,ScheduledDowngradeConfigBehavior:()=>Xz,SortDirection:()=>Qz,SubscriptionStatus:()=>eR,SubscriptionType:()=>rR,TimeSeriesGranularity:()=>iR,TraitDefinitionComparableType:()=>oR,TraitType:()=>tR,TrialStatus:()=>aR,UnauthorizedError:()=>x,WebhookEventStatus:()=>nR,WebhookRequestType:()=>sR,WebhookStatus:()=>cR,accesstokens:()=>Vs,accounts:()=>qs,billing:()=>Ds,catalogs:()=>Ms,checkout:()=>Is,companies:()=>Fs,components:()=>Ks,componentspublic:()=>Ls,credits:()=>Gs,dataexports:()=>Ws,entitlements:()=>Hs,events:()=>Ns,features:()=>$s,insights:()=>Js,integrationsapi:()=>Ys,planbundle:()=>Zs,plangroups:()=>Xs,planmigrations:()=>Qs,plans:()=>ec,scheduledcheckout:()=>rc,webhooks:()=>ic});var ve=(p,o,i)=>JSON.stringify(p,o,i);function so(p,o){return JSON.parse(p,o)}var b=class extends Error{constructor({message:o,statusCode:i,body:t,rawResponse:s,cause:r}){super(kb({message:o,statusCode:i,body:t})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.statusCode=i,this.body=t,this.rawResponse=s,r!=null&&(this.cause=r)}};function kb({message:p,statusCode:o,body:i}){let t=[];return p!=null&&t.push(p),o!=null&&t.push(`Status code: ${o.toString()}`),i!=null&&t.push(`Body: ${ve(i,void 0,2)}`),t.join(`
|
|
2
|
-
`)}var ai=class extends Error{constructor(o,i){super(o),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,i?.cause!=null&&(this.cause=i.cause)}};var v=class extends b{constructor(o,i){super({message:"BadRequestError",statusCode:400,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var _=class extends b{constructor(o,i){super({message:"ForbiddenError",statusCode:403,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var S=class extends b{constructor(o,i){super({message:"InternalServerError",statusCode:500,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var P=class extends b{constructor(o,i){super({message:"NotFoundError",statusCode:404,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var x=class extends b{constructor(o,i){super({message:"UnauthorizedError",statusCode:401,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var Vs={};var qs={};var Ds={};var Ms={};var Is={};var Fs={};var Ks={};var Ls={};var Gs={};var Ws={};var Hs={};var Ns={};var $s={};var Js={};var Ys={};var Zs={};var Xs={};var Qs={};var ec={};var rc={};var ic={};var Bb={CompaniesEdit:"companies_edit",CompanyUsersEdit:"company_users_edit",ComponentsEdit:"components_edit",CustomPlansEdit:"custom_plans_edit",DataExportsEdit:"data_exports_edit",FeaturesEdit:"features_edit",FlagRulesEdit:"flag_rules_edit",FlagsEdit:"flags_edit",OverridesEdit:"overrides_edit",PlanBillingEdit:"plan_billing_edit",PlanEntitlementsEdit:"plan_entitlements_edit",PlanVersionsEdit:"plan_versions_edit",PlansEdit:"plans_edit",WebhooksEdit:"webhooks_edit",WebhooksRevealSecret:"webhooks_reveal_secret"};var jb={Admin:"admin",Member:"member"};var Ab={ApiKey:"api_key",AppUser:"app_user",StripeApp:"stripe_app",System:"system",TemporaryAccessToken:"temporary_access_token"};var Vb={Admin:"admin",Capture:"capture",Read:"read",Write:"write"};var qb={Off:"off",Automatic:"automatic",UserControlled:"user_controlled"};var Db={Active:"active",Inactive:"inactive"};var Mb={ExpirationPriority:"expiration_priority",FirstInFirstOut:"first_in_first_out",LastInFirstOut:"last_in_first_out",PlanFirstThenCreditBundlesFirstInFirstOut:"plan_first_then_credit_bundles_first_in_first_out"};var Ib={Duration:"duration",EndOfBillingPeriod:"end_of_billing_period",EndOfNextBillingPeriod:"end_of_next_billing_period",EndOfTrial:"end_of_trial",NoExpiry:"no_expiry"};var Fb={BillingPeriods:"billing_periods",Days:"days"};var Kb={Adjustment:"adjustment",BillingCreditAutoTopup:"billing_credit_auto_topup",Free:"free",Plan:"plan",Purchased:"purchased",Rollover:"rollover"};var Lb={CustomerArchived:"customer_archived",Expired:"expired",IntegrationUninstalled:"integration_uninstalled",Manual:"manual",PlanChange:"plan_change",PlanPeriodReset:"plan_period_reset",Reconciled:"reconciled"};var Gb={SchematicAuthoritative:"schematic_authoritative",ExternalMirror:"external_mirror",ExternalRated:"external_rated"};var Wb={Expire:"expire",None:"none",Rollover:"rollover"};var Hb={Daily:"daily",Every6Months:"every_6_months",Monthly:"monthly",Quarterly:"quarterly",Weekly:"weekly",Yearly:"yearly"};var Nb={BillingPeriod:"billing_period",FirstOfMonth:"first_of_month"};var $b={NoReset:"no_reset",PlanPeriod:"plan_period"};var Jb={PerUnit:"per_unit",Tiered:"tiered"};var Yb={Licensed:"licensed",Metered:"metered"};var Zb={Day:"day",Month:"month",OneTime:"one-time",Year:"year"};var Xb={Metronome:"metronome",Orb:"orb",Schematic:"schematic",Stripe:"stripe"};var Qb={SchematicManaged:"schematic_managed",ProviderManaged:"provider_managed",NoBilling:"no_billing"};var ez={Cancel:"cancel",Subscribe:"subscribe"};var rz={Graduated:"graduated",Volume:"volume"};var iz={Free:"free",None:"none",OneTime:"one_time",Recurring:"recurring"};var oz={BillingMetaObject:"billing_meta_object",ManualUpsert:"manual_upsert"};var tz={DowngradeNotPermitted:"downgrade_not_permitted",FeatureUsageExceeded:"feature_usage_exceeded"};var az={Eq:"eq",Gt:"gt",Gte:"gte",IsEmpty:"is_empty",Lt:"lt",Lte:"lte",NotEmpty:"not_empty",Ne:"ne"};var nz={Billing:"billing",Entitlement:"entitlement"};var sz={Draft:"draft",Live:"live"};var cz={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var lz={Grant:"grant",Transfer:"transfer",Usage:"usage",ZeroOut:"zero_out"};var pz={CreatedAt:"created_at",ExpiresAt:"expires_at",Quantity:"quantity",QuantityRemaining:"quantity_remaining"};var uz={LeaseHold:"lease_hold",LeaseRelease:"lease_release",ManualAdjustment:"manual_adjustment",Reconciliation:"reconciliation",Track:"track"};var dz={OnPayment:"on_payment",OnPublish:"on_publish"};var mz={Active:"active",Expired:"expired",Paid:"paid",Pending:"pending"};var hz={Csv:"csv",CsvGz:"csv.gz"};var gz={Failure:"failure",Pending:"pending",Success:"success"};var yz={AuditLog:"audit-log",CompanyFeatureUsage:"company-feature-usage"};var wz={CreditBurndown:"credit_burndown",Overage:"overage",PayAsYouGo:"pay_as_you_go",PayInAdvance:"pay_in_advance",Tier:"tier"};var bz={CompanyOverride:"company_override",PlanEntitlement:"plan_entitlement",Unknown:"unknown"};var zz={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var Rz={Company:"company",User:"user"};var fz={Development:"development",Production:"production",Staging:"staging"};var _z={Enriched:"enriched",Failed:"failed",Pending:"pending",Processed:"processed",Unknown:"unknown"};var Oo={FlagCheck:"flag_check",Identify:"identify",Inference:"inference",Track:"track"};var Sz={AddOn:"add_on",Alpha:"alpha",Beta:"beta",Deprecated:"deprecated",Ga:"ga",Inactive:"inactive",InPlan:"in_plan",InternalTesting:"internal_testing",Legacy:"legacy"};var Pz={Boolean:"boolean",Event:"event",Trait:"trait"};var xz={Active:"active",Created:"created",Pending:"pending"};var Ez={Clerk:"clerk",Metronome:"metronome",Orb:"orb",Stripe:"stripe",Unknown:"unknown",Workos:"workos"};var Cz={Draft:"draft",Open:"open",Paid:"paid",Uncollectible:"uncollectible",Void:"void"};var Uz={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var vz={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Tz={AmbiguousSubscriptionItem:"ambiguous_subscription_item",MultipleSubscriptions:"multiple_subscriptions",NoPriceForInterval:"no_price_for_interval",NotOnOriginVersion:"not_on_origin_version",OperationItemNotFound:"operation_item_not_found",PermanentConfig:"permanent_config",PermanentDecline:"permanent_decline",TransientDecline:"transient_decline",TransientInfra:"transient_infra",TransientStripe:"transient_stripe",Unknown:"unknown",WouldLeaveEmptySubscription:"would_leave_empty_subscription"};var Oz={Create:"create",Update:"update",Delete:"delete"};var kz={Checkout:"checkout",CompanyUpsert:"company_upsert",FallbackPlan:"fallback_plan",ManagePlan:"manage_plan",Migration:"migration",PlanBillingProductChanged:"plan_billing_product_changed",PlanDeleted:"plan_deleted",PlanTraitChange:"plan_trait_change",PlanVersionMigration:"plan_version_migration",Quickstart:"quickstart",SubscriptionChange:"subscription_change"};var Bz={Fallback:"fallback",Initial:"initial",Trait:"trait",TrialExpiry:"trial_expiry"};var jz={Adjustment:"adjustment",Downgrade:"downgrade",Invalid:"invalid",Subscribe:"subscribe",Unsubscribe:"unsubscribe",Upgrade:"upgrade",UpgradeTrial:"upgrade_trial"};var Az={Amber:"amber",Blue:"blue",BlueGray:"blueGray",BlueGreen:"blueGreen",Cyan:"cyan",Emerald:"emerald",Fuchsia:"fuchsia",Gray:"gray",Green:"green",Indigo:"indigo",LightBlue:"lightBlue",Lime:"lime",Orange:"orange",Pink:"pink",Purple:"purple",Red:"red",RedOrange:"redOrange",Rose:"rose",Sky:"sky",Slate:"slate",Teal:"teal",TrueGray:"trueGray",Violet:"violet",WarmGray:"warmGray",Yellow:"yellow"};var Vz={Monthly:"monthly",Quarterly:"quarterly",Yearly:"yearly"};var qz={Plan:"plan",AddOn:"add_on"};var Dz={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending",Skipped:"skipped"};var Mz={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending"};var Iz={Immediate:"immediate",Leave:"leave"};var Fz={Published:"published",Draft:"draft",Archived:"archived"};var Kz={CreateProrations:"create_prorations",InvoiceImmediately:"invoice_immediately"};var Lz={V5B3E7220:"v5b3e7220",PlaceholderForFernCompatibility:"placeholder-for-fern-compatibility"};var Gz={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Oa={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var Wz={Company:"company",User:"user"};var Hz={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var Nz={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var $z={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Jz={Bool:"bool",Date:"date",Int:"int",String:"string"};var Yz={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Zz={Cancelled:"cancelled",Error:"error",Executing:"executing",Pending:"pending",Success:"success"};var Xz={EndOfBillingPeriod:"end_of_billing_period",None:"none"};var Qz={Asc:"asc",Desc:"desc"};var eR={Active:"active",Canceled:"canceled",Expired:"expired",Incomplete:"incomplete",IncompleteExpired:"incomplete_expired",PastDue:"past_due",Paused:"paused",Trialing:"trialing",Unpaid:"unpaid"};var rR={Free:"free",OneTime:"one_time",Paid:"paid",Trial:"trial"};var iR={Daily:"daily",Hourly:"hourly",Monthly:"monthly",Weekly:"weekly"};var oR={Bool:"bool",Date:"date",Int:"int",String:"string"};var tR={Boolean:"boolean",Currency:"currency",Date:"date",Number:"number",String:"string",Url:"url"};var aR={Active:"active",Converted:"converted",Expired:"expired"};var nR={Failure:"failure",Pending:"pending",Success:"success"};var sR={SubscriptionTrialEnded:"subscription.trial.ended",CompanyCreated:"company.created",CompanyDeleted:"company.deleted",CompanyOverrideCreated:"company.override.created",CompanyOverrideDeleted:"company.override.deleted",CompanyOverrideExpired:"company.override.expired",CompanyOverrideUpdated:"company.override.updated",CompanyPlanChanged:"company.plan_changed",CompanyScheduledDowngrade:"company.scheduled_downgrade",CompanyUpdated:"company.updated",CreditLimitReached:"credit.limit.reached",CreditLimitWarning:"credit.limit.warning",EntitlementLimitReached:"entitlement.limit.reached",EntitlementLimitWarning:"entitlement.limit.warning",EntitlementSoftLimitReached:"entitlement.soft_limit.reached",EntitlementSoftLimitWarning:"entitlement.soft_limit.warning",EntitlementTierLimitReached:"entitlement.tier_limit.reached",EntitlementTierLimitWarning:"entitlement.tier_limit.warning",FeatureCreated:"feature.created",FeatureDeleted:"feature.deleted",FeatureUpdated:"feature.updated",FlagCreated:"flag.created",FlagDeleted:"flag.deleted",FlagRulesUpdated:"flag_rules.updated",FlagUpdated:"flag.updated",PlanCreated:"plan.created",PlanDeleted:"plan.deleted",PlanEntitlementCreated:"plan.entitlement.created",PlanEntitlementDeleted:"plan.entitlement.deleted",PlanEntitlementUpdated:"plan.entitlement.updated",PlanUpdated:"plan.updated",PlanVersionDeleted:"plan_version.deleted",RuleDeleted:"rule.deleted",TestSend:"test.send",UserCreated:"user.created",UserDeleted:"user.deleted",UserUpdated:"user.updated",AutoTopupHardFailure:"auto.topup.hard.failure",AutoTopupRetryExceeded:"auto.topup.retry.exceeded"};var cR={Active:"active",Inactive:"inactive"};var lR=2147483647,rr=class{constructor({maxItems:o=1e3,ttl:i=5e3}={}){this.accessCounter=0;this.cache=new Map,this.maxItems=o,this.defaultTTL=i}async get(o){let i=this.cache.get(o);return i?i.expiration<=Date.now()?(this.evictItem(o,i),null):(this.accessCounter++,i.accessCounter=this.accessCounter,this.cache.set(o,i),i.value):null}async set(o,i,t){if(this.maxItems===0)return;let s=t??this.defaultTTL,r=this.cache.get(o);r&&this.evictItem(o,r),this.evictExpiredItems(),this.evictLRUItems(),this.accessCounter++;let a={value:i,accessCounter:this.accessCounter,expiration:Date.now()+s};a.timeoutId=setTimeout(()=>this.evictItem(o,a),Math.min(s,lR)),typeof a.timeoutId=="object"&&typeof a.timeoutId.unref=="function"&&a.timeoutId.unref(),this.cache.set(o,a)}async delete(o){let i=this.cache.get(o);i&&this.evictItem(o,i)}async deleteMissing(o,i){let t=new Set(o);for(let[s,r]of this.cache)t.has(s)||this.evictItem(s,r)}evictItem(o,i){i.timeoutId&&clearTimeout(i.timeoutId),this.cache.delete(o)}evictExpiredItems(){this.cache.forEach((o,i)=>{o.expiration<=Date.now()&&this.evictItem(i,o)})}evictLRUItems(){for(;this.cache.size>=this.maxItems;){let o,i=Number.MAX_SAFE_INTEGER;this.cache.forEach((t,s)=>{t.accessCounter<i&&(o=s,i=t.accessCounter)}),o&&this.evictItem(o,this.cache.get(o))}}};var ni=class{constructor(o){this.client=o.client,this.defaultTTL=Math.floor((o.ttl||5e3)/1e3),this.keyPrefix=o.keyPrefix||"schematic:"}getFullKey(o){return this.keyPrefix+o}async get(o){let i=this.getFullKey(o),t=await this.client.get(i);return t===null?null:JSON.parse(t)}async set(o,i,t){let s=this.getFullKey(o),r=JSON.stringify(i),a=t?Math.floor(t/1e3):this.defaultTTL;a>0?await this.client.setEx(s,a,r):await this.client.set(s,r)}async delete(o){let i=this.getFullKey(o);await this.client.del(i)}async deleteMissing(o,i){let t=i?.scanPattern?this.keyPrefix+i.scanPattern:this.keyPrefix+"*",s=new Set(o.map(u=>this.getFullKey(u))),r=[],a=1e3;for await(let u of this.client.scanIterator({MATCH:t,COUNT:1e3}))s.has(u)||(r.push(u),r.length>=a&&(await this.client.del(r),r.length=0));r.length>0&&await this.client.del(r)}};function ka(p){return typeof p=="object"&&p!==null&&"getAuthRequest"in p&&typeof p.getAuthRequest=="function"}var ui=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var ko={get:async(p,o)=>typeof p=="function"?p(o):p};var Ze={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},oc={[Ze.Debug]:1,[Ze.Info]:2,[Ze.Warn]:3,[Ze.Error]:4},co=class{debug(o,...i){console.debug(o,...i)}info(o,...i){console.info(o,...i)}warn(o,...i){console.warn(o,...i)}error(o,...i){console.error(o,...i)}},di=class{constructor(o){this.level=oc[o.level],this.logger=o.logger,this.silent=o.silent}shouldLog(o){return!this.silent&&this.level<=oc[o]}isDebug(){return this.shouldLog(Ze.Debug)}debug(o,...i){this.isDebug()&&this.logger.debug(o,...i)}isInfo(){return this.shouldLog(Ze.Info)}info(o,...i){this.isInfo()&&this.logger.info(o,...i)}isWarn(){return this.shouldLog(Ze.Warn)}warn(o,...i){this.isWarn()&&this.logger.warn(o,...i)}isError(){return this.shouldLog(Ze.Error)}error(o,...i){this.isError()&&this.logger.error(o,...i)}};function lo(p){return p==null?pR:p instanceof di?p:(p=p??{},p.level??=Ze.Info,p.logger??=new co,p.silent??=!0,new di(p))}var pR=new di({level:Ze.Info,logger:new co,silent:!0});var uR={arrayFormat:"indices",encode:!0};function Ba(p,o){if(p===void 0||p===null)return"";let i=String(p);return o?encodeURIComponent(i):i}function ja(p,o="",i){let t=[];for(let[s,r]of Object.entries(p)){let a=o?`${o}[${s}]`:s;if(r!==void 0)if(Array.isArray(r)){if(r.length===0)continue;let u=i.arrayFormat;if(u==="comma"){let g=i.encode?encodeURIComponent(a):a,h=r.filter(l=>l!=null).map(l=>Ba(l,i.encode));h.length>0&&t.push(`${g}=${h.join(",")}`)}else for(let g=0;g<r.length;g++){let h=r[g];if(h!==void 0)if(typeof h=="object"&&!Array.isArray(h)&&h!==null){let l=u==="indices"?`${a}[${g}]`:a;t.push(...ja(h,l,i))}else{let l=u==="indices"?`${a}[${g}]`:a,y=i.encode?encodeURIComponent(l):l;t.push(`${y}=${Ba(h,i.encode)}`)}}}else if(typeof r=="object"&&r!==null){if(Object.keys(r).length===0)continue;t.push(...ja(r,a,i))}else{let u=i.encode?encodeURIComponent(a):a;t.push(`${u}=${Ba(r,i.encode)}`)}}return t}function fr(p,o){return p==null||typeof p!="object"?"":ja(p,"",{...uR,...o}).join("&")}function Bo(p,o){let i=fr(o,{arrayFormat:"repeat"});return i?`${p}?${i}`:p}function tc(p){let o={get bodyUsed(){return p.bodyUsed},stream:()=>p.body,arrayBuffer:p.arrayBuffer.bind(p),blob:p.blob.bind(p)};return"bytes"in p&&typeof p.bytes=="function"&&(o.bytes=p.bytes.bind(p)),o}var fe=dR();function dR(){if(typeof window<"u"&&typeof window.document<"u")return{type:"browser",version:window.navigator.userAgent};if(typeof globalThis<"u"&&globalThis?.navigator?.userAgent==="Cloudflare-Workers")return{type:"workerd"};if(typeof EdgeRuntime=="string")return{type:"edge-runtime"};if(typeof self=="object"&&typeof self?.importScripts=="function"&&(self.constructor?.name==="DedicatedWorkerGlobalScope"||self.constructor?.name==="ServiceWorkerGlobalScope"||self.constructor?.name==="SharedWorkerGlobalScope"))return{type:"web-worker"};if(typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u")return{type:"deno",version:Deno.version.deno};if(typeof Bun<"u"&&typeof Bun.version<"u")return{type:"bun",version:Bun.version};if(typeof navigator<"u"&&navigator?.product==="ReactNative")return{type:"react-native"};let u=typeof process<"u"?process:void 0;return typeof u<"u"&&typeof u.versions?.node=="string"?{type:"node",version:u.versions.node,parsedVersion:Number(u.versions.node.split(".")[0])}:{type:"unknown"}}async function uc(p){return fe.type==="node"&&fe.parsedVersion!=null&&fe.parsedVersion>=18?new(await Promise.resolve().then(()=>(nc(),ac))).Node18UniversalStreamWrapper(p):fe.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(cc(),sc))).UndiciStreamWrapper(p):new(await Promise.resolve().then(()=>(pc(),lc))).NodePre18StreamWrapper(p)}async function mi(p,o){switch(o){case"binary-response":return tc(p);case"blob":return await p.blob();case"arrayBuffer":return await p.arrayBuffer();case"sse":return p.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:p.status}}:p.body;case"streaming":return p.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:p.status}}:uc(p.body);case"text":return await p.text()}let i=await p.text();if(i.length>0)try{return so(i)}catch{return{ok:!1,error:{reason:"non-json",statusCode:p.status,rawBody:i}}}}async function dc(p){let o=p.headers.get("Content-Type")?.toLowerCase();if(o==null||o.length===0)return mi(p);switch(o.indexOf(";")!==-1&&(o=o.split(";")[0]?.trim()??""),o){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":{let i=await p.text();return i.length>0?so(i):void 0}default:if(o.startsWith("application/vnd.")&&o.endsWith("+json")){let i=await p.text();return i.length>0?so(i):void 0}return await p.text()}}async function hi(){return fe.type==="node"&&fe.parsedVersion!=null&&fe.parsedVersion>=18?fetch:fe.type==="node"?(await import("node-fetch")).default:typeof fetch=="function"?fetch:(await import("node-fetch")).default}async function jo({body:p,type:o}){return o==="form"?fr(p,{arrayFormat:"repeat",encode:!0}):o.includes("json")?ve(p):p}var ir;typeof globalThis.Headers<"u"?ir=globalThis.Headers:ir=class mc{constructor(o){if(this.headers=new Map,o)if(o instanceof mc)o.forEach((i,t)=>this.append(t,i));else if(Array.isArray(o))for(let[i,t]of o)if(typeof i=="string"&&typeof t=="string")this.append(i,t);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[i,t]of Object.entries(o))if(typeof t=="string")this.append(i,t);else throw new TypeError("Header values must be strings")}append(o,i){let t=o.toLowerCase(),s=this.headers.get(t)||[];this.headers.set(t,[...s,i])}delete(o){let i=o.toLowerCase();this.headers.delete(i)}get(o){let i=o.toLowerCase(),t=this.headers.get(i);return t?t.join(", "):null}has(o){let i=o.toLowerCase();return this.headers.has(i)}set(o,i){let t=o.toLowerCase();this.headers.set(t,[i])}forEach(o,i){let t=i?o.bind(i):o;this.headers.forEach((s,r)=>t(s.join(", "),r,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[o,i]of this.headers.entries())yield[o,i.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let o of this.headers.values())yield o.join(", ")}[Symbol.iterator](){return this.entries()}};var mR="timeout";function hc(p){let o=new AbortController,i=setTimeout(()=>o.abort(mR),p);return{signal:o.signal,abortId:i}}function gc(...p){let o=p.length===1&&Array.isArray(p[0])?p[0]:p,i=new AbortController;for(let t of o){if(t.aborted){i.abort(t?.reason);break}t.addEventListener("abort",()=>i.abort(t?.reason),{signal:i.signal})}return i.signal}var po;function hR(){if(po!=null)return po;try{new Request("http://localhost",{cache:"no-store"}),po=!0}catch{po=!1}return po}var gi=async(p,o,i,t,s,r,a,u,g,h)=>{let l=[],y;if(r!=null){let{signal:T,abortId:O}=hc(r);y=O,l.push(T)}a!=null&&l.push(a);let w=gc(l),U=await p(o,{method:i,headers:t,body:s,signal:w,credentials:u?"include":void 0,duplex:g,...h&&hR()?{cache:"no-store"}:{}});return y!=null&&clearTimeout(y),U};var yi={headers:new ir,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},wi={headers:new ir,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function uo(p){return{headers:p.headers,redirected:p.redirected,status:p.status,statusText:p.statusText,type:p.type,url:p.url}}function gR(p){return[408,429].includes(p)||p>=500}function yR(p){let o=1+Math.random()*.2;return p*o}function wR(p){let o=1+(Math.random()-.5)*.2;return p*o}function bR(p,o){let i=p.headers.get("Retry-After");if(i){let s=parseInt(i,10);if(!Number.isNaN(s)&&s>0)return Math.min(s*1e3,6e4);let r=new Date(i);if(!Number.isNaN(r.getTime())){let a=r.getTime()-Date.now();if(a>0)return Math.min(Math.max(a,0),6e4)}}let t=p.headers.get("X-RateLimit-Reset");if(t){let s=parseInt(t,10);if(!Number.isNaN(s)){let r=s*1e3-Date.now();if(r>0)return yR(Math.min(r,6e4))}}return wR(Math.min(1e3*2**o,6e4))}async function bi(p,o=2){let i=await p();for(let t=0;t<o&&gR(i.status);++t){let s=bR(i,t);await new Promise(r=>setTimeout(r,s)),i=await p()}return i}var zR=new Set(["authorization","www-authenticate","x-api-key","api-key","apikey","x-api-token","x-auth-token","auth-token","cookie","set-cookie","proxy-authorization","proxy-authenticate","x-csrf-token","x-xsrf-token","x-session-token","x-access-token"]);function Da(p){let o={};for(let[i,t]of p instanceof ir?p.entries():Object.entries(p))zR.has(i.toLowerCase())?o[i]="[REDACTED]":o[i]=t;return o}var Ma=new Set(["api_key","api-key","apikey","token","access_token","access-token","auth_token","auth-token","password","passwd","secret","api_secret","api-secret","apisecret","key","session","session_id","session-id"]);function RR(p){if(p==null)return;let o={};for(let[i,t]of Object.entries(p))o[i]=Ma.has(i.toLowerCase())?"[REDACTED]":t;return o}function si(p){let o=p.indexOf("://");if(o===-1)return p;let i=o+3,t=p.indexOf("/",i),s=p.indexOf("?",i),r=p.indexOf("#",i),a=Math.min(t===-1?p.length:t,s===-1?p.length:s,r===-1?p.length:r),u=-1;for(let T=i;T<a;T++)p[T]==="@"&&(u=T);if(u!==-1&&(p=`${p.slice(0,i)}[REDACTED]@${p.slice(u+1)}`),s=p.indexOf("?"),s===-1)return p;r=p.indexOf("#",s);let g=r!==-1?r:p.length,h=p.slice(s+1,g);if(h.length===0)return p;let l=h.toLowerCase();if(!(l.includes("token")||l.includes("key")||l.includes("password")||l.includes("passwd")||l.includes("secret")||l.includes("session")||l.includes("auth")))return p;let w=[],U=h.split("&");for(let T of U){let O=T.indexOf("=");if(O===-1){w.push(T);continue}let A=T.slice(0,O),j=Ma.has(A.toLowerCase());if(!j&&A.includes("%"))try{let D=decodeURIComponent(A);j=Ma.has(D.toLowerCase())}catch{}w.push(j?`${A}=[REDACTED]`:T)}return p.slice(0,s+1)+w.join("&")+p.slice(g)}async function fR(p){let o=new ir;if(o.set("Accept",p.responseType==="json"?"application/json":p.responseType==="text"?"text/plain":p.responseType==="sse"?"text/event-stream":"*/*"),p.body!==void 0&&p.contentType!=null&&o.set("Content-Type",p.contentType),p.headers==null)return o;for(let[i,t]of Object.entries(p.headers)){let s=await ko.get(t,{endpointMetadata:p.endpointMetadata??{}});if(typeof s=="string"){o.set(i,s);continue}s!=null&&o.set(i,`${s}`)}return o}async function _R(p){let o=p.url;p.queryString!=null&&p.queryString.length>0?o=`${o}?${p.queryString}`:o=Bo(p.url,p.queryParameters);let i=await jo({body:p.body,type:p.requestType??"other"}),t=p.fetchFn??await hi(),s=await fR(p),r=lo(p.logging);if(r.isDebug()){let a={method:p.method,url:si(o),headers:Da(s),queryParameters:RR(p.queryParameters),hasBody:i!=null};r.debug("Making HTTP request",a)}try{let a=await bi(async()=>gi(t,o,p.method,s,i,p.timeoutMs,p.abortSignal,p.withCredentials,p.duplex,p.responseType==="streaming"||p.responseType==="sse"),p.maxRetries);if(a.status>=200&&a.status<400){if(r.isDebug()){let g={method:p.method,url:si(o),statusCode:a.status,responseHeaders:Da(a.headers)};r.debug("HTTP request succeeded",g)}return{ok:!0,body:await mi(a,p.responseType),headers:a.headers,rawResponse:uo(a)}}else{if(r.isError()){let u={method:p.method,url:si(o),statusCode:a.status,responseHeaders:Da(Object.fromEntries(a.headers.entries()))};r.error("HTTP request failed with error status",u)}return{ok:!1,error:{reason:"status-code",statusCode:a.status,body:await dc(a)},rawResponse:uo(a)}}}catch(a){if(p.abortSignal?.aborted){if(r.isError()){let u={method:p.method,url:si(o)};r.error("HTTP request was aborted",u)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:a},rawResponse:yi}}else if(a instanceof Error&&a.name==="AbortError"){if(r.isError()){let u={method:p.method,url:si(o),timeoutMs:p.timeoutMs};r.error("HTTP request timed out",u)}return{ok:!1,error:{reason:"timeout",cause:a},rawResponse:yi}}else if(a instanceof Error){if(r.isError()){let u={method:p.method,url:si(o),errorMessage:a.message};r.error("HTTP request failed with error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:a.message,cause:a},rawResponse:wi}}if(r.isError()){let u={method:p.method,url:si(o),error:ve(a)};r.error("HTTP request failed with unknown error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:ve(a),cause:a},rawResponse:wi}}}var E=_R;var R=class p extends Promise{constructor(o){super(i=>{i(void 0)}),this.innerPromise=o}static fromFunction(o,...i){return new p(o(...i))}static interceptFunction(o){return(...i)=>p.fromPromise(o(...i))}static fromPromise(o){return new p(o)}static fromExecutor(o){let i=new Promise(o);return new p(i)}static fromResult(o){let i=Promise.resolve(o);return new p(i)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:o})=>o)),this.unwrappedPromise}then(o,i){return this.unwrap().then(o,i)}catch(o){return this.unwrap().catch(o)}finally(o){return this.unwrap().finally(o)}async withRawResponse(){return await this.innerPromise}};function Ao(p,...o){if(!p)return"";if(o.length===0)return p;if(p.includes("://")){let i;try{i=new URL(p)}catch{return yc(p,...o)}let s=o[o.length-1]?.endsWith("/");for(let r of o){let a=bc(r);a&&(i.pathname=wc(i.pathname,a))}return s&&!i.pathname.endsWith("/")&&(i.pathname+="/"),i.toString()}return yc(p,...o)}function yc(p,...o){if(o.length===0)return p;let i=p,s=o[o.length-1]?.endsWith("/");for(let r of o){let a=bc(r);a&&(i=wc(i,a))}return s&&!i.endsWith("/")&&(i+="/"),i}function wc(p,o){return p.endsWith("/")?p+o:`${p}/${o}`}function bc(p){if(!p)return p;let o=0,i=p.length;return p.startsWith("/")&&(o=1),p.endsWith("/")&&(i=p.length-1),o===0&&i===p.length?p:p.slice(o,i)}var m={get:async p=>typeof p=="function"?p():p};async function Ia(p,o,i,t){let s=lo(i.logging),r,a=o;p instanceof Request?(r=p.url,o==null&&(a={method:p.method,headers:Object.fromEntries(p.headers.entries()),body:p.body,signal:p.signal,credentials:p.credentials,cache:p.cache,redirect:p.redirect,referrer:p.referrer,integrity:p.integrity,mode:p.mode})):r=p instanceof URL?p.toString():p;let u=(i.baseUrl!=null?await m.get(i.baseUrl):void 0)??(i.environment!=null?await m.get(i.environment):void 0),g;r.startsWith("http://")||r.startsWith("https://")?g=r:u!=null?g=Ao(u,r):g=r;let h={};if(i.headers!=null)for(let[D,V]of Object.entries(i.headers)){let re=await ko.get(V,{endpointMetadata:{}});re!=null&&(h[D.toLowerCase()]=`${re}`)}if(i.getAuthHeaders!=null){let D=await i.getAuthHeaders();for(let[V,re]of Object.entries(D))h[V.toLowerCase()]=re}if(a?.headers!=null){let D=a.headers instanceof Headers?Object.fromEntries(a.headers.entries()):Array.isArray(a.headers)?Object.fromEntries(a.headers):a.headers;for(let[V,re]of Object.entries(D))re!=null&&(h[V.toLowerCase()]=re)}if(t?.headers!=null)for(let[D,V]of Object.entries(t.headers))h[D.toLowerCase()]=V;let l=a?.method??"GET",y=a?.body,w=t?.timeoutInSeconds??i.timeoutInSeconds,U=w!=null?w*1e3:void 0,T=t?.maxRetries??i.maxRetries,O=t?.abortSignal??a?.signal??void 0,A=i.fetch??await hi();s.isDebug()&&s.debug("Making passthrough HTTP request",{method:l,url:g,hasBody:y!=null});let j=await bi(async()=>gi(A,g,l,h,y??void 0,U,O,a?.credentials==="include",void 0,!1),T);return s.isDebug()&&s.debug("Passthrough HTTP request completed",{method:l,url:g,statusCode:j.status}),j}var Vo={};Rr(Vo,{ConsoleLogger:()=>co,LogLevel:()=>Ze,Logger:()=>di,createLogger:()=>lo});var e={};Rr(e,{JsonError:()=>zi,ParseError:()=>Ri,any:()=>Bc,bigint:()=>Rc,boolean:()=>jc,booleanLiteral:()=>Oc,date:()=>fc,discriminant:()=>Gc,enum_:()=>mo,forwardCompatibleEnum_:()=>_c,getObjectLikeUtils:()=>Xe,getObjectUtils:()=>ci,getSchemaUtils:()=>J,isProperty:()=>Sr,lazy:()=>Sc,lazyObject:()=>vc,list:()=>Mo,never:()=>Ac,number:()=>Vc,object:()=>Do,objectWithoutOptionalProperties:()=>Uc,optional:()=>Fa,partialRecord:()=>Ic,property:()=>xc,record:()=>Mc,set:()=>Fc,string:()=>qc,stringLiteral:()=>kc,transform:()=>Ka,undiscriminatedUnion:()=>Lc,union:()=>Hc,unknown:()=>Dc,withParsedProperties:()=>Wa});var I={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function $(p,o){return`Expected ${o}. Received ${SR(p)}.`}function SR(p){if(Array.isArray(p))return"list";if(p===null)return"null";if(p instanceof BigInt)return"BigInt";switch(typeof p){case"string":return`"${p}"`;case"bigint":case"number":case"boolean":case"undefined":return`${p}`}return typeof p}function ye(p){return{...p,json:zc(p.json),parse:zc(p.parse)}}function zc(p){return(o,i)=>{let t=p(o,i),{skipValidation:s=!1}=i??{};return!t.ok&&s?(console.warn(["Failed to validate.",...t.errors.map(r=>" - "+(r.path.length>0?`${r.path.join(".")}: ${r.message}`:r.message))].join(`
|
|
3
|
-
`)),{ok:!0,value:o}):t}}function qo(p){return p.path.length===0?p.message:`${p.path.join(" -> ")}: ${p.message}`}var zi=class extends Error{constructor(i){super(i.map(qo).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};var Ri=class extends Error{constructor(i){super(i.map(qo).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};function J(p){return{nullable:()=>PR(p),optional:()=>Fa(p),optionalNullable:()=>xR(p),transform:o=>Ka(p,o),parseOrThrow:(o,i)=>{let t=p.parse(o,i);if(t.ok)return t.value;throw new Ri(t.errors)},jsonOrThrow:(o,i)=>{let t=p.json(o,i);if(t.ok)return t.value;throw new zi(t.errors)}}}function PR(p){let o={parse:(i,t)=>i==null?{ok:!0,value:null}:p.parse(i,t),json:(i,t)=>i==null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.NULLABLE};return{...o,...J(o)}}function Fa(p){let o={parse:(i,t)=>i==null?{ok:!0,value:void 0}:p.parse(i,t),json:(i,t)=>t?.omitUndefined&&i===void 0?{ok:!0,value:void 0}:i==null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.OPTIONAL};return{...o,...J(o)}}function xR(p){let o={parse:(i,t)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.parse(i,t),json:(i,t)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.OPTIONAL_NULLABLE};return{...o,...J(o)}}function Ka(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);return r.ok?{ok:!0,value:o.transform(r.value)}:r},json:(t,s)=>{let r=o.untransform(t);return p.json(r,s)},getType:()=>p.getType()};return{...i,...J(i)}}function Rc(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o=="bigint"?{ok:!0,value:o}:typeof o=="number"?{ok:!0,value:BigInt(o)}:{ok:!1,errors:[{path:i,message:$(o,"bigint | number")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="bigint"?{ok:!1,errors:[{path:i,message:$(o,"bigint")}]}:{ok:!0,value:o},getType:()=>I.BIGINT};return{...ye(p),...J(p)}}var ER=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function fc(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="string"?{ok:!1,errors:[{path:i,message:$(o,"string")}]}:ER.test(o)?{ok:!0,value:new Date(o)}:{ok:!1,errors:[{path:i,message:$(o,"ISO 8601 date string")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>o instanceof Date?{ok:!0,value:o.toISOString()}:{ok:!1,errors:[{path:i,message:$(o,"Date object")}]},getType:()=>I.DATE};return{...ye(p),...J(p)}}function be(p,o){return()=>{let i={parse:o,json:o,getType:()=>p};return{...ye(i),...J(i)}}}function mo(p){let o=new Set(p);return be(I.ENUM,(t,{allowUnrecognizedEnumValues:s,breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$(t,"string")}]}:!o.has(t)&&!s?{ok:!1,errors:[{path:r,message:$(t,"enum")}]}:{ok:!0,value:t})()}function _c(p){return mo(p).transform({transform:o=>o,untransform:o=>o})}function Sc(p){let o=La(p);return{...o,...J(o)}}function La(p){return{parse:(o,i)=>fi(p).parse(o,i),json:(o,i)=>fi(p).json(o,i),getType:()=>fi(p).getType()}}function fi(p){let o=p;return o.__zurg_memoized==null&&(o.__zurg_memoized=p()),o.__zurg_memoized}function Ga(p){return Object.entries(p)}function ho(p,o){let i=new Set(o);return Object.entries(p).reduce((t,[s,r])=>(i.has(s)&&(t[s]=r),t),{})}function _r(p){if(typeof p!="object"||p===null)return!1;let o=Object.getPrototypeOf(p);return o===null?!0:Object.getPrototypeOf(o)===null}function go(p){return Object.keys(p)}function Pc(p,o){let i=[],t=[];for(let s of p)o(s)?i.push(s):t.push(s);return[i,t]}var CR=Object.prototype.hasOwnProperty;function Xe(p){return{withParsedProperties:o=>Wa(p,o)}}function Wa(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);if(!r.ok)return r;let a={};for(let u in o)if(CR.call(o,u)){let g=o[u];a[u]=typeof g=="function"?g(r.value):g}return{ok:!0,value:{...r.value,...a}}},json:(t,s)=>{if(!_r(t))return{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:$(t,"object")}]};let r=new Set(Object.keys(o)),a=ho(t,Object.keys(t).filter(u=>!r.has(u)));return p.json(a,s)},getType:()=>p.getType()};return{...i,...J(i),...Xe(i)}}function xc(p,o){return{rawKey:p,valueSchema:o,isProperty:!0}}function Sr(p){return p.isProperty}var UR=Object.prototype.hasOwnProperty;function Do(p){let o;function i(){if(o==null){o={};for(let[w,U]of Ga(p)){let T=Sr(U)?U.rawKey:w,O=Sr(U)?U.valueSchema:U;o[T]={rawKey:T,parsedKey:w,valueSchema:O}}}return o}let t,s,r,a;function u(){if(t==null){t=[],s=[];for(let[w,U]of Ga(p)){let T=Sr(U)?U.rawKey:w,O=Sr(U)?U.valueSchema:U;vR(O)&&(t.push(T),s.push(w))}r=new Set(t),a=new Set(s)}return t}function g(){return s==null&&u(),s}function h(){return r==null&&u(),r}function l(){return a==null&&u(),a}let y={_getRawProperties:()=>Object.entries(p).map(([w,U])=>Sr(U)?U.rawKey:w),_getParsedProperties:()=>go(p),parse:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return Ec({value:w,requiredKeys:u(),requiredKeysSet:h(),getProperty:O=>{let A=i()[O];if(A!=null)return{transformedKey:A.parsedKey,transform:j=>{let D=[...T,O];return A.valueSchema.parse(j,{...U,breadcrumbsPrefix:D})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},json:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return Ec({value:w,requiredKeys:g(),requiredKeysSet:l(),getProperty:O=>{let A=p[O];if(A!=null)return Sr(A)?{transformedKey:A.rawKey,transform:j=>{let D=[...T,O];return A.valueSchema.json(j,{...U,breadcrumbsPrefix:D})}}:{transformedKey:O,transform:j=>{let D=[...T,O];return A.json(j,{...U,breadcrumbsPrefix:D})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},getType:()=>I.OBJECT};return{...ye(y),...J(y),...Xe(y),...ci(y)}}function Ec({value:p,requiredKeys:o,requiredKeysSet:i,getProperty:t,unrecognizedObjectKeys:s="fail",skipValidation:r=!1,breadcrumbsPrefix:a=[]}){if(!_r(p))return{ok:!1,errors:[{path:a,message:$(p,"object")}]};let u=o.length,g=[],h={};for(let l in p){if(!UR.call(p,l))continue;let y=p[l],w=t(l);if(w!=null){u>0&&i.has(l)&&u--;let U=w.transform(y);U.ok?h[w.transformedKey]=U.value:(h[l]=y,g.push(...U.errors))}else switch(s){case"fail":g.push({path:[...a,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":h[l]=y;break}}if(u>0)for(let l of o)l in p||g.push({path:a,message:`Missing required key "${l}"`});return g.length===0||r?{ok:!0,value:h}:{ok:!1,errors:g}}function ci(p){return{extend:o=>{let i={_getParsedProperties:()=>[...p._getParsedProperties(),...o._getParsedProperties()],_getRawProperties:()=>[...p._getRawProperties(),...o._getRawProperties()],parse:(t,s)=>Cc({extensionKeys:o._getRawProperties(),value:t,transformBase:r=>p.parse(r,s),transformExtension:r=>o.parse(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Cc({extensionKeys:o._getParsedProperties(),value:t,transformBase:r=>p.json(r,s),transformExtension:r=>o.json(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.OBJECT};return{...i,...J(i),...Xe(i),...ci(i)}},passthrough:()=>{let o=new Set(p._getRawProperties()),i=new Set(p._getParsedProperties()),t={_getParsedProperties:()=>p._getParsedProperties(),_getRawProperties:()=>p._getRawProperties(),parse:(s,r)=>{let a=p.parse(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!a.ok)return a;let u={};if(typeof s=="object"&&s!=null)for(let[g,h]of Object.entries(s))o.has(g)||(u[g]=h);return{ok:!0,value:{...u,...a.value}}},json:(s,r)=>{let a=p.json(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!a.ok)return a;let u={};if(typeof s=="object"&&s!=null)for(let[g,h]of Object.entries(s))i.has(g)||(u[g]=h);return{ok:!0,value:{...u,...a.value}}},getType:()=>I.OBJECT};return{...t,...J(t),...Xe(t),...ci(t)}}}}function Cc({extensionKeys:p,value:o,transformBase:i,transformExtension:t,breadcrumbsPrefix:s=[]}){if(!_r(o))return{ok:!1,errors:[{path:s,message:$(o,"object")}]};let r=new Set(p),[a,u]=Pc(go(o),l=>r.has(l)),g=i(ho(o,u)),h=t(ho(o,a));return g.ok&&h.ok?{ok:!0,value:{...g.value,...h.value}}:{ok:!1,errors:[...g.ok?[]:g.errors,...h.ok?[]:h.errors]}}function vR(p){return!TR(p)}function TR(p){switch(p.getType()){case I.ANY:case I.UNKNOWN:case I.OPTIONAL:case I.OPTIONAL_NULLABLE:return!0;default:return!1}}function Uc(p){return Do(p)}function vc(p){let o={...La(p),_getRawProperties:()=>fi(p)._getRawProperties(),_getParsedProperties:()=>fi(p)._getParsedProperties()};return{...o,...J(o),...Xe(o),...ci(o)}}function Mo(p){let o={parse:(i,t)=>Tc(i,(s,r)=>p.parse(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),json:(i,t)=>Tc(i,(s,r)=>p.json(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),getType:()=>I.LIST};return{...ye(o),...J(o)}}function Tc(p,o){if(!Array.isArray(p))return{ok:!1,errors:[{message:$(p,"list"),path:[]}]};let i=[],t=[];for(let s=0;s<p.length;s++){let r=o(p[s],s);r.ok?i.push(r.value):t.push(...r.errors)}return t.length===0?{ok:!0,value:i}:{ok:!1,errors:t}}function Oc(p){return be(I.BOOLEAN_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:$(i,`${p.toString()}`)}]})()}function kc(p){return be(I.STRING_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:$(i,`"${p}"`)}]})()}var Bc=be(I.ANY,p=>({ok:!0,value:p}));var jc=be(I.BOOLEAN,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="boolean"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"boolean")}]});var Ac=be(I.NEVER,(p,{breadcrumbsPrefix:o=[]}={})=>({ok:!1,errors:[{path:o,message:"Expected never"}]}));var Vc=be(I.NUMBER,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="number"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"number")}]});var qc=be(I.STRING,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="string"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"string")}]});var Dc=be(I.UNKNOWN,p=>({ok:!0,value:p}));var OR=Object.prototype.hasOwnProperty;function Mc(p,o){let i={parse:(t,s)=>Io({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Io({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.RECORD};return{...ye(i),...J(i)}}function Ic(p,o){let i={parse:(t,s)=>Io({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Io({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.RECORD};return{...ye(i),...J(i)}}function Io({value:p,isKeyNumeric:o,transformKey:i,transformValue:t,breadcrumbsPrefix:s=[]}){if(!_r(p))return{ok:!1,errors:[{path:s,message:$(p,"object")}]};let r={},a=[];for(let u in p){if(!OR.call(p,u))continue;let g=p[u];if(g===void 0)continue;let h=u;if(o){let w=u.length>0?Number(u):NaN;Number.isNaN(w)||(h=w)}let l=i(h),y=t(g,h);l.ok&&y.ok?r[l.value]=y.value:(l.ok||a.push(...l.errors),y.ok||a.push(...y.errors))}return a.length===0?{ok:!0,value:r}:{ok:!1,errors:a}}function Fc(p){let o=Mo(p),i={parse:(t,s)=>{let r=o.parse(t,s);return r.ok?{ok:!0,value:new Set(r.value)}:r},json:(t,s)=>t instanceof Set?o.json([...t],s):{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:$(t,"Set")}]},getType:()=>I.SET};return{...ye(i),...J(i)}}function Lc(p){let o={parse:(i,t)=>Kc((s,r)=>s.parse(i,r),p,t),json:(i,t)=>Kc((s,r)=>s.json(i,r),p,t),getType:()=>I.UNDISCRIMINATED_UNION};return{...ye(o),...J(o)}}function Kc(p,o,i){let t=[];for(let[s,r]of o.entries()){let a=p(r,{...i,skipValidation:!1});if(a.ok)return a;for(let u of a.errors)t.push({path:u.path,message:`[Variant ${s}] ${u.message}`})}return{ok:!1,errors:t}}function Gc(p,o){return{parsedDiscriminant:p,rawDiscriminant:o}}var kR=Object.prototype.hasOwnProperty;function Hc(p,o){let i=typeof p=="string"?p:p.rawDiscriminant,t=typeof p=="string"?p:p.parsedDiscriminant,s=mo(go(o)),r={parse:(a,u)=>Wc({value:a,discriminant:i,transformedDiscriminant:t,transformDiscriminantValue:g=>s.parse(g,{allowUnrecognizedEnumValues:u?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...u?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:g=>o[g],allowUnrecognizedUnionMembers:u?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(g,h)=>h.parse(g,u),breadcrumbsPrefix:u?.breadcrumbsPrefix}),json:(a,u)=>Wc({value:a,discriminant:t,transformedDiscriminant:i,transformDiscriminantValue:g=>s.json(g,{allowUnrecognizedEnumValues:u?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...u?.breadcrumbsPrefix??[],t]}),getAdditionalPropertiesSchema:g=>o[g],allowUnrecognizedUnionMembers:u?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(g,h)=>h.json(g,u),breadcrumbsPrefix:u?.breadcrumbsPrefix}),getType:()=>I.UNION};return{...ye(r),...J(r),...Xe(r)}}function Wc({value:p,discriminant:o,transformedDiscriminant:i,transformDiscriminantValue:t,getAdditionalPropertiesSchema:s,allowUnrecognizedUnionMembers:r=!1,transformAdditionalProperties:a,breadcrumbsPrefix:u=[]}){if(!_r(p))return{ok:!1,errors:[{path:u,message:$(p,"object")}]};let g=p[o],h={};for(let U in p)kR.call(p,U)&&U!==o&&(h[U]=p[U]);if(g==null)return{ok:!1,errors:[{path:u,message:`Missing discriminant ("${o}")`}]};let l=t(g);if(!l.ok)return{ok:!1,errors:l.errors};let y=s(l.value);if(y==null)return r?{ok:!0,value:{[i]:l.value,...h}}:{ok:!1,errors:[{path:[...u,o],message:"Unexpected discriminant value"}]};let w=a(h,y);return w.ok?{ok:!0,value:{[i]:g,...w.value}}:w}var d={};Rr(d,{encodePathParam:()=>Nc,join:()=>Ao,queryBuilder:()=>$c,toQueryString:()=>fr});function Nc(p){if(p===null)return"null";switch(typeof p){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:p=String(p);break}return encodeURIComponent(p)}function $c(){return new Ha}var Ha=class{constructor(){this.parts=new Map}add(o,i,t){if(i==null)return this;let s=fr({[o]:i},{arrayFormat:t?.style==="comma"?"comma":"repeat"});return s.length>0&&this.parts.set(o,s),this}addMany(o){if(o!=null)for(let[i,t]of Object.entries(o))this.add(i,t);return this}mergeAdditional(o){if(o!=null)for(let[i,t]of Object.entries(o)){if(t==null)continue;let s=fr({[i]:t},{arrayFormat:"repeat"});s.length>0&&this.parts.set(i,s)}return this}build(){return[...this.parts.values()].join("&")}};var Na="apiKey",BR="X-Schematic-Api-Key",_i=class p{constructor(o){this.options=o}static canCreate(o){return o?.[Na]!=null}async getAuthRequest({endpointMetadata:o}={}){let i=await m.get(this.options[Na]);if(i==null)throw new b({message:p.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[BR]:i}}}};(t=>{t.AUTH_SCHEME="ApiKeyAuth",t.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${Na}' when initializing the client`;function i(s){return new t(s)}t.createInstance=i})(_i||={});function f(...p){let o={};for(let[i,t]of p.filter(s=>s!=null).flatMap(s=>Object.entries(s))){let s=i.toLowerCase();t!=null?o[s]=t:s in o&&delete o[s]}return o}function jR(p){let o=f({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@schematichq/schematic-typescript-node","X-Fern-SDK-Version":"1.5.5","User-Agent":"@schematichq/schematic-typescript-node/1.5.5","X-Fern-Runtime":fe.type,"X-Fern-Runtime-Version":fe.version},p?.headers);return{...p,logging:Vo.createLogger(p?.logging),headers:o}}function K(p){let o=jR(p);if(p.auth===!1)return o.authProvider=new ui,o;if(p.auth!=null){if(typeof p.auth=="function")return o.authProvider={getAuthRequest:p.auth},o;if(ka(p.auth))return o.authProvider=p.auth,o;Object.assign(o,p.auth)}let i=AR(o);return o.authProvider??=new _i(i),o}function AR(p){return{...p,authProvider:new ui}}var z={Default:"https://api.schematichq.com"};function C(p,o,i,t){switch(p.reason){case"non-json":throw new b({statusCode:p.statusCode,body:p.rawBody,rawResponse:o});case"body-is-null":throw new b({statusCode:p.statusCode,rawResponse:o});case"timeout":throw new ai(`Timeout exceeded when calling ${i} ${t}.`,{cause:p.cause});case"unknown":throw new b({message:p.errorMessage,rawResponse:o,cause:p.cause});default:throw new b({message:"Unknown error",rawResponse:o})}}var $a=e.object({lookup:e.record(e.string(),e.string())});var Jc=e.stringLiteral("company");var Yc=e.object({apiKeyId:e.property("api_key_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),expiredAt:e.property("expired_at",e.date()),id:e.string(),resourceType:e.property("resource_type",Jc),token:e.string(),updatedAt:e.property("updated_at",e.date())});var Zc=e.object({data:Yc,params:e.record(e.string(),e.unknown())});var Ja=e.object({description:e.string().optional(),environmentId:e.property("environment_id",e.string().optional()),name:e.string(),readonly:e.boolean().optional()});var kr=e.enum_(["development","production","staging"]);var Ya=e.object({environmentType:e.property("environment_type",kr),name:e.string()});var Za=e.object({description:e.string().optional(),name:e.string().optional()});var Xa=e.object({environmentType:e.property("environment_type",kr.optional()),name:e.string().optional()});var Xc=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var q=e.object({count:e.number().optional()});var Qc=e.object({data:q,params:Xc});var el=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var rl=e.object({data:q,params:el});var Ee=e.enum_(["api_key","app_user","stripe_app","system","temporary_access_token"]);var il=e.object({actorType:e.property("actor_type",Ee.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var ol=e.object({data:q,params:il});var Me=e.enum_(["active","created","pending"]);var Se=e.enum_(["clerk","metronome","orb","stripe","unknown","workos"]);var Fo=e.object({id:e.string(),state:Me,type:Se});var Ko=e.enum_(["admin","capture","read","write"]);var Pe=e.object({createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",kr),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var tl=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:Fo.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(Ko),secret:e.string(),updatedAt:e.property("updated_at",e.date())});var al=e.object({data:tl,params:e.record(e.string(),e.unknown())});var xe=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:Fo.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(Ko),updatedAt:e.property("updated_at",e.date())});var nl=e.object({apiKeys:e.property("api_keys",e.list(xe)),createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",kr),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var sl=e.object({data:nl,params:e.record(e.string(),e.unknown())});var F=e.object({deleted:e.boolean().optional()});var cl=e.object({data:F,params:e.record(e.string(),e.unknown())});var ll=e.object({data:F,params:e.record(e.string(),e.unknown())});var pl=e.enum_(["companies_edit","company_users_edit","components_edit","custom_plans_edit","data_exports_edit","features_edit","flag_rules_edit","flags_edit","overrides_edit","plan_billing_edit","plan_entitlements_edit","plan_versions_edit","plans_edit","webhooks_edit","webhooks_reveal_secret"]);var ul=e.enum_(["admin","member"]);var Br=e.object({createdAt:e.property("created_at",e.date()),email:e.string().optional(),firstName:e.property("first_name",e.string().optional()),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),lastName:e.property("last_name",e.string().optional()),name:e.string().optional(),permissions:e.record(e.string(),e.list(pl)),role:ul.optional(),updatedAt:e.property("updated_at",e.date())});var dl=e.object({data:Br,params:e.record(e.string(),e.unknown())});var ml=e.object({data:xe,params:e.record(e.string(),e.unknown())});var hl=e.object({actorType:e.property("actor_type",Ee),apiKey:e.property("api_key",xe.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),reqBody:e.property("req_body",e.string().optional()),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respBody:e.property("resp_body",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var gl=e.object({data:hl,params:e.record(e.string(),e.unknown())});var yl=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var wl=e.object({accountId:e.property("account_id",e.string()),accountName:e.property("account_name",e.string()),actorType:e.property("actor_type",Ee),apiKeyId:e.property("api_key_id",e.string().optional()),environmentId:e.property("environment_id",e.string().optional()),environments:e.list(Pe),stripeUserId:e.property("stripe_user_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var bl=e.object({data:wl,params:e.record(e.string(),e.unknown())});var zl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Rl=e.object({data:e.list(Br),params:zl});var fl=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var _l=e.object({data:e.list(xe),params:fl});var Sl=e.object({actorType:e.property("actor_type",Ee.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var Lo=e.object({actorType:e.property("actor_type",Ee),apiKey:e.property("api_key",xe.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userName:e.property("user_name",e.string().optional())});var Pl=e.object({data:e.list(Lo),params:Sl});var xl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var El=e.object({data:e.list(Pe),params:xl});var Cl=e.object({ok:e.boolean()});var Ul=e.object({data:Cl,params:e.record(e.string(),e.unknown())});var vl=e.object({data:xe,params:e.record(e.string(),e.unknown())});var Tl=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var k=e.enum_(["metronome","orb","schematic","stripe"]);var Qa=e.object({companyId:e.property("company_id",e.string().optional()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),email:e.string(),externalId:e.property("external_id",e.string()),meta:e.record(e.string(),e.string()),name:e.string(),providerType:e.property("provider_type",k.optional())});var or=e.enum_(["per_unit","tiered"]);var ne=e.enum_(["licensed","metered"]);var de=e.enum_(["graduated","volume"]);var Ol=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitDecimal:e.property("per_unit_decimal",e.string().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),priceExternalId:e.property("price_external_id",e.string()),providerType:e.property("provider_type",k.optional()),upTo:e.property("up_to",e.number().optional())});var en=e.object({billingScheme:e.property("billing_scheme",or),currency:e.string(),externalAccountId:e.property("external_account_id",e.string()),interval:e.string(),intervalCount:e.property("interval_count",e.number().optional()),isActive:e.property("is_active",e.boolean()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number().optional()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceTiers:e.property("price_tiers",e.list(Ol)),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k.optional()),tiersMode:e.property("tiers_mode",de.optional()),usageType:e.property("usage_type",ne)});var rn=e.object({externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean().optional()),name:e.string().optional(),price:e.number(),providerType:e.property("provider_type",k.optional())});var kl=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),currency:e.string(),interval:e.string(),meterId:e.property("meter_id",e.string().optional()),packageSize:e.property("package_size",e.number().optional()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),productExternalId:e.property("product_external_id",e.string()),quantity:e.number(),subscriptionItemExternalId:e.property("subscription_item_external_id",e.string().optional()),usageType:e.property("usage_type",ne)});var Bl=e.object({couponExternalId:e.property("coupon_external_id",e.string()),customerFacingCode:e.property("customer_facing_code",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date())});var jr=e.enum_(["cancel","subscribe"]);var on=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodExternalId:e.property("default_payment_method_external_id",e.string().optional()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),discounts:e.list(Bl),expiredAt:e.property("expired_at",e.date()),interval:e.string().optional(),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number().optional()),periodStart:e.property("period_start",e.number().optional()),productExternalIds:e.property("product_external_ids",e.list(kl)),providerType:e.property("provider_type",k.optional()),status:e.string().optional(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",jr.optional())});var tn=e.object({amountOff:e.property("amount_off",e.number()),currency:e.string().optional(),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number()),externalId:e.property("external_id",e.string()),maxRedemptions:e.property("max_redemptions",e.number()),name:e.string(),percentOff:e.property("percent_off",e.number()),timesRedeemed:e.property("times_redeemed",e.number())});var Go=e.enum_(["draft","open","paid","uncollectible","void"]);var an=e.object({amountDue:e.property("amount_due",e.number()),amountPaid:e.property("amount_paid",e.number()),amountRemaining:e.property("amount_remaining",e.number()),collectionMethod:e.property("collection_method",e.string()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),dueDate:e.property("due_date",e.date().optional()),endingBalance:e.property("ending_balance",e.number().optional()),externalId:e.property("external_id",e.string().optional()),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),startingBalance:e.property("starting_balance",e.number().optional()),status:Go.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),url:e.string().optional()});var nn=e.object({displayName:e.property("display_name",e.string()),eventName:e.property("event_name",e.string()),eventPayloadKey:e.property("event_payload_key",e.string()),externalId:e.property("external_id",e.string()),providerType:e.property("provider_type",k.optional())});var sn=e.object({accountLast4:e.property("account_last4",e.string().optional()),accountName:e.property("account_name",e.string().optional()),bankName:e.property("bank_name",e.string().optional()),billingEmail:e.property("billing_email",e.string().optional()),billingName:e.property("billing_name",e.string().optional()),cardBrand:e.property("card_brand",e.string().optional()),cardExpMonth:e.property("card_exp_month",e.number().optional()),cardExpYear:e.property("card_exp_year",e.number().optional()),cardLast4:e.property("card_last4",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string()),externalId:e.property("external_id",e.string()),paymentMethodType:e.property("payment_method_type",e.string())});var jl=e.object({ids:e.list(e.string()).optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),priceUsageType:e.property("price_usage_type",ne.optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),recurringChargesOnly:e.property("recurring_charges_only",e.boolean().optional()),withOneTimeCharges:e.property("with_one_time_charges",e.boolean().optional()),withPricesOnly:e.property("with_prices_only",e.boolean().optional()),withZeroPrice:e.property("with_zero_price",e.boolean().optional()),withoutLinkedToPlan:e.property("without_linked_to_plan",e.boolean().optional())});var Al=e.object({data:q,params:jl});var Vl=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),providerType:e.property("provider_type",k.optional()),q:e.string().optional()});var ql=e.object({data:q,params:Vl});var Dl=e.object({data:F,params:e.record(e.string(),e.unknown())});var Ml=e.object({data:F,params:e.record(e.string(),e.unknown())});var Il=e.object({data:F,params:e.record(e.string(),e.unknown())});var Fl=e.object({data:F,params:e.record(e.string(),e.unknown())});var Kl=e.object({data:F,params:e.record(e.string(),e.unknown())});var Ll=e.object({data:F,params:e.record(e.string(),e.unknown())});var Gl=e.object({currency:e.string().optional(),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),ids:e.list(e.string()).optional(),interval:e.string().optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),price:e.number().optional(),productId:e.property("product_id",e.string().optional()),productIds:e.property("product_ids",e.list(e.string()).optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),tiersMode:e.property("tiers_mode",de.optional()),usageType:e.property("usage_type",ne.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var Si=e.enum_(["day","month","one-time","year"]);var Wo=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),upTo:e.property("up_to",e.number().optional())});var H=e.object({billingScheme:e.property("billing_scheme",or),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:Si,intervalCount:e.property("interval_count",e.number()),isActive:e.property("is_active",e.boolean()),meterEventName:e.property("meter_event_name",e.string().optional()),meterEventPayloadKey:e.property("meter_event_payload_key",e.string().optional()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceId:e.property("price_id",e.string()),priceTier:e.property("price_tier",e.list(Wo)),productExternalId:e.property("product_external_id",e.string()),productId:e.property("product_id",e.string()),productName:e.property("product_name",e.string()),providerType:e.property("provider_type",k),tiersMode:e.property("tiers_mode",de.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",ne)});var Wl=e.object({data:e.list(H),params:Gl});var Hl=e.object({currency:e.string().optional(),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),ids:e.list(e.string()).optional(),interval:e.string().optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),price:e.number().optional(),productId:e.property("product_id",e.string().optional()),productIds:e.property("product_ids",e.list(e.string()).optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),tiersMode:e.property("tiers_mode",de.optional()),usageType:e.property("usage_type",ne.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var Nl=e.object({data:e.list(H),params:Hl});var $l=e.object({ids:e.list(e.string()).optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),priceUsageType:e.property("price_usage_type",ne.optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),recurringChargesOnly:e.property("recurring_charges_only",e.boolean().optional()),withOneTimeCharges:e.property("with_one_time_charges",e.boolean().optional()),withPricesOnly:e.property("with_prices_only",e.boolean().optional()),withZeroPrice:e.property("with_zero_price",e.boolean().optional()),withoutLinkedToPlan:e.property("without_linked_to_plan",e.boolean().optional())});var L=e.object({currency:e.string(),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),interval:Si,intervalCount:e.property("interval_count",e.number()),nickname:e.string().optional(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),providerType:e.property("provider_type",k),scheme:or});var tr=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),currency:e.string().optional(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),name:e.string(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),prices:e.list(L),productId:e.property("product_id",e.string()),providerType:e.property("provider_type",k),quantity:e.number(),subscriptionCount:e.property("subscription_count",e.number()),updatedAt:e.property("updated_at",e.date())});var Jl=e.object({data:e.list(tr),params:$l});var Yl=e.object({isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ho=e.object({accountId:e.property("account_id",e.string()),amountOff:e.property("amount_off",e.number().optional()),currency:e.string().optional(),duration:e.string().optional(),durationInMonths:e.property("duration_in_months",e.number().optional()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),isActive:e.property("is_active",e.boolean()),maxRedemptions:e.property("max_redemptions",e.number().optional()),metadata:e.record(e.string(),e.unknown()),name:e.string(),percentOff:e.property("percent_off",e.number().optional()),providerType:e.property("provider_type",k),timesRedeemed:e.property("times_redeemed",e.number()),validFrom:e.property("valid_from",e.date().optional()),validUntil:e.property("valid_until",e.date().optional())});var Zl=e.object({data:e.list(Ho),params:Yl});var Xl=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),providerType:e.property("provider_type",k.optional()),q:e.string().optional()});var Ql=e.object({currency:e.string(),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),meteredUsage:e.property("metered_usage",e.boolean()),perUnitPrice:e.property("per_unit_price",e.number()),totalPrice:e.property("total_price",e.number())});var ep=e.object({companyId:e.property("company_id",e.string().optional()),deletedAt:e.property("deleted_at",e.date().optional()),email:e.string(),externalId:e.property("external_id",e.string()),id:e.string(),name:e.string(),providerType:e.property("provider_type",k),subscriptions:e.list(Ql),updatedAt:e.property("updated_at",e.date())});var rp=e.object({data:e.list(ep),params:Xl});var ip=e.object({companyId:e.property("company_id",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional())});var Ve=e.object({amountDue:e.property("amount_due",e.number()),amountPaid:e.property("amount_paid",e.number()),amountRemaining:e.property("amount_remaining",e.number()),collectionMethod:e.property("collection_method",e.string()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),dueDate:e.property("due_date",e.date().optional()),endingBalance:e.property("ending_balance",e.number()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string().optional()),id:e.string(),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),providerType:e.property("provider_type",k),startingBalance:e.property("starting_balance",e.number()),status:Go.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),updatedAt:e.property("updated_at",e.date()),url:e.string().optional()});var op=e.object({data:e.list(Ve),params:ip});var tp=e.object({displayName:e.property("display_name",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var No=e.object({dispalyName:e.property("dispaly_name",e.string()),eventName:e.property("event_name",e.string()),eventPayloadKey:e.property("event_payload_key",e.string()),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),providerType:e.property("provider_type",k)});var ap=e.object({data:e.list(No),params:tp});var np=e.object({companyId:e.property("company_id",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var qe=e.object({accountLast4:e.property("account_last4",e.string().optional()),accountName:e.property("account_name",e.string().optional()),bankName:e.property("bank_name",e.string().optional()),billingEmail:e.property("billing_email",e.string().optional()),billingName:e.property("billing_name",e.string().optional()),cardBrand:e.property("card_brand",e.string().optional()),cardExpMonth:e.property("card_exp_month",e.number().optional()),cardExpYear:e.property("card_exp_year",e.number().optional()),cardLast4:e.property("card_last4",e.string().optional()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),customerExternalId:e.property("customer_external_id",e.string()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),paymentMethodType:e.property("payment_method_type",e.string()),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var sp=e.object({data:e.list(qe),params:np});var cp=e.object({data:Ho,params:e.record(e.string(),e.unknown())});var lp=e.object({companyId:e.property("company_id",e.string().optional()),deletedAt:e.property("deleted_at",e.date().optional()),email:e.string(),externalId:e.property("external_id",e.string()),id:e.string(),name:e.string(),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var pp=e.object({data:lp,params:e.record(e.string(),e.unknown())});var up=e.object({data:No,params:e.record(e.string(),e.unknown())});var dp=e.object({data:L,params:e.record(e.string(),e.unknown())});var Ar=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),currency:e.string().optional(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),name:e.string(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),productId:e.property("product_id",e.string()),providerType:e.property("provider_type",k),quantity:e.number(),updatedAt:e.property("updated_at",e.date())});var mp=e.object({data:Ar,params:e.record(e.string(),e.unknown())});var hp=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",jr.optional())});var gp=e.object({data:hp,params:e.record(e.string(),e.unknown())});var yp=e.object({data:Ve,params:e.record(e.string(),e.unknown())});var wp=e.object({data:qe,params:e.record(e.string(),e.unknown())});var cn=e.object({description:e.string().optional(),isDefault:e.property("is_default",e.boolean()),name:e.string()});var bp=e.object({bundleId:e.property("bundle_id",e.string())});var zp=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var ln=e.object({entitlements:e.list(zp).optional(),planId:e.property("plan_id",e.string())});var pn=e.object({customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(ln).optional()),orderedBundles:e.property("ordered_bundles",e.list(bp).optional()),orderedPlans:e.property("ordered_plans",e.list(ln).optional()),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional())});var un=e.object({description:e.string().optional(),isDefault:e.property("is_default",e.boolean().optional()),name:e.string().optional()});var ar=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean()),description:e.string().optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),isDefault:e.property("is_default",e.boolean()),name:e.string(),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Rp=e.object({data:ar,params:e.record(e.string(),e.unknown())});var fp=e.object({data:F,params:e.record(e.string(),e.unknown())});var _p=e.object({data:ar,params:e.record(e.string(),e.unknown())});var Sp=e.object({bundleId:e.property("bundle_id",e.string())});var Pp=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean()});var dn=e.object({entitlements:e.list(Pp),planId:e.property("plan_id",e.string())});var Vr=e.enum_(["expiration_priority","first_in_first_out","last_in_first_out","plan_first_then_credit_bundles_first_in_first_out"]);var G=e.enum_(["billing_periods","days"]);var qr=e.enum_(["expire","none","rollover"]);var xp=e.object({currency:e.string(),price:L.optional()});var ge=e.object({burnStrategy:e.property("burn_strategy",Vr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(xp)),defaultExpiryUnit:e.property("default_expiry_unit",G),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",qr),description:e.string(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:L.optional(),product:Ar.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Te=e.object({billingProvider:e.property("billing_provider",k),externalResourceId:e.property("external_resource_id",e.string()),originator:k});var nr=e.enum_(["off","automatic","user_controlled"]);var Z=e.enum_(["duration","end_of_billing_period","end_of_next_billing_period","end_of_trial","no_expiry"]);var Oe=e.enum_(["daily","every_6_months","monthly","quarterly","weekly","yearly"]);var Ie=e.enum_(["billing_period","first_of_month"]);var sr=e.enum_(["no_reset","plan_period"]);var $o=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var ke=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",e.string().optional()),autoTopupAvailability:e.property("auto_topup_availability",nr),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Z.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",G.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean()),createdAt:e.property("created_at",e.date()),credit:ge.optional(),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),creditPluralName:e.property("credit_plural_name",e.string().optional()),creditSingularName:e.property("credit_singular_name",e.string().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:$o.optional(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),resetCadence:e.property("reset_cadence",Oe.optional()),resetStart:e.property("reset_start",Ie.optional()),resetType:e.property("reset_type",sr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number()),updatedAt:e.property("updated_at",e.date())});var Fe=e.enum_(["schematic_managed","provider_managed","no_billing"]);var Ke=e.enum_(["free","none","one_time","recurring"]);var Jo=e.object({ctaText:e.property("cta_text",e.string()),ctaWebSite:e.property("cta_web_site",e.string()),priceText:e.property("price_text",e.string())});var oe=e.enum_(["company","user"]);var me=e.enum_(["boolean","currency","date","number","string","url"]);var he=e.object({createdAt:e.property("created_at",e.date()),displayName:e.property("display_name",e.string()),entityType:e.property("entity_type",oe),hierarchy:e.list(e.string()),id:e.string(),traitType:e.property("trait_type",me),updatedAt:e.property("updated_at",e.date())});var Pi=e.object({companyCount:e.property("company_count",e.number()),environmentId:e.property("environment_id",e.string()),eventCount:e.property("event_count",e.number()),eventSubtype:e.property("event_subtype",e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),userCount:e.property("user_count",e.number())});var Le=e.enum_(["add_on","alpha","beta","deprecated","ga","inactive","in_plan","internal_testing","legacy"]);var se=e.enum_(["boolean","event","trait"]);var Dr=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",se),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var cr=e.stringLiteral("boolean");var Mr=e.enum_(["eq","gt","gte","is_empty","lt","lte","not_empty","ne"]);var xi=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var W=e.enum_(["all_time","current_day","current_month","current_week"]);var N=e.enum_(["billing_cycle","first_of_month"]);var Yo=e.object({comparisonTrait:e.property("comparison_trait",he.optional()),comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionGroupId:e.property("condition_group_id",e.string().optional()),conditionType:e.property("condition_type",xi),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Mr,resourceIds:e.property("resource_ids",e.list(e.string())),resources:e.list($o),ruleId:e.property("rule_id",e.string()),trait:he.optional(),traitEntityType:e.property("trait_entity_type",oe.optional()),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var Ep=e.object({conditions:e.list(Yo),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),ruleId:e.property("rule_id",e.string()),updatedAt:e.property("updated_at",e.date())});var Ir=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var Ei=e.object({conditionGroups:e.property("condition_groups",e.list(Ep)),conditions:e.list(Yo),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Ir),updatedAt:e.property("updated_at",e.date()),value:e.boolean()});var Cp=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:Dr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",cr),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Ei),updatedAt:e.property("updated_at",e.date())});var Fr=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Ge=e.object({billingLinkedResource:e.property("billing_linked_resource",Te.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Pi.optional()),featureType:e.property("feature_type",se),flags:e.list(Cp),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Fr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:he.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Kr=e.object({id:e.string(),name:e.string()});var Lr=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",L.optional()),oneTimePrice:e.property("one_time_price",L.optional()),quarterlyPrice:e.property("quarterly_price",L.optional()),yearlyPrice:e.property("yearly_price",L.optional())});var Up=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",H.optional()),quarterlyPrice:e.property("quarterly_price",H.optional()),yearlyPrice:e.property("yearly_price",H.optional())});var ze=e.enum_(["credit_burndown","overage","pay_as_you_go","pay_in_advance","tier"]);var Q=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var pe=e.enum_(["amber","blue","blueGray","blueGreen","cyan","emerald","fuchsia","gray","green","indigo","lightBlue","lime","orange","pink","purple","red","redOrange","rose","sky","slate","teal","trueGray","violet","warmGray","yellow"]);var te=e.enum_(["plan","add_on"]);var lr=e.object({audienceType:e.property("audience_type",e.string().optional()),companyId:e.property("company_id",e.string().optional()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),description:e.string(),icon:pe,id:e.string(),name:e.string(),planType:e.property("plan_type",te),updatedAt:e.property("updated_at",e.date())});var vp=e.object({id:e.string(),key:e.string(),value:e.number()});var ee=e.object({billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Up)),environmentId:e.property("environment_id",e.string()),feature:Dr.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),meteredMonthlyPrice:e.property("metered_monthly_price",H.optional()),meteredQuarterlyPrice:e.property("metered_quarterly_price",H.optional()),meteredYearlyPrice:e.property("metered_yearly_price",H.optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),plan:lr.optional(),planId:e.property("plan_id",e.string()),priceBehavior:e.property("price_behavior",ze.optional()),ruleId:e.property("rule_id",e.string()),ruleIdUsageExceeded:e.property("rule_id_usage_exceeded",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageBasedProduct:e.property("usage_based_product",Ar.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCredit:e.property("value_credit",ge.optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",he.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",Q),warningTiers:e.property("warning_tiers",e.list(vp))});var Ci=e.enum_(["monthly","quarterly","yearly"]);var Tp=e.enum_(["published","draft","archived"]);var Re=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:pe,id:e.string(),name:e.string(),originalPlanId:e.property("original_plan_id",e.string().optional()),planType:e.property("plan_type",te),status:Tp,updatedAt:e.property("updated_at",e.date()),version:e.number()});var pr=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ci)),billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",tr.optional()),billingStrategy:e.property("billing_strategy",Fe),catalogs:e.list(Kr).optional(),chargeType:e.property("charge_type",Ke),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ge),currencyPrices:e.property("currency_prices",e.list(Lr)),customPlanConfig:e.property("custom_plan_config",Jo.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ee).optional(),features:e.list(Ge),icon:pe,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ke).optional()),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",L.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",L.optional()),planType:e.property("plan_type",te),quarterlyPrice:e.property("quarterly_price",L.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(Re),yearlyPrice:e.property("yearly_price",L.optional())});var Op=e.object({addOns:e.property("add_ons",e.list(pr)),customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean()),orderedAddOns:e.property("ordered_add_ons",e.list(dn)),orderedBundles:e.property("ordered_bundles",e.list(Sp)),orderedPlans:e.property("ordered_plans",e.list(dn)),plans:e.list(pr),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional())});var kp=e.object({data:Op,params:e.record(e.string(),e.unknown())});var Bp=e.object({creditBundleIds:e.property("credit_bundle_ids",e.list(e.string()))});var jp=e.object({data:Bp,params:e.record(e.string(),e.unknown())});var Ap=e.object({icon:e.string(),id:e.string(),name:e.string()});var Vp=e.object({features:e.list(Ap)});var qp=e.object({data:Vp,params:e.record(e.string(),e.unknown())});var Dp=e.object({planIds:e.property("plan_ids",e.list(e.string()))});var Mp=e.object({data:Dp,params:e.record(e.string(),e.unknown())});var Ip=e.object({isDefault:e.property("is_default",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Fp=e.object({data:e.list(ar),params:Ip});var Kp=e.object({data:ar,params:e.record(e.string(),e.unknown())});var Lp=e.object({data:ar,params:e.record(e.string(),e.unknown())});var mn=e.object({cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),prorate:e.boolean().optional()});var hn=e.object({companyId:e.property("company_id",e.string()),currency:e.string().optional(),selectedPlanId:e.property("selected_plan_id",e.string().optional())});var gn=e.object({trialEnd:e.property("trial_end",e.date().optional())});var Ui=e.object({billingScheme:e.property("billing_scheme",or),billingThreshold:e.property("billing_threshold",e.number().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),interval:e.string(),intervalCount:e.property("interval_count",e.number().optional()),meterId:e.property("meter_id",e.string().optional()),name:e.string(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceId:e.property("price_id",e.string()),priceTier:e.property("price_tier",e.list(Wo)),providerType:e.property("provider_type",k),quantity:e.number(),subscriptionId:e.property("subscription_id",e.string()),subscriptionItemExternalId:e.property("subscription_item_external_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",ne)});var vi=e.object({amountOff:e.property("amount_off",e.number().optional()),couponId:e.property("coupon_id",e.string()),couponName:e.property("coupon_name",e.string()),currency:e.string().optional(),customerFacingCode:e.property("customer_facing_code",e.string().optional()),discountExternalId:e.property("discount_external_id",e.string()),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number().optional()),endedAt:e.property("ended_at",e.date().optional()),isActive:e.property("is_active",e.boolean()),percentOff:e.property("percent_off",e.number().optional()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date()),subscriptionExternalId:e.property("subscription_external_id",e.string())});var yo=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),discounts:e.list(vi),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),latestInvoice:e.property("latest_invoice",Ve.optional()),metadata:e.record(e.string(),e.unknown()).optional(),paymentMethod:e.property("payment_method",qe.optional()),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),products:e.list(Ui),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",jr.optional())});var Gp=e.object({accountId:e.property("account_id",e.string()),capturedAtMax:e.property("captured_at_max",e.date()),capturedAtMin:e.property("captured_at_min",e.date()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",N),period:W,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var Wp=e.enum_(["schematic_authoritative","external_mirror","external_rated"]);var Hp=e.object({currency:e.string(),price:H.optional()});var Zo=e.object({accountId:e.property("account_id",e.string()),burnStrategy:e.property("burn_strategy",Vr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Hp)),defaultExpiryUnit:e.property("default_expiry_unit",G),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",qr),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:e.string().optional(),id:e.string(),ledgerAuthority:e.property("ledger_authority",Wp),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:H.optional(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),product:Ar.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Ti=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Np=e.object({billingCreditAutoTopupAmount:e.property("billing_credit_auto_topup_amount",e.number().optional()),billingCreditAutoTopupAmountType:e.property("billing_credit_auto_topup_amount_type",e.string().optional()),billingCreditAutoTopupAvailability:e.property("billing_credit_auto_topup_availability",nr.optional()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Z.optional()),billingCreditAutoTopupExpiryUnit:e.property("billing_credit_auto_topup_expiry_unit",G.optional()),billingCreditAutoTopupExpiryUnitCount:e.property("billing_credit_auto_topup_expiry_unit_count",e.number().optional()),billingCreditAutoTopupSelfService:e.property("billing_credit_auto_topup_self_service",e.boolean()),billingCreditAutoTopupThresholdCredits:e.property("billing_credit_auto_topup_threshold_credits",e.number().optional()),billingCreditAutoTopupThresholdPercent:e.property("billing_credit_auto_topup_threshold_percent",e.number().optional()),billingCreditCanBuyBundles:e.property("billing_credit_can_buy_bundles",e.boolean()),companyAutoTopupAmount:e.property("company_auto_topup_amount",e.number().optional()),companyAutoTopupEnabled:e.property("company_auto_topup_enabled",e.boolean().optional()),companyAutoTopupThresholdCredits:e.property("company_auto_topup_threshold_credits",e.number().optional()),createdAt:e.property("created_at",e.date()),credit:Zo.optional(),creditAmount:e.property("credit_amount",e.number()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Ti.optional(),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),resetCadence:e.property("reset_cadence",Oe.optional()),resetStart:e.property("reset_start",Ie.optional()),resetType:e.property("reset_type",sr),rolloverPercentage:e.property("rollover_percentage",e.number()),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var yn=e.object({addedOn:e.property("added_on",e.date().optional()),billingProductExternalId:e.property("billing_product_external_id",e.string().optional()),billingProductId:e.property("billing_product_id",e.string().optional()),description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),includedCreditGrants:e.property("included_credit_grants",e.list(Np)),name:e.string(),planPeriod:e.property("plan_period",e.string().optional()),planPrice:e.property("plan_price",e.number().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var Oi=e.enum_(["on_payment","on_publish"]);var Pr=e.enum_(["active","expired","paid","pending"]);var Gr=e.object({activationStrategy:e.property("activation_strategy",Oi),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),daysUntilDue:e.property("days_until_due",e.number()),externalInvoiceId:e.property("external_invoice_id",e.string().optional()),id:e.string(),paidAt:e.property("paid_at",e.date().optional()),planId:e.property("plan_id",e.string()),publishedAt:e.property("published_at",e.date().optional()),status:Pr,stripeInvoiceUrl:e.property("stripe_invoice_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Xo=e.object({createdAt:e.property("created_at",e.date()),entityType:e.property("entity_type",oe),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date())});var Qo=e.object({createdAt:e.property("created_at",e.date()),definition:Xo.optional(),definitionId:e.property("definition_id",e.string()),entityId:e.property("entity_id",e.string()),entityType:e.property("entity_type",oe),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});var et=e.object({createdAt:e.property("created_at",e.date()),definition:he.optional(),definitionId:e.property("definition_id",e.string()),environmentId:e.property("environment_id",e.string()),id:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});var $p=e.object({key:e.string(),value:e.number()});var rt=e.object({allocation:e.number().optional(),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditReserved:e.property("credit_reserved",e.number().optional()),creditSettled:e.property("credit_settled",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditUsed:e.property("credit_used",e.number().optional()),eventName:e.property("event_name",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",Q),warningTiers:e.property("warning_tiers",e.list($p).optional())});var Jp=e.enum_(["bool","date","int","string"]);var wn=e.object({comparableType:e.property("comparable_type",Jp),entityType:e.property("entity_type",oe),id:e.string()});var it=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",wn.optional()),conditionType:e.property("condition_type",xi),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Mr,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",wn.optional()),traitValue:e.property("trait_value",e.string())});var Yp=e.object({conditions:e.list(it)});var Zp=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(Yp)),conditions:e.list(it),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Ir),value:e.boolean()});var ot=e.object({currency:e.string(),effectiveAfter:e.property("effective_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),fromPlanName:e.property("from_plan_name",e.string()),fromSubscriptionPrice:e.property("from_subscription_price",e.number()),id:e.string(),interval:e.string(),scheduledInterval:e.property("scheduled_interval",e.string().optional()),scheduledPrice:e.property("scheduled_price",e.number().optional()),toPlanId:e.property("to_plan_id",e.string()),toPlanName:e.property("to_plan_name",e.string())});var X=e.object({addOns:e.property("add_ons",e.list(yn)),billingCreditBalances:e.property("billing_credit_balances",e.record(e.string(),e.number()).optional()),billingSubscription:e.property("billing_subscription",yo.optional()),billingSubscriptions:e.property("billing_subscriptions",e.list(yo)),createdAt:e.property("created_at",e.date()),customPlanBillings:e.property("custom_plan_billings",e.list(Gr)),defaultPaymentMethod:e.property("default_payment_method",qe.optional()),entitlements:e.list(rt),entityTraits:e.property("entity_traits",e.list(et)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Qo),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),metrics:e.list(Gp),name:e.string(),paymentMethods:e.property("payment_methods",e.list(qe)),plan:yn.optional(),plans:e.list(Ti),rules:e.list(Zp),scheduledDowngrade:e.property("scheduled_downgrade",ot.optional()),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date()),userCount:e.property("user_count",e.number())});var tt=e.object({company:X.optional(),success:e.boolean()});var Xp=e.object({data:tt,params:e.record(e.string(),e.unknown())});var Qp=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),confirmPaymentIntentClientSecret:e.property("confirm_payment_intent_client_secret",e.string().optional()),confirmPaymentIntentId:e.property("confirm_payment_intent_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),invoiceId:e.property("invoice_id",e.string().optional()),invoiceUrl:e.property("invoice_url",e.string().optional()),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",jr.optional())});var eu=e.object({data:Qp,params:e.record(e.string(),e.unknown())});var Ce=e.enum_(["active","inactive"]);var De=e.stringLiteral("fixed");var ru=e.object({currency:e.string(),price:L.optional()});var We=e.object({billingInvoiceId:e.property("billing_invoice_id",e.string().optional()),bundleType:e.property("bundle_type",De),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string().optional()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currencyPrices:e.property("currency_prices",e.list(ru)),expiryType:e.property("expiry_type",Z),expiryUnit:e.property("expiry_unit",G),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),hasGrants:e.property("has_grants",e.boolean()),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:L.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Ce,unitPrice:e.property("unit_price",L.optional()),updatedAt:e.property("updated_at",e.date())});var at=e.object({definitionId:e.property("definition_id",e.string()),helperText:e.property("helper_text",e.string().optional()),id:e.string(),name:e.string(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string()),value:e.string().optional()});var ki=e.object({cancelAt:e.property("cancel_at",e.date().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),discounts:e.list(vi),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",Ve.optional()),paymentMethod:e.property("payment_method",qe.optional()),products:e.list(Ui),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.date().optional())});var iu=e.object({bundle:We.optional(),quantity:e.number(),total:e.number()});var Be=e.enum_(["adjustment","billing_credit_auto_topup","free","plan","purchased","rollover"]);var ou=e.object({createdAt:e.property("created_at",e.date()),externalUserId:e.property("external_user_id",e.string()),externalUserName:e.property("external_user_name",e.string()),id:e.string(),note:e.string(),updatedAt:e.property("updated_at",e.date())});var He=e.object({company:X.optional(),companyId:e.property("company_id",e.string()),consumptionRate:e.property("consumption_rate",e.number().optional()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),expirationDate:e.property("expiration_date",e.date().optional()),feature:Dr.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),notes:e.list(ou),ruleId:e.property("rule_id",e.string().optional()),ruleIdUsageExceeded:e.property("rule_id_usage_exceeded",e.string().optional()),updatedAt:e.property("updated_at",e.date()),valueBool:e.property("value_bool",e.boolean().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",he.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",Q)});var Bi=e.object({creditTypeIcon:e.property("credit_type_icon",e.string().optional()),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",Be),quantity:e.number()});var ji=e.object({usageThisBillingPeriod:e.property("usage_this_billing_period",e.number().optional()),usageThisCalendarMonth:e.property("usage_this_calendar_month",e.number().optional()),usageThisWeek:e.property("usage_this_week",e.number().optional()),usageToday:e.property("usage_today",e.number().optional())});var Wr=e.enum_(["company_override","plan_entitlement","unknown"]);var Hr=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",Q),companyOverride:e.property("company_override",He.optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Bi).optional()),creditGrantReason:e.property("credit_grant_reason",Be.optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditUsageAggregation:e.property("credit_usage_aggregation",ji.optional()),creditUsed:e.property("credit_used",e.number().optional()),effectiveLimit:e.property("effective_limit",e.number().optional()),effectivePrice:e.property("effective_price",e.number().optional()),entitlementExpirationDate:e.property("entitlement_expiration_date",e.date().optional()),entitlementId:e.property("entitlement_id",e.string()),entitlementSource:e.property("entitlement_source",e.string().optional()),entitlementType:e.property("entitlement_type",Wr),feature:Ge.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:W.optional(),plan:lr.optional(),planEntitlement:e.property("plan_entitlement",ee.optional()),priceBehavior:e.property("price_behavior",ze.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",H.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",H.optional())});var Ai=e.object({features:e.list(Hr)});var we=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",tr.optional()),billingStrategy:e.property("billing_strategy",Fe),catalogs:e.list(Kr).optional(),chargeType:e.property("charge_type",Ke),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ge),currencyPrices:e.property("currency_prices",e.list(Lr)),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ee).optional(),features:e.list(Ge),icon:pe,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ke).optional()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",L.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",L.optional()),planType:e.property("plan_type",te),quarterlyPrice:e.property("quarterly_price",L.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(Re),yearlyPrice:e.property("yearly_price",L.optional())});var wo=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),featureId:e.property("feature_id",e.string()),meteredPrice:e.property("metered_price",H.optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),priceBehavior:e.property("price_behavior",ze.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",H.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueType:e.property("value_type",Q),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",H.optional())});var tu=e.object({activeAddOns:e.property("active_add_ons",e.list(we)),activePlan:e.property("active_plan",we.optional()),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(wo)),availableCreditBundles:e.property("available_credit_bundles",e.list(We)),company:X.optional(),customCheckoutFields:e.property("custom_checkout_fields",e.list(at)),featureUsage:e.property("feature_usage",Ai.optional()),selectedCreditBundles:e.property("selected_credit_bundles",e.list(iu)),selectedPlan:e.property("selected_plan",we.optional()),selectedUsageBasedEntitlements:e.property("selected_usage_based_entitlements",e.list(wo)),subscription:ki.optional()});var au=e.object({data:tu,params:e.record(e.string(),e.unknown())});var nu=e.object({data:tt,params:e.record(e.string(),e.unknown())});var su=e.object({amountOff:e.property("amount_off",e.number().optional()),couponName:e.property("coupon_name",e.string()),currency:e.string().optional(),customerFacingCode:e.property("customer_facing_code",e.string().optional()),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number().optional()),endedAt:e.property("ended_at",e.date().optional()),isActive:e.property("is_active",e.boolean()),percentOff:e.property("percent_off",e.number().optional()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date())});var cu=e.object({amount:e.number(),description:e.string(),priceId:e.property("price_id",e.string()),proration:e.boolean(),quantity:e.number()});var lu=e.object({amountOff:e.property("amount_off",e.number()),discounts:e.list(su),dueNow:e.property("due_now",e.number()),newCharges:e.property("new_charges",e.number()),percentOff:e.property("percent_off",e.number()),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date()),promoCodeApplied:e.property("promo_code_applied",e.boolean()),proration:e.number(),taxAmount:e.property("tax_amount",e.number().optional()),taxDisplayName:e.property("tax_display_name",e.string().optional()),taxRequireBillingDetails:e.property("tax_require_billing_details",e.boolean()),totalPerBillingPeriod:e.property("total_per_billing_period",e.number()),trialEnd:e.property("trial_end",e.date().optional()),upcomingInvoiceLineItems:e.property("upcoming_invoice_line_items",e.list(cu))});var nt=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),finance:lu.optional(),isScheduledDowngrade:e.property("is_scheduled_downgrade",e.boolean()),newCharges:e.property("new_charges",e.number()),optInRequired:e.property("opt_in_required",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),paymentMethodRequired:e.property("payment_method_required",e.boolean()),percentOff:e.property("percent_off",e.number()),periodStart:e.property("period_start",e.date()),promoCodeApplied:e.property("promo_code_applied",e.boolean()),proration:e.number(),scheduledChangeTime:e.property("scheduled_change_time",e.date().optional()),trialEnd:e.property("trial_end",e.date().optional()),usageViolations:e.property("usage_violations",e.list(Hr))});var pu=e.object({data:nt,params:e.record(e.string(),e.unknown())});var uu=e.object({subscriptionChangePreview:e.property("subscription_change_preview",nt.optional())});var du=e.object({data:uu,params:e.record(e.string(),e.unknown())});var mu=e.object({data:yo,params:e.record(e.string(),e.unknown())});var bn=e.object({displayName:e.property("display_name",e.string().optional()),entityType:e.property("entity_type",oe),hierarchy:e.list(e.string()),traitType:e.property("trait_type",me)});var zn=e.object({companyId:e.property("company_id",e.string()),userId:e.property("user_id",e.string())});var Rn=e.object({displayName:e.property("display_name",e.string().optional()),traitType:e.property("trait_type",me)});var hu=e.object({traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string())});var fn=e.object({applyToExistingCompanies:e.property("apply_to_existing_companies",e.boolean()),planId:e.property("plan_id",e.string()),traits:e.list(hu)});var je=e.enum_(["asc","desc"]);var xr=e.enum_(["active","canceled","expired","incomplete","incomplete_expired","past_due","paused","trialing","unpaid"]);var Er=e.enum_(["free","one_time","paid","trial"]);var gu=e.object({creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",je.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(xr).optional()),subscriptionTypes:e.property("subscription_types",e.list(Er).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var yu=e.object({data:q,params:gu});var wu=e.object({entityType:e.property("entity_type",oe.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var bu=e.object({data:q,params:wu});var zu=e.object({entityType:e.property("entity_type",oe.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",me.optional()),traitTypes:e.property("trait_types",e.list(me).optional())});var Ru=e.object({data:q,params:zu});var fu=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),traitIds:e.property("trait_ids",e.list(e.string()).optional())});var _u=e.object({data:q,params:fu});var Su=e.object({companyId:e.property("company_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Pu=e.object({data:q,params:Su});var xu=e.object({data:X,params:e.record(e.string(),e.unknown())});var ur=e.object({createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Vi=e.object({company:ur.optional(),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),id:e.string(),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string())});var Ne=e.object({companyMemberships:e.property("company_memberships",e.list(Vi)),createdAt:e.property("created_at",e.date()),entityTraits:e.property("entity_traits",e.list(et)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Qo),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string(),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date())});var Eu=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Cu=e.object({data:ur,params:e.record(e.string(),e.unknown())});var Uu=e.object({data:F,params:e.record(e.string(),e.unknown())});var vu=e.object({cancelSubscription:e.property("cancel_subscription",e.boolean().optional()),prorate:e.boolean().optional()});var Tu=e.object({data:F,params:vu});var st=e.object({createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Ou=e.object({data:st,params:e.record(e.string(),e.unknown())});var ku=e.object({data:F,params:e.record(e.string(),e.unknown())});var Bu=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional()});var ju=e.object({data:e.list(ki),params:Bu});var Au=e.object({companyId:e.property("company_id",e.string().optional())});var Vu=e.object({cancelAt:e.property("cancel_at",e.date().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),company:ur.optional(),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),discounts:e.list(vi),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",Ve.optional()),paymentMethod:e.property("payment_method",qe.optional()),planName:e.property("plan_name",e.string()),products:e.list(Ui),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.date().optional())});var qu=e.object({data:e.list(Vu),params:Au});var Du=e.object({companyId:e.property("company_id",e.string().optional())});var Mu=e.object({billingEntity:e.property("billing_entity",ur.optional()),hasOwnStripeCustomer:e.property("has_own_stripe_customer",e.boolean())});var Iu=e.object({data:e.list(Mu),params:Du});var Fu=e.object({data:X,params:e.record(e.string(),e.unknown())});var Ku=e.object({data:he,params:e.record(e.string(),e.unknown())});var Lu=e.object({definitionId:e.property("definition_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Gu=e.object({definitionId:e.property("definition_id",e.string()),value:e.string()});var Wu=e.object({data:e.list(Gu),params:Lu});var Hu=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var Nu=e.object({data:he,params:e.record(e.string(),e.unknown())});var ct=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Me,type:Se,updatedAt:e.property("updated_at",e.date())});var qi=e.enum_(["checkout","company_upsert","fallback_plan","manage_plan","migration","plan_billing_product_changed","plan_deleted","plan_trait_change","plan_version_migration","quickstart","subscription_change"]);var Di=e.enum_(["fallback","initial","trait","trial_expiry"]);var $u=e.enum_(["adjustment","downgrade","invalid","subscribe","unsubscribe","upgrade","upgrade_trial"]);var bo=e.object({deleted:e.boolean(),description:e.string(),icon:e.string(),id:e.string(),name:e.string()});var _n=e.object({id:e.string(),name:e.string(),version:e.number()});var Ju=e.object({featureId:e.property("feature_id",e.string()),hierarchy:e.list(e.string()),reason:e.string(),traitId:e.property("trait_id",e.string()),traitName:e.property("trait_name",e.string()),traitType:e.property("trait_type",me),value:e.string()});var lt=e.object({action:qi,actorType:e.property("actor_type",Ee),addOnsAdded:e.property("add_ons_added",e.list(bo)),addOnsRemoved:e.property("add_ons_removed",e.list(bo)),apiKey:e.property("api_key",xe.optional()),auditLog:e.property("audit_log",Lo.optional()),basePlan:e.property("base_plan",bo.optional()),basePlanAction:e.property("base_plan_action",Di.optional()),basePlanVersion:e.property("base_plan_version",_n.optional()),company:ur.optional(),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),integration:ct.optional(),isVersionUpgrade:e.property("is_version_upgrade",e.boolean()),previousBasePlan:e.property("previous_base_plan",bo.optional()),previousBasePlanVersion:e.property("previous_base_plan_version",_n.optional()),requestId:e.property("request_id",e.string().optional()),subscriptionChangeAction:e.property("subscription_change_action",$u.optional()),traitsUpdated:e.property("traits_updated",e.list(Ju)),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var Yu=e.object({data:lt,params:e.record(e.string(),e.unknown())});var Mi=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),planId:e.property("plan_id",e.string()),planType:e.property("plan_type",e.string()),traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var Zu=e.object({data:Mi,params:e.record(e.string(),e.unknown())});var Xu=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Qu=e.object({creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",je.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(xr).optional()),subscriptionTypes:e.property("subscription_types",e.list(Er).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var ed=e.object({data:e.list(X),params:Qu});var rd=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),userId:e.property("user_id",e.string().optional())});var id=e.object({data:e.list(Vi),params:rd});var od=e.object({entityType:e.property("entity_type",oe.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var td=e.object({data:e.list(Xo),params:od});var ad=e.object({entityType:e.property("entity_type",oe.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",me.optional()),traitTypes:e.property("trait_types",e.list(me).optional())});var nd=e.object({data:e.list(he),params:ad});var sd=e.object({action:qi.optional(),basePlanAction:e.property("base_plan_action",Di.optional()),companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional(),planIds:e.property("plan_ids",e.list(e.string()).optional())});var cd=e.object({data:e.list(lt),params:sd});var ld=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),traitIds:e.property("trait_ids",e.list(e.string()).optional())});var pd=e.object({data:e.list(Mi),params:ld});var ud=e.object({companyId:e.property("company_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var dd=e.object({data:e.list(Ne),params:ud});var md=e.object({keys:e.record(e.string(),e.string()).optional()});var hd=e.object({data:X,params:md});var gd=e.object({keys:e.record(e.string(),e.string()).optional()});var yd=e.object({data:Ne,params:gd});var wd=e.object({data:he,params:e.record(e.string(),e.unknown())});var bd=e.object({data:e.list(Mi),params:e.record(e.string(),e.unknown())});var zd=e.object({data:X,params:e.record(e.string(),e.unknown())});var Rd=e.object({data:X,params:e.record(e.string(),e.unknown())});var fd=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var _d=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Sn=e.object({catalogId:e.property("catalog_id",e.string().optional())});var Ii=e.enum_(["billing","entitlement"]);var Pn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Ii),name:e.string()});var pt=e.enum_(["draft","live"]);var xn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Ii.optional()),name:e.string().optional(),state:pt.optional()});var $e=e.object({ast:e.record(e.string(),e.number()).optional(),catalogId:e.property("catalog_id",e.string().optional()),createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),state:pt,type:Ii,updatedAt:e.property("updated_at",e.date())});var Sd=e.object({data:$e,params:e.record(e.string(),e.unknown())});var Pd=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var xd=e.object({data:q,params:Pd});var Ed=e.object({data:$e,params:e.record(e.string(),e.unknown())});var Cd=e.object({data:F,params:e.record(e.string(),e.unknown())});var Ud=e.object({data:$e,params:e.record(e.string(),e.unknown())});var vd=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Td=e.object({data:e.list($e),params:vd});var Od=e.object({companyId:e.property("company_id",e.string().optional()),componentId:e.property("component_id",e.string().optional())});var zo=e.object({billingScheme:e.property("billing_scheme",or),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:Si,intervalCount:e.property("interval_count",e.number()),isActive:e.property("is_active",e.boolean()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k),tiersMode:e.property("tiers_mode",de.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",ne)});var kd=e.object({currency:e.string(),price:H.optional()});var Bd=e.object({bundleType:e.property("bundle_type",De),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string().optional()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currencyPrices:e.property("currency_prices",e.list(kd)),expiryType:e.property("expiry_type",Z),expiryUnit:e.property("expiry_unit",G),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),hasGrants:e.property("has_grants",e.boolean()),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:zo.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Ce,unitPrice:e.property("unit_price",zo.optional()),updatedAt:e.property("updated_at",e.date())});var jd=e.enum_(["downgrade_not_permitted","feature_usage_exceeded"]);var Nr=e.object({ctaText:e.property("cta_text",e.string()),ctaWebSite:e.property("cta_web_site",e.string()),priceText:e.property("price_text",e.string())});var ut=e.object({billingCreditAutoTopupAmount:e.property("billing_credit_auto_topup_amount",e.number().optional()),billingCreditAutoTopupAmountType:e.property("billing_credit_auto_topup_amount_type",e.string().optional()),billingCreditAutoTopupAvailability:e.property("billing_credit_auto_topup_availability",nr.optional()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Z.optional()),billingCreditAutoTopupExpiryUnit:e.property("billing_credit_auto_topup_expiry_unit",G.optional()),billingCreditAutoTopupExpiryUnitCount:e.property("billing_credit_auto_topup_expiry_unit_count",e.number().optional()),billingCreditAutoTopupSelfService:e.property("billing_credit_auto_topup_self_service",e.boolean()),billingCreditAutoTopupThresholdCredits:e.property("billing_credit_auto_topup_threshold_credits",e.number().optional()),billingCreditAutoTopupThresholdPercent:e.property("billing_credit_auto_topup_threshold_percent",e.number().optional()),billingCreditCanBuyBundles:e.property("billing_credit_can_buy_bundles",e.boolean()),createdAt:e.property("created_at",e.date()),credit:Zo.optional(),creditAmount:e.property("credit_amount",e.number()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Ti.optional(),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),resetCadence:e.property("reset_cadence",Oe.optional()),resetStart:e.property("reset_start",Ie.optional()),resetType:e.property("reset_type",sr),rolloverPercentage:e.property("rollover_percentage",e.number()),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var En=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ci)),billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",tr.optional()),billingStrategy:e.property("billing_strategy",Fe),catalogs:e.list(Kr).optional(),chargeType:e.property("charge_type",Ke),companyCanTrial:e.property("company_can_trial",e.boolean()),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ge),currencyPrices:e.property("currency_prices",e.list(Lr)),current:e.boolean(),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Nr.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ee).optional(),features:e.list(Ge),icon:pe,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ut)),invalidReason:e.property("invalid_reason",jd.optional()),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",L.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",L.optional()),planType:e.property("plan_type",te),quarterlyPrice:e.property("quarterly_price",L.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageViolations:e.property("usage_violations",e.list(Hr)),valid:e.boolean(),versions:e.list(Re),yearlyPrice:e.property("yearly_price",L.optional())});var $r=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var dt=e.object({badgeVisibility:e.property("badge_visibility",e.boolean()),checkout:e.boolean()});var Ad=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean())});var mt=e.object({showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var Jr=e.enum_(["customer_archived","expired","integration_uninstalled","manual","plan_change","plan_period_reset","reconciled"]);var Vd=e.object({amount:e.number(),createdAt:e.property("created_at",e.date()),direction:e.string(),id:e.string(),reason:e.string(),relatedGrantId:e.property("related_grant_id",e.string())});var qd=e.object({billingCreditBundleId:e.property("billing_credit_bundle_id",e.string().optional()),billingCreditId:e.property("billing_credit_id",e.string()),companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditName:e.property("credit_name",e.string()),currency:e.string().optional(),exhaustedAt:e.property("exhausted_at",e.date().optional()),expiresAt:e.property("expires_at",e.date().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),grantReason:e.property("grant_reason",Be),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),price:zo.optional(),quantity:e.number(),quantityRemaining:e.property("quantity_remaining",e.number()),quantityUsed:e.property("quantity_used",e.number()),renewalEnabled:e.property("renewal_enabled",e.boolean()),renewalPeriod:e.property("renewal_period",Oe.optional()),reserved:e.number().optional(),settled:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),sourceGrantId:e.property("source_grant_id",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(Vd).optional(),updatedAt:e.property("updated_at",e.date()),validFrom:e.property("valid_from",e.date().optional()),zeroedOutDate:e.property("zeroed_out_date",e.date().optional()),zeroedOutReason:e.property("zeroed_out_reason",Jr.optional())});var Dd=e.object({accountId:e.property("account_id",e.string().optional()),publishableKey:e.property("publishable_key",e.string().optional()),schematicPublishableKey:e.property("schematic_publishable_key",e.string()),setupIntentClientSecret:e.property("setup_intent_client_secret",e.string().optional())});var Md=e.object({activeAddOns:e.property("active_add_ons",e.list(En)),activePlans:e.property("active_plans",e.list(En)),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(wo)),addOnCompatibilities:e.property("add_on_compatibilities",e.list($r)),capabilities:dt.optional(),checkoutSettings:e.property("checkout_settings",Ad),company:X.optional(),component:$e.optional(),creditBundles:e.property("credit_bundles",e.list(Bd)),creditGrants:e.property("credit_grants",e.list(qd)),customCheckoutFields:e.property("custom_checkout_fields",e.list(at)),defaultPlan:e.property("default_plan",we.optional()),displaySettings:e.property("display_settings",mt),featureUsage:e.property("feature_usage",Ai.optional()),invoices:e.list(Ve),postTrialPlan:e.property("post_trial_plan",we.optional()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),scheduledDowngrade:e.property("scheduled_downgrade",ot.optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),stripeEmbed:e.property("stripe_embed",Dd.optional()),subscription:ki.optional(),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional()),upcomingInvoice:e.property("upcoming_invoice",Ve.optional())});var Id=e.object({data:Md,params:Od});var Fd=e.object({data:$e,params:e.record(e.string(),e.unknown())});var Cn=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ci)),billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",tr.optional()),billingStrategy:e.property("billing_strategy",Fe),catalogs:e.list(Kr).optional(),chargeType:e.property("charge_type",Ke),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ge),currencyPrices:e.property("currency_prices",e.list(Lr)),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Nr.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ee).optional(),features:e.list(Ge),icon:pe,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ut)),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",L.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",L.optional()),planType:e.property("plan_type",te),quarterlyPrice:e.property("quarterly_price",L.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(Re),yearlyPrice:e.property("yearly_price",L.optional())});var Kd=e.object({activeAddOns:e.property("active_add_ons",e.list(Cn)),activePlans:e.property("active_plans",e.list(Cn)),addOnCompatibilities:e.property("add_on_compatibilities",e.list($r)),capabilities:dt.optional(),displaySettings:e.property("display_settings",mt),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var Ld=e.object({data:Kd,params:e.record(e.string(),e.unknown())});var Un=e.object({companyId:e.property("company_id",e.string()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date().optional()),requestedAmount:e.property("requested_amount",e.number())});var ht=e.object({currency:e.string(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional())});var vn=e.object({burnStrategy:e.property("burn_strategy",Vr.optional()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(ht).optional()),defaultExpiryUnit:e.property("default_expiry_unit",G.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",qr.optional()),description:e.string(),icon:e.string().optional(),name:e.string(),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var Tn=e.object({billingPeriodsCount:e.property("billing_periods_count",e.number().optional()),companyId:e.property("company_id",e.string()),creditId:e.property("credit_id",e.string()),currency:e.string().optional(),expiresAt:e.property("expires_at",e.date().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),quantity:e.number(),reason:Be,renewalEnabled:e.property("renewal_enabled",e.boolean().optional()),renewalPeriod:e.property("renewal_period",Ie.optional())});var gt=e.object({currency:e.string(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional())});var On=e.object({bundleName:e.property("bundle_name",e.string()),bundleType:e.property("bundle_type",De.optional()),creditId:e.property("credit_id",e.string()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(gt).optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),pricePerUnit:e.property("price_per_unit",e.number()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),quantity:e.number().optional(),status:Ce.optional()});var kn=e.object({additionalAmount:e.property("additional_amount",e.number()),expiresAt:e.property("expires_at",e.date().optional())});var Bn=e.object({burnStrategy:e.property("burn_strategy",Vr.optional()),currencyPrices:e.property("currency_prices",e.list(ht).optional()),defaultExpiryUnit:e.property("default_expiry_unit",G.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",qr.optional()),description:e.string(),icon:e.string().optional(),name:e.string(),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var jn=e.object({bundleName:e.property("bundle_name",e.string()),currencyPrices:e.property("currency_prices",e.list(gt).optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),pricePerUnit:e.property("price_per_unit",e.number()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),quantity:e.number().optional(),status:Ce.optional()});var An=e.object({reason:Jr.optional()});var Fi=e.object({companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date()),grantedAmount:e.property("granted_amount",e.number()),id:e.string(),releasedAt:e.property("released_at",e.date().optional()),updatedAt:e.property("updated_at",e.date())});var Gd=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var Wd=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var Hd=e.object({data:q,params:Wd});var Nd=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var $d=e.object({data:q,params:Nd});var Jd=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional())});var Yd=e.object({data:q,params:Jd});var li=e.enum_(["created_at","expires_at","quantity","quantity_remaining"]);var Zd=e.object({companyId:e.property("company_id",e.string().optional()),dir:je.optional(),limit:e.number().optional(),offset:e.number().optional(),order:li.optional()});var Xd=e.object({data:q,params:Zd});var Qd=e.object({bundleType:e.property("bundle_type",De.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:Ce.optional()});var em=e.object({data:q,params:Qd});var Cr=e.enum_(["grant","transfer","usage","zero_out"]);var rm=e.object({billingCreditId:e.property("billing_credit_id",e.string().optional()),companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.string().optional()),eventType:e.property("event_type",Cr.optional()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),startTime:e.property("start_time",e.string().optional())});var im=e.object({data:q,params:rm});var om=e.object({data:ge,params:e.record(e.string(),e.unknown())});var tm=e.object({data:ke,params:e.record(e.string(),e.unknown())});var am=e.object({data:We,params:e.record(e.string(),e.unknown())});var nm=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var sm=e.object({data:F,params:nm});var cm=e.object({data:F,params:e.record(e.string(),e.unknown())});var lm=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var pm=e.object({data:We,params:e.record(e.string(),e.unknown())});var um=e.object({data:ge,params:e.record(e.string(),e.unknown())});var dm=e.object({data:ke,params:e.record(e.string(),e.unknown())});var mm=e.object({amount:e.number(),createdAt:e.property("created_at",e.date()),direction:e.string(),id:e.string(),reason:e.string(),relatedGrantId:e.property("related_grant_id",e.string())});var Yr=e.object({companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),createdAt:e.property("created_at",e.date()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currency:e.string().optional(),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",Be),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),price:L.optional(),quantity:e.number(),quantityRemaining:e.property("quantity_remaining",e.number()),quantityUsed:e.property("quantity_used",e.number()),renewalEnabled:e.property("renewal_enabled",e.boolean()),renewalPeriod:e.property("renewal_period",Oe.optional()),reserved:e.number().optional(),settled:e.number().optional(),sourceGrantId:e.property("source_grant_id",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(mm).optional(),updatedAt:e.property("updated_at",e.date()),validFrom:e.property("valid_from",e.date().optional()),zeroedOutDate:e.property("zeroed_out_date",e.date().optional()),zeroedOutReason:e.property("zeroed_out_reason",Jr.optional())});var hm=e.object({data:Yr,params:e.record(e.string(),e.unknown())});var gm=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var ym=e.object({data:e.list(ge),params:gm});var wm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional())});var bm=e.object({data:e.list(ke),params:wm});var zm=e.object({companyId:e.property("company_id",e.string().optional())});var Rm=e.object({creditId:e.property("credit_id",e.string()),remaining:e.number(),reserved:e.number(),settled:e.number(),source:k,total:e.number().optional()});var fm=e.object({data:e.list(Rm),params:zm});var _m=e.object({companyId:e.property("company_id",e.string().optional()),dir:je.optional(),limit:e.number().optional(),offset:e.number().optional(),order:li.optional()});var Sm=e.object({data:e.list(Yr),params:_m});var Pm=e.object({bundleType:e.property("bundle_type",De.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:Ce.optional()});var xm=e.object({data:e.list(We),params:Pm});var Em=e.object({billingCreditId:e.property("billing_credit_id",e.string().optional()),companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.string().optional()),eventType:e.property("event_type",Cr.optional()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),startTime:e.property("start_time",e.string().optional())});var Cm=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var Um=e.object({id:e.string(),logoUrl:e.property("logo_url",e.string().optional()),name:e.string()});var vm=e.enum_(["lease_hold","lease_release","manual_adjustment","reconciliation","track"]);var Tm=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string()});var Om=e.object({amount:e.number(),autoTopupLogId:e.property("auto_topup_log_id",e.string().optional()),billingCreditBundleId:e.property("billing_credit_bundle_id",e.string().optional()),billingCreditId:e.property("billing_credit_id",e.string()),company:Um.optional(),companyId:e.property("company_id",e.string()),credit:Cm.optional(),creditName:e.property("credit_name",e.string()),environmentId:e.property("environment_id",e.string()),eventAt:e.property("event_at",e.date()),eventId:e.property("event_id",e.string()),eventType:e.property("event_type",Cr),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),feature:Tm.optional(),featureId:e.property("feature_id",e.string().optional()),fromGrantId:e.property("from_grant_id",e.string().optional()),grantExpiresAt:e.property("grant_expires_at",e.date().optional()),grantId:e.property("grant_id",e.string().optional()),grantQuantity:e.property("grant_quantity",e.number().optional()),grantQuantityRemaining:e.property("grant_quantity_remaining",e.number().optional()),grantReason:e.property("grant_reason",Be.optional()),grantValidFrom:e.property("grant_valid_from",e.date().optional()),planId:e.property("plan_id",e.string().optional()),quantityConsumed:e.property("quantity_consumed",e.number().optional()),quantityRemainingAtZeroOut:e.property("quantity_remaining_at_zero_out",e.number().optional()),sourceId:e.property("source_id",e.number()),toGrantId:e.property("to_grant_id",e.string().optional()),usageEventId:e.property("usage_event_id",e.string().optional()),usageReason:e.property("usage_reason",vm.optional()),zeroedOutReason:e.property("zeroed_out_reason",Jr.optional())});var km=e.object({data:e.list(Om),params:Em});var Bm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var jm=e.object({data:e.list(Yr),params:Bm});var Am=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var Vm=e.object({data:F,params:e.record(e.string(),e.unknown())});var qm=e.object({data:ge,params:e.record(e.string(),e.unknown())});var Dm=e.object({data:ke,params:e.record(e.string(),e.unknown())});var Mm=e.object({data:We,params:e.record(e.string(),e.unknown())});var Im=e.object({data:Yr,params:e.record(e.string(),e.unknown())});var Fm=e.object({actorType:e.property("actor_type",e.string().optional()),endTime:e.property("end_time",e.date().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var Km=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string())),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),subscriptionStatuses:e.property("subscription_statuses",e.list(e.string()).optional()),subscriptionTypes:e.property("subscription_types",e.list(e.string()).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var yt=e.union(e.discriminant("exportType","export_type"),{"audit-log":Fm,"company-feature-usage":Km}).transform({transform:p=>p,untransform:p=>p});var wt=e.enum_(["csv","csv.gz"]);var Zr=e.enum_(["audit-log","company-feature-usage"]);var Vn=e.object({exportType:e.property("export_type",Zr),metadata:yt.optional(),outputFileType:e.property("output_file_type",wt)});var Ki=e.enum_(["failure","pending","success"]);var Li=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),exportType:e.property("export_type",Zr),id:e.string(),metadata:yt.optional(),outputFileType:e.property("output_file_type",wt),status:Ki,updatedAt:e.property("updated_at",e.date())});var Lm=e.object({data:Li,params:e.record(e.string(),e.unknown())});var Gm=e.object({data:Li,params:e.record(e.string(),e.unknown())});var Wm=e.object({exportType:e.property("export_type",Zr.optional()),limit:e.number().optional(),offset:e.number().optional(),status:Ki.optional()});var Hm=e.object({data:e.list(Li),params:Wm});var ae=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),upTo:e.property("up_to",e.number().optional())});var Xr=e.object({currency:e.string(),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Gi=e.object({key:e.string(),value:e.number()});var qn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingProvider:e.property("billing_provider",k),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Xr).optional()),externalResourceId:e.property("external_resource_id",e.string()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional()),priceTiers:e.property("price_tiers",e.list(ae).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",Q),warningTiers:e.property("warning_tiers",e.list(Gi).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Dn=e.object({companyId:e.property("company_id",e.string()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",Q)});var Mn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Xr).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional()),priceTiers:e.property("price_tiers",e.list(ae).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",Q),warningTiers:e.property("warning_tiers",e.list(Gi).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var In=e.object({sourcePlanId:e.property("source_plan_id",e.string()),targetPlanId:e.property("target_plan_id",e.string())});var Fn=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",Q)});var Kn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Xr).optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional()),priceTiers:e.property("price_tiers",e.list(ae).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",Q),warningTiers:e.property("warning_tiers",e.list(Gi).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Nm=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),withoutExpired:e.property("without_expired",e.boolean().optional())});var $m=e.object({data:q,params:Nm});var Jm=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ym=e.object({data:q,params:Jm});var Zm=e.object({companyId:e.property("company_id",e.string().optional()),companyKeys:e.property("company_keys",e.record(e.string(),e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),includeUsageAggregation:e.property("include_usage_aggregation",e.boolean().optional()),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),q:e.string().optional(),withoutNegativeEntitlements:e.property("without_negative_entitlements",e.boolean().optional())});var Xm=e.object({data:q,params:Zm});var Qm=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var eh=e.object({data:q,params:Qm});var rh=e.object({featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),withMeteredProducts:e.property("with_metered_products",e.boolean().optional())});var ih=e.object({data:q,params:rh});var oh=e.object({data:He,params:e.record(e.string(),e.unknown())});var th=e.object({data:ee,params:e.record(e.string(),e.unknown())});var ah=e.object({data:F,params:e.record(e.string(),e.unknown())});var nh=e.object({data:F,params:e.record(e.string(),e.unknown())});var bt=e.object({code:e.string(),description:e.string(),detail:e.string().optional(),id:e.string().optional()});var sh=e.object({message:e.string()});var ch=e.object({entitlementId:e.property("entitlement_id",e.string()),errors:e.list(sh),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string())});var lh=e.object({data:e.list(ee),issues:e.list(bt),skipped:e.list(ch)});var ph=e.object({data:lh,params:e.record(e.string(),e.unknown())});var uh=e.object({data:He,params:e.record(e.string(),e.unknown())});var dh=e.object({keys:e.record(e.string(),e.string()).optional()});var mh=e.object({data:Ai,params:dh});var Qe=e.enum_(["daily","hourly","monthly","weekly"]);var hh=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:Qe.optional(),startTime:e.property("start_time",e.date().optional())});var gh=e.object({effectiveAt:e.property("effective_at",e.date()),isSoftLimit:e.property("is_soft_limit",e.boolean()),limitSource:e.property("limit_source",Wr),limitValue:e.property("limit_value",e.number().optional()),planId:e.property("plan_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional())});var yh=e.object({periodEnd:e.property("period_end",e.date().optional()),periodStart:e.property("period_start",e.date().optional()),timestamp:e.date(),usage:e.number()});var wh=e.object({featureId:e.property("feature_id",e.string()),featureType:e.property("feature_type",se),limits:e.list(gh),periodType:e.property("period_type",e.string().optional()),usagePoints:e.property("usage_points",e.list(yh))});var bh=e.object({data:wh,params:hh});var zh=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Rh=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),withoutExpired:e.property("without_expired",e.boolean().optional())});var fh=e.object({data:e.list(He),params:Rh});var _h=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Sh=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Bi).optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditTypeName:e.property("credit_type_name",e.string().optional()),creditUsed:e.property("credit_used",e.number().optional()),usageAggregation:e.property("usage_aggregation",ji.optional())});var Ph=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",Q),company:X.optional(),companyOverride:e.property("company_override",He.optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(Bi).optional()),creditGrantReason:e.property("credit_grant_reason",Be.optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditUsage:e.property("credit_usage",Sh.optional()),creditUsageAggregation:e.property("credit_usage_aggregation",ji.optional()),creditUsed:e.property("credit_used",e.number().optional()),effectiveLimit:e.property("effective_limit",e.number().optional()),effectivePrice:e.property("effective_price",e.number().optional()),entitlementExpirationDate:e.property("entitlement_expiration_date",e.date().optional()),entitlementId:e.property("entitlement_id",e.string()),entitlementSource:e.property("entitlement_source",e.string().optional()),entitlementType:e.property("entitlement_type",Wr),feature:Ge.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:W.optional(),plan:lr.optional(),planEntitlement:e.property("plan_entitlement",ee.optional()),priceBehavior:e.property("price_behavior",ze.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",H.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",H.optional())});var xh=e.object({data:e.list(Ph),params:_h});var Eh=e.object({companyId:e.property("company_id",e.string().optional()),companyKeys:e.property("company_keys",e.record(e.string(),e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),includeUsageAggregation:e.property("include_usage_aggregation",e.boolean().optional()),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),q:e.string().optional(),withoutNegativeEntitlements:e.property("without_negative_entitlements",e.boolean().optional())});var Ch=e.object({data:e.list(Hr),params:Eh});var Uh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var dr=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:Dr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",cr),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainer:Br.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Ei),updatedAt:e.property("updated_at",e.date())});var Je=e.object({billingLinkedResource:e.property("billing_linked_resource",Te.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Pi.optional()),featureType:e.property("feature_type",se),flags:e.list(dr),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainer:Br.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Fr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:he.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var vh=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",Q),company:X.optional(),entitlementId:e.property("entitlement_id",e.string()),entitlementType:e.property("entitlement_type",Wr),feature:Je.optional(),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),period:W.optional(),plan:lr.optional(),usage:e.number().optional(),user:st.optional()});var Th=e.object({data:e.list(vh),params:Uh});var Oh=e.object({featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),withMeteredProducts:e.property("with_metered_products",e.boolean().optional())});var kh=e.object({data:e.list(ee),params:Oh});var Bh=e.object({data:He,params:e.record(e.string(),e.unknown())});var jh=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Ah=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Vh=e.object({companyId:e.property("company_id",e.string().optional()),error:e.string().optional(),flagId:e.property("flag_id",e.string().optional()),flagKey:e.property("flag_key",e.string()),reason:e.string(),reqCompany:e.property("req_company",e.record(e.string(),e.string()).optional()),reqUser:e.property("req_user",e.record(e.string(),e.string()).optional()),ruleId:e.property("rule_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var qh=e.object({keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Dh=e.object({company:qh.optional(),keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Mh=e.object({cachedInputTokens:e.property("cached_input_tokens",e.number().optional()),company:e.record(e.string(),e.string()),cost:e.string().optional(),currency:e.string().optional(),event:e.string().optional(),inputTokens:e.property("input_tokens",e.number()),operation:e.string().optional(),outputTokens:e.property("output_tokens",e.number()),provider:e.string(),reasoningTokens:e.property("reasoning_tokens",e.number().optional()),requestModel:e.property("request_model",e.string().optional()),requests:e.number().optional(),responseModel:e.property("response_model",e.string()),user:e.record(e.string(),e.string()).optional()});var Ih=e.object({company:e.record(e.string(),e.string()).optional(),event:e.string(),leaseId:e.property("lease_id",e.string().optional()),quantity:e.number().optional(),traits:e.record(e.string(),e.unknown()).optional(),user:e.record(e.string(),e.string()).optional()});var zt=e.undiscriminatedUnion([Ih,Vh,Dh,Mh]);var Ur=e.enum_(["flag_check","identify","inference","track"]);var Rt=e.object({backfill:e.boolean().optional(),body:zt.optional(),eventType:e.property("event_type",Ur),idempotencyKey:e.property("idempotency_key",e.string().optional()),sentAt:e.property("sent_at",e.date().optional()),trustedClientClock:e.property("trusted_client_clock",e.boolean().optional())});var Ln=e.object({events:e.list(Rt)});var ft=e.object({capturedAt:e.property("captured_at",e.date()),eventId:e.property("event_id",e.string().optional()),remoteAddr:e.property("remote_addr",e.string().optional()),remoteIp:e.property("remote_ip",e.string()),userAgent:e.property("user_agent",e.string())});var Fh=e.object({events:e.list(ft)});var Kh=e.object({data:Fh,params:e.record(e.string(),e.unknown())});var Lh=e.object({data:ft,params:e.record(e.string(),e.unknown())});var Gh=e.enum_(["enriched","failed","pending","processed","unknown"]);var _t=e.object({apiKey:e.property("api_key",e.string().optional()),apiKeyView:e.property("api_key_view",xe.optional()),body:e.record(e.string(),e.unknown()),bodyPreview:e.property("body_preview",e.string()),capturedAt:e.property("captured_at",e.date()),company:Fr.optional(),companyId:e.property("company_id",e.string().optional()),enrichedAt:e.property("enriched_at",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),errorMessage:e.property("error_message",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string())),features:e.list(Fr),id:e.string(),idempotencyKey:e.property("idempotency_key",e.string().optional()),leaseId:e.property("lease_id",e.string().optional()),loadedAt:e.property("loaded_at",e.date().optional()),processedAt:e.property("processed_at",e.date().optional()),quantity:e.number(),sentAt:e.property("sent_at",e.date().optional()),status:Gh,subtype:e.string().optional(),type:Ur,updatedAt:e.property("updated_at",e.date().optional()),user:Fr.optional(),userId:e.property("user_id",e.string().optional())});var Wh=e.object({data:_t,params:e.record(e.string(),e.unknown())});var Hh=e.object({eventSubtypes:e.property("event_subtypes",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Nh=e.object({data:e.list(Pi),params:Hh});var $h=e.object({connected:e.boolean(),environmentId:e.property("environment_id",e.string()),lastEventAt:e.property("last_event_at",e.date().optional())});var Jh=e.object({data:$h,params:e.record(e.string(),e.unknown())});var Yh=e.object({companyId:e.property("company_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),eventTypes:e.property("event_types",e.list(Ur).optional()),flagId:e.property("flag_id",e.string().optional()),idempotencyKey:e.property("idempotency_key",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),userId:e.property("user_id",e.string().optional())});var Zh=e.object({data:e.list(_t),params:Yh});var Ro=e.object({company:e.record(e.string(),e.string()).optional(),user:e.record(e.string(),e.string()).optional()});var Gn=e.object({contexts:e.list(Ro)});var Wi=e.object({defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",cr),id:e.string().optional(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var Wn=e.object({billingProvider:e.property("billing_provider",k),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),externalResourceId:e.property("external_resource_id",e.string()),featureType:e.property("feature_type",se),flag:Wi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var Hn=e.object({description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",se),flag:Wi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var Nn=e.object({description:e.string().optional(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",se.optional()),flag:Wi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string().optional(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var St=e.object({comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionType:e.property("condition_type",xi),creditCost:e.property("credit_cost",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string().optional(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Mr,resourceIds:e.property("resource_ids",e.list(e.string())),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string().optional())});var Xh=e.object({conditions:e.list(St),flagId:e.property("flag_id",e.string().optional()),id:e.string().optional()});var Qh=e.object({conditionGroups:e.property("condition_groups",e.list(Xh)),conditions:e.list(St),id:e.string().optional(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Ir.optional()),value:e.boolean()});var $n=e.object({rules:e.list(Qh)});var Pt=e.object({companyId:e.property("company_id",e.string().optional()),entitlement:rt.optional(),error:e.string().optional(),featureAllocation:e.property("feature_allocation",e.number().optional()),featureUsage:e.property("feature_usage",e.number().optional()),featureUsageEvent:e.property("feature_usage_event",e.string().optional()),featureUsagePeriod:e.property("feature_usage_period",W.optional()),featureUsageResetAt:e.property("feature_usage_reset_at",e.date().optional()),flag:e.string(),flagId:e.property("flag_id",e.string().optional()),reason:e.string(),ruleId:e.property("rule_id",e.string().optional()),ruleType:e.property("rule_type",Ir.optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var eg=e.object({data:Pt,params:e.record(e.string(),e.unknown())});var rg=e.object({remaining:e.number(),reserved:e.number(),settled:e.number()});var ig=e.enum_(["active","converted","expired"]);var og=e.object({id:e.string(),name:e.string(),trialEndDate:e.property("trial_end_date",e.date().optional()),trialStatus:e.property("trial_status",ig.optional())});var xt=e.object({creditBalances:e.property("credit_balances",e.record(e.string(),rg).optional()),flags:e.list(Pt),plan:og.optional()});var tg=e.object({data:e.list(xt)});var ag=e.object({data:tg,params:e.record(e.string(),e.unknown())});var ng=e.object({data:xt,params:e.record(e.string(),e.unknown())});var sg=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(se).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),withoutCompanyOverrideFor:e.property("without_company_override_for",e.string().optional()),withoutPlanEntitlementFor:e.property("without_plan_entitlement_for",e.string().optional())});var cg=e.object({data:q,params:sg});var lg=e.object({featureId:e.property("feature_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var pg=e.object({data:q,params:lg});var ug=e.object({data:Je,params:e.record(e.string(),e.unknown())});var dg=e.object({data:dr,params:e.record(e.string(),e.unknown())});var mg=e.object({data:F,params:e.record(e.string(),e.unknown())});var hg=e.object({data:F,params:e.record(e.string(),e.unknown())});var gg=e.object({data:Je,params:e.record(e.string(),e.unknown())});var yg=e.object({data:dr,params:e.record(e.string(),e.unknown())});var wg=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(se).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),withoutCompanyOverrideFor:e.property("without_company_override_for",e.string().optional()),withoutPlanEntitlementFor:e.property("without_plan_entitlement_for",e.string().optional())});var bg=e.object({data:e.list(Je),params:wg});var zg=e.object({featureId:e.property("feature_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Rg=e.object({data:e.list(dr),params:zg});var fg=e.object({data:Je,params:e.record(e.string(),e.unknown())});var _g=e.object({data:dr,params:e.record(e.string(),e.unknown())});var Sg=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",cr),id:e.string(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Pg=e.object({flag:Sg.optional(),rules:e.list(Ei)});var xg=e.object({data:Pg,params:e.record(e.string(),e.unknown())});var Eg=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Cg=e.object({limit:e.number().optional()});var Ug=e.object({actorName:e.property("actor_name",e.string()),method:e.string(),resourceName:e.property("resource_name",e.string()),resourceType:e.property("resource_type",e.string()),timestamp:e.date(),title:e.string()});var vg=e.object({entries:e.list(Ug)});var Tg=e.object({data:vg,params:Cg});var Og=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:Qe.optional(),startTime:e.property("start_time",e.date().optional())});var Et=e.object({timestamp:e.date(),usage:e.number()});var kg=e.object({eventSubtype:e.property("event_subtype",e.string()),featureId:e.property("feature_id",e.string()),points:e.list(Et)});var Bg=e.object({data:kg,params:Og});var jg=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:Qe.optional(),startTime:e.property("start_time",e.date().optional())});var Ag=e.object({featureId:e.property("feature_id",e.string()),points:e.list(Et),traitDefinitionId:e.property("trait_definition_id",e.string())});var Vg=e.object({data:Ag,params:jg});var qg=e.object({months:e.number().optional()});var Dg=e.object({month:e.date(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),subscribers:e.number()});var Mg=e.object({points:e.list(Dg)});var Ig=e.object({data:Mg,params:qg});var Fg=e.object({amount:e.number(),currency:e.string()});var Kg=e.object({activeCredits:e.property("active_credits",e.number()),mrr:e.list(Fg),paidCompanies:e.property("paid_companies",e.number()),totalCompanies:e.property("total_companies",e.number()),totalFeatures:e.property("total_features",e.number()),totalPlans:e.property("total_plans",e.number())});var Lg=e.object({data:Kg,params:e.record(e.string(),e.unknown())});var Gg=e.object({endTime:e.property("end_time",e.date().optional()),limit:e.number().optional(),startTime:e.property("start_time",e.date().optional())});var Wg=e.object({changePct:e.property("change_pct",e.number().optional()),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string()),pluralName:e.property("plural_name",e.string().optional()),priorUsage:e.property("prior_usage",e.number()),usage:e.number()});var Hg=e.object({features:e.list(Wg)});var Ng=e.object({data:Hg,params:Gg});var Hi=e.enum_(["billing_meta_object","manual_upsert"]);var Jn=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Hi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),integrationId:e.property("integration_id",e.string())});var Ct=e.object({authorPlans:e.property("author_plans",e.boolean()),checkout:e.boolean(),editBilling:e.property("edit_billing",e.boolean())});var $g=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Jg=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var Yg=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var Zg=e.object({accountId:e.property("account_id",e.string().optional()),accountName:e.property("account_name",e.string().optional()),companyUpdateOnly:e.property("company_update_only",e.boolean().optional()),isSandbox:e.property("is_sandbox",e.boolean()),liveMode:e.property("live_mode",e.boolean()),onboardUrl:e.property("onboard_url",e.string().optional())});var Xg=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Ut=e.union("type",{clerk:$g,metronome:Jg,orb:Yg,stripe:Zg,workos:Xg}).transform({transform:p=>p,untransform:p=>p});var Qg=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Hi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:Ut.optional(),createdAt:e.property("created_at",e.date()),id:e.string(),integrationId:e.property("integration_id",e.string()),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),liveMode:e.property("live_mode",e.boolean()),updatedAt:e.property("updated_at",e.date())});var Ni=e.object({capabilities:Ct,config:Qg,integration:ct});var ey=e.object({data:Ni,params:e.record(e.string(),e.unknown())});var ry=e.object({type:Se,url:e.string()});var iy=e.object({data:ry,params:e.record(e.string(),e.unknown())});var oy=e.object({data:Ni,params:e.record(e.string(),e.unknown())});var ty=e.object({data:Ni,params:e.record(e.string(),e.unknown())});var ay=e.object({billingOnly:e.property("billing_only",e.boolean().optional()),excludeIds:e.property("exclude_ids",e.list(e.string()).optional()),id:e.string().optional(),limit:e.number().optional(),offset:e.number().optional(),state:Me.optional(),type:Se.optional()});var ny=e.object({capabilities:Ct,config:Ut.optional(),id:e.string(),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),lastWebhookReceivedAt:e.property("last_webhook_received_at",e.date().optional()),state:Me,type:Se});var sy=e.object({data:e.list(ny),params:ay});var cy=e.object({keys:e.list(e.string())});var ly=e.object({data:cy,params:e.record(e.string(),e.unknown())});var vt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Me,type:Se,updatedAt:e.property("updated_at",e.date())});var py=e.object({data:vt,params:e.record(e.string(),e.unknown())});var uy=e.object({data:vt,params:e.record(e.string(),e.unknown())});var dy=e.object({data:F,params:e.record(e.string(),e.unknown())});var my=e.object({companyId:e.property("company_id",e.string()),description:e.string(),icon:pe.optional(),name:e.string()});var Tt=e.stringLiteral("credit");var Ot=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional()),autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",Tt.optional()),autoTopupAvailability:e.property("auto_topup_availability",nr.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Z.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",G.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean().optional()),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),resetCadence:e.property("reset_cadence",Oe),resetStart:e.property("reset_start",Ie),resetType:e.property("reset_type",sr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional())});var hy=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var kt=e.enum_(["create","update","delete"]);var Bt=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional()),autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",Tt.optional()),autoTopupAvailability:e.property("auto_topup_availability",nr.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Z.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",G.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean().optional()),creditAmount:e.property("credit_amount",e.number().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),resetCadence:e.property("reset_cadence",Oe),resetStart:e.property("reset_start",Ie),resetType:e.property("reset_type",sr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional())});var $i=e.object({action:kt,createReq:e.property("create_req",Ot.optional()),creditGrantId:e.property("credit_grant_id",e.string().optional()),deleteReq:e.property("delete_req",hy.optional()),updateReq:e.property("update_req",Bt.optional())});var gy=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Xr).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional()),priceTiers:e.property("price_tiers",e.list(ae).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",Q),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Ji=e.object({action:kt,entitlementId:e.property("entitlement_id",e.string().optional()),req:gy.optional()});var yy=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",e.number().optional()),oneTimePrice:e.property("one_time_price",e.number().optional()),quarterlyPrice:e.property("quarterly_price",e.number().optional()),yearlyPrice:e.property("yearly_price",e.number().optional())});var Qr=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingStrategy:e.property("billing_strategy",Fe.optional()),chargeType:e.property("charge_type",Ke),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(yy).optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",e.number().optional()),monthlyPriceId:e.property("monthly_price_id",e.string().optional()),oneTimePrice:e.property("one_time_price",e.number().optional()),oneTimePriceId:e.property("one_time_price_id",e.string().optional()),quarterlyPrice:e.property("quarterly_price",e.number().optional()),quarterlyPriceId:e.property("quarterly_price_id",e.string().optional()),trialDays:e.property("trial_days",e.number().optional()),yearlyPrice:e.property("yearly_price",e.number().optional()),yearlyPriceId:e.property("yearly_price_id",e.string().optional())});var Yn=e.object({billingProduct:e.property("billing_product",Qr.optional()),creditGrants:e.property("credit_grants",e.list($i).optional()),entitlements:e.list(Ji),plan:my.optional()});var jt=e.object({description:e.string(),icon:pe.optional(),name:e.string(),planType:e.property("plan_type",te)});var Zn=e.object({billingProduct:e.property("billing_product",Qr.optional()),creditGrants:e.property("credit_grants",e.list($i).optional()),entitlements:e.list(Ji),plan:jt.optional()});var At=e.object({description:e.string().optional(),icon:pe.optional(),name:e.string()});var Xn=e.object({billingProduct:e.property("billing_product",Qr.optional()),creditGrants:e.property("credit_grants",e.list($i).optional()),entitlements:e.list(Ji),plan:At.optional(),planVersionId:e.property("plan_version_id",e.string().optional())});var Vt=e.object({accountId:e.property("account_id",e.string()),billingProductId:e.property("billing_product_id",e.string()),billingStrategy:e.property("billing_strategy",Fe),chargeType:e.property("charge_type",Ke),controlledBy:e.property("controlled_by",k),environmentId:e.property("environment_id",e.string()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPriceId:e.property("monthly_price_id",e.string().optional()),oneTimePriceId:e.property("one_time_price_id",e.string().optional()),planId:e.property("plan_id",e.string()),trialDays:e.property("trial_days",e.number().optional()),yearlyPriceId:e.property("yearly_price_id",e.string().optional())});var Yi=e.object({billingProduct:e.property("billing_product",Vt.optional()),creditGrants:e.property("credit_grants",e.list(ke).optional()),entitlements:e.list(ee).optional(),plan:lr.optional()});var wy=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var by=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var zy=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var qt=e.object({definitionId:e.property("definition_id",e.string().optional()),helperText:e.property("helper_text",e.string().optional()),id:e.string().optional(),name:e.string(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string())});var Ry=e.object({entitlementId:e.property("entitlement_id",e.string()),visible:e.boolean().optional()});var vr=e.object({entitlements:e.list(Ry).optional(),planId:e.property("plan_id",e.string())});var Zi=e.object({bundleId:e.string()});var Dt=e.enum_(["create_prorations","invoice_immediately"]);var Mt=e.enum_(["end_of_billing_period","none"]);var Qn=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list($r).optional()),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutCollectAddress:e.property("checkout_collect_address",e.boolean()),checkoutCollectEmail:e.property("checkout_collect_email",e.boolean()),checkoutCollectPhone:e.property("checkout_collect_phone",e.boolean()),customCheckoutFields:e.property("custom_checkout_fields",e.list(qt).optional()),customPlanConfig:e.property("custom_plan_config",Nr.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),enableTaxCollection:e.property("enable_tax_collection",e.boolean()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(vr)),orderedBundleList:e.property("ordered_bundle_list",e.list(Zi)),orderedPlans:e.property("ordered_plans",e.list(vr)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",Dt),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",Mt.optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var es=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list($r).optional()),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutCollectAddress:e.property("checkout_collect_address",e.boolean()),checkoutCollectEmail:e.property("checkout_collect_email",e.boolean()),checkoutCollectPhone:e.property("checkout_collect_phone",e.boolean()),customCheckoutFields:e.property("custom_checkout_fields",e.list(qt).optional()),customPlanConfig:e.property("custom_plan_config",Nr.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),enableTaxCollection:e.property("enable_tax_collection",e.boolean()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(vr)),orderedBundleList:e.property("ordered_bundle_list",e.list(Zi)),orderedPlans:e.property("ordered_plans",e.list(vr)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",Dt),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",Mt.optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var It=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional())});var fy=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var Ft=e.object({showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var Kt=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(fy)),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutSettings:e.property("checkout_settings",It),componentSettings:e.property("component_settings",Ft),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnIds:e.property("ordered_add_on_ids",e.list(vr)),planIds:e.property("plan_ids",e.list(vr)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",e.string()),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",e.string().optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var _y=e.object({data:Kt,params:e.record(e.string(),e.unknown())});var Sy=e.object({includeCompanyCounts:e.property("include_company_counts",e.boolean().optional())});var Py=e.object({createdAt:e.property("created_at",e.date()),definitionId:e.property("definition_id",e.string()),helperText:e.property("helper_text",e.string().optional()),id:e.string(),name:e.string(),position:e.number(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string()),traitHierarchy:e.property("trait_hierarchy",e.list(e.string())),updatedAt:e.property("updated_at",e.date())});var xy=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var rs=e.object({entitlements:e.list(xy).optional(),planId:e.property("plan_id",e.string())});var Ey=e.object({addOns:e.property("add_ons",e.list(pr)),checkoutSettings:e.property("checkout_settings",It),componentSettings:e.property("component_settings",Ft),customCheckoutFields:e.property("custom_checkout_fields",e.list(Py)),customPlanConfig:e.property("custom_plan_config",Jo.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),defaultPlan:e.property("default_plan",pr.optional()),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlan:e.property("fallback_plan",pr.optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlan:e.property("initial_plan",pr.optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPrice:e.property("initial_plan_price",H.optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnList:e.property("ordered_add_on_list",e.list(rs)),orderedBundleList:e.property("ordered_bundle_list",e.list(Zi)),orderedPlanList:e.property("ordered_plan_list",e.list(rs)),plans:e.list(pr),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",e.string()),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",e.string().optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlan:e.property("trial_expiry_plan",pr.optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPrice:e.property("trial_expiry_plan_price",H.optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var Cy=e.object({data:Ey,params:Sy});var Uy=e.object({data:Kt,params:e.record(e.string(),e.unknown())});var Xi=e.enum_(["immediate","leave"]);var is=e.object({companyIds:e.property("company_ids",e.list(e.string())),excludedCompanyIds:e.property("excluded_company_ids",e.list(e.string())),planId:e.property("plan_id",e.string()),planVersionIdTo:e.property("plan_version_id_to",e.string()),planVersionIdsFrom:e.property("plan_version_ids_from",e.list(e.string())),strategy:Xi,targetPlanType:e.property("target_plan_type",te)});var Lt=e.enum_(["ambiguous_subscription_item","multiple_subscriptions","no_price_for_interval","not_on_origin_version","operation_item_not_found","permanent_config","permanent_decline","transient_decline","transient_infra","transient_stripe","unknown","would_leave_empty_subscription"]);var os=e.object({errorCodes:e.property("error_codes",e.list(Lt))});var Tr=e.enum_(["completed","failed","in_progress","pending","skipped"]);var vy=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Tr.optional()});var Ty=e.object({data:q,params:vy});var Or=e.enum_(["completed","failed","in_progress","pending"]);var Oy=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Or.optional()});var ky=e.object({data:q,params:Oy});var ei=e.object({completedAt:e.property("completed_at",e.date().optional()),completedCompanies:e.property("completed_companies",e.number()),createdAt:e.property("created_at",e.date()),error:e.string().optional(),failedCompanies:e.property("failed_companies",e.number()),id:e.string(),planId:e.property("plan_id",e.string()),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),planVersionIdTo:e.property("plan_version_id_to",e.string()),planVersionIdsFrom:e.property("plan_version_ids_from",e.list(e.string())),skippedCompanies:e.property("skipped_companies",e.number()),startedAt:e.property("started_at",e.date().optional()),status:Or,strategy:Xi,totalCompanies:e.property("total_companies",e.number()),updatedAt:e.property("updated_at",e.date())});var By=e.object({data:ei,params:e.record(e.string(),e.unknown())});var jy=e.object({data:ei,params:e.record(e.string(),e.unknown())});var Ay=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Tr.optional()});var Gt=e.object({companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),completedAt:e.property("completed_at",e.date().optional()),createdAt:e.property("created_at",e.date()),error:e.string().optional(),errorCode:e.property("error_code",Lt.optional()),id:e.string(),migrationId:e.property("migration_id",e.string()),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),startedAt:e.property("started_at",e.date().optional()),status:Tr,updatedAt:e.property("updated_at",e.date())});var Vy=e.object({data:e.list(Gt),params:Ay});var qy=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Or.optional()});var Dy=e.object({data:e.list(ei),params:qy});var My=e.object({data:Gt,params:e.record(e.string(),e.unknown())});var Iy=e.object({data:ei,params:e.record(e.string(),e.unknown())});var ts=e.object({billingProvider:e.property("billing_provider",k),description:e.string(),externalResourceId:e.property("external_resource_id",e.string()),externalResourceVersion:e.property("external_resource_version",e.string().optional()),icon:pe.optional(),name:e.string(),planType:e.property("plan_type",te)});var as=e.object({companyId:e.property("company_id",e.string()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),description:e.string(),icon:pe.optional(),name:e.string()});var ns=e.object({activationStrategy:e.property("activation_strategy",Oi.optional()),couponExternalId:e.property("coupon_external_id",e.string().optional()),customerEmail:e.property("customer_email",e.string().optional()),daysUntilDue:e.property("days_until_due",e.number().optional()),excludedCompanyIds:e.property("excluded_company_ids",e.list(e.string())),migrationStrategy:e.property("migration_strategy",Xi)});var ss=e.object({activationStrategy:e.property("activation_strategy",Oi.optional()),customerEmail:e.property("customer_email",e.string()),daysUntilDue:e.property("days_until_due",e.number().optional())});var cs=e.object({addOnIds:e.property("add_on_ids",e.list(e.string())),basePlanId:e.property("base_plan_id",e.string().optional())});var Fy=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Ky=e.object({data:q,params:Fy});var Ly=e.object({companyId:e.property("company_id",e.string().optional()),companyScopedOnly:e.property("company_scoped_only",e.boolean().optional()),excludeCompanyScoped:e.property("exclude_company_scoped",e.boolean().optional()),forFallbackPlan:e.property("for_fallback_plan",e.boolean().optional()),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),hasProductId:e.property("has_product_id",e.boolean().optional()),ids:e.list(e.string()).optional(),includeDraftVersions:e.property("include_draft_versions",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planType:e.property("plan_type",te.optional()),q:e.string().optional(),scopedToCompanyId:e.property("scoped_to_company_id",e.string().optional()),withEntitlements:e.property("with_entitlements",e.boolean().optional()),withoutEntitlementFor:e.property("without_entitlement_for",e.string().optional()),withoutPaidProductId:e.property("without_paid_product_id",e.boolean().optional())});var Gy=e.object({data:q,params:Ly});var Wy=e.object({data:we,params:e.record(e.string(),e.unknown())});var Hy=e.object({data:we,params:e.record(e.string(),e.unknown())});var Ny=e.object({data:F,params:e.record(e.string(),e.unknown())});var $y=e.object({promoteArchivedVersion:e.property("promote_archived_version",e.boolean().optional())});var Jy=e.object({data:F,params:$y});var Yy=e.object({planVersionId:e.property("plan_version_id",e.string().optional())});var Zy=e.object({data:we,params:Yy});var Xy=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Qy=e.object({data:e.list(X),params:Xy});var ew=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),status:Pr.optional(),statuses:e.list(Pr).optional()});var rw=e.object({data:e.list(Gr),params:ew});var iw=e.object({planId:e.property("plan_id",e.string().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var ow=e.object({data:e.list(bt),params:iw});var tw=e.object({companyId:e.property("company_id",e.string().optional()),companyScopedOnly:e.property("company_scoped_only",e.boolean().optional()),excludeCompanyScoped:e.property("exclude_company_scoped",e.boolean().optional()),forFallbackPlan:e.property("for_fallback_plan",e.boolean().optional()),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),hasProductId:e.property("has_product_id",e.boolean().optional()),ids:e.list(e.string()).optional(),includeDraftVersions:e.property("include_draft_versions",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planType:e.property("plan_type",te.optional()),q:e.string().optional(),scopedToCompanyId:e.property("scoped_to_company_id",e.string().optional()),withEntitlements:e.property("with_entitlements",e.boolean().optional()),withoutEntitlementFor:e.property("without_entitlement_for",e.string().optional()),withoutPaidProductId:e.property("without_paid_product_id",e.boolean().optional())});var aw=e.object({data:e.list(we),params:tw});var nw=e.object({data:Gr,params:e.record(e.string(),e.unknown())});var sw=e.object({data:Re,params:e.record(e.string(),e.unknown())});var cw=e.object({data:Gr,params:e.record(e.string(),e.unknown())});var lw=e.object({data:X,params:e.record(e.string(),e.unknown())});var pw=e.object({data:we,params:e.record(e.string(),e.unknown())});var uw=e.object({data:Vt,params:e.record(e.string(),e.unknown())});var dw=e.object({data:we,params:e.record(e.string(),e.unknown())});var ls=e.object({companyId:e.property("company_id",e.string()),executeAfter:e.property("execute_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),toPlanId:e.property("to_plan_id",e.string())});var ri=e.enum_(["cancelled","error","executing","pending","success"]);var ps=e.object({executeAfter:e.property("execute_after",e.date().optional()),status:ri.optional()});var ii=e.object({actorType:e.property("actor_type",e.string()),companyId:e.property("company_id",e.string()),completedAt:e.property("completed_at",e.date().optional()),createdAt:e.property("created_at",e.date()),errorMessage:e.property("error_message",e.string().optional()),executeAfter:e.property("execute_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),id:e.string(),scheduledInterval:e.property("scheduled_interval",e.string().optional()),scheduledPrice:e.property("scheduled_price",e.number().optional()),startedAt:e.property("started_at",e.date().optional()),status:ri,toPlanId:e.property("to_plan_id",e.string()),updatedAt:e.property("updated_at",e.date())});var mw=e.object({data:ii,params:e.record(e.string(),e.unknown())});var hw=e.object({data:ii,params:e.record(e.string(),e.unknown())});var gw=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),status:ri.optional()});var yw=e.object({data:e.list(ii),params:gw});var ww=e.object({data:ii,params:e.record(e.string(),e.unknown())});var Qi=e.object({creditId:e.property("credit_id",e.string())});var eo=e.object({featureId:e.property("feature_id",e.string())});var mr=e.enum_(["subscription.trial.ended","company.created","company.deleted","company.override.created","company.override.deleted","company.override.expired","company.override.updated","company.plan_changed","company.scheduled_downgrade","company.updated","credit.limit.reached","credit.limit.warning","entitlement.limit.reached","entitlement.limit.warning","entitlement.soft_limit.reached","entitlement.soft_limit.warning","entitlement.tier_limit.reached","entitlement.tier_limit.warning","feature.created","feature.deleted","feature.updated","flag.created","flag.deleted","flag_rules.updated","flag.updated","plan.created","plan.deleted","plan.entitlement.created","plan.entitlement.deleted","plan.entitlement.updated","plan.updated","plan_version.deleted","rule.deleted","test.send","user.created","user.deleted","user.updated","auto.topup.hard.failure","auto.topup.retry.exceeded"]);var us=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Qi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(eo).optional()),name:e.string(),requestTypes:e.property("request_types",e.list(mr)),url:e.string()});var ds=e.object({requestType:e.property("request_type",mr)});var Wt=e.enum_(["active","inactive"]);var ms=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Qi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(eo).optional()),name:e.string().optional(),requestTypes:e.property("request_types",e.list(mr).optional()),status:Wt.optional(),url:e.string().optional()});var bw=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),webhookId:e.property("webhook_id",e.string().optional())});var zw=e.object({data:q,params:bw});var Rw=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var fw=e.object({data:q,params:Rw});var hr=e.object({createdAt:e.property("created_at",e.date()),creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Qi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(eo).optional()),id:e.string(),name:e.string(),requestTypes:e.property("request_types",e.list(mr)),secret:e.string(),status:Wt,updatedAt:e.property("updated_at",e.date()),url:e.string()});var _w=e.object({data:hr,params:e.record(e.string(),e.unknown())});var Sw=e.object({data:F,params:e.record(e.string(),e.unknown())});var Pw=e.enum_(["failure","pending","success"]);var Ht=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),payload:e.string().optional(),requestType:e.property("request_type",mr),responseCode:e.property("response_code",e.number().optional()),sentAt:e.property("sent_at",e.date().optional()),status:Pw,updatedAt:e.property("updated_at",e.date()),webhook:hr.optional(),webhookId:e.property("webhook_id",e.string())});var xw=e.object({data:Ht,params:e.record(e.string(),e.unknown())});var Ew=e.object({data:hr,params:e.record(e.string(),e.unknown())});var Cw=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),webhookId:e.property("webhook_id",e.string().optional())});var Uw=e.object({data:e.list(Ht),params:Cw});var vw=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Tw=e.object({data:e.list(hr),params:vw});var Ow=e.object({responseCode:e.property("response_code",e.number()),success:e.boolean()});var kw=e.object({data:Ow,params:e.record(e.string(),e.unknown())});var Bw=e.object({data:hr,params:e.record(e.string(),e.unknown())});var n=e.object({error:e.string()});var Nt=e.object({id:e.string(),value:e.string()});var jw=e.object({addOnId:e.property("add_on_id",e.string()),priceId:e.property("price_id",e.string())});var Aw=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),planCreditGrantId:e.property("plan_credit_grant_id",e.string())});var $t=e.object({bundleId:e.property("bundle_id",e.string()),quantity:e.number()});var Jt=e.object({priceId:e.property("price_id",e.string()),quantity:e.number()});var hs=e.object({addOnIds:e.property("add_on_ids",e.list(jw)),autoTopupOverrides:e.property("auto_topup_overrides",e.list(Aw)),billingEntityId:e.property("billing_entity_id",e.string().optional()),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list($t)),customFieldValues:e.property("custom_field_values",e.list(Nt)),newPlanId:e.property("new_plan_id",e.string()),newPriceId:e.property("new_price_id",e.string()),optInAccepted:e.property("opt_in_accepted",e.boolean().optional()),payInAdvance:e.property("pay_in_advance",e.list(Jt)),paymentMethodId:e.property("payment_method_id",e.string().optional()),promoCode:e.property("promo_code",e.string().optional()),skipTrial:e.property("skip_trial",e.boolean())});var gs=e.object({defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",cr),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var Yt=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Hi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:e.record(e.string(),e.unknown()).optional(),isSandbox:e.property("is_sandbox",e.boolean().optional()),liveMode:e.property("live_mode",e.boolean().optional()),type:Se});var ys=e.object({keys:e.record(e.string(),e.string())});var Vw=e.object({planId:e.property("plan_id",e.string()),priceId:e.property("price_id",e.string().optional()),versionId:e.property("version_id",e.string().optional())});var ws=e.object({addOnSelections:e.property("add_on_selections",e.list(Vw)),basePlanId:e.property("base_plan_id",e.string().optional()),basePlanPriceId:e.property("base_plan_price_id",e.string().optional()),basePlanVersionId:e.property("base_plan_version_id",e.string().optional()),billingEntityId:e.property("billing_entity_id",e.string().optional()),cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list($t)),customFieldValues:e.property("custom_field_values",e.list(Nt)),payInAdvanceEntitlements:e.property("pay_in_advance_entitlements",e.list(Jt)),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),promoCode:e.property("promo_code",e.string().optional()),prorate:e.boolean().optional(),trialEnd:e.property("trial_end",e.date().optional())});var qw=e.record(e.string(),e.unknown());var Dw=e.record(e.string(),e.unknown());var Mw=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var ro=e.enum_(["all_time","current_day","current_month","current_week"]);var io=e.enum_(["billing_cycle","first_of_month"]);var Iw=e.object({key:e.string(),value:e.number()});var Zt=e.object({allocation:e.number().optional(),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditReserved:e.property("credit_reserved",e.number().optional()),creditSettled:e.property("credit_settled",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditUsed:e.property("credit_used",e.number().optional()),eventName:e.property("event_name",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",ro.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",io.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",Mw),warningTiers:e.property("warning_tiers",e.list(Iw).optional())});var Fw=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var Xt=e.object({accountId:e.property("account_id",e.string()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",io),period:ro,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var Kw=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var Lw=e.enum_(["company","user"]);var Gw=e.enum_(["bool","date","int","string"]);var fo=e.object({comparableType:e.property("comparable_type",Gw),entityType:e.property("entity_type",Lw),id:e.string()});var Qt=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",fo.optional()),conditionType:e.property("condition_type",Kw),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",ro.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",io.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Mr,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",fo.optional()),traitValue:e.property("trait_value",e.string())});var Ww=e.object({conditions:e.list(Qt)});var oo=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(Ww)),conditions:e.list(Qt),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Fw),value:e.boolean()});var Hw=e.object({id:e.string(),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date())});var ea=e.object({traitDefinition:e.property("trait_definition",fo.optional()),value:e.string()});var Nw=e.object({accountId:e.property("account_id",e.string()),basePlanId:e.property("base_plan_id",e.string().optional()),billingProductIds:e.property("billing_product_ids",e.list(e.string())),creditBalances:e.property("credit_balances",e.record(e.string(),e.number())),entitlements:e.list(Zt).optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),metrics:e.list(Xt),planIds:e.property("plan_ids",e.list(e.string())),planVersionIds:e.property("plan_version_ids",e.list(e.string())),rules:e.list(oo),subscription:Hw.optional(),traits:e.list(ea)});var bs=e.object({accountId:e.property("account_id",e.string()),defaultValue:e.property("default_value",e.boolean()),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),rules:e.list(oo)});var $w=e.object({accountId:e.property("account_id",e.string()),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),rules:e.list(oo),traits:e.list(ea)});var zs=e.object({basePlanId:e.property("base_plan_id",e.string().optional()),basePlanPriceId:e.property("base_plan_price_id",e.string().optional()),id:e.string().optional(),keys:e.record(e.string(),e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string().optional(),preventKeyRemap:e.property("prevent_key_remap",e.boolean().optional()),traits:e.record(e.string(),e.unknown()).optional(),updateOnly:e.property("update_only",e.boolean().optional())});var Rs=e.object({incr:e.number().optional(),keys:e.record(e.string(),e.string()),set:e.string().optional(),trait:e.string(),updateOnly:e.property("update_only",e.boolean().optional())});var fs=e.object({companies:e.list(e.record(e.string(),e.string())).optional(),company:e.record(e.string(),e.string()).optional(),companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),id:e.string().optional(),keys:e.record(e.string(),e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional(),updateOnly:e.property("update_only",e.boolean().optional())});var ra=class{constructor(o){this._options=K(o)}issueTemporaryAccessToken(o,i){return R.fromPromise(this.__issueTemporaryAccessToken(o,i))}async __issueTemporaryAccessToken(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"temporary-access-tokens"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:{...$a.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),resource_type:"company"},timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Zc.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/temporary-access-tokens")}};var ia=class{constructor(o){this._options=K(o)}listAccountMembers(o={},i){return R.fromPromise(this.__listAccountMembers(o,i))}async __listAccountMembers(o={},i){let{ids:t,q:s,limit:r,offset:a}=o,u={ids:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"account-members"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Rl.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/account-members")}getAccountMember(o,i){return R.fromPromise(this.__getAccountMember(o,i))}async __getAccountMember(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`account-members/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:dl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/account-members/{account_member_id}")}countAccountMembers(o={},i){return R.fromPromise(this.__countAccountMembers(o,i))}async __countAccountMembers(o={},i){let{ids:t,q:s,limit:r,offset:a}=o,u={ids:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"account-members/count"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Qc.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/account-members/count")}listApiKeys(o,i){return R.fromPromise(this.__listApiKeys(o,i))}async __listApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:a}=o,u={environment_id:t,require_environment:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:_l.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/api-keys")}createApiKey(o,i){return R.fromPromise(this.__createApiKey(o,i))}async __createApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ja.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:al.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/api-keys")}getApiKey(o,i){return R.fromPromise(this.__getApiKey(o,i))}async __getApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ml.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/api-keys/{api_key_id}")}updateApiKey(o,i={},t){return R.fromPromise(this.__updateApiKey(o,i,t))}async __updateApiKey(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Za.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:vl.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/api-keys/{api_key_id}")}deleteApiKey(o,i){return R.fromPromise(this.__deleteApiKey(o,i))}async __deleteApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:cl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/api-keys/{api_key_id}")}countApiKeys(o,i){return R.fromPromise(this.__countApiKeys(o,i))}async __countApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:a}=o,u={environment_id:t,require_environment:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys/count"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:rl.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/api-keys/count")}listAuditLogs(o={},i){return R.fromPromise(this.__listAuditLogs(o,i))}async __listAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:a,startTime:u,limit:g,offset:h}=o,l={actor_type:t!=null?Ee.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:a,start_time:u?.toISOString(),limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=f(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"audit-log"),method:"GET",headers:w,queryString:d.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Pl.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/audit-log")}getAuditLog(o,i){return R.fromPromise(this.__getAuditLog(o,i))}async __getAuditLog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`audit-log/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/audit-log/{audit_log_id}")}countAuditLogs(o={},i){return R.fromPromise(this.__countAuditLogs(o,i))}async __countAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:a,startTime:u,limit:g,offset:h}=o,l={actor_type:t!=null?Ee.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:a,start_time:u?.toISOString(),limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=f(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"audit-log/count"),method:"GET",headers:w,queryString:d.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:ol.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/audit-log/count")}listEnvironments(o={},i){return R.fromPromise(this.__listEnvironments(o,i))}async __listEnvironments(o={},i){let{ids:t,limit:s,offset:r}=o,a={ids:t,limit:s,offset:r},u=await this._options.authProvider.getAuthRequest(),g=f(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"environments"),method:"GET",headers:g,queryString:d.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:El.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/environments")}createEnvironment(o,i){return R.fromPromise(this.__createEnvironment(o,i))}async __createEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"environments"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ya.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:sl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/environments")}getEnvironment(o,i){return R.fromPromise(this.__getEnvironment(o,i))}async __getEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/environments/{environment_id}")}updateEnvironment(o,i={},t){return R.fromPromise(this.__updateEnvironment(o,i,t))}async __updateEnvironment(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Xa.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Tl.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/environments/{environment_id}")}deleteEnvironment(o,i){return R.fromPromise(this.__deleteEnvironment(o,i))}async __deleteEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ll.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/environments/{environment_id}")}quickstart(o){return R.fromPromise(this.__quickstart(o))}async __quickstart(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"quickstart"),method:"POST",headers:t,queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Ul.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 400:throw new v(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"POST","/quickstart")}getWhoAmI(o){return R.fromPromise(this.__getWhoAmI(o))}async __getWhoAmI(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"whoami"),method:"GET",headers:t,queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:bl.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/whoami")}};var oa=class{constructor(o){this._options=K(o)}listCoupons(o={},i){return R.fromPromise(this.__listCoupons(o,i))}async __listCoupons(o={},i){let{isActive:t,q:s,limit:r,offset:a}=o,u={is_active:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/coupons"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Zl.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/coupons")}upsertBillingCoupon(o,i){return R.fromPromise(this.__upsertBillingCoupon(o,i))}async __upsertBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/coupons"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:tn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:cp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/coupons")}deleteBillingCoupon(o,i){return R.fromPromise(this.__deleteBillingCoupon(o,i))}async __deleteBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/coupons/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Dl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/coupons/{billing_id}")}deleteBillingCustomer(o,i){return R.fromPromise(this.__deleteBillingCustomer(o,i))}async __deleteBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/customer/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ml.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/customer/{billing_id}")}upsertBillingCustomer(o,i){return R.fromPromise(this.__upsertBillingCustomer(o,i))}async __upsertBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customer/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qa.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:pp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/customer/upsert")}listCustomersWithSubscriptions(o={},i){return R.fromPromise(this.__listCustomersWithSubscriptions(o,i))}async __listCustomersWithSubscriptions(o={},i){let{companyIds:t,name:s,providerType:r,q:a,limit:u,offset:g}=o,h={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customers"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:rp.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/billing/customers")}countCustomers(o={},i){return R.fromPromise(this.__countCustomers(o,i))}async __countCustomers(o={},i){let{companyIds:t,name:s,providerType:r,q:a,limit:u,offset:g}=o,h={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customers/count"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:ql.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/billing/customers/count")}listInvoices(o,i){return R.fromPromise(this.__listInvoices(o,i))}async __listInvoices(o,i){let{companyId:t,customerExternalId:s,subscriptionExternalId:r,limit:a,offset:u}=o,g={company_id:t,customer_external_id:s,subscription_external_id:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/invoices"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:op.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/billing/invoices")}upsertInvoice(o,i){return R.fromPromise(this.__upsertInvoice(o,i))}async __upsertInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/invoices"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:an.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/invoices")}deleteBillingInvoice(o,i){return R.fromPromise(this.__deleteBillingInvoice(o,i))}async __deleteBillingInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/invoices/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Il.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/invoices/{billing_id}")}listMeters(o={},i){return R.fromPromise(this.__listMeters(o,i))}async __listMeters(o={},i){let{displayName:t,limit:s,offset:r}=o,a={display_name:t,limit:s,offset:r},u=await this._options.authProvider.getAuthRequest(),g=f(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/meter"),method:"GET",headers:g,queryString:d.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:ap.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/billing/meter")}upsertBillingMeter(o,i){return R.fromPromise(this.__upsertBillingMeter(o,i))}async __upsertBillingMeter(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/meter/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:nn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:up.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/meter/upsert")}listPaymentMethods(o,i){return R.fromPromise(this.__listPaymentMethods(o,i))}async __listPaymentMethods(o,i){let{companyId:t,customerExternalId:s,limit:r,offset:a}=o,u={company_id:t,customer_external_id:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/payment-methods"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:sp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/payment-methods")}upsertPaymentMethod(o,i){return R.fromPromise(this.__upsertPaymentMethod(o,i))}async __upsertPaymentMethod(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/payment-methods"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:sn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/payment-methods")}deletePaymentMethodByExternalId(o,i){return R.fromPromise(this.__deletePaymentMethodByExternalId(o,i))}async __deletePaymentMethodByExternalId(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/payment-methods/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Kl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/payment-methods/{billing_id}")}listBillingPrices(o={},i){return R.fromPromise(this.__listBillingPrices(o,i))}async __listBillingPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:u,isActive:g,planVersionId:h,price:l,productId:y,productIds:w,providerType:U,q:T,tiersMode:O,usageType:A,withMeter:j,limit:D,offset:V}=o,re={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:u,is_active:g,plan_version_id:h,price:l,product_id:y,product_ids:w,provider_type:U!=null?k.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,q:T,tiers_mode:O!=null?de.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:A!=null?ne.jsonOrThrow(A,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:j,limit:D,offset:V},ue=await this._options.authProvider.getAuthRequest(),Ue=f(ue.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/price"),method:"GET",headers:Ue,queryString:d.queryBuilder().addMany(re).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Wl.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return C(B.error,B.rawResponse,"GET","/billing/price")}upsertBillingPrice(o,i){return R.fromPromise(this.__upsertBillingPrice(o,i))}async __upsertBillingPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/price/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:en.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:dp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/price/upsert")}deleteBillingProduct(o,i){return R.fromPromise(this.__deleteBillingProduct(o,i))}async __deleteBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/product/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Fl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/product/{billing_id}")}listBillingProductPrices(o={},i){return R.fromPromise(this.__listBillingProductPrices(o,i))}async __listBillingProductPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:u,isActive:g,planVersionId:h,price:l,productId:y,productIds:w,providerType:U,q:T,tiersMode:O,usageType:A,withMeter:j,limit:D,offset:V}=o,re={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:u,is_active:g,plan_version_id:h,price:l,product_id:y,product_ids:w,provider_type:U!=null?k.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,q:T,tiers_mode:O!=null?de.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:A!=null?ne.jsonOrThrow(A,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:j,limit:D,offset:V},ue=await this._options.authProvider.getAuthRequest(),Ue=f(ue.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/product/prices"),method:"GET",headers:Ue,queryString:d.queryBuilder().addMany(re).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Nl.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return C(B.error,B.rawResponse,"GET","/billing/product/prices")}deleteProductPrice(o,i){return R.fromPromise(this.__deleteProductPrice(o,i))}async __deleteProductPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/product/prices/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ll.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/product/prices/{billing_id}")}upsertBillingProduct(o,i){return R.fromPromise(this.__upsertBillingProduct(o,i))}async __upsertBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/product/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:rn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:mp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/product/upsert")}listBillingProducts(o={},i){return R.fromPromise(this.__listBillingProducts(o,i))}async __listBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:a,providerType:u,q:g,recurringChargesOnly:h,withOneTimeCharges:l,withPricesOnly:y,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=o,A={ids:t,is_active:s,name:r,price_usage_type:a!=null?ne.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:u!=null?k.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,q:g,recurring_charges_only:h,with_one_time_charges:l,with_prices_only:y,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},j=await this._options.authProvider.getAuthRequest(),D=f(j.headers,this._options?.headers,i?.headers),V=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/products"),method:"GET",headers:D,queryString:d.queryBuilder().addMany(A).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(V.ok)return{data:Jl.parseOrThrow(V.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:V.rawResponse};if(V.error.reason==="status-code")switch(V.error.statusCode){case 400:throw new v(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 401:throw new x(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 403:throw new _(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 404:throw new P(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 500:throw new S(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);default:throw new b({statusCode:V.error.statusCode,body:V.error.body,rawResponse:V.rawResponse})}return C(V.error,V.rawResponse,"GET","/billing/products")}countBillingProducts(o={},i){return R.fromPromise(this.__countBillingProducts(o,i))}async __countBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:a,providerType:u,q:g,recurringChargesOnly:h,withOneTimeCharges:l,withPricesOnly:y,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=o,A={ids:t,is_active:s,name:r,price_usage_type:a!=null?ne.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:u!=null?k.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,q:g,recurring_charges_only:h,with_one_time_charges:l,with_prices_only:y,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},j=await this._options.authProvider.getAuthRequest(),D=f(j.headers,this._options?.headers,i?.headers),V=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/products/count"),method:"GET",headers:D,queryString:d.queryBuilder().addMany(A).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(V.ok)return{data:Al.parseOrThrow(V.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:V.rawResponse};if(V.error.reason==="status-code")switch(V.error.statusCode){case 400:throw new v(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 401:throw new x(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 403:throw new _(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 404:throw new P(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 500:throw new S(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);default:throw new b({statusCode:V.error.statusCode,body:V.error.body,rawResponse:V.rawResponse})}return C(V.error,V.rawResponse,"GET","/billing/products/count")}upsertBillingSubscription(o,i){return R.fromPromise(this.__upsertBillingSubscription(o,i))}async __upsertBillingSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/subscription/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:on.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/subscription/upsert")}};var ta=class{constructor(o){this._options=K(o)}listCatalogs(o={},i){return R.fromPromise(this.__listCatalogs(o,i))}async __listCatalogs(o={},i){let{isDefault:t,q:s,limit:r,offset:a}=o,u={is_default:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"catalogs"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Fp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/catalogs")}createCatalog(o,i){return R.fromPromise(this.__createCatalog(o,i))}async __createCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"catalogs"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:cn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Rp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/catalogs")}getCatalog(o,i){return R.fromPromise(this.__getCatalog(o,i))}async __getCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_p.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}")}updateCatalog(o,i={},t){return R.fromPromise(this.__updateCatalog(o,i,t))}async __updateCatalog(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:un.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Kp.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/catalogs/{catalog_id}")}deleteCatalog(o,i){return R.fromPromise(this.__deleteCatalog(o,i))}async __deleteCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/catalogs/{catalog_id}")}getConfiguration(o,i){return R.fromPromise(this.__getConfiguration(o,i))}async __getConfiguration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/configuration`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:kp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/configuration")}updateConfiguration(o,i={},t){return R.fromPromise(this.__updateConfiguration(o,i,t))}async __updateConfiguration(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/configuration`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:pn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Lp.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/catalogs/{catalog_id}/configuration")}getCreditBundlesInCatalog(o,i){return R.fromPromise(this.__getCreditBundlesInCatalog(o,i))}async __getCreditBundlesInCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/credit-bundles`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:jp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/credit-bundles")}addCreditBundle(o,i,t){return R.fromPromise(this.__addCreditBundle(o,i,t))}async __addCreditBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/credit-bundles/${d.encodePathParam(i)}`),method:"POST",headers:r,queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/catalogs/{catalog_id}/credit-bundles/{credit_bundle_id}")}removeCreditBundle(o,i,t){return R.fromPromise(this.__removeCreditBundle(o,i,t))}async __removeCreditBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/credit-bundles/${d.encodePathParam(i)}`),method:"DELETE",headers:r,queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"DELETE","/catalogs/{catalog_id}/credit-bundles/{credit_bundle_id}")}getDerivedFeatures(o,i){return R.fromPromise(this.__getDerivedFeatures(o,i))}async __getDerivedFeatures(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/features`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/features")}getPlansInCatalog(o,i){return R.fromPromise(this.__getPlansInCatalog(o,i))}async __getPlansInCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/plans`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Mp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/plans")}addPlan(o,i,t){return R.fromPromise(this.__addPlan(o,i,t))}async __addPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/plans/${d.encodePathParam(i)}`),method:"POST",headers:r,queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/catalogs/{catalog_id}/plans/{plan_id}")}removePlan(o,i,t){return R.fromPromise(this.__removePlan(o,i,t))}async __removePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${d.encodePathParam(o)}/plans/${d.encodePathParam(i)}`),method:"DELETE",headers:r,queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"DELETE","/catalogs/{catalog_id}/plans/{plan_id}")}};var aa=class{constructor(o){this._options=K(o)}internal(o,i){return R.fromPromise(this.__internal(o,i))}async __internal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:hs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:eu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/checkout-internal")}getCheckoutData(o,i){return R.fromPromise(this.__getCheckoutData(o,i))}async __getCheckoutData(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal/data"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:hn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:au.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/checkout-internal/data")}previewCheckoutInternal(o,i){return R.fromPromise(this.__previewCheckoutInternal(o,i))}async __previewCheckoutInternal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal/preview"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:hs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:pu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/checkout-internal/preview")}managePlan(o,i){return R.fromPromise(this.__managePlan(o,i))}async __managePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ws.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:nu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/manage-plan")}previewManagePlan(o,i){return R.fromPromise(this.__previewManagePlan(o,i))}async __previewManagePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan/preview"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ws.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:du.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/manage-plan/preview")}cancelSubscription(o,i){return R.fromPromise(this.__cancelSubscription(o,i))}async __cancelSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan/subscription/cancel"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:mn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Xp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/manage-plan/subscription/cancel")}updateCustomerSubscriptionTrialEnd(o,i={},t){return R.fromPromise(this.__updateCustomerSubscriptionTrialEnd(o,i,t))}async __updateCustomerSubscriptionTrialEnd(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`subscription/${d.encodePathParam(o)}/edit-trial-end`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:gn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:mu.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/subscription/{subscription_id}/edit-trial-end")}};var na=class{constructor(o){this._options=K(o)}listCompanies(o={},i){return R.fromPromise(this.__listCompanies(o,i))}async __listCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:u,planIds:g,planVersionId:h,planVersionIds:l,q:y,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:A,withoutFeatureOverrideFor:j,withoutPlan:D,withoutSubscription:V,withSubscription:re,limit:ue,offset:Ue}=o,B={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:u,plan_ids:g,plan_version_id:h,plan_version_ids:l,q:y,sort_order_column:w,sort_order_direction:U!=null?je.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(zr=>xr.jsonOrThrow(zr,{unrecognizedObjectKeys:"strip"})):T!=null?xr.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(zr=>Er.jsonOrThrow(zr,{unrecognizedObjectKeys:"strip"})):O!=null?Er.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:A,without_feature_override_for:j,without_plan:D,without_subscription:V,with_subscription:re,limit:ue,offset:Ue},ti=await this._options.authProvider.getAuthRequest(),br=f(ti.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies"),method:"GET",headers:br,queryString:d.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(M.ok)return{data:ed.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 400:throw new v(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new x(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new P(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return C(M.error,M.rawResponse,"GET","/companies")}upsertCompany(o,i){return R.fromPromise(this.__upsertCompany(o,i))}async __upsertCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:zs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/companies")}getCompany(o,i){return R.fromPromise(this.__getCompany(o,i))}async __getCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Fu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/companies/{company_id}")}deleteCompany(o,i={},t){return R.fromPromise(this.__deleteCompany(o,i,t))}async __deleteCompany(o,i={},t){let{cancelSubscription:s,prorate:r}=i,a={cancel_subscription:s,prorate:r},u=await this._options.authProvider.getAuthRequest(),g=f(u.headers,this._options?.headers,t?.headers),h=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${d.encodePathParam(o)}`),method:"DELETE",headers:g,queryString:d.queryBuilder().addMany(a).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Tu.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"DELETE","/companies/{company_id}")}countCompanies(o={},i){return R.fromPromise(this.__countCompanies(o,i))}async __countCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:u,planIds:g,planVersionId:h,planVersionIds:l,q:y,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:A,withoutFeatureOverrideFor:j,withoutPlan:D,withoutSubscription:V,withSubscription:re,limit:ue,offset:Ue}=o,B={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:u,plan_ids:g,plan_version_id:h,plan_version_ids:l,q:y,sort_order_column:w,sort_order_direction:U!=null?je.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(zr=>xr.jsonOrThrow(zr,{unrecognizedObjectKeys:"strip"})):T!=null?xr.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(zr=>Er.jsonOrThrow(zr,{unrecognizedObjectKeys:"strip"})):O!=null?Er.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:A,without_feature_override_for:j,without_plan:D,without_subscription:V,with_subscription:re,limit:ue,offset:Ue},ti=await this._options.authProvider.getAuthRequest(),br=f(ti.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/count"),method:"GET",headers:br,queryString:d.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(M.ok)return{data:yu.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 400:throw new v(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new x(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new P(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return C(M.error,M.rawResponse,"GET","/companies/count")}createCompany(o,i){return R.fromPromise(this.__createCompany(o,i))}async __createCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/create"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:zs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/companies/create")}deleteCompanyByKeys(o,i){return R.fromPromise(this.__deleteCompanyByKeys(o,i))}async __deleteCompanyByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/delete"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ys.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/companies/delete")}lookupCompany(o,i){return R.fromPromise(this.__lookupCompany(o,i))}async __lookupCompany(o,i){let{keys:t}=o,s={keys:ve(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/lookup"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:hd.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/companies/lookup")}getCompanyBillingEntity(o={},i){return R.fromPromise(this.__getCompanyBillingEntity(o,i))}async __getCompanyBillingEntity(o={},i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-billing-entity"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:Iu.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new v(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/company-billing-entity")}getBillingEntityChildSubscriptions(o={},i){return R.fromPromise(this.__getBillingEntityChildSubscriptions(o,i))}async __getBillingEntityChildSubscriptions(o={},i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-billing-entity-subscriptions"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:qu.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new v(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/company-billing-entity-subscriptions")}listCompanyMemberships(o={},i){return R.fromPromise(this.__listCompanyMemberships(o,i))}async __listCompanyMemberships(o={},i){let{companyId:t,userId:s,limit:r,offset:a}=o,u={company_id:t,user_id:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-memberships"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:id.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/company-memberships")}getOrCreateCompanyMembership(o,i){return R.fromPromise(this.__getOrCreateCompanyMembership(o,i))}async __getOrCreateCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-memberships"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:zn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/company-memberships")}deleteCompanyMembership(o,i){return R.fromPromise(this.__deleteCompanyMembership(o,i))}async __deleteCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-memberships/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Uu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/company-memberships/{company_membership_id}")}getActiveCompanySubscription(o={},i){return R.fromPromise(this.__getActiveCompanySubscription(o,i))}async __getActiveCompanySubscription(o={},i){let{companyId:t,companyIds:s,limit:r,offset:a}=o,u={company_id:t,company_ids:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-subscriptions"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ju.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/company-subscriptions")}upsertCompanyTrait(o,i){return R.fromPromise(this.__upsertCompanyTrait(o,i))}async __upsertCompanyTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-traits"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Rd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/company-traits")}listEntityKeyDefinitions(o={},i){return R.fromPromise(this.__listEntityKeyDefinitions(o,i))}async __listEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:a,offset:u}=o,g={entity_type:t!=null?oe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-key-definitions"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:td.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/entity-key-definitions")}countEntityKeyDefinitions(o={},i){return R.fromPromise(this.__countEntityKeyDefinitions(o,i))}async __countEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:a,offset:u}=o,g={entity_type:t!=null?oe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-key-definitions/count"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:bu.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/entity-key-definitions/count")}listEntityTraitDefinitions(o={},i){return R.fromPromise(this.__listEntityTraitDefinitions(o,i))}async __listEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:a,traitTypes:u,limit:g,offset:h}=o,l={entity_type:t!=null?oe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(u)?u.map(T=>me.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):u!=null?me.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=f(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions"),method:"GET",headers:w,queryString:d.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:nd.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/entity-trait-definitions")}getOrCreateEntityTraitDefinition(o,i){return R.fromPromise(this.__getOrCreateEntityTraitDefinition(o,i))}async __getOrCreateEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:bn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Nu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/entity-trait-definitions")}getEntityTraitDefinition(o,i){return R.fromPromise(this.__getEntityTraitDefinition(o,i))}async __getEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-trait-definitions/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ku.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/entity-trait-definitions/{entity_trait_definition_id}")}updateEntityTraitDefinition(o,i,t){return R.fromPromise(this.__updateEntityTraitDefinition(o,i,t))}async __updateEntityTraitDefinition(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-trait-definitions/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:wd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/entity-trait-definitions/{entity_trait_definition_id}")}countEntityTraitDefinitions(o={},i){return R.fromPromise(this.__countEntityTraitDefinitions(o,i))}async __countEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:a,traitTypes:u,limit:g,offset:h}=o,l={entity_type:t!=null?oe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(u)?u.map(T=>me.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):u!=null?me.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=f(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions/count"),method:"GET",headers:w,queryString:d.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Ru.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/entity-trait-definitions/count")}getEntityTraitValues(o,i){return R.fromPromise(this.__getEntityTraitValues(o,i))}async __getEntityTraitValues(o,i){let{definitionId:t,q:s,limit:r,offset:a}=o,u={definition_id:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-values"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Wu.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/entity-trait-values")}listPlanChanges(o={},i){return R.fromPromise(this.__listPlanChanges(o,i))}async __listPlanChanges(o={},i){let{action:t,basePlanAction:s,companyId:r,companyIds:a,planIds:u,limit:g,offset:h}=o,l={action:t!=null?qi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,base_plan_action:s!=null?Di.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,company_id:r,company_ids:a,plan_ids:u,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=f(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-changes"),method:"GET",headers:w,queryString:d.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:cd.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/plan-changes")}getPlanChange(o,i){return R.fromPromise(this.__getPlanChange(o,i))}async __getPlanChange(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-changes/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Yu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/plan-changes/{plan_change_id}")}listPlanTraits(o={},i){return R.fromPromise(this.__listPlanTraits(o,i))}async __listPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:a,limit:u,offset:g}=o,h={ids:t,plan_id:s,trait_id:r,trait_ids:a,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:pd.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/plan-traits")}getPlanTrait(o,i){return R.fromPromise(this.__getPlanTrait(o,i))}async __getPlanTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-traits/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Zu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/plan-traits/{plan_trait_id}")}updatePlanTraitsBulk(o,i){return R.fromPromise(this.__updatePlanTraitsBulk(o,i))}async __updatePlanTraitsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits/bulk"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:fn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:bd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-traits/bulk")}countPlanTraits(o={},i){return R.fromPromise(this.__countPlanTraits(o,i))}async __countPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:a,limit:u,offset:g}=o,h={ids:t,plan_id:s,trait_id:r,trait_ids:a,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits/count"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:_u.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/plan-traits/count")}upsertUserTrait(o,i){return R.fromPromise(this.__upsertUserTrait(o,i))}async __upsertUserTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"user-traits"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_d.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/user-traits")}listUsers(o={},i){return R.fromPromise(this.__listUsers(o,i))}async __listUsers(o={},i){let{companyId:t,ids:s,planId:r,q:a,limit:u,offset:g}=o,h={company_id:t,ids:s,plan_id:r,q:a,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:dd.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/users")}upsertUser(o,i){return R.fromPromise(this.__upsertUser(o,i))}async __upsertUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:fs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/users")}getUser(o,i){return R.fromPromise(this.__getUser(o,i))}async __getUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`users/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Xu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/users/{user_id}")}deleteUser(o,i){return R.fromPromise(this.__deleteUser(o,i))}async __deleteUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`users/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ku.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/users/{user_id}")}countUsers(o={},i){return R.fromPromise(this.__countUsers(o,i))}async __countUsers(o={},i){let{companyId:t,ids:s,planId:r,q:a,limit:u,offset:g}=o,h={company_id:t,ids:s,plan_id:r,q:a,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/count"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Pu.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/users/count")}createUser(o,i){return R.fromPromise(this.__createUser(o,i))}async __createUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/create"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:fs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Eu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/users/create")}deleteUserByKeys(o,i){return R.fromPromise(this.__deleteUserByKeys(o,i))}async __deleteUserByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/delete"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ys.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ou.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/users/delete")}lookupUser(o,i){return R.fromPromise(this.__lookupUser(o,i))}async __lookupUser(o,i){let{keys:t}=o,s={keys:ve(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/lookup"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:yd.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/users/lookup")}};var sa=class{constructor(o){this._options=K(o)}listComponents(o={},i){return R.fromPromise(this.__listComponents(o,i))}async __listComponents(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},u=await this._options.authProvider.getAuthRequest(),g=f(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components"),method:"GET",headers:g,queryString:d.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Td.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/components")}createComponent(o,i){return R.fromPromise(this.__createComponent(o,i))}async __createComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Pn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ed.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/components")}getComponent(o,i){return R.fromPromise(this.__getComponent(o,i))}async __getComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ud.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/components/{component_id}")}updateComponent(o,i={},t){return R.fromPromise(this.__updateComponent(o,i,t))}async __updateComponent(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Fd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/components/{component_id}")}deleteComponent(o,i){return R.fromPromise(this.__deleteComponent(o,i))}async __deleteComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/components/{component_id}")}bindCatalog(o,i={},t){return R.fromPromise(this.__bindCatalog(o,i,t))}async __bindCatalog(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${d.encodePathParam(o)}/catalog`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Sn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Sd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/components/{component_id}/catalog")}countComponents(o={},i){return R.fromPromise(this.__countComponents(o,i))}async __countComponents(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},u=await this._options.authProvider.getAuthRequest(),g=f(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components/count"),method:"GET",headers:g,queryString:d.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:xd.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/components/count")}previewComponentData(o={},i){return R.fromPromise(this.__previewComponentData(o,i))}async __previewComponentData(o={},i){let{companyId:t,componentId:s}=o,r={company_id:t,component_id:s},a=await this._options.authProvider.getAuthRequest(),u=f(a.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components/preview-data"),method:"GET",headers:u,queryString:d.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Id.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/components/preview-data")}};var ca=class{constructor(o){this._options=K(o)}getPublicPlans(o){return R.fromPromise(this.__getPublicPlans(o))}async __getPublicPlans(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"public/plans"),method:"GET",headers:t,queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Ld.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/public/plans")}};var la=class{constructor(o){this._options=K(o)}listBillingCredits(o={},i){return R.fromPromise(this.__listBillingCredits(o,i))}async __listBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:a}=o,u={ids:t,name:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ym.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/credits")}createBillingCredit(o,i){return R.fromPromise(this.__createBillingCredit(o,i))}async __createBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:vn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:om.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits")}getSingleBillingCredit(o,i){return R.fromPromise(this.__getSingleBillingCredit(o,i))}async __getSingleBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:um.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/billing/credits/{credit_id}")}updateBillingCredit(o,i,t){return R.fromPromise(this.__updateBillingCredit(o,i,t))}async __updateBillingCredit(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Bn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:qm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/{credit_id}")}softDeleteBillingCredit(o,i){return R.fromPromise(this.__softDeleteBillingCredit(o,i))}async __softDeleteBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/credits/{credit_id}")}listCompanyCreditBalances(o,i){return R.fromPromise(this.__listCompanyCreditBalances(o,i))}async __listCompanyCreditBalances(o,i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/balance"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:fm.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new v(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/billing/credits/balance")}listCreditBundles(o={},i){return R.fromPromise(this.__listCreditBundles(o,i))}async __listCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:a,limit:u,offset:g}=o,h={ids:t,credit_id:s,status:r!=null?Ce.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?De.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:xm.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/billing/credits/bundles")}createCreditBundle(o,i){return R.fromPromise(this.__createCreditBundle(o,i))}async __createCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:On.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:am.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits/bundles")}getCreditBundle(o,i){return R.fromPromise(this.__getCreditBundle(o,i))}async __getCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:pm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/billing/credits/bundles/{bundle_id}")}updateCreditBundleDetails(o,i,t){return R.fromPromise(this.__updateCreditBundleDetails(o,i,t))}async __updateCreditBundleDetails(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:jn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Mm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/bundles/{bundle_id}")}deleteCreditBundle(o,i){return R.fromPromise(this.__deleteCreditBundle(o,i))}async __deleteCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:cm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/billing/credits/bundles/{bundle_id}")}countCreditBundles(o={},i){return R.fromPromise(this.__countCreditBundles(o,i))}async __countCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:a,limit:u,offset:g}=o,h={ids:t,credit_id:s,status:r!=null?Ce.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?De.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles/count"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:em.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/billing/credits/bundles/count")}countBillingCredits(o={},i){return R.fromPromise(this.__countBillingCredits(o,i))}async __countBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:a}=o,u={ids:t,name:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/count"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:$d.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/credits/count")}zeroOutGrant(o,i={},t){return R.fromPromise(this.__zeroOutGrant(o,i,t))}async __zeroOutGrant(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/grants/${d.encodePathParam(o)}/zero-out`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:An.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Im.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/grants/{grant_id}/zero-out")}grantBillingCreditsToCompany(o,i){return R.fromPromise(this.__grantBillingCreditsToCompany(o,i))}async __grantBillingCreditsToCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Tn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits/grants/company")}countCompanyGrants(o={},i){return R.fromPromise(this.__countCompanyGrants(o,i))}async __countCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:a,offset:u}=o,g={company_id:t,order:s!=null?li.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?je.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company/count"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Xd.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/billing/credits/grants/company/count")}listCompanyGrants(o={},i){return R.fromPromise(this.__listCompanyGrants(o,i))}async __listCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:a,offset:u}=o,g={company_id:t,order:s!=null?li.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?je.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company/list"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Sm.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/billing/credits/grants/company/list")}countBillingCreditsGrants(o={},i){return R.fromPromise(this.__countBillingCreditsGrants(o,i))}async __countBillingCreditsGrants(o={},i){let{creditId:t,ids:s,limit:r,offset:a}=o,u={credit_id:t,ids:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/count"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Hd.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/credits/grants/count")}listGrantsForCredit(o={},i){return R.fromPromise(this.__listGrantsForCredit(o,i))}async __listGrantsForCredit(o={},i){let{creditId:t,ids:s,limit:r,offset:a}=o,u={credit_id:t,ids:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/list"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:jm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/billing/credits/grants/list")}acquireCreditLease(o,i){return R.fromPromise(this.__acquireCreditLease(o,i))}async __acquireCreditLease(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/lease"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Un.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits/lease")}extendCreditLease(o,i,t){return R.fromPromise(this.__extendCreditLease(o,i,t))}async __extendCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/lease/${d.encodePathParam(o)}/extend`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:kn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:lm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/extend")}releaseCreditLease(o,i,t){return R.fromPromise(this.__releaseCreditLease(o,i,t))}async __releaseCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/lease/${d.encodePathParam(o)}/release`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Dw.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Am.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/release")}listBillingPlanCreditGrants(o={},i){return R.fromPromise(this.__listBillingPlanCreditGrants(o,i))}async __listBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:a,planVersionId:u,planVersionIds:g,limit:h,offset:l}=o,y={credit_id:t,ids:s,plan_id:r,plan_ids:a,plan_version_id:u,plan_version_ids:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants"),method:"GET",headers:U,queryString:d.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:bm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/billing/credits/plan-grants")}createBillingPlanCreditGrant(o,i){return R.fromPromise(this.__createBillingPlanCreditGrant(o,i))}async __createBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ot.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:tm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/billing/credits/plan-grants")}getSingleBillingPlanCreditGrant(o,i){return R.fromPromise(this.__getSingleBillingPlanCreditGrant(o,i))}async __getSingleBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:dm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/billing/credits/plan-grants/{plan_grant_id}")}updateBillingPlanCreditGrant(o,i,t){return R.fromPromise(this.__updateBillingPlanCreditGrant(o,i,t))}async __updateBillingPlanCreditGrant(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Bt.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Dm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/billing/credits/plan-grants/{plan_grant_id}")}deleteBillingPlanCreditGrant(o,i={},t){return R.fromPromise(this.__deleteBillingPlanCreditGrant(o,i,t))}async __deleteBillingPlanCreditGrant(o,i={},t){let{applyToExisting:s}=i,r={apply_to_existing:s},a=await this._options.authProvider.getAuthRequest(),u=f(a.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${d.encodePathParam(o)}`),method:"DELETE",headers:u,queryString:d.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:sm.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"DELETE","/billing/credits/plan-grants/{plan_grant_id}")}countBillingPlanCreditGrants(o={},i){return R.fromPromise(this.__countBillingPlanCreditGrants(o,i))}async __countBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:a,planVersionId:u,planVersionIds:g,limit:h,offset:l}=o,y={credit_id:t,ids:s,plan_id:r,plan_ids:a,plan_version_id:u,plan_version_ids:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants/count"),method:"GET",headers:U,queryString:d.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Yd.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/billing/credits/plan-grants/count")}listCreditEventLedger(o,i){return R.fromPromise(this.__listCreditEventLedger(o,i))}async __listCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:a,featureId:u,startTime:g,limit:h,offset:l}=o,y={billing_credit_id:t,company_id:s,end_time:r,event_type:a!=null?Cr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:u,start_time:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"v2/billing/credits/ledger"),method:"GET",headers:U,queryString:d.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:km.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/v2/billing/credits/ledger")}countCreditEventLedger(o,i){return R.fromPromise(this.__countCreditEventLedger(o,i))}async __countCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:a,featureId:u,startTime:g,limit:h,offset:l}=o,y={billing_credit_id:t,company_id:s,end_time:r,event_type:a!=null?Cr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:u,start_time:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"v2/billing/credits/ledger/count"),method:"GET",headers:U,queryString:d.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:im.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/v2/billing/credits/ledger/count")}};var pa=class{constructor(o){this._options=K(o)}listDataExports(o={},i){return R.fromPromise(this.__listDataExports(o,i))}async __listDataExports(o={},i){let{exportType:t,status:s,limit:r,offset:a}=o,u={export_type:t!=null?Zr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,status:s!=null?Ki.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"data-exports"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Hm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/data-exports")}createDataExport(o,i){return R.fromPromise(this.__createDataExport(o,i))}async __createDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"data-exports"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Vn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Lm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/data-exports")}getDataExport(o,i){return R.fromPromise(this.__getDataExport(o,i))}async __getDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`data-exports/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}")}getDataExportArtifact(o,i){return R.fromPromise(this.__getDataExportArtifact(o,i))}async __getDataExportArtifact(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`data-exports/${d.encodePathParam(o)}/artifact`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),responseType:"streaming",timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:r.body,rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}/artifact")}};var ua=class{constructor(o){this._options=K(o)}listCompanyOverrides(o={},i){return R.fromPromise(this.__listCompanyOverrides(o,i))}async __listCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:a,ids:u,withoutExpired:g,q:h,limit:l,offset:y}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:a,ids:u,without_expired:g,q:h,limit:l,offset:y},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"GET",headers:T,queryString:d.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:fh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return C(O.error,O.rawResponse,"GET","/company-overrides")}createCompanyOverride(o,i){return R.fromPromise(this.__createCompanyOverride(o,i))}async __createCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Dn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:oh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/company-overrides")}getCompanyOverride(o,i){return R.fromPromise(this.__getCompanyOverride(o,i))}async __getCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:uh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/company-overrides/{company_override_id}")}updateCompanyOverride(o,i,t){return R.fromPromise(this.__updateCompanyOverride(o,i,t))}async __updateCompanyOverride(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Fn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Bh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/company-overrides/{company_override_id}")}deleteCompanyOverride(o,i){return R.fromPromise(this.__deleteCompanyOverride(o,i))}async __deleteCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ah.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/company-overrides/{company_override_id}")}countCompanyOverrides(o={},i){return R.fromPromise(this.__countCompanyOverrides(o,i))}async __countCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:a,ids:u,withoutExpired:g,q:h,limit:l,offset:y}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:a,ids:u,without_expired:g,q:h,limit:l,offset:y},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides/count"),method:"GET",headers:T,queryString:d.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:$m.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return C(O.error,O.rawResponse,"GET","/company-overrides/count")}listFeatureCompanies(o,i){return R.fromPromise(this.__listFeatureCompanies(o,i))}async __listFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,u={feature_id:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-companies"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:xh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/feature-companies")}countFeatureCompanies(o,i){return R.fromPromise(this.__countFeatureCompanies(o,i))}async __countFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,u={feature_id:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-companies/count"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Ym.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/feature-companies/count")}listFeatureUsage(o={},i){return R.fromPromise(this.__listFeatureUsage(o,i))}async __listFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:u,q:g,withoutNegativeEntitlements:h,limit:l,offset:y}=o,w={company_id:t,company_keys:s!=null?ve(s):void 0,feature_ids:r,include_usage_aggregation:a,managed_by:u!=null?k.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,q:g,without_negative_entitlements:h,limit:l,offset:y},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage"),method:"GET",headers:T,queryString:d.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:Ch.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return C(O.error,O.rawResponse,"GET","/feature-usage")}getFeatureUsageTimeSeries(o,i){return R.fromPromise(this.__getFeatureUsageTimeSeries(o,i))}async __getFeatureUsageTimeSeries(o,i){let{companyId:t,endTime:s,featureId:r,granularity:a,startTime:u}=o,g={company_id:t,end_time:s.toISOString(),feature_id:r,granularity:a!=null?Qe.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,start_time:u.toISOString()},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage-timeseries"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:bh.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/feature-usage-timeseries")}countFeatureUsage(o={},i){return R.fromPromise(this.__countFeatureUsage(o,i))}async __countFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:u,q:g,withoutNegativeEntitlements:h,limit:l,offset:y}=o,w={company_id:t,company_keys:s!=null?ve(s):void 0,feature_ids:r,include_usage_aggregation:a,managed_by:u!=null?k.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,q:g,without_negative_entitlements:h,limit:l,offset:y},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage/count"),method:"GET",headers:T,queryString:d.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:Xm.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return C(O.error,O.rawResponse,"GET","/feature-usage/count")}listFeatureUsers(o,i){return R.fromPromise(this.__listFeatureUsers(o,i))}async __listFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,u={feature_id:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-users"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Th.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/feature-users")}countFeatureUsers(o,i){return R.fromPromise(this.__countFeatureUsers(o,i))}async __countFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,u={feature_id:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-users/count"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:eh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/feature-users/count")}listPlanEntitlements(o={},i){return R.fromPromise(this.__listPlanEntitlements(o,i))}async __listPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:a,planIds:u,planVersionId:g,planVersionIds:h,q:l,withMeteredProducts:y,limit:w,offset:U}=o,T={feature_id:t,feature_ids:s,ids:r,plan_id:a,plan_ids:u,plan_version_id:g,plan_version_ids:h,q:l,with_metered_products:y,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),A=f(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements"),method:"GET",headers:A,queryString:d.queryBuilder().addMany(T).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(j.ok)return{data:kh.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new v(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new x(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new P(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return C(j.error,j.rawResponse,"GET","/plan-entitlements")}createPlanEntitlement(o,i){return R.fromPromise(this.__createPlanEntitlement(o,i))}async __createPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Mn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:th.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-entitlements")}getPlanEntitlement(o,i){return R.fromPromise(this.__getPlanEntitlement(o,i))}async __getPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/plan-entitlements/{plan_entitlement_id}")}updatePlanEntitlement(o,i,t){return R.fromPromise(this.__updatePlanEntitlement(o,i,t))}async __updatePlanEntitlement(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Kn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:jh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plan-entitlements/{plan_entitlement_id}")}deletePlanEntitlement(o,i){return R.fromPromise(this.__deletePlanEntitlement(o,i))}async __deletePlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:nh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/plan-entitlements/{plan_entitlement_id}")}upsertPlanEntitlementForBillingProduct(o,i){return R.fromPromise(this.__upsertPlanEntitlementForBillingProduct(o,i))}async __upsertPlanEntitlementForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:qn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ah.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-entitlements/billing-linked")}countPlanEntitlements(o={},i){return R.fromPromise(this.__countPlanEntitlements(o,i))}async __countPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:a,planIds:u,planVersionId:g,planVersionIds:h,q:l,withMeteredProducts:y,limit:w,offset:U}=o,T={feature_id:t,feature_ids:s,ids:r,plan_id:a,plan_ids:u,plan_version_id:g,plan_version_ids:h,q:l,with_metered_products:y,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),A=f(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/count"),method:"GET",headers:A,queryString:d.queryBuilder().addMany(T).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(j.ok)return{data:ih.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new v(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new x(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new P(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return C(j.error,j.rawResponse,"GET","/plan-entitlements/count")}duplicatePlanEntitlements(o,i){return R.fromPromise(this.__duplicatePlanEntitlements(o,i))}async __duplicatePlanEntitlements(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/duplicate"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:In.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ph.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-entitlements/duplicate")}getFeatureUsageByCompany(o,i){return R.fromPromise(this.__getFeatureUsageByCompany(o,i))}async __getFeatureUsageByCompany(o,i){let{keys:t}=o,s={keys:ve(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"usage-by-company"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:mh.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/usage-by-company")}};var da=class{constructor(o){this._options=K(o)}createEventBatch(o,i){return R.fromPromise(this.__createEventBatch(o,i))}async __createEventBatch(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"event-batch"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ln.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Kh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/event-batch")}getEventSummaries(o={},i){return R.fromPromise(this.__getEventSummaries(o,i))}async __getEventSummaries(o={},i){let{q:t,eventSubtypes:s,limit:r,offset:a}=o,u={q:t,event_subtypes:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"event-types"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Nh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/event-types")}listEvents(o={},i){return R.fromPromise(this.__listEvents(o,i))}async __listEvents(o={},i){let{companyId:t,eventSubtype:s,eventTypes:r,flagId:a,idempotencyKey:u,userId:g,limit:h,offset:l}=o,y={company_id:t,event_subtype:s,event_types:Array.isArray(r)?r.map(O=>Ur.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"})):r!=null?Ur.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,flag_id:a,idempotency_key:u,user_id:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"events"),method:"GET",headers:U,queryString:d.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Zh.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return C(T.error,T.rawResponse,"GET","/events")}createEvent(o,i){return R.fromPromise(this.__createEvent(o,i))}async __createEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"events"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Rt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Lh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/events")}getEvent(o,i){return R.fromPromise(this.__getEvent(o,i))}async __getEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`events/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/events/{event_id}")}getSegmentIntegrationStatus(o){return R.fromPromise(this.__getSegmentIntegrationStatus(o))}async __getSegmentIntegrationStatus(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"segment-integration"),method:"GET",headers:t,queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Jh.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/segment-integration")}};var ma=class{constructor(o){this._options=K(o)}listFeatures(o={},i){return R.fromPromise(this.__listFeatures(o,i))}async __listFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:a,planVersionId:u,q:g,withoutCompanyOverrideFor:h,withoutPlanEntitlementFor:l,limit:y,offset:w}=o,U={boolean_require_event:t,feature_type:Array.isArray(s)?s.map(j=>se.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"})):s!=null?se.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,ids:r,managed_by:a!=null?k.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,plan_version_id:u,q:g,without_company_override_for:h,without_plan_entitlement_for:l,limit:y,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features"),method:"GET",headers:O,queryString:d.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:bg.parseOrThrow(A.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new v(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new x(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new P(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return C(A.error,A.rawResponse,"GET","/features")}createFeature(o,i){return R.fromPromise(this.__createFeature(o,i))}async __createFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Hn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ug.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/features")}getFeature(o,i){return R.fromPromise(this.__getFeature(o,i))}async __getFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/features/{feature_id}")}updateFeature(o,i={},t){return R.fromPromise(this.__updateFeature(o,i,t))}async __updateFeature(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Nn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:fg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/features/{feature_id}")}deleteFeature(o,i){return R.fromPromise(this.__deleteFeature(o,i))}async __deleteFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:mg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/features/{feature_id}")}upsertFeatureForBillingProduct(o,i){return R.fromPromise(this.__upsertFeatureForBillingProduct(o,i))}async __upsertFeatureForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Wn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Eg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/features/billing-linked")}countFeatures(o={},i){return R.fromPromise(this.__countFeatures(o,i))}async __countFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:a,planVersionId:u,q:g,withoutCompanyOverrideFor:h,withoutPlanEntitlementFor:l,limit:y,offset:w}=o,U={boolean_require_event:t,feature_type:Array.isArray(s)?s.map(j=>se.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"})):s!=null?se.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,ids:r,managed_by:a!=null?k.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,plan_version_id:u,q:g,without_company_override_for:h,without_plan_entitlement_for:l,limit:y,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features/count"),method:"GET",headers:O,queryString:d.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:cg.parseOrThrow(A.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new v(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new x(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new P(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return C(A.error,A.rawResponse,"GET","/features/count")}listFlags(o={},i){return R.fromPromise(this.__listFlags(o,i))}async __listFlags(o={},i){let{featureId:t,ids:s,q:r,limit:a,offset:u}=o,g={feature_id:t,ids:s,q:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Rg.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/flags")}createFlag(o,i){return R.fromPromise(this.__createFlag(o,i))}async __createFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:gs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:dg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/flags")}getFlag(o,i){return R.fromPromise(this.__getFlag(o,i))}async __getFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/flags/{flag_id}")}updateFlag(o,i,t){return R.fromPromise(this.__updateFlag(o,i,t))}async __updateFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:gs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:_g.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/flags/{flag_id}")}deleteFlag(o,i){return R.fromPromise(this.__deleteFlag(o,i))}async __deleteFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/flags/{flag_id}")}updateFlagRules(o,i,t){return R.fromPromise(this.__updateFlagRules(o,i,t))}async __updateFlagRules(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${d.encodePathParam(o)}/rules`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:$n.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:xg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/flags/{flag_id}/rules")}checkFlag(o,i,t){return R.fromPromise(this.__checkFlag(o,i,t))}async __checkFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${d.encodePathParam(o)}/check`),method:"POST",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Ro.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:eg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/flags/{key}/check")}checkFlags(o,i){return R.fromPromise(this.__checkFlags(o,i))}async __checkFlags(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/check"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ro.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ng.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/flags/check")}checkFlagsBulk(o,i){return R.fromPromise(this.__checkFlagsBulk(o,i))}async __checkFlagsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/check-bulk"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Gn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ag.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/flags/check-bulk")}countFlags(o={},i){return R.fromPromise(this.__countFlags(o,i))}async __countFlags(o={},i){let{featureId:t,ids:s,q:r,limit:a,offset:u}=o,g={feature_id:t,ids:s,q:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/count"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:pg.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/flags/count")}};var ha=class{constructor(o){this._options=K(o)}getActivity(o={},i){return R.fromPromise(this.__getActivity(o,i))}async __getActivity(o={},i){let{limit:t}=o,s={limit:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/activity"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:Tg.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/insights/activity")}getEnvironmentFeatureUsageTimeSeries(o,i){return R.fromPromise(this.__getEnvironmentFeatureUsageTimeSeries(o,i))}async __getEnvironmentFeatureUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:a}=o,u={end_time:t.toISOString(),feature_id:s,granularity:r!=null?Qe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:a.toISOString()},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/feature-usage-timeseries"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Bg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/insights/feature-usage-timeseries")}getPlanGrowth(o={},i){return R.fromPromise(this.__getPlanGrowth(o,i))}async __getPlanGrowth(o={},i){let{months:t}=o,s={months:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/plan-growth"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:Ig.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/insights/plan-growth")}getSummary(o){return R.fromPromise(this.__getSummary(o))}async __getSummary(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/summary"),method:"GET",headers:t,queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Lg.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/insights/summary")}getTopFeaturesByUsage(o,i){return R.fromPromise(this.__getTopFeaturesByUsage(o,i))}async __getTopFeaturesByUsage(o,i){let{endTime:t,limit:s,startTime:r}=o,a={end_time:t.toISOString(),limit:s,start_time:r.toISOString()},u=await this._options.authProvider.getAuthRequest(),g=f(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/top-features"),method:"GET",headers:g,queryString:d.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Ng.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/insights/top-features")}getEnvironmentTraitUsageTimeSeries(o,i){return R.fromPromise(this.__getEnvironmentTraitUsageTimeSeries(o,i))}async __getEnvironmentTraitUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:a}=o,u={end_time:t.toISOString(),feature_id:s,granularity:r!=null?Qe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:a.toISOString()},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/trait-usage-timeseries"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Vg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/insights/trait-usage-timeseries")}};var ga=class{constructor(o){this._options=K(o)}runIntegration(o,i){return R.fromPromise(this.__runIntegration(o,i))}async __runIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integration/start/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:py.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/integration/start/{integration_id}")}listIntegrations(o={},i){return R.fromPromise(this.__listIntegrations(o,i))}async __listIntegrations(o={},i){let{billingOnly:t,excludeIds:s,id:r,state:a,type:u,limit:g,offset:h}=o,l={billing_only:t,exclude_ids:s,id:r,state:a!=null?Me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,type:u!=null?Se.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=f(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations"),method:"GET",headers:w,queryString:d.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:sy.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return C(U.error,U.rawResponse,"GET","/integrations")}getIntegrationWebhookUrl(o,i){return R.fromPromise(this.__getIntegrationWebhookUrl(o,i))}async __getIntegrationWebhookUrl(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integrations/${d.encodePathParam(o)}/webhook-url`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:iy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/integrations/{type}/webhook-url")}installIntegration(o,i){return R.fromPromise(this.__installIntegration(o,i))}async __installIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/install"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Yt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:oy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/integrations/install")}startDataImport(o,i){return R.fromPromise(this.__startDataImport(o,i))}async __startDataImport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/start-data-import"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Jn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:uy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/integrations/start-data-import")}loadSampleDataSet(o){return R.fromPromise(this.__loadSampleDataSet(o))}async __loadSampleDataSet(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/dataset-sample-v2"),method:"GET",headers:t,queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:ly.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return C(s.error,s.rawResponse,"GET","/integrations/stripe/dataset-sample-v2")}assumeStripeInstalled(o,i){return R.fromPromise(this.__assumeStripeInstalled(o,i))}async __assumeStripeInstalled(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/v2/assume-installed"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Yt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ey.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/integrations/stripe/v2/assume-installed")}installStripe(o,i){return R.fromPromise(this.__installStripe(o,i))}async __installStripe(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/v2/install"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Yt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ty.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/integrations/stripe/v2/install")}uninstallIntegration(o,i){return R.fromPromise(this.__uninstallIntegration(o,i))}async __uninstallIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integrations/uninstall/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:dy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/integrations/uninstall/{integration_id}")}};var ya=class{constructor(o){this._options=K(o)}createCustomPlanBundle(o,i){return R.fromPromise(this.__createCustomPlanBundle(o,i))}async __createCustomPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Yn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/custom-plan-bundles")}createPlanBundle(o,i){return R.fromPromise(this.__createPlanBundle(o,i))}async __createPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Zn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:by.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-bundles")}updatePlanBundle(o,i,t){return R.fromPromise(this.__updatePlanBundle(o,i,t))}async __updatePlanBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-bundles/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:zy.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plan-bundles/{plan_bundle_id}")}};var wa=class{constructor(o){this._options=K(o)}getPlanGroup(o={},i){return R.fromPromise(this.__getPlanGroup(o,i))}async __getPlanGroup(o={},i){let{includeCompanyCounts:t}=o,s={include_company_counts:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-groups"),method:"GET",headers:a,queryString:d.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(u.ok)return{data:Cy.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 401:throw new x(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return C(u.error,u.rawResponse,"GET","/plan-groups")}createPlanGroup(o,i){return R.fromPromise(this.__createPlanGroup(o,i))}async __createPlanGroup(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-groups"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_y.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-groups")}updatePlanGroup(o,i,t){return R.fromPromise(this.__updatePlanGroup(o,i,t))}async __updatePlanGroup(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-groups/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:es.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Uy.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plan-groups/{plan_group_id}")}};var ba=class{constructor(o){this._options=K(o)}listCompanyMigrations(o={},i){return R.fromPromise(this.__listCompanyMigrations(o,i))}async __listCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:a,offset:u}=o,g={migration_id:t,q:s,status:r!=null?Tr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-company-migrations"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Vy.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/plan-version-company-migrations")}retryCompanyMigration(o,i){return R.fromPromise(this.__retryCompanyMigration(o,i))}async __retryCompanyMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-company-migrations/${d.encodePathParam(o)}/retry`),method:"POST",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:My.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-version-company-migrations/{plan_version_company_migration_id}/retry")}countCompanyMigrations(o={},i){return R.fromPromise(this.__countCompanyMigrations(o,i))}async __countCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:a,offset:u}=o,g={migration_id:t,q:s,status:r!=null?Tr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-company-migrations/count"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Ty.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/plan-version-company-migrations/count")}listMigrations(o={},i){return R.fromPromise(this.__listMigrations(o,i))}async __listMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:a}=o,u={plan_version_id:t,status:s!=null?Or.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Dy.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/plan-version-migrations")}createMigration(o,i){return R.fromPromise(this.__createMigration(o,i))}async __createMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:is.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:By.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plan-version-migrations")}getMigration(o,i){return R.fromPromise(this.__getMigration(o,i))}async __getMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-migrations/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:jy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/plan-version-migrations/{plan_version_migration_id}")}retryMigration(o,i,t){return R.fromPromise(this.__retryMigration(o,i,t))}async __retryMigration(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-migrations/${d.encodePathParam(o)}/retry`),method:"POST",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:os.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Iy.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/plan-version-migrations/{plan_version_migration_id}/retry")}countMigrations(o={},i){return R.fromPromise(this.__countMigrations(o,i))}async __countMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:a}=o,u={plan_version_id:t,status:s!=null?Or.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations/count"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ky.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/plan-version-migrations/count")}};var za=class{constructor(o){this._options=K(o)}updateCompanyPlans(o,i,t){return R.fromPromise(this.__updateCompanyPlans(o,i,t))}async __updateCompanyPlans(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-plans/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:cs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:lw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/company-plans/{company_plan_id}")}listCustomPlanBillings(o={},i){return R.fromPromise(this.__listCustomPlanBillings(o,i))}async __listCustomPlanBillings(o={},i){let{companyId:t,planId:s,status:r,statuses:a,limit:u,offset:g}=o,h={company_id:t,plan_id:s,status:r!=null?Pr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,statuses:Array.isArray(a)?a.map(U=>Pr.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"})):a!=null?Pr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:u,offset:g},l=await this._options.authProvider.getAuthRequest(),y=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plan-billings"),method:"GET",headers:y,queryString:d.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:rw.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return C(w.error,w.rawResponse,"GET","/custom-plan-billings")}markCustomPlanBillingPaid(o,i,t){return R.fromPromise(this.__markCustomPlanBillingPaid(o,i,t))}async __markCustomPlanBillingPaid(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`custom-plan-billings/${d.encodePathParam(o)}/mark-paid`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:qw.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:nw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/mark-paid")}retryCustomPlanBilling(o,i,t){return R.fromPromise(this.__retryCustomPlanBilling(o,i,t))}async __retryCustomPlanBilling(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`custom-plan-billings/${d.encodePathParam(o)}/retry`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ss.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:cw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/retry")}createCustomPlan(o,i){return R.fromPromise(this.__createCustomPlan(o,i))}async __createCustomPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plans"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:as.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/custom-plans")}listPlans(o={},i){return R.fromPromise(this.__listPlans(o,i))}async __listPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:u,forTrialExpiryPlan:g,hasProductId:h,ids:l,includeDraftVersions:y,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:A,withoutPaidProductId:j,limit:D,offset:V}=o,re={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:a,for_initial_plan:u,for_trial_expiry_plan:g,has_product_id:h,ids:l,include_draft_versions:y,plan_type:w!=null?te.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:A,without_paid_product_id:j,limit:D,offset:V},ue=await this._options.authProvider.getAuthRequest(),Ue=f(ue.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans"),method:"GET",headers:Ue,queryString:d.queryBuilder().addMany(re).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:aw.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return C(B.error,B.rawResponse,"GET","/plans")}createPlan(o,i){return R.fromPromise(this.__createPlan(o,i))}async __createPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:jt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plans")}getPlan(o,i={},t){return R.fromPromise(this.__getPlan(o,i,t))}async __getPlan(o,i={},t){let{planVersionId:s}=i,r={plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),u=f(a.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${d.encodePathParam(o)}`),method:"GET",headers:u,queryString:d.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Zy.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/plans/{plan_id}")}updatePlan(o,i,t){return R.fromPromise(this.__updatePlan(o,i,t))}async __updatePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:At.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:pw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plans/{plan_id}")}deletePlan(o,i){return R.fromPromise(this.__deletePlan(o,i))}async __deletePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ny.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/plans/{plan_id}")}upsertBillingProductPlan(o,i,t){return R.fromPromise(this.__upsertBillingProductPlan(o,i,t))}async __upsertBillingProductPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${d.encodePathParam(o)}/billing_products`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Qr.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:uw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plans/{plan_id}/billing_products")}upsertPlanForBillingProduct(o,i){return R.fromPromise(this.__upsertPlanForBillingProduct(o,i))}async __upsertPlanForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ts.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:dw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/plans/billing-linked")}listBillingProductMatchCompanies(o,i){return R.fromPromise(this.__listBillingProductMatchCompanies(o,i))}async __listBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:a}=o,u={plan_id:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-product-match-companies"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Qy.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/plans/billing-product-match-companies")}countBillingProductMatchCompanies(o,i){return R.fromPromise(this.__countBillingProductMatchCompanies(o,i))}async __countBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:a}=o,u={plan_id:t,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-product-match-companies/count"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Ky.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/plans/billing-product-match-companies/count")}countPlans(o={},i){return R.fromPromise(this.__countPlans(o,i))}async __countPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:u,forTrialExpiryPlan:g,hasProductId:h,ids:l,includeDraftVersions:y,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:A,withoutPaidProductId:j,limit:D,offset:V}=o,re={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:a,for_initial_plan:u,for_trial_expiry_plan:g,has_product_id:h,ids:l,include_draft_versions:y,plan_type:w!=null?te.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:A,without_paid_product_id:j,limit:D,offset:V},ue=await this._options.authProvider.getAuthRequest(),Ue=f(ue.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/count"),method:"GET",headers:Ue,queryString:d.queryBuilder().addMany(re).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Gy.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return C(B.error,B.rawResponse,"GET","/plans/count")}listPlanIssues(o,i){return R.fromPromise(this.__listPlanIssues(o,i))}async __listPlanIssues(o,i){let{planId:t,planVersionId:s}=o,r={plan_id:t,plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),u=f(a.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/issues"),method:"GET",headers:u,queryString:d.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:ow.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"GET","/plans/issues")}deletePlanVersion(o,i={},t){return R.fromPromise(this.__deletePlanVersion(o,i,t))}async __deletePlanVersion(o,i={},t){let{promoteArchivedVersion:s}=i,r={promote_archived_version:s},a=await this._options.authProvider.getAuthRequest(),u=f(a.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/version/${d.encodePathParam(o)}`),method:"DELETE",headers:u,queryString:d.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Jy.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return C(g.error,g.rawResponse,"DELETE","/plans/version/{plan_id}")}publishPlanVersion(o,i,t){return R.fromPromise(this.__publishPlanVersion(o,i,t))}async __publishPlanVersion(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/version/${d.encodePathParam(o)}/publish`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ns.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:sw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/plans/version/{plan_id}/publish")}};var Ra=class{constructor(o){this._options=K(o)}listScheduledCheckouts(o={},i){return R.fromPromise(this.__listScheduledCheckouts(o,i))}async __listScheduledCheckouts(o={},i){let{companyId:t,status:s,limit:r,offset:a}=o,u={company_id:t,status:s!=null?ri.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"scheduled-checkout"),method:"GET",headers:h,queryString:d.queryBuilder().addMany(u).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:yw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return C(l.error,l.rawResponse,"GET","/scheduled-checkout")}createScheduledCheckout(o,i){return R.fromPromise(this.__createScheduledCheckout(o,i))}async __createScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"scheduled-checkout"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ls.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:mw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/scheduled-checkout")}getScheduledCheckout(o,i){return R.fromPromise(this.__getScheduledCheckout(o,i))}async __getScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`scheduled-checkout/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/scheduled-checkout/{scheduled_checkout_id}")}updateScheduledCheckout(o,i={},t){return R.fromPromise(this.__updateScheduledCheckout(o,i,t))}async __updateScheduledCheckout(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`scheduled-checkout/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ps.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ww.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/scheduled-checkout/{scheduled_checkout_id}")}};var fa=class{constructor(o){this._options=K(o)}listWebhookEvents(o={},i){return R.fromPromise(this.__listWebhookEvents(o,i))}async __listWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:a,offset:u}=o,g={ids:t,q:s,webhook_id:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhook-events"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Uw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/webhook-events")}getWebhookEvent(o,i){return R.fromPromise(this.__getWebhookEvent(o,i))}async __getWebhookEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhook-events/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/webhook-events/{webhook_event_id}")}countWebhookEvents(o={},i){return R.fromPromise(this.__countWebhookEvents(o,i))}async __countWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:a,offset:u}=o,g={ids:t,q:s,webhook_id:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),l=f(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhook-events/count"),method:"GET",headers:l,queryString:d.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:zw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return C(y.error,y.rawResponse,"GET","/webhook-events/count")}listWebhooks(o={},i){return R.fromPromise(this.__listWebhooks(o,i))}async __listWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},u=await this._options.authProvider.getAuthRequest(),g=f(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks"),method:"GET",headers:g,queryString:d.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Tw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/webhooks")}createWebhook(o,i){return R.fromPromise(this.__createWebhook(o,i))}async __createWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks"),method:"POST",headers:s,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:us.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_w.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"POST","/webhooks")}getWebhook(o,i){return R.fromPromise(this.__getWebhook(o,i))}async __getWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${d.encodePathParam(o)}`),method:"GET",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ew.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"GET","/webhooks/{webhook_id}")}updateWebhook(o,i={},t){return R.fromPromise(this.__updateWebhook(o,i,t))}async __updateWebhook(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${d.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ms.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Bw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"PUT","/webhooks/{webhook_id}")}deleteWebhook(o,i){return R.fromPromise(this.__deleteWebhook(o,i))}async __deleteWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${d.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:d.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return C(r.error,r.rawResponse,"DELETE","/webhooks/{webhook_id}")}sendTestWebhookAction(o,i,t){return R.fromPromise(this.__sendTestWebhookAction(o,i,t))}async __sendTestWebhookAction(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${d.encodePathParam(o)}/test`),method:"POST",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ds.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:kw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return C(a.error,a.rawResponse,"POST","/webhooks/{webhook_id}/test")}countWebhooks(o={},i){return R.fromPromise(this.__countWebhooks(o,i))}async __countWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},u=await this._options.authProvider.getAuthRequest(),g=f(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks/count"),method:"GET",headers:g,queryString:d.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:fw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return C(h.error,h.rawResponse,"GET","/webhooks/count")}};var _a=class{constructor(o){this._options=K(o)}get accounts(){return this._accounts??=new ia(this._options)}get billing(){return this._billing??=new oa(this._options)}get credits(){return this._credits??=new la(this._options)}get catalogs(){return this._catalogs??=new ta(this._options)}get checkout(){return this._checkout??=new aa(this._options)}get companies(){return this._companies??=new na(this._options)}get entitlements(){return this._entitlements??=new ua(this._options)}get plans(){return this._plans??=new za(this._options)}get components(){return this._components??=new sa(this._options)}get planbundle(){return this._planbundle??=new ya(this._options)}get dataexports(){return this._dataexports??=new pa(this._options)}get events(){return this._events??=new da(this._options)}get features(){return this._features??=new ma(this._options)}get insights(){return this._insights??=new ha(this._options)}get integrationsapi(){return this._integrationsapi??=new ga(this._options)}get plangroups(){return this._plangroups??=new wa(this._options)}get planmigrations(){return this._planmigrations??=new ba(this._options)}get componentspublic(){return this._componentspublic??=new ca(this._options)}get scheduledcheckout(){return this._scheduledcheckout??=new Ra(this._options)}get accesstokens(){return this._accesstokens??=new ra(this._options)}get webhooks(){return this._webhooks??=new fa(this._options)}getCreditLedger(o){return R.fromPromise(this.__getCreditLedger(o))}async __getCreditLedger(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/ledger"),method:"GET",headers:t,queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:void 0,rawResponse:s.rawResponse};if(s.error.reason==="status-code")throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse});return C(s.error,s.rawResponse,"GET","/billing/credits/ledger")}async fetch(o,i,t){return Ia(o,i,{baseUrl:this._options.baseUrl??this._options.environment,headers:this._options.headers,timeoutInSeconds:this._options.timeoutInSeconds,maxRetries:this._options.maxRetries,fetch:this._options.fetch,logging:this._options.logging,getAuthHeaders:async()=>(await this._options.authProvider.getAuthRequest()).headers},t)}};var er={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},_s={[er.Debug]:1,[er.Info]:2,[er.Warn]:3,[er.Error]:4},Jw=er.Warn,oi=class{constructor(o=Jw){this.level=_s[o]??_s[Jw]}shouldLog(o){return _s[o]>=this.level}error(o,...i){this.shouldLog(er.Error)&&console.error(o,...i)}warn(o,...i){this.shouldLog(er.Warn)&&console.warn(o,...i)}info(o,...i){this.shouldLog(er.Info)&&console.info(o,...i)}debug(o,...i){this.shouldLog(er.Debug)&&console.debug(o,...i)}};var VR=1e3,qR=1e3,DR=3,MR=1e3,Sa=class{constructor(o,i){this.events=[];this.intervalId=null;this.shutdown=!1;this.stopped=!1;this.flushing=!1;let{logger:t=new oi,maxSize:s=qR,interval:r=VR,offline:a=!1,maxRetries:u=DR,initialRetryDelay:g=MR}=i||{};this.captureClient=o,this.interval=r,this.logger=t,this.maxSize=s,this.offline=a,this.maxRetries=u,this.initialRetryDelay=g,this.startPeriodicFlush()}async flush(){if(!(this.events.length===0||this.flushing)){this.flushing=!0;try{let o=[...this.events];this.events=[];let i=0,t=!1,s=null;for(;i<=this.maxRetries&&!t;)try{i>0&&this.logger.info(`Retrying event batch submission (attempt ${i} of ${this.maxRetries})`),await this.captureClient.sendBatch(o),t=!0}catch(r){if(s=r,i++,i<=this.maxRetries){let a=this.initialRetryDelay*Math.pow(2,i-1),u=Math.random()*.1*a,g=a+u;this.logger.warn(`Event batch submission failed: ${r}. Retrying in ${(g/1e3).toFixed(2)} seconds...`),process.env.NODE_ENV!=="test"&&await new Promise(h=>setTimeout(h,g))}}t?i>0&&this.logger.info(`Event batch submission succeeded after ${i} retries`):this.logger.error(`Event batch submission failed after ${this.maxRetries} retries:`,s)}finally{this.flushing=!1}}}async push(o){if(!this.offline){if(this.stopped){this.logger.error("Event buffer is stopped, not accepting new events");return}this.events.length>=this.maxSize&&!this.flushing&&await this.flush(),this.events.push(o)}}async stop(){this.shutdown=!0,this.stopped=!0,this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),await this.flush()}startPeriodicFlush(){this.offline||this.intervalId||(this.intervalId=setInterval(async()=>{this.shutdown||await this.flush()},this.interval),this.intervalId.unref&&this.intervalId.unref())}};var IR="https://c.schematichq.com",FR=1e4,KR=p=>p.replace(/\/+$/,"")+"/batch",LR=(p,o)=>{let i={api_key:o,type:p.eventType};return p.body!==void 0&&(i.body=zt.jsonOrThrow(p.body,{unrecognizedObjectKeys:"strip"})),p.idempotencyKey!==void 0&&(i.idempotency_key=p.idempotencyKey),p.sentAt!==void 0&&(i.sent_at=p.sentAt instanceof Date?p.sentAt.toISOString():p.sentAt),p.trustedClientClock!==void 0&&(i.trusted_client_clock=p.trustedClientClock),p.backfill!==void 0&&(i.backfill=p.backfill),i},GR=(p,o)=>({events:p.map(i=>LR(i,o))}),WR=p=>{if(typeof p!="object"||p===null||!("reason"in p))return"unknown error";let o=p;switch(o.reason){case"status-code":{let i=typeof o.body=="string"?o.body:JSON.stringify(o.body??"");return`HTTP ${o.statusCode}: ${i}`}case"timeout":return"request timed out";case"non-json":return`non-JSON response (HTTP ${o.statusCode})`;case"body-is-null":return`empty response body (HTTP ${o.statusCode})`;default:return o.errorMessage??"unknown error"}},Pa=class{constructor(o){this.apiKey=o.apiKey,this.baseUrl=o.baseUrl??IR,this.timeoutMs=o.timeoutMs??FR,this.fetcher=o.fetcher,this.headers=o.headers??{}}async sendBatch(o){if(o.length===0)return;let i=await this.fetcher({url:KR(this.baseUrl),method:"POST",contentType:"application/json",requestType:"json",headers:{...this.headers,"X-Schematic-Api-Key":this.apiKey},body:GR(o,this.apiKey),timeoutMs:this.timeoutMs,maxRetries:0});if(!i.ok)throw new Error(`capture service returned ${WR(i.error)}`)}};function Yw(p){return async function(i){let t={};if(p&&Object.assign(t,p),i.body!==void 0&&i.contentType!=null&&(t["Content-Type"]=i.contentType),i.headers!=null)for(let[u,g]of Object.entries(i.headers))g!=null&&typeof g=="string"&&(t[u]=g);let s=i.queryString!=null&&i.queryString.length>0?`${i.url}?${i.queryString}`:Bo(i.url,i.queryParameters),r=await jo({body:i.body,type:i.requestType==="json"?"json":"other"}),a=await hi();try{let u=await bi(async()=>gi(a,s,i.method,t,r,i.timeoutMs,i.abortSignal,i.withCredentials,i.duplex),i.maxRetries),g=await mi(u,i.responseType),h=uo(u);return u.status>=200&&u.status<400?{ok:!0,body:g,headers:u.headers,rawResponse:h}:{ok:!1,error:{reason:"status-code",statusCode:u.status,body:g},rawResponse:h}}catch(u){return i.abortSignal!=null&&i.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:yi}:u instanceof Error&&u.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:yi}:u instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:u.message},rawResponse:wi}:{ok:!1,error:{reason:"unknown",errorMessage:JSON.stringify(u)},rawResponse:wi}}}}async function HR(p){return{ok:!0,body:{},headers:{"Content-Type":"application/json"},rawResponse:{headers:new ir,redirected:!1,status:200,statusText:"OK",type:"basic",url:""}}}var Zw=HR;var to=class{constructor(){this.wasmInstance=null;this.initialized=!1}async initialize(){if(!this.initialized)try{let o=await import("./wasm/rulesengine.js"),i=o.RulesEngineJS?o:o.default??o;this.wasmInstance=new i.RulesEngineJS,this.initialized=!0}catch(o){throw new Error(`Failed to initialize WASM rules engine: ${o}`)}}async checkFlag(o,i,t){return this.checkFlagWithOptions(o,i,t)}async checkFlagWithOptions(o,i,t,s){this.ensureInitialized();let r=(a,u)=>u===null?void 0:u;try{let a=JSON.stringify(o,r),u=i?JSON.stringify(i,r):void 0,g=t?JSON.stringify(t,r):void 0,h=s?JSON.stringify(NR(s),r):void 0,l=this.wasmInstance.checkFlagWithOptions(a,u,g,h);return JSON.parse(l)}catch(a){throw new Error(`WASM flag check failed: ${a}`)}}getVersionKey(){return this.ensureInitialized(),this.wasmInstance.getVersionKey()}isInitialized(){return this.initialized}ensureInitialized(){if(!this.initialized||!this.wasmInstance)throw new Error("WASM rules engine not initialized. Call initialize() first.")}};function NR(p){let o={};return p.creditCost&&Object.keys(p.creditCost).length>0&&(o.credit_cost=p.creditCost),p.usage!==void 0&&(o.usage=p.usage),p.eventUsage&&(o.event_usage={event_subtype:p.eventUsage.eventSubtype,quantity:p.eventUsage.quantity}),o}Ss();var $R={unrecognizedObjectKeys:"passthrough"};function Xw(p,o){let i=p.parse(o,$R);return i.ok?i.value:o}function xs(p){return JSON.parse(JSON.stringify(p))}function JR(p){return JSON.parse(JSON.stringify(p))}function Qw(p,o){let i=xs(p),t,s=!1;for(let r of Object.keys(o))switch(r){case"id":i.id=o[r];break;case"account_id":i.accountId=o[r];break;case"environment_id":i.environmentId=o[r];break;case"base_plan_id":i.basePlanId=o[r]??null;break;case"billing_product_ids":i.billingProductIds=o[r];break;case"plan_ids":i.planIds=o[r];break;case"plan_version_ids":i.planVersionIds=o[r];break;case"entitlements":{let a=o[r]??[];i.entitlements=a.map(u=>Xw(Zt,u));break}case"rules":i.rules=o[r];break;case"traits":i.traits=o[r];break;case"subscription":i.subscription=o[r];break;case"keys":{let a=i.keys??{},u=o[r];i.keys={...a,...u};break}case"credit_balances":{let a=i.creditBalances??{},u=o[r]??{};i.creditBalances={...a,...u},t=u;break}case"credit_lease_balance":{let a=i.creditBalances??{},u=o[r]??{},g={};for(let[h,l]of Object.entries(u))l&&typeof l.remaining=="number"&&(g[h]=l.remaining);i.creditBalances={...a,...g},t={...t??{},...g};break}case"metrics":{let a=i.metrics??[],u=(o[r]??[]).map(g=>Xw(Xt,g));i.metrics=ZR(a,u),s=!0;break}}return(t||s)&&!("entitlements"in o)&&YR(i,t,s),i}function YR(p,o,i){let t=p.entitlements??[];if(t.length===0)return;let s=new Map;if(i){let r=p.metrics??[];for(let a of r)a&&s.set(xa(Ps(a)),a.value??0)}for(let r of t){let a=r.creditId??r.credit_id;o&&a&&a in o&&(r.creditRemaining=o[a],delete r.credit_remaining);let u=r.eventName??r.event_name;if(s.size>0&&u){let g=(r.metricPeriod??r.metric_period)||"all_time",h=(r.monthReset??r.month_reset)||"first_of_month",l=s.get(xa({eventSubtype:u,period:g,monthReset:h}));l!==void 0&&(r.usage=l)}}}function eb(p,o){let i=JR(p);for(let t of Object.keys(o))switch(t){case"id":i.id=o[t];break;case"account_id":i.accountId=o[t];break;case"environment_id":i.environmentId=o[t];break;case"keys":{let s=i.keys??{},r=o[t];i.keys={...s,...r};break}case"traits":i.traits=o[t];break;case"rules":i.rules=o[t];break}return i}function xa(p){return`${p.eventSubtype}|${p.period}|${p.monthReset}`}function Ps(p){return{eventSubtype:(p.eventSubtype??p.event_subtype)||"",period:p.period||"",monthReset:(p.monthReset??p.month_reset)||""}}function ZR(p,o){let i=[...p],t=new Map;for(let s=0;s<i.length;s++){let r=i[s];if(r){let a=xa(Ps(r));t.set(a,s)}}for(let s of o){if(!s)continue;let r=xa(Ps(s)),a=t.get(r);a!==void 0?i[a]=s:i.push(s)}return i}var gr="company",yr="user",nf="flags",Cs=30*1e3,sf=1440*60*1e3,cf=720*60*60*1e3,_o=class extends ao{constructor(i){super();this.replicatorReady=!1;this.pendingCompanyRequests=new Map;this.pendingUserRequests=new Map;if(this.apiKey=i.apiKey,this.baseURL=i.baseURL??z.Default,this.logger=i.logger,this.cacheTTL=i.cacheTTL??sf,this.companyCacheProvider=this.createCacheProvider(i,"company"),this.userCacheProvider=this.createCacheProvider(i,"user"),this.flagsCacheProvider=this.createCacheProvider(i,"flag"),this.companyKeyCacheProvider=this.createKeyCacheProvider(i),this.userKeyCacheProvider=this.createKeyCacheProvider(i),this.replicatorMode=i.replicatorMode??!1,this.replicatorHealthURL=i.replicatorHealthURL,this.replicatorHealthCheck=i.replicatorHealthCheck??30*1e3,this.replicatorMode&&!i.redisClient&&!i.companyCache&&!i.userCache&&!i.flagCache)throw new Error("Replicator mode requires a Redis client or custom cache providers for shared cache access");this.rulesEngine=new to}createCacheProvider(i,t){let s;switch(t){case"company":s=i.companyCache;break;case"user":s=i.userCache;break;case"flag":s=i.flagCache;break}if(s)return this.logger.debug(`Using custom cache provider for ${t} cache`),s;let r=this.calculateCacheTTL(t);return i.redisClient?(this.logger.debug(`Using Redis cache provider for ${t} cache (TTL: ${r}ms)`),new ni({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:r})):(this.logger.debug(`Using memory cache provider for ${t} cache (TTL: ${r}ms)`),new rr({ttl:r}))}createKeyCacheProvider(i){let t=this.cacheTTL;return i.redisClient?new ni({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:t}):new rr({ttl:t})}calculateCacheTTL(i){return i==="flag"?Math.max(cf,this.cacheTTL):this.cacheTTL}async start(){try{await this.rulesEngine.initialize(),this.logger.debug("Rules engine initialized successfully")}catch(t){this.logger.warn(`Failed to initialize rules engine: ${t}`)}if(this.replicatorMode){this.logger.info("Replicator mode enabled - skipping WebSocket connection"),this.replicatorHealthURL&&this.startReplicatorHealthCheck();return}this.logger.info("Starting DataStream client");let{DatastreamWSClient:i}=(lb(),As(cb));this.wsClient=new i({url:this.baseURL,apiKey:this.apiKey,logger:this.logger,messageHandler:this.handleMessage.bind(this),connectionReadyHandler:this.handleConnectionReady.bind(this)}),this.wsClient.on("connected",()=>{this.emit("connected")}),this.wsClient.on("disconnected",()=>{this.emit("disconnected"),this.clearPendingRequests()}),this.wsClient.on("ready",()=>{this.emit("ready")}),this.wsClient.on("not-ready",()=>{this.emit("not-ready")}),this.wsClient.on("error",t=>{this.emit("error",t)}),this.wsClient.start()}isConnected(){return this.replicatorMode?this.isReplicatorReady():this.wsClient?.isConnected()??!1}async getCompany(i){let t=await this.getCompanyFromCache(i);if(t)return this.logger.debug(`Company found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("Company not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForCompany(i),r=!1;for(let a of s)if(this.pendingCompanyRequests.has(a)){r=!0;break}return new Promise((a,u)=>{let g=setTimeout(()=>{this.cleanupPendingCompanyRequests(s,h),u(new Error("Timeout while waiting for company data"))},Cs),h=l=>{clearTimeout(g),l?a(l):u(new Error("Company not found"))};for(let l of s)this.pendingCompanyRequests.has(l)||this.pendingCompanyRequests.set(l,[]),this.pendingCompanyRequests.get(l).push(h);r||this.sendDataStreamRequest({entity_type:"rulesengine.Company",keys:i}).catch(l=>{this.cleanupPendingCompanyRequests(s,h),u(l)})})}async getUser(i){let t=await this.getUserFromCache(i);if(t)return this.logger.debug(`User found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("User not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForUser(i),r=!1;for(let a of s)if(this.pendingUserRequests.has(a)){r=!0;break}return new Promise((a,u)=>{let g=setTimeout(()=>{this.cleanupPendingUserRequests(s,h),u(new Error("Timeout while waiting for user data"))},Cs),h=l=>{clearTimeout(g),l?a(l):u(new Error("User not found"))};for(let l of s)this.pendingUserRequests.has(l)||this.pendingUserRequests.set(l,[]),this.pendingUserRequests.get(l).push(h);r||this.sendDataStreamRequest({entity_type:"rulesengine.User",keys:i}).catch(l=>{this.cleanupPendingUserRequests(s,h),u(l)})})}async getFlag(i){let t=this.flagCacheKey(i);this.logger.debug(`Retrieving flag from cache: ${i} (cache key: ${t})`);try{return await this.flagsCacheProvider.get(t)||null}catch(s){return this.logger.warn(`Failed to retrieve flag from cache: ${s}`),null}}async getAllFlags(){return this.pendingFlagRequest?new Promise((i,t)=>{let s=this.pendingFlagRequest;this.pendingFlagRequest=r=>{s(r),r?i():t(new Error("Failed to refresh flags"))}}):new Promise((i,t)=>{let s=setTimeout(()=>{this.pendingFlagRequest=void 0,t(new Error("Timeout while waiting for flags data"))},Cs);this.pendingFlagRequest=r=>{clearTimeout(s),this.pendingFlagRequest=void 0,r?i():t(new Error("Failed to refresh flags"))},this.sendDataStreamRequest({entity_type:"rulesengine.Flags"}).catch(r=>{clearTimeout(s),this.pendingFlagRequest=void 0,t(r)})})}async checkFlag(i,t,s){let r=await this.getFlag(t);if(!r)throw new Error(`Flag not found: ${t}`);let a=i.company&&Object.keys(i.company).length>0,u=i.user&&Object.keys(i.user).length>0,g=null,h=null;if(a&&(g=await this.getCompanyFromCache(i.company),this.logger.debug(`Company ${g?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.company)}`)),u&&(h=await this.getUserFromCache(i.user),this.logger.debug(`User ${h?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.user)}`)),this.replicatorMode)return this.evaluateFlag(r,g,h,s);if((!a||g)&&(!u||h))return this.logger.debug(`All required resources found in cache for flag ${t} evaluation`),this.evaluateFlag(r,g,h,s);if(!this.isConnected())throw new Error("Datastream not connected and required entities not in cache");let l=a&&!g?this.getCompany(i.company):Promise.resolve(g),y=u&&!h?this.getUser(i.user):Promise.resolve(h),[w,U]=await Promise.all([l,y]);return this.evaluateFlag(r,w,U,s)}async getCachedCompany(i){return this.getCompanyFromCache(i)}async getCachedUser(i){return this.getUserFromCache(i)}getRulesEngine(){return this.rulesEngine}async updateCompanyMetrics(i,t,s){let r=await this.getCompanyFromCache(i);if(!r)return;let a=this.deepCopyCompany(r);if(a.metrics)for(let u of a.metrics)(u.eventSubtype??u.event_subtype)===t&&(u.value=(u.value||0)+s);await this.cacheCompanyForKeys(a)}close(){this.logger.info("Closing DataStream client"),this.replicatorHealthInterval&&(clearInterval(this.replicatorHealthInterval),this.replicatorHealthInterval=void 0),this.clearPendingRequests(),this.wsClient&&(this.wsClient.close(),this.wsClient=void 0),this.logger.info("DataStream client closed")}isReplicatorReady(){return this.replicatorReady}isReplicatorMode(){return this.replicatorMode}getReplicatorCacheVersion(){return this.replicatorCacheVersion}async getReplicatorCacheVersionAsync(i=2e3){if(this.replicatorCacheVersion)return this.replicatorCacheVersion;if(this.replicatorMode&&this.replicatorHealthURL)try{let t=new AbortController,s=setTimeout(()=>t.abort(),i),r=await fetch(this.replicatorHealthURL,{method:"GET",signal:t.signal});if(clearTimeout(s),r.ok){let a=await r.json(),u=a.cache_version||a.cacheVersion;if(u)return this.replicatorCacheVersion=u,u}}catch(t){this.logger.debug(`Failed to fetch replicator cache version: ${t}`)}}async handleMessage(i){this.logger.debug(`Processing datastream message: EntityType=${i.entity_type}, MessageType=${i.message_type}`);try{if(i.message_type==="error"){await this.handleErrorMessage(i);return}switch(i.entity_type){case"rulesengine.Company":case"rulesengine.Companies":await this.handleCompanyMessage(i);break;case"rulesengine.User":case"rulesengine.Users":await this.handleUserMessage(i);break;case"rulesengine.Flags":await this.handleFlagsMessage(i);break;case"rulesengine.Flag":await this.handleFlagMessage(i);break;default:this.logger.warn(`Unknown entity type in datastream message: ${i.entity_type}`)}}catch(t){this.logger.error(`Error processing datastream message: ${t}`),this.emit("error",t)}}async handleCompanyMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial company message missing entity_id");return}let r=this.resourceIdCacheKey(gr,s),a=await this.companyCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial company '${s}', skipping`);return}try{t=Qw(a,i.data)}catch(u){this.logger.error(`Failed to merge partial company: ${u}`);return}}else try{t=Nw.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize company payload: ${s}`);return}if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,a]of Object.entries(t.keys)){let u=this.resourceKeyToCacheKey(gr,r,a);try{await this.companyKeyCacheProvider.delete(u)}catch(g){this.logger.warn(`Failed to delete company key mapping from cache: ${g}`)}}let s=this.resourceIdCacheKey(gr,t.id);try{await this.companyCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete company resource from cache: ${r}`)}return}await this.cacheCompanyForKeys(t),this.notifyPendingCompanyRequests(t.keys||{},t)}}async handleUserMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial user message missing entity_id");return}let r=this.resourceIdCacheKey(yr,s),a=await this.userCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial user '${s}', skipping`);return}try{t=eb(a,i.data)}catch(u){this.logger.error(`Failed to merge partial user: ${u}`);return}}else try{t=$w.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize user payload: ${s}`);return}if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,a]of Object.entries(t.keys)){let u=this.resourceKeyToCacheKey(yr,r,a);try{await this.userKeyCacheProvider.delete(u)}catch(g){this.logger.warn(`Failed to delete user key mapping from cache: ${g}`)}}let s=this.resourceIdCacheKey(yr,t.id);try{await this.userCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete user resource from cache: ${r}`)}return}await this.cacheUserForKeys(t),this.notifyPendingUserRequests(t.keys||{},t)}}async handleFlagsMessage(i){let t=i.data;if(!Array.isArray(t)){this.logger.warn("Expected flags array in bulk flags message");return}let s=[],r=0,a;for(let l of t)try{s.push(bs.parseOrThrow(l,{unrecognizedObjectKeys:"passthrough"}))}catch(y){r++,a===void 0&&(a=y)}r>0&&this.logger.warn(`Failed to deserialize ${r} flag(s) in bulk message: ${String(a)}`);let u=await Promise.allSettled(s.filter(l=>l?.key).map(async l=>{let y=this.flagCacheKey(l.key);return await this.flagsCacheProvider.set(y,l),y})),g=u.filter(l=>l.status==="fulfilled").map(l=>l.value),h=u.filter(l=>l.status==="rejected");if(h.length>0&&this.logger.warn(`Failed to cache ${h.length} flag(s)`),this.flagsCacheProvider.deleteMissing)try{await this.flagsCacheProvider.deleteMissing(g,{scanPattern:"flags:*"})}catch(l){this.logger.warn(`Failed to delete missing flags: ${l}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleFlagMessage(i){let t;try{t=bs.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(r){this.logger.warn(`Failed to deserialize flag payload: ${r}`);return}if(!t?.key)return;let s=this.flagCacheKey(t.key);try{switch(i.message_type){case"delete":await this.flagsCacheProvider.delete(s);break;case"full":await this.flagsCacheProvider.set(s,t);break;default:this.logger.warn(`Unhandled message type for flag: ${i.message_type}`);break}}catch(r){this.logger.warn(`Failed to update flag cache: ${r}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleErrorMessage(i){let t=i.data;if(t?.keys&&t?.entity_type)switch(t.entity_type){case"rulesengine.Company":this.notifyPendingCompanyRequests(t.keys,null);break;case"rulesengine.User":this.notifyPendingUserRequests(t.keys,null);break;default:this.logger.warn(`Received error for unsupported entity type: ${t.entity_type}`)}let s=t?.error||"Unknown datastream error";this.logger.warn(`DataStream error received: ${s}`)}async handleConnectionReady(){this.logger.info("DataStream connection is ready");try{await this.getAllFlags(),this.logger.debug("Requested initial flag data")}catch(i){throw this.logger.error(`Failed to request initial flag data: ${i}`),i}}async sendDataStreamRequest(i){if(!this.wsClient||!this.wsClient.isConnected())throw new Error("DataStream client is not connected");this.logger.debug(`Sending datastream request: EntityType=${i.entity_type}, Keys=${JSON.stringify(i.keys)}`);let t={data:i};await this.wsClient.sendMessage(t)}async getCompanyFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(gr,t,s);try{let a=await this.companyKeyCacheProvider.get(r);if(a){let u=this.resourceIdCacheKey(gr,a),g=await this.companyCacheProvider.get(u);if(g)return g}}catch(a){this.logger.warn(`Failed to retrieve company from cache: ${a}`)}}return null}async getUserFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(yr,t,s);try{let a=await this.userKeyCacheProvider.get(r);if(a){let u=this.resourceIdCacheKey(yr,a),g=await this.userCacheProvider.get(u);if(g)return g}}catch(a){this.logger.warn(`Failed to retrieve user from cache: ${a}`)}}return null}async cacheCompanyForKeys(i){if(!i.keys||Object.keys(i.keys).length===0)throw new Error("No keys provided for company lookup");let t=this.resourceIdCacheKey(gr,i.id),s=await this.companyCacheProvider.get(t);if(s?.keys){for(let[r,a]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==a){let u=this.resourceKeyToCacheKey(gr,r,a);try{await this.companyKeyCacheProvider.delete(u)}catch(g){this.logger.warn(`Failed to delete stale company key mapping '${u}': ${g}`)}}}await this.companyCacheProvider.set(t,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let u=this.resourceKeyToCacheKey(gr,r,a);try{await this.companyKeyCacheProvider.set(u,i.id,this.cacheTTL)}catch(g){this.logger.warn(`Failed to cache company key mapping '${u}': ${g}`)}}}async cacheUserForKeys(i){if(!i.keys||Object.keys(i.keys).length===0)throw new Error("No keys provided for user lookup");let t=this.resourceIdCacheKey(yr,i.id),s=await this.userCacheProvider.get(t);if(s?.keys){for(let[r,a]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==a){let u=this.resourceKeyToCacheKey(yr,r,a);try{await this.userKeyCacheProvider.delete(u)}catch(g){this.logger.warn(`Failed to delete stale user key mapping '${u}': ${g}`)}}}await this.userCacheProvider.set(t,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let u=this.resourceKeyToCacheKey(yr,r,a);try{await this.userKeyCacheProvider.set(u,i.id,this.cacheTTL)}catch(g){this.logger.warn(`Failed to cache user key mapping '${u}': ${g}`)}}}generateCacheKeysForCompany(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(gr,t,s))}generateCacheKeysForUser(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(yr,t,s))}notifyPendingCompanyRequests(i,t){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(gr,s,r),u=this.pendingCompanyRequests.get(a);u&&(this.pendingCompanyRequests.delete(a),u.forEach(g=>{try{g(t)}catch(h){this.logger.error(`Error in company request handler: ${h}`)}}))}}notifyPendingUserRequests(i,t){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(yr,s,r),u=this.pendingUserRequests.get(a);u&&(this.pendingUserRequests.delete(a),u.forEach(g=>{try{g(t)}catch(h){this.logger.error(`Error in user request handler: ${h}`)}}))}}cleanupPendingCompanyRequests(i,t){for(let s of i){let r=this.pendingCompanyRequests.get(s);if(r){let a=r.indexOf(t);a!==-1&&r.splice(a,1),r.length===0&&this.pendingCompanyRequests.delete(s)}}}cleanupPendingUserRequests(i,t){for(let s of i){let r=this.pendingUserRequests.get(s);if(r){let a=r.indexOf(t);a!==-1&&r.splice(a,1),r.length===0&&this.pendingUserRequests.delete(s)}}}clearPendingRequests(){for(let[,i]of this.pendingCompanyRequests)i.forEach(t=>{try{t(null)}catch(s){this.logger.error(`Error clearing company request: ${s}`)}});this.pendingCompanyRequests.clear();for(let[,i]of this.pendingUserRequests)i.forEach(t=>{try{t(null)}catch(s){this.logger.error(`Error clearing user request: ${s}`)}});if(this.pendingUserRequests.clear(),this.pendingFlagRequest){try{this.pendingFlagRequest(!1)}catch(i){this.logger.error(`Error clearing flag request: ${i}`)}this.pendingFlagRequest=void 0}}startReplicatorHealthCheck(){this.replicatorHealthURL&&(this.logger.info(`Starting replicator health check with URL: ${this.replicatorHealthURL}, interval: ${this.replicatorHealthCheck}ms`),this.checkReplicatorHealth(),this.replicatorHealthInterval=setInterval(()=>{this.checkReplicatorHealth()},this.replicatorHealthCheck),this.replicatorHealthInterval.unref())}async checkReplicatorHealth(){if(this.replicatorHealthURL)try{let i=new AbortController,t=setTimeout(()=>i.abort(),5e3),s=await fetch(this.replicatorHealthURL,{method:"GET",signal:i.signal});if(clearTimeout(t),!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let r=await s.json(),a=this.replicatorReady;this.replicatorReady=r.ready??!1;let u=r.cache_version||r.cacheVersion;if(u&&u!==this.replicatorCacheVersion){let g=this.replicatorCacheVersion;this.replicatorCacheVersion=u,this.logger.info(`Cache version changed from ${g||"(null)"} to ${u}`)}this.replicatorReady&&!a?(this.logger.info("External replicator is now ready"),this.emit("replicator-health-changed",!0)):!this.replicatorReady&&a&&(this.logger.info("External replicator is no longer ready"),this.emit("replicator-health-changed",!1))}catch(i){this.replicatorReady&&(this.replicatorReady=!1,this.logger.info("External replicator is no longer ready"),this.emit("replicator-health-changed",!1)),this.logger.debug(`Replicator health check failed: ${i}`)}}flagCacheKey(i){let t=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey(),s=`${nf}:${t}:${i.toLowerCase()}`;return this.logger.debug(`Generated flag cache key - flag: ${i}, mode: ${this.replicatorMode?"replicator":"datastream"}, version: ${t}, cacheKey: ${s}`),s}resourceIdCacheKey(i,t){let s=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${s}:${t}`}resourceKeyToCacheKey(i,t,s){let r=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${r}:${t.toLowerCase()}:${s.toLowerCase()}`}deepCopyCompany(i){return xs(i)}async evaluateFlag(i,t,s,r){let a=i.defaultValue??!1;try{if(this.rulesEngine.isInitialized()){this.logger.debug(`Evaluating flag with rules engine: ${JSON.stringify({flagId:i.id,flagRules:i.rules?.length||0,companyId:t?.id,userId:s?.id})}`);let u=await this.rulesEngine.checkFlagWithOptions(i,t,s,r);return this.logger.debug(`Rules engine evaluation result: ${JSON.stringify(u)}`),{flagKey:i.key,value:u.value??a,reason:u.reason||"RULES_ENGINE_EVALUATION",companyId:t?.id,userId:s?.id,flagId:i.id,ruleId:u.ruleId,ruleType:u.ruleType,entitlement:u.entitlement?{...u.entitlement,metricResetAt:u.entitlement.metricResetAt?new Date(u.entitlement.metricResetAt):void 0}:void 0}}else return this.logger.warn("Rules engine not initialized, using default flag value"),{flagKey:i.key,value:a,reason:"RULES_ENGINE_UNAVAILABLE",companyId:t?.id,userId:s?.id,flagId:i.id}}catch(u){return this.logger.error(`Rules engine evaluation failed: ${u}`),{flagKey:i.key,value:a,reason:"RULES_ENGINE_ERROR",companyId:t?.id,userId:s?.id,flagId:i.id}}}getRulesEngineVersionKey(){try{if(this.rulesEngine.isInitialized())return this.rulesEngine.getVersionKey()}catch(i){this.logger.warn(`Failed to get rules engine version key: ${i}`)}return"1"}};function Ye(p,o){return`${p}:${o}`}var So=class{constructor(){this.leases=new Map;this.locks=new Map}get(o,i){let t=this.leases.get(Ye(o,i));return t?{...t}:void 0}async replace(o){let i=Ye(o.companyId,o.creditTypeId);return this.withLock(i,()=>{let t=this.leases.get(i);return t&&t.expiresAt.getTime()>Date.now()?!1:(this.leases.set(i,{...o,localRemainingCredits:o.grantedAmount}),!0)})}async extend(o,i,t,s,r){let a=Ye(o,i);return this.withLock(a,()=>{let u=this.leases.get(a);if(!u||r!==void 0&&u.leaseId!==r)return;let g=t-u.grantedAmount;g>0&&(u.grantedAmount=t,u.localRemainingCredits+=g),s&&s.getTime()>u.expiresAt.getTime()&&(u.expiresAt=s)})}async drop(o,i){let t=Ye(o,i);return this.withLock(t,()=>{this.leases.delete(t)})}async tryReserve(o,i,t){if(!Number.isFinite(t)||t<0)return null;let s=Ye(o,i);return this.withLock(s,()=>{let r=this.leases.get(s);return!r||r.expiresAt.getTime()<=Date.now()||r.localRemainingCredits<t?null:(r.localRemainingCredits-=t,r.localRemainingCredits)})}async refund(o,i,t,s){if(t<=0)return;let r=Ye(o,i);return this.withLock(r,()=>{let a=this.leases.get(r);a&&(s!==void 0&&a.leaseId!==s||(a.localRemainingCredits=Math.min(a.localRemainingCredits+t,a.grantedAmount)))})}list(){return Array.from(this.leases.values(),o=>({...o}))}async withLock(o,i){let t=this.locks.get(o)??Promise.resolve(),s,r=new Promise(u=>s=u),a=t.then(()=>r);this.locks.set(o,a),await t;try{return await i()}finally{s(),this.locks.get(o)===a&&this.locks.delete(o)}}};var Po=class{constructor(o,i=1e3){this.leaseStore=o;this.sweepIntervalMs=i;this.reservations=new Map;this.sweepInterval=null;this.stopped=!1}add(o){this.reservations.set(o.id,o)}get(o){return this.reservations.get(o)}reservedCredits(o,i){let t=0;for(let s of this.reservations.values())s.companyId===o&&s.creditTypeId===i&&(t+=s.creditsReserved);return t}async consume(o,i){let t=this.reservations.get(o);if(!t)return null;this.reservations.delete(o);let s=Math.max(0,Math.min(i,t.creditsReserved)),r=t.creditsReserved-s;return r>0&&await this.leaseStore.refund(t.companyId,t.creditTypeId,r,t.leaseId),s}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(o=new Date){let i=0;for(let[t,s]of this.reservations)s.expiresAt.getTime()<=o.getTime()&&(this.reservations.delete(t),await this.leaseStore.refund(s.companyId,s.creditTypeId,s.creditsReserved,s.leaseId),i++);return i}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}size(){return this.reservations.size}};var xo=class{constructor(o){this.inflightAcquire=new Map;this.inflightExtend=new Map;this.creditsClient=o.creditsClient,this.leaseStore=o.leaseStore,this.logger=o.logger,this.config=o.config}resolveConfig(o){let i=this.config.overrides?.[o];return{leaseDuration:i?.defaultLeaseDuration??this.config.defaultLeaseDuration??3e5,reservationTTL:i?.defaultReservationTTL??this.config.defaultReservationTTL??6e4,leaseSize:i?.defaultLeaseSize??this.config.defaultLeaseSize??1e4,lowWaterMark:i?.lowWaterMark??this.config.lowWaterMark??.25}}async acquireIfNeeded(o,i,t){let s;try{s=await this.leaseStore.get(o,i)}catch(g){this.logger.error(`Failed to read lease store for ${o}/${i}: ${g}`);return}if(s&&s.expiresAt.getTime()>Date.now())return s;let r=Ye(o,i),a=this.inflightAcquire.get(r);if(a)return a;let u=this.acquire(o,i,t).finally(()=>{this.inflightAcquire.delete(r)});return this.inflightAcquire.set(r,u),u}async acquire(o,i,t){let s=this.resolveConfig(i),r={companyId:o,creditTypeId:i,requestedAmount:s.leaseSize,expiresAt:new Date(Date.now()+s.leaseDuration)};try{let u=(await this.creditsClient.acquireCreditLease(r,t)).data;if(await this.leaseStore.replace({leaseId:u.id,companyId:u.companyId,creditTypeId:u.creditTypeId,grantedAmount:u.grantedAmount,expiresAt:u.expiresAt}))this.logger.debug(`Acquired credit lease ${u.id} for ${o}/${i} (granted=${u.grantedAmount}, expires=${u.expiresAt.toISOString()})`);else{let h=await this.leaseStore.get(o,i);return h&&h.leaseId!==u.id?(this.logger.debug(`Lost acquire race for ${o}/${i}; releasing redundant lease ${u.id}`),this.creditsClient.releaseCreditLease(u.id,{}).catch(l=>this.logger.warn(`Failed to release redundant credit lease ${u.id}: ${l}`))):this.logger.debug(`Lost acquire race for ${o}/${i}; server returned the installed lease ${u.id}, nothing to release`),h}return await this.leaseStore.get(o,i)}catch(a){this.logger.error(`Failed to acquire credit lease for ${o}/${i}: ${a}`);return}}async maybeExtendInBackground(o,i,t,s){let r;try{r=await this.leaseStore.get(o,i)}catch(U){this.logger.warn(`Failed to read lease store for ${o}/${i}: ${U}`);return}if(!r||r.expiresAt.getTime()<=Date.now())return;let a=this.resolveConfig(i),g=r.localRemainingCredits/Math.max(r.grantedAmount,1)<=a.lowWaterMark,h=t!==void 0&&r.localRemainingCredits<t;if(!g&&!h)return r;let l=Ye(o,i),y=this.inflightExtend.get(l);if(y)return y;let w=this.extend(r,a,t,s).finally(()=>{this.inflightExtend.delete(l)});return this.inflightExtend.set(l,w),w}async extend(o,i,t,s){let r=t!==void 0?t-o.localRemainingCredits:0,a={additionalAmount:Math.max(i.leaseSize,r),expiresAt:new Date(Date.now()+i.leaseDuration)};try{let g=(await this.creditsClient.extendCreditLease(o.leaseId,a,s)).data;return await this.leaseStore.extend(o.companyId,o.creditTypeId,g.grantedAmount,g.expiresAt,o.leaseId),this.logger.debug(`Extended credit lease ${o.leaseId} to ${g.grantedAmount} (was ${o.grantedAmount} at last read, expires ${g.expiresAt.toISOString()})`),await this.leaseStore.get(o.companyId,o.creditTypeId)}catch(u){this.logger.warn(`Failed to extend credit lease ${o.leaseId}: ${u}`);return}}async releaseAllLocalLeases(){let o=this.leaseStore.list?.();!o||o.length===0||await Promise.all(o.map(async i=>{if(!(i.expiresAt.getTime()<=Date.now()))try{await this.creditsClient.releaseCreditLease(i.leaseId,{}),await this.leaseStore.drop(i.companyId,i.creditTypeId),this.logger.debug(`Released credit lease ${i.leaseId} on close`)}catch(t){this.logger.warn(`Failed to release credit lease ${i.leaseId} on close (it will expire server-side): ${t}`)}}))}};var pf="schematic:",uf="credit-lease:",pb=6e4,ub=`
|
|
1
|
+
"use strict";var Wb=Object.create;var Bo=Object.defineProperty;var Hb=Object.getOwnPropertyDescriptor;var Nb=Object.getOwnPropertyNames;var $b=Object.getPrototypeOf,Jb=Object.prototype.hasOwnProperty;var di=(p,o)=>()=>(p&&(o=p(p=0)),o);var Yb=(p,o)=>()=>(o||p((o={exports:{}}).exports,o),o.exports),fr=(p,o)=>{for(var i in o)Bo(p,i,{get:o[i],enumerable:!0})},Is=(p,o,i,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of Nb(o))!Jb.call(p,s)&&s!==i&&Bo(p,s,{get:()=>o[s],enumerable:!(t=Hb(o,s))||t.enumerable});return p};var lo=(p,o,i)=>(i=p!=null?Wb($b(p)):{},Is(o||!p||!p.__esModule?Bo(i,"default",{value:p,enumerable:!0}):i,p)),Fs=p=>Is(Bo({},"__esModule",{value:!0}),p);var dc={};fr(dc,{Node18UniversalStreamWrapper:()=>Ma});var Ma,mc=di(()=>{"use strict";Ma=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",async i=>{if(o instanceof p)o._write(i);else if(o instanceof WritableStream){let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}else o.write(i)}),this.on("end",async()=>{o instanceof p?o._end():o instanceof WritableStream?o.getWriter().close():o.end()}),this.on("error",async i=>{o instanceof p?o._error(i):o instanceof WritableStream?o.getWriter().abort(i):o.destroy(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",async i=>{if(o instanceof p)o._write(i);else if(o instanceof WritableStream){let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}else o.write(i)}),this.off("end",async()=>{o instanceof p?o._end():o instanceof WritableStream?o.getWriter().close():o.end()}),this.off("error",async i=>{o instanceof p?o._error(i):o instanceof WritableStream?o.getWriter().abort(i):o.destroy(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var hc={};fr(hc,{UndiciStreamWrapper:()=>Ia});var Ia,gc=di(()=>{"use strict";Ia=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.on("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.on("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.off("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.off("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var yc={};fr(yc,{NodePre18StreamWrapper:()=>Fa});var Fa,wc=di(()=>{"use strict";Fa=class{constructor(o){this.readableStream=o}on(o,i){this.readableStream.on(o,i)}off(o,i){this.readableStream.off(o,i)}pipe(o){return this.readableStream.pipe(o),o}pipeTo(o){return this.pipe(o)}unpipe(o){o?this.readableStream.unpipe(o):this.readableStream.unpipe()}destroy(o){this.readableStream.destroy(o)}pause(){this.readableStream.pause()}resume(){this.readableStream.resume()}get isPaused(){return this.readableStream.isPaused()}async read(){return new Promise((o,i)=>{let t=this.readableStream.read();t?o(t):(this.readableStream.once("readable",()=>{let s=this.readableStream.read();o(s)}),this.readableStream.once("error",i))})}setEncoding(o){this.readableStream.setEncoding(o),this.encoding=o}async text(){let o=[],i=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let s of this.readableStream)o.push(i.encode(s));return new TextDecoder(this.encoding||"utf-8").decode(Buffer.concat(o))}async json(){let o=await this.text();return JSON.parse(o)}[Symbol.asyncIterator](){let i=this.readableStream[Symbol.asyncIterator]();return{async next(){let{value:t,done:s}=await i.next();return{value:t,done:s}},[Symbol.asyncIterator](){return this}}}}});var co,vs=di(()=>{"use strict";co=class{constructor(){this._emitter=null}ensureEmitter(){if(!this._emitter){let{EventEmitter:o}=require("events");this._emitter=new o}return this._emitter}on(o,i){return this.ensureEmitter().on(o,i),this}emit(o,...i){return this._emitter?.emit(o,...i)??!1}removeAllListeners(o){return this._emitter?.removeAllListeners(o),this}}});var Rb=Yb((wne,bf)=>{bf.exports={name:"@schematichq/schematic-typescript-node",version:"1.5.6",private:!1,repository:{type:"git",url:"git+https://github.com/schematichq/schematic-node.git"},main:"./dist/index.js",types:"./dist/index.d.ts",scripts:{format:"biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","format:check":"biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",lint:"biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","lint:fix":"biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",check:"biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none","check:fix":"biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",build:"node build.js",prepack:"",test:"jest --config jest.config.mjs","test:unit":"jest --selectProjects unit","test:wire":"jest --selectProjects wire","build:legacy":"tsc","test:cloudflare":"node scripts/test-cloudflare.mjs"},dependencies:{"form-data":"^4.0.4","formdata-node":"^6.0.3","node-fetch":"^2.7.0","readable-stream":"^4.7.0",ws:"^8.18.1"},devDependencies:{"@types/node-fetch":"^2.6.12","@types/readable-stream":"^4.0.23",webpack:"^5.105.4","ts-loader":"^9.5.4",jest:"^29.7.0","@jest/globals":"^29.7.0","@types/jest":"^29.5.14","ts-jest":"^29.3.4","jest-environment-jsdom":"^29.7.0",msw:"2.11.2","@types/node":"^20.0.0",typescript:"~5.9.3","@biomejs/biome":"2.4.10",esbuild:"^0.25.9",miniflare:"^4.20260421.0",redis:"^4.7.0","@types/ws":"^8.18.1"},browser:{fs:!1,os:!1,path:!1,stream:!1,crypto:!1,timers:!1},packageManager:"yarn@1.22.22",engines:{node:">=18.0.0"},sideEffects:!1,license:"MIT",files:["dist/**/*.js","dist/**/*.d.ts","dist/**/*.wasm","!dist/**/*.js.map","!dist/**/*.test.*","README.md"]}});var fb,_b,Sb,Pb=di(()=>{"use strict";fb=Rb(),_b=fb.name,Sb=fb.version});var Eb={};fr(Eb,{DatastreamWSClient:()=>ks});function Pf(p){let o=new URL(p);switch(o.protocol){case"https:":o.protocol="wss:";break;case"http:":o.protocol="ws:";break;default:throw new Error(`Unsupported scheme: ${o.protocol} (must be http: or https:)`)}if(o.hostname){let i=o.hostname.split(".");i.length>1&&i[0]==="api"&&(i[0]="datastream",o.hostname=i.join("."))}return o.pathname="/datastream",o.toString()}var xb,zf,Cb,Rf,ff,_f,Sf,ks,Ub=di(()=>{"use strict";xb=lo(require("ws"));Pb();vs();zf=10*1e3,Cb=60*1e3,Rf=Cb*9/10,ff=10,_f=1*1e3,Sf=30*1e3;ks=class extends co{constructor(i){super();this.connected=!1;this.ready=!1;this.shouldReconnect=!0;this.reconnectAttempts=0;if(!i.url)throw new Error("URL is required");if(!i.apiKey)throw new Error("ApiKey is required");if(!i.messageHandler)throw new Error("MessageHandler is required");i.url.startsWith("http://")||i.url.startsWith("https://")?this.url=Pf(i.url):this.url=i.url,this.headers={"X-Schematic-Api-Key":i.apiKey,"X-Schematic-Client":_b,"X-Schematic-Client-Version":Sb,"X-Schematic-Datastream-Mode":"datastream"},this.logger=i.logger,this.messageHandler=i.messageHandler,this.connectionReadyHandler=i.connectionReadyHandler,this.maxReconnectAttempts=i.maxReconnectAttempts??ff,this.minReconnectDelay=i.minReconnectDelay??_f,this.maxReconnectDelay=i.maxReconnectDelay??Sf}start(){this.shouldReconnect=!0,this.reconnectAttempts=0,this.connectAndRead()}isConnected(){return this.connected}isReady(){return this.ready&&this.connected}async sendMessage(i){if(!this.isConnected()||!this.ws)throw new Error("WebSocket connection is not available!");return new Promise((t,s)=>{if(!this.ws){s(new Error("WebSocket connection is not available!"));return}let r=setTimeout(()=>{s(new Error("Write timeout"))},zf);try{this.ws.send(JSON.stringify(i),a=>{clearTimeout(r),a?s(a):t()})}catch(a){clearTimeout(r),s(a)}})}close(){this.logger.info("Closing WebSocket connection"),this.shouldReconnect=!1,this.setReady(!1),this.setConnected(!1),this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.ws&&(this.ws.close(),this.ws=void 0)}async connectAndRead(){try{for(;this.shouldReconnect;)try{let i=await this.connect();if(this.reconnectAttempts=0,this.ws=i,this.setConnected(!0),this.setupWebSocketHandlers(i),this.connectionReadyHandler)try{await this.connectionReadyHandler(),this.logger.debug("Connection ready handler completed successfully")}catch(t){this.logger.error(`Connection ready handler failed: ${t}`),this.setConnected(!1),this.setReady(!1),i.close();continue}if(this.setReady(!0),this.logger.debug("WebSocket client is ready"),this.startPingPong(),await new Promise(t=>{let s=()=>{this.logger.info("WebSocket connection closed"),this.cleanup(),t()},r=a=>{this.logger.error(`WebSocket error: ${a.message}`),this.emit("error",a),this.cleanup(),t()};i.on("close",s),i.on("error",r)}),!this.shouldReconnect)break}catch(i){this.reconnectAttempts++,this.setConnected(!1),this.setReady(!1);let t=i instanceof Error?i.message:String(i);if(this.logger.warn(`WebSocket connection failed: ${t}, attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts}`),this.reconnectAttempts>=this.maxReconnectAttempts){this.logger.error("Max reconnection attempts reached"),this.emit("error",new Error("Max reconnection attempts reached"));break}let s=this.calculateBackoffDelay(this.reconnectAttempts);this.logger.debug(`Waiting ${s}ms before reconnecting...`),await new Promise(r=>{this.reconnectTimeout=setTimeout(r,s),this.reconnectTimeout.unref()})}}catch(i){this.emit("error",i)}}connect(){return new Promise((i,t)=>{this.logger.debug(`Connecting to WebSocket: ${this.url}`);let s=new xb.default(this.url,{headers:this.headers,handshakeTimeout:3e4}),r=setTimeout(()=>{s.close(),t(new Error("Connection timeout"))},3e4);s.on("open",()=>{clearTimeout(r),i(s)}),s.on("error",a=>{clearTimeout(r),t(a)})})}setupWebSocketHandlers(i){i.on("message",t=>{this.handleMessage(t)}),i.on("pong",()=>{this.handlePong()}),i.on("close",t=>{this.handleClose(t)}),i.on("error",t=>{this.handleError(t)})}async handleMessage(i){try{let t;Buffer.isBuffer(i)?t=i.toString():Array.isArray(i)?t=Buffer.concat(i).toString():t=String(i);let s;try{s=JSON.parse(t)}catch(r){this.emit("error",new Error(`Failed to parse datastream message: ${r}`));return}try{await this.messageHandler(s)}catch(r){this.emit("error",new Error(`Message handler error: ${r}`))}}catch(t){this.emit("error",t)}}handleClose(i){this.logger.info(`WebSocket connection closed with code ${i}`),this.setConnected(!1),this.setReady(!1),this.cleanup()}handleError(i){this.logger.error(`WebSocket error: ${i.message}`),this.setConnected(!1),this.setReady(!1),this.cleanup()}startPingPong(){this.logger.debug("Starting ping/pong keepalive mechanism"),this.pingInterval=setInterval(()=>{this.sendPing()},Rf),this.pingInterval.unref()}sendPing(){if(this.ws){this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0),this.pongTimeout=setTimeout(()=>{this.logger.warn("Pong timeout - closing connection"),this.setConnected(!1),this.ws&&this.ws.close()},Cb),this.pongTimeout.unref();try{this.ws.ping()}catch(i){this.logger.error(`Failed to send ping: ${i}`),this.setConnected(!1)}}}handlePong(){this.logger.debug("Received pong from server"),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0)}calculateBackoffDelay(i){let t=Math.floor(Math.random()*this.minReconnectDelay),s=Math.pow(2,i-1)*this.minReconnectDelay+t;return Math.min(s,this.maxReconnectDelay+t)}setConnected(i){let t=this.connected;this.connected=i,i||(this.ready=!1),t!==i&&(this.logger.debug(`Connection state changed: ${i}`),i?this.emit("connected"):this.emit("disconnected"))}setReady(i){let t=this.ready;this.ready=i,t!==i&&(this.logger.debug(`Ready state changed: ${i}`),i?this.emit("ready"):this.emit("not-ready"))}cleanup(){this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0),this.pongTimeout&&(clearTimeout(this.pongTimeout),this.pongTimeout=void 0)}}});var Xf={};fr(Xf,{ConsoleLogger:()=>ai,LocalCache:()=>rr,LogLevel:()=>er,RedisCacheProvider:()=>ci,RulesEngineClient:()=>so,Schematic:()=>ee,SchematicClient:()=>ka,SchematicEnvironment:()=>z,SchematicError:()=>b,SchematicTimeoutError:()=>si,WEBHOOK_SIGNATURE_HEADER:()=>Vs,WEBHOOK_TIMESTAMP_HEADER:()=>qs,WebhookSignatureError:()=>br,computeHexSignature:()=>Fb,computeSignature:()=>ja,verifySignature:()=>Ds,verifyWebhookSignature:()=>Kb});module.exports=Fs(Xf);var ee={};fr(ee,{AccountMemberPermission:()=>Xb,AccountMemberRole:()=>Qb,ActorType:()=>ez,ApiKeyScope:()=>rz,BadRequestError:()=>v,BillingCreditAutoTopupAvailability:()=>iz,BillingCreditBundleStatus:()=>oz,BillingCreditBurnStrategy:()=>tz,BillingCreditExpiryType:()=>az,BillingCreditExpiryUnit:()=>nz,BillingCreditGrantReason:()=>sz,BillingCreditGrantZeroedOutReason:()=>cz,BillingCreditLedgerAuthority:()=>lz,BillingCreditRolloverPolicy:()=>pz,BillingPlanCreditGrantResetCadence:()=>uz,BillingPlanCreditGrantResetStart:()=>dz,BillingPlanCreditGrantResetType:()=>mz,BillingPriceScheme:()=>hz,BillingPriceUsageType:()=>gz,BillingProductPriceInterval:()=>yz,BillingProviderType:()=>wz,BillingStrategy:()=>bz,BillingSubscriptionTrialEndSetting:()=>zz,BillingTiersMode:()=>Rz,ChargeType:()=>fz,CompanyMatchingCriteria:()=>_z,CompanyPlanInvalidReason:()=>Sz,ComparableOperator:()=>Pz,ComponentEntityType:()=>xz,ComponentState:()=>Cz,ConditionType:()=>Ez,CreditEventType:()=>Uz,CreditGrantSortOrder:()=>vz,CreditUsageReason:()=>Tz,CustomPlanActivationStrategy:()=>Oz,CustomPlanBillingStatus:()=>kz,DataExportOutputFileType:()=>Bz,DataExportStatus:()=>jz,DataExportType:()=>Az,EntitlementPriceBehavior:()=>Vz,EntitlementType:()=>qz,EntitlementValueType:()=>Dz,EntityType:()=>Mz,EnvironmentType:()=>Iz,EventStatus:()=>Fz,EventType:()=>jo,FeatureLifecyclePhase:()=>Kz,FeatureType:()=>Lz,ForbiddenError:()=>_,IntegrationState:()=>Gz,IntegrationType:()=>Wz,InternalServerError:()=>S,InvoiceStatus:()=>Hz,MetricPeriod:()=>Nz,MetricPeriodMonthReset:()=>$z,MigrationErrorCode:()=>Jz,NotFoundError:()=>P,PlanBundleAction:()=>Yz,PlanChangeAction:()=>Zz,PlanChangeBasePlanAction:()=>Xz,PlanChangeSubscriptionAction:()=>Qz,PlanIcon:()=>eR,PlanPriceCadence:()=>rR,PlanType:()=>iR,PlanVersionCompanyMigrationStatus:()=>oR,PlanVersionMigrationStatus:()=>tR,PlanVersionMigrationStrategy:()=>aR,PlanVersionStatus:()=>nR,ProrationBehavior:()=>sR,RuleType:()=>gR,RulesEngineSchemaVersion:()=>cR,RulesengineConditionType:()=>lR,RulesengineEntitlementValueType:()=>Aa,RulesengineEntityType:()=>pR,RulesengineMetricPeriod:()=>uR,RulesengineMetricPeriodMonthReset:()=>dR,RulesengineRuleType:()=>mR,RulesengineTraitDefinitionComparableType:()=>hR,ScheduledCheckoutStatus:()=>yR,ScheduledDowngradeConfigBehavior:()=>wR,SortDirection:()=>bR,SubscriptionStatus:()=>zR,SubscriptionType:()=>RR,TimeSeriesGranularity:()=>fR,TraitDefinitionComparableType:()=>_R,TraitType:()=>SR,TrialStatus:()=>PR,UnauthorizedError:()=>x,WebhookEventStatus:()=>xR,WebhookRequestType:()=>CR,WebhookStatus:()=>ER,accesstokens:()=>Ks,accounts:()=>Ls,billing:()=>Gs,catalogs:()=>Ws,checkout:()=>Hs,companies:()=>Ns,components:()=>$s,componentspublic:()=>Js,credits:()=>Ys,dataexports:()=>Zs,entitlements:()=>Xs,events:()=>Qs,features:()=>ec,insights:()=>rc,integrationsapi:()=>ic,licenses:()=>oc,planbundle:()=>tc,plangroups:()=>ac,planmigrations:()=>nc,plans:()=>sc,scheduledcheckout:()=>cc,webhooks:()=>lc});var ve=(p,o,i)=>JSON.stringify(p,o,i);function po(p,o){return JSON.parse(p,o)}var b=class extends Error{constructor({message:o,statusCode:i,body:t,rawResponse:s,cause:r}){super(Zb({message:o,statusCode:i,body:t})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.statusCode=i,this.body=t,this.rawResponse=s,r!=null&&(this.cause=r)}};function Zb({message:p,statusCode:o,body:i}){let t=[];return p!=null&&t.push(p),o!=null&&t.push(`Status code: ${o.toString()}`),i!=null&&t.push(`Body: ${ve(i,void 0,2)}`),t.join(`
|
|
2
|
+
`)}var si=class extends Error{constructor(o,i){super(o),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,i?.cause!=null&&(this.cause=i.cause)}};var v=class extends b{constructor(o,i){super({message:"BadRequestError",statusCode:400,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var _=class extends b{constructor(o,i){super({message:"ForbiddenError",statusCode:403,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var S=class extends b{constructor(o,i){super({message:"InternalServerError",statusCode:500,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var P=class extends b{constructor(o,i){super({message:"NotFoundError",statusCode:404,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var x=class extends b{constructor(o,i){super({message:"UnauthorizedError",statusCode:401,body:o,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var Ks={};var Ls={};var Gs={};var Ws={};var Hs={};var Ns={};var $s={};var Js={};var Ys={};var Zs={};var Xs={};var Qs={};var ec={};var rc={};var ic={};var oc={};var tc={};var ac={};var nc={};var sc={};var cc={};var lc={};var Xb={CompaniesEdit:"companies_edit",CompanyUsersEdit:"company_users_edit",ComponentsEdit:"components_edit",CustomPlansEdit:"custom_plans_edit",DataExportsEdit:"data_exports_edit",FeaturesEdit:"features_edit",FlagRulesEdit:"flag_rules_edit",FlagsEdit:"flags_edit",OverridesEdit:"overrides_edit",PlanBillingEdit:"plan_billing_edit",PlanEntitlementsEdit:"plan_entitlements_edit",PlanVersionsEdit:"plan_versions_edit",PlansEdit:"plans_edit",WebhooksEdit:"webhooks_edit",WebhooksRevealSecret:"webhooks_reveal_secret"};var Qb={Admin:"admin",Member:"member"};var ez={ApiKey:"api_key",AppUser:"app_user",StripeApp:"stripe_app",System:"system",TemporaryAccessToken:"temporary_access_token"};var rz={Admin:"admin",Capture:"capture",Read:"read",Write:"write"};var iz={Off:"off",Automatic:"automatic",UserControlled:"user_controlled"};var oz={Active:"active",Inactive:"inactive"};var tz={ExpirationPriority:"expiration_priority",FirstInFirstOut:"first_in_first_out",LastInFirstOut:"last_in_first_out",PlanFirstThenCreditBundlesFirstInFirstOut:"plan_first_then_credit_bundles_first_in_first_out"};var az={Duration:"duration",EndOfBillingPeriod:"end_of_billing_period",EndOfNextBillingPeriod:"end_of_next_billing_period",EndOfTrial:"end_of_trial",NoExpiry:"no_expiry"};var nz={BillingPeriods:"billing_periods",Days:"days"};var sz={Adjustment:"adjustment",BillingCreditAutoTopup:"billing_credit_auto_topup",Free:"free",Plan:"plan",Purchased:"purchased",Rollover:"rollover"};var cz={CustomerArchived:"customer_archived",Expired:"expired",IntegrationUninstalled:"integration_uninstalled",LicenseRetired:"license_retired",Manual:"manual",PlanChange:"plan_change",PlanPeriodReset:"plan_period_reset",Reconciled:"reconciled"};var lz={SchematicAuthoritative:"schematic_authoritative",ExternalMirror:"external_mirror",ExternalRated:"external_rated"};var pz={Expire:"expire",None:"none",Rollover:"rollover"};var uz={Daily:"daily",Every6Months:"every_6_months",Monthly:"monthly",Quarterly:"quarterly",Weekly:"weekly",Yearly:"yearly"};var dz={BillingPeriod:"billing_period",FirstOfMonth:"first_of_month"};var mz={NoReset:"no_reset",PlanPeriod:"plan_period"};var hz={PerUnit:"per_unit",Tiered:"tiered"};var gz={Licensed:"licensed",Metered:"metered"};var yz={Day:"day",Month:"month",OneTime:"one-time",Year:"year"};var wz={Metronome:"metronome",Orb:"orb",Schematic:"schematic",Stripe:"stripe"};var bz={SchematicManaged:"schematic_managed",ProviderManaged:"provider_managed",NoBilling:"no_billing"};var zz={Cancel:"cancel",Subscribe:"subscribe"};var Rz={Graduated:"graduated",Volume:"volume"};var fz={Free:"free",None:"none",OneTime:"one_time",Recurring:"recurring"};var _z={BillingMetaObject:"billing_meta_object",ManualUpsert:"manual_upsert"};var Sz={DowngradeNotPermitted:"downgrade_not_permitted",FeatureUsageExceeded:"feature_usage_exceeded"};var Pz={Eq:"eq",Gt:"gt",Gte:"gte",IsEmpty:"is_empty",Lt:"lt",Lte:"lte",NotEmpty:"not_empty",Ne:"ne"};var xz={Billing:"billing",Entitlement:"entitlement"};var Cz={Draft:"draft",Live:"live"};var Ez={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Uz={Grant:"grant",Transfer:"transfer",Usage:"usage",ZeroOut:"zero_out"};var vz={CreatedAt:"created_at",ExpiresAt:"expires_at",Quantity:"quantity",QuantityRemaining:"quantity_remaining"};var Tz={LeaseHold:"lease_hold",LeaseRelease:"lease_release",ManualAdjustment:"manual_adjustment",Reconciliation:"reconciliation",Track:"track"};var Oz={OnPayment:"on_payment",OnPublish:"on_publish"};var kz={Active:"active",Expired:"expired",Paid:"paid",Pending:"pending"};var Bz={Csv:"csv",CsvGz:"csv.gz"};var jz={Failure:"failure",Pending:"pending",Success:"success"};var Az={AuditLog:"audit-log",CompanyFeatureUsage:"company-feature-usage"};var Vz={CreditBurndown:"credit_burndown",Overage:"overage",PayAsYouGo:"pay_as_you_go",PayInAdvance:"pay_in_advance",Tier:"tier"};var qz={CompanyOverride:"company_override",PlanEntitlement:"plan_entitlement",Unknown:"unknown"};var Dz={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var Mz={Company:"company",User:"user"};var Iz={Development:"development",Production:"production",Staging:"staging"};var Fz={Enriched:"enriched",Failed:"failed",Pending:"pending",Processed:"processed",Unknown:"unknown"};var jo={FlagCheck:"flag_check",Identify:"identify",Inference:"inference",Track:"track"};var Kz={AddOn:"add_on",Alpha:"alpha",Beta:"beta",Deprecated:"deprecated",Ga:"ga",Inactive:"inactive",InPlan:"in_plan",InternalTesting:"internal_testing",Legacy:"legacy"};var Lz={Boolean:"boolean",Event:"event",License:"license",Trait:"trait"};var Gz={Active:"active",Created:"created",Pending:"pending"};var Wz={Clerk:"clerk",Metronome:"metronome",Orb:"orb",Stripe:"stripe",Unknown:"unknown",Workos:"workos"};var Hz={Draft:"draft",Open:"open",Paid:"paid",Uncollectible:"uncollectible",Void:"void"};var Nz={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var $z={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Jz={AmbiguousSubscriptionItem:"ambiguous_subscription_item",MultipleSubscriptions:"multiple_subscriptions",NoPriceForInterval:"no_price_for_interval",NotOnOriginVersion:"not_on_origin_version",OperationItemNotFound:"operation_item_not_found",PermanentConfig:"permanent_config",PermanentDecline:"permanent_decline",TransientDecline:"transient_decline",TransientInfra:"transient_infra",TransientStripe:"transient_stripe",Unknown:"unknown",WouldLeaveEmptySubscription:"would_leave_empty_subscription"};var Yz={Create:"create",Update:"update",Delete:"delete"};var Zz={Checkout:"checkout",CompanyUpsert:"company_upsert",FallbackPlan:"fallback_plan",ManagePlan:"manage_plan",Migration:"migration",PlanBillingProductChanged:"plan_billing_product_changed",PlanDeleted:"plan_deleted",PlanTraitChange:"plan_trait_change",PlanVersionMigration:"plan_version_migration",Quickstart:"quickstart",SubscriptionChange:"subscription_change"};var Xz={Fallback:"fallback",Initial:"initial",Trait:"trait",TrialExpiry:"trial_expiry"};var Qz={Adjustment:"adjustment",Downgrade:"downgrade",Invalid:"invalid",Subscribe:"subscribe",Unsubscribe:"unsubscribe",Upgrade:"upgrade",UpgradeTrial:"upgrade_trial"};var eR={Amber:"amber",Blue:"blue",BlueGray:"blueGray",BlueGreen:"blueGreen",Cyan:"cyan",Emerald:"emerald",Fuchsia:"fuchsia",Gray:"gray",Green:"green",Indigo:"indigo",LightBlue:"lightBlue",Lime:"lime",Orange:"orange",Pink:"pink",Purple:"purple",Red:"red",RedOrange:"redOrange",Rose:"rose",Sky:"sky",Slate:"slate",Teal:"teal",TrueGray:"trueGray",Violet:"violet",WarmGray:"warmGray",Yellow:"yellow"};var rR={Monthly:"monthly",Quarterly:"quarterly",Yearly:"yearly"};var iR={Plan:"plan",AddOn:"add_on"};var oR={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending",Skipped:"skipped"};var tR={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending"};var aR={Immediate:"immediate",Leave:"leave"};var nR={Published:"published",Draft:"draft",Archived:"archived"};var sR={CreateProrations:"create_prorations",InvoiceImmediately:"invoice_immediately"};var cR={V5B3E7220:"v5b3e7220",PlaceholderForFernCompatibility:"placeholder-for-fern-compatibility"};var lR={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Aa={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var pR={Company:"company",User:"user"};var uR={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var dR={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var mR={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var hR={Bool:"bool",Date:"date",Int:"int",String:"string"};var gR={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var yR={Cancelled:"cancelled",Error:"error",Executing:"executing",Pending:"pending",Success:"success"};var wR={EndOfBillingPeriod:"end_of_billing_period",None:"none"};var bR={Asc:"asc",Desc:"desc"};var zR={Active:"active",Canceled:"canceled",Expired:"expired",Incomplete:"incomplete",IncompleteExpired:"incomplete_expired",PastDue:"past_due",Paused:"paused",Trialing:"trialing",Unpaid:"unpaid"};var RR={Free:"free",OneTime:"one_time",Paid:"paid",Trial:"trial"};var fR={Daily:"daily",Hourly:"hourly",Monthly:"monthly",Weekly:"weekly"};var _R={Bool:"bool",Date:"date",Int:"int",String:"string"};var SR={Boolean:"boolean",Currency:"currency",Date:"date",Number:"number",String:"string",Url:"url"};var PR={Active:"active",Converted:"converted",Expired:"expired"};var xR={Failure:"failure",Pending:"pending",Success:"success"};var CR={SubscriptionTrialEnded:"subscription.trial.ended",CompanyCreated:"company.created",CompanyDeleted:"company.deleted",CompanyOverrideCreated:"company.override.created",CompanyOverrideDeleted:"company.override.deleted",CompanyOverrideExpired:"company.override.expired",CompanyOverrideUpdated:"company.override.updated",CompanyPlanChanged:"company.plan_changed",CompanyScheduledDowngrade:"company.scheduled_downgrade",CompanyUpdated:"company.updated",CreditLimitReached:"credit.limit.reached",CreditLimitWarning:"credit.limit.warning",CreditPurchaseSuccess:"credit.purchase.success",EntitlementLimitReached:"entitlement.limit.reached",EntitlementLimitWarning:"entitlement.limit.warning",EntitlementSoftLimitReached:"entitlement.soft_limit.reached",EntitlementSoftLimitWarning:"entitlement.soft_limit.warning",EntitlementTierLimitReached:"entitlement.tier_limit.reached",EntitlementTierLimitWarning:"entitlement.tier_limit.warning",FeatureCreated:"feature.created",FeatureDeleted:"feature.deleted",FeatureUpdated:"feature.updated",FlagCreated:"flag.created",FlagDeleted:"flag.deleted",FlagRulesUpdated:"flag_rules.updated",FlagUpdated:"flag.updated",PlanCreated:"plan.created",PlanDeleted:"plan.deleted",PlanEntitlementCreated:"plan.entitlement.created",PlanEntitlementDeleted:"plan.entitlement.deleted",PlanEntitlementUpdated:"plan.entitlement.updated",PlanUpdated:"plan.updated",PlanVersionDeleted:"plan_version.deleted",RuleDeleted:"rule.deleted",TestSend:"test.send",UserCreated:"user.created",UserDeleted:"user.deleted",UserUpdated:"user.updated",AutoTopupHardFailure:"auto.topup.hard.failure",AutoTopupRetryExceeded:"auto.topup.retry.exceeded",AutoTopupSuccess:"auto.topup.success"};var ER={Active:"active",Inactive:"inactive"};var UR=2147483647,rr=class{constructor({maxItems:o=1e3,ttl:i=5e3}={}){this.accessCounter=0;this.cache=new Map,this.maxItems=o,this.defaultTTL=i}async get(o){let i=this.cache.get(o);return i?i.expiration<=Date.now()?(this.evictItem(o,i),null):(this.accessCounter++,i.accessCounter=this.accessCounter,this.cache.set(o,i),i.value):null}async set(o,i,t){if(this.maxItems===0)return;let s=t??this.defaultTTL,r=this.cache.get(o);r&&this.evictItem(o,r),this.evictExpiredItems(),this.evictLRUItems(),this.accessCounter++;let a={value:i,accessCounter:this.accessCounter,expiration:Date.now()+s};a.timeoutId=setTimeout(()=>this.evictItem(o,a),Math.min(s,UR)),typeof a.timeoutId=="object"&&typeof a.timeoutId.unref=="function"&&a.timeoutId.unref(),this.cache.set(o,a)}async delete(o){let i=this.cache.get(o);i&&this.evictItem(o,i)}async deleteMissing(o,i){let t=new Set(o);for(let[s,r]of this.cache)t.has(s)||this.evictItem(s,r)}evictItem(o,i){i.timeoutId&&clearTimeout(i.timeoutId),this.cache.delete(o)}evictExpiredItems(){this.cache.forEach((o,i)=>{o.expiration<=Date.now()&&this.evictItem(i,o)})}evictLRUItems(){for(;this.cache.size>=this.maxItems;){let o,i=Number.MAX_SAFE_INTEGER;this.cache.forEach((t,s)=>{t.accessCounter<i&&(o=s,i=t.accessCounter)}),o&&this.evictItem(o,this.cache.get(o))}}};var ci=class{constructor(o){this.client=o.client,this.defaultTTL=Math.floor((o.ttl||5e3)/1e3),this.keyPrefix=o.keyPrefix||"schematic:"}getFullKey(o){return this.keyPrefix+o}async get(o){let i=this.getFullKey(o),t=await this.client.get(i);return t===null?null:JSON.parse(t)}async set(o,i,t){let s=this.getFullKey(o),r=JSON.stringify(i),a=t?Math.floor(t/1e3):this.defaultTTL;a>0?await this.client.setEx(s,a,r):await this.client.set(s,r)}async delete(o){let i=this.getFullKey(o);await this.client.del(i)}async deleteMissing(o,i){let t=i?.scanPattern?this.keyPrefix+i.scanPattern:this.keyPrefix+"*",s=new Set(o.map(d=>this.getFullKey(d))),r=[],a=1e3;for await(let d of this.client.scanIterator({MATCH:t,COUNT:1e3}))s.has(d)||(r.push(d),r.length>=a&&(await this.client.del(r),r.length=0));r.length>0&&await this.client.del(r)}};function Va(p){return typeof p=="object"&&p!==null&&"getAuthRequest"in p&&typeof p.getAuthRequest=="function"}var mi=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var Ao={get:async(p,o)=>typeof p=="function"?p(o):p};var Ze={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},pc={[Ze.Debug]:1,[Ze.Info]:2,[Ze.Warn]:3,[Ze.Error]:4},uo=class{debug(o,...i){console.debug(o,...i)}info(o,...i){console.info(o,...i)}warn(o,...i){console.warn(o,...i)}error(o,...i){console.error(o,...i)}},hi=class{constructor(o){this.level=pc[o.level],this.logger=o.logger,this.silent=o.silent}shouldLog(o){return!this.silent&&this.level<=pc[o]}isDebug(){return this.shouldLog(Ze.Debug)}debug(o,...i){this.isDebug()&&this.logger.debug(o,...i)}isInfo(){return this.shouldLog(Ze.Info)}info(o,...i){this.isInfo()&&this.logger.info(o,...i)}isWarn(){return this.shouldLog(Ze.Warn)}warn(o,...i){this.isWarn()&&this.logger.warn(o,...i)}isError(){return this.shouldLog(Ze.Error)}error(o,...i){this.isError()&&this.logger.error(o,...i)}};function mo(p){return p==null?vR:p instanceof hi?p:(p=p??{},p.level??=Ze.Info,p.logger??=new uo,p.silent??=!0,new hi(p))}var vR=new hi({level:Ze.Info,logger:new uo,silent:!0});var TR={arrayFormat:"indices",encode:!0};function qa(p,o){if(p===void 0||p===null)return"";let i=String(p);return o?encodeURIComponent(i):i}function Da(p,o="",i){let t=[];for(let[s,r]of Object.entries(p)){let a=o?`${o}[${s}]`:s;if(r!==void 0)if(Array.isArray(r)){if(r.length===0)continue;let d=i.arrayFormat;if(d==="comma"){let y=i.encode?encodeURIComponent(a):a,g=r.filter(l=>l!=null).map(l=>qa(l,i.encode));g.length>0&&t.push(`${y}=${g.join(",")}`)}else for(let y=0;y<r.length;y++){let g=r[y];if(g!==void 0)if(typeof g=="object"&&!Array.isArray(g)&&g!==null){let l=d==="indices"?`${a}[${y}]`:a;t.push(...Da(g,l,i))}else{let l=d==="indices"?`${a}[${y}]`:a,h=i.encode?encodeURIComponent(l):l;t.push(`${h}=${qa(g,i.encode)}`)}}}else if(typeof r=="object"&&r!==null){if(Object.keys(r).length===0)continue;t.push(...Da(r,a,i))}else{let d=i.encode?encodeURIComponent(a):a;t.push(`${d}=${qa(r,i.encode)}`)}}return t}function _r(p,o){return p==null||typeof p!="object"?"":Da(p,"",{...TR,...o}).join("&")}function Vo(p,o){let i=_r(o,{arrayFormat:"repeat"});return i?`${p}?${i}`:p}function uc(p){let o={get bodyUsed(){return p.bodyUsed},stream:()=>p.body,arrayBuffer:p.arrayBuffer.bind(p),blob:p.blob.bind(p)};return"bytes"in p&&typeof p.bytes=="function"&&(o.bytes=p.bytes.bind(p)),o}var fe=OR();function OR(){if(typeof window<"u"&&typeof window.document<"u")return{type:"browser",version:window.navigator.userAgent};if(typeof globalThis<"u"&&globalThis?.navigator?.userAgent==="Cloudflare-Workers")return{type:"workerd"};if(typeof EdgeRuntime=="string")return{type:"edge-runtime"};if(typeof self=="object"&&typeof self?.importScripts=="function"&&(self.constructor?.name==="DedicatedWorkerGlobalScope"||self.constructor?.name==="ServiceWorkerGlobalScope"||self.constructor?.name==="SharedWorkerGlobalScope"))return{type:"web-worker"};if(typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u")return{type:"deno",version:Deno.version.deno};if(typeof Bun<"u"&&typeof Bun.version<"u")return{type:"bun",version:Bun.version};if(typeof navigator<"u"&&navigator?.product==="ReactNative")return{type:"react-native"};let d=typeof process<"u"?process:void 0;return typeof d<"u"&&typeof d.versions?.node=="string"?{type:"node",version:d.versions.node,parsedVersion:Number(d.versions.node.split(".")[0])}:{type:"unknown"}}async function bc(p){return fe.type==="node"&&fe.parsedVersion!=null&&fe.parsedVersion>=18?new(await Promise.resolve().then(()=>(mc(),dc))).Node18UniversalStreamWrapper(p):fe.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(gc(),hc))).UndiciStreamWrapper(p):new(await Promise.resolve().then(()=>(wc(),yc))).NodePre18StreamWrapper(p)}async function gi(p,o){switch(o){case"binary-response":return uc(p);case"blob":return await p.blob();case"arrayBuffer":return await p.arrayBuffer();case"sse":return p.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:p.status}}:p.body;case"streaming":return p.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:p.status}}:bc(p.body);case"text":return await p.text()}let i=await p.text();if(i.length>0)try{return po(i)}catch{return{ok:!1,error:{reason:"non-json",statusCode:p.status,rawBody:i}}}}async function zc(p){let o=p.headers.get("Content-Type")?.toLowerCase();if(o==null||o.length===0)return gi(p);switch(o.indexOf(";")!==-1&&(o=o.split(";")[0]?.trim()??""),o){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":{let i=await p.text();return i.length>0?po(i):void 0}default:if(o.startsWith("application/vnd.")&&o.endsWith("+json")){let i=await p.text();return i.length>0?po(i):void 0}return await p.text()}}async function yi(){return fe.type==="node"&&fe.parsedVersion!=null&&fe.parsedVersion>=18?fetch:fe.type==="node"?(await import("node-fetch")).default:typeof fetch=="function"?fetch:(await import("node-fetch")).default}async function qo({body:p,type:o}){return o==="form"?_r(p,{arrayFormat:"repeat",encode:!0}):o.includes("json")?ve(p):p}var ir;typeof globalThis.Headers<"u"?ir=globalThis.Headers:ir=class Rc{constructor(o){if(this.headers=new Map,o)if(o instanceof Rc)o.forEach((i,t)=>this.append(t,i));else if(Array.isArray(o))for(let[i,t]of o)if(typeof i=="string"&&typeof t=="string")this.append(i,t);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[i,t]of Object.entries(o))if(typeof t=="string")this.append(i,t);else throw new TypeError("Header values must be strings")}append(o,i){let t=o.toLowerCase(),s=this.headers.get(t)||[];this.headers.set(t,[...s,i])}delete(o){let i=o.toLowerCase();this.headers.delete(i)}get(o){let i=o.toLowerCase(),t=this.headers.get(i);return t?t.join(", "):null}has(o){let i=o.toLowerCase();return this.headers.has(i)}set(o,i){let t=o.toLowerCase();this.headers.set(t,[i])}forEach(o,i){let t=i?o.bind(i):o;this.headers.forEach((s,r)=>t(s.join(", "),r,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[o,i]of this.headers.entries())yield[o,i.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let o of this.headers.values())yield o.join(", ")}[Symbol.iterator](){return this.entries()}};var kR="timeout";function fc(p){let o=new AbortController,i=setTimeout(()=>o.abort(kR),p);return{signal:o.signal,abortId:i}}function _c(...p){let o=p.length===1&&Array.isArray(p[0])?p[0]:p,i=new AbortController;for(let t of o){if(t.aborted){i.abort(t?.reason);break}t.addEventListener("abort",()=>i.abort(t?.reason),{signal:i.signal})}return i.signal}var ho;function BR(){if(ho!=null)return ho;try{new Request("http://localhost",{cache:"no-store"}),ho=!0}catch{ho=!1}return ho}var wi=async(p,o,i,t,s,r,a,d,y,g)=>{let l=[],h;if(r!=null){let{signal:T,abortId:O}=fc(r);h=O,l.push(T)}a!=null&&l.push(a);let w=_c(l),U=await p(o,{method:i,headers:t,body:s,signal:w,credentials:d?"include":void 0,duplex:y,...g&&BR()?{cache:"no-store"}:{}});return h!=null&&clearTimeout(h),U};var bi={headers:new ir,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},zi={headers:new ir,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function go(p){return{headers:p.headers,redirected:p.redirected,status:p.status,statusText:p.statusText,type:p.type,url:p.url}}function jR(p){return[408,429].includes(p)||p>=500}function AR(p){let o=1+Math.random()*.2;return p*o}function VR(p){let o=1+(Math.random()-.5)*.2;return p*o}function qR(p,o){let i=p.headers.get("Retry-After");if(i){let s=parseInt(i,10);if(!Number.isNaN(s)&&s>0)return Math.min(s*1e3,6e4);let r=new Date(i);if(!Number.isNaN(r.getTime())){let a=r.getTime()-Date.now();if(a>0)return Math.min(Math.max(a,0),6e4)}}let t=p.headers.get("X-RateLimit-Reset");if(t){let s=parseInt(t,10);if(!Number.isNaN(s)){let r=s*1e3-Date.now();if(r>0)return AR(Math.min(r,6e4))}}return VR(Math.min(1e3*2**o,6e4))}async function Ri(p,o=2){let i=await p();for(let t=0;t<o&&jR(i.status);++t){let s=qR(i,t);await new Promise(r=>setTimeout(r,s)),i=await p()}return i}var DR=new Set(["authorization","www-authenticate","x-api-key","api-key","apikey","x-api-token","x-auth-token","auth-token","cookie","set-cookie","proxy-authorization","proxy-authenticate","x-csrf-token","x-xsrf-token","x-session-token","x-access-token"]);function Ka(p){let o={};for(let[i,t]of p instanceof ir?p.entries():Object.entries(p))DR.has(i.toLowerCase())?o[i]="[REDACTED]":o[i]=t;return o}var La=new Set(["api_key","api-key","apikey","token","access_token","access-token","auth_token","auth-token","password","passwd","secret","api_secret","api-secret","apisecret","key","session","session_id","session-id"]);function MR(p){if(p==null)return;let o={};for(let[i,t]of Object.entries(p))o[i]=La.has(i.toLowerCase())?"[REDACTED]":t;return o}function li(p){let o=p.indexOf("://");if(o===-1)return p;let i=o+3,t=p.indexOf("/",i),s=p.indexOf("?",i),r=p.indexOf("#",i),a=Math.min(t===-1?p.length:t,s===-1?p.length:s,r===-1?p.length:r),d=-1;for(let T=i;T<a;T++)p[T]==="@"&&(d=T);if(d!==-1&&(p=`${p.slice(0,i)}[REDACTED]@${p.slice(d+1)}`),s=p.indexOf("?"),s===-1)return p;r=p.indexOf("#",s);let y=r!==-1?r:p.length,g=p.slice(s+1,y);if(g.length===0)return p;let l=g.toLowerCase();if(!(l.includes("token")||l.includes("key")||l.includes("password")||l.includes("passwd")||l.includes("secret")||l.includes("session")||l.includes("auth")))return p;let w=[],U=g.split("&");for(let T of U){let O=T.indexOf("=");if(O===-1){w.push(T);continue}let A=T.slice(0,O),j=La.has(A.toLowerCase());if(!j&&A.includes("%"))try{let D=decodeURIComponent(A);j=La.has(D.toLowerCase())}catch{}w.push(j?`${A}=[REDACTED]`:T)}return p.slice(0,s+1)+w.join("&")+p.slice(y)}async function IR(p){let o=new ir;if(o.set("Accept",p.responseType==="json"?"application/json":p.responseType==="text"?"text/plain":p.responseType==="sse"?"text/event-stream":"*/*"),p.body!==void 0&&p.contentType!=null&&o.set("Content-Type",p.contentType),p.headers==null)return o;for(let[i,t]of Object.entries(p.headers)){let s=await Ao.get(t,{endpointMetadata:p.endpointMetadata??{}});if(typeof s=="string"){o.set(i,s);continue}s!=null&&o.set(i,`${s}`)}return o}async function FR(p){let o=p.url;p.queryString!=null&&p.queryString.length>0?o=`${o}?${p.queryString}`:o=Vo(p.url,p.queryParameters);let i=await qo({body:p.body,type:p.requestType??"other"}),t=p.fetchFn??await yi(),s=await IR(p),r=mo(p.logging);if(r.isDebug()){let a={method:p.method,url:li(o),headers:Ka(s),queryParameters:MR(p.queryParameters),hasBody:i!=null};r.debug("Making HTTP request",a)}try{let a=await Ri(async()=>wi(t,o,p.method,s,i,p.timeoutMs,p.abortSignal,p.withCredentials,p.duplex,p.responseType==="streaming"||p.responseType==="sse"),p.maxRetries);if(a.status>=200&&a.status<400){if(r.isDebug()){let y={method:p.method,url:li(o),statusCode:a.status,responseHeaders:Ka(a.headers)};r.debug("HTTP request succeeded",y)}return{ok:!0,body:await gi(a,p.responseType),headers:a.headers,rawResponse:go(a)}}else{if(r.isError()){let d={method:p.method,url:li(o),statusCode:a.status,responseHeaders:Ka(Object.fromEntries(a.headers.entries()))};r.error("HTTP request failed with error status",d)}return{ok:!1,error:{reason:"status-code",statusCode:a.status,body:await zc(a)},rawResponse:go(a)}}}catch(a){if(p.abortSignal?.aborted){if(r.isError()){let d={method:p.method,url:li(o)};r.error("HTTP request was aborted",d)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:a},rawResponse:bi}}else if(a instanceof Error&&a.name==="AbortError"){if(r.isError()){let d={method:p.method,url:li(o),timeoutMs:p.timeoutMs};r.error("HTTP request timed out",d)}return{ok:!1,error:{reason:"timeout",cause:a},rawResponse:bi}}else if(a instanceof Error){if(r.isError()){let d={method:p.method,url:li(o),errorMessage:a.message};r.error("HTTP request failed with error",d)}return{ok:!1,error:{reason:"unknown",errorMessage:a.message,cause:a},rawResponse:zi}}if(r.isError()){let d={method:p.method,url:li(o),error:ve(a)};r.error("HTTP request failed with unknown error",d)}return{ok:!1,error:{reason:"unknown",errorMessage:ve(a),cause:a},rawResponse:zi}}}var C=FR;var R=class p extends Promise{constructor(o){super(i=>{i(void 0)}),this.innerPromise=o}static fromFunction(o,...i){return new p(o(...i))}static interceptFunction(o){return(...i)=>p.fromPromise(o(...i))}static fromPromise(o){return new p(o)}static fromExecutor(o){let i=new Promise(o);return new p(i)}static fromResult(o){let i=Promise.resolve(o);return new p(i)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:o})=>o)),this.unwrappedPromise}then(o,i){return this.unwrap().then(o,i)}catch(o){return this.unwrap().catch(o)}finally(o){return this.unwrap().finally(o)}async withRawResponse(){return await this.innerPromise}};function Do(p,...o){if(!p)return"";if(o.length===0)return p;if(p.includes("://")){let i;try{i=new URL(p)}catch{return Sc(p,...o)}let s=o[o.length-1]?.endsWith("/");for(let r of o){let a=xc(r);a&&(i.pathname=Pc(i.pathname,a))}return s&&!i.pathname.endsWith("/")&&(i.pathname+="/"),i.toString()}return Sc(p,...o)}function Sc(p,...o){if(o.length===0)return p;let i=p,s=o[o.length-1]?.endsWith("/");for(let r of o){let a=xc(r);a&&(i=Pc(i,a))}return s&&!i.endsWith("/")&&(i+="/"),i}function Pc(p,o){return p.endsWith("/")?p+o:`${p}/${o}`}function xc(p){if(!p)return p;let o=0,i=p.length;return p.startsWith("/")&&(o=1),p.endsWith("/")&&(i=p.length-1),o===0&&i===p.length?p:p.slice(o,i)}var m={get:async p=>typeof p=="function"?p():p};async function Ga(p,o,i,t){let s=mo(i.logging),r,a=o;p instanceof Request?(r=p.url,o==null&&(a={method:p.method,headers:Object.fromEntries(p.headers.entries()),body:p.body,signal:p.signal,credentials:p.credentials,cache:p.cache,redirect:p.redirect,referrer:p.referrer,integrity:p.integrity,mode:p.mode})):r=p instanceof URL?p.toString():p;let d=(i.baseUrl!=null?await m.get(i.baseUrl):void 0)??(i.environment!=null?await m.get(i.environment):void 0),y;r.startsWith("http://")||r.startsWith("https://")?y=r:d!=null?y=Do(d,r):y=r;let g={};if(i.headers!=null)for(let[D,V]of Object.entries(i.headers)){let oe=await Ao.get(V,{endpointMetadata:{}});oe!=null&&(g[D.toLowerCase()]=`${oe}`)}if(i.getAuthHeaders!=null){let D=await i.getAuthHeaders();for(let[V,oe]of Object.entries(D))g[V.toLowerCase()]=oe}if(a?.headers!=null){let D=a.headers instanceof Headers?Object.fromEntries(a.headers.entries()):Array.isArray(a.headers)?Object.fromEntries(a.headers):a.headers;for(let[V,oe]of Object.entries(D))oe!=null&&(g[V.toLowerCase()]=oe)}if(t?.headers!=null)for(let[D,V]of Object.entries(t.headers))g[D.toLowerCase()]=V;let l=a?.method??"GET",h=a?.body,w=t?.timeoutInSeconds??i.timeoutInSeconds,U=w!=null?w*1e3:void 0,T=t?.maxRetries??i.maxRetries,O=t?.abortSignal??a?.signal??void 0,A=i.fetch??await yi();s.isDebug()&&s.debug("Making passthrough HTTP request",{method:l,url:y,hasBody:h!=null});let j=await Ri(async()=>wi(A,y,l,g,h??void 0,U,O,a?.credentials==="include",void 0,!1),T);return s.isDebug()&&s.debug("Passthrough HTTP request completed",{method:l,url:y,statusCode:j.status}),j}var Mo={};fr(Mo,{ConsoleLogger:()=>uo,LogLevel:()=>Ze,Logger:()=>hi,createLogger:()=>mo});var e={};fr(e,{JsonError:()=>fi,ParseError:()=>_i,any:()=>Ic,bigint:()=>Ec,boolean:()=>Fc,booleanLiteral:()=>Dc,date:()=>Uc,discriminant:()=>Zc,enum_:()=>yo,forwardCompatibleEnum_:()=>vc,getObjectLikeUtils:()=>Xe,getObjectUtils:()=>pi,getSchemaUtils:()=>J,isProperty:()=>Pr,lazy:()=>Tc,lazyObject:()=>Vc,list:()=>Ko,never:()=>Kc,number:()=>Lc,object:()=>Fo,objectWithoutOptionalProperties:()=>Ac,optional:()=>Wa,partialRecord:()=>Nc,property:()=>kc,record:()=>Hc,set:()=>$c,string:()=>Gc,stringLiteral:()=>Mc,transform:()=>Ha,undiscriminatedUnion:()=>Yc,union:()=>Qc,unknown:()=>Wc,withParsedProperties:()=>Ja});var I={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function $(p,o){return`Expected ${o}. Received ${KR(p)}.`}function KR(p){if(Array.isArray(p))return"list";if(p===null)return"null";if(p instanceof BigInt)return"BigInt";switch(typeof p){case"string":return`"${p}"`;case"bigint":case"number":case"boolean":case"undefined":return`${p}`}return typeof p}function ye(p){return{...p,json:Cc(p.json),parse:Cc(p.parse)}}function Cc(p){return(o,i)=>{let t=p(o,i),{skipValidation:s=!1}=i??{};return!t.ok&&s?(console.warn(["Failed to validate.",...t.errors.map(r=>" - "+(r.path.length>0?`${r.path.join(".")}: ${r.message}`:r.message))].join(`
|
|
3
|
+
`)),{ok:!0,value:o}):t}}function Io(p){return p.path.length===0?p.message:`${p.path.join(" -> ")}: ${p.message}`}var fi=class extends Error{constructor(i){super(i.map(Io).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};var _i=class extends Error{constructor(i){super(i.map(Io).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};function J(p){return{nullable:()=>LR(p),optional:()=>Wa(p),optionalNullable:()=>GR(p),transform:o=>Ha(p,o),parseOrThrow:(o,i)=>{let t=p.parse(o,i);if(t.ok)return t.value;throw new _i(t.errors)},jsonOrThrow:(o,i)=>{let t=p.json(o,i);if(t.ok)return t.value;throw new fi(t.errors)}}}function LR(p){let o={parse:(i,t)=>i==null?{ok:!0,value:null}:p.parse(i,t),json:(i,t)=>i==null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.NULLABLE};return{...o,...J(o)}}function Wa(p){let o={parse:(i,t)=>i==null?{ok:!0,value:void 0}:p.parse(i,t),json:(i,t)=>t?.omitUndefined&&i===void 0?{ok:!0,value:void 0}:i==null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.OPTIONAL};return{...o,...J(o)}}function GR(p){let o={parse:(i,t)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.parse(i,t),json:(i,t)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.json(i,t),getType:()=>I.OPTIONAL_NULLABLE};return{...o,...J(o)}}function Ha(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);return r.ok?{ok:!0,value:o.transform(r.value)}:r},json:(t,s)=>{let r=o.untransform(t);return p.json(r,s)},getType:()=>p.getType()};return{...i,...J(i)}}function Ec(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o=="bigint"?{ok:!0,value:o}:typeof o=="number"?{ok:!0,value:BigInt(o)}:{ok:!1,errors:[{path:i,message:$(o,"bigint | number")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="bigint"?{ok:!1,errors:[{path:i,message:$(o,"bigint")}]}:{ok:!0,value:o},getType:()=>I.BIGINT};return{...ye(p),...J(p)}}var WR=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Uc(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="string"?{ok:!1,errors:[{path:i,message:$(o,"string")}]}:WR.test(o)?{ok:!0,value:new Date(o)}:{ok:!1,errors:[{path:i,message:$(o,"ISO 8601 date string")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>o instanceof Date?{ok:!0,value:o.toISOString()}:{ok:!1,errors:[{path:i,message:$(o,"Date object")}]},getType:()=>I.DATE};return{...ye(p),...J(p)}}function be(p,o){return()=>{let i={parse:o,json:o,getType:()=>p};return{...ye(i),...J(i)}}}function yo(p){let o=new Set(p);return be(I.ENUM,(t,{allowUnrecognizedEnumValues:s,breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$(t,"string")}]}:!o.has(t)&&!s?{ok:!1,errors:[{path:r,message:$(t,"enum")}]}:{ok:!0,value:t})()}function vc(p){return yo(p).transform({transform:o=>o,untransform:o=>o})}function Tc(p){let o=Na(p);return{...o,...J(o)}}function Na(p){return{parse:(o,i)=>Si(p).parse(o,i),json:(o,i)=>Si(p).json(o,i),getType:()=>Si(p).getType()}}function Si(p){let o=p;return o.__zurg_memoized==null&&(o.__zurg_memoized=p()),o.__zurg_memoized}function $a(p){return Object.entries(p)}function wo(p,o){let i=new Set(o);return Object.entries(p).reduce((t,[s,r])=>(i.has(s)&&(t[s]=r),t),{})}function Sr(p){if(typeof p!="object"||p===null)return!1;let o=Object.getPrototypeOf(p);return o===null?!0:Object.getPrototypeOf(o)===null}function bo(p){return Object.keys(p)}function Oc(p,o){let i=[],t=[];for(let s of p)o(s)?i.push(s):t.push(s);return[i,t]}var HR=Object.prototype.hasOwnProperty;function Xe(p){return{withParsedProperties:o=>Ja(p,o)}}function Ja(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);if(!r.ok)return r;let a={};for(let d in o)if(HR.call(o,d)){let y=o[d];a[d]=typeof y=="function"?y(r.value):y}return{ok:!0,value:{...r.value,...a}}},json:(t,s)=>{if(!Sr(t))return{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:$(t,"object")}]};let r=new Set(Object.keys(o)),a=wo(t,Object.keys(t).filter(d=>!r.has(d)));return p.json(a,s)},getType:()=>p.getType()};return{...i,...J(i),...Xe(i)}}function kc(p,o){return{rawKey:p,valueSchema:o,isProperty:!0}}function Pr(p){return p.isProperty}var NR=Object.prototype.hasOwnProperty;function Fo(p){let o;function i(){if(o==null){o={};for(let[w,U]of $a(p)){let T=Pr(U)?U.rawKey:w,O=Pr(U)?U.valueSchema:U;o[T]={rawKey:T,parsedKey:w,valueSchema:O}}}return o}let t,s,r,a;function d(){if(t==null){t=[],s=[];for(let[w,U]of $a(p)){let T=Pr(U)?U.rawKey:w,O=Pr(U)?U.valueSchema:U;$R(O)&&(t.push(T),s.push(w))}r=new Set(t),a=new Set(s)}return t}function y(){return s==null&&d(),s}function g(){return r==null&&d(),r}function l(){return a==null&&d(),a}let h={_getRawProperties:()=>Object.entries(p).map(([w,U])=>Pr(U)?U.rawKey:w),_getParsedProperties:()=>bo(p),parse:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return Bc({value:w,requiredKeys:d(),requiredKeysSet:g(),getProperty:O=>{let A=i()[O];if(A!=null)return{transformedKey:A.parsedKey,transform:j=>{let D=[...T,O];return A.valueSchema.parse(j,{...U,breadcrumbsPrefix:D})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},json:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return Bc({value:w,requiredKeys:y(),requiredKeysSet:l(),getProperty:O=>{let A=p[O];if(A!=null)return Pr(A)?{transformedKey:A.rawKey,transform:j=>{let D=[...T,O];return A.valueSchema.json(j,{...U,breadcrumbsPrefix:D})}}:{transformedKey:O,transform:j=>{let D=[...T,O];return A.json(j,{...U,breadcrumbsPrefix:D})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},getType:()=>I.OBJECT};return{...ye(h),...J(h),...Xe(h),...pi(h)}}function Bc({value:p,requiredKeys:o,requiredKeysSet:i,getProperty:t,unrecognizedObjectKeys:s="fail",skipValidation:r=!1,breadcrumbsPrefix:a=[]}){if(!Sr(p))return{ok:!1,errors:[{path:a,message:$(p,"object")}]};let d=o.length,y=[],g={};for(let l in p){if(!NR.call(p,l))continue;let h=p[l],w=t(l);if(w!=null){d>0&&i.has(l)&&d--;let U=w.transform(h);U.ok?g[w.transformedKey]=U.value:(g[l]=h,y.push(...U.errors))}else switch(s){case"fail":y.push({path:[...a,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":g[l]=h;break}}if(d>0)for(let l of o)l in p||y.push({path:a,message:`Missing required key "${l}"`});return y.length===0||r?{ok:!0,value:g}:{ok:!1,errors:y}}function pi(p){return{extend:o=>{let i={_getParsedProperties:()=>[...p._getParsedProperties(),...o._getParsedProperties()],_getRawProperties:()=>[...p._getRawProperties(),...o._getRawProperties()],parse:(t,s)=>jc({extensionKeys:o._getRawProperties(),value:t,transformBase:r=>p.parse(r,s),transformExtension:r=>o.parse(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>jc({extensionKeys:o._getParsedProperties(),value:t,transformBase:r=>p.json(r,s),transformExtension:r=>o.json(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.OBJECT};return{...i,...J(i),...Xe(i),...pi(i)}},passthrough:()=>{let o=new Set(p._getRawProperties()),i=new Set(p._getParsedProperties()),t={_getParsedProperties:()=>p._getParsedProperties(),_getRawProperties:()=>p._getRawProperties(),parse:(s,r)=>{let a=p.parse(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!a.ok)return a;let d={};if(typeof s=="object"&&s!=null)for(let[y,g]of Object.entries(s))o.has(y)||(d[y]=g);return{ok:!0,value:{...d,...a.value}}},json:(s,r)=>{let a=p.json(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!a.ok)return a;let d={};if(typeof s=="object"&&s!=null)for(let[y,g]of Object.entries(s))i.has(y)||(d[y]=g);return{ok:!0,value:{...d,...a.value}}},getType:()=>I.OBJECT};return{...t,...J(t),...Xe(t),...pi(t)}}}}function jc({extensionKeys:p,value:o,transformBase:i,transformExtension:t,breadcrumbsPrefix:s=[]}){if(!Sr(o))return{ok:!1,errors:[{path:s,message:$(o,"object")}]};let r=new Set(p),[a,d]=Oc(bo(o),l=>r.has(l)),y=i(wo(o,d)),g=t(wo(o,a));return y.ok&&g.ok?{ok:!0,value:{...y.value,...g.value}}:{ok:!1,errors:[...y.ok?[]:y.errors,...g.ok?[]:g.errors]}}function $R(p){return!JR(p)}function JR(p){switch(p.getType()){case I.ANY:case I.UNKNOWN:case I.OPTIONAL:case I.OPTIONAL_NULLABLE:return!0;default:return!1}}function Ac(p){return Fo(p)}function Vc(p){let o={...Na(p),_getRawProperties:()=>Si(p)._getRawProperties(),_getParsedProperties:()=>Si(p)._getParsedProperties()};return{...o,...J(o),...Xe(o),...pi(o)}}function Ko(p){let o={parse:(i,t)=>qc(i,(s,r)=>p.parse(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),json:(i,t)=>qc(i,(s,r)=>p.json(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),getType:()=>I.LIST};return{...ye(o),...J(o)}}function qc(p,o){if(!Array.isArray(p))return{ok:!1,errors:[{message:$(p,"list"),path:[]}]};let i=[],t=[];for(let s=0;s<p.length;s++){let r=o(p[s],s);r.ok?i.push(r.value):t.push(...r.errors)}return t.length===0?{ok:!0,value:i}:{ok:!1,errors:t}}function Dc(p){return be(I.BOOLEAN_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:$(i,`${p.toString()}`)}]})()}function Mc(p){return be(I.STRING_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:$(i,`"${p}"`)}]})()}var Ic=be(I.ANY,p=>({ok:!0,value:p}));var Fc=be(I.BOOLEAN,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="boolean"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"boolean")}]});var Kc=be(I.NEVER,(p,{breadcrumbsPrefix:o=[]}={})=>({ok:!1,errors:[{path:o,message:"Expected never"}]}));var Lc=be(I.NUMBER,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="number"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"number")}]});var Gc=be(I.STRING,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="string"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"string")}]});var Wc=be(I.UNKNOWN,p=>({ok:!0,value:p}));var YR=Object.prototype.hasOwnProperty;function Hc(p,o){let i={parse:(t,s)=>Lo({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Lo({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.RECORD};return{...ye(i),...J(i)}}function Nc(p,o){let i={parse:(t,s)=>Lo({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Lo({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.RECORD};return{...ye(i),...J(i)}}function Lo({value:p,isKeyNumeric:o,transformKey:i,transformValue:t,breadcrumbsPrefix:s=[]}){if(!Sr(p))return{ok:!1,errors:[{path:s,message:$(p,"object")}]};let r={},a=[];for(let d in p){if(!YR.call(p,d))continue;let y=p[d];if(y===void 0)continue;let g=d;if(o){let w=d.length>0?Number(d):NaN;Number.isNaN(w)||(g=w)}let l=i(g),h=t(y,g);l.ok&&h.ok?r[l.value]=h.value:(l.ok||a.push(...l.errors),h.ok||a.push(...h.errors))}return a.length===0?{ok:!0,value:r}:{ok:!1,errors:a}}function $c(p){let o=Ko(p),i={parse:(t,s)=>{let r=o.parse(t,s);return r.ok?{ok:!0,value:new Set(r.value)}:r},json:(t,s)=>t instanceof Set?o.json([...t],s):{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:$(t,"Set")}]},getType:()=>I.SET};return{...ye(i),...J(i)}}function Yc(p){let o={parse:(i,t)=>Jc((s,r)=>s.parse(i,r),p,t),json:(i,t)=>Jc((s,r)=>s.json(i,r),p,t),getType:()=>I.UNDISCRIMINATED_UNION};return{...ye(o),...J(o)}}function Jc(p,o,i){let t=[];for(let[s,r]of o.entries()){let a=p(r,{...i,skipValidation:!1});if(a.ok)return a;for(let d of a.errors)t.push({path:d.path,message:`[Variant ${s}] ${d.message}`})}return{ok:!1,errors:t}}function Zc(p,o){return{parsedDiscriminant:p,rawDiscriminant:o}}var ZR=Object.prototype.hasOwnProperty;function Qc(p,o){let i=typeof p=="string"?p:p.rawDiscriminant,t=typeof p=="string"?p:p.parsedDiscriminant,s=yo(bo(o)),r={parse:(a,d)=>Xc({value:a,discriminant:i,transformedDiscriminant:t,transformDiscriminantValue:y=>s.parse(y,{allowUnrecognizedEnumValues:d?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...d?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:y=>o[y],allowUnrecognizedUnionMembers:d?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(y,g)=>g.parse(y,d),breadcrumbsPrefix:d?.breadcrumbsPrefix}),json:(a,d)=>Xc({value:a,discriminant:t,transformedDiscriminant:i,transformDiscriminantValue:y=>s.json(y,{allowUnrecognizedEnumValues:d?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...d?.breadcrumbsPrefix??[],t]}),getAdditionalPropertiesSchema:y=>o[y],allowUnrecognizedUnionMembers:d?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(y,g)=>g.json(y,d),breadcrumbsPrefix:d?.breadcrumbsPrefix}),getType:()=>I.UNION};return{...ye(r),...J(r),...Xe(r)}}function Xc({value:p,discriminant:o,transformedDiscriminant:i,transformDiscriminantValue:t,getAdditionalPropertiesSchema:s,allowUnrecognizedUnionMembers:r=!1,transformAdditionalProperties:a,breadcrumbsPrefix:d=[]}){if(!Sr(p))return{ok:!1,errors:[{path:d,message:$(p,"object")}]};let y=p[o],g={};for(let U in p)ZR.call(p,U)&&U!==o&&(g[U]=p[U]);if(y==null)return{ok:!1,errors:[{path:d,message:`Missing discriminant ("${o}")`}]};let l=t(y);if(!l.ok)return{ok:!1,errors:l.errors};let h=s(l.value);if(h==null)return r?{ok:!0,value:{[i]:l.value,...g}}:{ok:!1,errors:[{path:[...d,o],message:"Unexpected discriminant value"}]};let w=a(g,h);return w.ok?{ok:!0,value:{[i]:y,...w.value}}:w}var u={};fr(u,{encodePathParam:()=>el,join:()=>Do,queryBuilder:()=>rl,toQueryString:()=>_r});function el(p){if(p===null)return"null";switch(typeof p){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:p=String(p);break}return encodeURIComponent(p)}function rl(){return new Ya}var Ya=class{constructor(){this.parts=new Map}add(o,i,t){if(i==null)return this;let s=_r({[o]:i},{arrayFormat:t?.style==="comma"?"comma":"repeat"});return s.length>0&&this.parts.set(o,s),this}addMany(o){if(o!=null)for(let[i,t]of Object.entries(o))this.add(i,t);return this}mergeAdditional(o){if(o!=null)for(let[i,t]of Object.entries(o)){if(t==null)continue;let s=_r({[i]:t},{arrayFormat:"repeat"});s.length>0&&this.parts.set(i,s)}return this}build(){return[...this.parts.values()].join("&")}};var Za="apiKey",XR="X-Schematic-Api-Key",Pi=class p{constructor(o){this.options=o}static canCreate(o){return o?.[Za]!=null}async getAuthRequest({endpointMetadata:o}={}){let i=await m.get(this.options[Za]);if(i==null)throw new b({message:p.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[XR]:i}}}};(t=>{t.AUTH_SCHEME="ApiKeyAuth",t.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${Za}' when initializing the client`;function i(s){return new t(s)}t.createInstance=i})(Pi||={});function f(...p){let o={};for(let[i,t]of p.filter(s=>s!=null).flatMap(s=>Object.entries(s))){let s=i.toLowerCase();t!=null?o[s]=t:s in o&&delete o[s]}return o}function QR(p){let o=f({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@schematichq/schematic-typescript-node","X-Fern-SDK-Version":"1.5.6","User-Agent":"@schematichq/schematic-typescript-node/1.5.6","X-Fern-Runtime":fe.type,"X-Fern-Runtime-Version":fe.version},p?.headers);return{...p,logging:Mo.createLogger(p?.logging),headers:o}}function K(p){let o=QR(p);if(p.auth===!1)return o.authProvider=new mi,o;if(p.auth!=null){if(typeof p.auth=="function")return o.authProvider={getAuthRequest:p.auth},o;if(Va(p.auth))return o.authProvider=p.auth,o;Object.assign(o,p.auth)}let i=ef(o);return o.authProvider??=new Pi(i),o}function ef(p){return{...p,authProvider:new mi}}var z={Default:"https://api.schematichq.com"};function E(p,o,i,t){switch(p.reason){case"non-json":throw new b({statusCode:p.statusCode,body:p.rawBody,rawResponse:o});case"body-is-null":throw new b({statusCode:p.statusCode,rawResponse:o});case"timeout":throw new si(`Timeout exceeded when calling ${i} ${t}.`,{cause:p.cause});case"unknown":throw new b({message:p.errorMessage,rawResponse:o,cause:p.cause});default:throw new b({message:"Unknown error",rawResponse:o})}}var Xa=e.object({lookup:e.record(e.string(),e.string())});var il=e.stringLiteral("company");var ol=e.object({apiKeyId:e.property("api_key_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),expiredAt:e.property("expired_at",e.date()),id:e.string(),resourceType:e.property("resource_type",il),token:e.string(),updatedAt:e.property("updated_at",e.date())});var tl=e.object({data:ol,params:e.record(e.string(),e.unknown())});var Qa=e.object({description:e.string().optional(),environmentId:e.property("environment_id",e.string().optional()),name:e.string(),readonly:e.boolean().optional()});var jr=e.enum_(["development","production","staging"]);var en=e.object({environmentType:e.property("environment_type",jr),name:e.string()});var rn=e.object({description:e.string().optional(),name:e.string().optional()});var on=e.object({environmentType:e.property("environment_type",jr.optional()),name:e.string().optional()});var xr=e.enum_(["admin","member"]);var al=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),role:xr.optional()});var q=e.object({count:e.number().optional()});var nl=e.object({data:q,params:al});var sl=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var cl=e.object({data:q,params:sl});var Ce=e.enum_(["api_key","app_user","stripe_app","system","temporary_access_token"]);var ll=e.object({actorType:e.property("actor_type",Ce.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var pl=e.object({data:q,params:ll});var Me=e.enum_(["active","created","pending"]);var Se=e.enum_(["clerk","metronome","orb","stripe","unknown","workos"]);var Go=e.object({id:e.string(),state:Me,type:Se});var Wo=e.enum_(["admin","capture","read","write"]);var Pe=e.object({createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",jr),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var ul=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:Go.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(Wo),secret:e.string(),updatedAt:e.property("updated_at",e.date())});var dl=e.object({data:ul,params:e.record(e.string(),e.unknown())});var xe=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:Go.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(Wo),updatedAt:e.property("updated_at",e.date())});var ml=e.object({apiKeys:e.property("api_keys",e.list(xe)),createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",jr),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var hl=e.object({data:ml,params:e.record(e.string(),e.unknown())});var F=e.object({deleted:e.boolean().optional()});var gl=e.object({data:F,params:e.record(e.string(),e.unknown())});var yl=e.object({data:F,params:e.record(e.string(),e.unknown())});var wl=e.enum_(["companies_edit","company_users_edit","components_edit","custom_plans_edit","data_exports_edit","features_edit","flag_rules_edit","flags_edit","overrides_edit","plan_billing_edit","plan_entitlements_edit","plan_versions_edit","plans_edit","webhooks_edit","webhooks_reveal_secret"]);var Ar=e.object({createdAt:e.property("created_at",e.date()),email:e.string().optional(),firstName:e.property("first_name",e.string().optional()),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),lastName:e.property("last_name",e.string().optional()),name:e.string().optional(),permissions:e.record(e.string(),e.list(wl)),role:xr.optional(),updatedAt:e.property("updated_at",e.date())});var bl=e.object({data:Ar,params:e.record(e.string(),e.unknown())});var zl=e.object({data:xe,params:e.record(e.string(),e.unknown())});var Rl=e.object({actorType:e.property("actor_type",Ce),apiKey:e.property("api_key",xe.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),reqBody:e.property("req_body",e.string().optional()),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respBody:e.property("resp_body",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var fl=e.object({data:Rl,params:e.record(e.string(),e.unknown())});var _l=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var Sl=e.object({accountId:e.property("account_id",e.string()),accountName:e.property("account_name",e.string()),actorType:e.property("actor_type",Ce),apiKeyId:e.property("api_key_id",e.string().optional()),environmentId:e.property("environment_id",e.string().optional()),environments:e.list(Pe),stripeUserId:e.property("stripe_user_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var Pl=e.object({data:Sl,params:e.record(e.string(),e.unknown())});var xl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),role:xr.optional()});var Cl=e.object({data:e.list(Ar),params:xl});var El=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var Ul=e.object({data:e.list(xe),params:El});var vl=e.object({actorType:e.property("actor_type",Ce.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var Ho=e.object({actorType:e.property("actor_type",Ce),apiKey:e.property("api_key",xe.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userName:e.property("user_name",e.string().optional())});var Tl=e.object({data:e.list(Ho),params:vl});var Ol=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var kl=e.object({data:e.list(Pe),params:Ol});var Bl=e.object({ok:e.boolean()});var jl=e.object({data:Bl,params:e.record(e.string(),e.unknown())});var Al=e.object({data:xe,params:e.record(e.string(),e.unknown())});var Vl=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var k=e.enum_(["metronome","orb","schematic","stripe"]);var tn=e.object({companyId:e.property("company_id",e.string().optional()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),email:e.string(),externalId:e.property("external_id",e.string()),meta:e.record(e.string(),e.string()),name:e.string(),providerType:e.property("provider_type",k.optional())});var or=e.enum_(["per_unit","tiered"]);var ce=e.enum_(["licensed","metered"]);var de=e.enum_(["graduated","volume"]);var ql=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitDecimal:e.property("per_unit_decimal",e.string().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),priceExternalId:e.property("price_external_id",e.string()),providerType:e.property("provider_type",k.optional()),upTo:e.property("up_to",e.number().optional())});var an=e.object({billingScheme:e.property("billing_scheme",or),currency:e.string(),externalAccountId:e.property("external_account_id",e.string()),interval:e.string(),intervalCount:e.property("interval_count",e.number().optional()),isActive:e.property("is_active",e.boolean()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number().optional()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceTiers:e.property("price_tiers",e.list(ql)),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k.optional()),tiersMode:e.property("tiers_mode",de.optional()),usageType:e.property("usage_type",ce)});var nn=e.object({externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean().optional()),name:e.string().optional(),price:e.number(),providerType:e.property("provider_type",k.optional())});var Dl=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),currency:e.string(),interval:e.string(),meterId:e.property("meter_id",e.string().optional()),packageSize:e.property("package_size",e.number().optional()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),productExternalId:e.property("product_external_id",e.string()),quantity:e.number(),subscriptionItemExternalId:e.property("subscription_item_external_id",e.string().optional()),usageType:e.property("usage_type",ce)});var Ml=e.object({couponExternalId:e.property("coupon_external_id",e.string()),customerFacingCode:e.property("customer_facing_code",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date())});var Vr=e.enum_(["cancel","subscribe"]);var sn=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodExternalId:e.property("default_payment_method_external_id",e.string().optional()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),discounts:e.list(Ml),expiredAt:e.property("expired_at",e.date()),interval:e.string().optional(),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number().optional()),periodStart:e.property("period_start",e.number().optional()),productExternalIds:e.property("product_external_ids",e.list(Dl)),providerType:e.property("provider_type",k.optional()),status:e.string().optional(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Vr.optional())});var cn=e.object({amountOff:e.property("amount_off",e.number()),currency:e.string().optional(),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number()),externalId:e.property("external_id",e.string()),maxRedemptions:e.property("max_redemptions",e.number()),name:e.string(),percentOff:e.property("percent_off",e.number()),timesRedeemed:e.property("times_redeemed",e.number())});var No=e.enum_(["draft","open","paid","uncollectible","void"]);var ln=e.object({amountDue:e.property("amount_due",e.number()),amountPaid:e.property("amount_paid",e.number()),amountRemaining:e.property("amount_remaining",e.number()),collectionMethod:e.property("collection_method",e.string()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),dueDate:e.property("due_date",e.date().optional()),endingBalance:e.property("ending_balance",e.number().optional()),externalId:e.property("external_id",e.string().optional()),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),startingBalance:e.property("starting_balance",e.number().optional()),status:No.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),url:e.string().optional()});var pn=e.object({displayName:e.property("display_name",e.string()),eventName:e.property("event_name",e.string()),eventPayloadKey:e.property("event_payload_key",e.string()),externalId:e.property("external_id",e.string()),providerType:e.property("provider_type",k.optional())});var un=e.object({accountLast4:e.property("account_last4",e.string().optional()),accountName:e.property("account_name",e.string().optional()),bankName:e.property("bank_name",e.string().optional()),billingEmail:e.property("billing_email",e.string().optional()),billingName:e.property("billing_name",e.string().optional()),cardBrand:e.property("card_brand",e.string().optional()),cardExpMonth:e.property("card_exp_month",e.number().optional()),cardExpYear:e.property("card_exp_year",e.number().optional()),cardLast4:e.property("card_last4",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string()),externalId:e.property("external_id",e.string()),paymentMethodType:e.property("payment_method_type",e.string())});var Il=e.object({ids:e.list(e.string()).optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),priceUsageType:e.property("price_usage_type",ce.optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),recurringChargesOnly:e.property("recurring_charges_only",e.boolean().optional()),withOneTimeCharges:e.property("with_one_time_charges",e.boolean().optional()),withPricesOnly:e.property("with_prices_only",e.boolean().optional()),withZeroPrice:e.property("with_zero_price",e.boolean().optional()),withoutLinkedToPlan:e.property("without_linked_to_plan",e.boolean().optional())});var Fl=e.object({data:q,params:Il});var Kl=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),providerType:e.property("provider_type",k.optional()),q:e.string().optional()});var Ll=e.object({data:q,params:Kl});var Gl=e.object({data:F,params:e.record(e.string(),e.unknown())});var Wl=e.object({data:F,params:e.record(e.string(),e.unknown())});var Hl=e.object({data:F,params:e.record(e.string(),e.unknown())});var Nl=e.object({data:F,params:e.record(e.string(),e.unknown())});var $l=e.object({data:F,params:e.record(e.string(),e.unknown())});var Jl=e.object({data:F,params:e.record(e.string(),e.unknown())});var Yl=e.object({currency:e.string().optional(),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),ids:e.list(e.string()).optional(),interval:e.string().optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),price:e.number().optional(),productId:e.property("product_id",e.string().optional()),productIds:e.property("product_ids",e.list(e.string()).optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),tiersMode:e.property("tiers_mode",de.optional()),usageType:e.property("usage_type",ce.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var xi=e.enum_(["day","month","one-time","year"]);var $o=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),upTo:e.property("up_to",e.number().optional())});var H=e.object({billingScheme:e.property("billing_scheme",or),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:xi,intervalCount:e.property("interval_count",e.number()),isActive:e.property("is_active",e.boolean()),meterEventName:e.property("meter_event_name",e.string().optional()),meterEventPayloadKey:e.property("meter_event_payload_key",e.string().optional()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceId:e.property("price_id",e.string()),priceTier:e.property("price_tier",e.list($o)),productExternalId:e.property("product_external_id",e.string()),productId:e.property("product_id",e.string()),productName:e.property("product_name",e.string()),providerType:e.property("provider_type",k),tiersMode:e.property("tiers_mode",de.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",ce)});var Zl=e.object({data:e.list(H),params:Yl});var Xl=e.object({currency:e.string().optional(),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),ids:e.list(e.string()).optional(),interval:e.string().optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),price:e.number().optional(),productId:e.property("product_id",e.string().optional()),productIds:e.property("product_ids",e.list(e.string()).optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),tiersMode:e.property("tiers_mode",de.optional()),usageType:e.property("usage_type",ce.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var Ql=e.object({data:e.list(H),params:Xl});var ep=e.object({ids:e.list(e.string()).optional(),isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),priceUsageType:e.property("price_usage_type",ce.optional()),providerType:e.property("provider_type",k.optional()),q:e.string().optional(),recurringChargesOnly:e.property("recurring_charges_only",e.boolean().optional()),withOneTimeCharges:e.property("with_one_time_charges",e.boolean().optional()),withPricesOnly:e.property("with_prices_only",e.boolean().optional()),withZeroPrice:e.property("with_zero_price",e.boolean().optional()),withoutLinkedToPlan:e.property("without_linked_to_plan",e.boolean().optional())});var L=e.object({currency:e.string(),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),interval:xi,intervalCount:e.property("interval_count",e.number()),nickname:e.string().optional(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),providerType:e.property("provider_type",k),scheme:or});var tr=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),currency:e.string().optional(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),name:e.string(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),prices:e.list(L),productId:e.property("product_id",e.string()),providerType:e.property("provider_type",k),quantity:e.number(),subscriptionCount:e.property("subscription_count",e.number()),updatedAt:e.property("updated_at",e.date())});var rp=e.object({data:e.list(tr),params:ep});var ip=e.object({isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Jo=e.object({accountId:e.property("account_id",e.string()),amountOff:e.property("amount_off",e.number().optional()),currency:e.string().optional(),duration:e.string().optional(),durationInMonths:e.property("duration_in_months",e.number().optional()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),isActive:e.property("is_active",e.boolean()),maxRedemptions:e.property("max_redemptions",e.number().optional()),metadata:e.record(e.string(),e.unknown()),name:e.string(),percentOff:e.property("percent_off",e.number().optional()),providerType:e.property("provider_type",k),timesRedeemed:e.property("times_redeemed",e.number()),validFrom:e.property("valid_from",e.date().optional()),validUntil:e.property("valid_until",e.date().optional())});var op=e.object({data:e.list(Jo),params:ip});var tp=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional(),providerType:e.property("provider_type",k.optional()),q:e.string().optional()});var ap=e.object({currency:e.string(),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),meteredUsage:e.property("metered_usage",e.boolean()),perUnitPrice:e.property("per_unit_price",e.number()),totalPrice:e.property("total_price",e.number())});var np=e.object({companyId:e.property("company_id",e.string().optional()),deletedAt:e.property("deleted_at",e.date().optional()),email:e.string(),externalId:e.property("external_id",e.string()),id:e.string(),name:e.string(),providerType:e.property("provider_type",k),subscriptions:e.list(ap),updatedAt:e.property("updated_at",e.date())});var sp=e.object({data:e.list(np),params:tp});var cp=e.object({companyId:e.property("company_id",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional())});var Ve=e.object({amountDue:e.property("amount_due",e.number()),amountPaid:e.property("amount_paid",e.number()),amountRemaining:e.property("amount_remaining",e.number()),collectionMethod:e.property("collection_method",e.string()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),dueDate:e.property("due_date",e.date().optional()),endingBalance:e.property("ending_balance",e.number()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string().optional()),id:e.string(),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),providerType:e.property("provider_type",k),startingBalance:e.property("starting_balance",e.number()),status:No.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),updatedAt:e.property("updated_at",e.date()),url:e.string().optional()});var lp=e.object({data:e.list(Ve),params:cp});var pp=e.object({displayName:e.property("display_name",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var Yo=e.object({dispalyName:e.property("dispaly_name",e.string()),eventName:e.property("event_name",e.string()),eventPayloadKey:e.property("event_payload_key",e.string()),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),providerType:e.property("provider_type",k)});var up=e.object({data:e.list(Yo),params:pp});var dp=e.object({companyId:e.property("company_id",e.string().optional()),customerExternalId:e.property("customer_external_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var qe=e.object({accountLast4:e.property("account_last4",e.string().optional()),accountName:e.property("account_name",e.string().optional()),bankName:e.property("bank_name",e.string().optional()),billingEmail:e.property("billing_email",e.string().optional()),billingName:e.property("billing_name",e.string().optional()),cardBrand:e.property("card_brand",e.string().optional()),cardExpMonth:e.property("card_exp_month",e.number().optional()),cardExpYear:e.property("card_exp_year",e.number().optional()),cardLast4:e.property("card_last4",e.string().optional()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),customerExternalId:e.property("customer_external_id",e.string()),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),paymentMethodType:e.property("payment_method_type",e.string()),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var mp=e.object({data:e.list(qe),params:dp});var hp=e.object({data:Jo,params:e.record(e.string(),e.unknown())});var gp=e.object({companyId:e.property("company_id",e.string().optional()),deletedAt:e.property("deleted_at",e.date().optional()),email:e.string(),externalId:e.property("external_id",e.string()),id:e.string(),name:e.string(),providerType:e.property("provider_type",k),updatedAt:e.property("updated_at",e.date())});var yp=e.object({data:gp,params:e.record(e.string(),e.unknown())});var wp=e.object({data:Yo,params:e.record(e.string(),e.unknown())});var bp=e.object({data:L,params:e.record(e.string(),e.unknown())});var ar=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),currency:e.string().optional(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),isActive:e.property("is_active",e.boolean()),name:e.string(),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),productId:e.property("product_id",e.string()),providerType:e.property("provider_type",k),quantity:e.number(),updatedAt:e.property("updated_at",e.date())});var zp=e.object({data:ar,params:e.record(e.string(),e.unknown())});var Rp=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Vr.optional())});var fp=e.object({data:Rp,params:e.record(e.string(),e.unknown())});var _p=e.object({data:Ve,params:e.record(e.string(),e.unknown())});var Sp=e.object({data:qe,params:e.record(e.string(),e.unknown())});var dn=e.object({description:e.string().optional(),isDefault:e.property("is_default",e.boolean()),name:e.string()});var Pp=e.object({bundleId:e.property("bundle_id",e.string())});var xp=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var mn=e.object({entitlements:e.list(xp).optional(),planId:e.property("plan_id",e.string())});var hn=e.object({customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(mn).optional()),orderedBundles:e.property("ordered_bundles",e.list(Pp).optional()),orderedPlans:e.property("ordered_plans",e.list(mn).optional()),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional())});var gn=e.object({description:e.string().optional(),isDefault:e.property("is_default",e.boolean().optional()),name:e.string().optional()});var nr=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean()),description:e.string().optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),isDefault:e.property("is_default",e.boolean()),name:e.string(),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Cp=e.object({data:nr,params:e.record(e.string(),e.unknown())});var Ep=e.object({data:F,params:e.record(e.string(),e.unknown())});var Up=e.object({data:nr,params:e.record(e.string(),e.unknown())});var vp=e.object({bundleId:e.property("bundle_id",e.string())});var Tp=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean()});var yn=e.object({entitlements:e.list(Tp),planId:e.property("plan_id",e.string())});var qr=e.enum_(["expiration_priority","first_in_first_out","last_in_first_out","plan_first_then_credit_bundles_first_in_first_out"]);var G=e.enum_(["billing_periods","days"]);var Dr=e.enum_(["expire","none","rollover"]);var Op=e.object({currency:e.string(),price:L.optional()});var ge=e.object({burnStrategy:e.property("burn_strategy",qr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Op)),defaultExpiryUnit:e.property("default_expiry_unit",G),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Dr),description:e.string(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:L.optional(),product:ar.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Te=e.object({billingProvider:e.property("billing_provider",k),externalResourceId:e.property("external_resource_id",e.string()),originator:k});var sr=e.enum_(["off","automatic","user_controlled"]);var Z=e.enum_(["duration","end_of_billing_period","end_of_next_billing_period","end_of_trial","no_expiry"]);var Oe=e.enum_(["daily","every_6_months","monthly","quarterly","weekly","yearly"]);var Ie=e.enum_(["billing_period","first_of_month"]);var cr=e.enum_(["no_reset","plan_period"]);var Zo=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var ke=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",e.string().optional()),autoTopupAvailability:e.property("auto_topup_availability",sr),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Z.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",G.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean()),createdAt:e.property("created_at",e.date()),credit:ge.optional(),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),creditPluralName:e.property("credit_plural_name",e.string().optional()),creditSingularName:e.property("credit_singular_name",e.string().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Zo.optional(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),resetCadence:e.property("reset_cadence",Oe.optional()),resetStart:e.property("reset_start",Ie.optional()),resetType:e.property("reset_type",cr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number()),updatedAt:e.property("updated_at",e.date())});var Fe=e.enum_(["schematic_managed","provider_managed","no_billing"]);var Ke=e.enum_(["free","none","one_time","recurring"]);var Xo=e.object({ctaText:e.property("cta_text",e.string()),ctaWebSite:e.property("cta_web_site",e.string()),priceText:e.property("price_text",e.string())});var te=e.enum_(["company","user"]);var me=e.enum_(["boolean","currency","date","number","string","url"]);var he=e.object({createdAt:e.property("created_at",e.date()),displayName:e.property("display_name",e.string()),entityType:e.property("entity_type",te),hierarchy:e.list(e.string()),id:e.string(),traitType:e.property("trait_type",me),updatedAt:e.property("updated_at",e.date())});var Ci=e.object({companyCount:e.property("company_count",e.number()),environmentId:e.property("environment_id",e.string()),eventCount:e.property("event_count",e.number()),eventSubtype:e.property("event_subtype",e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),userCount:e.property("user_count",e.number())});var Le=e.enum_(["add_on","alpha","beta","deprecated","ga","inactive","in_plan","internal_testing","legacy"]);var le=e.enum_(["boolean","event","license","trait"]);var Mr=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",le),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var lr=e.stringLiteral("boolean");var Ir=e.enum_(["eq","gt","gte","is_empty","lt","lte","not_empty","ne"]);var Ei=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var W=e.enum_(["all_time","current_day","current_month","current_week"]);var N=e.enum_(["billing_cycle","first_of_month"]);var Qo=e.object({comparisonTrait:e.property("comparison_trait",he.optional()),comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionGroupId:e.property("condition_group_id",e.string().optional()),conditionType:e.property("condition_type",Ei),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ir,resourceIds:e.property("resource_ids",e.list(e.string())),resources:e.list(Zo),ruleId:e.property("rule_id",e.string()),trait:he.optional(),traitEntityType:e.property("trait_entity_type",te.optional()),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var kp=e.object({conditions:e.list(Qo),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),ruleId:e.property("rule_id",e.string()),updatedAt:e.property("updated_at",e.date())});var Fr=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var Ui=e.object({conditionGroups:e.property("condition_groups",e.list(kp)),conditions:e.list(Qo),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Fr),updatedAt:e.property("updated_at",e.date()),value:e.boolean()});var Bp=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:Mr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",lr),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Ui),updatedAt:e.property("updated_at",e.date())});var Kr=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Ge=e.object({billingLinkedResource:e.property("billing_linked_resource",Te.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Ci.optional()),featureType:e.property("feature_type",le),flags:e.list(Bp),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Kr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:he.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var Lr=e.object({id:e.string(),name:e.string()});var Gr=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",L.optional()),oneTimePrice:e.property("one_time_price",L.optional()),quarterlyPrice:e.property("quarterly_price",L.optional()),yearlyPrice:e.property("yearly_price",L.optional())});var jp=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",H.optional()),quarterlyPrice:e.property("quarterly_price",H.optional()),yearlyPrice:e.property("yearly_price",H.optional())});var ze=e.enum_(["credit_burndown","overage","pay_as_you_go","pay_in_advance","tier"]);var re=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var pe=e.enum_(["amber","blue","blueGray","blueGreen","cyan","emerald","fuchsia","gray","green","indigo","lightBlue","lime","orange","pink","purple","red","redOrange","rose","sky","slate","teal","trueGray","violet","warmGray","yellow"]);var Q=e.enum_(["plan","add_on"]);var pr=e.object({audienceType:e.property("audience_type",e.string().optional()),companyId:e.property("company_id",e.string().optional()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),description:e.string(),icon:pe,id:e.string(),name:e.string(),planType:e.property("plan_type",Q),updatedAt:e.property("updated_at",e.date())});var Ap=e.object({id:e.string(),key:e.string(),value:e.number()});var ie=e.object({billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(jp)),environmentId:e.property("environment_id",e.string()),feature:Mr.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),meteredMonthlyPrice:e.property("metered_monthly_price",H.optional()),meteredQuarterlyPrice:e.property("metered_quarterly_price",H.optional()),meteredYearlyPrice:e.property("metered_yearly_price",H.optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),plan:pr.optional(),planId:e.property("plan_id",e.string()),priceBehavior:e.property("price_behavior",ze.optional()),ruleId:e.property("rule_id",e.string()),ruleIdUsageExceeded:e.property("rule_id_usage_exceeded",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageBasedProduct:e.property("usage_based_product",ar.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCredit:e.property("value_credit",ge.optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",he.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),warningTiers:e.property("warning_tiers",e.list(Ap))});var vi=e.enum_(["monthly","quarterly","yearly"]);var Vp=e.enum_(["published","draft","archived"]);var Re=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:pe,id:e.string(),name:e.string(),originalPlanId:e.property("original_plan_id",e.string().optional()),planType:e.property("plan_type",Q),status:Vp,updatedAt:e.property("updated_at",e.date()),version:e.number()});var ur=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(vi)),billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",tr.optional()),billingStrategy:e.property("billing_strategy",Fe),catalogs:e.list(Lr).optional(),chargeType:e.property("charge_type",Ke),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ge),currencyPrices:e.property("currency_prices",e.list(Gr)),customPlanConfig:e.property("custom_plan_config",Xo.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ie).optional(),features:e.list(Ge),icon:pe,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ke).optional()),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",L.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",L.optional()),planType:e.property("plan_type",Q),quarterlyPrice:e.property("quarterly_price",L.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(Re),yearlyPrice:e.property("yearly_price",L.optional())});var qp=e.object({addOns:e.property("add_ons",e.list(ur)),customPlanCtaText:e.property("custom_plan_cta_text",e.string().optional()),customPlanCtaUrl:e.property("custom_plan_cta_url",e.string().optional()),customPlanPriceText:e.property("custom_plan_price_text",e.string().optional()),customPlansVisible:e.property("custom_plans_visible",e.boolean()),orderedAddOns:e.property("ordered_add_ons",e.list(yn)),orderedBundles:e.property("ordered_bundles",e.list(vp)),orderedPlans:e.property("ordered_plans",e.list(yn)),plans:e.list(ur),pricingModel:e.property("pricing_model",e.string().optional()),pricingUrl:e.property("pricing_url",e.string().optional())});var Dp=e.object({data:qp,params:e.record(e.string(),e.unknown())});var Mp=e.object({creditBundleIds:e.property("credit_bundle_ids",e.list(e.string()))});var Ip=e.object({data:Mp,params:e.record(e.string(),e.unknown())});var Fp=e.object({icon:e.string(),id:e.string(),name:e.string()});var Kp=e.object({features:e.list(Fp)});var Lp=e.object({data:Kp,params:e.record(e.string(),e.unknown())});var Gp=e.object({planIds:e.property("plan_ids",e.list(e.string()))});var Wp=e.object({data:Gp,params:e.record(e.string(),e.unknown())});var Hp=e.object({isDefault:e.property("is_default",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Np=e.object({data:e.list(nr),params:Hp});var $p=e.object({data:nr,params:e.record(e.string(),e.unknown())});var Jp=e.object({data:nr,params:e.record(e.string(),e.unknown())});var wn=e.object({cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),prorate:e.boolean().optional()});var bn=e.object({companyId:e.property("company_id",e.string()),currency:e.string().optional(),selectedPlanId:e.property("selected_plan_id",e.string().optional())});var Ti=e.object({id:e.string(),value:e.string()});var Yp=e.object({city:e.string(),country:e.string(),line1:e.string(),line2:e.string(),postalCode:e.property("postal_code",e.string()),state:e.string()});var zn=e.object({address:Yp.optional(),email:e.string().optional(),phone:e.string().optional(),values:e.list(Ti)});var Rn=e.object({trialEnd:e.property("trial_end",e.date().optional())});var Oi=e.object({billingScheme:e.property("billing_scheme",or),billingThreshold:e.property("billing_threshold",e.number().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),environmentId:e.property("environment_id",e.string()),externalId:e.property("external_id",e.string()),id:e.string(),interval:e.string(),intervalCount:e.property("interval_count",e.number().optional()),meterId:e.property("meter_id",e.string().optional()),name:e.string(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),priceId:e.property("price_id",e.string()),priceTier:e.property("price_tier",e.list($o)),providerType:e.property("provider_type",k),quantity:e.number(),subscriptionId:e.property("subscription_id",e.string()),subscriptionItemExternalId:e.property("subscription_item_external_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",ce)});var ki=e.object({amountOff:e.property("amount_off",e.number().optional()),couponId:e.property("coupon_id",e.string()),couponName:e.property("coupon_name",e.string()),currency:e.string().optional(),customerFacingCode:e.property("customer_facing_code",e.string().optional()),discountExternalId:e.property("discount_external_id",e.string()),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number().optional()),endedAt:e.property("ended_at",e.date().optional()),isActive:e.property("is_active",e.boolean()),percentOff:e.property("percent_off",e.number().optional()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date()),subscriptionExternalId:e.property("subscription_external_id",e.string())});var zo=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),discounts:e.list(ki),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),latestInvoice:e.property("latest_invoice",Ve.optional()),metadata:e.record(e.string(),e.unknown()).optional(),paymentMethod:e.property("payment_method",qe.optional()),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),products:e.list(Oi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Vr.optional())});var Zp=e.object({accountId:e.property("account_id",e.string()),capturedAtMax:e.property("captured_at_max",e.date()),capturedAtMin:e.property("captured_at_min",e.date()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",N),period:W,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var Xp=e.enum_(["schematic_authoritative","external_mirror","external_rated"]);var Qp=e.object({currency:e.string(),price:H.optional()});var et=e.object({accountId:e.property("account_id",e.string()),burnStrategy:e.property("burn_strategy",qr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Qp)),defaultExpiryUnit:e.property("default_expiry_unit",G),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Dr),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:e.string().optional(),id:e.string(),ledgerAuthority:e.property("ledger_authority",Xp),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:H.optional(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),product:ar.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Bi=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var eu=e.object({billingCreditAutoTopupAmount:e.property("billing_credit_auto_topup_amount",e.number().optional()),billingCreditAutoTopupAmountType:e.property("billing_credit_auto_topup_amount_type",e.string().optional()),billingCreditAutoTopupAvailability:e.property("billing_credit_auto_topup_availability",sr.optional()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Z.optional()),billingCreditAutoTopupExpiryUnit:e.property("billing_credit_auto_topup_expiry_unit",G.optional()),billingCreditAutoTopupExpiryUnitCount:e.property("billing_credit_auto_topup_expiry_unit_count",e.number().optional()),billingCreditAutoTopupSelfService:e.property("billing_credit_auto_topup_self_service",e.boolean()),billingCreditAutoTopupThresholdCredits:e.property("billing_credit_auto_topup_threshold_credits",e.number().optional()),billingCreditAutoTopupThresholdPercent:e.property("billing_credit_auto_topup_threshold_percent",e.number().optional()),billingCreditCanBuyBundles:e.property("billing_credit_can_buy_bundles",e.boolean()),companyAutoTopupAmount:e.property("company_auto_topup_amount",e.number().optional()),companyAutoTopupEnabled:e.property("company_auto_topup_enabled",e.boolean().optional()),companyAutoTopupThresholdCredits:e.property("company_auto_topup_threshold_credits",e.number().optional()),createdAt:e.property("created_at",e.date()),credit:et.optional(),creditAmount:e.property("credit_amount",e.number()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Bi.optional(),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),resetCadence:e.property("reset_cadence",Oe.optional()),resetStart:e.property("reset_start",Ie.optional()),resetType:e.property("reset_type",cr),rolloverPercentage:e.property("rollover_percentage",e.number()),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var fn=e.object({addedOn:e.property("added_on",e.date().optional()),billingProductExternalId:e.property("billing_product_external_id",e.string().optional()),billingProductId:e.property("billing_product_id",e.string().optional()),description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),includedCreditGrants:e.property("included_credit_grants",e.list(eu)),name:e.string(),planPeriod:e.property("plan_period",e.string().optional()),planPrice:e.property("plan_price",e.number().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var ji=e.enum_(["on_payment","on_publish"]);var Cr=e.enum_(["active","expired","paid","pending"]);var Wr=e.object({activationStrategy:e.property("activation_strategy",ji),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),daysUntilDue:e.property("days_until_due",e.number()),externalInvoiceId:e.property("external_invoice_id",e.string().optional()),id:e.string(),paidAt:e.property("paid_at",e.date().optional()),planId:e.property("plan_id",e.string()),publishedAt:e.property("published_at",e.date().optional()),status:Cr,stripeInvoiceUrl:e.property("stripe_invoice_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var rt=e.object({createdAt:e.property("created_at",e.date()),entityType:e.property("entity_type",te),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date())});var it=e.object({createdAt:e.property("created_at",e.date()),definition:rt.optional(),definitionId:e.property("definition_id",e.string()),entityId:e.property("entity_id",e.string()),entityType:e.property("entity_type",te),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});var ot=e.object({createdAt:e.property("created_at",e.date()),definition:he.optional(),definitionId:e.property("definition_id",e.string()),environmentId:e.property("environment_id",e.string()),id:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});var ru=e.object({key:e.string(),value:e.number()});var tt=e.object({allocation:e.number().optional(),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditReserved:e.property("credit_reserved",e.number().optional()),creditSettled:e.property("credit_settled",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditUsed:e.property("credit_used",e.number().optional()),eventName:e.property("event_name",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",re),warningTiers:e.property("warning_tiers",e.list(ru).optional())});var iu=e.enum_(["bool","date","int","string"]);var _n=e.object({comparableType:e.property("comparable_type",iu),entityType:e.property("entity_type",te),id:e.string()});var at=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",_n.optional()),conditionType:e.property("condition_type",Ei),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ir,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",_n.optional()),traitValue:e.property("trait_value",e.string())});var ou=e.object({conditions:e.list(at)});var tu=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(ou)),conditions:e.list(at),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Fr),value:e.boolean()});var nt=e.object({currency:e.string(),effectiveAfter:e.property("effective_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),fromPlanName:e.property("from_plan_name",e.string()),fromSubscriptionPrice:e.property("from_subscription_price",e.number()),id:e.string(),interval:e.string(),scheduledInterval:e.property("scheduled_interval",e.string().optional()),scheduledPrice:e.property("scheduled_price",e.number().optional()),toPlanId:e.property("to_plan_id",e.string()),toPlanName:e.property("to_plan_name",e.string())});var X=e.object({addOns:e.property("add_ons",e.list(fn)),billingCreditBalances:e.property("billing_credit_balances",e.record(e.string(),e.number()).optional()),billingSubscription:e.property("billing_subscription",zo.optional()),billingSubscriptions:e.property("billing_subscriptions",e.list(zo)),createdAt:e.property("created_at",e.date()),customPlanBillings:e.property("custom_plan_billings",e.list(Wr)),defaultPaymentMethod:e.property("default_payment_method",qe.optional()),entitlements:e.list(tt),entityTraits:e.property("entity_traits",e.list(ot)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(it),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),metrics:e.list(Zp),name:e.string(),paymentMethods:e.property("payment_methods",e.list(qe)),plan:fn.optional(),plans:e.list(Bi),rules:e.list(tu),scheduledDowngrade:e.property("scheduled_downgrade",nt.optional()),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date()),userCount:e.property("user_count",e.number())});var st=e.object({company:X.optional(),success:e.boolean()});var au=e.object({data:st,params:e.record(e.string(),e.unknown())});var nu=e.object({applicationId:e.property("application_id",e.string().optional()),cancelAt:e.property("cancel_at",e.number().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),companyId:e.property("company_id",e.string().optional()),confirmPaymentIntentClientSecret:e.property("confirm_payment_intent_client_secret",e.string().optional()),confirmPaymentIntentId:e.property("confirm_payment_intent_id",e.string().optional()),createdAt:e.property("created_at",e.date()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),defaultPaymentMethodId:e.property("default_payment_method_id",e.string().optional()),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),invoiceId:e.property("invoice_id",e.string().optional()),invoiceUrl:e.property("invoice_url",e.string().optional()),metadata:e.record(e.string(),e.unknown()).optional(),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.number().optional()),trialEndSetting:e.property("trial_end_setting",Vr.optional())});var su=e.object({data:nu,params:e.record(e.string(),e.unknown())});var Ee=e.enum_(["active","inactive"]);var De=e.stringLiteral("fixed");var cu=e.object({currency:e.string(),price:L.optional()});var We=e.object({billingInvoiceId:e.property("billing_invoice_id",e.string().optional()),bundleType:e.property("bundle_type",De),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string().optional()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currencyPrices:e.property("currency_prices",e.list(cu)),expiryType:e.property("expiry_type",Z),expiryUnit:e.property("expiry_unit",G),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),hasGrants:e.property("has_grants",e.boolean()),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:L.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Ee,unitPrice:e.property("unit_price",L.optional()),updatedAt:e.property("updated_at",e.date())});var Ai=e.object({definitionId:e.property("definition_id",e.string()),helperText:e.property("helper_text",e.string().optional()),id:e.string(),name:e.string(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string()),value:e.string().optional()});var Vi=e.object({cancelAt:e.property("cancel_at",e.date().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),discounts:e.list(ki),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",Ve.optional()),paymentMethod:e.property("payment_method",qe.optional()),products:e.list(Oi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.date().optional())});var lu=e.object({bundle:We.optional(),quantity:e.number(),total:e.number()});var Be=e.enum_(["adjustment","billing_credit_auto_topup","free","plan","purchased","rollover"]);var pu=e.object({createdAt:e.property("created_at",e.date()),externalUserId:e.property("external_user_id",e.string()),externalUserName:e.property("external_user_name",e.string()),id:e.string(),note:e.string(),updatedAt:e.property("updated_at",e.date())});var He=e.object({company:X.optional(),companyId:e.property("company_id",e.string()),consumptionRate:e.property("consumption_rate",e.number().optional()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),expirationDate:e.property("expiration_date",e.date().optional()),feature:Mr.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),notes:e.list(pu),ruleId:e.property("rule_id",e.string().optional()),ruleIdUsageExceeded:e.property("rule_id_usage_exceeded",e.string().optional()),updatedAt:e.property("updated_at",e.date()),valueBool:e.property("value_bool",e.boolean().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",he.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re)});var qi=e.object({creditTypeIcon:e.property("credit_type_icon",e.string().optional()),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",Be),quantity:e.number()});var Di=e.object({usageThisBillingPeriod:e.property("usage_this_billing_period",e.number().optional()),usageThisCalendarMonth:e.property("usage_this_calendar_month",e.number().optional()),usageThisWeek:e.property("usage_this_week",e.number().optional()),usageToday:e.property("usage_today",e.number().optional())});var Hr=e.enum_(["company_override","plan_entitlement","unknown"]);var Nr=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",re),companyOverride:e.property("company_override",He.optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(qi).optional()),creditGrantReason:e.property("credit_grant_reason",Be.optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditUsageAggregation:e.property("credit_usage_aggregation",Di.optional()),creditUsed:e.property("credit_used",e.number().optional()),effectiveLimit:e.property("effective_limit",e.number().optional()),effectivePrice:e.property("effective_price",e.number().optional()),entitlementExpirationDate:e.property("entitlement_expiration_date",e.date().optional()),entitlementId:e.property("entitlement_id",e.string()),entitlementSource:e.property("entitlement_source",e.string().optional()),entitlementType:e.property("entitlement_type",Hr),feature:Ge.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:W.optional(),plan:pr.optional(),planEntitlement:e.property("plan_entitlement",ie.optional()),priceBehavior:e.property("price_behavior",ze.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",H.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",H.optional())});var Mi=e.object({features:e.list(Nr)});var we=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",tr.optional()),billingStrategy:e.property("billing_strategy",Fe),catalogs:e.list(Lr).optional(),chargeType:e.property("charge_type",Ke),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ge),currencyPrices:e.property("currency_prices",e.list(Gr)),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ie).optional(),features:e.list(Ge),icon:pe,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ke).optional()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",L.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",L.optional()),planType:e.property("plan_type",Q),quarterlyPrice:e.property("quarterly_price",L.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(Re),yearlyPrice:e.property("yearly_price",L.optional())});var Ro=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),featureId:e.property("feature_id",e.string()),meteredPrice:e.property("metered_price",H.optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),priceBehavior:e.property("price_behavior",ze.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",H.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueType:e.property("value_type",re),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",H.optional())});var uu=e.object({activeAddOns:e.property("active_add_ons",e.list(we)),activePlan:e.property("active_plan",we.optional()),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(Ro)),availableCreditBundles:e.property("available_credit_bundles",e.list(We)),company:X.optional(),customCheckoutFields:e.property("custom_checkout_fields",e.list(Ai)),featureUsage:e.property("feature_usage",Mi.optional()),selectedCreditBundles:e.property("selected_credit_bundles",e.list(lu)),selectedPlan:e.property("selected_plan",we.optional()),selectedUsageBasedEntitlements:e.property("selected_usage_based_entitlements",e.list(Ro)),subscription:Vi.optional()});var du=e.object({data:uu,params:e.record(e.string(),e.unknown())});var mu=e.object({city:e.string(),country:e.string(),line1:e.string(),line2:e.string(),postalCode:e.property("postal_code",e.string()),state:e.string()});var hu=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean())});var ct=e.object({address:mu.optional(),checkoutSettings:e.property("checkout_settings",hu),customFields:e.property("custom_fields",e.list(Ai)),email:e.string().optional(),phone:e.string().optional()});var gu=e.object({data:ct,params:e.record(e.string(),e.unknown())});var yu=e.object({data:st,params:e.record(e.string(),e.unknown())});var wu=e.object({amountOff:e.property("amount_off",e.number().optional()),couponName:e.property("coupon_name",e.string()),currency:e.string().optional(),customerFacingCode:e.property("customer_facing_code",e.string().optional()),duration:e.string(),durationInMonths:e.property("duration_in_months",e.number().optional()),endedAt:e.property("ended_at",e.date().optional()),isActive:e.property("is_active",e.boolean()),percentOff:e.property("percent_off",e.number().optional()),promoCodeExternalId:e.property("promo_code_external_id",e.string().optional()),startedAt:e.property("started_at",e.date())});var bu=e.object({amount:e.number(),description:e.string(),priceId:e.property("price_id",e.string()),proration:e.boolean(),quantity:e.number()});var zu=e.object({amountOff:e.property("amount_off",e.number()),discounts:e.list(wu),dueNow:e.property("due_now",e.number()),newCharges:e.property("new_charges",e.number()),percentOff:e.property("percent_off",e.number()),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date()),promoCodeApplied:e.property("promo_code_applied",e.boolean()),proration:e.number(),taxAmount:e.property("tax_amount",e.number().optional()),taxDisplayName:e.property("tax_display_name",e.string().optional()),taxRequireBillingDetails:e.property("tax_require_billing_details",e.boolean()),totalPerBillingPeriod:e.property("total_per_billing_period",e.number()),trialEnd:e.property("trial_end",e.date().optional()),upcomingInvoiceLineItems:e.property("upcoming_invoice_line_items",e.list(bu))});var lt=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),finance:zu.optional(),isScheduledDowngrade:e.property("is_scheduled_downgrade",e.boolean()),newCharges:e.property("new_charges",e.number()),optInRequired:e.property("opt_in_required",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),paymentMethodRequired:e.property("payment_method_required",e.boolean()),percentOff:e.property("percent_off",e.number()),periodStart:e.property("period_start",e.date()),promoCodeApplied:e.property("promo_code_applied",e.boolean()),proration:e.number(),scheduledChangeTime:e.property("scheduled_change_time",e.date().optional()),trialEnd:e.property("trial_end",e.date().optional()),usageViolations:e.property("usage_violations",e.list(Nr))});var Ru=e.object({data:lt,params:e.record(e.string(),e.unknown())});var fu=e.object({subscriptionChangePreview:e.property("subscription_change_preview",lt.optional())});var _u=e.object({data:fu,params:e.record(e.string(),e.unknown())});var Su=e.object({data:ct,params:e.record(e.string(),e.unknown())});var Pu=e.object({data:zo,params:e.record(e.string(),e.unknown())});var Sn=e.object({displayName:e.property("display_name",e.string().optional()),entityType:e.property("entity_type",te),hierarchy:e.list(e.string()),traitType:e.property("trait_type",me)});var Pn=e.object({companyId:e.property("company_id",e.string()),userId:e.property("user_id",e.string())});var xn=e.object({displayName:e.property("display_name",e.string().optional()),traitType:e.property("trait_type",me)});var xu=e.object({traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string())});var Cn=e.object({applyToExistingCompanies:e.property("apply_to_existing_companies",e.boolean()),planId:e.property("plan_id",e.string()),traits:e.list(xu)});var je=e.enum_(["asc","desc"]);var Er=e.enum_(["active","canceled","expired","incomplete","incomplete_expired","past_due","paused","trialing","unpaid"]);var Ur=e.enum_(["free","one_time","paid","trial"]);var Cu=e.object({creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",je.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(Er).optional()),subscriptionTypes:e.property("subscription_types",e.list(Ur).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var Eu=e.object({data:q,params:Cu});var Uu=e.object({entityType:e.property("entity_type",te.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var vu=e.object({data:q,params:Uu});var Tu=e.object({entityType:e.property("entity_type",te.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",me.optional()),traitTypes:e.property("trait_types",e.list(me).optional())});var Ou=e.object({data:q,params:Tu});var ku=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),traitIds:e.property("trait_ids",e.list(e.string()).optional())});var Bu=e.object({data:q,params:ku});var ju=e.object({companyId:e.property("company_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Au=e.object({data:q,params:ju});var Vu=e.object({data:X,params:e.record(e.string(),e.unknown())});var dr=e.object({createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Ii=e.object({company:dr.optional(),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),id:e.string(),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string())});var Ne=e.object({companyMemberships:e.property("company_memberships",e.list(Ii)),createdAt:e.property("created_at",e.date()),entityTraits:e.property("entity_traits",e.list(ot)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(it),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string(),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date())});var qu=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Du=e.object({data:dr,params:e.record(e.string(),e.unknown())});var Mu=e.object({data:F,params:e.record(e.string(),e.unknown())});var Iu=e.object({cancelSubscription:e.property("cancel_subscription",e.boolean().optional()),prorate:e.boolean().optional()});var Fu=e.object({data:F,params:Iu});var pt=e.object({createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Ku=e.object({data:pt,params:e.record(e.string(),e.unknown())});var Lu=e.object({data:F,params:e.record(e.string(),e.unknown())});var Gu=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional()});var Wu=e.object({data:e.list(Vi),params:Gu});var Hu=e.object({companyId:e.property("company_id",e.string().optional())});var Nu=e.object({cancelAt:e.property("cancel_at",e.date().optional()),cancelAtPeriodEnd:e.property("cancel_at_period_end",e.boolean()),company:dr.optional(),currency:e.string(),customerExternalId:e.property("customer_external_id",e.string()),discounts:e.list(ki),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",Ve.optional()),paymentMethod:e.property("payment_method",qe.optional()),planName:e.property("plan_name",e.string()),products:e.list(Oi),providerType:e.property("provider_type",k),status:e.string(),subscriptionExternalId:e.property("subscription_external_id",e.string()),totalPrice:e.property("total_price",e.number()),trialEnd:e.property("trial_end",e.date().optional())});var $u=e.object({data:e.list(Nu),params:Hu});var Ju=e.object({companyId:e.property("company_id",e.string().optional())});var Yu=e.object({billingEntity:e.property("billing_entity",dr.optional()),hasOwnStripeCustomer:e.property("has_own_stripe_customer",e.boolean())});var Zu=e.object({data:e.list(Yu),params:Ju});var Xu=e.object({data:X,params:e.record(e.string(),e.unknown())});var Qu=e.object({data:he,params:e.record(e.string(),e.unknown())});var ed=e.object({definitionId:e.property("definition_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var rd=e.object({definitionId:e.property("definition_id",e.string()),value:e.string()});var id=e.object({data:e.list(rd),params:ed});var od=e.object({data:Ii,params:e.record(e.string(),e.unknown())});var td=e.object({data:he,params:e.record(e.string(),e.unknown())});var ut=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Me,type:Se,updatedAt:e.property("updated_at",e.date())});var Fi=e.enum_(["checkout","company_upsert","fallback_plan","manage_plan","migration","plan_billing_product_changed","plan_deleted","plan_trait_change","plan_version_migration","quickstart","subscription_change"]);var Ki=e.enum_(["fallback","initial","trait","trial_expiry"]);var ad=e.enum_(["adjustment","downgrade","invalid","subscribe","unsubscribe","upgrade","upgrade_trial"]);var fo=e.object({deleted:e.boolean(),description:e.string(),icon:e.string(),id:e.string(),name:e.string()});var En=e.object({id:e.string(),name:e.string(),version:e.number()});var nd=e.object({featureId:e.property("feature_id",e.string()),hierarchy:e.list(e.string()),reason:e.string(),traitId:e.property("trait_id",e.string()),traitName:e.property("trait_name",e.string()),traitType:e.property("trait_type",me),value:e.string()});var dt=e.object({action:Fi,actorType:e.property("actor_type",Ce),addOnsAdded:e.property("add_ons_added",e.list(fo)),addOnsRemoved:e.property("add_ons_removed",e.list(fo)),apiKey:e.property("api_key",xe.optional()),auditLog:e.property("audit_log",Ho.optional()),basePlan:e.property("base_plan",fo.optional()),basePlanAction:e.property("base_plan_action",Ki.optional()),basePlanVersion:e.property("base_plan_version",En.optional()),company:dr.optional(),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),integration:ut.optional(),isVersionUpgrade:e.property("is_version_upgrade",e.boolean()),previousBasePlan:e.property("previous_base_plan",fo.optional()),previousBasePlanVersion:e.property("previous_base_plan_version",En.optional()),requestId:e.property("request_id",e.string().optional()),subscriptionChangeAction:e.property("subscription_change_action",ad.optional()),traitsUpdated:e.property("traits_updated",e.list(nd)),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var sd=e.object({data:dt,params:e.record(e.string(),e.unknown())});var Li=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),id:e.string(),planId:e.property("plan_id",e.string()),planType:e.property("plan_type",e.string()),traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var cd=e.object({data:Li,params:e.record(e.string(),e.unknown())});var ld=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var pd=e.object({creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),sortOrderColumn:e.property("sort_order_column",e.string().optional()),sortOrderDirection:e.property("sort_order_direction",je.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(Er).optional()),subscriptionTypes:e.property("subscription_types",e.list(Ur).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var ud=e.object({data:e.list(X),params:pd});var dd=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),userId:e.property("user_id",e.string().optional())});var md=e.object({data:e.list(Ii),params:dd});var hd=e.object({entityType:e.property("entity_type",te.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var gd=e.object({data:e.list(rt),params:hd});var yd=e.object({entityType:e.property("entity_type",te.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",me.optional()),traitTypes:e.property("trait_types",e.list(me).optional())});var wd=e.object({data:e.list(he),params:yd});var bd=e.object({action:Fi.optional(),basePlanAction:e.property("base_plan_action",Ki.optional()),companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional(),planIds:e.property("plan_ids",e.list(e.string()).optional())});var zd=e.object({data:e.list(dt),params:bd});var Rd=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),traitId:e.property("trait_id",e.string().optional()),traitIds:e.property("trait_ids",e.list(e.string()).optional())});var fd=e.object({data:e.list(Li),params:Rd});var _d=e.object({companyId:e.property("company_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Sd=e.object({data:e.list(Ne),params:_d});var Pd=e.object({keys:e.record(e.string(),e.string()).optional()});var xd=e.object({data:X,params:Pd});var Cd=e.object({keys:e.record(e.string(),e.string()).optional()});var Ed=e.object({data:Ne,params:Cd});var Ud=e.object({data:he,params:e.record(e.string(),e.unknown())});var vd=e.object({data:e.list(Li),params:e.record(e.string(),e.unknown())});var Td=e.object({data:X,params:e.record(e.string(),e.unknown())});var Od=e.object({data:X,params:e.record(e.string(),e.unknown())});var kd=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Bd=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Un=e.object({catalogId:e.property("catalog_id",e.string().optional())});var Gi=e.enum_(["billing","entitlement"]);var vn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Gi),name:e.string()});var mt=e.enum_(["draft","live"]);var Tn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Gi.optional()),name:e.string().optional(),state:mt.optional()});var $e=e.object({ast:e.record(e.string(),e.number()).optional(),catalogId:e.property("catalog_id",e.string().optional()),createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),state:mt,type:Gi,updatedAt:e.property("updated_at",e.date())});var jd=e.object({data:$e,params:e.record(e.string(),e.unknown())});var Ad=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Vd=e.object({data:q,params:Ad});var qd=e.object({data:$e,params:e.record(e.string(),e.unknown())});var Dd=e.object({data:F,params:e.record(e.string(),e.unknown())});var Md=e.object({data:$e,params:e.record(e.string(),e.unknown())});var Id=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Fd=e.object({data:e.list($e),params:Id});var Kd=e.object({companyId:e.property("company_id",e.string().optional()),componentId:e.property("component_id",e.string().optional())});var _o=e.object({billingScheme:e.property("billing_scheme",or),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:xi,intervalCount:e.property("interval_count",e.number()),isActive:e.property("is_active",e.boolean()),meterId:e.property("meter_id",e.string().optional()),nickname:e.string().optional(),packageSize:e.property("package_size",e.number()),price:e.number(),priceDecimal:e.property("price_decimal",e.string().optional()),priceExternalId:e.property("price_external_id",e.string()),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k),tiersMode:e.property("tiers_mode",de.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",ce)});var Ld=e.object({currency:e.string(),price:H.optional()});var Gd=e.object({bundleType:e.property("bundle_type",De),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string().optional()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currencyPrices:e.property("currency_prices",e.list(Ld)),expiryType:e.property("expiry_type",Z),expiryUnit:e.property("expiry_unit",G),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),hasGrants:e.property("has_grants",e.boolean()),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:_o.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Ee,unitPrice:e.property("unit_price",_o.optional()),updatedAt:e.property("updated_at",e.date())});var Wd=e.enum_(["downgrade_not_permitted","feature_usage_exceeded"]);var $r=e.object({ctaText:e.property("cta_text",e.string()),ctaWebSite:e.property("cta_web_site",e.string()),priceText:e.property("price_text",e.string())});var ht=e.object({billingCreditAutoTopupAmount:e.property("billing_credit_auto_topup_amount",e.number().optional()),billingCreditAutoTopupAmountType:e.property("billing_credit_auto_topup_amount_type",e.string().optional()),billingCreditAutoTopupAvailability:e.property("billing_credit_auto_topup_availability",sr.optional()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Z.optional()),billingCreditAutoTopupExpiryUnit:e.property("billing_credit_auto_topup_expiry_unit",G.optional()),billingCreditAutoTopupExpiryUnitCount:e.property("billing_credit_auto_topup_expiry_unit_count",e.number().optional()),billingCreditAutoTopupSelfService:e.property("billing_credit_auto_topup_self_service",e.boolean()),billingCreditAutoTopupThresholdCredits:e.property("billing_credit_auto_topup_threshold_credits",e.number().optional()),billingCreditAutoTopupThresholdPercent:e.property("billing_credit_auto_topup_threshold_percent",e.number().optional()),billingCreditCanBuyBundles:e.property("billing_credit_can_buy_bundles",e.boolean()),createdAt:e.property("created_at",e.date()),credit:et.optional(),creditAmount:e.property("credit_amount",e.number()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Bi.optional(),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),resetCadence:e.property("reset_cadence",Oe.optional()),resetStart:e.property("reset_start",Ie.optional()),resetType:e.property("reset_type",cr),rolloverPercentage:e.property("rollover_percentage",e.number()),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var On=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(vi)),billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",tr.optional()),billingStrategy:e.property("billing_strategy",Fe),catalogs:e.list(Lr).optional(),chargeType:e.property("charge_type",Ke),companyCanTrial:e.property("company_can_trial",e.boolean()),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ge),currencyPrices:e.property("currency_prices",e.list(Gr)),current:e.boolean(),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",$r.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ie).optional(),features:e.list(Ge),icon:pe,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ht)),invalidReason:e.property("invalid_reason",Wd.optional()),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",L.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",L.optional()),planType:e.property("plan_type",Q),quarterlyPrice:e.property("quarterly_price",L.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageViolations:e.property("usage_violations",e.list(Nr)),valid:e.boolean(),versions:e.list(Re),yearlyPrice:e.property("yearly_price",L.optional())});var Jr=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var gt=e.object({badgeVisibility:e.property("badge_visibility",e.boolean()),checkout:e.boolean()});var Hd=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean())});var yt=e.object({showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var Yr=e.enum_(["customer_archived","expired","integration_uninstalled","license_retired","manual","plan_change","plan_period_reset","reconciled"]);var Nd=e.object({amount:e.number(),createdAt:e.property("created_at",e.date()),direction:e.string(),id:e.string(),reason:e.string(),relatedGrantId:e.property("related_grant_id",e.string())});var $d=e.object({billingCreditBundleId:e.property("billing_credit_bundle_id",e.string().optional()),billingCreditId:e.property("billing_credit_id",e.string()),companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),createdAt:e.property("created_at",e.date()),creditDescription:e.property("credit_description",e.string()),creditIcon:e.property("credit_icon",e.string().optional()),creditName:e.property("credit_name",e.string()),currency:e.string().optional(),exhaustedAt:e.property("exhausted_at",e.date().optional()),expiresAt:e.property("expires_at",e.date().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),grantReason:e.property("grant_reason",Be),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),price:_o.optional(),quantity:e.number(),quantityRemaining:e.property("quantity_remaining",e.number()),quantityUsed:e.property("quantity_used",e.number()),renewalEnabled:e.property("renewal_enabled",e.boolean()),renewalPeriod:e.property("renewal_period",Oe.optional()),reserved:e.number().optional(),settled:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),sourceGrantId:e.property("source_grant_id",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(Nd).optional(),updatedAt:e.property("updated_at",e.date()),validFrom:e.property("valid_from",e.date().optional()),zeroedOutDate:e.property("zeroed_out_date",e.date().optional()),zeroedOutReason:e.property("zeroed_out_reason",Yr.optional())});var Jd=e.object({accountId:e.property("account_id",e.string().optional()),publishableKey:e.property("publishable_key",e.string().optional()),schematicPublishableKey:e.property("schematic_publishable_key",e.string()),setupIntentClientSecret:e.property("setup_intent_client_secret",e.string().optional())});var Yd=e.object({activeAddOns:e.property("active_add_ons",e.list(On)),activePlans:e.property("active_plans",e.list(On)),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(Ro)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Jr)),capabilities:gt.optional(),checkoutSettings:e.property("checkout_settings",Hd),company:X.optional(),component:$e.optional(),creditBundles:e.property("credit_bundles",e.list(Gd)),creditGrants:e.property("credit_grants",e.list($d)),customCheckoutFields:e.property("custom_checkout_fields",e.list(Ai)),defaultPlan:e.property("default_plan",we.optional()),displaySettings:e.property("display_settings",yt),featureUsage:e.property("feature_usage",Mi.optional()),invoices:e.list(Ve),postTrialPlan:e.property("post_trial_plan",we.optional()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),scheduledDowngrade:e.property("scheduled_downgrade",nt.optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),stripeEmbed:e.property("stripe_embed",Jd.optional()),subscription:Vi.optional(),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional()),upcomingInvoice:e.property("upcoming_invoice",Ve.optional())});var Zd=e.object({data:Yd,params:Kd});var Xd=e.object({data:$e,params:e.record(e.string(),e.unknown())});var kn=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(vi)),billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",tr.optional()),billingStrategy:e.property("billing_strategy",Fe),catalogs:e.list(Lr).optional(),chargeType:e.property("charge_type",Ke),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",e.string().optional()),companyLogoUrl:e.property("company_logo_url",e.string().optional()),companyName:e.property("company_name",e.string().optional()),compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),controlledBy:e.property("controlled_by",k),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),createdAt:e.property("created_at",e.date()),credits:e.list(ge),currencyPrices:e.property("currency_prices",e.list(Gr)),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",$r.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ie).optional(),features:e.list(Ge),icon:pe,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ht)),isCustom:e.property("is_custom",e.boolean()),isDefault:e.property("is_default",e.boolean()),isFree:e.property("is_free",e.boolean()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",L.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",L.optional()),planType:e.property("plan_type",Q),quarterlyPrice:e.property("quarterly_price",L.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),versions:e.list(Re),yearlyPrice:e.property("yearly_price",L.optional())});var Qd=e.object({activeAddOns:e.property("active_add_ons",e.list(kn)),activePlans:e.property("active_plans",e.list(kn)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Jr)),capabilities:gt.optional(),displaySettings:e.property("display_settings",yt),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var em=e.object({data:Qd,params:e.record(e.string(),e.unknown())});var Bn=e.object({companyId:e.property("company_id",e.string()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date().optional()),requestedAmount:e.property("requested_amount",e.number())});var wt=e.object({currency:e.string(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional())});var jn=e.object({burnStrategy:e.property("burn_strategy",qr.optional()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(wt).optional()),defaultExpiryUnit:e.property("default_expiry_unit",G.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Dr.optional()),description:e.string(),icon:e.string().optional(),name:e.string(),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var An=e.object({billingPeriodsCount:e.property("billing_periods_count",e.number().optional()),companyId:e.property("company_id",e.string()),creditId:e.property("credit_id",e.string()),currency:e.string().optional(),expiresAt:e.property("expires_at",e.date().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),quantity:e.number(),reason:Be,renewalEnabled:e.property("renewal_enabled",e.boolean().optional()),renewalPeriod:e.property("renewal_period",Ie.optional())});var bt=e.object({currency:e.string(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional())});var Vn=e.object({bundleName:e.property("bundle_name",e.string()),bundleType:e.property("bundle_type",De.optional()),creditId:e.property("credit_id",e.string()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(bt).optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),pricePerUnit:e.property("price_per_unit",e.number()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),quantity:e.number().optional(),status:Ee.optional()});var qn=e.object({additionalAmount:e.property("additional_amount",e.number()),expiresAt:e.property("expires_at",e.date().optional())});var Dn=e.object({burnStrategy:e.property("burn_strategy",qr.optional()),currencyPrices:e.property("currency_prices",e.list(wt).optional()),defaultExpiryUnit:e.property("default_expiry_unit",G.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Dr.optional()),description:e.string(),icon:e.string().optional(),name:e.string(),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var Mn=e.object({bundleName:e.property("bundle_name",e.string()),currencyPrices:e.property("currency_prices",e.list(bt).optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),pricePerUnit:e.property("price_per_unit",e.number()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),quantity:e.number().optional(),status:Ee.optional()});var In=e.object({reason:Yr.optional()});var Wi=e.object({companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date()),grantedAmount:e.property("granted_amount",e.number()),id:e.string(),releasedAt:e.property("released_at",e.date().optional()),updatedAt:e.property("updated_at",e.date())});var rm=e.object({data:Wi,params:e.record(e.string(),e.unknown())});var im=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var om=e.object({data:q,params:im});var tm=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var am=e.object({data:q,params:tm});var nm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional())});var sm=e.object({data:q,params:nm});var ui=e.enum_(["created_at","expires_at","quantity","quantity_remaining"]);var cm=e.object({companyId:e.property("company_id",e.string().optional()),dir:je.optional(),limit:e.number().optional(),offset:e.number().optional(),order:ui.optional()});var lm=e.object({data:q,params:cm});var pm=e.object({bundleType:e.property("bundle_type",De.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:Ee.optional()});var um=e.object({data:q,params:pm});var vr=e.enum_(["grant","transfer","usage","zero_out"]);var dm=e.object({billingCreditId:e.property("billing_credit_id",e.string().optional()),companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.string().optional()),eventType:e.property("event_type",vr.optional()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),startTime:e.property("start_time",e.string().optional())});var mm=e.object({data:q,params:dm});var hm=e.object({data:ge,params:e.record(e.string(),e.unknown())});var gm=e.object({data:ke,params:e.record(e.string(),e.unknown())});var ym=e.object({data:We,params:e.record(e.string(),e.unknown())});var wm=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var bm=e.object({data:F,params:wm});var zm=e.object({data:F,params:e.record(e.string(),e.unknown())});var Rm=e.object({data:Wi,params:e.record(e.string(),e.unknown())});var fm=e.object({data:We,params:e.record(e.string(),e.unknown())});var _m=e.object({data:ge,params:e.record(e.string(),e.unknown())});var Sm=e.object({data:ke,params:e.record(e.string(),e.unknown())});var Pm=e.object({amount:e.number(),createdAt:e.property("created_at",e.date()),direction:e.string(),id:e.string(),reason:e.string(),relatedGrantId:e.property("related_grant_id",e.string())});var Zr=e.object({companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),createdAt:e.property("created_at",e.date()),creditIcon:e.property("credit_icon",e.string().optional()),creditId:e.property("credit_id",e.string()),creditName:e.property("credit_name",e.string()),currency:e.string().optional(),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",Be),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),price:L.optional(),quantity:e.number(),quantityRemaining:e.property("quantity_remaining",e.number()),quantityUsed:e.property("quantity_used",e.number()),renewalEnabled:e.property("renewal_enabled",e.boolean()),renewalPeriod:e.property("renewal_period",Oe.optional()),reserved:e.number().optional(),settled:e.number().optional(),sourceGrantId:e.property("source_grant_id",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(Pm).optional(),updatedAt:e.property("updated_at",e.date()),validFrom:e.property("valid_from",e.date().optional()),zeroedOutDate:e.property("zeroed_out_date",e.date().optional()),zeroedOutReason:e.property("zeroed_out_reason",Yr.optional())});var xm=e.object({data:Zr,params:e.record(e.string(),e.unknown())});var Cm=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Em=e.object({data:e.list(ge),params:Cm});var Um=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional())});var vm=e.object({data:e.list(ke),params:Um});var Tm=e.object({companyId:e.property("company_id",e.string().optional())});var Om=e.object({creditId:e.property("credit_id",e.string()),remaining:e.number(),reserved:e.number(),settled:e.number(),source:k,total:e.number().optional()});var km=e.object({data:e.list(Om),params:Tm});var Bm=e.object({companyId:e.property("company_id",e.string().optional()),dir:je.optional(),limit:e.number().optional(),offset:e.number().optional(),order:ui.optional()});var jm=e.object({data:e.list(Zr),params:Bm});var Am=e.object({bundleType:e.property("bundle_type",De.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:Ee.optional()});var Vm=e.object({data:e.list(We),params:Am});var qm=e.object({billingCreditId:e.property("billing_credit_id",e.string().optional()),companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.string().optional()),eventType:e.property("event_type",vr.optional()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),startTime:e.property("start_time",e.string().optional())});var Dm=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional())});var Mm=e.object({id:e.string(),logoUrl:e.property("logo_url",e.string().optional()),name:e.string()});var Im=e.enum_(["lease_hold","lease_release","manual_adjustment","reconciliation","track"]);var Fm=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string()});var Km=e.object({amount:e.number(),autoTopupLogId:e.property("auto_topup_log_id",e.string().optional()),billingCreditBundleId:e.property("billing_credit_bundle_id",e.string().optional()),billingCreditId:e.property("billing_credit_id",e.string()),company:Mm.optional(),companyId:e.property("company_id",e.string()),credit:Dm.optional(),creditName:e.property("credit_name",e.string()),environmentId:e.property("environment_id",e.string()),eventAt:e.property("event_at",e.date()),eventId:e.property("event_id",e.string()),eventType:e.property("event_type",vr),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),feature:Fm.optional(),featureId:e.property("feature_id",e.string().optional()),fromGrantId:e.property("from_grant_id",e.string().optional()),grantExpiresAt:e.property("grant_expires_at",e.date().optional()),grantId:e.property("grant_id",e.string().optional()),grantQuantity:e.property("grant_quantity",e.number().optional()),grantQuantityRemaining:e.property("grant_quantity_remaining",e.number().optional()),grantReason:e.property("grant_reason",Be.optional()),grantValidFrom:e.property("grant_valid_from",e.date().optional()),planId:e.property("plan_id",e.string().optional()),quantityConsumed:e.property("quantity_consumed",e.number().optional()),quantityRemainingAtZeroOut:e.property("quantity_remaining_at_zero_out",e.number().optional()),sourceId:e.property("source_id",e.number()),toGrantId:e.property("to_grant_id",e.string().optional()),usageEventId:e.property("usage_event_id",e.string().optional()),usageReason:e.property("usage_reason",Im.optional()),zeroedOutReason:e.property("zeroed_out_reason",Yr.optional())});var Lm=e.object({data:e.list(Km),params:qm});var Gm=e.object({creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var Wm=e.object({data:e.list(Zr),params:Gm});var Hm=e.object({data:Wi,params:e.record(e.string(),e.unknown())});var Nm=e.object({data:F,params:e.record(e.string(),e.unknown())});var $m=e.object({data:ge,params:e.record(e.string(),e.unknown())});var Jm=e.object({data:ke,params:e.record(e.string(),e.unknown())});var Ym=e.object({data:We,params:e.record(e.string(),e.unknown())});var Zm=e.object({data:Zr,params:e.record(e.string(),e.unknown())});var Xm=e.object({actorType:e.property("actor_type",e.string().optional()),endTime:e.property("end_time",e.date().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var Qm=e.object({companyIds:e.property("company_ids",e.list(e.string()).optional()),creditTypeIds:e.property("credit_type_ids",e.list(e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string())),hasScheduledDowngrade:e.property("has_scheduled_downgrade",e.boolean().optional()),monetizedSubscriptions:e.property("monetized_subscriptions",e.boolean().optional()),notificationEmailRecipientEmailAddresses:e.property("notification_email_recipient_email_addresses",e.list(e.string()).optional()),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),subscriptionStatuses:e.property("subscription_statuses",e.list(e.string()).optional()),subscriptionTypes:e.property("subscription_types",e.list(e.string()).optional()),withEntitlementFor:e.property("with_entitlement_for",e.string().optional()),withSubscription:e.property("with_subscription",e.boolean().optional()),withoutFeatureOverrideFor:e.property("without_feature_override_for",e.string().optional()),withoutPlan:e.property("without_plan",e.boolean().optional()),withoutSubscription:e.property("without_subscription",e.boolean().optional())});var zt=e.union(e.discriminant("exportType","export_type"),{"audit-log":Xm,"company-feature-usage":Qm}).transform({transform:p=>p,untransform:p=>p});var Rt=e.enum_(["csv","csv.gz"]);var Xr=e.enum_(["audit-log","company-feature-usage"]);var Fn=e.object({exportType:e.property("export_type",Xr),metadata:zt.optional(),outputFileType:e.property("output_file_type",Rt)});var Hi=e.enum_(["failure","pending","success"]);var Ni=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),exportType:e.property("export_type",Xr),id:e.string(),metadata:zt.optional(),outputFileType:e.property("output_file_type",Rt),status:Hi,updatedAt:e.property("updated_at",e.date())});var eh=e.object({data:Ni,params:e.record(e.string(),e.unknown())});var rh=e.object({data:Ni,params:e.record(e.string(),e.unknown())});var ih=e.object({exportType:e.property("export_type",Xr.optional()),limit:e.number().optional(),offset:e.number().optional(),status:Hi.optional()});var oh=e.object({data:e.list(Ni),params:ih});var ae=e.object({flatAmount:e.property("flat_amount",e.number().optional()),perUnitPrice:e.property("per_unit_price",e.number().optional()),perUnitPriceDecimal:e.property("per_unit_price_decimal",e.string().optional()),upTo:e.property("up_to",e.number().optional())});var Qr=e.object({currency:e.string(),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var ei=e.object({key:e.string(),value:e.number()});var Kn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingProvider:e.property("billing_provider",k),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Qr).optional()),externalResourceId:e.property("external_resource_id",e.string()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional()),priceTiers:e.property("price_tiers",e.list(ae).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),warningTiers:e.property("warning_tiers",e.list(ei).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Ln=e.object({companyId:e.property("company_id",e.string()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re)});var Gn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Qr).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional()),priceTiers:e.property("price_tiers",e.list(ae).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),warningTiers:e.property("warning_tiers",e.list(ei).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Wn=e.object({sourcePlanId:e.property("source_plan_id",e.string()),targetPlanId:e.property("target_plan_id",e.string())});var Hn=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re)});var Nn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Qr).optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional()),priceTiers:e.property("price_tiers",e.list(ae).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),warningTiers:e.property("warning_tiers",e.list(ei).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var th=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),withoutExpired:e.property("without_expired",e.boolean().optional())});var ah=e.object({data:q,params:th});var nh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var sh=e.object({data:q,params:nh});var ch=e.object({companyId:e.property("company_id",e.string().optional()),companyKeys:e.property("company_keys",e.record(e.string(),e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),includeUsageAggregation:e.property("include_usage_aggregation",e.boolean().optional()),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),q:e.string().optional(),withoutNegativeEntitlements:e.property("without_negative_entitlements",e.boolean().optional())});var lh=e.object({data:q,params:ch});var ph=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var uh=e.object({data:q,params:ph});var dh=e.object({featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),withMeteredProducts:e.property("with_metered_products",e.boolean().optional())});var mh=e.object({data:q,params:dh});var hh=e.object({data:He,params:e.record(e.string(),e.unknown())});var gh=e.object({data:ie,params:e.record(e.string(),e.unknown())});var yh=e.object({data:F,params:e.record(e.string(),e.unknown())});var wh=e.object({data:F,params:e.record(e.string(),e.unknown())});var ft=e.object({code:e.string(),description:e.string(),detail:e.string().optional(),id:e.string().optional()});var bh=e.object({message:e.string()});var zh=e.object({entitlementId:e.property("entitlement_id",e.string()),errors:e.list(bh),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string())});var Rh=e.object({data:e.list(ie),issues:e.list(ft),skipped:e.list(zh)});var fh=e.object({data:Rh,params:e.record(e.string(),e.unknown())});var _h=e.object({data:He,params:e.record(e.string(),e.unknown())});var Sh=e.object({keys:e.record(e.string(),e.string()).optional()});var Ph=e.object({data:Mi,params:Sh});var Qe=e.enum_(["daily","hourly","monthly","weekly"]);var xh=e.object({companyId:e.property("company_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:Qe.optional(),startTime:e.property("start_time",e.date().optional())});var Ch=e.object({effectiveAt:e.property("effective_at",e.date()),isSoftLimit:e.property("is_soft_limit",e.boolean()),limitSource:e.property("limit_source",Hr),limitValue:e.property("limit_value",e.number().optional()),planId:e.property("plan_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional())});var Eh=e.object({periodEnd:e.property("period_end",e.date().optional()),periodStart:e.property("period_start",e.date().optional()),timestamp:e.date(),usage:e.number()});var Uh=e.object({featureId:e.property("feature_id",e.string()),featureType:e.property("feature_type",le),limits:e.list(Ch),periodType:e.property("period_type",e.string().optional()),usagePoints:e.property("usage_points",e.list(Eh))});var vh=e.object({data:Uh,params:xh});var Th=e.object({data:ie,params:e.record(e.string(),e.unknown())});var Oh=e.object({companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),withoutExpired:e.property("without_expired",e.boolean().optional())});var kh=e.object({data:e.list(He),params:Oh});var Bh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var jh=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(qi).optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditTypeName:e.property("credit_type_name",e.string().optional()),creditUsed:e.property("credit_used",e.number().optional()),usageAggregation:e.property("usage_aggregation",Di.optional())});var Ah=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",re),company:X.optional(),companyOverride:e.property("company_override",He.optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),creditGrantCounts:e.property("credit_grant_counts",e.record(e.string(),e.number()).optional()),creditGrantDetails:e.property("credit_grant_details",e.list(qi).optional()),creditGrantReason:e.property("credit_grant_reason",Be.optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditTypeIcon:e.property("credit_type_icon",e.string().optional()),creditUsage:e.property("credit_usage",jh.optional()),creditUsageAggregation:e.property("credit_usage_aggregation",Di.optional()),creditUsed:e.property("credit_used",e.number().optional()),effectiveLimit:e.property("effective_limit",e.number().optional()),effectivePrice:e.property("effective_price",e.number().optional()),entitlementExpirationDate:e.property("entitlement_expiration_date",e.date().optional()),entitlementId:e.property("entitlement_id",e.string()),entitlementSource:e.property("entitlement_source",e.string().optional()),entitlementType:e.property("entitlement_type",Hr),feature:Ge.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:W.optional(),plan:pr.optional(),planEntitlement:e.property("plan_entitlement",ie.optional()),priceBehavior:e.property("price_behavior",ze.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",H.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",H.optional())});var Vh=e.object({data:e.list(Ah),params:Bh});var qh=e.object({companyId:e.property("company_id",e.string().optional()),companyKeys:e.property("company_keys",e.record(e.string(),e.string()).optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),includeUsageAggregation:e.property("include_usage_aggregation",e.boolean().optional()),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),q:e.string().optional(),withoutNegativeEntitlements:e.property("without_negative_entitlements",e.boolean().optional())});var Dh=e.object({data:e.list(Nr),params:qh});var Mh=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var mr=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:Mr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",lr),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainer:Ar.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Ui),updatedAt:e.property("updated_at",e.date())});var Je=e.object({billingLinkedResource:e.property("billing_linked_resource",Te.optional()),billingProduct:e.property("billing_product",ar.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Ci.optional()),featureType:e.property("feature_type",le),flags:e.list(mr),icon:e.string(),id:e.string(),licenseId:e.property("license_id",e.string().optional()),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainer:Ar.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Kr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:he.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date()),usageLimitTraitId:e.property("usage_limit_trait_id",e.string().optional())});var Ih=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",re),company:X.optional(),entitlementId:e.property("entitlement_id",e.string()),entitlementType:e.property("entitlement_type",Hr),feature:Je.optional(),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),period:W.optional(),plan:pr.optional(),usage:e.number().optional(),user:pt.optional()});var Fh=e.object({data:e.list(Ih),params:Mh});var Kh=e.object({featureId:e.property("feature_id",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),planIds:e.property("plan_ids",e.list(e.string()).optional()),planVersionId:e.property("plan_version_id",e.string().optional()),planVersionIds:e.property("plan_version_ids",e.list(e.string()).optional()),q:e.string().optional(),withMeteredProducts:e.property("with_metered_products",e.boolean().optional())});var Lh=e.object({data:e.list(ie),params:Kh});var Gh=e.object({data:He,params:e.record(e.string(),e.unknown())});var Wh=e.object({data:ie,params:e.record(e.string(),e.unknown())});var Hh=e.object({data:ie,params:e.record(e.string(),e.unknown())});var Nh=e.object({companyId:e.property("company_id",e.string().optional()),error:e.string().optional(),flagId:e.property("flag_id",e.string().optional()),flagKey:e.property("flag_key",e.string()),reason:e.string(),reqCompany:e.property("req_company",e.record(e.string(),e.string()).optional()),reqUser:e.property("req_user",e.record(e.string(),e.string()).optional()),ruleId:e.property("rule_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var $h=e.object({keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Jh=e.object({company:$h.optional(),keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Yh=e.object({cachedInputTokens:e.property("cached_input_tokens",e.number().optional()),company:e.record(e.string(),e.string()),cost:e.string().optional(),currency:e.string().optional(),event:e.string().optional(),inputTokens:e.property("input_tokens",e.number()),operation:e.string().optional(),outputTokens:e.property("output_tokens",e.number()),provider:e.string(),reasoningTokens:e.property("reasoning_tokens",e.number().optional()),requestModel:e.property("request_model",e.string().optional()),requests:e.number().optional(),responseModel:e.property("response_model",e.string()),user:e.record(e.string(),e.string()).optional()});var Zh=e.object({company:e.record(e.string(),e.string()).optional(),event:e.string(),leaseId:e.property("lease_id",e.string().optional()),quantity:e.number().optional(),traits:e.record(e.string(),e.unknown()).optional(),user:e.record(e.string(),e.string()).optional()});var _t=e.undiscriminatedUnion([Zh,Nh,Jh,Yh]);var Tr=e.enum_(["flag_check","identify","inference","track"]);var St=e.object({backfill:e.boolean().optional(),body:_t.optional(),eventType:e.property("event_type",Tr),idempotencyKey:e.property("idempotency_key",e.string().optional()),sentAt:e.property("sent_at",e.date().optional()),trustedClientClock:e.property("trusted_client_clock",e.boolean().optional())});var $n=e.object({events:e.list(St)});var Pt=e.object({capturedAt:e.property("captured_at",e.date()),eventId:e.property("event_id",e.string().optional()),remoteAddr:e.property("remote_addr",e.string().optional()),remoteIp:e.property("remote_ip",e.string()),userAgent:e.property("user_agent",e.string())});var Xh=e.object({events:e.list(Pt)});var Qh=e.object({data:Xh,params:e.record(e.string(),e.unknown())});var eg=e.object({data:Pt,params:e.record(e.string(),e.unknown())});var rg=e.enum_(["enriched","failed","pending","processed","unknown"]);var xt=e.object({apiKey:e.property("api_key",e.string().optional()),apiKeyView:e.property("api_key_view",xe.optional()),body:e.record(e.string(),e.unknown()),bodyPreview:e.property("body_preview",e.string()),capturedAt:e.property("captured_at",e.date()),company:Kr.optional(),companyId:e.property("company_id",e.string().optional()),enrichedAt:e.property("enriched_at",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),errorMessage:e.property("error_message",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string())),features:e.list(Kr),id:e.string(),idempotencyKey:e.property("idempotency_key",e.string().optional()),leaseId:e.property("lease_id",e.string().optional()),loadedAt:e.property("loaded_at",e.date().optional()),processedAt:e.property("processed_at",e.date().optional()),quantity:e.number(),sentAt:e.property("sent_at",e.date().optional()),status:rg,subtype:e.string().optional(),type:Tr,updatedAt:e.property("updated_at",e.date().optional()),user:Kr.optional(),userId:e.property("user_id",e.string().optional())});var ig=e.object({data:xt,params:e.record(e.string(),e.unknown())});var og=e.object({eventSubtypes:e.property("event_subtypes",e.list(e.string()).optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var tg=e.object({data:e.list(Ci),params:og});var ag=e.object({connected:e.boolean(),environmentId:e.property("environment_id",e.string()),lastEventAt:e.property("last_event_at",e.date().optional())});var ng=e.object({data:ag,params:e.record(e.string(),e.unknown())});var sg=e.object({companyId:e.property("company_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),eventTypes:e.property("event_types",e.list(Tr).optional()),flagId:e.property("flag_id",e.string().optional()),idempotencyKey:e.property("idempotency_key",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),userId:e.property("user_id",e.string().optional())});var cg=e.object({data:e.list(xt),params:sg});var So=e.object({company:e.record(e.string(),e.string()).optional(),user:e.record(e.string(),e.string()).optional()});var Jn=e.object({contexts:e.list(So)});var $i=e.object({defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",lr),id:e.string().optional(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var Yn=e.object({billingProvider:e.property("billing_provider",k),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),externalResourceId:e.property("external_resource_id",e.string()),featureType:e.property("feature_type",le),flag:$i.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var Zn=e.object({description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",le),flag:$i.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var Xn=e.object({description:e.string().optional(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",le.optional()),flag:$i.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Le.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string().optional(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var Ct=e.object({comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionType:e.property("condition_type",Ei),creditCost:e.property("credit_cost",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string().optional(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ir,resourceIds:e.property("resource_ids",e.list(e.string())),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string().optional())});var lg=e.object({conditions:e.list(Ct),flagId:e.property("flag_id",e.string().optional()),id:e.string().optional()});var pg=e.object({conditionGroups:e.property("condition_groups",e.list(lg)),conditions:e.list(Ct),id:e.string().optional(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Fr.optional()),value:e.boolean()});var Qn=e.object({rules:e.list(pg)});var Et=e.object({companyId:e.property("company_id",e.string().optional()),entitlement:tt.optional(),error:e.string().optional(),featureAllocation:e.property("feature_allocation",e.number().optional()),featureUsage:e.property("feature_usage",e.number().optional()),featureUsageEvent:e.property("feature_usage_event",e.string().optional()),featureUsagePeriod:e.property("feature_usage_period",W.optional()),featureUsageResetAt:e.property("feature_usage_reset_at",e.date().optional()),flag:e.string(),flagId:e.property("flag_id",e.string().optional()),reason:e.string(),ruleId:e.property("rule_id",e.string().optional()),ruleType:e.property("rule_type",Fr.optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var ug=e.object({data:Et,params:e.record(e.string(),e.unknown())});var dg=e.object({remaining:e.number(),reserved:e.number(),settled:e.number()});var mg=e.enum_(["active","converted","expired"]);var hg=e.object({id:e.string(),name:e.string(),trialEndDate:e.property("trial_end_date",e.date().optional()),trialStatus:e.property("trial_status",mg.optional())});var Ut=e.object({creditBalances:e.property("credit_balances",e.record(e.string(),dg).optional()),flags:e.list(Et),plan:hg.optional()});var gg=e.object({data:e.list(Ut)});var yg=e.object({data:gg,params:e.record(e.string(),e.unknown())});var wg=e.object({data:Ut,params:e.record(e.string(),e.unknown())});var bg=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(le).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),withoutCompanyOverrideFor:e.property("without_company_override_for",e.string().optional()),withoutPlanEntitlementFor:e.property("without_plan_entitlement_for",e.string().optional())});var zg=e.object({data:q,params:bg});var Rg=e.object({featureId:e.property("feature_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var fg=e.object({data:q,params:Rg});var _g=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Sg=e.object({data:mr,params:e.record(e.string(),e.unknown())});var Pg=e.object({data:F,params:e.record(e.string(),e.unknown())});var xg=e.object({data:F,params:e.record(e.string(),e.unknown())});var Cg=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Eg=e.object({data:mr,params:e.record(e.string(),e.unknown())});var Ug=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(le).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),managedBy:e.property("managed_by",k.optional()),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),q:e.string().optional(),withoutCompanyOverrideFor:e.property("without_company_override_for",e.string().optional()),withoutPlanEntitlementFor:e.property("without_plan_entitlement_for",e.string().optional())});var vg=e.object({data:e.list(Je),params:Ug});var Tg=e.object({featureId:e.property("feature_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Og=e.object({data:e.list(mr),params:Tg});var kg=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Bg=e.object({data:mr,params:e.record(e.string(),e.unknown())});var jg=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",lr),id:e.string(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Ag=e.object({flag:jg.optional(),rules:e.list(Ui)});var Vg=e.object({data:Ag,params:e.record(e.string(),e.unknown())});var qg=e.object({data:Je,params:e.record(e.string(),e.unknown())});var Dg=e.object({limit:e.number().optional()});var Mg=e.object({actorName:e.property("actor_name",e.string()),method:e.string(),resourceName:e.property("resource_name",e.string()),resourceType:e.property("resource_type",e.string()),timestamp:e.date(),title:e.string()});var Ig=e.object({entries:e.list(Mg)});var Fg=e.object({data:Ig,params:Dg});var Kg=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:Qe.optional(),startTime:e.property("start_time",e.date().optional())});var vt=e.object({timestamp:e.date(),usage:e.number()});var Lg=e.object({eventSubtype:e.property("event_subtype",e.string()),featureId:e.property("feature_id",e.string()),points:e.list(vt)});var Gg=e.object({data:Lg,params:Kg});var Wg=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:Qe.optional(),startTime:e.property("start_time",e.date().optional())});var Hg=e.object({featureId:e.property("feature_id",e.string()),points:e.list(vt),traitDefinitionId:e.property("trait_definition_id",e.string())});var Ng=e.object({data:Hg,params:Wg});var $g=e.object({months:e.number().optional()});var Jg=e.object({month:e.date(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),subscribers:e.number()});var Yg=e.object({points:e.list(Jg)});var Zg=e.object({data:Yg,params:$g});var Xg=e.object({amount:e.number(),currency:e.string()});var Qg=e.object({activeCredits:e.property("active_credits",e.number()),mrr:e.list(Xg),paidCompanies:e.property("paid_companies",e.number()),totalCompanies:e.property("total_companies",e.number()),totalFeatures:e.property("total_features",e.number()),totalPlans:e.property("total_plans",e.number())});var ey=e.object({data:Qg,params:e.record(e.string(),e.unknown())});var ry=e.object({endTime:e.property("end_time",e.date().optional()),limit:e.number().optional(),startTime:e.property("start_time",e.date().optional())});var iy=e.object({changePct:e.property("change_pct",e.number().optional()),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string()),pluralName:e.property("plural_name",e.string().optional()),priorUsage:e.property("prior_usage",e.number()),usage:e.number()});var oy=e.object({features:e.list(iy)});var ty=e.object({data:oy,params:ry});var Ji=e.enum_(["billing_meta_object","manual_upsert"]);var es=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Ji.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),integrationId:e.property("integration_id",e.string())});var Tt=e.object({authorPlans:e.property("author_plans",e.boolean()),checkout:e.boolean(),editBilling:e.property("edit_billing",e.boolean())});var ay=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var ny=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var sy=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var cy=e.object({accountId:e.property("account_id",e.string().optional()),accountName:e.property("account_name",e.string().optional()),companyUpdateOnly:e.property("company_update_only",e.boolean().optional()),isSandbox:e.property("is_sandbox",e.boolean()),liveMode:e.property("live_mode",e.boolean()),onboardUrl:e.property("onboard_url",e.string().optional())});var ly=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Ot=e.union("type",{clerk:ay,metronome:ny,orb:sy,stripe:cy,workos:ly}).transform({transform:p=>p,untransform:p=>p});var py=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Ji.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:Ot.optional(),createdAt:e.property("created_at",e.date()),id:e.string(),integrationId:e.property("integration_id",e.string()),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),liveMode:e.property("live_mode",e.boolean()),updatedAt:e.property("updated_at",e.date())});var Yi=e.object({capabilities:Tt,config:py,integration:ut});var uy=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var dy=e.object({type:Se,url:e.string()});var my=e.object({data:dy,params:e.record(e.string(),e.unknown())});var hy=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var gy=e.object({data:Yi,params:e.record(e.string(),e.unknown())});var yy=e.object({billingOnly:e.property("billing_only",e.boolean().optional()),excludeIds:e.property("exclude_ids",e.list(e.string()).optional()),id:e.string().optional(),limit:e.number().optional(),offset:e.number().optional(),state:Me.optional(),type:Se.optional()});var wy=e.object({capabilities:Tt,config:Ot.optional(),id:e.string(),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),lastWebhookReceivedAt:e.property("last_webhook_received_at",e.date().optional()),state:Me,type:Se});var by=e.object({data:e.list(wy),params:yy});var zy=e.object({keys:e.list(e.string())});var Ry=e.object({data:zy,params:e.record(e.string(),e.unknown())});var kt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Me,type:Se,updatedAt:e.property("updated_at",e.date())});var fy=e.object({data:kt,params:e.record(e.string(),e.unknown())});var _y=e.object({data:kt,params:e.record(e.string(),e.unknown())});var Sy=e.object({data:F,params:e.record(e.string(),e.unknown())});var Py=e.object({featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var xy=e.object({data:q,params:Py});var Bt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Cy=e.object({data:Bt,params:e.record(e.string(),e.unknown())});var Ey=e.object({featureIds:e.property("feature_ids",e.list(e.string()).optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Uy=e.object({data:e.list(Bt),params:Ey});var vy=e.object({companyId:e.property("company_id",e.string()),description:e.string(),icon:pe.optional(),name:e.string()});var jt=e.stringLiteral("credit");var At=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional()),autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",jt.optional()),autoTopupAvailability:e.property("auto_topup_availability",sr.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Z.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",G.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean().optional()),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),resetCadence:e.property("reset_cadence",Oe),resetStart:e.property("reset_start",Ie),resetType:e.property("reset_type",cr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional())});var Ty=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var Vt=e.enum_(["create","update","delete"]);var qt=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional()),autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",jt.optional()),autoTopupAvailability:e.property("auto_topup_availability",sr.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Z.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",G.optional()),autoTopupExpiryUnitCount:e.property("auto_topup_expiry_unit_count",e.number().optional()),autoTopupSelfService:e.property("auto_topup_self_service",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),autoTopupThresholdPercent:e.property("auto_topup_threshold_percent",e.number().optional()),canBuyBundles:e.property("can_buy_bundles",e.boolean().optional()),creditAmount:e.property("credit_amount",e.number().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),resetCadence:e.property("reset_cadence",Oe),resetStart:e.property("reset_start",Ie),resetType:e.property("reset_type",cr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional())});var Zi=e.object({action:Vt,createReq:e.property("create_req",At.optional()),creditGrantId:e.property("credit_grant_id",e.string().optional()),deleteReq:e.property("delete_req",Ty.optional()),updateReq:e.property("update_req",qt.optional())});var Oy=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Qr).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional()),priceTiers:e.property("price_tiers",e.list(ae).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ae).optional()),quarterlyUnitPrice:e.property("quarterly_unit_price",e.number().optional()),quarterlyUnitPriceDecimal:e.property("quarterly_unit_price_decimal",e.string().optional()),softLimit:e.property("soft_limit",e.number().optional()),tierMode:e.property("tier_mode",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),warningTiers:e.property("warning_tiers",e.list(ei).optional()),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ae).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Xi=e.object({action:Vt,entitlementId:e.property("entitlement_id",e.string().optional()),req:Oy.optional()});var ky=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",e.number().optional()),oneTimePrice:e.property("one_time_price",e.number().optional()),quarterlyPrice:e.property("quarterly_price",e.number().optional()),yearlyPrice:e.property("yearly_price",e.number().optional())});var ri=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingStrategy:e.property("billing_strategy",Fe.optional()),chargeType:e.property("charge_type",Ke),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(ky).optional()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPrice:e.property("monthly_price",e.number().optional()),monthlyPriceId:e.property("monthly_price_id",e.string().optional()),oneTimePrice:e.property("one_time_price",e.number().optional()),oneTimePriceId:e.property("one_time_price_id",e.string().optional()),quarterlyPrice:e.property("quarterly_price",e.number().optional()),quarterlyPriceId:e.property("quarterly_price_id",e.string().optional()),trialDays:e.property("trial_days",e.number().optional()),yearlyPrice:e.property("yearly_price",e.number().optional()),yearlyPriceId:e.property("yearly_price_id",e.string().optional())});var rs=e.object({billingProduct:e.property("billing_product",ri.optional()),creditGrants:e.property("credit_grants",e.list(Zi).optional()),entitlements:e.list(Xi),plan:vy.optional()});var Dt=e.object({description:e.string(),icon:pe.optional(),name:e.string(),planType:e.property("plan_type",Q)});var is=e.object({billingProduct:e.property("billing_product",ri.optional()),creditGrants:e.property("credit_grants",e.list(Zi).optional()),entitlements:e.list(Xi),plan:Dt.optional()});var Mt=e.object({description:e.string().optional(),icon:pe.optional(),name:e.string()});var os=e.object({billingProduct:e.property("billing_product",ri.optional()),creditGrants:e.property("credit_grants",e.list(Zi).optional()),entitlements:e.list(Xi),plan:Mt.optional(),planVersionId:e.property("plan_version_id",e.string().optional())});var It=e.object({accountId:e.property("account_id",e.string()),billingProductId:e.property("billing_product_id",e.string()),billingStrategy:e.property("billing_strategy",Fe),chargeType:e.property("charge_type",Ke),controlledBy:e.property("controlled_by",k),environmentId:e.property("environment_id",e.string()),isTrialable:e.property("is_trialable",e.boolean()),monthlyPriceId:e.property("monthly_price_id",e.string().optional()),oneTimePriceId:e.property("one_time_price_id",e.string().optional()),planId:e.property("plan_id",e.string()),trialDays:e.property("trial_days",e.number().optional()),yearlyPriceId:e.property("yearly_price_id",e.string().optional())});var Qi=e.object({billingProduct:e.property("billing_product",It.optional()),creditGrants:e.property("credit_grants",e.list(ke).optional()),entitlements:e.list(ie).optional(),plan:pr.optional()});var By=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var jy=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var Ay=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var Ft=e.object({definitionId:e.property("definition_id",e.string().optional()),helperText:e.property("helper_text",e.string().optional()),id:e.string().optional(),name:e.string(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string())});var Vy=e.object({entitlementId:e.property("entitlement_id",e.string()),visible:e.boolean().optional()});var Or=e.object({entitlements:e.list(Vy).optional(),planId:e.property("plan_id",e.string())});var eo=e.object({bundleId:e.string()});var Kt=e.enum_(["create_prorations","invoice_immediately"]);var Lt=e.enum_(["end_of_billing_period","none"]);var ts=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Jr).optional()),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutCollectAddress:e.property("checkout_collect_address",e.boolean()),checkoutCollectEmail:e.property("checkout_collect_email",e.boolean()),checkoutCollectPhone:e.property("checkout_collect_phone",e.boolean()),customCheckoutFields:e.property("custom_checkout_fields",e.list(Ft).optional()),customPlanConfig:e.property("custom_plan_config",$r.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),enableTaxCollection:e.property("enable_tax_collection",e.boolean()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(Or)),orderedBundleList:e.property("ordered_bundle_list",e.list(eo)),orderedPlans:e.property("ordered_plans",e.list(Or)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",Kt),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",Lt.optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var as=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Jr).optional()),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutCollectAddress:e.property("checkout_collect_address",e.boolean()),checkoutCollectEmail:e.property("checkout_collect_email",e.boolean()),checkoutCollectPhone:e.property("checkout_collect_phone",e.boolean()),customCheckoutFields:e.property("custom_checkout_fields",e.list(Ft).optional()),customPlanConfig:e.property("custom_plan_config",$r.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),enableTaxCollection:e.property("enable_tax_collection",e.boolean()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional()),orderedAddOns:e.property("ordered_add_ons",e.list(Or)),orderedBundleList:e.property("ordered_bundle_list",e.list(eo)),orderedPlans:e.property("ordered_plans",e.list(Or)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",Kt),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",Lt.optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var Gt=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean()),optInEnabled:e.property("opt_in_enabled",e.boolean()),optInText:e.property("opt_in_text",e.string().optional()),optInTitle:e.property("opt_in_title",e.string().optional())});var qy=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var Wt=e.object({showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showFeatureDescription:e.property("show_feature_description",e.boolean()),showHardLimit:e.property("show_hard_limit",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean())});var Ht=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(qy)),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutSettings:e.property("checkout_settings",Gt),componentSettings:e.property("component_settings",Wt),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnIds:e.property("ordered_add_on_ids",e.list(Or)),planIds:e.property("plan_ids",e.list(Or)),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",e.string()),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",e.string().optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var Dy=e.object({data:Ht,params:e.record(e.string(),e.unknown())});var My=e.object({includeCompanyCounts:e.property("include_company_counts",e.boolean().optional())});var Iy=e.object({createdAt:e.property("created_at",e.date()),definitionId:e.property("definition_id",e.string()),helperText:e.property("helper_text",e.string().optional()),id:e.string(),name:e.string(),position:e.number(),required:e.boolean(),stripeMetadataKey:e.property("stripe_metadata_key",e.string()),traitHierarchy:e.property("trait_hierarchy",e.list(e.string())),updatedAt:e.property("updated_at",e.date())});var Fy=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var ns=e.object({entitlements:e.list(Fy).optional(),planId:e.property("plan_id",e.string())});var Ky=e.object({addOns:e.property("add_ons",e.list(ur)),checkoutSettings:e.property("checkout_settings",Gt),componentSettings:e.property("component_settings",Wt),customCheckoutFields:e.property("custom_checkout_fields",e.list(Iy)),customPlanConfig:e.property("custom_plan_config",Xo.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),defaultPlan:e.property("default_plan",ur.optional()),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlan:e.property("fallback_plan",ur.optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlan:e.property("initial_plan",ur.optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPrice:e.property("initial_plan_price",H.optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnList:e.property("ordered_add_on_list",e.list(ns)),orderedBundleList:e.property("ordered_bundle_list",e.list(eo)),orderedPlanList:e.property("ordered_plan_list",e.list(ns)),plans:e.list(ur),preventDowngradesWhenOverLimit:e.property("prevent_downgrades_when_over_limit",e.boolean()),preventSelfServiceDowngrade:e.property("prevent_self_service_downgrade",e.boolean()),preventSelfServiceDowngradeButtonText:e.property("prevent_self_service_downgrade_button_text",e.string().optional()),preventSelfServiceDowngradeUrl:e.property("prevent_self_service_downgrade_url",e.string().optional()),prorationBehavior:e.property("proration_behavior",e.string()),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",e.string().optional()),scheduledDowngradePreventWhenOverLimit:e.property("scheduled_downgrade_prevent_when_over_limit",e.boolean().optional()),showAsMonthlyPrices:e.property("show_as_monthly_prices",e.boolean()),showCredits:e.property("show_credits",e.boolean()),showPeriodToggle:e.property("show_period_toggle",e.boolean()),showZeroPriceAsFree:e.property("show_zero_price_as_free",e.boolean()),syncCustomerBillingDetails:e.property("sync_customer_billing_details",e.boolean()),taxCollectionEnabled:e.property("tax_collection_enabled",e.boolean()),trialDays:e.property("trial_days",e.number().optional()),trialExpiryPlan:e.property("trial_expiry_plan",ur.optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPrice:e.property("trial_expiry_plan_price",H.optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var Ly=e.object({data:Ky,params:My});var Gy=e.object({data:Ht,params:e.record(e.string(),e.unknown())});var ro=e.enum_(["immediate","leave"]);var ss=e.object({companyIds:e.property("company_ids",e.list(e.string())),excludedCompanyIds:e.property("excluded_company_ids",e.list(e.string())),planId:e.property("plan_id",e.string()),planVersionIdTo:e.property("plan_version_id_to",e.string()),planVersionIdsFrom:e.property("plan_version_ids_from",e.list(e.string())),strategy:ro,targetPlanType:e.property("target_plan_type",Q)});var cs=e.object({companyIds:e.property("company_ids",e.list(e.string())),planId:e.property("plan_id",e.string()),planVersionIdTo:e.property("plan_version_id_to",e.string()),targetPlanType:e.property("target_plan_type",Q)});var Nt=e.enum_(["ambiguous_subscription_item","multiple_subscriptions","no_price_for_interval","not_on_origin_version","operation_item_not_found","permanent_config","permanent_decline","transient_decline","transient_infra","transient_stripe","unknown","would_leave_empty_subscription"]);var ls=e.object({errorCodes:e.property("error_codes",e.list(Nt))});var kr=e.enum_(["completed","failed","in_progress","pending","skipped"]);var Wy=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:kr.optional()});var Hy=e.object({data:q,params:Wy});var Br=e.enum_(["completed","failed","in_progress","pending"]);var Ny=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Br.optional()});var $y=e.object({data:q,params:Ny});var ii=e.object({completedAt:e.property("completed_at",e.date().optional()),completedCompanies:e.property("completed_companies",e.number()),createdAt:e.property("created_at",e.date()),error:e.string().optional(),failedCompanies:e.property("failed_companies",e.number()),id:e.string(),planId:e.property("plan_id",e.string()),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),planVersionIdTo:e.property("plan_version_id_to",e.string()),planVersionIdsFrom:e.property("plan_version_ids_from",e.list(e.string())),skippedCompanies:e.property("skipped_companies",e.number()),startedAt:e.property("started_at",e.date().optional()),status:Br,strategy:ro,totalCompanies:e.property("total_companies",e.number()),updatedAt:e.property("updated_at",e.date())});var Jy=e.object({data:ii,params:e.record(e.string(),e.unknown())});var Yy=e.object({data:ii,params:e.record(e.string(),e.unknown())});var Zy=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:kr.optional()});var $t=e.object({companyId:e.property("company_id",e.string()),companyName:e.property("company_name",e.string()),completedAt:e.property("completed_at",e.date().optional()),createdAt:e.property("created_at",e.date()),error:e.string().optional(),errorCode:e.property("error_code",Nt.optional()),id:e.string(),migrationId:e.property("migration_id",e.string()),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),startedAt:e.property("started_at",e.date().optional()),status:kr,updatedAt:e.property("updated_at",e.date())});var Xy=e.object({data:e.list($t),params:Zy});var Qy=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Br.optional()});var ew=e.object({data:e.list(ii),params:Qy});var rw=e.object({companyId:e.property("company_id",e.string()),hasBillingChanges:e.property("has_billing_changes",e.boolean()),hasCustomPricing:e.property("has_custom_pricing",e.boolean()),note:e.string().optional(),planVersionIdFrom:e.property("plan_version_id_from",e.string().optional()),willUpdateSubscription:e.property("will_update_subscription",e.boolean())});var iw=e.object({companies:e.list(rw)});var ow=e.object({data:iw,params:e.record(e.string(),e.unknown())});var tw=e.object({data:$t,params:e.record(e.string(),e.unknown())});var aw=e.object({data:ii,params:e.record(e.string(),e.unknown())});var ps=e.object({billingProvider:e.property("billing_provider",k),description:e.string(),externalResourceId:e.property("external_resource_id",e.string()),externalResourceVersion:e.property("external_resource_version",e.string().optional()),icon:pe.optional(),name:e.string(),planType:e.property("plan_type",Q)});var us=e.object({companyId:e.property("company_id",e.string()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),description:e.string(),icon:pe.optional(),name:e.string()});var ds=e.object({activationStrategy:e.property("activation_strategy",ji.optional()),couponExternalId:e.property("coupon_external_id",e.string().optional()),customerEmail:e.property("customer_email",e.string().optional()),daysUntilDue:e.property("days_until_due",e.number().optional()),excludedCompanyIds:e.property("excluded_company_ids",e.list(e.string())),migrationStrategy:e.property("migration_strategy",ro)});var ms=e.object({activationStrategy:e.property("activation_strategy",ji.optional()),customerEmail:e.property("customer_email",e.string()),daysUntilDue:e.property("days_until_due",e.number().optional())});var hs=e.object({addOnIds:e.property("add_on_ids",e.list(e.string())),basePlanId:e.property("base_plan_id",e.string().optional())});var nw=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var sw=e.object({data:q,params:nw});var cw=e.object({companyId:e.property("company_id",e.string().optional()),companyScopedOnly:e.property("company_scoped_only",e.boolean().optional()),excludeCompanyScoped:e.property("exclude_company_scoped",e.boolean().optional()),forFallbackPlan:e.property("for_fallback_plan",e.boolean().optional()),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),hasProductId:e.property("has_product_id",e.boolean().optional()),ids:e.list(e.string()).optional(),includeDraftVersions:e.property("include_draft_versions",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planType:e.property("plan_type",Q.optional()),q:e.string().optional(),scopedToCompanyId:e.property("scoped_to_company_id",e.string().optional()),withEntitlements:e.property("with_entitlements",e.boolean().optional()),withoutEntitlementFor:e.property("without_entitlement_for",e.string().optional()),withoutPaidProductId:e.property("without_paid_product_id",e.boolean().optional())});var lw=e.object({data:q,params:cw});var pw=e.object({data:we,params:e.record(e.string(),e.unknown())});var uw=e.object({data:we,params:e.record(e.string(),e.unknown())});var dw=e.object({data:F,params:e.record(e.string(),e.unknown())});var mw=e.object({promoteArchivedVersion:e.property("promote_archived_version",e.boolean().optional())});var hw=e.object({data:F,params:mw});var gw=e.object({planVersionId:e.property("plan_version_id",e.string().optional())});var yw=e.object({data:we,params:gw});var ww=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var bw=e.object({data:e.list(X),params:ww});var zw=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),status:Cr.optional(),statuses:e.list(Cr).optional()});var Rw=e.object({data:e.list(Wr),params:zw});var fw=e.object({planId:e.property("plan_id",e.string().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var _w=e.object({data:e.list(ft),params:fw});var Sw=e.object({companyId:e.property("company_id",e.string().optional()),companyScopedOnly:e.property("company_scoped_only",e.boolean().optional()),excludeCompanyScoped:e.property("exclude_company_scoped",e.boolean().optional()),forFallbackPlan:e.property("for_fallback_plan",e.boolean().optional()),forInitialPlan:e.property("for_initial_plan",e.boolean().optional()),forTrialExpiryPlan:e.property("for_trial_expiry_plan",e.boolean().optional()),hasProductId:e.property("has_product_id",e.boolean().optional()),ids:e.list(e.string()).optional(),includeDraftVersions:e.property("include_draft_versions",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),planType:e.property("plan_type",Q.optional()),q:e.string().optional(),scopedToCompanyId:e.property("scoped_to_company_id",e.string().optional()),withEntitlements:e.property("with_entitlements",e.boolean().optional()),withoutEntitlementFor:e.property("without_entitlement_for",e.string().optional()),withoutPaidProductId:e.property("without_paid_product_id",e.boolean().optional())});var Pw=e.object({data:e.list(we),params:Sw});var xw=e.object({data:Wr,params:e.record(e.string(),e.unknown())});var Cw=e.object({data:Re,params:e.record(e.string(),e.unknown())});var Ew=e.object({data:Wr,params:e.record(e.string(),e.unknown())});var Uw=e.object({data:X,params:e.record(e.string(),e.unknown())});var vw=e.object({data:we,params:e.record(e.string(),e.unknown())});var Tw=e.object({data:It,params:e.record(e.string(),e.unknown())});var Ow=e.object({data:we,params:e.record(e.string(),e.unknown())});var gs=e.object({companyId:e.property("company_id",e.string()),executeAfter:e.property("execute_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),toPlanId:e.property("to_plan_id",e.string())});var oi=e.enum_(["cancelled","error","executing","pending","success"]);var ys=e.object({executeAfter:e.property("execute_after",e.date().optional()),status:oi.optional()});var ti=e.object({actorType:e.property("actor_type",e.string()),companyId:e.property("company_id",e.string()),completedAt:e.property("completed_at",e.date().optional()),createdAt:e.property("created_at",e.date()),errorMessage:e.property("error_message",e.string().optional()),executeAfter:e.property("execute_after",e.date()),fromPlanId:e.property("from_plan_id",e.string()),id:e.string(),scheduledInterval:e.property("scheduled_interval",e.string().optional()),scheduledPrice:e.property("scheduled_price",e.number().optional()),startedAt:e.property("started_at",e.date().optional()),status:oi,toPlanId:e.property("to_plan_id",e.string()),updatedAt:e.property("updated_at",e.date())});var kw=e.object({data:ti,params:e.record(e.string(),e.unknown())});var Bw=e.object({data:ti,params:e.record(e.string(),e.unknown())});var jw=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),status:oi.optional()});var Aw=e.object({data:e.list(ti),params:jw});var Vw=e.object({data:ti,params:e.record(e.string(),e.unknown())});var io=e.object({creditId:e.property("credit_id",e.string())});var oo=e.object({featureId:e.property("feature_id",e.string())});var hr=e.enum_(["subscription.trial.ended","company.created","company.deleted","company.override.created","company.override.deleted","company.override.expired","company.override.updated","company.plan_changed","company.scheduled_downgrade","company.updated","credit.limit.reached","credit.limit.warning","credit.purchase.success","entitlement.limit.reached","entitlement.limit.warning","entitlement.soft_limit.reached","entitlement.soft_limit.warning","entitlement.tier_limit.reached","entitlement.tier_limit.warning","feature.created","feature.deleted","feature.updated","flag.created","flag.deleted","flag_rules.updated","flag.updated","plan.created","plan.deleted","plan.entitlement.created","plan.entitlement.deleted","plan.entitlement.updated","plan.updated","plan_version.deleted","rule.deleted","test.send","user.created","user.deleted","user.updated","auto.topup.hard.failure","auto.topup.retry.exceeded","auto.topup.success"]);var ws=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(io).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(oo).optional()),name:e.string(),requestTypes:e.property("request_types",e.list(hr)),url:e.string()});var bs=e.object({requestType:e.property("request_type",hr)});var Jt=e.enum_(["active","inactive"]);var zs=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(io).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(oo).optional()),name:e.string().optional(),requestTypes:e.property("request_types",e.list(hr).optional()),status:Jt.optional(),url:e.string().optional()});var qw=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),webhookId:e.property("webhook_id",e.string().optional())});var Dw=e.object({data:q,params:qw});var Mw=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Iw=e.object({data:q,params:Mw});var gr=e.object({createdAt:e.property("created_at",e.date()),creditTriggerConfigs:e.property("credit_trigger_configs",e.list(io).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(oo).optional()),id:e.string(),name:e.string(),requestTypes:e.property("request_types",e.list(hr)),secret:e.string(),status:Jt,updatedAt:e.property("updated_at",e.date()),url:e.string()});var Fw=e.object({data:gr,params:e.record(e.string(),e.unknown())});var Kw=e.object({data:F,params:e.record(e.string(),e.unknown())});var Lw=e.enum_(["failure","pending","success"]);var Yt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),payload:e.string().optional(),requestType:e.property("request_type",hr),responseCode:e.property("response_code",e.number().optional()),sentAt:e.property("sent_at",e.date().optional()),status:Lw,updatedAt:e.property("updated_at",e.date()),webhook:gr.optional(),webhookId:e.property("webhook_id",e.string())});var Gw=e.object({data:Yt,params:e.record(e.string(),e.unknown())});var Ww=e.object({data:gr,params:e.record(e.string(),e.unknown())});var Hw=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),webhookId:e.property("webhook_id",e.string().optional())});var Nw=e.object({data:e.list(Yt),params:Hw});var $w=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Jw=e.object({data:e.list(gr),params:$w});var Yw=e.object({responseCode:e.property("response_code",e.number()),success:e.boolean()});var Zw=e.object({data:Yw,params:e.record(e.string(),e.unknown())});var Xw=e.object({data:gr,params:e.record(e.string(),e.unknown())});var n=e.object({error:e.string()});var Qw=e.object({addOnId:e.property("add_on_id",e.string()),priceId:e.property("price_id",e.string())});var eb=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupThresholdCredits:e.property("auto_topup_threshold_credits",e.number().optional()),planCreditGrantId:e.property("plan_credit_grant_id",e.string())});var Zt=e.object({bundleId:e.property("bundle_id",e.string()),quantity:e.number()});var Xt=e.object({priceId:e.property("price_id",e.string()),quantity:e.number()});var Rs=e.object({addOnIds:e.property("add_on_ids",e.list(Qw)),autoTopupOverrides:e.property("auto_topup_overrides",e.list(eb)),billingEntityId:e.property("billing_entity_id",e.string().optional()),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(Zt)),customFieldValues:e.property("custom_field_values",e.list(Ti)),newPlanId:e.property("new_plan_id",e.string()),newPriceId:e.property("new_price_id",e.string()),optInAccepted:e.property("opt_in_accepted",e.boolean().optional()),payInAdvance:e.property("pay_in_advance",e.list(Xt)),paymentMethodId:e.property("payment_method_id",e.string().optional()),promoCode:e.property("promo_code",e.string().optional()),skipTrial:e.property("skip_trial",e.boolean())});var fs=e.object({defaultValue:e.property("default_value",e.boolean()),description:e.string(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",lr),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var Qt=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Ji.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:e.record(e.string(),e.unknown()).optional(),isSandbox:e.property("is_sandbox",e.boolean().optional()),liveMode:e.property("live_mode",e.boolean().optional()),type:Se});var _s=e.object({keys:e.record(e.string(),e.string())});var rb=e.object({planId:e.property("plan_id",e.string()),priceId:e.property("price_id",e.string().optional()),versionId:e.property("version_id",e.string().optional())});var Ss=e.object({addOnSelections:e.property("add_on_selections",e.list(rb)),basePlanId:e.property("base_plan_id",e.string().optional()),basePlanPriceId:e.property("base_plan_price_id",e.string().optional()),basePlanVersionId:e.property("base_plan_version_id",e.string().optional()),billingEntityId:e.property("billing_entity_id",e.string().optional()),cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(Zt)),customFieldValues:e.property("custom_field_values",e.list(Ti)),payInAdvanceEntitlements:e.property("pay_in_advance_entitlements",e.list(Xt)),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),promoCode:e.property("promo_code",e.string().optional()),prorate:e.boolean().optional(),trialEnd:e.property("trial_end",e.date().optional())});var ib=e.record(e.string(),e.unknown());var ob=e.record(e.string(),e.unknown());var tb=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var to=e.enum_(["all_time","current_day","current_month","current_week"]);var ao=e.enum_(["billing_cycle","first_of_month"]);var ab=e.object({key:e.string(),value:e.number()});var ea=e.object({allocation:e.number().optional(),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",e.number().optional()),creditReserved:e.property("credit_reserved",e.number().optional()),creditSettled:e.property("credit_settled",e.number().optional()),creditTotal:e.property("credit_total",e.number().optional()),creditUsed:e.property("credit_used",e.number().optional()),eventName:e.property("event_name",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",to.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",ao.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",tb),warningTiers:e.property("warning_tiers",e.list(ab).optional())});var nb=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var ra=e.object({accountId:e.property("account_id",e.string()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",ao),period:to,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var sb=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var cb=e.enum_(["company","user"]);var lb=e.enum_(["bool","date","int","string"]);var Po=e.object({comparableType:e.property("comparable_type",lb),entityType:e.property("entity_type",cb),id:e.string()});var ia=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",Po.optional()),conditionType:e.property("condition_type",sb),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",to.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",ao.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ir,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",Po.optional()),traitValue:e.property("trait_value",e.string())});var pb=e.object({conditions:e.list(ia)});var no=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(pb)),conditions:e.list(ia),environmentId:e.property("environment_id",e.string()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",nb),value:e.boolean()});var ub=e.object({id:e.string(),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date())});var oa=e.object({traitDefinition:e.property("trait_definition",Po.optional()),value:e.string()});var db=e.object({accountId:e.property("account_id",e.string()),basePlanId:e.property("base_plan_id",e.string().optional()),billingProductIds:e.property("billing_product_ids",e.list(e.string())),creditBalances:e.property("credit_balances",e.record(e.string(),e.number())),entitlements:e.list(ea).optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),metrics:e.list(ra),planIds:e.property("plan_ids",e.list(e.string())),planVersionIds:e.property("plan_version_ids",e.list(e.string())),rules:e.list(no),subscription:ub.optional(),traits:e.list(oa)});var Ps=e.object({accountId:e.property("account_id",e.string()),defaultValue:e.property("default_value",e.boolean()),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),rules:e.list(no)});var mb=e.object({accountId:e.property("account_id",e.string()),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),rules:e.list(no),traits:e.list(oa)});var xs=e.object({basePlanId:e.property("base_plan_id",e.string().optional()),basePlanPriceId:e.property("base_plan_price_id",e.string().optional()),id:e.string().optional(),keys:e.record(e.string(),e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string().optional(),preventKeyRemap:e.property("prevent_key_remap",e.boolean().optional()),traits:e.record(e.string(),e.unknown()).optional(),updateOnly:e.property("update_only",e.boolean().optional())});var Cs=e.object({incr:e.number().optional(),keys:e.record(e.string(),e.string()),set:e.string().optional(),trait:e.string(),updateOnly:e.property("update_only",e.boolean().optional())});var Es=e.object({companies:e.list(e.record(e.string(),e.string())).optional(),company:e.record(e.string(),e.string()).optional(),companyId:e.property("company_id",e.string().optional()),companyIds:e.property("company_ids",e.list(e.string()).optional()),id:e.string().optional(),keys:e.record(e.string(),e.string()),lastSeenAt:e.property("last_seen_at",e.date().optional()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional(),updateOnly:e.property("update_only",e.boolean().optional())});var ta=class{constructor(o){this._options=K(o)}issueTemporaryAccessToken(o,i){return R.fromPromise(this.__issueTemporaryAccessToken(o,i))}async __issueTemporaryAccessToken(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"temporary-access-tokens"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:{...Xa.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),resource_type:"company"},timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:tl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/temporary-access-tokens")}};var aa=class{constructor(o){this._options=K(o)}listAccountMembers(o={},i){return R.fromPromise(this.__listAccountMembers(o,i))}async __listAccountMembers(o={},i){let{ids:t,q:s,role:r,limit:a,offset:d}=o,y={ids:t,q:s,role:r!=null?xr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"account-members"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Cl.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/account-members")}getAccountMember(o,i){return R.fromPromise(this.__getAccountMember(o,i))}async __getAccountMember(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`account-members/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:bl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/account-members/{account_member_id}")}countAccountMembers(o={},i){return R.fromPromise(this.__countAccountMembers(o,i))}async __countAccountMembers(o={},i){let{ids:t,q:s,role:r,limit:a,offset:d}=o,y={ids:t,q:s,role:r!=null?xr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"account-members/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:nl.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/account-members/count")}listApiKeys(o,i){return R.fromPromise(this.__listApiKeys(o,i))}async __listApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:a}=o,d={environment_id:t,require_environment:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Ul.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/api-keys")}createApiKey(o,i){return R.fromPromise(this.__createApiKey(o,i))}async __createApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qa.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:dl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/api-keys")}getApiKey(o,i){return R.fromPromise(this.__getApiKey(o,i))}async __getApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/api-keys/{api_key_id}")}updateApiKey(o,i={},t){return R.fromPromise(this.__updateApiKey(o,i,t))}async __updateApiKey(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Al.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/api-keys/{api_key_id}")}deleteApiKey(o,i){return R.fromPromise(this.__deleteApiKey(o,i))}async __deleteApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`api-keys/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/api-keys/{api_key_id}")}countApiKeys(o,i){return R.fromPromise(this.__countApiKeys(o,i))}async __countApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:a}=o,d={environment_id:t,require_environment:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"api-keys/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:cl.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/api-keys/count")}listAuditLogs(o={},i){return R.fromPromise(this.__listAuditLogs(o,i))}async __listAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:a,startTime:d,limit:y,offset:g}=o,l={actor_type:t!=null?Ce.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:a,start_time:d?.toISOString(),limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"audit-log"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Tl.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/audit-log")}getAuditLog(o,i){return R.fromPromise(this.__getAuditLog(o,i))}async __getAuditLog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`audit-log/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/audit-log/{audit_log_id}")}countAuditLogs(o={},i){return R.fromPromise(this.__countAuditLogs(o,i))}async __countAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:a,startTime:d,limit:y,offset:g}=o,l={actor_type:t!=null?Ce.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:a,start_time:d?.toISOString(),limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"audit-log/count"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:pl.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/audit-log/count")}listEnvironments(o={},i){return R.fromPromise(this.__listEnvironments(o,i))}async __listEnvironments(o={},i){let{ids:t,limit:s,offset:r}=o,a={ids:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"environments"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:kl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/environments")}createEnvironment(o,i){return R.fromPromise(this.__createEnvironment(o,i))}async __createEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"environments"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:en.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/environments")}getEnvironment(o,i){return R.fromPromise(this.__getEnvironment(o,i))}async __getEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_l.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/environments/{environment_id}")}updateEnvironment(o,i={},t){return R.fromPromise(this.__updateEnvironment(o,i,t))}async __updateEnvironment(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:on.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Vl.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/environments/{environment_id}")}deleteEnvironment(o,i){return R.fromPromise(this.__deleteEnvironment(o,i))}async __deleteEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`environments/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/environments/{environment_id}")}quickstart(o){return R.fromPromise(this.__quickstart(o))}async __quickstart(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"quickstart"),method:"POST",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:jl.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 400:throw new v(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"POST","/quickstart")}getWhoAmI(o){return R.fromPromise(this.__getWhoAmI(o))}async __getWhoAmI(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"whoami"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Pl.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/whoami")}};var na=class{constructor(o){this._options=K(o)}listCoupons(o={},i){return R.fromPromise(this.__listCoupons(o,i))}async __listCoupons(o={},i){let{isActive:t,q:s,limit:r,offset:a}=o,d={is_active:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/coupons"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:op.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/coupons")}upsertBillingCoupon(o,i){return R.fromPromise(this.__upsertBillingCoupon(o,i))}async __upsertBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/coupons"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:cn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/coupons")}deleteBillingCoupon(o,i){return R.fromPromise(this.__deleteBillingCoupon(o,i))}async __deleteBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/coupons/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/coupons/{billing_id}")}deleteBillingCustomer(o,i){return R.fromPromise(this.__deleteBillingCustomer(o,i))}async __deleteBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/customer/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/customer/{billing_id}")}upsertBillingCustomer(o,i){return R.fromPromise(this.__upsertBillingCustomer(o,i))}async __upsertBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customer/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:tn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/customer/upsert")}listCustomersWithSubscriptions(o={},i){return R.fromPromise(this.__listCustomersWithSubscriptions(o,i))}async __listCustomersWithSubscriptions(o={},i){let{companyIds:t,name:s,providerType:r,q:a,limit:d,offset:y}=o,g={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customers"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:sp.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/customers")}countCustomers(o={},i){return R.fromPromise(this.__countCustomers(o,i))}async __countCustomers(o={},i){let{companyIds:t,name:s,providerType:r,q:a,limit:d,offset:y}=o,g={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/customers/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Ll.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/customers/count")}listInvoices(o,i){return R.fromPromise(this.__listInvoices(o,i))}async __listInvoices(o,i){let{companyId:t,customerExternalId:s,subscriptionExternalId:r,limit:a,offset:d}=o,y={company_id:t,customer_external_id:s,subscription_external_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/invoices"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:lp.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/billing/invoices")}upsertInvoice(o,i){return R.fromPromise(this.__upsertInvoice(o,i))}async __upsertInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/invoices"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ln.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_p.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/invoices")}deleteBillingInvoice(o,i){return R.fromPromise(this.__deleteBillingInvoice(o,i))}async __deleteBillingInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/invoices/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/invoices/{billing_id}")}listMeters(o={},i){return R.fromPromise(this.__listMeters(o,i))}async __listMeters(o={},i){let{displayName:t,limit:s,offset:r}=o,a={display_name:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/meter"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:up.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/billing/meter")}upsertBillingMeter(o,i){return R.fromPromise(this.__upsertBillingMeter(o,i))}async __upsertBillingMeter(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/meter/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:pn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/meter/upsert")}listPaymentMethods(o,i){return R.fromPromise(this.__listPaymentMethods(o,i))}async __listPaymentMethods(o,i){let{companyId:t,customerExternalId:s,limit:r,offset:a}=o,d={company_id:t,customer_external_id:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/payment-methods"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:mp.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/payment-methods")}upsertPaymentMethod(o,i){return R.fromPromise(this.__upsertPaymentMethod(o,i))}async __upsertPaymentMethod(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/payment-methods"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:un.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/payment-methods")}deletePaymentMethodByExternalId(o,i){return R.fromPromise(this.__deletePaymentMethodByExternalId(o,i))}async __deletePaymentMethodByExternalId(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/payment-methods/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$l.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/payment-methods/{billing_id}")}listBillingPrices(o={},i){return R.fromPromise(this.__listBillingPrices(o,i))}async __listBillingPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:d,isActive:y,planVersionId:g,price:l,productId:h,productIds:w,providerType:U,q:T,tiersMode:O,usageType:A,withMeter:j,limit:D,offset:V}=o,oe={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:d,is_active:y,plan_version_id:g,price:l,product_id:h,product_ids:w,provider_type:U!=null?k.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,q:T,tiers_mode:O!=null?de.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:A!=null?ce.jsonOrThrow(A,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:j,limit:D,offset:V},ue=await this._options.authProvider.getAuthRequest(),Ue=f(ue.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/price"),method:"GET",headers:Ue,queryString:u.queryBuilder().addMany(oe).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Zl.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return E(B.error,B.rawResponse,"GET","/billing/price")}upsertBillingPrice(o,i){return R.fromPromise(this.__upsertBillingPrice(o,i))}async __upsertBillingPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/price/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:an.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:bp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/price/upsert")}deleteBillingProduct(o,i){return R.fromPromise(this.__deleteBillingProduct(o,i))}async __deleteBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/product/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Nl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/product/{billing_id}")}listBillingProductPrices(o={},i){return R.fromPromise(this.__listBillingProductPrices(o,i))}async __listBillingProductPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:d,isActive:y,planVersionId:g,price:l,productId:h,productIds:w,providerType:U,q:T,tiersMode:O,usageType:A,withMeter:j,limit:D,offset:V}=o,oe={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:d,is_active:y,plan_version_id:g,price:l,product_id:h,product_ids:w,provider_type:U!=null?k.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,q:T,tiers_mode:O!=null?de.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:A!=null?ce.jsonOrThrow(A,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:j,limit:D,offset:V},ue=await this._options.authProvider.getAuthRequest(),Ue=f(ue.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/product/prices"),method:"GET",headers:Ue,queryString:u.queryBuilder().addMany(oe).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Ql.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return E(B.error,B.rawResponse,"GET","/billing/product/prices")}deleteProductPrice(o,i){return R.fromPromise(this.__deleteProductPrice(o,i))}async __deleteProductPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/product/prices/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Jl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/product/prices/{billing_id}")}upsertBillingProduct(o,i){return R.fromPromise(this.__upsertBillingProduct(o,i))}async __upsertBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/product/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:nn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/product/upsert")}listBillingProducts(o={},i){return R.fromPromise(this.__listBillingProducts(o,i))}async __listBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:a,providerType:d,q:y,recurringChargesOnly:g,withOneTimeCharges:l,withPricesOnly:h,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=o,A={ids:t,is_active:s,name:r,price_usage_type:a!=null?ce.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,recurring_charges_only:g,with_one_time_charges:l,with_prices_only:h,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},j=await this._options.authProvider.getAuthRequest(),D=f(j.headers,this._options?.headers,i?.headers),V=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/products"),method:"GET",headers:D,queryString:u.queryBuilder().addMany(A).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(V.ok)return{data:rp.parseOrThrow(V.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:V.rawResponse};if(V.error.reason==="status-code")switch(V.error.statusCode){case 400:throw new v(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 401:throw new x(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 403:throw new _(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 404:throw new P(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 500:throw new S(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);default:throw new b({statusCode:V.error.statusCode,body:V.error.body,rawResponse:V.rawResponse})}return E(V.error,V.rawResponse,"GET","/billing/products")}countBillingProducts(o={},i){return R.fromPromise(this.__countBillingProducts(o,i))}async __countBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:a,providerType:d,q:y,recurringChargesOnly:g,withOneTimeCharges:l,withPricesOnly:h,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=o,A={ids:t,is_active:s,name:r,price_usage_type:a!=null?ce.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,recurring_charges_only:g,with_one_time_charges:l,with_prices_only:h,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},j=await this._options.authProvider.getAuthRequest(),D=f(j.headers,this._options?.headers,i?.headers),V=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/products/count"),method:"GET",headers:D,queryString:u.queryBuilder().addMany(A).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(V.ok)return{data:Fl.parseOrThrow(V.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:V.rawResponse};if(V.error.reason==="status-code")switch(V.error.statusCode){case 400:throw new v(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 401:throw new x(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 403:throw new _(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 404:throw new P(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 500:throw new S(n.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);default:throw new b({statusCode:V.error.statusCode,body:V.error.body,rawResponse:V.rawResponse})}return E(V.error,V.rawResponse,"GET","/billing/products/count")}upsertBillingSubscription(o,i){return R.fromPromise(this.__upsertBillingSubscription(o,i))}async __upsertBillingSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/subscription/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:sn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/subscription/upsert")}};var sa=class{constructor(o){this._options=K(o)}listCatalogs(o={},i){return R.fromPromise(this.__listCatalogs(o,i))}async __listCatalogs(o={},i){let{isDefault:t,q:s,limit:r,offset:a}=o,d={is_default:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"catalogs"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Np.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/catalogs")}createCatalog(o,i){return R.fromPromise(this.__createCatalog(o,i))}async __createCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"catalogs"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:dn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/catalogs")}getCatalog(o,i){return R.fromPromise(this.__getCatalog(o,i))}async __getCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Up.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}")}updateCatalog(o,i={},t){return R.fromPromise(this.__updateCatalog(o,i,t))}async __updateCatalog(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:gn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:$p.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/catalogs/{catalog_id}")}deleteCatalog(o,i){return R.fromPromise(this.__deleteCatalog(o,i))}async __deleteCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ep.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/catalogs/{catalog_id}")}getConfiguration(o,i){return R.fromPromise(this.__getConfiguration(o,i))}async __getConfiguration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/configuration`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Dp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/configuration")}updateConfiguration(o,i={},t){return R.fromPromise(this.__updateConfiguration(o,i,t))}async __updateConfiguration(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/configuration`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:hn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Jp.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/catalogs/{catalog_id}/configuration")}getCreditBundlesInCatalog(o,i){return R.fromPromise(this.__getCreditBundlesInCatalog(o,i))}async __getCreditBundlesInCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ip.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/credit-bundles")}addCreditBundle(o,i,t){return R.fromPromise(this.__addCreditBundle(o,i,t))}async __addCreditBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles/${u.encodePathParam(i)}`),method:"POST",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/catalogs/{catalog_id}/credit-bundles/{credit_bundle_id}")}removeCreditBundle(o,i,t){return R.fromPromise(this.__removeCreditBundle(o,i,t))}async __removeCreditBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/credit-bundles/${u.encodePathParam(i)}`),method:"DELETE",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"DELETE","/catalogs/{catalog_id}/credit-bundles/{credit_bundle_id}")}getDerivedFeatures(o,i){return R.fromPromise(this.__getDerivedFeatures(o,i))}async __getDerivedFeatures(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/features`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Lp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/features")}getPlansInCatalog(o,i){return R.fromPromise(this.__getPlansInCatalog(o,i))}async __getPlansInCatalog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Wp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/catalogs/{catalog_id}/plans")}addPlan(o,i,t){return R.fromPromise(this.__addPlan(o,i,t))}async __addPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans/${u.encodePathParam(i)}`),method:"POST",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/catalogs/{catalog_id}/plans/{plan_id}")}removePlan(o,i,t){return R.fromPromise(this.__removePlan(o,i,t))}async __removePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`catalogs/${u.encodePathParam(o)}/plans/${u.encodePathParam(i)}`),method:"DELETE",headers:r,queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"DELETE","/catalogs/{catalog_id}/plans/{plan_id}")}};var ca=class{constructor(o){this._options=K(o)}internal(o,i){return R.fromPromise(this.__internal(o,i))}async __internal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:su.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal")}getCheckoutData(o,i){return R.fromPromise(this.__getCheckoutData(o,i))}async __getCheckoutData(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal/data"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:bn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:du.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal/data")}previewCheckoutInternal(o,i){return R.fromPromise(this.__previewCheckoutInternal(o,i))}async __previewCheckoutInternal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"checkout-internal/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ru.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal/preview")}getCompanyBillingDetails(o,i){return R.fromPromise(this.__getCompanyBillingDetails(o,i))}async __getCompanyBillingDetails(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}/billing-details`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/companies/{company_id}/billing-details")}updateCompanyBillingDetails(o,i,t){return R.fromPromise(this.__updateCompanyBillingDetails(o,i,t))}async __updateCompanyBillingDetails(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}/billing-details`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:zn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Su.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/companies/{company_id}/billing-details")}managePlan(o,i){return R.fromPromise(this.__managePlan(o,i))}async __managePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ss.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan")}previewManagePlan(o,i){return R.fromPromise(this.__previewManagePlan(o,i))}async __previewManagePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ss.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_u.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan/preview")}cancelSubscription(o,i){return R.fromPromise(this.__cancelSubscription(o,i))}async __cancelSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"manage-plan/subscription/cancel"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:wn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:au.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan/subscription/cancel")}updateCustomerSubscriptionTrialEnd(o,i={},t){return R.fromPromise(this.__updateCustomerSubscriptionTrialEnd(o,i,t))}async __updateCustomerSubscriptionTrialEnd(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`subscription/${u.encodePathParam(o)}/edit-trial-end`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Pu.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/subscription/{subscription_id}/edit-trial-end")}};var la=class{constructor(o){this._options=K(o)}listCompanies(o={},i){return R.fromPromise(this.__listCompanies(o,i))}async __listCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:d,planIds:y,planVersionId:g,planVersionIds:l,q:h,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:A,withoutFeatureOverrideFor:j,withoutPlan:D,withoutSubscription:V,withSubscription:oe,limit:ue,offset:Ue}=o,B={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:d,plan_ids:y,plan_version_id:g,plan_version_ids:l,q:h,sort_order_column:w,sort_order_direction:U!=null?je.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(Rr=>Er.jsonOrThrow(Rr,{unrecognizedObjectKeys:"strip"})):T!=null?Er.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(Rr=>Ur.jsonOrThrow(Rr,{unrecognizedObjectKeys:"strip"})):O!=null?Ur.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:A,without_feature_override_for:j,without_plan:D,without_subscription:V,with_subscription:oe,limit:ue,offset:Ue},ni=await this._options.authProvider.getAuthRequest(),zr=f(ni.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies"),method:"GET",headers:zr,queryString:u.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(M.ok)return{data:ud.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 400:throw new v(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new x(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new P(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return E(M.error,M.rawResponse,"GET","/companies")}upsertCompany(o,i){return R.fromPromise(this.__upsertCompany(o,i))}async __upsertCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:xs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Td.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies")}getCompany(o,i){return R.fromPromise(this.__getCompany(o,i))}async __getCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Xu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/companies/{company_id}")}deleteCompany(o,i={},t){return R.fromPromise(this.__deleteCompany(o,i,t))}async __deleteCompany(o,i={},t){let{cancelSubscription:s,prorate:r}=i,a={cancel_subscription:s,prorate:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`companies/${u.encodePathParam(o)}`),method:"DELETE",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Fu.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"DELETE","/companies/{company_id}")}countCompanies(o={},i){return R.fromPromise(this.__countCompanies(o,i))}async __countCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:d,planIds:y,planVersionId:g,planVersionIds:l,q:h,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:A,withoutFeatureOverrideFor:j,withoutPlan:D,withoutSubscription:V,withSubscription:oe,limit:ue,offset:Ue}=o,B={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:d,plan_ids:y,plan_version_id:g,plan_version_ids:l,q:h,sort_order_column:w,sort_order_direction:U!=null?je.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(Rr=>Er.jsonOrThrow(Rr,{unrecognizedObjectKeys:"strip"})):T!=null?Er.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(Rr=>Ur.jsonOrThrow(Rr,{unrecognizedObjectKeys:"strip"})):O!=null?Ur.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:A,without_feature_override_for:j,without_plan:D,without_subscription:V,with_subscription:oe,limit:ue,offset:Ue},ni=await this._options.authProvider.getAuthRequest(),zr=f(ni.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/count"),method:"GET",headers:zr,queryString:u.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(M.ok)return{data:Eu.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 400:throw new v(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new x(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new P(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return E(M.error,M.rawResponse,"GET","/companies/count")}createCompany(o,i){return R.fromPromise(this.__createCompany(o,i))}async __createCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/create"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:xs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies/create")}deleteCompanyByKeys(o,i){return R.fromPromise(this.__deleteCompanyByKeys(o,i))}async __deleteCompanyByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/delete"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:_s.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Du.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies/delete")}lookupCompany(o,i){return R.fromPromise(this.__lookupCompany(o,i))}async __lookupCompany(o,i){let{keys:t}=o,s={keys:ve(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"companies/lookup"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:xd.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/companies/lookup")}getCompanyBillingEntity(o={},i){return R.fromPromise(this.__getCompanyBillingEntity(o,i))}async __getCompanyBillingEntity(o={},i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-billing-entity"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Zu.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/company-billing-entity")}getBillingEntityChildSubscriptions(o={},i){return R.fromPromise(this.__getBillingEntityChildSubscriptions(o,i))}async __getBillingEntityChildSubscriptions(o={},i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-billing-entity-subscriptions"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:$u.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/company-billing-entity-subscriptions")}listCompanyMemberships(o={},i){return R.fromPromise(this.__listCompanyMemberships(o,i))}async __listCompanyMemberships(o={},i){let{companyId:t,userId:s,limit:r,offset:a}=o,d={company_id:t,user_id:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-memberships"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:md.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/company-memberships")}getOrCreateCompanyMembership(o,i){return R.fromPromise(this.__getOrCreateCompanyMembership(o,i))}async __getOrCreateCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-memberships"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Pn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:od.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-memberships")}deleteCompanyMembership(o,i){return R.fromPromise(this.__deleteCompanyMembership(o,i))}async __deleteCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-memberships/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Mu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/company-memberships/{company_membership_id}")}getActiveCompanySubscription(o={},i){return R.fromPromise(this.__getActiveCompanySubscription(o,i))}async __getActiveCompanySubscription(o={},i){let{companyId:t,companyIds:s,limit:r,offset:a}=o,d={company_id:t,company_ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-subscriptions"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Wu.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/company-subscriptions")}upsertCompanyTrait(o,i){return R.fromPromise(this.__upsertCompanyTrait(o,i))}async __upsertCompanyTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-traits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Cs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Od.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-traits")}listEntityKeyDefinitions(o={},i){return R.fromPromise(this.__listEntityKeyDefinitions(o,i))}async __listEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:a,offset:d}=o,y={entity_type:t!=null?te.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-key-definitions"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:gd.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/entity-key-definitions")}countEntityKeyDefinitions(o={},i){return R.fromPromise(this.__countEntityKeyDefinitions(o,i))}async __countEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:a,offset:d}=o,y={entity_type:t!=null?te.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-key-definitions/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:vu.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/entity-key-definitions/count")}listEntityTraitDefinitions(o={},i){return R.fromPromise(this.__listEntityTraitDefinitions(o,i))}async __listEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:a,traitTypes:d,limit:y,offset:g}=o,l={entity_type:t!=null?te.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(d)?d.map(T=>me.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):d!=null?me.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:wd.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/entity-trait-definitions")}getOrCreateEntityTraitDefinition(o,i){return R.fromPromise(this.__getOrCreateEntityTraitDefinition(o,i))}async __getOrCreateEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Sn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:td.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/entity-trait-definitions")}getEntityTraitDefinition(o,i){return R.fromPromise(this.__getEntityTraitDefinition(o,i))}async __getEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-trait-definitions/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Qu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/entity-trait-definitions/{entity_trait_definition_id}")}updateEntityTraitDefinition(o,i,t){return R.fromPromise(this.__updateEntityTraitDefinition(o,i,t))}async __updateEntityTraitDefinition(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`entity-trait-definitions/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Ud.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/entity-trait-definitions/{entity_trait_definition_id}")}countEntityTraitDefinitions(o={},i){return R.fromPromise(this.__countEntityTraitDefinitions(o,i))}async __countEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:a,traitTypes:d,limit:y,offset:g}=o,l={entity_type:t!=null?te.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(d)?d.map(T=>me.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):d!=null?me.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-definitions/count"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Ou.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/entity-trait-definitions/count")}getEntityTraitValues(o,i){return R.fromPromise(this.__getEntityTraitValues(o,i))}async __getEntityTraitValues(o,i){let{definitionId:t,q:s,limit:r,offset:a}=o,d={definition_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"entity-trait-values"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:id.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/entity-trait-values")}listPlanChanges(o={},i){return R.fromPromise(this.__listPlanChanges(o,i))}async __listPlanChanges(o={},i){let{action:t,basePlanAction:s,companyId:r,companyIds:a,planIds:d,limit:y,offset:g}=o,l={action:t!=null?Fi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,base_plan_action:s!=null?Ki.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,company_id:r,company_ids:a,plan_ids:d,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-changes"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:zd.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/plan-changes")}getPlanChange(o,i){return R.fromPromise(this.__getPlanChange(o,i))}async __getPlanChange(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-changes/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:sd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-changes/{plan_change_id}")}listPlanTraits(o={},i){return R.fromPromise(this.__listPlanTraits(o,i))}async __listPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:a,limit:d,offset:y}=o,g={ids:t,plan_id:s,trait_id:r,trait_ids:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:fd.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/plan-traits")}getPlanTrait(o,i){return R.fromPromise(this.__getPlanTrait(o,i))}async __getPlanTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-traits/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:cd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-traits/{plan_trait_id}")}updatePlanTraitsBulk(o,i){return R.fromPromise(this.__updatePlanTraitsBulk(o,i))}async __updatePlanTraitsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits/bulk"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Cn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:vd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-traits/bulk")}countPlanTraits(o={},i){return R.fromPromise(this.__countPlanTraits(o,i))}async __countPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:a,limit:d,offset:y}=o,g={ids:t,plan_id:s,trait_id:r,trait_ids:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-traits/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Bu.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/plan-traits/count")}upsertUserTrait(o,i){return R.fromPromise(this.__upsertUserTrait(o,i))}async __upsertUserTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"user-traits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Cs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Bd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/user-traits")}listUsers(o={},i){return R.fromPromise(this.__listUsers(o,i))}async __listUsers(o={},i){let{companyId:t,ids:s,planId:r,q:a,limit:d,offset:y}=o,g={company_id:t,ids:s,plan_id:r,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Sd.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/users")}upsertUser(o,i){return R.fromPromise(this.__upsertUser(o,i))}async __upsertUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Es.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:kd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users")}getUser(o,i){return R.fromPromise(this.__getUser(o,i))}async __getUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`users/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ld.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/users/{user_id}")}deleteUser(o,i){return R.fromPromise(this.__deleteUser(o,i))}async __deleteUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`users/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Lu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/users/{user_id}")}countUsers(o={},i){return R.fromPromise(this.__countUsers(o,i))}async __countUsers(o={},i){let{companyId:t,ids:s,planId:r,q:a,limit:d,offset:y}=o,g={company_id:t,ids:s,plan_id:r,q:a,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Au.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/users/count")}createUser(o,i){return R.fromPromise(this.__createUser(o,i))}async __createUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/create"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Es.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users/create")}deleteUserByKeys(o,i){return R.fromPromise(this.__deleteUserByKeys(o,i))}async __deleteUserByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/delete"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:_s.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ku.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users/delete")}lookupUser(o,i){return R.fromPromise(this.__lookupUser(o,i))}async __lookupUser(o,i){let{keys:t}=o,s={keys:ve(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"users/lookup"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Ed.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/users/lookup")}};var pa=class{constructor(o){this._options=K(o)}listComponents(o={},i){return R.fromPromise(this.__listComponents(o,i))}async __listComponents(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Fd.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/components")}createComponent(o,i){return R.fromPromise(this.__createComponent(o,i))}async __createComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:vn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/components")}getComponent(o,i){return R.fromPromise(this.__getComponent(o,i))}async __getComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Md.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/components/{component_id}")}updateComponent(o,i={},t){return R.fromPromise(this.__updateComponent(o,i,t))}async __updateComponent(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Tn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Xd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/components/{component_id}")}deleteComponent(o,i){return R.fromPromise(this.__deleteComponent(o,i))}async __deleteComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Dd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/components/{component_id}")}bindCatalog(o,i={},t){return R.fromPromise(this.__bindCatalog(o,i,t))}async __bindCatalog(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`components/${u.encodePathParam(o)}/catalog`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Un.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:jd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/components/{component_id}/catalog")}countComponents(o={},i){return R.fromPromise(this.__countComponents(o,i))}async __countComponents(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Vd.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/components/count")}previewComponentData(o={},i){return R.fromPromise(this.__previewComponentData(o,i))}async __previewComponentData(o={},i){let{companyId:t,componentId:s}=o,r={company_id:t,component_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"components/preview-data"),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Zd.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/components/preview-data")}};var ua=class{constructor(o){this._options=K(o)}getPublicPlans(o){return R.fromPromise(this.__getPublicPlans(o))}async __getPublicPlans(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"public/plans"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:em.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/public/plans")}};var da=class{constructor(o){this._options=K(o)}listBillingCredits(o={},i){return R.fromPromise(this.__listBillingCredits(o,i))}async __listBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:a}=o,d={ids:t,name:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Em.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/credits")}createBillingCredit(o,i){return R.fromPromise(this.__createBillingCredit(o,i))}async __createBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:jn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits")}getSingleBillingCredit(o,i){return R.fromPromise(this.__getSingleBillingCredit(o,i))}async __getSingleBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_m.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/{credit_id}")}updateBillingCredit(o,i,t){return R.fromPromise(this.__updateBillingCredit(o,i,t))}async __updateBillingCredit(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Dn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:$m.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/{credit_id}")}softDeleteBillingCredit(o,i){return R.fromPromise(this.__softDeleteBillingCredit(o,i))}async __softDeleteBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Nm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/credits/{credit_id}")}listCompanyCreditBalances(o,i){return R.fromPromise(this.__listCompanyCreditBalances(o,i))}async __listCompanyCreditBalances(o,i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/balance"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:km.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new v(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/billing/credits/balance")}listCreditBundles(o={},i){return R.fromPromise(this.__listCreditBundles(o,i))}async __listCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:a,limit:d,offset:y}=o,g={ids:t,credit_id:s,status:r!=null?Ee.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?De.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Vm.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/credits/bundles")}createCreditBundle(o,i){return R.fromPromise(this.__createCreditBundle(o,i))}async __createCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Vn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ym.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/bundles")}getCreditBundle(o,i){return R.fromPromise(this.__getCreditBundle(o,i))}async __getCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/bundles/{bundle_id}")}updateCreditBundleDetails(o,i,t){return R.fromPromise(this.__updateCreditBundleDetails(o,i,t))}async __updateCreditBundleDetails(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Mn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Ym.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/bundles/{bundle_id}")}deleteCreditBundle(o,i){return R.fromPromise(this.__deleteCreditBundle(o,i))}async __deleteCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/credits/bundles/{bundle_id}")}countCreditBundles(o={},i){return R.fromPromise(this.__countCreditBundles(o,i))}async __countCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:a,limit:d,offset:y}=o,g={ids:t,credit_id:s,status:r!=null?Ee.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?De.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/bundles/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:um.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/credits/bundles/count")}countBillingCredits(o={},i){return R.fromPromise(this.__countBillingCredits(o,i))}async __countBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:a}=o,d={ids:t,name:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:am.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/credits/count")}zeroOutGrant(o,i={},t){return R.fromPromise(this.__zeroOutGrant(o,i,t))}async __zeroOutGrant(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/grants/${u.encodePathParam(o)}/zero-out`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:In.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Zm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/grants/{grant_id}/zero-out")}grantBillingCreditsToCompany(o,i){return R.fromPromise(this.__grantBillingCreditsToCompany(o,i))}async __grantBillingCreditsToCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:An.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/grants/company")}countCompanyGrants(o={},i){return R.fromPromise(this.__countCompanyGrants(o,i))}async __countCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:a,offset:d}=o,y={company_id:t,order:s!=null?ui.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?je.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:lm.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/billing/credits/grants/company/count")}listCompanyGrants(o={},i){return R.fromPromise(this.__listCompanyGrants(o,i))}async __listCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:a,offset:d}=o,y={company_id:t,order:s!=null?ui.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?je.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/company/list"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:jm.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/billing/credits/grants/company/list")}countBillingCreditsGrants(o={},i){return R.fromPromise(this.__countBillingCreditsGrants(o,i))}async __countBillingCreditsGrants(o={},i){let{creditId:t,ids:s,limit:r,offset:a}=o,d={credit_id:t,ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:om.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/credits/grants/count")}listGrantsForCredit(o={},i){return R.fromPromise(this.__listGrantsForCredit(o,i))}async __listGrantsForCredit(o={},i){let{creditId:t,ids:s,limit:r,offset:a}=o,d={credit_id:t,ids:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/grants/list"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Wm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/billing/credits/grants/list")}acquireCreditLease(o,i){return R.fromPromise(this.__acquireCreditLease(o,i))}async __acquireCreditLease(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/lease"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Bn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:rm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/lease")}extendCreditLease(o,i,t){return R.fromPromise(this.__extendCreditLease(o,i,t))}async __extendCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/lease/${u.encodePathParam(o)}/extend`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:qn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Rm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/extend")}releaseCreditLease(o,i,t){return R.fromPromise(this.__releaseCreditLease(o,i,t))}async __releaseCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/lease/${u.encodePathParam(o)}/release`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ob.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Hm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/release")}listBillingPlanCreditGrants(o={},i){return R.fromPromise(this.__listBillingPlanCreditGrants(o,i))}async __listBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:a,planVersionId:d,planVersionIds:y,limit:g,offset:l}=o,h={credit_id:t,ids:s,plan_id:r,plan_ids:a,plan_version_id:d,plan_version_ids:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:vm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/billing/credits/plan-grants")}createBillingPlanCreditGrant(o,i){return R.fromPromise(this.__createBillingPlanCreditGrant(o,i))}async __createBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:At.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/plan-grants")}getSingleBillingPlanCreditGrant(o,i){return R.fromPromise(this.__getSingleBillingPlanCreditGrant(o,i))}async __getSingleBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/plan-grants/{plan_grant_id}")}updateBillingPlanCreditGrant(o,i,t){return R.fromPromise(this.__updateBillingPlanCreditGrant(o,i,t))}async __updateBillingPlanCreditGrant(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:qt.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Jm.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/plan-grants/{plan_grant_id}")}deleteBillingPlanCreditGrant(o,i={},t){return R.fromPromise(this.__deleteBillingPlanCreditGrant(o,i,t))}async __deleteBillingPlanCreditGrant(o,i={},t){let{applyToExisting:s}=i,r={apply_to_existing:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"DELETE",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:bm.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"DELETE","/billing/credits/plan-grants/{plan_grant_id}")}countBillingPlanCreditGrants(o={},i){return R.fromPromise(this.__countBillingPlanCreditGrants(o,i))}async __countBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:a,planVersionId:d,planVersionIds:y,limit:g,offset:l}=o,h={credit_id:t,ids:s,plan_id:r,plan_ids:a,plan_version_id:d,plan_version_ids:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/plan-grants/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:sm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/billing/credits/plan-grants/count")}listCreditEventLedger(o,i){return R.fromPromise(this.__listCreditEventLedger(o,i))}async __listCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:a,featureId:d,startTime:y,limit:g,offset:l}=o,h={billing_credit_id:t,company_id:s,end_time:r,event_type:a!=null?vr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:d,start_time:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"v2/billing/credits/ledger"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:Lm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/v2/billing/credits/ledger")}countCreditEventLedger(o,i){return R.fromPromise(this.__countCreditEventLedger(o,i))}async __countCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:a,featureId:d,startTime:y,limit:g,offset:l}=o,h={billing_credit_id:t,company_id:s,end_time:r,event_type:a!=null?vr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:d,start_time:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"v2/billing/credits/ledger/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:mm.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/v2/billing/credits/ledger/count")}};var ma=class{constructor(o){this._options=K(o)}listDataExports(o={},i){return R.fromPromise(this.__listDataExports(o,i))}async __listDataExports(o={},i){let{exportType:t,status:s,limit:r,offset:a}=o,d={export_type:t!=null?Xr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,status:s!=null?Hi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"data-exports"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:oh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/data-exports")}createDataExport(o,i){return R.fromPromise(this.__createDataExport(o,i))}async __createDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"data-exports"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Fn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:eh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/data-exports")}getDataExport(o,i){return R.fromPromise(this.__getDataExport(o,i))}async __getDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`data-exports/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:rh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}")}getDataExportArtifact(o,i){return R.fromPromise(this.__getDataExportArtifact(o,i))}async __getDataExportArtifact(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`data-exports/${u.encodePathParam(o)}/artifact`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),responseType:"streaming",timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:r.body,rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}/artifact")}};var ha=class{constructor(o){this._options=K(o)}listCompanyOverrides(o={},i){return R.fromPromise(this.__listCompanyOverrides(o,i))}async __listCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:a,ids:d,withoutExpired:y,q:g,limit:l,offset:h}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:a,ids:d,without_expired:y,q:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:kh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/company-overrides")}createCompanyOverride(o,i){return R.fromPromise(this.__createCompanyOverride(o,i))}async __createCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ln.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-overrides")}getCompanyOverride(o,i){return R.fromPromise(this.__getCompanyOverride(o,i))}async __getCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_h.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/company-overrides/{company_override_id}")}updateCompanyOverride(o,i,t){return R.fromPromise(this.__updateCompanyOverride(o,i,t))}async __updateCompanyOverride(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Hn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Gh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/company-overrides/{company_override_id}")}deleteCompanyOverride(o,i){return R.fromPromise(this.__deleteCompanyOverride(o,i))}async __deleteCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-overrides/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/company-overrides/{company_override_id}")}countCompanyOverrides(o={},i){return R.fromPromise(this.__countCompanyOverrides(o,i))}async __countCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:a,ids:d,withoutExpired:y,q:g,limit:l,offset:h}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:a,ids:d,without_expired:y,q:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides/count"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:ah.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/company-overrides/count")}listFeatureCompanies(o,i){return R.fromPromise(this.__listFeatureCompanies(o,i))}async __listFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-companies"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Vh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/feature-companies")}countFeatureCompanies(o,i){return R.fromPromise(this.__countFeatureCompanies(o,i))}async __countFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-companies/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:sh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/feature-companies/count")}listFeatureUsage(o={},i){return R.fromPromise(this.__listFeatureUsage(o,i))}async __listFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:d,q:y,withoutNegativeEntitlements:g,limit:l,offset:h}=o,w={company_id:t,company_keys:s!=null?ve(s):void 0,feature_ids:r,include_usage_aggregation:a,managed_by:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,without_negative_entitlements:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:Dh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/feature-usage")}getFeatureUsageTimeSeries(o,i){return R.fromPromise(this.__getFeatureUsageTimeSeries(o,i))}async __getFeatureUsageTimeSeries(o,i){let{companyId:t,endTime:s,featureId:r,granularity:a,startTime:d}=o,y={company_id:t,end_time:s.toISOString(),feature_id:r,granularity:a!=null?Qe.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,start_time:d.toISOString()},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage-timeseries"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:vh.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/feature-usage-timeseries")}countFeatureUsage(o={},i){return R.fromPromise(this.__countFeatureUsage(o,i))}async __countFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:d,q:y,withoutNegativeEntitlements:g,limit:l,offset:h}=o,w={company_id:t,company_keys:s!=null?ve(s):void 0,feature_ids:r,include_usage_aggregation:a,managed_by:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:y,without_negative_entitlements:g,limit:l,offset:h},U=await this._options.authProvider.getAuthRequest(),T=f(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage/count"),method:"GET",headers:T,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:lh.parseOrThrow(O.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:O.rawResponse};if(O.error.reason==="status-code")switch(O.error.statusCode){case 400:throw new v(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/feature-usage/count")}listFeatureUsers(o,i){return R.fromPromise(this.__listFeatureUsers(o,i))}async __listFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-users"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Fh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/feature-users")}countFeatureUsers(o,i){return R.fromPromise(this.__countFeatureUsers(o,i))}async __countFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:a}=o,d={feature_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-users/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:uh.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/feature-users/count")}listPlanEntitlements(o={},i){return R.fromPromise(this.__listPlanEntitlements(o,i))}async __listPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:a,planIds:d,planVersionId:y,planVersionIds:g,q:l,withMeteredProducts:h,limit:w,offset:U}=o,T={feature_id:t,feature_ids:s,ids:r,plan_id:a,plan_ids:d,plan_version_id:y,plan_version_ids:g,q:l,with_metered_products:h,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),A=f(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements"),method:"GET",headers:A,queryString:u.queryBuilder().addMany(T).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(j.ok)return{data:Lh.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new v(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new x(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new P(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return E(j.error,j.rawResponse,"GET","/plan-entitlements")}createPlanEntitlement(o,i){return R.fromPromise(this.__createPlanEntitlement(o,i))}async __createPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Gn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements")}getPlanEntitlement(o,i){return R.fromPromise(this.__getPlanEntitlement(o,i))}async __getPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Th.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-entitlements/{plan_entitlement_id}")}updatePlanEntitlement(o,i,t){return R.fromPromise(this.__updatePlanEntitlement(o,i,t))}async __updatePlanEntitlement(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Nn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Wh.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-entitlements/{plan_entitlement_id}")}deletePlanEntitlement(o,i){return R.fromPromise(this.__deletePlanEntitlement(o,i))}async __deletePlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/plan-entitlements/{plan_entitlement_id}")}upsertPlanEntitlementForBillingProduct(o,i){return R.fromPromise(this.__upsertPlanEntitlementForBillingProduct(o,i))}async __upsertPlanEntitlementForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Kn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements/billing-linked")}countPlanEntitlements(o={},i){return R.fromPromise(this.__countPlanEntitlements(o,i))}async __countPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:a,planIds:d,planVersionId:y,planVersionIds:g,q:l,withMeteredProducts:h,limit:w,offset:U}=o,T={feature_id:t,feature_ids:s,ids:r,plan_id:a,plan_ids:d,plan_version_id:y,plan_version_ids:g,q:l,with_metered_products:h,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),A=f(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/count"),method:"GET",headers:A,queryString:u.queryBuilder().addMany(T).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(j.ok)return{data:mh.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new v(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new x(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new P(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return E(j.error,j.rawResponse,"GET","/plan-entitlements/count")}duplicatePlanEntitlements(o,i){return R.fromPromise(this.__duplicatePlanEntitlements(o,i))}async __duplicatePlanEntitlements(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-entitlements/duplicate"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Wn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements/duplicate")}getFeatureUsageByCompany(o,i){return R.fromPromise(this.__getFeatureUsageByCompany(o,i))}async __getFeatureUsageByCompany(o,i){let{keys:t}=o,s={keys:ve(t)},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"usage-by-company"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Ph.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/usage-by-company")}};var ga=class{constructor(o){this._options=K(o)}createEventBatch(o,i){return R.fromPromise(this.__createEventBatch(o,i))}async __createEventBatch(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"event-batch"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:$n.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Qh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/event-batch")}getEventSummaries(o={},i){return R.fromPromise(this.__getEventSummaries(o,i))}async __getEventSummaries(o={},i){let{q:t,eventSubtypes:s,limit:r,offset:a}=o,d={q:t,event_subtypes:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"event-types"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:tg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/event-types")}listEvents(o={},i){return R.fromPromise(this.__listEvents(o,i))}async __listEvents(o={},i){let{companyId:t,eventSubtype:s,eventTypes:r,flagId:a,idempotencyKey:d,userId:y,limit:g,offset:l}=o,h={company_id:t,event_subtype:s,event_types:Array.isArray(r)?r.map(O=>Tr.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"})):r!=null?Tr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,flag_id:a,idempotency_key:d,user_id:y,limit:g,offset:l},w=await this._options.authProvider.getAuthRequest(),U=f(w.headers,this._options?.headers,i?.headers),T=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"events"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(T.ok)return{data:cg.parseOrThrow(T.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:T.rawResponse};if(T.error.reason==="status-code")switch(T.error.statusCode){case 400:throw new v(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(n.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);default:throw new b({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse})}return E(T.error,T.rawResponse,"GET","/events")}createEvent(o,i){return R.fromPromise(this.__createEvent(o,i))}async __createEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"events"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:St.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:eg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/events")}getEvent(o,i){return R.fromPromise(this.__getEvent(o,i))}async __getEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`events/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ig.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/events/{event_id}")}getSegmentIntegrationStatus(o){return R.fromPromise(this.__getSegmentIntegrationStatus(o))}async __getSegmentIntegrationStatus(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"segment-integration"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:ng.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/segment-integration")}};var ya=class{constructor(o){this._options=K(o)}listFeatures(o={},i){return R.fromPromise(this.__listFeatures(o,i))}async __listFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:a,planVersionId:d,q:y,withoutCompanyOverrideFor:g,withoutPlanEntitlementFor:l,limit:h,offset:w}=o,U={boolean_require_event:t,feature_type:Array.isArray(s)?s.map(j=>le.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"})):s!=null?le.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,ids:r,managed_by:a!=null?k.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,plan_version_id:d,q:y,without_company_override_for:g,without_plan_entitlement_for:l,limit:h,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features"),method:"GET",headers:O,queryString:u.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:vg.parseOrThrow(A.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new v(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new x(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new P(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return E(A.error,A.rawResponse,"GET","/features")}createFeature(o,i){return R.fromPromise(this.__createFeature(o,i))}async __createFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Zn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_g.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/features")}getFeature(o,i){return R.fromPromise(this.__getFeature(o,i))}async __getFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/features/{feature_id}")}updateFeature(o,i={},t){return R.fromPromise(this.__updateFeature(o,i,t))}async __updateFeature(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:kg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/features/{feature_id}")}deleteFeature(o,i){return R.fromPromise(this.__deleteFeature(o,i))}async __deleteFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`features/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Pg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/features/{feature_id}")}upsertFeatureForBillingProduct(o,i){return R.fromPromise(this.__upsertFeatureForBillingProduct(o,i))}async __upsertFeatureForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Yn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/features/billing-linked")}countFeatures(o={},i){return R.fromPromise(this.__countFeatures(o,i))}async __countFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:a,planVersionId:d,q:y,withoutCompanyOverrideFor:g,withoutPlanEntitlementFor:l,limit:h,offset:w}=o,U={boolean_require_event:t,feature_type:Array.isArray(s)?s.map(j=>le.jsonOrThrow(j,{unrecognizedObjectKeys:"strip"})):s!=null?le.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,ids:r,managed_by:a!=null?k.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,plan_version_id:d,q:y,without_company_override_for:g,without_plan_entitlement_for:l,limit:h,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"features/count"),method:"GET",headers:O,queryString:u.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:zg.parseOrThrow(A.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new v(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new x(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new P(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return E(A.error,A.rawResponse,"GET","/features/count")}listFlags(o={},i){return R.fromPromise(this.__listFlags(o,i))}async __listFlags(o={},i){let{featureId:t,ids:s,q:r,limit:a,offset:d}=o,y={feature_id:t,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Og.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/flags")}createFlag(o,i){return R.fromPromise(this.__createFlag(o,i))}async __createFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:fs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags")}getFlag(o,i){return R.fromPromise(this.__getFlag(o,i))}async __getFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Eg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/flags/{flag_id}")}updateFlag(o,i,t){return R.fromPromise(this.__updateFlag(o,i,t))}async __updateFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:fs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Bg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/flags/{flag_id}")}deleteFlag(o,i){return R.fromPromise(this.__deleteFlag(o,i))}async __deleteFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:xg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/flags/{flag_id}")}updateFlagRules(o,i,t){return R.fromPromise(this.__updateFlagRules(o,i,t))}async __updateFlagRules(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}/rules`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Qn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Vg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/flags/{flag_id}/rules")}checkFlag(o,i,t){return R.fromPromise(this.__checkFlag(o,i,t))}async __checkFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`flags/${u.encodePathParam(o)}/check`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:So.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:ug.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/flags/{key}/check")}checkFlags(o,i){return R.fromPromise(this.__checkFlags(o,i))}async __checkFlags(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/check"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:So.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:wg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags/check")}checkFlagsBulk(o,i){return R.fromPromise(this.__checkFlagsBulk(o,i))}async __checkFlagsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/check-bulk"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Jn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:yg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags/check-bulk")}countFlags(o={},i){return R.fromPromise(this.__countFlags(o,i))}async __countFlags(o={},i){let{featureId:t,ids:s,q:r,limit:a,offset:d}=o,y={feature_id:t,ids:s,q:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"flags/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:fg.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/flags/count")}};var wa=class{constructor(o){this._options=K(o)}getActivity(o={},i){return R.fromPromise(this.__getActivity(o,i))}async __getActivity(o={},i){let{limit:t}=o,s={limit:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/activity"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Fg.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/insights/activity")}getEnvironmentFeatureUsageTimeSeries(o,i){return R.fromPromise(this.__getEnvironmentFeatureUsageTimeSeries(o,i))}async __getEnvironmentFeatureUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:a}=o,d={end_time:t.toISOString(),feature_id:s,granularity:r!=null?Qe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:a.toISOString()},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/feature-usage-timeseries"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Gg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/insights/feature-usage-timeseries")}getPlanGrowth(o={},i){return R.fromPromise(this.__getPlanGrowth(o,i))}async __getPlanGrowth(o={},i){let{months:t}=o,s={months:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/plan-growth"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Zg.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/insights/plan-growth")}getSummary(o){return R.fromPromise(this.__getSummary(o))}async __getSummary(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/summary"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:ey.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/insights/summary")}getTopFeaturesByUsage(o,i){return R.fromPromise(this.__getTopFeaturesByUsage(o,i))}async __getTopFeaturesByUsage(o,i){let{endTime:t,limit:s,startTime:r}=o,a={end_time:t.toISOString(),limit:s,start_time:r.toISOString()},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/top-features"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:ty.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/insights/top-features")}getEnvironmentTraitUsageTimeSeries(o,i){return R.fromPromise(this.__getEnvironmentTraitUsageTimeSeries(o,i))}async __getEnvironmentTraitUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:a}=o,d={end_time:t.toISOString(),feature_id:s,granularity:r!=null?Qe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:a.toISOString()},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"insights/trait-usage-timeseries"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Ng.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/insights/trait-usage-timeseries")}};var ba=class{constructor(o){this._options=K(o)}runIntegration(o,i){return R.fromPromise(this.__runIntegration(o,i))}async __runIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integration/start/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:fy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/integration/start/{integration_id}")}listIntegrations(o={},i){return R.fromPromise(this.__listIntegrations(o,i))}async __listIntegrations(o={},i){let{billingOnly:t,excludeIds:s,id:r,state:a,type:d,limit:y,offset:g}=o,l={billing_only:t,exclude_ids:s,id:r,state:a!=null?Me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,type:d!=null?Se.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:y,offset:g},h=await this._options.authProvider.getAuthRequest(),w=f(h.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:by.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new v(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/integrations")}getIntegrationWebhookUrl(o,i){return R.fromPromise(this.__getIntegrationWebhookUrl(o,i))}async __getIntegrationWebhookUrl(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integrations/${u.encodePathParam(o)}/webhook-url`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:my.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/integrations/{type}/webhook-url")}installIntegration(o,i){return R.fromPromise(this.__installIntegration(o,i))}async __installIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/install"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/install")}startDataImport(o,i){return R.fromPromise(this.__startDataImport(o,i))}async __startDataImport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/start-data-import"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:es.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_y.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/start-data-import")}loadSampleDataSet(o){return R.fromPromise(this.__loadSampleDataSet(o))}async __loadSampleDataSet(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/dataset-sample-v2"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Ry.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new x(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/integrations/stripe/dataset-sample-v2")}assumeStripeInstalled(o,i){return R.fromPromise(this.__assumeStripeInstalled(o,i))}async __assumeStripeInstalled(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/v2/assume-installed"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:uy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/stripe/v2/assume-installed")}installStripe(o,i){return R.fromPromise(this.__installStripe(o,i))}async __installStripe(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"integrations/stripe/v2/install"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/stripe/v2/install")}uninstallIntegration(o,i){return R.fromPromise(this.__uninstallIntegration(o,i))}async __uninstallIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`integrations/uninstall/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/integrations/uninstall/{integration_id}")}};var za=class{constructor(o){this._options=K(o)}listLicenses(o={},i){return R.fromPromise(this.__listLicenses(o,i))}async __listLicenses(o={},i){let{featureIds:t,ids:s,name:r,limit:a,offset:d}=o,y={feature_ids:t,ids:s,name:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"licenses"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Uy.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/licenses")}getSingleLicense(o,i){return R.fromPromise(this.__getSingleLicense(o,i))}async __getSingleLicense(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`licenses/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Cy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/licenses/{license_id}")}countLicenses(o={},i){return R.fromPromise(this.__countLicenses(o,i))}async __countLicenses(o={},i){let{featureIds:t,ids:s,name:r,limit:a,offset:d}=o,y={feature_ids:t,ids:s,name:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"licenses/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:xy.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/licenses/count")}};var Ra=class{constructor(o){this._options=K(o)}createCustomPlanBundle(o,i){return R.fromPromise(this.__createCustomPlanBundle(o,i))}async __createCustomPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:rs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:By.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/custom-plan-bundles")}createPlanBundle(o,i){return R.fromPromise(this.__createPlanBundle(o,i))}async __createPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:is.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:jy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-bundles")}updatePlanBundle(o,i,t){return R.fromPromise(this.__updatePlanBundle(o,i,t))}async __updatePlanBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-bundles/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:os.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Ay.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-bundles/{plan_bundle_id}")}};var fa=class{constructor(o){this._options=K(o)}getPlanGroup(o={},i){return R.fromPromise(this.__getPlanGroup(o,i))}async __getPlanGroup(o={},i){let{includeCompanyCounts:t}=o,s={include_company_counts:t},r=await this._options.authProvider.getAuthRequest(),a=f(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-groups"),method:"GET",headers:a,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Ly.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new x(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new _(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new P(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new S(n.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return E(d.error,d.rawResponse,"GET","/plan-groups")}createPlanGroup(o,i){return R.fromPromise(this.__createPlanGroup(o,i))}async __createPlanGroup(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-groups"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ts.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Dy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-groups")}updatePlanGroup(o,i,t){return R.fromPromise(this.__updatePlanGroup(o,i,t))}async __updatePlanGroup(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-groups/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:as.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Gy.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-groups/{plan_group_id}")}};var _a=class{constructor(o){this._options=K(o)}listCompanyMigrations(o={},i){return R.fromPromise(this.__listCompanyMigrations(o,i))}async __listCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:a,offset:d}=o,y={migration_id:t,q:s,status:r!=null?kr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-company-migrations"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Xy.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/plan-version-company-migrations")}retryCompanyMigration(o,i){return R.fromPromise(this.__retryCompanyMigration(o,i))}async __retryCompanyMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-company-migrations/${u.encodePathParam(o)}/retry`),method:"POST",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:tw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-version-company-migrations/{plan_version_company_migration_id}/retry")}countCompanyMigrations(o={},i){return R.fromPromise(this.__countCompanyMigrations(o,i))}async __countCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:a,offset:d}=o,y={migration_id:t,q:s,status:r!=null?kr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-company-migrations/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Hy.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/plan-version-company-migrations/count")}listMigrations(o={},i){return R.fromPromise(this.__listMigrations(o,i))}async __listMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:a}=o,d={plan_version_id:t,status:s!=null?Br.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ew.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/plan-version-migrations")}createMigration(o,i){return R.fromPromise(this.__createMigration(o,i))}async __createMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ss.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Jy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-version-migrations")}getMigration(o,i){return R.fromPromise(this.__getMigration(o,i))}async __getMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-migrations/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Yy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-version-migrations/{plan_version_migration_id}")}retryMigration(o,i,t){return R.fromPromise(this.__retryMigration(o,i,t))}async __retryMigration(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plan-version-migrations/${u.encodePathParam(o)}/retry`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ls.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:aw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/plan-version-migrations/{plan_version_migration_id}/retry")}countMigrations(o={},i){return R.fromPromise(this.__countMigrations(o,i))}async __countMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:a}=o,d={plan_version_id:t,status:s!=null?Br.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:$y.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/plan-version-migrations/count")}previewMigration(o,i){return R.fromPromise(this.__previewMigration(o,i))}async __previewMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plan-version-migrations/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:cs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:ow.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-version-migrations/preview")}};var Sa=class{constructor(o){this._options=K(o)}updateCompanyPlans(o,i,t){return R.fromPromise(this.__updateCompanyPlans(o,i,t))}async __updateCompanyPlans(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`company-plans/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:hs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Uw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/company-plans/{company_plan_id}")}listCustomPlanBillings(o={},i){return R.fromPromise(this.__listCustomPlanBillings(o,i))}async __listCustomPlanBillings(o={},i){let{companyId:t,planId:s,status:r,statuses:a,limit:d,offset:y}=o,g={company_id:t,plan_id:s,status:r!=null?Cr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,statuses:Array.isArray(a)?a.map(U=>Cr.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"})):a!=null?Cr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:y},l=await this._options.authProvider.getAuthRequest(),h=f(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plan-billings"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Rw.parseOrThrow(w.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:w.rawResponse};if(w.error.reason==="status-code")switch(w.error.statusCode){case 400:throw new v(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/custom-plan-billings")}markCustomPlanBillingPaid(o,i,t){return R.fromPromise(this.__markCustomPlanBillingPaid(o,i,t))}async __markCustomPlanBillingPaid(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`custom-plan-billings/${u.encodePathParam(o)}/mark-paid`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ib.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:xw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/mark-paid")}retryCustomPlanBilling(o,i,t){return R.fromPromise(this.__retryCustomPlanBilling(o,i,t))}async __retryCustomPlanBilling(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`custom-plan-billings/${u.encodePathParam(o)}/retry`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ms.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Ew.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/retry")}createCustomPlan(o,i){return R.fromPromise(this.__createCustomPlan(o,i))}async __createCustomPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"custom-plans"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:us.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:pw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/custom-plans")}listPlans(o={},i){return R.fromPromise(this.__listPlans(o,i))}async __listPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:d,forTrialExpiryPlan:y,hasProductId:g,ids:l,includeDraftVersions:h,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:A,withoutPaidProductId:j,limit:D,offset:V}=o,oe={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:a,for_initial_plan:d,for_trial_expiry_plan:y,has_product_id:g,ids:l,include_draft_versions:h,plan_type:w!=null?Q.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:A,without_paid_product_id:j,limit:D,offset:V},ue=await this._options.authProvider.getAuthRequest(),Ue=f(ue.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans"),method:"GET",headers:Ue,queryString:u.queryBuilder().addMany(oe).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Pw.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return E(B.error,B.rawResponse,"GET","/plans")}createPlan(o,i){return R.fromPromise(this.__createPlan(o,i))}async __createPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Dt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:uw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plans")}getPlan(o,i={},t){return R.fromPromise(this.__getPlan(o,i,t))}async __getPlan(o,i={},t){let{planVersionId:s}=i,r={plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:yw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/plans/{plan_id}")}updatePlan(o,i,t){return R.fromPromise(this.__updatePlan(o,i,t))}async __updatePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Mt.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:vw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/{plan_id}")}deletePlan(o,i){return R.fromPromise(this.__deletePlan(o,i))}async __deletePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:dw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/plans/{plan_id}")}upsertBillingProductPlan(o,i,t){return R.fromPromise(this.__upsertBillingProductPlan(o,i,t))}async __upsertBillingProductPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/${u.encodePathParam(o)}/billing_products`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ri.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Tw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/{plan_id}/billing_products")}upsertPlanForBillingProduct(o,i){return R.fromPromise(this.__upsertPlanForBillingProduct(o,i))}async __upsertPlanForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ps.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ow.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plans/billing-linked")}listBillingProductMatchCompanies(o,i){return R.fromPromise(this.__listBillingProductMatchCompanies(o,i))}async __listBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:a}=o,d={plan_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-product-match-companies"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:bw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/plans/billing-product-match-companies")}countBillingProductMatchCompanies(o,i){return R.fromPromise(this.__countBillingProductMatchCompanies(o,i))}async __countBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:a}=o,d={plan_id:t,q:s,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/billing-product-match-companies/count"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:sw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/plans/billing-product-match-companies/count")}countPlans(o={},i){return R.fromPromise(this.__countPlans(o,i))}async __countPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:d,forTrialExpiryPlan:y,hasProductId:g,ids:l,includeDraftVersions:h,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:A,withoutPaidProductId:j,limit:D,offset:V}=o,oe={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:a,for_initial_plan:d,for_trial_expiry_plan:y,has_product_id:g,ids:l,include_draft_versions:h,plan_type:w!=null?Q.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:A,without_paid_product_id:j,limit:D,offset:V},ue=await this._options.authProvider.getAuthRequest(),Ue=f(ue.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/count"),method:"GET",headers:Ue,queryString:u.queryBuilder().addMany(oe).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:lw.parseOrThrow(B.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new v(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return E(B.error,B.rawResponse,"GET","/plans/count")}listPlanIssues(o,i){return R.fromPromise(this.__listPlanIssues(o,i))}async __listPlanIssues(o,i){let{planId:t,planVersionId:s}=o,r={plan_id:t,plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"plans/issues"),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:_w.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/plans/issues")}deletePlanVersion(o,i={},t){return R.fromPromise(this.__deletePlanVersion(o,i,t))}async __deletePlanVersion(o,i={},t){let{promoteArchivedVersion:s}=i,r={promote_archived_version:s},a=await this._options.authProvider.getAuthRequest(),d=f(a.headers,this._options?.headers,t?.headers),y=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/version/${u.encodePathParam(o)}`),method:"DELETE",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:hw.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new v(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"DELETE","/plans/version/{plan_id}")}publishPlanVersion(o,i,t){return R.fromPromise(this.__publishPlanVersion(o,i,t))}async __publishPlanVersion(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`plans/version/${u.encodePathParam(o)}/publish`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ds.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Cw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/version/{plan_id}/publish")}};var Pa=class{constructor(o){this._options=K(o)}listScheduledCheckouts(o={},i){return R.fromPromise(this.__listScheduledCheckouts(o,i))}async __listScheduledCheckouts(o={},i){let{companyId:t,status:s,limit:r,offset:a}=o,d={company_id:t,status:s!=null?oi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},y=await this._options.authProvider.getAuthRequest(),g=f(y.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"scheduled-checkout"),method:"GET",headers:g,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Aw.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new v(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(n.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new b({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return E(l.error,l.rawResponse,"GET","/scheduled-checkout")}createScheduledCheckout(o,i){return R.fromPromise(this.__createScheduledCheckout(o,i))}async __createScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"scheduled-checkout"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:gs.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:kw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/scheduled-checkout")}getScheduledCheckout(o,i){return R.fromPromise(this.__getScheduledCheckout(o,i))}async __getScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`scheduled-checkout/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Bw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/scheduled-checkout/{scheduled_checkout_id}")}updateScheduledCheckout(o,i={},t){return R.fromPromise(this.__updateScheduledCheckout(o,i,t))}async __updateScheduledCheckout(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`scheduled-checkout/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ys.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Vw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/scheduled-checkout/{scheduled_checkout_id}")}};var xa=class{constructor(o){this._options=K(o)}listWebhookEvents(o={},i){return R.fromPromise(this.__listWebhookEvents(o,i))}async __listWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:a,offset:d}=o,y={ids:t,q:s,webhook_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhook-events"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Nw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/webhook-events")}getWebhookEvent(o,i){return R.fromPromise(this.__getWebhookEvent(o,i))}async __getWebhookEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhook-events/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/webhook-events/{webhook_event_id}")}countWebhookEvents(o={},i){return R.fromPromise(this.__countWebhookEvents(o,i))}async __countWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:a,offset:d}=o,y={ids:t,q:s,webhook_id:r,limit:a,offset:d},g=await this._options.authProvider.getAuthRequest(),l=f(g.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhook-events/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(h.ok)return{data:Dw.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new v(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/webhook-events/count")}listWebhooks(o={},i){return R.fromPromise(this.__listWebhooks(o,i))}async __listWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Jw.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/webhooks")}createWebhook(o,i){return R.fromPromise(this.__createWebhook(o,i))}async __createWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ws.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Fw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/webhooks")}getWebhook(o,i){return R.fromPromise(this.__getWebhook(o,i))}async __getWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ww.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/webhooks/{webhook_id}")}updateWebhook(o,i={},t){return R.fromPromise(this.__updateWebhook(o,i,t))}async __updateWebhook(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:zs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Xw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/webhooks/{webhook_id}")}deleteWebhook(o,i){return R.fromPromise(this.__deleteWebhook(o,i))}async __deleteWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=f(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Kw.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new v(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/webhooks/{webhook_id}")}sendTestWebhookAction(o,i,t){return R.fromPromise(this.__sendTestWebhookAction(o,i,t))}async __sendTestWebhookAction(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,t?.headers),a=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,`webhooks/${u.encodePathParam(o)}/test`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:bs.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(a.ok)return{data:Zw.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new v(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new x(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new P(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/webhooks/{webhook_id}/test")}countWebhooks(o={},i){return R.fromPromise(this.__countWebhooks(o,i))}async __countWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,a={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),y=f(d.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"webhooks/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(a).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Iw.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new v(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/webhooks/count")}};var Ca=class{constructor(o){this._options=K(o)}get accounts(){return this._accounts??=new aa(this._options)}get billing(){return this._billing??=new na(this._options)}get credits(){return this._credits??=new da(this._options)}get catalogs(){return this._catalogs??=new sa(this._options)}get checkout(){return this._checkout??=new ca(this._options)}get companies(){return this._companies??=new la(this._options)}get entitlements(){return this._entitlements??=new ha(this._options)}get plans(){return this._plans??=new Sa(this._options)}get components(){return this._components??=new pa(this._options)}get planbundle(){return this._planbundle??=new Ra(this._options)}get dataexports(){return this._dataexports??=new ma(this._options)}get events(){return this._events??=new ga(this._options)}get features(){return this._features??=new ya(this._options)}get insights(){return this._insights??=new wa(this._options)}get integrationsapi(){return this._integrationsapi??=new ba(this._options)}get licenses(){return this._licenses??=new za(this._options)}get plangroups(){return this._plangroups??=new fa(this._options)}get planmigrations(){return this._planmigrations??=new _a(this._options)}get componentspublic(){return this._componentspublic??=new ua(this._options)}get scheduledcheckout(){return this._scheduledcheckout??=new Pa(this._options)}get accesstokens(){return this._accesstokens??=new ta(this._options)}get webhooks(){return this._webhooks??=new xa(this._options)}getCreditLedger(o){return R.fromPromise(this.__getCreditLedger(o))}async __getCreditLedger(o){let i=await this._options.authProvider.getAuthRequest(),t=f(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??C)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"billing/credits/ledger"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:void 0,rawResponse:s.rawResponse};if(s.error.reason==="status-code")throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse});return E(s.error,s.rawResponse,"GET","/billing/credits/ledger")}async fetch(o,i,t){return Ga(o,i,{baseUrl:this._options.baseUrl??this._options.environment,headers:this._options.headers,timeoutInSeconds:this._options.timeoutInSeconds,maxRetries:this._options.maxRetries,fetch:this._options.fetch,logging:this._options.logging,getAuthHeaders:async()=>(await this._options.authProvider.getAuthRequest()).headers},t)}};var er={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Us={[er.Debug]:1,[er.Info]:2,[er.Warn]:3,[er.Error]:4},hb=er.Warn,ai=class{constructor(o=hb){this.level=Us[o]??Us[hb]}shouldLog(o){return Us[o]>=this.level}error(o,...i){this.shouldLog(er.Error)&&console.error(o,...i)}warn(o,...i){this.shouldLog(er.Warn)&&console.warn(o,...i)}info(o,...i){this.shouldLog(er.Info)&&console.info(o,...i)}debug(o,...i){this.shouldLog(er.Debug)&&console.debug(o,...i)}};var rf=1e3,of=1e3,tf=3,af=1e3,Ea=class{constructor(o,i){this.events=[];this.intervalId=null;this.shutdown=!1;this.stopped=!1;this.flushing=!1;let{logger:t=new ai,maxSize:s=of,interval:r=rf,offline:a=!1,maxRetries:d=tf,initialRetryDelay:y=af}=i||{};this.captureClient=o,this.interval=r,this.logger=t,this.maxSize=s,this.offline=a,this.maxRetries=d,this.initialRetryDelay=y,this.startPeriodicFlush()}async flush(){if(!(this.events.length===0||this.flushing)){this.flushing=!0;try{let o=[...this.events];this.events=[];let i=0,t=!1,s=null;for(;i<=this.maxRetries&&!t;)try{i>0&&this.logger.info(`Retrying event batch submission (attempt ${i} of ${this.maxRetries})`),await this.captureClient.sendBatch(o),t=!0}catch(r){if(s=r,i++,i<=this.maxRetries){let a=this.initialRetryDelay*Math.pow(2,i-1),d=Math.random()*.1*a,y=a+d;this.logger.warn(`Event batch submission failed: ${r}. Retrying in ${(y/1e3).toFixed(2)} seconds...`),process.env.NODE_ENV!=="test"&&await new Promise(g=>setTimeout(g,y))}}t?i>0&&this.logger.info(`Event batch submission succeeded after ${i} retries`):this.logger.error(`Event batch submission failed after ${this.maxRetries} retries:`,s)}finally{this.flushing=!1}}}async push(o){if(!this.offline){if(this.stopped){this.logger.error("Event buffer is stopped, not accepting new events");return}this.events.length>=this.maxSize&&!this.flushing&&await this.flush(),this.events.push(o)}}async stop(){this.shutdown=!0,this.stopped=!0,this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),await this.flush()}startPeriodicFlush(){this.offline||this.intervalId||(this.intervalId=setInterval(async()=>{this.shutdown||await this.flush()},this.interval),this.intervalId.unref&&this.intervalId.unref())}};var nf="https://c.schematichq.com",sf=1e4,cf=p=>p.replace(/\/+$/,"")+"/batch",lf=(p,o)=>{let i={api_key:o,type:p.eventType};return p.body!==void 0&&(i.body=_t.jsonOrThrow(p.body,{unrecognizedObjectKeys:"strip"})),p.idempotencyKey!==void 0&&(i.idempotency_key=p.idempotencyKey),p.sentAt!==void 0&&(i.sent_at=p.sentAt instanceof Date?p.sentAt.toISOString():p.sentAt),p.trustedClientClock!==void 0&&(i.trusted_client_clock=p.trustedClientClock),p.backfill!==void 0&&(i.backfill=p.backfill),i},pf=(p,o)=>({events:p.map(i=>lf(i,o))}),uf=p=>{if(typeof p!="object"||p===null||!("reason"in p))return"unknown error";let o=p;switch(o.reason){case"status-code":{let i=typeof o.body=="string"?o.body:JSON.stringify(o.body??"");return`HTTP ${o.statusCode}: ${i}`}case"timeout":return"request timed out";case"non-json":return`non-JSON response (HTTP ${o.statusCode})`;case"body-is-null":return`empty response body (HTTP ${o.statusCode})`;default:return o.errorMessage??"unknown error"}},Ua=class{constructor(o){this.apiKey=o.apiKey,this.baseUrl=o.baseUrl??nf,this.timeoutMs=o.timeoutMs??sf,this.fetcher=o.fetcher,this.headers=o.headers??{}}async sendBatch(o){if(o.length===0)return;let i=await this.fetcher({url:cf(this.baseUrl),method:"POST",contentType:"application/json",requestType:"json",headers:{...this.headers,"X-Schematic-Api-Key":this.apiKey},body:pf(o,this.apiKey),timeoutMs:this.timeoutMs,maxRetries:0});if(!i.ok)throw new Error(`capture service returned ${uf(i.error)}`)}};function gb(p){return async function(i){let t={};if(p&&Object.assign(t,p),i.body!==void 0&&i.contentType!=null&&(t["Content-Type"]=i.contentType),i.headers!=null)for(let[d,y]of Object.entries(i.headers))y!=null&&typeof y=="string"&&(t[d]=y);let s=i.queryString!=null&&i.queryString.length>0?`${i.url}?${i.queryString}`:Vo(i.url,i.queryParameters),r=await qo({body:i.body,type:i.requestType==="json"?"json":"other"}),a=await yi();try{let d=await Ri(async()=>wi(a,s,i.method,t,r,i.timeoutMs,i.abortSignal,i.withCredentials,i.duplex),i.maxRetries),y=await gi(d,i.responseType),g=go(d);return d.status>=200&&d.status<400?{ok:!0,body:y,headers:d.headers,rawResponse:g}:{ok:!1,error:{reason:"status-code",statusCode:d.status,body:y},rawResponse:g}}catch(d){return i.abortSignal!=null&&i.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:bi}:d instanceof Error&&d.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:bi}:d instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:d.message},rawResponse:zi}:{ok:!1,error:{reason:"unknown",errorMessage:JSON.stringify(d)},rawResponse:zi}}}}async function df(p){return{ok:!0,body:{},headers:{"Content-Type":"application/json"},rawResponse:{headers:new ir,redirected:!1,status:200,statusText:"OK",type:"basic",url:""}}}var yb=df;var so=class{constructor(){this.wasmInstance=null;this.initialized=!1}async initialize(){if(!this.initialized)try{let o=await import("./wasm/rulesengine.js"),i=o.RulesEngineJS?o:o.default??o;this.wasmInstance=new i.RulesEngineJS,this.initialized=!0}catch(o){throw new Error(`Failed to initialize WASM rules engine: ${o}`)}}async checkFlag(o,i,t){return this.checkFlagWithOptions(o,i,t)}async checkFlagWithOptions(o,i,t,s){this.ensureInitialized();let r=(a,d)=>d===null?void 0:d;try{let a=JSON.stringify(o,r),d=i?JSON.stringify(i,r):void 0,y=t?JSON.stringify(t,r):void 0,g=s?JSON.stringify(mf(s),r):void 0,l=this.wasmInstance.checkFlagWithOptions(a,d,y,g);return JSON.parse(l)}catch(a){throw new Error(`WASM flag check failed: ${a}`)}}getVersionKey(){return this.ensureInitialized(),this.wasmInstance.getVersionKey()}isInitialized(){return this.initialized}ensureInitialized(){if(!this.initialized||!this.wasmInstance)throw new Error("WASM rules engine not initialized. Call initialize() first.")}};function mf(p){let o={};return p.creditCost&&Object.keys(p.creditCost).length>0&&(o.credit_cost=p.creditCost),p.usage!==void 0&&(o.usage=p.usage),p.eventUsage&&(o.event_usage={event_subtype:p.eventUsage.eventSubtype,quantity:p.eventUsage.quantity}),o}vs();var hf={unrecognizedObjectKeys:"passthrough"};function wb(p,o){let i=p.parse(o,hf);return i.ok?i.value:o}function Os(p){return JSON.parse(JSON.stringify(p))}function gf(p){return JSON.parse(JSON.stringify(p))}function bb(p,o){let i=Os(p),t,s=!1;for(let r of Object.keys(o))switch(r){case"id":i.id=o[r];break;case"account_id":i.accountId=o[r];break;case"environment_id":i.environmentId=o[r];break;case"base_plan_id":i.basePlanId=o[r]??null;break;case"billing_product_ids":i.billingProductIds=o[r];break;case"plan_ids":i.planIds=o[r];break;case"plan_version_ids":i.planVersionIds=o[r];break;case"entitlements":{let a=o[r]??[];i.entitlements=a.map(d=>wb(ea,d));break}case"rules":i.rules=o[r];break;case"traits":i.traits=o[r];break;case"subscription":i.subscription=o[r];break;case"keys":{let a=i.keys??{},d=o[r];i.keys={...a,...d};break}case"credit_balances":{let a=i.creditBalances??{},d=o[r]??{};i.creditBalances={...a,...d},t=d;break}case"credit_lease_balance":{let a=i.creditBalances??{},d=o[r]??{},y={};for(let[g,l]of Object.entries(d))l&&typeof l.remaining=="number"&&(y[g]=l.remaining);i.creditBalances={...a,...y},t={...t??{},...y};break}case"metrics":{let a=i.metrics??[],d=(o[r]??[]).map(y=>wb(ra,y));i.metrics=wf(a,d),s=!0;break}}return(t||s)&&!("entitlements"in o)&&yf(i,t,s),i}function yf(p,o,i){let t=p.entitlements??[];if(t.length===0)return;let s=new Map;if(i){let r=p.metrics??[];for(let a of r)a&&s.set(va(Ts(a)),a.value??0)}for(let r of t){let a=r.creditId??r.credit_id;o&&a&&a in o&&(r.creditRemaining=o[a],delete r.credit_remaining);let d=r.eventName??r.event_name;if(s.size>0&&d){let y=(r.metricPeriod??r.metric_period)||"all_time",g=(r.monthReset??r.month_reset)||"first_of_month",l=s.get(va({eventSubtype:d,period:y,monthReset:g}));l!==void 0&&(r.usage=l)}}}function zb(p,o){let i=gf(p);for(let t of Object.keys(o))switch(t){case"id":i.id=o[t];break;case"account_id":i.accountId=o[t];break;case"environment_id":i.environmentId=o[t];break;case"keys":{let s=i.keys??{},r=o[t];i.keys={...s,...r};break}case"traits":i.traits=o[t];break;case"rules":i.rules=o[t];break}return i}function va(p){return`${p.eventSubtype}|${p.period}|${p.monthReset}`}function Ts(p){return{eventSubtype:(p.eventSubtype??p.event_subtype)||"",period:p.period||"",monthReset:(p.monthReset??p.month_reset)||""}}function wf(p,o){let i=[...p],t=new Map;for(let s=0;s<i.length;s++){let r=i[s];if(r){let a=va(Ts(r));t.set(a,s)}}for(let s of o){if(!s)continue;let r=va(Ts(s)),a=t.get(r);a!==void 0?i[a]=s:i.push(s)}return i}var yr="company",wr="user",xf="flags",Bs=30*1e3,Cf=1440*60*1e3,Ef=720*60*60*1e3,xo=class extends co{constructor(i){super();this.replicatorReady=!1;this.pendingCompanyRequests=new Map;this.pendingUserRequests=new Map;if(this.apiKey=i.apiKey,this.baseURL=i.baseURL??z.Default,this.logger=i.logger,this.cacheTTL=i.cacheTTL??Cf,this.companyCacheProvider=this.createCacheProvider(i,"company"),this.userCacheProvider=this.createCacheProvider(i,"user"),this.flagsCacheProvider=this.createCacheProvider(i,"flag"),this.companyKeyCacheProvider=this.createKeyCacheProvider(i),this.userKeyCacheProvider=this.createKeyCacheProvider(i),this.replicatorMode=i.replicatorMode??!1,this.replicatorHealthURL=i.replicatorHealthURL,this.replicatorHealthCheck=i.replicatorHealthCheck??30*1e3,this.replicatorMode&&!i.redisClient&&!i.companyCache&&!i.userCache&&!i.flagCache)throw new Error("Replicator mode requires a Redis client or custom cache providers for shared cache access");this.rulesEngine=new so}createCacheProvider(i,t){let s;switch(t){case"company":s=i.companyCache;break;case"user":s=i.userCache;break;case"flag":s=i.flagCache;break}if(s)return this.logger.debug(`Using custom cache provider for ${t} cache`),s;let r=this.calculateCacheTTL(t);return i.redisClient?(this.logger.debug(`Using Redis cache provider for ${t} cache (TTL: ${r}ms)`),new ci({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:r})):(this.logger.debug(`Using memory cache provider for ${t} cache (TTL: ${r}ms)`),new rr({ttl:r}))}createKeyCacheProvider(i){let t=this.cacheTTL;return i.redisClient?new ci({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:t}):new rr({ttl:t})}calculateCacheTTL(i){return i==="flag"?Math.max(Ef,this.cacheTTL):this.cacheTTL}async start(){try{await this.rulesEngine.initialize(),this.logger.debug("Rules engine initialized successfully")}catch(t){this.logger.warn(`Failed to initialize rules engine: ${t}`)}if(this.replicatorMode){this.logger.info("Replicator mode enabled - skipping WebSocket connection"),this.replicatorHealthURL&&this.startReplicatorHealthCheck();return}this.logger.info("Starting DataStream client");let{DatastreamWSClient:i}=(Ub(),Fs(Eb));this.wsClient=new i({url:this.baseURL,apiKey:this.apiKey,logger:this.logger,messageHandler:this.handleMessage.bind(this),connectionReadyHandler:this.handleConnectionReady.bind(this)}),this.wsClient.on("connected",()=>{this.emit("connected")}),this.wsClient.on("disconnected",()=>{this.emit("disconnected"),this.clearPendingRequests()}),this.wsClient.on("ready",()=>{this.emit("ready")}),this.wsClient.on("not-ready",()=>{this.emit("not-ready")}),this.wsClient.on("error",t=>{this.emit("error",t)}),this.wsClient.start()}isConnected(){return this.replicatorMode?this.isReplicatorReady():this.wsClient?.isConnected()??!1}async getCompany(i){let t=await this.getCompanyFromCache(i);if(t)return this.logger.debug(`Company found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("Company not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForCompany(i),r=!1;for(let a of s)if(this.pendingCompanyRequests.has(a)){r=!0;break}return new Promise((a,d)=>{let y=setTimeout(()=>{this.cleanupPendingCompanyRequests(s,g),d(new Error("Timeout while waiting for company data"))},Bs),g=l=>{clearTimeout(y),l?a(l):d(new Error("Company not found"))};for(let l of s)this.pendingCompanyRequests.has(l)||this.pendingCompanyRequests.set(l,[]),this.pendingCompanyRequests.get(l).push(g);r||this.sendDataStreamRequest({entity_type:"rulesengine.Company",keys:i}).catch(l=>{this.cleanupPendingCompanyRequests(s,g),d(l)})})}async getUser(i){let t=await this.getUserFromCache(i);if(t)return this.logger.debug(`User found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("User not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForUser(i),r=!1;for(let a of s)if(this.pendingUserRequests.has(a)){r=!0;break}return new Promise((a,d)=>{let y=setTimeout(()=>{this.cleanupPendingUserRequests(s,g),d(new Error("Timeout while waiting for user data"))},Bs),g=l=>{clearTimeout(y),l?a(l):d(new Error("User not found"))};for(let l of s)this.pendingUserRequests.has(l)||this.pendingUserRequests.set(l,[]),this.pendingUserRequests.get(l).push(g);r||this.sendDataStreamRequest({entity_type:"rulesengine.User",keys:i}).catch(l=>{this.cleanupPendingUserRequests(s,g),d(l)})})}async getFlag(i){let t=this.flagCacheKey(i);this.logger.debug(`Retrieving flag from cache: ${i} (cache key: ${t})`);try{return await this.flagsCacheProvider.get(t)||null}catch(s){return this.logger.warn(`Failed to retrieve flag from cache: ${s}`),null}}async getAllFlags(){return this.pendingFlagRequest?new Promise((i,t)=>{let s=this.pendingFlagRequest;this.pendingFlagRequest=r=>{s(r),r?i():t(new Error("Failed to refresh flags"))}}):new Promise((i,t)=>{let s=setTimeout(()=>{this.pendingFlagRequest=void 0,t(new Error("Timeout while waiting for flags data"))},Bs);this.pendingFlagRequest=r=>{clearTimeout(s),this.pendingFlagRequest=void 0,r?i():t(new Error("Failed to refresh flags"))},this.sendDataStreamRequest({entity_type:"rulesengine.Flags"}).catch(r=>{clearTimeout(s),this.pendingFlagRequest=void 0,t(r)})})}async checkFlag(i,t,s){let r=await this.getFlag(t);if(!r)throw new Error(`Flag not found: ${t}`);let a=i.company&&Object.keys(i.company).length>0,d=i.user&&Object.keys(i.user).length>0,y=null,g=null;if(a&&(y=await this.getCompanyFromCache(i.company),this.logger.debug(`Company ${y?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.company)}`)),d&&(g=await this.getUserFromCache(i.user),this.logger.debug(`User ${g?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.user)}`)),this.replicatorMode)return this.evaluateFlag(r,y,g,s);if((!a||y)&&(!d||g))return this.logger.debug(`All required resources found in cache for flag ${t} evaluation`),this.evaluateFlag(r,y,g,s);if(!this.isConnected())throw new Error("Datastream not connected and required entities not in cache");let l=a&&!y?this.getCompany(i.company):Promise.resolve(y),h=d&&!g?this.getUser(i.user):Promise.resolve(g),[w,U]=await Promise.all([l,h]);return this.evaluateFlag(r,w,U,s)}async getCachedCompany(i){return this.getCompanyFromCache(i)}async getCachedUser(i){return this.getUserFromCache(i)}getRulesEngine(){return this.rulesEngine}async updateCompanyMetrics(i,t,s){let r=await this.getCompanyFromCache(i);if(!r)return;let a=this.deepCopyCompany(r);if(a.metrics)for(let d of a.metrics)(d.eventSubtype??d.event_subtype)===t&&(d.value=(d.value||0)+s);await this.cacheCompanyForKeys(a)}close(){this.logger.info("Closing DataStream client"),this.replicatorHealthInterval&&(clearInterval(this.replicatorHealthInterval),this.replicatorHealthInterval=void 0),this.clearPendingRequests(),this.wsClient&&(this.wsClient.close(),this.wsClient=void 0),this.logger.info("DataStream client closed")}isReplicatorReady(){return this.replicatorReady}isReplicatorMode(){return this.replicatorMode}getReplicatorCacheVersion(){return this.replicatorCacheVersion}async getReplicatorCacheVersionAsync(i=2e3){if(this.replicatorCacheVersion)return this.replicatorCacheVersion;if(this.replicatorMode&&this.replicatorHealthURL)try{let t=new AbortController,s=setTimeout(()=>t.abort(),i),r=await fetch(this.replicatorHealthURL,{method:"GET",signal:t.signal});if(clearTimeout(s),r.ok){let a=await r.json(),d=a.cache_version||a.cacheVersion;if(d)return this.replicatorCacheVersion=d,d}}catch(t){this.logger.debug(`Failed to fetch replicator cache version: ${t}`)}}async handleMessage(i){this.logger.debug(`Processing datastream message: EntityType=${i.entity_type}, MessageType=${i.message_type}`);try{if(i.message_type==="error"){await this.handleErrorMessage(i);return}switch(i.entity_type){case"rulesengine.Company":case"rulesengine.Companies":await this.handleCompanyMessage(i);break;case"rulesengine.User":case"rulesengine.Users":await this.handleUserMessage(i);break;case"rulesengine.Flags":await this.handleFlagsMessage(i);break;case"rulesengine.Flag":await this.handleFlagMessage(i);break;default:this.logger.warn(`Unknown entity type in datastream message: ${i.entity_type}`)}}catch(t){this.logger.error(`Error processing datastream message: ${t}`),this.emit("error",t)}}async handleCompanyMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial company message missing entity_id");return}let r=this.resourceIdCacheKey(yr,s),a=await this.companyCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial company '${s}', skipping`);return}try{t=bb(a,i.data)}catch(d){this.logger.error(`Failed to merge partial company: ${d}`);return}}else try{t=db.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize company payload: ${s}`);return}if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,a]of Object.entries(t.keys)){let d=this.resourceKeyToCacheKey(yr,r,a);try{await this.companyKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete company key mapping from cache: ${y}`)}}let s=this.resourceIdCacheKey(yr,t.id);try{await this.companyCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete company resource from cache: ${r}`)}return}await this.cacheCompanyForKeys(t),this.notifyPendingCompanyRequests(t.keys||{},t)}}async handleUserMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial user message missing entity_id");return}let r=this.resourceIdCacheKey(wr,s),a=await this.userCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial user '${s}', skipping`);return}try{t=zb(a,i.data)}catch(d){this.logger.error(`Failed to merge partial user: ${d}`);return}}else try{t=mb.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize user payload: ${s}`);return}if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,a]of Object.entries(t.keys)){let d=this.resourceKeyToCacheKey(wr,r,a);try{await this.userKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete user key mapping from cache: ${y}`)}}let s=this.resourceIdCacheKey(wr,t.id);try{await this.userCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete user resource from cache: ${r}`)}return}await this.cacheUserForKeys(t),this.notifyPendingUserRequests(t.keys||{},t)}}async handleFlagsMessage(i){let t=i.data;if(!Array.isArray(t)){this.logger.warn("Expected flags array in bulk flags message");return}let s=[],r=0,a;for(let l of t)try{s.push(Ps.parseOrThrow(l,{unrecognizedObjectKeys:"passthrough"}))}catch(h){r++,a===void 0&&(a=h)}r>0&&this.logger.warn(`Failed to deserialize ${r} flag(s) in bulk message: ${String(a)}`);let d=await Promise.allSettled(s.filter(l=>l?.key).map(async l=>{let h=this.flagCacheKey(l.key);return await this.flagsCacheProvider.set(h,l),h})),y=d.filter(l=>l.status==="fulfilled").map(l=>l.value),g=d.filter(l=>l.status==="rejected");if(g.length>0&&this.logger.warn(`Failed to cache ${g.length} flag(s)`),this.flagsCacheProvider.deleteMissing)try{await this.flagsCacheProvider.deleteMissing(y,{scanPattern:"flags:*"})}catch(l){this.logger.warn(`Failed to delete missing flags: ${l}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleFlagMessage(i){let t;try{t=Ps.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(r){this.logger.warn(`Failed to deserialize flag payload: ${r}`);return}if(!t?.key)return;let s=this.flagCacheKey(t.key);try{switch(i.message_type){case"delete":await this.flagsCacheProvider.delete(s);break;case"full":await this.flagsCacheProvider.set(s,t);break;default:this.logger.warn(`Unhandled message type for flag: ${i.message_type}`);break}}catch(r){this.logger.warn(`Failed to update flag cache: ${r}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleErrorMessage(i){let t=i.data;if(t?.keys&&t?.entity_type)switch(t.entity_type){case"rulesengine.Company":this.notifyPendingCompanyRequests(t.keys,null);break;case"rulesengine.User":this.notifyPendingUserRequests(t.keys,null);break;default:this.logger.warn(`Received error for unsupported entity type: ${t.entity_type}`)}let s=t?.error||"Unknown datastream error";this.logger.warn(`DataStream error received: ${s}`)}async handleConnectionReady(){this.logger.info("DataStream connection is ready");try{await this.getAllFlags(),this.logger.debug("Requested initial flag data")}catch(i){throw this.logger.error(`Failed to request initial flag data: ${i}`),i}}async sendDataStreamRequest(i){if(!this.wsClient||!this.wsClient.isConnected())throw new Error("DataStream client is not connected");this.logger.debug(`Sending datastream request: EntityType=${i.entity_type}, Keys=${JSON.stringify(i.keys)}`);let t={data:i};await this.wsClient.sendMessage(t)}async getCompanyFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(yr,t,s);try{let a=await this.companyKeyCacheProvider.get(r);if(a){let d=this.resourceIdCacheKey(yr,a),y=await this.companyCacheProvider.get(d);if(y)return y}}catch(a){this.logger.warn(`Failed to retrieve company from cache: ${a}`)}}return null}async getUserFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(wr,t,s);try{let a=await this.userKeyCacheProvider.get(r);if(a){let d=this.resourceIdCacheKey(wr,a),y=await this.userCacheProvider.get(d);if(y)return y}}catch(a){this.logger.warn(`Failed to retrieve user from cache: ${a}`)}}return null}async cacheCompanyForKeys(i){if(!i.keys||Object.keys(i.keys).length===0)throw new Error("No keys provided for company lookup");let t=this.resourceIdCacheKey(yr,i.id),s=await this.companyCacheProvider.get(t);if(s?.keys){for(let[r,a]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==a){let d=this.resourceKeyToCacheKey(yr,r,a);try{await this.companyKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete stale company key mapping '${d}': ${y}`)}}}await this.companyCacheProvider.set(t,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let d=this.resourceKeyToCacheKey(yr,r,a);try{await this.companyKeyCacheProvider.set(d,i.id,this.cacheTTL)}catch(y){this.logger.warn(`Failed to cache company key mapping '${d}': ${y}`)}}}async cacheUserForKeys(i){if(!i.keys||Object.keys(i.keys).length===0)throw new Error("No keys provided for user lookup");let t=this.resourceIdCacheKey(wr,i.id),s=await this.userCacheProvider.get(t);if(s?.keys){for(let[r,a]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==a){let d=this.resourceKeyToCacheKey(wr,r,a);try{await this.userKeyCacheProvider.delete(d)}catch(y){this.logger.warn(`Failed to delete stale user key mapping '${d}': ${y}`)}}}await this.userCacheProvider.set(t,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let d=this.resourceKeyToCacheKey(wr,r,a);try{await this.userKeyCacheProvider.set(d,i.id,this.cacheTTL)}catch(y){this.logger.warn(`Failed to cache user key mapping '${d}': ${y}`)}}}generateCacheKeysForCompany(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(yr,t,s))}generateCacheKeysForUser(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(wr,t,s))}notifyPendingCompanyRequests(i,t){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(yr,s,r),d=this.pendingCompanyRequests.get(a);d&&(this.pendingCompanyRequests.delete(a),d.forEach(y=>{try{y(t)}catch(g){this.logger.error(`Error in company request handler: ${g}`)}}))}}notifyPendingUserRequests(i,t){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(wr,s,r),d=this.pendingUserRequests.get(a);d&&(this.pendingUserRequests.delete(a),d.forEach(y=>{try{y(t)}catch(g){this.logger.error(`Error in user request handler: ${g}`)}}))}}cleanupPendingCompanyRequests(i,t){for(let s of i){let r=this.pendingCompanyRequests.get(s);if(r){let a=r.indexOf(t);a!==-1&&r.splice(a,1),r.length===0&&this.pendingCompanyRequests.delete(s)}}}cleanupPendingUserRequests(i,t){for(let s of i){let r=this.pendingUserRequests.get(s);if(r){let a=r.indexOf(t);a!==-1&&r.splice(a,1),r.length===0&&this.pendingUserRequests.delete(s)}}}clearPendingRequests(){for(let[,i]of this.pendingCompanyRequests)i.forEach(t=>{try{t(null)}catch(s){this.logger.error(`Error clearing company request: ${s}`)}});this.pendingCompanyRequests.clear();for(let[,i]of this.pendingUserRequests)i.forEach(t=>{try{t(null)}catch(s){this.logger.error(`Error clearing user request: ${s}`)}});if(this.pendingUserRequests.clear(),this.pendingFlagRequest){try{this.pendingFlagRequest(!1)}catch(i){this.logger.error(`Error clearing flag request: ${i}`)}this.pendingFlagRequest=void 0}}startReplicatorHealthCheck(){this.replicatorHealthURL&&(this.logger.info(`Starting replicator health check with URL: ${this.replicatorHealthURL}, interval: ${this.replicatorHealthCheck}ms`),this.checkReplicatorHealth(),this.replicatorHealthInterval=setInterval(()=>{this.checkReplicatorHealth()},this.replicatorHealthCheck),this.replicatorHealthInterval.unref())}async checkReplicatorHealth(){if(this.replicatorHealthURL)try{let i=new AbortController,t=setTimeout(()=>i.abort(),5e3),s=await fetch(this.replicatorHealthURL,{method:"GET",signal:i.signal});if(clearTimeout(t),!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let r=await s.json(),a=this.replicatorReady;this.replicatorReady=r.ready??!1;let d=r.cache_version||r.cacheVersion;if(d&&d!==this.replicatorCacheVersion){let y=this.replicatorCacheVersion;this.replicatorCacheVersion=d,this.logger.info(`Cache version changed from ${y||"(null)"} to ${d}`)}this.replicatorReady&&!a?(this.logger.info("External replicator is now ready"),this.emit("replicator-health-changed",!0)):!this.replicatorReady&&a&&(this.logger.info("External replicator is no longer ready"),this.emit("replicator-health-changed",!1))}catch(i){this.replicatorReady&&(this.replicatorReady=!1,this.logger.info("External replicator is no longer ready"),this.emit("replicator-health-changed",!1)),this.logger.debug(`Replicator health check failed: ${i}`)}}flagCacheKey(i){let t=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey(),s=`${xf}:${t}:${i.toLowerCase()}`;return this.logger.debug(`Generated flag cache key - flag: ${i}, mode: ${this.replicatorMode?"replicator":"datastream"}, version: ${t}, cacheKey: ${s}`),s}resourceIdCacheKey(i,t){let s=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${s}:${t}`}resourceKeyToCacheKey(i,t,s){let r=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${r}:${t.toLowerCase()}:${s.toLowerCase()}`}deepCopyCompany(i){return Os(i)}async evaluateFlag(i,t,s,r){let a=i.defaultValue??!1;try{if(this.rulesEngine.isInitialized()){this.logger.debug(`Evaluating flag with rules engine: ${JSON.stringify({flagId:i.id,flagRules:i.rules?.length||0,companyId:t?.id,userId:s?.id})}`);let d=await this.rulesEngine.checkFlagWithOptions(i,t,s,r);return this.logger.debug(`Rules engine evaluation result: ${JSON.stringify(d)}`),{flagKey:i.key,value:d.value??a,reason:d.reason||"RULES_ENGINE_EVALUATION",companyId:t?.id,userId:s?.id,flagId:i.id,ruleId:d.ruleId,ruleType:d.ruleType,entitlement:d.entitlement?{...d.entitlement,metricResetAt:d.entitlement.metricResetAt?new Date(d.entitlement.metricResetAt):void 0}:void 0}}else return this.logger.warn("Rules engine not initialized, using default flag value"),{flagKey:i.key,value:a,reason:"RULES_ENGINE_UNAVAILABLE",companyId:t?.id,userId:s?.id,flagId:i.id}}catch(d){return this.logger.error(`Rules engine evaluation failed: ${d}`),{flagKey:i.key,value:a,reason:"RULES_ENGINE_ERROR",companyId:t?.id,userId:s?.id,flagId:i.id}}}getRulesEngineVersionKey(){try{if(this.rulesEngine.isInitialized())return this.rulesEngine.getVersionKey()}catch(i){this.logger.warn(`Failed to get rules engine version key: ${i}`)}return"1"}};function Ye(p,o){return`${p}:${o}`}var Co=class{constructor(){this.leases=new Map;this.locks=new Map}get(o,i){let t=this.leases.get(Ye(o,i));return t?{...t}:void 0}async replace(o){let i=Ye(o.companyId,o.creditTypeId);return this.withLock(i,()=>{let t=this.leases.get(i);return t&&t.expiresAt.getTime()>Date.now()?!1:(this.leases.set(i,{...o,localRemainingCredits:o.grantedAmount}),!0)})}async extend(o,i,t,s,r){let a=Ye(o,i);return this.withLock(a,()=>{let d=this.leases.get(a);if(!d||r!==void 0&&d.leaseId!==r)return;let y=t-d.grantedAmount;y>0&&(d.grantedAmount=t,d.localRemainingCredits+=y),s&&s.getTime()>d.expiresAt.getTime()&&(d.expiresAt=s)})}async drop(o,i){let t=Ye(o,i);return this.withLock(t,()=>{this.leases.delete(t)})}async tryReserve(o,i,t){if(!Number.isFinite(t)||t<0)return null;let s=Ye(o,i);return this.withLock(s,()=>{let r=this.leases.get(s);return!r||r.expiresAt.getTime()<=Date.now()||r.localRemainingCredits<t?null:(r.localRemainingCredits-=t,r.localRemainingCredits)})}async refund(o,i,t,s){if(t<=0)return;let r=Ye(o,i);return this.withLock(r,()=>{let a=this.leases.get(r);a&&(s!==void 0&&a.leaseId!==s||(a.localRemainingCredits=Math.min(a.localRemainingCredits+t,a.grantedAmount)))})}list(){return Array.from(this.leases.values(),o=>({...o}))}async withLock(o,i){let t=this.locks.get(o)??Promise.resolve(),s,r=new Promise(d=>s=d),a=t.then(()=>r);this.locks.set(o,a),await t;try{return await i()}finally{s(),this.locks.get(o)===a&&this.locks.delete(o)}}};var Eo=class{constructor(o,i=1e3){this.leaseStore=o;this.sweepIntervalMs=i;this.reservations=new Map;this.sweepInterval=null;this.stopped=!1}add(o){this.reservations.set(o.id,o)}get(o){return this.reservations.get(o)}reservedCredits(o,i){let t=0;for(let s of this.reservations.values())s.companyId===o&&s.creditTypeId===i&&(t+=s.creditsReserved);return t}async consume(o,i){let t=this.reservations.get(o);if(!t)return null;this.reservations.delete(o);let s=Math.max(0,Math.min(i,t.creditsReserved)),r=t.creditsReserved-s;return r>0&&await this.leaseStore.refund(t.companyId,t.creditTypeId,r,t.leaseId),s}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(o=new Date){let i=0;for(let[t,s]of this.reservations)s.expiresAt.getTime()<=o.getTime()&&(this.reservations.delete(t),await this.leaseStore.refund(s.companyId,s.creditTypeId,s.creditsReserved,s.leaseId),i++);return i}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}size(){return this.reservations.size}};var Uo=class{constructor(o){this.inflightAcquire=new Map;this.inflightExtend=new Map;this.creditsClient=o.creditsClient,this.leaseStore=o.leaseStore,this.logger=o.logger,this.config=o.config}resolveConfig(o){let i=this.config.overrides?.[o];return{leaseDuration:i?.defaultLeaseDuration??this.config.defaultLeaseDuration??3e5,reservationTTL:i?.defaultReservationTTL??this.config.defaultReservationTTL??6e4,leaseSize:i?.defaultLeaseSize??this.config.defaultLeaseSize??1e4,lowWaterMark:i?.lowWaterMark??this.config.lowWaterMark??.25}}async acquireIfNeeded(o,i,t){let s;try{s=await this.leaseStore.get(o,i)}catch(y){this.logger.error(`Failed to read lease store for ${o}/${i}: ${y}`);return}if(s&&s.expiresAt.getTime()>Date.now())return s;let r=Ye(o,i),a=this.inflightAcquire.get(r);if(a)return a;let d=this.acquire(o,i,t).finally(()=>{this.inflightAcquire.delete(r)});return this.inflightAcquire.set(r,d),d}async acquire(o,i,t){let s=this.resolveConfig(i),r={companyId:o,creditTypeId:i,requestedAmount:s.leaseSize,expiresAt:new Date(Date.now()+s.leaseDuration)};try{let d=(await this.creditsClient.acquireCreditLease(r,t)).data;if(await this.leaseStore.replace({leaseId:d.id,companyId:d.companyId,creditTypeId:d.creditTypeId,grantedAmount:d.grantedAmount,expiresAt:d.expiresAt}))this.logger.debug(`Acquired credit lease ${d.id} for ${o}/${i} (granted=${d.grantedAmount}, expires=${d.expiresAt.toISOString()})`);else{let g=await this.leaseStore.get(o,i);return g&&g.leaseId!==d.id?(this.logger.debug(`Lost acquire race for ${o}/${i}; releasing redundant lease ${d.id}`),this.creditsClient.releaseCreditLease(d.id,{}).catch(l=>this.logger.warn(`Failed to release redundant credit lease ${d.id}: ${l}`))):this.logger.debug(`Lost acquire race for ${o}/${i}; server returned the installed lease ${d.id}, nothing to release`),g}return await this.leaseStore.get(o,i)}catch(a){this.logger.error(`Failed to acquire credit lease for ${o}/${i}: ${a}`);return}}async maybeExtendInBackground(o,i,t,s){let r;try{r=await this.leaseStore.get(o,i)}catch(U){this.logger.warn(`Failed to read lease store for ${o}/${i}: ${U}`);return}if(!r||r.expiresAt.getTime()<=Date.now())return;let a=this.resolveConfig(i),y=r.localRemainingCredits/Math.max(r.grantedAmount,1)<=a.lowWaterMark,g=t!==void 0&&r.localRemainingCredits<t;if(!y&&!g)return r;let l=Ye(o,i),h=this.inflightExtend.get(l);if(h)return h;let w=this.extend(r,a,t,s).finally(()=>{this.inflightExtend.delete(l)});return this.inflightExtend.set(l,w),w}async extend(o,i,t,s){let r=t!==void 0?t-o.localRemainingCredits:0,a={additionalAmount:Math.max(i.leaseSize,r),expiresAt:new Date(Date.now()+i.leaseDuration)};try{let y=(await this.creditsClient.extendCreditLease(o.leaseId,a,s)).data;return await this.leaseStore.extend(o.companyId,o.creditTypeId,y.grantedAmount,y.expiresAt,o.leaseId),this.logger.debug(`Extended credit lease ${o.leaseId} to ${y.grantedAmount} (was ${o.grantedAmount} at last read, expires ${y.expiresAt.toISOString()})`),await this.leaseStore.get(o.companyId,o.creditTypeId)}catch(d){this.logger.warn(`Failed to extend credit lease ${o.leaseId}: ${d}`);return}}async releaseAllLocalLeases(){let o=this.leaseStore.list?.();!o||o.length===0||await Promise.all(o.map(async i=>{if(!(i.expiresAt.getTime()<=Date.now()))try{await this.creditsClient.releaseCreditLease(i.leaseId,{}),await this.leaseStore.drop(i.companyId,i.creditTypeId),this.logger.debug(`Released credit lease ${i.leaseId} on close`)}catch(t){this.logger.warn(`Failed to release credit lease ${i.leaseId} on close (it will expire server-side): ${t}`)}}))}};var vf="schematic:",Tf="credit-lease:",vb=6e4,Tb=`
|
|
4
4
|
redis.replicate_commands()
|
|
5
5
|
local t = redis.call('TIME')
|
|
6
6
|
local now = (tonumber(t[1]) * 1000) + math.floor(tonumber(t[2]) / 1000)
|
|
7
|
-
`,
|
|
7
|
+
`,Of=Tb+`
|
|
8
8
|
local existing_id = redis.call('HGET', KEYS[1], 'leaseId')
|
|
9
9
|
local existing_expiry = tonumber(redis.call('HGET', KEYS[1], 'expiresAt') or '0')
|
|
10
10
|
local new_id = ARGV[1]
|
|
@@ -26,7 +26,7 @@ redis.call('HSET', KEYS[1],
|
|
|
26
26
|
'expiresAt', ARGV[3])
|
|
27
27
|
redis.call('PEXPIREAT', KEYS[1], new_expiry + grace)
|
|
28
28
|
return 1
|
|
29
|
-
`,
|
|
29
|
+
`,kf=Tb+`
|
|
30
30
|
local raw = redis.call('HGET', KEYS[1], 'localRemainingCredits')
|
|
31
31
|
if not raw then return false end
|
|
32
32
|
local expiry = tonumber(redis.call('HGET', KEYS[1], 'expiresAt') or '0')
|
|
@@ -37,7 +37,7 @@ if remaining < requested then return false end
|
|
|
37
37
|
local new_remaining = remaining - requested
|
|
38
38
|
redis.call('HSET', KEYS[1], 'localRemainingCredits', tostring(new_remaining))
|
|
39
39
|
return tostring(new_remaining)
|
|
40
|
-
`,
|
|
40
|
+
`,Bf=`
|
|
41
41
|
local raw_remaining = redis.call('HGET', KEYS[1], 'localRemainingCredits')
|
|
42
42
|
if not raw_remaining then return 0 end
|
|
43
43
|
local required_lease = ARGV[2]
|
|
@@ -52,7 +52,7 @@ local new_balance = remaining + refund
|
|
|
52
52
|
if new_balance > granted then new_balance = granted end
|
|
53
53
|
redis.call('HSET', KEYS[1], 'localRemainingCredits', tostring(new_balance))
|
|
54
54
|
return 1
|
|
55
|
-
`,
|
|
55
|
+
`,jf=`
|
|
56
56
|
local raw_granted = redis.call('HGET', KEYS[1], 'grantedAmount')
|
|
57
57
|
if not raw_granted then return 0 end
|
|
58
58
|
local required_lease = ARGV[4]
|
|
@@ -77,9 +77,9 @@ if new_expiry > current_expiry then
|
|
|
77
77
|
redis.call('PEXPIREAT', KEYS[1], new_expiry + grace)
|
|
78
78
|
end
|
|
79
79
|
return 1
|
|
80
|
-
`,
|
|
80
|
+
`,vo=class{constructor(o){this.client=o.client,this.keyPrefix=o.keyPrefix??vf,this.defaultLeaseDurationMs=o.defaultLeaseDurationMs??3e5}hashKey(o,i){return`${this.keyPrefix}${Tf}${Ye(o,i)}`}async get(o,i){let t=await this.client.hGetAll(this.hashKey(o,i));if(!(!t||!t.leaseId))return Af(t)}async replace(o){let i=await this.client.eval(Of,{keys:[this.hashKey(o.companyId,o.creditTypeId)],arguments:[o.leaseId,String(o.grantedAmount),String(o.expiresAt.getTime()),String(vb),o.companyId,o.creditTypeId]});return Number(i)===1}async extend(o,i,t,s,r){let a=(s??new Date(Date.now()+this.defaultLeaseDurationMs)).getTime();await this.client.eval(jf,{keys:[this.hashKey(o,i)],arguments:[String(t),String(a),String(vb),r??""]})}async drop(o,i){await this.client.del(this.hashKey(o,i))}async tryReserve(o,i,t){if(!Number.isFinite(t)||t<0)return null;let s=await this.client.eval(kf,{keys:[this.hashKey(o,i)],arguments:[String(t)]});return s==null?null:Number(s)}async refund(o,i,t,s){t<=0||await this.client.eval(Bf,{keys:[this.hashKey(o,i)],arguments:[String(t),s??""]})}};function Af(p){return{leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,grantedAmount:Number(p.grantedAmount??"0"),localRemainingCredits:Number(p.localRemainingCredits??"0"),expiresAt:new Date(Number(p.expiresAt??"0"))}}var Vf="schematic:",qf="credit-reservation:",Df="credit-reservations:byExpiry",Mf="credit-reservations:byCredit:";var If=`
|
|
81
81
|
local raw = redis.call('HGETALL', KEYS[1])
|
|
82
82
|
if #raw == 0 then return nil end
|
|
83
83
|
redis.call('DEL', KEYS[1])
|
|
84
84
|
return raw
|
|
85
|
-
`;function db(p){return`${p.companyId}|${p.creditTypeId}|${p.id}`}function _f(p){let o=p.split("|");if(o.length===3)return{companyId:o[0],creditTypeId:o[1],id:o[2]}}var mb=256,Sf=16,Co=class{constructor(o){this.sweepInterval=null;this.stopped=!1;this.client=o.client,this.leaseStore=o.leaseStore,this.sweepIntervalMs=o.sweepIntervalMs??1e3,this.keyPrefix=o.keyPrefix??wf}hashKey(o){return`${this.keyPrefix}${bf}${o}`}indexKey(){return`${this.keyPrefix}${zf}`}byCreditKey(o,i){return`${this.keyPrefix}${Rf}${o}:${i}`}async add(o){let i=o.expiresAt.getTime(),t=this.hashKey(o.id);await this.client.hSet(t,{id:o.id,leaseId:o.leaseId,companyId:o.companyId,creditTypeId:o.creditTypeId,eventSubtype:o.eventSubtype,quantityReserved:String(o.quantityReserved),creditsReserved:String(o.creditsReserved),consumptionRate:String(o.consumptionRate),expiresAt:String(i),evalCtx:JSON.stringify(o.evalCtx)}),await Promise.all([this.client.pExpireAt(t,i+3e4),this.client.zAdd(this.indexKey(),{score:i,value:db(o)}),this.client.hSet(this.byCreditKey(o.companyId,o.creditTypeId),o.id,String(o.creditsReserved))])}async get(o){let i=await this.client.hGetAll(this.hashKey(o));if(!(!i||!i.id))return xf(i)}async reservedCredits(o,i){let t=await this.client.hGetAll(this.byCreditKey(o,i)).catch(()=>({})),s=0;for(let r of Object.values(t))s+=Number(r)||0;return s}async consume(o,i){let t=await this.client.eval(ff,{keys:[this.hashKey(o)],arguments:[]}),s=Pf(t);if(!s||!s.id)return null;let r=s.companyId,a=s.creditTypeId,u=Number(s.creditsReserved)||0;await this.client.zRem(this.indexKey(),db({companyId:r,creditTypeId:a,id:o})).catch(()=>{}),await this.client.hDel(this.byCreditKey(r,a),o).catch(()=>{});let g=i;g<0&&(g=0),g>u&&(g=u);let h=u-g;return h>0&&await this.leaseStore.refund(r,a,h,s.leaseId),g}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(o=new Date){let i=o.getTime(),t=0;for(let s=0;s<Sf;s++){let r=await this.client.zRangeByScore(this.indexKey(),0,i,{LIMIT:{offset:0,count:mb}});if(r.length===0)break;for(let a of r){let u=_f(a);if(!u){await this.client.zRem(this.indexKey(),a).catch(()=>{});continue}let g=await this.consume(u.id,0);if(await this.client.zRem(this.indexKey(),a).catch(()=>{}),g!==null){t++;continue}await this.client.hDel(this.byCreditKey(u.companyId,u.creditTypeId),u.id).catch(()=>{})}if(r.length<mb)break}return t}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}async size(){return this.client.zCard(this.indexKey()).catch(()=>0)}};function Pf(p){if(!Array.isArray(p)||p.length===0)return;let o={};for(let i=0;i+1<p.length;i+=2)o[String(p[i])]=String(p[i+1]);return o}function xf(p){return{id:p.id,leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,eventSubtype:p.eventSubtype,quantityReserved:Number(p.quantityReserved),creditsReserved:Number(p.creditsReserved),consumptionRate:Number(p.consumptionRate),expiresAt:new Date(Number(p.expiresAt)),evalCtx:p.evalCtx?JSON.parse(p.evalCtx):{}}}var gb=require("crypto");function Uo(p,o,i,t){return p.enqueueFlagCheckEvent({flagKey:i.flagKey,value:i.value,reason:i.reason,error:i.err,flagId:i.flagId,companyId:t?.companyId,userId:t?.userId,ruleId:t?.ruleId,reqCompany:o.company,reqUser:o.user}),i}async function yb(p,o,i,t,s){let{datastream:r,leaseStore:a,reservations:u,manager:g,logger:h}=p,l=t.onAcquireFailure??"fail-closed";if(t.usage===void 0||!Number.isFinite(t.usage)||t.usage<0)return h.error(`Lease check: invalid usage ${t.usage} for flag ${o} \u2014 must be a finite, non-negative number`),Uo(p,i,Ea(l,o,"invalid_usage",null));if(t.usage===0)return h.debug(`Lease check: usage is 0 for flag ${o} \u2014 nothing to reserve, using plain check`),s();if(!r)return h.debug("Credit-lease check requested without datastream \u2014 falling back to plain check"),s();let y=null;try{y=await r.getFlag(o)}catch(_e){h.warn(`Lease check: failed to load flag ${o}: ${_e}`)}if(!y)return h.debug(`Lease check: no cached flag for ${o}, falling back`),s();let{eventSubtype:w,quantity:U}=Cf(t);if(!i.company)return h.debug("Lease check: no company on evalCtx, falling back"),s();let T=null;try{T=await r.getCompany(i.company)}catch(_e){h.debug(`Lease check: company fetch failed for keys ${JSON.stringify(i.company)} (${_e}), falling back`)}if(!T)return s();let O=null;if(i.user){try{O=await r.getUser(i.user)}catch(_e){h.debug(`Lease check: user fetch failed for keys ${JSON.stringify(i.user)} (${_e}), falling back`)}if(!O)return s()}let A;try{A=await r.getRulesEngine().checkFlagWithOptions(y,T,O??null,null)}catch(_e){return h.warn(`Lease check: entitlement probe failed for flag ${o} (${_e}), falling back`),s()}let j=A.entitlement;if(!j||j.valueType!==Oa.Credit)return h.debug(`Lease check: flag ${o} matched a non-credit entitlement (valueType=${j?.valueType??"<none>"}), falling back to plain check \u2014 no reservation`),s();let D=j.creditId,V=j.consumptionRate??0,re=w??j.eventSubtype;if(!D||V<=0||!re)return h.debug(`Lease check: flag ${o} credit entitlement is incomplete (creditId=${D??"<none>"}, consumptionRate=${V}, subtype=${re??"<none>"}), falling back`),s();let ue=U*V,Ue=t.timeoutMs!==void 0?{timeoutInSeconds:t.timeoutMs/1e3}:void 0,B=_e=>Tf({datastream:r,logger:h,mode:l,key:o,reason:_e,flag:y,company:T,user:O,creditId:D,options:t}).then(vo=>Uo(p,i,vo,{companyId:T.id,userId:O?.id})),ti=await g.acquireIfNeeded(T.id,D,Ue);if(!ti)return B("lease_acquire_failed");let br;try{br=await a.tryReserve(T.id,D,ue),br===null&&(await g.maybeExtendInBackground(T.id,D,ue,Ue),br=await a.tryReserve(T.id,D,ue))}catch(_e){return h.error(`Lease check: reserve against ${T.id}/${D} failed: ${_e}`),B("lease_store_error")}if(br===null)return B("insufficient_lease_balance");let M=Uf({leaseId:ti.leaseId,companyId:T.id,creditTypeId:D,eventSubtype:re,quantityReserved:U,creditsReserved:ue,consumptionRate:V,reservationTTL:Ef(p,D),evalCtx:i});try{await u.add(M)}catch(_e){h.error(`Lease check: failed to persist reservation ${M.id}: ${_e}`);try{await u.consume(M.id,0)===null&&await a.refund(T.id,D,ue,ti.leaseId)}catch(vo){h.warn(`Lease check: could not undo local debit for ${M.id} (${vo}); the slice is reclaimed at lease expiry`)}return B("lease_store_error")}let zr=br+ue,Pb=wb(T,D,zr),xb={creditCost:{[D]:ue}},Ae;try{Ae=await r.getRulesEngine().checkFlagWithOptions(y,Pb,O??null,xb)}catch(_e){return h.error(`Lease check: WASM eval failed: ${_e}`),await hb(u,M,h),Uo(p,i,Ea(l,o,`wasm_error: ${_e}`,y),{companyId:T.id,userId:O?.id})}let Bs={companyId:Ae.companyId??T.id,userId:Ae.userId??O?.id,ruleId:Ae.ruleId};return Ae.value?(g.maybeExtendInBackground(T.id,D),Uo(p,i,{allowed:!0,value:!0,reservation:M,reason:Ae.reason??"lease_reserved",entitlement:Us(Ae.entitlement),flagKey:Ae.flagKey??o,flagId:Ae.flagId},Bs)):(await hb(u,M,h),Uo(p,i,{allowed:!1,value:!1,reason:Ae.reason??"denied_by_engine",entitlement:Us(Ae.entitlement),flagKey:Ae.flagKey??o,flagId:Ae.flagId},Bs))}function Ef(p,o){return p.manager.resolveConfig(o)}function Cf(p){return{eventSubtype:p.eventSubtype,quantity:p.usage??0}}function vs(p){if(p.usage!==void 0)return p.eventSubtype!==void 0?{eventUsage:{eventSubtype:p.eventSubtype,quantity:p.usage}}:{usage:p.usage}}function wb(p,o,i){return{...p,creditBalances:{...p.creditBalances??{},[o]:i}}}function Uf(p){return{id:(0,gb.randomUUID)(),leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,eventSubtype:p.eventSubtype,quantityReserved:p.quantityReserved,creditsReserved:p.creditsReserved,consumptionRate:p.consumptionRate,expiresAt:new Date(Date.now()+p.reservationTTL.reservationTTL),evalCtx:p.evalCtx}}function Us(p){if(p)return{...p,metricResetAt:p.metricResetAt?new Date(p.metricResetAt):void 0}}async function hb(p,o,i){try{await p.consume(o.id,0)}catch(t){i.warn(`Lease check: failed to cancel reservation ${o.id} (${t}); its hold is reclaimed by the sweeper or at lease expiry`)}}var vf=Number.MAX_SAFE_INTEGER;async function Tf(p){let{datastream:o,logger:i,mode:t,key:s,reason:r,flag:a,company:u,user:g,creditId:h,options:l}=p;if(t==="fail-closed")return Ea(t,s,r,a);try{let y=wb(u,h,vf),w=await o.getRulesEngine().checkFlagWithOptions(a,y,g,vs(l));return{allowed:w.value,value:w.value,reason:`${w.reason??"evaluated"} (${r}_fail_open)`,entitlement:Us(w.entitlement),flagKey:w.flagKey??s,flagId:w.flagId??a.id,err:r}}catch(y){return i.warn(`Lease check: fail-open evaluation failed (${y}); allowing`),Ea(t,s,r,a)}}function Ea(p,o,i,t){return p==="fail-closed"?{allowed:!1,value:!1,reason:i,flagKey:o,flagId:t?.id,err:i}:{allowed:!0,value:!0,reason:`${i}_fail_open`,flagKey:o,flagId:t?.id,err:i}}async function bb(p,o,i,t){let s=i*o.consumptionRate,r=await p.consume(o.id,s);return{track:Ca(o,i,t),settledLocally:r!==null}}function Ca(p,o,i){let t={event:p.eventSubtype,quantity:o,leaseId:p.leaseId};return p.evalCtx.company&&(t.company=p.evalCtx.company),p.evalCtx.user&&(t.user=p.evalCtx.user),i?.traits&&(t.traits=i.traits),t}var Rb="lease-reservation:",Ua=class extends _a{constructor(i){let{apiKey:t="",basePath:s,eventBufferInterval:r,eventCaptureBaseURL:a,flagDefaults:u={},logLevel:g,timeoutMs:h}=i??{},{offline:l=!1}=i??{},y=i?.logger??new oi(g),w={};i?.environmentId&&(w["X-Schematic-Environment-Id"]=i.environmentId),i?.headers&&Object.assign(w,i.headers),l?t!==""&&y.debug("Offline mode enabled, ignoring API key"):t===""&&!l&&(y.warn("No API key was provided, running in offline mode"),l=!0);let U=l?Zw:Yw(w);super({apiKey:t,environment:s,fetcher:U,timeoutInSeconds:h!==void 0?h/1e3:void 0});this.leaseBackendShared=!1;this.prewarmResolveTimeoutMs=5e3;this.logger=y;let T={},O=this._options?.headers;if(O)for(let[j,D]of Object.entries(O))typeof D=="string"&&(T[j]=D);let A=new Pa({apiKey:t,fetcher:U,headers:T,baseUrl:a,timeoutMs:h});if(this.eventBuffer=new Sa(A,{interval:r,logger:y,offline:l}),this.flagCheckCacheProviders=i?.cacheProviders?.flagChecks??[new rr],this.flagDefaults=u,this.offline=l,i?.useDataStream&&!l){let D=["workerd","edge-runtime","browser","web-worker"].includes(fe.type),V=i.dataStream?.replicatorMode===!0;if(D&&!V)y.warn(`DataStream is not supported in ${fe.type} runtime and will be disabled. DataStream requires Node.js APIs (WebSocket) that are not available in edge/browser environments. Use replicatorMode for edge runtime compatibility.`);else{let re={apiKey:t,baseURL:s,logger:y,cacheTTL:i.dataStream?.cacheTTL,redisClient:i.dataStream?.redisClient,redisKeyPrefix:i.dataStream?.redisKeyPrefix,replicatorMode:i.dataStream?.replicatorMode,replicatorHealthURL:i.dataStream?.replicatorHealthURL,replicatorHealthCheck:i.dataStream?.replicatorHealthCheck};this.datastreamClient=new _o(re),this.datastreamClient.start().catch(ue=>{y.error(`Failed to start DataStream client: ${ue}`),this.datastreamClient=void 0})}}if(i?.creditLeases&&l&&y.warn("creditLeases is configured but the client is in offline mode \u2014 lease-gated checks are disabled and check() will return flag defaults with no credit gating."),i?.creditLeases&&!l){this.datastreamClient||y.warn("creditLeases is configured but DataStream is not enabled \u2014 check() will fall back to plain flag checks with NO credit gating (usage is ignored). Set useDataStream: true (or replicatorMode) to enable lease-gated checks.");let j=i.creditLeases.sweepIntervalMs??1e3,D=i.creditLeases.redisClient??i.dataStream?.redisClient,V=i.creditLeases.redisKeyPrefix??i.dataStream?.redisKeyPrefix;D?(this.leaseBackendShared=!0,this.leaseStore=new Eo({client:D,keyPrefix:V,defaultLeaseDurationMs:i.creditLeases.defaultLeaseDuration}),this.reservations=new Co({client:D,leaseStore:this.leaseStore,sweepIntervalMs:j,keyPrefix:V})):(y.warn("creditLeases is enabled without a shared Redis backend; lease and reservation state will be kept per-process. Configure dataStream.redisClient (or creditLeases.redisClient) so leases gate correctly across multiple SDK instances."),this.leaseStore=new So,this.reservations=new Po(this.leaseStore,j)),this.reservations.startSweep(),this.creditLeaseManager=new xo({creditsClient:this.credits,leaseStore:this.leaseStore,logger:y,config:i.creditLeases}),this.prewarmResolveTimeoutMs=i.creditLeases.prewarmResolveTimeoutMs??5e3}}useDataStream(){return this.datastreamClient!==void 0}async checkFlag(i,t,s){return(await this.checkFlagWithEntitlement(i,t,s)).value}async checkFlagWithEntitlement(i,t,s){let r=()=>s?.defaultValue===void 0?this.getFlagDefault(t):typeof s.defaultValue=="function"?s.defaultValue():s.defaultValue;if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag value for flag ${t}`),{flagKey:t,reason:"flag default",value:r()};if(this.useDataStream())try{let a=await this.datastreamClient.checkFlag(i,t,s);return this.enqueueEvent(Oo.FlagCheck,{flagKey:t,value:a?.value??!1,reason:a?.reason??"unknown",ruleId:a?.ruleId,companyId:a?.companyId,userId:a?.userId,flagId:a?.flagId,reqCompany:i.company,reqUser:i.user}),{companyId:a.companyId,entitlement:a.entitlement,err:a.err,flagKey:a.flagKey??t,flagId:a.flagId,reason:a.reason,ruleId:a.ruleId,ruleType:a.ruleType,userId:a.userId,value:a.value??this.getFlagDefault(t)}}catch(a){return this.logger.debug(`Datastream flag check failed (${a}), falling back to API`),this.checkFlagViaAPI(i,t,s,r)}return this.checkFlagViaAPI(i,t,s,r)}async checkFlagViaAPI(i,t,s,r){let a=r??(()=>this.getFlagDefault(t));try{let u=JSON.stringify({evalCtx:i,key:t});for(let l of this.flagCheckCacheProviders){let y=await l.get(u);if(y!=null)return this.logger.debug(`${l.constructor.name} cache hit for flag ${t}`),y}let g=await this.features.checkFlag(t,i,{timeoutInSeconds:s?.timeoutMs!==void 0?s.timeoutMs/1e3:void 0});if(g.data.value===void 0)return this.logger.debug(`No value returned from feature flag API for flag ${t}, falling back to default`),{flagKey:t,reason:"flag default",value:a()};this.logger.debug(`Feature flag API response for ${t}: ${JSON.stringify(g.data)}`);let h={companyId:g.data.companyId,entitlement:g.data.entitlement,err:g.data.error,flagKey:g.data.flag,flagId:g.data.flagId,reason:g.data.reason,ruleId:g.data.ruleId,ruleType:g.data.ruleType,userId:g.data.userId,value:g.data.value};try{for(let l of this.flagCheckCacheProviders)this.logger.debug(`Caching value for flag ${t} in ${l.constructor.name}`),await l.set(u,h)}catch(l){this.logger.warn(`Cache write failed for flag ${t}: ${l}`)}return h}catch(u){return this.logger.error(`Error checking flag ${t}: ${u}`),{flagKey:t,reason:"flag default",value:a()}}}async checkFlags(i,t){if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag values for flags ${t?t.join(", "):"all"}`),t&&t.length>0?t.map(s=>({flag:s,value:this.getFlagDefault(s),reason:"Offline mode - using default value"})):[];try{if(this.useDataStream()&&this.datastreamClient.isConnected()&&t&&t.length>0){let w=await this.checkFlagsViaDataStream(i,t);if(w)return w}if(!t||t.length===0)return this.logger.debug("No specific flag keys provided, calling standard checkFlags API"),(await this.features.checkFlags(i)).data.flags;let s=new Map,r=[],a=await Promise.all(t.map(async w=>{let U=JSON.stringify({evalCtx:i,key:w});for(let T of this.flagCheckCacheProviders){let O=await T.get(U);if(O!=null)return this.logger.debug(`${T.constructor.name} cache hit for flag ${w}`),{key:w,cached:{flag:w,value:O.value,reason:O.reason}}}return{key:w,cached:null}}));for(let{key:w,cached:U}of a)U?s.set(w,U):r.push(w);if(r.length===0)return this.logger.debug(`All ${t.length} flags found in cache`),t.map(w=>s.get(w));this.logger.debug(`Cache miss for ${r.length} flags: ${r.join(", ")}, calling API`);let g=(await this.features.checkFlags(i)).data.flags,h=[],l=new Map(g.map(w=>[w.flag,w])),y=[];for(let w of t){let U=l.get(w);if(U){let T=JSON.stringify({evalCtx:i,key:w}),O={companyId:U.companyId,entitlement:U.entitlement,err:U.error,flagKey:U.flag,flagId:U.flagId,reason:U.reason,ruleId:U.ruleId,ruleType:U.ruleType,userId:U.userId,value:U.value};y.push({cacheKey:T,cacheEntry:O,key:w}),h.push(U)}else{let T=s.get(w);if(T)h.push(T);else{this.logger.debug(`Flag ${w} not found in API response or cache, using default value`);let O={flag:w,value:this.getFlagDefault(w),reason:"Flag not found - using default value"};h.push(O)}}}return await Promise.all(y.map(async({cacheKey:w,cacheEntry:U,key:T})=>{try{await Promise.all(this.flagCheckCacheProviders.map(O=>(this.logger.debug(`Caching value for flag ${w} in ${O.constructor.name}`),O.set(w,U))))}catch(O){this.logger.warn(`Cache write failed for flag ${T}: ${O}`)}})),this.logger.debug(`Checked ${t.length} flags: used fresh API values for consistency (${r.length} were cache misses)`),h}catch(s){return this.logger.error(`Error checking flags ${t?t.join(", "):"all"}: ${s}`),t&&t.length>0?t.map(r=>({flag:r,value:this.getFlagDefault(r),reason:`Error occurred - using default value: ${s}`})):[]}}async checkFlagsViaDataStream(i,t){let s=[];for(let r of t)try{let a=await this.datastreamClient.checkFlag(i,r);s.push({flag:a.flagKey??r,value:a.value??this.getFlagDefault(r),reason:a.reason,flagId:a.flagId,ruleId:a.ruleId,ruleType:a.ruleType,companyId:a.companyId,userId:a.userId,entitlement:a.entitlement,error:a.err})}catch(a){return this.logger.debug(`Datastream checkFlags falling back to API (${a})`),null}return this.logger.debug(`All ${t.length} flags evaluated via DataStream`),s}async close(){return this.reservations&&this.reservations.stop(),this.creditLeaseManager&&!this.leaseBackendShared&&await this.creditLeaseManager.releaseAllLocalLeases(),this.datastreamClient&&this.datastreamClient.close(),this.eventBuffer.stop()}async prewarm(i,t){if(!this.creditLeaseManager||!this.leaseStore){this.logger.debug("prewarm called but creditLeases is not configured");return}if(!i.company||Object.keys(i.company).length===0){this.logger.debug("prewarm requires a company on evalCtx");return}let s=await this.resolveCompanyIdWithWait(i);if(!s){this.logger.debug(`prewarm: company not resolved within ${this.prewarmResolveTimeoutMs}ms for keys ${JSON.stringify(i.company)} (first check() will acquire)`);return}await Promise.all(t.map(r=>this.creditLeaseManager.acquireIfNeeded(s,r).catch(a=>this.logger.warn(`prewarm: failed to acquire lease for ${r}: ${a}`))))}async resolveCompanyIdWithWait(i){if(!i.company)return;if(i.company.id)return i.company.id;let t=this.datastreamClient;if(!t||this.prewarmResolveTimeoutMs<=0)return this.resolveCompanyId(i);let s=i.company,r=await t.getCachedCompany(s);if(r?.id)return r.id;let a=Date.now()+this.prewarmResolveTimeoutMs;for(;;){try{let u=await t.getCompany(s);if(u?.id)return u.id}catch(u){this.logger.debug(`prewarm: datastream company fetch failed (${u})`)}if(Date.now()>=a)return;await new Promise(u=>setTimeout(u,100))}}async check(i,t,s){let r=async()=>{let u=await this.checkFlagWithEntitlement(i,t,{defaultValue:s?.defaultValue,timeoutMs:s?.timeoutMs,...s?vs(s):void 0});return{allowed:u.value,value:u.value,reason:u.reason,entitlement:u.entitlement,flagKey:u.flagKey,flagId:u.flagId,err:u.err}};return!(s?.usage!==void 0)||!this.creditLeaseManager||!this.leaseStore||!this.reservations?r():yb({leaseStore:this.leaseStore,reservations:this.reservations,manager:this.creditLeaseManager,datastream:this.datastreamClient,logger:this.logger,enqueueFlagCheckEvent:u=>this.enqueueEvent(Oo.FlagCheck,u)},t,i,s,r)}async trackWithReservation(i,t,s){if(this.offline)return;if(!Number.isFinite(t)||t<0){this.logger.error(`trackWithReservation: invalid actualQuantity ${t} for reservation ${i.id} \u2014 must be a finite, non-negative number; skipping settle (the hold is refunded at its TTL)`);return}if(!this.reservations){this.logger.warn("trackWithReservation called but creditLeases is not configured \u2014 emitting unsettled track"),await this.track(Ca(i,t,s),{idempotencyKey:`${Rb}${i.id}`});return}let r,a;try{({track:r,settledLocally:a}=await bb(this.reservations,i,t,s))}catch(u){this.logger.warn(`trackWithReservation: failed to settle reservation ${i.id} locally (${u}) \u2014 emitting track anyway`),r=Ca(i,t,s),a=!1}a||this.logger.debug(`trackWithReservation: reservation ${i.id} was not settled locally (expired/swept, already settled, or store unreachable) \u2014 emitting track keyed for idempotent server-side dedupe`),await this.track(r,{idempotencyKey:`${Rb}${i.id}`})}async resolveCompanyId(i){if(i.company){if(i.company.id)return i.company.id;if(this.datastreamClient)return(await this.datastreamClient.getCachedCompany(i.company))?.id}}async identify(i,t){if(!this.offline){try{await this.enqueueEvent("identify",i,t)}catch(s){this.logger.error(`Error sending identify event: ${s}`)}if(t?.prewarm&&t.prewarm.length>0){let s={company:i.company?.keys,user:i.keys};this.eventBuffer.flush().catch(r=>{this.logger.debug(`identify flush before prewarm failed: ${r}`)}),this.prewarm(s,t.prewarm).catch(r=>{this.logger.warn(`identify prewarm failed: ${r}`)})}}}async track(i,t){if(!this.offline)try{if(await this.enqueueEvent("track",i,t),i.company&&this.useDataStream()&&this.datastreamClient.isConnected())try{await this.datastreamClient.updateCompanyMetrics(i.company,i.event,i.quantity||1)}catch(s){this.logger.error(`Failed to update company metrics: ${s}`)}}catch(s){this.logger.error(`Error sending track event: ${s}`)}}setFlagDefault(i,t){this.flagDefaults[i]=t}setFlagDefaults(i){Object.assign(this.flagDefaults,i)}getFlagDefault(i){return this.flagDefaults[i]??!1}async enqueueEvent(i,t,s){try{let r={eventType:i,body:t,sentAt:new Date};s&&(s.idempotencyKey!==void 0&&(r.idempotencyKey=s.idempotencyKey),"sentAt"in s&&s.sentAt!==void 0&&(r.sentAt=s.sentAt),"trustedClientClock"in s&&s.trustedClientClock!==void 0&&(r.trustedClientClock=s.trustedClientClock),"backfill"in s&&s.backfill!==void 0&&(r.backfill=s.backfill)),this.eventBuffer.push(r)}catch(r){this.logger.error(`Error enqueueing ${i} event: ${r}`)}}};var va=no(require("crypto")),Ts="X-Schematic-Webhook-Signature",Os="X-Schematic-Webhook-Timestamp",wr=class p extends Error{constructor(o){super(o),Object.setPrototypeOf(this,p.prototype),this.name="WebhookSignatureError"}static missingSignature(){return new p("Missing webhook signature header")}static missingTimestamp(){return new p("Missing webhook timestamp header")}static invalidSignature(){return new p("Invalid webhook signature")}};function Ta(p,o,i){let t=Buffer.isBuffer(p)?p:Buffer.from(p),s=Buffer.concat([t,Buffer.from(`+${o}`)]),r=va.createHmac("sha256",i);return r.update(s),r.digest()}function _b(p,o,i){return Ta(p,o,i).toString("hex")}function ks(p,o,i,t){if(!o)throw wr.missingSignature();if(!i)throw wr.missingTimestamp();let s;try{s=Buffer.from(o,"hex")}catch(a){throw new wr(`Invalid signature format: ${a?.message||"Unknown error"}`)}let r=Ta(p,i,t);if(s.length!==r.length||!va.timingSafeEqual(s,r))throw wr.invalidSignature()}function Sb(p,o,i,t={}){let s=p.headers,r=t.signatureHeader||Ts,a=t.timestampHeader||Os,u=fb(s,r),g=fb(s,a),h;if(i!==void 0)h=i;else if("rawBody"in p&&p.rawBody)h=p.rawBody;else throw new wr("Request body is not available. Provide the body as a parameter or ensure req.rawBody exists.");ks(h,u,g,o)}function fb(p,o){let i=p[o]||p[o.toLowerCase()];return Array.isArray(i)?i[0]||"":i||""}0&&(module.exports={ConsoleLogger,LocalCache,LogLevel,RedisCacheProvider,RulesEngineClient,Schematic,SchematicClient,SchematicEnvironment,SchematicError,SchematicTimeoutError,WEBHOOK_SIGNATURE_HEADER,WEBHOOK_TIMESTAMP_HEADER,WebhookSignatureError,computeHexSignature,computeSignature,verifySignature,verifyWebhookSignature});
|
|
85
|
+
`;function Ob(p){return`${p.companyId}|${p.creditTypeId}|${p.id}`}function Ff(p){let o=p.split("|");if(o.length===3)return{companyId:o[0],creditTypeId:o[1],id:o[2]}}var kb=256,Kf=16,To=class{constructor(o){this.sweepInterval=null;this.stopped=!1;this.client=o.client,this.leaseStore=o.leaseStore,this.sweepIntervalMs=o.sweepIntervalMs??1e3,this.keyPrefix=o.keyPrefix??Vf}hashKey(o){return`${this.keyPrefix}${qf}${o}`}indexKey(){return`${this.keyPrefix}${Df}`}byCreditKey(o,i){return`${this.keyPrefix}${Mf}${o}:${i}`}async add(o){let i=o.expiresAt.getTime(),t=this.hashKey(o.id);await this.client.hSet(t,{id:o.id,leaseId:o.leaseId,companyId:o.companyId,creditTypeId:o.creditTypeId,eventSubtype:o.eventSubtype,quantityReserved:String(o.quantityReserved),creditsReserved:String(o.creditsReserved),consumptionRate:String(o.consumptionRate),expiresAt:String(i),evalCtx:JSON.stringify(o.evalCtx)}),await Promise.all([this.client.pExpireAt(t,i+3e4),this.client.zAdd(this.indexKey(),{score:i,value:Ob(o)}),this.client.hSet(this.byCreditKey(o.companyId,o.creditTypeId),o.id,String(o.creditsReserved))])}async get(o){let i=await this.client.hGetAll(this.hashKey(o));if(!(!i||!i.id))return Gf(i)}async reservedCredits(o,i){let t=await this.client.hGetAll(this.byCreditKey(o,i)).catch(()=>({})),s=0;for(let r of Object.values(t))s+=Number(r)||0;return s}async consume(o,i){let t=await this.client.eval(If,{keys:[this.hashKey(o)],arguments:[]}),s=Lf(t);if(!s||!s.id)return null;let r=s.companyId,a=s.creditTypeId,d=Number(s.creditsReserved)||0;await this.client.zRem(this.indexKey(),Ob({companyId:r,creditTypeId:a,id:o})).catch(()=>{}),await this.client.hDel(this.byCreditKey(r,a),o).catch(()=>{});let y=i;y<0&&(y=0),y>d&&(y=d);let g=d-y;return g>0&&await this.leaseStore.refund(r,a,g,s.leaseId),y}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(o=new Date){let i=o.getTime(),t=0;for(let s=0;s<Kf;s++){let r=await this.client.zRangeByScore(this.indexKey(),0,i,{LIMIT:{offset:0,count:kb}});if(r.length===0)break;for(let a of r){let d=Ff(a);if(!d){await this.client.zRem(this.indexKey(),a).catch(()=>{});continue}let y=await this.consume(d.id,0);if(await this.client.zRem(this.indexKey(),a).catch(()=>{}),y!==null){t++;continue}await this.client.hDel(this.byCreditKey(d.companyId,d.creditTypeId),d.id).catch(()=>{})}if(r.length<kb)break}return t}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}async size(){return this.client.zCard(this.indexKey()).catch(()=>0)}};function Lf(p){if(!Array.isArray(p)||p.length===0)return;let o={};for(let i=0;i+1<p.length;i+=2)o[String(p[i])]=String(p[i+1]);return o}function Gf(p){return{id:p.id,leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,eventSubtype:p.eventSubtype,quantityReserved:Number(p.quantityReserved),creditsReserved:Number(p.creditsReserved),consumptionRate:Number(p.consumptionRate),expiresAt:new Date(Number(p.expiresAt)),evalCtx:p.evalCtx?JSON.parse(p.evalCtx):{}}}var jb=require("crypto");function Oo(p,o,i,t){return p.enqueueFlagCheckEvent({flagKey:i.flagKey,value:i.value,reason:i.reason,error:i.err,flagId:i.flagId,companyId:t?.companyId,userId:t?.userId,ruleId:t?.ruleId,reqCompany:o.company,reqUser:o.user}),i}async function Ab(p,o,i,t,s){let{datastream:r,leaseStore:a,reservations:d,manager:y,logger:g}=p,l=t.onAcquireFailure??"fail-closed";if(t.usage===void 0||!Number.isFinite(t.usage)||t.usage<0)return g.error(`Lease check: invalid usage ${t.usage} for flag ${o} \u2014 must be a finite, non-negative number`),Oo(p,i,Ta(l,o,"invalid_usage",null));if(t.usage===0)return g.debug(`Lease check: usage is 0 for flag ${o} \u2014 nothing to reserve, using plain check`),s();if(!r)return g.debug("Credit-lease check requested without datastream \u2014 falling back to plain check"),s();let h=null;try{h=await r.getFlag(o)}catch(_e){g.warn(`Lease check: failed to load flag ${o}: ${_e}`)}if(!h)return g.debug(`Lease check: no cached flag for ${o}, falling back`),s();let{eventSubtype:w,quantity:U}=Hf(t);if(!i.company)return g.debug("Lease check: no company on evalCtx, falling back"),s();let T=null;try{T=await r.getCompany(i.company)}catch(_e){g.debug(`Lease check: company fetch failed for keys ${JSON.stringify(i.company)} (${_e}), falling back`)}if(!T)return s();let O=null;if(i.user){try{O=await r.getUser(i.user)}catch(_e){g.debug(`Lease check: user fetch failed for keys ${JSON.stringify(i.user)} (${_e}), falling back`)}if(!O)return s()}let A;try{A=await r.getRulesEngine().checkFlagWithOptions(h,T,O??null,null)}catch(_e){return g.warn(`Lease check: entitlement probe failed for flag ${o} (${_e}), falling back`),s()}let j=A.entitlement;if(!j||j.valueType!==Aa.Credit)return g.debug(`Lease check: flag ${o} matched a non-credit entitlement (valueType=${j?.valueType??"<none>"}), falling back to plain check \u2014 no reservation`),s();let D=j.creditId,V=j.consumptionRate??0,oe=w??j.eventSubtype;if(!D||V<=0||!oe)return g.debug(`Lease check: flag ${o} credit entitlement is incomplete (creditId=${D??"<none>"}, consumptionRate=${V}, subtype=${oe??"<none>"}), falling back`),s();let ue=U*V,Ue=t.timeoutMs!==void 0?{timeoutInSeconds:t.timeoutMs/1e3}:void 0,B=_e=>Jf({datastream:r,logger:g,mode:l,key:o,reason:_e,flag:h,company:T,user:O,creditId:D,options:t}).then(ko=>Oo(p,i,ko,{companyId:T.id,userId:O?.id})),ni=await y.acquireIfNeeded(T.id,D,Ue);if(!ni)return B("lease_acquire_failed");let zr;try{zr=await a.tryReserve(T.id,D,ue),zr===null&&(await y.maybeExtendInBackground(T.id,D,ue,Ue),zr=await a.tryReserve(T.id,D,ue))}catch(_e){return g.error(`Lease check: reserve against ${T.id}/${D} failed: ${_e}`),B("lease_store_error")}if(zr===null)return B("insufficient_lease_balance");let M=Nf({leaseId:ni.leaseId,companyId:T.id,creditTypeId:D,eventSubtype:oe,quantityReserved:U,creditsReserved:ue,consumptionRate:V,reservationTTL:Wf(p,D),evalCtx:i});try{await d.add(M)}catch(_e){g.error(`Lease check: failed to persist reservation ${M.id}: ${_e}`);try{await d.consume(M.id,0)===null&&await a.refund(T.id,D,ue,ni.leaseId)}catch(ko){g.warn(`Lease check: could not undo local debit for ${M.id} (${ko}); the slice is reclaimed at lease expiry`)}return B("lease_store_error")}let Rr=zr+ue,Lb=Vb(T,D,Rr),Gb={creditCost:{[D]:ue}},Ae;try{Ae=await r.getRulesEngine().checkFlagWithOptions(h,Lb,O??null,Gb)}catch(_e){return g.error(`Lease check: WASM eval failed: ${_e}`),await Bb(d,M,g),Oo(p,i,Ta(l,o,`wasm_error: ${_e}`,h),{companyId:T.id,userId:O?.id})}let Ms={companyId:Ae.companyId??T.id,userId:Ae.userId??O?.id,ruleId:Ae.ruleId};return Ae.value?(y.maybeExtendInBackground(T.id,D),Oo(p,i,{allowed:!0,value:!0,reservation:M,reason:Ae.reason??"lease_reserved",entitlement:js(Ae.entitlement),flagKey:Ae.flagKey??o,flagId:Ae.flagId},Ms)):(await Bb(d,M,g),Oo(p,i,{allowed:!1,value:!1,reason:Ae.reason??"denied_by_engine",entitlement:js(Ae.entitlement),flagKey:Ae.flagKey??o,flagId:Ae.flagId},Ms))}function Wf(p,o){return p.manager.resolveConfig(o)}function Hf(p){return{eventSubtype:p.eventSubtype,quantity:p.usage??0}}function As(p){if(p.usage!==void 0)return p.eventSubtype!==void 0?{eventUsage:{eventSubtype:p.eventSubtype,quantity:p.usage}}:{usage:p.usage}}function Vb(p,o,i){return{...p,creditBalances:{...p.creditBalances??{},[o]:i}}}function Nf(p){return{id:(0,jb.randomUUID)(),leaseId:p.leaseId,companyId:p.companyId,creditTypeId:p.creditTypeId,eventSubtype:p.eventSubtype,quantityReserved:p.quantityReserved,creditsReserved:p.creditsReserved,consumptionRate:p.consumptionRate,expiresAt:new Date(Date.now()+p.reservationTTL.reservationTTL),evalCtx:p.evalCtx}}function js(p){if(p)return{...p,metricResetAt:p.metricResetAt?new Date(p.metricResetAt):void 0}}async function Bb(p,o,i){try{await p.consume(o.id,0)}catch(t){i.warn(`Lease check: failed to cancel reservation ${o.id} (${t}); its hold is reclaimed by the sweeper or at lease expiry`)}}var $f=Number.MAX_SAFE_INTEGER;async function Jf(p){let{datastream:o,logger:i,mode:t,key:s,reason:r,flag:a,company:d,user:y,creditId:g,options:l}=p;if(t==="fail-closed")return Ta(t,s,r,a);try{let h=Vb(d,g,$f),w=await o.getRulesEngine().checkFlagWithOptions(a,h,y,As(l));return{allowed:w.value,value:w.value,reason:`${w.reason??"evaluated"} (${r}_fail_open)`,entitlement:js(w.entitlement),flagKey:w.flagKey??s,flagId:w.flagId??a.id,err:r}}catch(h){return i.warn(`Lease check: fail-open evaluation failed (${h}); allowing`),Ta(t,s,r,a)}}function Ta(p,o,i,t){return p==="fail-closed"?{allowed:!1,value:!1,reason:i,flagKey:o,flagId:t?.id,err:i}:{allowed:!0,value:!0,reason:`${i}_fail_open`,flagKey:o,flagId:t?.id,err:i}}async function qb(p,o,i,t){let s=i*o.consumptionRate,r=await p.consume(o.id,s);return{track:Oa(o,i,t),settledLocally:r!==null}}function Oa(p,o,i){let t={event:p.eventSubtype,quantity:o,leaseId:p.leaseId};return p.evalCtx.company&&(t.company=p.evalCtx.company),p.evalCtx.user&&(t.user=p.evalCtx.user),i?.traits&&(t.traits=i.traits),t}var Mb="lease-reservation:",ka=class extends Ca{constructor(i){let{apiKey:t="",basePath:s,eventBufferInterval:r,eventCaptureBaseURL:a,flagDefaults:d={},logLevel:y,timeoutMs:g}=i??{},{offline:l=!1}=i??{},h=i?.logger??new ai(y),w={};i?.environmentId&&(w["X-Schematic-Environment-Id"]=i.environmentId),i?.headers&&Object.assign(w,i.headers),l?t!==""&&h.debug("Offline mode enabled, ignoring API key"):t===""&&!l&&(h.warn("No API key was provided, running in offline mode"),l=!0);let U=l?yb:gb(w);super({apiKey:t,environment:s,fetcher:U,timeoutInSeconds:g!==void 0?g/1e3:void 0});this.leaseBackendShared=!1;this.prewarmResolveTimeoutMs=5e3;this.logger=h;let T={},O=this._options?.headers;if(O)for(let[j,D]of Object.entries(O))typeof D=="string"&&(T[j]=D);let A=new Ua({apiKey:t,fetcher:U,headers:T,baseUrl:a,timeoutMs:g});if(this.eventBuffer=new Ea(A,{interval:r,logger:h,offline:l}),this.flagCheckCacheProviders=i?.cacheProviders?.flagChecks??[new rr],this.flagDefaults=d,this.offline=l,i?.useDataStream&&!l){let D=["workerd","edge-runtime","browser","web-worker"].includes(fe.type),V=i.dataStream?.replicatorMode===!0;if(D&&!V)h.warn(`DataStream is not supported in ${fe.type} runtime and will be disabled. DataStream requires Node.js APIs (WebSocket) that are not available in edge/browser environments. Use replicatorMode for edge runtime compatibility.`);else{let oe={apiKey:t,baseURL:s,logger:h,cacheTTL:i.dataStream?.cacheTTL,redisClient:i.dataStream?.redisClient,redisKeyPrefix:i.dataStream?.redisKeyPrefix,replicatorMode:i.dataStream?.replicatorMode,replicatorHealthURL:i.dataStream?.replicatorHealthURL,replicatorHealthCheck:i.dataStream?.replicatorHealthCheck};this.datastreamClient=new xo(oe),this.datastreamClient.start().catch(ue=>{h.error(`Failed to start DataStream client: ${ue}`),this.datastreamClient=void 0})}}if(i?.creditLeases&&l&&h.warn("creditLeases is configured but the client is in offline mode \u2014 lease-gated checks are disabled and check() will return flag defaults with no credit gating."),i?.creditLeases&&!l){this.datastreamClient||h.warn("creditLeases is configured but DataStream is not enabled \u2014 check() will fall back to plain flag checks with NO credit gating (usage is ignored). Set useDataStream: true (or replicatorMode) to enable lease-gated checks.");let j=i.creditLeases.sweepIntervalMs??1e3,D=i.creditLeases.redisClient??i.dataStream?.redisClient,V=i.creditLeases.redisKeyPrefix??i.dataStream?.redisKeyPrefix;D?(this.leaseBackendShared=!0,this.leaseStore=new vo({client:D,keyPrefix:V,defaultLeaseDurationMs:i.creditLeases.defaultLeaseDuration}),this.reservations=new To({client:D,leaseStore:this.leaseStore,sweepIntervalMs:j,keyPrefix:V})):(h.warn("creditLeases is enabled without a shared Redis backend; lease and reservation state will be kept per-process. Configure dataStream.redisClient (or creditLeases.redisClient) so leases gate correctly across multiple SDK instances."),this.leaseStore=new Co,this.reservations=new Eo(this.leaseStore,j)),this.reservations.startSweep(),this.creditLeaseManager=new Uo({creditsClient:this.credits,leaseStore:this.leaseStore,logger:h,config:i.creditLeases}),this.prewarmResolveTimeoutMs=i.creditLeases.prewarmResolveTimeoutMs??5e3}}useDataStream(){return this.datastreamClient!==void 0}async checkFlag(i,t,s){return(await this.checkFlagWithEntitlement(i,t,s)).value}async checkFlagWithEntitlement(i,t,s){let r=()=>s?.defaultValue===void 0?this.getFlagDefault(t):typeof s.defaultValue=="function"?s.defaultValue():s.defaultValue;if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag value for flag ${t}`),{flagKey:t,reason:"flag default",value:r()};if(this.useDataStream())try{let a=await this.datastreamClient.checkFlag(i,t,s);return this.enqueueEvent(jo.FlagCheck,{flagKey:t,value:a?.value??!1,reason:a?.reason??"unknown",ruleId:a?.ruleId,companyId:a?.companyId,userId:a?.userId,flagId:a?.flagId,reqCompany:i.company,reqUser:i.user}),{companyId:a.companyId,entitlement:a.entitlement,err:a.err,flagKey:a.flagKey??t,flagId:a.flagId,reason:a.reason,ruleId:a.ruleId,ruleType:a.ruleType,userId:a.userId,value:a.value??this.getFlagDefault(t)}}catch(a){return this.logger.debug(`Datastream flag check failed (${a}), falling back to API`),this.checkFlagViaAPI(i,t,s,r)}return this.checkFlagViaAPI(i,t,s,r)}async checkFlagViaAPI(i,t,s,r){let a=r??(()=>this.getFlagDefault(t));try{let d=JSON.stringify({evalCtx:i,key:t});for(let l of this.flagCheckCacheProviders){let h=await l.get(d);if(h!=null)return this.logger.debug(`${l.constructor.name} cache hit for flag ${t}`),h}let y=await this.features.checkFlag(t,i,{timeoutInSeconds:s?.timeoutMs!==void 0?s.timeoutMs/1e3:void 0});if(y.data.value===void 0)return this.logger.debug(`No value returned from feature flag API for flag ${t}, falling back to default`),{flagKey:t,reason:"flag default",value:a()};this.logger.debug(`Feature flag API response for ${t}: ${JSON.stringify(y.data)}`);let g={companyId:y.data.companyId,entitlement:y.data.entitlement,err:y.data.error,flagKey:y.data.flag,flagId:y.data.flagId,reason:y.data.reason,ruleId:y.data.ruleId,ruleType:y.data.ruleType,userId:y.data.userId,value:y.data.value};try{for(let l of this.flagCheckCacheProviders)this.logger.debug(`Caching value for flag ${t} in ${l.constructor.name}`),await l.set(d,g)}catch(l){this.logger.warn(`Cache write failed for flag ${t}: ${l}`)}return g}catch(d){return this.logger.error(`Error checking flag ${t}: ${d}`),{flagKey:t,reason:"flag default",value:a()}}}async checkFlags(i,t){if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag values for flags ${t?t.join(", "):"all"}`),t&&t.length>0?t.map(s=>({flag:s,value:this.getFlagDefault(s),reason:"Offline mode - using default value"})):[];try{if(this.useDataStream()&&this.datastreamClient.isConnected()&&t&&t.length>0){let w=await this.checkFlagsViaDataStream(i,t);if(w)return w}if(!t||t.length===0)return this.logger.debug("No specific flag keys provided, calling standard checkFlags API"),(await this.features.checkFlags(i)).data.flags;let s=new Map,r=[],a=await Promise.all(t.map(async w=>{let U=JSON.stringify({evalCtx:i,key:w});for(let T of this.flagCheckCacheProviders){let O=await T.get(U);if(O!=null)return this.logger.debug(`${T.constructor.name} cache hit for flag ${w}`),{key:w,cached:{flag:w,value:O.value,reason:O.reason}}}return{key:w,cached:null}}));for(let{key:w,cached:U}of a)U?s.set(w,U):r.push(w);if(r.length===0)return this.logger.debug(`All ${t.length} flags found in cache`),t.map(w=>s.get(w));this.logger.debug(`Cache miss for ${r.length} flags: ${r.join(", ")}, calling API`);let y=(await this.features.checkFlags(i)).data.flags,g=[],l=new Map(y.map(w=>[w.flag,w])),h=[];for(let w of t){let U=l.get(w);if(U){let T=JSON.stringify({evalCtx:i,key:w}),O={companyId:U.companyId,entitlement:U.entitlement,err:U.error,flagKey:U.flag,flagId:U.flagId,reason:U.reason,ruleId:U.ruleId,ruleType:U.ruleType,userId:U.userId,value:U.value};h.push({cacheKey:T,cacheEntry:O,key:w}),g.push(U)}else{let T=s.get(w);if(T)g.push(T);else{this.logger.debug(`Flag ${w} not found in API response or cache, using default value`);let O={flag:w,value:this.getFlagDefault(w),reason:"Flag not found - using default value"};g.push(O)}}}return await Promise.all(h.map(async({cacheKey:w,cacheEntry:U,key:T})=>{try{await Promise.all(this.flagCheckCacheProviders.map(O=>(this.logger.debug(`Caching value for flag ${w} in ${O.constructor.name}`),O.set(w,U))))}catch(O){this.logger.warn(`Cache write failed for flag ${T}: ${O}`)}})),this.logger.debug(`Checked ${t.length} flags: used fresh API values for consistency (${r.length} were cache misses)`),g}catch(s){return this.logger.error(`Error checking flags ${t?t.join(", "):"all"}: ${s}`),t&&t.length>0?t.map(r=>({flag:r,value:this.getFlagDefault(r),reason:`Error occurred - using default value: ${s}`})):[]}}async checkFlagsViaDataStream(i,t){let s=[];for(let r of t)try{let a=await this.datastreamClient.checkFlag(i,r);s.push({flag:a.flagKey??r,value:a.value??this.getFlagDefault(r),reason:a.reason,flagId:a.flagId,ruleId:a.ruleId,ruleType:a.ruleType,companyId:a.companyId,userId:a.userId,entitlement:a.entitlement,error:a.err})}catch(a){return this.logger.debug(`Datastream checkFlags falling back to API (${a})`),null}return this.logger.debug(`All ${t.length} flags evaluated via DataStream`),s}async close(){return this.reservations&&this.reservations.stop(),this.creditLeaseManager&&!this.leaseBackendShared&&await this.creditLeaseManager.releaseAllLocalLeases(),this.datastreamClient&&this.datastreamClient.close(),this.eventBuffer.stop()}async prewarm(i,t){if(!this.creditLeaseManager||!this.leaseStore){this.logger.debug("prewarm called but creditLeases is not configured");return}if(!i.company||Object.keys(i.company).length===0){this.logger.debug("prewarm requires a company on evalCtx");return}let s=await this.resolveCompanyIdWithWait(i);if(!s){this.logger.debug(`prewarm: company not resolved within ${this.prewarmResolveTimeoutMs}ms for keys ${JSON.stringify(i.company)} (first check() will acquire)`);return}await Promise.all(t.map(r=>this.creditLeaseManager.acquireIfNeeded(s,r).catch(a=>this.logger.warn(`prewarm: failed to acquire lease for ${r}: ${a}`))))}async resolveCompanyIdWithWait(i){if(!i.company)return;if(i.company.id)return i.company.id;let t=this.datastreamClient;if(!t||this.prewarmResolveTimeoutMs<=0)return this.resolveCompanyId(i);let s=i.company,r=await t.getCachedCompany(s);if(r?.id)return r.id;let a=Date.now()+this.prewarmResolveTimeoutMs;for(;;){try{let d=await t.getCompany(s);if(d?.id)return d.id}catch(d){this.logger.debug(`prewarm: datastream company fetch failed (${d})`)}if(Date.now()>=a)return;await new Promise(d=>setTimeout(d,100))}}async check(i,t,s){let r=async()=>{let d=await this.checkFlagWithEntitlement(i,t,{defaultValue:s?.defaultValue,timeoutMs:s?.timeoutMs,...s?As(s):void 0});return{allowed:d.value,value:d.value,reason:d.reason,entitlement:d.entitlement,flagKey:d.flagKey,flagId:d.flagId,err:d.err}};return!(s?.usage!==void 0)||!this.creditLeaseManager||!this.leaseStore||!this.reservations?r():Ab({leaseStore:this.leaseStore,reservations:this.reservations,manager:this.creditLeaseManager,datastream:this.datastreamClient,logger:this.logger,enqueueFlagCheckEvent:d=>this.enqueueEvent(jo.FlagCheck,d)},t,i,s,r)}async trackWithReservation(i,t,s){if(this.offline)return;if(!Number.isFinite(t)||t<0){this.logger.error(`trackWithReservation: invalid actualQuantity ${t} for reservation ${i.id} \u2014 must be a finite, non-negative number; skipping settle (the hold is refunded at its TTL)`);return}if(!this.reservations){this.logger.warn("trackWithReservation called but creditLeases is not configured \u2014 emitting unsettled track"),await this.track(Oa(i,t,s),{idempotencyKey:`${Mb}${i.id}`});return}let r,a;try{({track:r,settledLocally:a}=await qb(this.reservations,i,t,s))}catch(d){this.logger.warn(`trackWithReservation: failed to settle reservation ${i.id} locally (${d}) \u2014 emitting track anyway`),r=Oa(i,t,s),a=!1}a||this.logger.debug(`trackWithReservation: reservation ${i.id} was not settled locally (expired/swept, already settled, or store unreachable) \u2014 emitting track keyed for idempotent server-side dedupe`),await this.track(r,{idempotencyKey:`${Mb}${i.id}`})}async resolveCompanyId(i){if(i.company){if(i.company.id)return i.company.id;if(this.datastreamClient)return(await this.datastreamClient.getCachedCompany(i.company))?.id}}async identify(i,t){if(!this.offline){try{await this.enqueueEvent("identify",i,t)}catch(s){this.logger.error(`Error sending identify event: ${s}`)}if(t?.prewarm&&t.prewarm.length>0){let s={company:i.company?.keys,user:i.keys};this.eventBuffer.flush().catch(r=>{this.logger.debug(`identify flush before prewarm failed: ${r}`)}),this.prewarm(s,t.prewarm).catch(r=>{this.logger.warn(`identify prewarm failed: ${r}`)})}}}async track(i,t){if(!this.offline)try{if(await this.enqueueEvent("track",i,t),i.company&&this.useDataStream()&&this.datastreamClient.isConnected())try{await this.datastreamClient.updateCompanyMetrics(i.company,i.event,i.quantity||1)}catch(s){this.logger.error(`Failed to update company metrics: ${s}`)}}catch(s){this.logger.error(`Error sending track event: ${s}`)}}setFlagDefault(i,t){this.flagDefaults[i]=t}setFlagDefaults(i){Object.assign(this.flagDefaults,i)}getFlagDefault(i){return this.flagDefaults[i]??!1}async enqueueEvent(i,t,s){try{let r={eventType:i,body:t,sentAt:new Date};s&&(s.idempotencyKey!==void 0&&(r.idempotencyKey=s.idempotencyKey),"sentAt"in s&&s.sentAt!==void 0&&(r.sentAt=s.sentAt),"trustedClientClock"in s&&s.trustedClientClock!==void 0&&(r.trustedClientClock=s.trustedClientClock),"backfill"in s&&s.backfill!==void 0&&(r.backfill=s.backfill)),this.eventBuffer.push(r)}catch(r){this.logger.error(`Error enqueueing ${i} event: ${r}`)}}};var Ba=lo(require("crypto")),Vs="X-Schematic-Webhook-Signature",qs="X-Schematic-Webhook-Timestamp",br=class p extends Error{constructor(o){super(o),Object.setPrototypeOf(this,p.prototype),this.name="WebhookSignatureError"}static missingSignature(){return new p("Missing webhook signature header")}static missingTimestamp(){return new p("Missing webhook timestamp header")}static invalidSignature(){return new p("Invalid webhook signature")}};function ja(p,o,i){let t=Buffer.isBuffer(p)?p:Buffer.from(p),s=Buffer.concat([t,Buffer.from(`+${o}`)]),r=Ba.createHmac("sha256",i);return r.update(s),r.digest()}function Fb(p,o,i){return ja(p,o,i).toString("hex")}function Ds(p,o,i,t){if(!o)throw br.missingSignature();if(!i)throw br.missingTimestamp();let s;try{s=Buffer.from(o,"hex")}catch(a){throw new br(`Invalid signature format: ${a?.message||"Unknown error"}`)}let r=ja(p,i,t);if(s.length!==r.length||!Ba.timingSafeEqual(s,r))throw br.invalidSignature()}function Kb(p,o,i,t={}){let s=p.headers,r=t.signatureHeader||Vs,a=t.timestampHeader||qs,d=Ib(s,r),y=Ib(s,a),g;if(i!==void 0)g=i;else if("rawBody"in p&&p.rawBody)g=p.rawBody;else throw new br("Request body is not available. Provide the body as a parameter or ensure req.rawBody exists.");Ds(g,d,y,o)}function Ib(p,o){let i=p[o]||p[o.toLowerCase()];return Array.isArray(i)?i[0]||"":i||""}0&&(module.exports={ConsoleLogger,LocalCache,LogLevel,RedisCacheProvider,RulesEngineClient,Schematic,SchematicClient,SchematicEnvironment,SchematicError,SchematicTimeoutError,WEBHOOK_SIGNATURE_HEADER,WEBHOOK_TIMESTAMP_HEADER,WebhookSignatureError,computeHexSignature,computeSignature,verifySignature,verifyWebhookSignature});
|