@schematichq/schematic-typescript-node 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/api/resources/billing/client/Client.d.ts +47 -0
  2. package/dist/api/resources/billing/client/requests/ListBillingPricesRequest.d.ts +3 -0
  3. package/dist/api/resources/billing/client/requests/ListBillingProductPricesRequest.d.ts +3 -0
  4. package/dist/api/resources/billing/types/DeleteBillingCouponResponse.d.ts +6 -0
  5. package/dist/api/resources/billing/types/DeleteBillingCustomerResponse.d.ts +6 -0
  6. package/dist/api/resources/billing/types/DeleteBillingInvoiceResponse.d.ts +6 -0
  7. package/dist/api/resources/billing/types/ListBillingPricesParams.d.ts +2 -0
  8. package/dist/api/resources/billing/types/ListBillingProductPricesParams.d.ts +2 -0
  9. package/dist/api/resources/billing/types/index.d.ts +3 -0
  10. package/dist/api/resources/plans/client/Client.d.ts +1 -5
  11. package/dist/api/resources/plans/client/requests/PublishPlanVersionRequestBody.d.ts +1 -6
  12. package/dist/api/resources/webhooks/client/Client.d.ts +18 -0
  13. package/dist/api/resources/webhooks/client/requests/TestWebhookRequestBody.d.ts +10 -0
  14. package/dist/api/resources/webhooks/client/requests/index.d.ts +1 -0
  15. package/dist/api/resources/webhooks/types/SendTestWebhookActionResponse.d.ts +6 -0
  16. package/dist/api/resources/webhooks/types/index.d.ts +1 -0
  17. package/dist/api/types/AccountMemberPermission.d.ts +0 -1
  18. package/dist/api/types/CheckFlagsResponseData.d.ts +2 -0
  19. package/dist/api/types/CompanyCreditBalance.d.ts +8 -0
  20. package/dist/api/types/CompanySubscriptionResponseData.d.ts +1 -0
  21. package/dist/api/types/FeatureEntitlement.d.ts +4 -0
  22. package/dist/api/types/RulesengineFeatureEntitlement.d.ts +4 -0
  23. package/dist/api/types/TestWebhookResponseData.d.ts +4 -0
  24. package/dist/api/types/index.d.ts +2 -0
  25. package/dist/credits/check.d.ts +9 -5
  26. package/dist/credits/types.d.ts +11 -9
  27. package/dist/datastream/merge.d.ts +1 -1
  28. package/dist/index.js +9 -9
  29. package/dist/rules-engine.d.ts +4 -0
  30. package/dist/serialization/resources/billing/types/DeleteBillingCouponResponse.d.ts +11 -0
  31. package/dist/serialization/resources/billing/types/DeleteBillingCustomerResponse.d.ts +11 -0
  32. package/dist/serialization/resources/billing/types/DeleteBillingInvoiceResponse.d.ts +11 -0
  33. package/dist/serialization/resources/billing/types/ListBillingPricesParams.d.ts +1 -0
  34. package/dist/serialization/resources/billing/types/ListBillingProductPricesParams.d.ts +1 -0
  35. package/dist/serialization/resources/billing/types/index.d.ts +3 -0
  36. package/dist/serialization/resources/plans/client/requests/PublishPlanVersionRequestBody.d.ts +0 -2
  37. package/dist/serialization/resources/webhooks/client/requests/TestWebhookRequestBody.d.ts +10 -0
  38. package/dist/serialization/resources/webhooks/client/requests/index.d.ts +1 -0
  39. package/dist/serialization/resources/webhooks/types/SendTestWebhookActionResponse.d.ts +11 -0
  40. package/dist/serialization/resources/webhooks/types/index.d.ts +1 -0
  41. package/dist/serialization/types/AccountMemberPermission.d.ts +1 -1
  42. package/dist/serialization/types/CheckFlagsResponseData.d.ts +2 -0
  43. package/dist/serialization/types/CompanyCreditBalance.d.ts +11 -0
  44. package/dist/serialization/types/CompanySubscriptionResponseData.d.ts +1 -0
  45. package/dist/serialization/types/FeatureEntitlement.d.ts +2 -0
  46. package/dist/serialization/types/RulesengineFeatureEntitlement.d.ts +2 -0
  47. package/dist/serialization/types/TestWebhookResponseData.d.ts +10 -0
  48. package/dist/serialization/types/index.d.ts +2 -0
  49. package/dist/wasm/rulesengine.js +4 -4
  50. package/dist/wrapper.d.ts +0 -30
  51. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var Sw=Object.create;var ft=Object.defineProperty;var Pw=Object.getOwnPropertyDescriptor;var xw=Object.getOwnPropertyNames;var Ew=Object.getPrototypeOf,Cw=Object.prototype.hasOwnProperty;var ni=(p,t)=>()=>(p&&(t=p(p=0)),t);var Uw=(p,t)=>()=>(t||p((t={exports:{}}).exports,t),t.exports),yr=(p,t)=>{for(var i in t)ft(p,i,{get:t[i],enumerable:!0})},ws=(p,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xw(t))!Cw.call(p,s)&&s!==i&&ft(p,s,{get:()=>t[s],enumerable:!(o=Pw(t,s))||o.enumerable});return p};var Qi=(p,t,i)=>(i=p!=null?Sw(Ew(p)):{},ws(t||!p||!p.__esModule?ft(i,"default",{value:p,enumerable:!0}):i,p)),bs=p=>ws(ft({},"__esModule",{value:!0}),p);var Fs={};yr(Fs,{Node18UniversalStreamWrapper:()=>Ca});var Ca,Ks=ni(()=>{"use strict";Ca=class p{constructor(t){this.readableStream=t,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(t,i){this.events[t]?.push(i)}off(t,i){this.events[t]=this.events[t]?.filter(o=>o!==i)}pipe(t){return this.on("data",async i=>{if(t instanceof p)t._write(i);else if(t instanceof WritableStream){let o=t.getWriter();o.write(i).then(()=>o.releaseLock())}else t.write(i)}),this.on("end",async()=>{t instanceof p?t._end():t instanceof WritableStream?t.getWriter().close():t.end()}),this.on("error",async i=>{t instanceof p?t._error(i):t instanceof WritableStream?t.getWriter().abort(i):t.destroy(i)}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",async i=>{if(t instanceof p)t._write(i);else if(t instanceof WritableStream){let o=t.getWriter();o.write(i).then(()=>o.releaseLock())}else t.write(i)}),this.off("end",async()=>{t instanceof p?t._end():t instanceof WritableStream?t.getWriter().close():t.end()}),this.off("error",async i=>{t instanceof p?t._error(i):t instanceof WritableStream?t.getWriter().abort(i):t.destroy(i)})}destroy(t){this.reader.cancel(t).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(o=>{this.resumeCallback=o});let{done:t,value:i}=await this.reader.read();if(!t)return i}setEncoding(t){this.encoding=t}async text(){let t=[];for(;;){let{done:o,value:s}=await this.reader.read();if(o)break;s&&t.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(t).arrayBuffer())}async json(){let t=await this.text();return JSON.parse(t)}_write(t){this._emit("data",t)}_end(){this._emit("end")}_error(t){this._emit("error",t)}_emit(t,i){if(this.events[t])for(let o of this.events[t]||[])o(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o});let{done:t,value:i}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(t){this._emit("error",t)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o});let{done:t,value:i}=await this.reader.read();return t?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var Ls={};yr(Ls,{UndiciStreamWrapper:()=>Ua});var Ua,Gs=ni(()=>{"use strict";Ua=class p{constructor(t){this.readableStream=t,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(t,i){this.events[t]?.push(i)}off(t,i){this.events[t]=this.events[t]?.filter(o=>o!==i)}pipe(t){return this.on("data",i=>{if(t instanceof p)t._write(i);else{let o=t.getWriter();o.write(i).then(()=>o.releaseLock())}}),this.on("end",()=>{t instanceof p?t._end():t.getWriter().close()}),this.on("error",i=>{t instanceof p?t._error(i):t.getWriter().abort(i)}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",i=>{if(t instanceof p)t._write(i);else{let o=t.getWriter();o.write(i).then(()=>o.releaseLock())}}),this.off("end",()=>{t instanceof p?t._end():t.getWriter().close()}),this.off("error",i=>{t instanceof p?t._error(i):t.getWriter().abort(i)})}destroy(t){this.reader.cancel(t).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(o=>{this.resumeCallback=o});let{done:t,value:i}=await this.reader.read();if(!t)return i}setEncoding(t){this.encoding=t}async text(){let t=[];for(;;){let{done:o,value:s}=await this.reader.read();if(o)break;s&&t.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(t).arrayBuffer())}async json(){let t=await this.text();return JSON.parse(t)}_write(t){this._emit("data",t)}_end(){this._emit("end")}_error(t){this._emit("error",t)}_emit(t,i){if(this.events[t])for(let o of this.events[t]||[])o(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o});let{done:t,value:i}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(t){this._emit("error",t)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o});let{done:t,value:i}=await this.reader.read();return t?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var Ws={};yr(Ws,{NodePre18StreamWrapper:()=>va});var va,Ns=ni(()=>{"use strict";va=class{constructor(t){this.readableStream=t}on(t,i){this.readableStream.on(t,i)}off(t,i){this.readableStream.off(t,i)}pipe(t){return this.readableStream.pipe(t),t}pipeTo(t){return this.pipe(t)}unpipe(t){t?this.readableStream.unpipe(t):this.readableStream.unpipe()}destroy(t){this.readableStream.destroy(t)}pause(){this.readableStream.pause()}resume(){this.readableStream.resume()}get isPaused(){return this.readableStream.isPaused()}async read(){return new Promise((t,i)=>{let o=this.readableStream.read();o?t(o):(this.readableStream.once("readable",()=>{let s=this.readableStream.read();t(s)}),this.readableStream.once("error",i))})}setEncoding(t){this.readableStream.setEncoding(t),this.encoding=t}async text(){let t=[],i=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let s of this.readableStream)t.push(i.encode(s));return new TextDecoder(this.encoding||"utf-8").decode(Buffer.concat(t))}async json(){let t=await this.text();return JSON.parse(t)}[Symbol.asyncIterator](){let i=this.readableStream[Symbol.asyncIterator]();return{async next(){let{value:o,done:s}=await i.next();return{value:o,done:s}},[Symbol.asyncIterator](){return this}}}}});var Zi,cs=ni(()=>{"use strict";Zi=class{constructor(){this._emitter=null}ensureEmitter(){if(!this._emitter){let{EventEmitter:t}=require("events");this._emitter=new t}return this._emitter}on(t,i){return this.ensureEmitter().on(t,i),this}emit(t,...i){return this._emitter?.emit(t,...i)??!1}removeAllListeners(t){return this._emitter?.removeAllListeners(t),this}}});var Xy=Uw((Pre,Hz)=>{Hz.exports={name:"@schematichq/schematic-typescript-node",version:"1.5.1",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 Qy,ew,rw,iw=ni(()=>{"use strict";Qy=Xy(),ew=Qy.name,rw=Qy.version});var aw={};yr(aw,{DatastreamWSClient:()=>us});function Qz(p){let t=new URL(p);switch(t.protocol){case"https:":t.protocol="wss:";break;case"http:":t.protocol="ws:";break;default:throw new Error(`Unsupported scheme: ${t.protocol} (must be http: or https:)`)}if(t.hostname){let i=t.hostname.split(".");i.length>1&&i[0]==="api"&&(i[0]="datastream",t.hostname=i.join("."))}return t.pathname="/datastream",t.toString()}var tw,$z,ow,Jz,Yz,Zz,Xz,us,nw=ni(()=>{"use strict";tw=Qi(require("ws"));iw();cs();$z=10*1e3,ow=60*1e3,Jz=ow*9/10,Yz=10,Zz=1*1e3,Xz=30*1e3;us=class extends Zi{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=Qz(i.url):this.url=i.url,this.headers={"X-Schematic-Api-Key":i.apiKey,"X-Schematic-Client":ew,"X-Schematic-Client-Version":rw,"X-Schematic-Datastream-Mode":"datastream"},this.logger=i.logger,this.messageHandler=i.messageHandler,this.connectionReadyHandler=i.connectionReadyHandler,this.maxReconnectAttempts=i.maxReconnectAttempts??Yz,this.minReconnectDelay=i.minReconnectDelay??Zz,this.maxReconnectDelay=i.maxReconnectDelay??Xz}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((o,s)=>{if(!this.ws){s(new Error("WebSocket connection is not available!"));return}let r=setTimeout(()=>{s(new Error("Write timeout"))},$z);try{this.ws.send(JSON.stringify(i),a=>{clearTimeout(r),a?s(a):o()})}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(o){this.logger.error(`Connection ready handler failed: ${o}`),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(o=>{let s=()=>{this.logger.info("WebSocket connection closed"),this.cleanup(),o()},r=a=>{this.logger.error(`WebSocket error: ${a.message}`),this.emit("error",a),this.cleanup(),o()};i.on("close",s),i.on("error",r)}),!this.shouldReconnect)break}catch(i){this.reconnectAttempts++,this.setConnected(!1),this.setReady(!1);let o=i instanceof Error?i.message:String(i);if(this.logger.warn(`WebSocket connection failed: ${o}, 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,o)=>{this.logger.debug(`Connecting to WebSocket: ${this.url}`);let s=new tw.default(this.url,{headers:this.headers,handshakeTimeout:3e4}),r=setTimeout(()=>{s.close(),o(new Error("Connection timeout"))},3e4);s.on("open",()=>{clearTimeout(r),i(s)}),s.on("error",a=>{clearTimeout(r),o(a)})})}setupWebSocketHandlers(i){i.on("message",o=>{this.handleMessage(o)}),i.on("pong",()=>{this.handlePong()}),i.on("close",o=>{this.handleClose(o)}),i.on("error",o=>{this.handleError(o)})}async handleMessage(i){try{let o;Buffer.isBuffer(i)?o=i.toString():Array.isArray(i)?o=Buffer.concat(i).toString():o=String(i);let s;try{s=JSON.parse(o)}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(o){this.emit("error",o)}}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()},Jz),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()},ow),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 o=Math.floor(Math.random()*this.minReconnectDelay),s=Math.pow(2,i-1)*this.minReconnectDelay+o;return Math.min(s,this.maxReconnectDelay+o)}setConnected(i){let o=this.connected;this.connected=i,i||(this.ready=!1),o!==i&&(this.logger.debug(`Connection state changed: ${i}`),i?this.emit("connected"):this.emit("disconnected"))}setReady(i){let o=this.ready;this.ready=i,o!==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 vR={};yr(vR,{ConsoleLogger:()=>Qr,LocalCache:()=>rr,LogLevel:()=>er,RedisCacheProvider:()=>ri,RulesEngineClient:()=>Yi,Schematic:()=>ae,SchematicClient:()=>Ra,SchematicEnvironment:()=>z,SchematicError:()=>b,SchematicTimeoutError:()=>ei,WEBHOOK_SIGNATURE_HEADER:()=>hs,WEBHOOK_TIMESTAMP_HEADER:()=>gs,WebhookSignatureError:()=>mr,computeHexSignature:()=>Rw,computeSignature:()=>_a,verifySignature:()=>ys,verifyWebhookSignature:()=>fw});module.exports=bs(vR);var ae={};yr(ae,{AccountMemberPermission:()=>Tw,AccountMemberRole:()=>Ow,ActorType:()=>kw,ApiKeyScope:()=>Bw,BadRequestError:()=>v,BillingCreditBundleStatus:()=>jw,BillingCreditBurnStrategy:()=>Aw,BillingCreditExpiryType:()=>Vw,BillingCreditExpiryUnit:()=>qw,BillingCreditGrantReason:()=>Mw,BillingCreditGrantZeroedOutReason:()=>Dw,BillingCreditLedgerAuthority:()=>Iw,BillingCreditRolloverPolicy:()=>Fw,BillingPlanCreditGrantResetCadence:()=>Kw,BillingPlanCreditGrantResetStart:()=>Lw,BillingPlanCreditGrantResetType:()=>Gw,BillingPriceScheme:()=>Ww,BillingPriceUsageType:()=>Nw,BillingProductPriceInterval:()=>Hw,BillingProviderType:()=>$w,BillingStrategy:()=>Jw,BillingSubscriptionTrialEndSetting:()=>Yw,BillingTiersMode:()=>Zw,ChargeType:()=>Xw,CompanyMatchingCriteria:()=>Qw,CompanyPlanInvalidReason:()=>eb,ComparableOperator:()=>rb,ComponentEntityType:()=>ib,ComponentState:()=>tb,ConditionType:()=>ob,CreditEventType:()=>ab,CreditGrantSortOrder:()=>nb,CreditUsageReason:()=>sb,CustomPlanActivationStrategy:()=>cb,CustomPlanBillingStatus:()=>lb,DataExportStatus:()=>pb,EntitlementPriceBehavior:()=>ub,EntitlementType:()=>db,EntitlementValueType:()=>mb,EntityType:()=>hb,EnvironmentType:()=>gb,EventStatus:()=>yb,EventType:()=>_t,FeatureLifecyclePhase:()=>wb,FeatureType:()=>bb,ForbiddenError:()=>_,IntegrationState:()=>zb,IntegrationType:()=>Rb,InternalServerError:()=>S,InvoiceStatus:()=>fb,MetricPeriod:()=>_b,MetricPeriodMonthReset:()=>Sb,MigrationErrorCode:()=>Pb,NotFoundError:()=>P,PlanBundleAction:()=>xb,PlanChangeAction:()=>Eb,PlanChangeBasePlanAction:()=>Cb,PlanChangeSubscriptionAction:()=>Ub,PlanIcon:()=>vb,PlanPriceCadence:()=>Tb,PlanType:()=>Ob,PlanVersionCompanyMigrationStatus:()=>kb,PlanVersionMigrationStatus:()=>Bb,PlanVersionMigrationStrategy:()=>jb,PlanVersionStatus:()=>Ab,ProrationBehavior:()=>Vb,RuleType:()=>Wb,RulesEngineSchemaVersion:()=>qb,RulesengineConditionType:()=>Mb,RulesengineEntitlementValueType:()=>Db,RulesengineEntityType:()=>Ib,RulesengineMetricPeriod:()=>Fb,RulesengineMetricPeriodMonthReset:()=>Kb,RulesengineRuleType:()=>Lb,RulesengineTraitDefinitionComparableType:()=>Gb,ScheduledCheckoutStatus:()=>Nb,ScheduledDowngradeConfigBehavior:()=>Hb,SortDirection:()=>$b,SubscriptionStatus:()=>Jb,SubscriptionType:()=>Yb,TimeSeriesGranularity:()=>Zb,TraitDefinitionComparableType:()=>Xb,TraitType:()=>Qb,TrialStatus:()=>ez,UnauthorizedError:()=>x,WebhookEventStatus:()=>rz,WebhookRequestType:()=>iz,WebhookStatus:()=>tz,accesstokens:()=>zs,accounts:()=>Rs,billing:()=>fs,checkout:()=>_s,companies:()=>Ss,components:()=>Ps,componentspublic:()=>xs,credits:()=>Es,dataexports:()=>Cs,entitlements:()=>Us,events:()=>vs,features:()=>Ts,insights:()=>Os,integrationsapi:()=>ks,planbundle:()=>Bs,plangroups:()=>js,planmigrations:()=>As,plans:()=>Vs,scheduledcheckout:()=>qs,webhooks:()=>Ms});var ve=(p,t,i)=>JSON.stringify(p,t,i);function et(p,t){return JSON.parse(p,t)}var b=class extends Error{constructor({message:t,statusCode:i,body:o,rawResponse:s,cause:r}){super(vw({message:t,statusCode:i,body:o})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.statusCode=i,this.body=o,this.rawResponse=s,r!=null&&(this.cause=r)}};function vw({message:p,statusCode:t,body:i}){let o=[];return p!=null&&o.push(p),t!=null&&o.push(`Status code: ${t.toString()}`),i!=null&&o.push(`Body: ${ve(i,void 0,2)}`),o.join(`
2
- `)}var ei=class extends Error{constructor(t,i){super(t),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(t,i){super({message:"BadRequestError",statusCode:400,body:t,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(t,i){super({message:"ForbiddenError",statusCode:403,body:t,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(t,i){super({message:"InternalServerError",statusCode:500,body:t,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(t,i){super({message:"NotFoundError",statusCode:404,body:t,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(t,i){super({message:"UnauthorizedError",statusCode:401,body:t,rawResponse:i}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var zs={};var Rs={};var fs={};var _s={};var Ss={};var Ps={};var xs={};var Es={};var Cs={};var Us={};var vs={};var Ts={};var Os={};var ks={};var Bs={};var js={};var As={};var Vs={};var qs={};var Ms={};var Tw={BillingCreditsEdit:"billing_credits_edit",CompaniesEdit:"companies_edit",CompanyUsersEdit:"company_users_edit",ComponentsEdit:"components_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 Ow={Admin:"admin",Member:"member"};var kw={ApiKey:"api_key",AppUser:"app_user",StripeApp:"stripe_app",System:"system",TemporaryAccessToken:"temporary_access_token"};var Bw={Admin:"admin",Capture:"capture",Read:"read",Write:"write"};var jw={Active:"active",Inactive:"inactive"};var Aw={ExpirationPriority:"expiration_priority",FirstInFirstOut:"first_in_first_out",LastInFirstOut:"last_in_first_out",PlanFirstThenCreditBundlesFirstInFirstOut:"plan_first_then_credit_bundles_first_in_first_out"};var Vw={Duration:"duration",EndOfBillingPeriod:"end_of_billing_period",EndOfNextBillingPeriod:"end_of_next_billing_period",EndOfTrial:"end_of_trial",NoExpiry:"no_expiry"};var qw={BillingPeriods:"billing_periods",Days:"days"};var Mw={Adjustment:"adjustment",BillingCreditAutoTopup:"billing_credit_auto_topup",Free:"free",Plan:"plan",Purchased:"purchased",Rollover:"rollover"};var Dw={Expired:"expired",Manual:"manual",PlanChange:"plan_change",PlanPeriodReset:"plan_period_reset",Reconciled:"reconciled"};var Iw={SchematicAuthoritative:"schematic_authoritative",ExternalMirror:"external_mirror",ExternalRated:"external_rated"};var Fw={Expire:"expire",None:"none",Rollover:"rollover"};var Kw={Daily:"daily",Monthly:"monthly",Weekly:"weekly",Yearly:"yearly"};var Lw={BillingPeriod:"billing_period",FirstOfMonth:"first_of_month"};var Gw={NoReset:"no_reset",PlanPeriod:"plan_period"};var Ww={PerUnit:"per_unit",Tiered:"tiered"};var Nw={Licensed:"licensed",Metered:"metered"};var Hw={Day:"day",Month:"month",OneTime:"one-time",Year:"year"};var $w={Metronome:"metronome",Orb:"orb",Schematic:"schematic",Stripe:"stripe"};var Jw={SchematicManaged:"schematic_managed",ProviderManaged:"provider_managed",NoBilling:"no_billing"};var Yw={Cancel:"cancel",Subscribe:"subscribe"};var Zw={Graduated:"graduated",Volume:"volume"};var Xw={Free:"free",None:"none",OneTime:"one_time",Recurring:"recurring"};var Qw={BillingMetaObject:"billing_meta_object",ManualUpsert:"manual_upsert"};var eb={DowngradeNotPermitted:"downgrade_not_permitted",FeatureUsageExceeded:"feature_usage_exceeded"};var rb={Eq:"eq",Gt:"gt",Gte:"gte",IsEmpty:"is_empty",Lt:"lt",Lte:"lte",NotEmpty:"not_empty",Ne:"ne"};var ib={Billing:"billing",Entitlement:"entitlement"};var tb={Draft:"draft",Live:"live"};var ob={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var ab={Grant:"grant",Transfer:"transfer",Usage:"usage",ZeroOut:"zero_out"};var nb={CreatedAt:"created_at",ExpiresAt:"expires_at",Quantity:"quantity",QuantityRemaining:"quantity_remaining"};var sb={LeaseHold:"lease_hold",LeaseRelease:"lease_release",ManualAdjustment:"manual_adjustment",Reconciliation:"reconciliation",Track:"track"};var cb={OnPayment:"on_payment",OnPublish:"on_publish"};var lb={Active:"active",Expired:"expired",Paid:"paid",Pending:"pending"};var pb={Failure:"failure",Pending:"pending",Success:"success"};var ub={CreditBurndown:"credit_burndown",Overage:"overage",PayAsYouGo:"pay_as_you_go",PayInAdvance:"pay_in_advance",Tier:"tier"};var db={CompanyOverride:"company_override",PlanEntitlement:"plan_entitlement",Unknown:"unknown"};var mb={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var hb={Company:"company",User:"user"};var gb={Development:"development",Production:"production",Staging:"staging"};var yb={Enriched:"enriched",Failed:"failed",Pending:"pending",Processed:"processed",Unknown:"unknown"};var _t={FlagCheck:"flag_check",Identify:"identify",Track:"track"};var wb={AddOn:"add_on",Alpha:"alpha",Beta:"beta",Deprecated:"deprecated",Ga:"ga",Inactive:"inactive",InPlan:"in_plan",InternalTesting:"internal_testing",Legacy:"legacy"};var bb={Boolean:"boolean",Event:"event",Trait:"trait"};var zb={Active:"active",Created:"created",Pending:"pending"};var Rb={Clerk:"clerk",Metronome:"metronome",Orb:"orb",Stripe:"stripe",Unknown:"unknown",Workos:"workos"};var fb={Draft:"draft",Open:"open",Paid:"paid",Uncollectible:"uncollectible",Void:"void"};var _b={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var Sb={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Pb={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 xb={Create:"create",Update:"update",Delete:"delete"};var Eb={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 Cb={Fallback:"fallback",Initial:"initial",Trait:"trait",TrialExpiry:"trial_expiry"};var Ub={Adjustment:"adjustment",Downgrade:"downgrade",Invalid:"invalid",Subscribe:"subscribe",Unsubscribe:"unsubscribe",Upgrade:"upgrade",UpgradeTrial:"upgrade_trial"};var vb={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 Tb={Monthly:"monthly",Quarterly:"quarterly",Yearly:"yearly"};var Ob={Plan:"plan",AddOn:"add_on"};var kb={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending",Skipped:"skipped"};var Bb={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending"};var jb={Immediate:"immediate",Leave:"leave"};var Ab={Published:"published",Draft:"draft",Archived:"archived"};var Vb={CreateProrations:"create_prorations",InvoiceImmediately:"invoice_immediately"};var qb={V97288F60:"v97288f60",PlaceholderForFernCompatibility:"placeholder-for-fern-compatibility"};var Mb={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Db={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var Ib={Company:"company",User:"user"};var Fb={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var Kb={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Lb={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Gb={Bool:"bool",Date:"date",Int:"int",String:"string"};var Wb={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Nb={Cancelled:"cancelled",Error:"error",Executing:"executing",Pending:"pending",Success:"success"};var Hb={EndOfBillingPeriod:"end_of_billing_period",None:"none"};var $b={Asc:"asc",Desc:"desc"};var Jb={Active:"active",Canceled:"canceled",Expired:"expired",Incomplete:"incomplete",IncompleteExpired:"incomplete_expired",PastDue:"past_due",Paused:"paused",Trialing:"trialing",Unpaid:"unpaid"};var Yb={Free:"free",OneTime:"one_time",Paid:"paid",Trial:"trial"};var Zb={Daily:"daily",Hourly:"hourly",Monthly:"monthly",Weekly:"weekly"};var Xb={Bool:"bool",Date:"date",Int:"int",String:"string"};var Qb={Boolean:"boolean",Currency:"currency",Date:"date",Number:"number",String:"string",Url:"url"};var ez={Active:"active",Converted:"converted",Expired:"expired"};var rz={Failure:"failure",Pending:"pending",Success:"success"};var iz={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 tz={Active:"active",Inactive:"inactive"};var oz=2147483647,rr=class{constructor({maxItems:t=1e3,ttl:i=5e3}={}){this.accessCounter=0;this.cache=new Map,this.maxItems=t,this.defaultTTL=i}async get(t){let i=this.cache.get(t);return i?i.expiration<=Date.now()?(this.evictItem(t,i),null):(this.accessCounter++,i.accessCounter=this.accessCounter,this.cache.set(t,i),i.value):null}async set(t,i,o){if(this.maxItems===0)return;let s=o??this.defaultTTL,r=this.cache.get(t);r&&this.evictItem(t,r),this.evictExpiredItems(),this.evictLRUItems(),this.accessCounter++;let a={value:i,accessCounter:this.accessCounter,expiration:Date.now()+s};a.timeoutId=setTimeout(()=>this.evictItem(t,a),Math.min(s,oz)),typeof a.timeoutId=="object"&&typeof a.timeoutId.unref=="function"&&a.timeoutId.unref(),this.cache.set(t,a)}async delete(t){let i=this.cache.get(t);i&&this.evictItem(t,i)}async deleteMissing(t,i){let o=new Set(t);for(let[s,r]of this.cache)o.has(s)||this.evictItem(s,r)}evictItem(t,i){i.timeoutId&&clearTimeout(i.timeoutId),this.cache.delete(t)}evictExpiredItems(){this.cache.forEach((t,i)=>{t.expiration<=Date.now()&&this.evictItem(i,t)})}evictLRUItems(){for(;this.cache.size>=this.maxItems;){let t,i=Number.MAX_SAFE_INTEGER;this.cache.forEach((o,s)=>{o.accessCounter<i&&(t=s,i=o.accessCounter)}),t&&this.evictItem(t,this.cache.get(t))}}};var ri=class{constructor(t){this.client=t.client,this.defaultTTL=Math.floor((t.ttl||5e3)/1e3),this.keyPrefix=t.keyPrefix||"schematic:"}getFullKey(t){return this.keyPrefix+t}async get(t){let i=this.getFullKey(t),o=await this.client.get(i);return o===null?null:JSON.parse(o)}async set(t,i,o){let s=this.getFullKey(t),r=JSON.stringify(i),a=o?Math.floor(o/1e3):this.defaultTTL;a>0?await this.client.setEx(s,a,r):await this.client.set(s,r)}async delete(t){let i=this.getFullKey(t);await this.client.del(i)}async deleteMissing(t,i){let o=i?.scanPattern?this.keyPrefix+i.scanPattern:this.keyPrefix+"*",s=new Set(t.map(u=>this.getFullKey(u))),r=[],a=1e3;for await(let u of this.client.scanIterator({MATCH:o,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 Pa(p){return typeof p=="object"&&p!==null&&"getAuthRequest"in p&&typeof p.getAuthRequest=="function"}var si=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var St={get:async(p,t)=>typeof p=="function"?p(t):p};var Je={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Ds={[Je.Debug]:1,[Je.Info]:2,[Je.Warn]:3,[Je.Error]:4},rt=class{debug(t,...i){console.debug(t,...i)}info(t,...i){console.info(t,...i)}warn(t,...i){console.warn(t,...i)}error(t,...i){console.error(t,...i)}},ci=class{constructor(t){this.level=Ds[t.level],this.logger=t.logger,this.silent=t.silent}shouldLog(t){return!this.silent&&this.level<=Ds[t]}isDebug(){return this.shouldLog(Je.Debug)}debug(t,...i){this.isDebug()&&this.logger.debug(t,...i)}isInfo(){return this.shouldLog(Je.Info)}info(t,...i){this.isInfo()&&this.logger.info(t,...i)}isWarn(){return this.shouldLog(Je.Warn)}warn(t,...i){this.isWarn()&&this.logger.warn(t,...i)}isError(){return this.shouldLog(Je.Error)}error(t,...i){this.isError()&&this.logger.error(t,...i)}};function it(p){return p==null?az:p instanceof ci?p:(p=p??{},p.level??=Je.Info,p.logger??=new rt,p.silent??=!0,new ci(p))}var az=new ci({level:Je.Info,logger:new rt,silent:!0});var nz={arrayFormat:"indices",encode:!0};function xa(p,t){if(p===void 0||p===null)return"";let i=String(p);return t?encodeURIComponent(i):i}function Ea(p,t="",i){let o=[];for(let[s,r]of Object.entries(p)){let a=t?`${t}[${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(c=>c!=null).map(c=>xa(c,i.encode));h.length>0&&o.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 c=u==="indices"?`${a}[${g}]`:a;o.push(...Ea(h,c,i))}else{let c=u==="indices"?`${a}[${g}]`:a,y=i.encode?encodeURIComponent(c):c;o.push(`${y}=${xa(h,i.encode)}`)}}}else if(typeof r=="object"&&r!==null){if(Object.keys(r).length===0)continue;o.push(...Ea(r,a,i))}else{let u=i.encode?encodeURIComponent(a):a;o.push(`${u}=${xa(r,i.encode)}`)}}return o}function wr(p,t){return p==null||typeof p!="object"?"":Ea(p,"",{...nz,...t}).join("&")}function Pt(p,t){let i=wr(t,{arrayFormat:"repeat"});return i?`${p}?${i}`:p}function Is(p){let t={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"&&(t.bytes=p.bytes.bind(p)),t}var fe=sz();function sz(){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 Hs(p){return fe.type==="node"&&fe.parsedVersion!=null&&fe.parsedVersion>=18?new(await Promise.resolve().then(()=>(Ks(),Fs))).Node18UniversalStreamWrapper(p):fe.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(Gs(),Ls))).UndiciStreamWrapper(p):new(await Promise.resolve().then(()=>(Ns(),Ws))).NodePre18StreamWrapper(p)}async function li(p,t){switch(t){case"binary-response":return Is(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}}:Hs(p.body);case"text":return await p.text()}let i=await p.text();if(i.length>0)try{return et(i)}catch{return{ok:!1,error:{reason:"non-json",statusCode:p.status,rawBody:i}}}}async function $s(p){let t=p.headers.get("Content-Type")?.toLowerCase();if(t==null||t.length===0)return li(p);switch(t.indexOf(";")!==-1&&(t=t.split(";")[0]?.trim()??""),t){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?et(i):void 0}default:if(t.startsWith("application/vnd.")&&t.endsWith("+json")){let i=await p.text();return i.length>0?et(i):void 0}return await p.text()}}async function pi(){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 xt({body:p,type:t}){return t==="form"?wr(p,{arrayFormat:"repeat",encode:!0}):t.includes("json")?ve(p):p}var ir;typeof globalThis.Headers<"u"?ir=globalThis.Headers:ir=class Js{constructor(t){if(this.headers=new Map,t)if(t instanceof Js)t.forEach((i,o)=>this.append(o,i));else if(Array.isArray(t))for(let[i,o]of t)if(typeof i=="string"&&typeof o=="string")this.append(i,o);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[i,o]of Object.entries(t))if(typeof o=="string")this.append(i,o);else throw new TypeError("Header values must be strings")}append(t,i){let o=t.toLowerCase(),s=this.headers.get(o)||[];this.headers.set(o,[...s,i])}delete(t){let i=t.toLowerCase();this.headers.delete(i)}get(t){let i=t.toLowerCase(),o=this.headers.get(i);return o?o.join(", "):null}has(t){let i=t.toLowerCase();return this.headers.has(i)}set(t,i){let o=t.toLowerCase();this.headers.set(o,[i])}forEach(t,i){let o=i?t.bind(i):t;this.headers.forEach((s,r)=>o(s.join(", "),r,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[t,i]of this.headers.entries())yield[t,i.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let t of this.headers.values())yield t.join(", ")}[Symbol.iterator](){return this.entries()}};var cz="timeout";function Ys(p){let t=new AbortController,i=setTimeout(()=>t.abort(cz),p);return{signal:t.signal,abortId:i}}function Zs(...p){let t=p.length===1&&Array.isArray(p[0])?p[0]:p,i=new AbortController;for(let o of t){if(o.aborted){i.abort(o?.reason);break}o.addEventListener("abort",()=>i.abort(o?.reason),{signal:i.signal})}return i.signal}var tt;function lz(){if(tt!=null)return tt;try{new Request("http://localhost",{cache:"no-store"}),tt=!0}catch{tt=!1}return tt}var ui=async(p,t,i,o,s,r,a,u,g,h)=>{let c=[],y;if(r!=null){let{signal:T,abortId:O}=Ys(r);y=O,c.push(T)}a!=null&&c.push(a);let w=Zs(c),U=await p(t,{method:i,headers:o,body:s,signal:w,credentials:u?"include":void 0,duplex:g,...h&&lz()?{cache:"no-store"}:{}});return y!=null&&clearTimeout(y),U};var di={headers:new ir,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},mi={headers:new ir,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function ot(p){return{headers:p.headers,redirected:p.redirected,status:p.status,statusText:p.statusText,type:p.type,url:p.url}}function pz(p){return[408,429].includes(p)||p>=500}function uz(p){let t=1+Math.random()*.2;return p*t}function dz(p){let t=1+(Math.random()-.5)*.2;return p*t}function mz(p,t){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 o=p.headers.get("X-RateLimit-Reset");if(o){let s=parseInt(o,10);if(!Number.isNaN(s)){let r=s*1e3-Date.now();if(r>0)return uz(Math.min(r,6e4))}}return dz(Math.min(1e3*2**t,6e4))}async function hi(p,t=2){let i=await p();for(let o=0;o<t&&pz(i.status);++o){let s=mz(i,o);await new Promise(r=>setTimeout(r,s)),i=await p()}return i}var hz=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 Ta(p){let t={};for(let[i,o]of p instanceof ir?p.entries():Object.entries(p))hz.has(i.toLowerCase())?t[i]="[REDACTED]":t[i]=o;return t}var Oa=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 gz(p){if(p==null)return;let t={};for(let[i,o]of Object.entries(p))t[i]=Oa.has(i.toLowerCase())?"[REDACTED]":o;return t}function ii(p){let t=p.indexOf("://");if(t===-1)return p;let i=t+3,o=p.indexOf("/",i),s=p.indexOf("?",i),r=p.indexOf("#",i),a=Math.min(o===-1?p.length:o,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 c=h.toLowerCase();if(!(c.includes("token")||c.includes("key")||c.includes("password")||c.includes("passwd")||c.includes("secret")||c.includes("session")||c.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 j=T.slice(0,O),B=Oa.has(j.toLowerCase());if(!B&&j.includes("%"))try{let I=decodeURIComponent(j);B=Oa.has(I.toLowerCase())}catch{}w.push(B?`${j}=[REDACTED]`:T)}return p.slice(0,s+1)+w.join("&")+p.slice(g)}async function yz(p){let t=new ir;if(t.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&&t.set("Content-Type",p.contentType),p.headers==null)return t;for(let[i,o]of Object.entries(p.headers)){let s=await St.get(o,{endpointMetadata:p.endpointMetadata??{}});if(typeof s=="string"){t.set(i,s);continue}s!=null&&t.set(i,`${s}`)}return t}async function wz(p){let t=p.url;p.queryString!=null&&p.queryString.length>0?t=`${t}?${p.queryString}`:t=Pt(p.url,p.queryParameters);let i=await xt({body:p.body,type:p.requestType??"other"}),o=p.fetchFn??await pi(),s=await yz(p),r=it(p.logging);if(r.isDebug()){let a={method:p.method,url:ii(t),headers:Ta(s),queryParameters:gz(p.queryParameters),hasBody:i!=null};r.debug("Making HTTP request",a)}try{let a=await hi(async()=>ui(o,t,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:ii(t),statusCode:a.status,responseHeaders:Ta(a.headers)};r.debug("HTTP request succeeded",g)}return{ok:!0,body:await li(a,p.responseType),headers:a.headers,rawResponse:ot(a)}}else{if(r.isError()){let u={method:p.method,url:ii(t),statusCode:a.status,responseHeaders:Ta(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 $s(a)},rawResponse:ot(a)}}}catch(a){if(p.abortSignal?.aborted){if(r.isError()){let u={method:p.method,url:ii(t)};r.error("HTTP request was aborted",u)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:a},rawResponse:di}}else if(a instanceof Error&&a.name==="AbortError"){if(r.isError()){let u={method:p.method,url:ii(t),timeoutMs:p.timeoutMs};r.error("HTTP request timed out",u)}return{ok:!1,error:{reason:"timeout",cause:a},rawResponse:di}}else if(a instanceof Error){if(r.isError()){let u={method:p.method,url:ii(t),errorMessage:a.message};r.error("HTTP request failed with error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:a.message,cause:a},rawResponse:mi}}if(r.isError()){let u={method:p.method,url:ii(t),error:ve(a)};r.error("HTTP request failed with unknown error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:ve(a),cause:a},rawResponse:mi}}}var E=wz;var R=class p extends Promise{constructor(t){super(i=>{i(void 0)}),this.innerPromise=t}static fromFunction(t,...i){return new p(t(...i))}static interceptFunction(t){return(...i)=>p.fromPromise(t(...i))}static fromPromise(t){return new p(t)}static fromExecutor(t){let i=new Promise(t);return new p(i)}static fromResult(t){let i=Promise.resolve(t);return new p(i)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:t})=>t)),this.unwrappedPromise}then(t,i){return this.unwrap().then(t,i)}catch(t){return this.unwrap().catch(t)}finally(t){return this.unwrap().finally(t)}async withRawResponse(){return await this.innerPromise}};function Et(p,...t){if(!p)return"";if(t.length===0)return p;if(p.includes("://")){let i;try{i=new URL(p)}catch{return Xs(p,...t)}let s=t[t.length-1]?.endsWith("/");for(let r of t){let a=ec(r);a&&(i.pathname=Qs(i.pathname,a))}return s&&!i.pathname.endsWith("/")&&(i.pathname+="/"),i.toString()}return Xs(p,...t)}function Xs(p,...t){if(t.length===0)return p;let i=p,s=t[t.length-1]?.endsWith("/");for(let r of t){let a=ec(r);a&&(i=Qs(i,a))}return s&&!i.endsWith("/")&&(i+="/"),i}function Qs(p,t){return p.endsWith("/")?p+t:`${p}/${t}`}function ec(p){if(!p)return p;let t=0,i=p.length;return p.startsWith("/")&&(t=1),p.endsWith("/")&&(i=p.length-1),t===0&&i===p.length?p:p.slice(t,i)}var m={get:async p=>typeof p=="function"?p():p};async function ka(p,t,i,o){let s=it(i.logging),r,a=t;p instanceof Request?(r=p.url,t==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=Et(u,r):g=r;let h={};if(i.headers!=null)for(let[I,A]of Object.entries(i.headers)){let X=await St.get(A,{endpointMetadata:{}});X!=null&&(h[I.toLowerCase()]=`${X}`)}if(i.getAuthHeaders!=null){let I=await i.getAuthHeaders();for(let[A,X]of Object.entries(I))h[A.toLowerCase()]=X}if(a?.headers!=null){let I=a.headers instanceof Headers?Object.fromEntries(a.headers.entries()):Array.isArray(a.headers)?Object.fromEntries(a.headers):a.headers;for(let[A,X]of Object.entries(I))X!=null&&(h[A.toLowerCase()]=X)}if(o?.headers!=null)for(let[I,A]of Object.entries(o.headers))h[I.toLowerCase()]=A;let c=a?.method??"GET",y=a?.body,w=o?.timeoutInSeconds??i.timeoutInSeconds,U=w!=null?w*1e3:void 0,T=o?.maxRetries??i.maxRetries,O=o?.abortSignal??a?.signal??void 0,j=i.fetch??await pi();s.isDebug()&&s.debug("Making passthrough HTTP request",{method:c,url:g,hasBody:y!=null});let B=await hi(async()=>ui(j,g,c,h,y??void 0,U,O,a?.credentials==="include",void 0,!1),T);return s.isDebug()&&s.debug("Passthrough HTTP request completed",{method:c,url:g,statusCode:B.status}),B}var Ct={};yr(Ct,{ConsoleLogger:()=>rt,LogLevel:()=>Je,Logger:()=>ci,createLogger:()=>it});var e={};yr(e,{JsonError:()=>gi,ParseError:()=>yi,any:()=>gc,bigint:()=>ic,boolean:()=>yc,booleanLiteral:()=>mc,date:()=>tc,discriminant:()=>Ec,enum_:()=>at,forwardCompatibleEnum_:()=>oc,getObjectLikeUtils:()=>Ye,getObjectUtils:()=>ti,getSchemaUtils:()=>Y,isProperty:()=>zr,lazy:()=>ac,lazyObject:()=>uc,list:()=>Tt,never:()=>wc,number:()=>bc,object:()=>vt,objectWithoutOptionalProperties:()=>pc,optional:()=>Ba,partialRecord:()=>_c,property:()=>sc,record:()=>fc,set:()=>Sc,string:()=>zc,stringLiteral:()=>hc,transform:()=>ja,undiscriminatedUnion:()=>xc,union:()=>Uc,unknown:()=>Rc,withParsedProperties:()=>qa});var D={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 J(p,t){return`Expected ${t}. Received ${bz(p)}.`}function bz(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:rc(p.json),parse:rc(p.parse)}}function rc(p){return(t,i)=>{let o=p(t,i),{skipValidation:s=!1}=i??{};return!o.ok&&s?(console.warn(["Failed to validate.",...o.errors.map(r=>" - "+(r.path.length>0?`${r.path.join(".")}: ${r.message}`:r.message))].join(`
3
- `)),{ok:!0,value:t}):o}}function Ut(p){return p.path.length===0?p.message:`${p.path.join(" -> ")}: ${p.message}`}var gi=class extends Error{constructor(i){super(i.map(Ut).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};var yi=class extends Error{constructor(i){super(i.map(Ut).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};function Y(p){return{nullable:()=>zz(p),optional:()=>Ba(p),optionalNullable:()=>Rz(p),transform:t=>ja(p,t),parseOrThrow:(t,i)=>{let o=p.parse(t,i);if(o.ok)return o.value;throw new yi(o.errors)},jsonOrThrow:(t,i)=>{let o=p.json(t,i);if(o.ok)return o.value;throw new gi(o.errors)}}}function zz(p){let t={parse:(i,o)=>i==null?{ok:!0,value:null}:p.parse(i,o),json:(i,o)=>i==null?{ok:!0,value:null}:p.json(i,o),getType:()=>D.NULLABLE};return{...t,...Y(t)}}function Ba(p){let t={parse:(i,o)=>i==null?{ok:!0,value:void 0}:p.parse(i,o),json:(i,o)=>o?.omitUndefined&&i===void 0?{ok:!0,value:void 0}:i==null?{ok:!0,value:null}:p.json(i,o),getType:()=>D.OPTIONAL};return{...t,...Y(t)}}function Rz(p){let t={parse:(i,o)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.parse(i,o),json:(i,o)=>i===void 0?{ok:!0,value:void 0}:i===null?{ok:!0,value:null}:p.json(i,o),getType:()=>D.OPTIONAL_NULLABLE};return{...t,...Y(t)}}function ja(p,t){let i={parse:(o,s)=>{let r=p.parse(o,s);return r.ok?{ok:!0,value:t.transform(r.value)}:r},json:(o,s)=>{let r=t.untransform(o);return p.json(r,s)},getType:()=>p.getType()};return{...i,...Y(i)}}function ic(){let p={parse:(t,{breadcrumbsPrefix:i=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:i,message:J(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:i=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:i,message:J(t,"bigint")}]}:{ok:!0,value:t},getType:()=>D.BIGINT};return{...ye(p),...Y(p)}}var fz=/^([+-]?\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 tc(){let p={parse:(t,{breadcrumbsPrefix:i=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:i,message:J(t,"string")}]}:fz.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:i,message:J(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:i=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:i,message:J(t,"Date object")}]},getType:()=>D.DATE};return{...ye(p),...Y(p)}}function be(p,t){return()=>{let i={parse:t,json:t,getType:()=>p};return{...ye(i),...Y(i)}}}function at(p){let t=new Set(p);return be(D.ENUM,(o,{allowUnrecognizedEnumValues:s,breadcrumbsPrefix:r=[]}={})=>typeof o!="string"?{ok:!1,errors:[{path:r,message:J(o,"string")}]}:!t.has(o)&&!s?{ok:!1,errors:[{path:r,message:J(o,"enum")}]}:{ok:!0,value:o})()}function oc(p){return at(p).transform({transform:t=>t,untransform:t=>t})}function ac(p){let t=Aa(p);return{...t,...Y(t)}}function Aa(p){return{parse:(t,i)=>wi(p).parse(t,i),json:(t,i)=>wi(p).json(t,i),getType:()=>wi(p).getType()}}function wi(p){let t=p;return t.__zurg_memoized==null&&(t.__zurg_memoized=p()),t.__zurg_memoized}function Va(p){return Object.entries(p)}function nt(p,t){let i=new Set(t);return Object.entries(p).reduce((o,[s,r])=>(i.has(s)&&(o[s]=r),o),{})}function br(p){if(typeof p!="object"||p===null)return!1;let t=Object.getPrototypeOf(p);return t===null?!0:Object.getPrototypeOf(t)===null}function st(p){return Object.keys(p)}function nc(p,t){let i=[],o=[];for(let s of p)t(s)?i.push(s):o.push(s);return[i,o]}var _z=Object.prototype.hasOwnProperty;function Ye(p){return{withParsedProperties:t=>qa(p,t)}}function qa(p,t){let i={parse:(o,s)=>{let r=p.parse(o,s);if(!r.ok)return r;let a={};for(let u in t)if(_z.call(t,u)){let g=t[u];a[u]=typeof g=="function"?g(r.value):g}return{ok:!0,value:{...r.value,...a}}},json:(o,s)=>{if(!br(o))return{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:J(o,"object")}]};let r=new Set(Object.keys(t)),a=nt(o,Object.keys(o).filter(u=>!r.has(u)));return p.json(a,s)},getType:()=>p.getType()};return{...i,...Y(i),...Ye(i)}}function sc(p,t){return{rawKey:p,valueSchema:t,isProperty:!0}}function zr(p){return p.isProperty}var Sz=Object.prototype.hasOwnProperty;function vt(p){let t;function i(){if(t==null){t={};for(let[w,U]of Va(p)){let T=zr(U)?U.rawKey:w,O=zr(U)?U.valueSchema:U;t[T]={rawKey:T,parsedKey:w,valueSchema:O}}}return t}let o,s,r,a;function u(){if(o==null){o=[],s=[];for(let[w,U]of Va(p)){let T=zr(U)?U.rawKey:w,O=zr(U)?U.valueSchema:U;Pz(O)&&(o.push(T),s.push(w))}r=new Set(o),a=new Set(s)}return o}function g(){return s==null&&u(),s}function h(){return r==null&&u(),r}function c(){return a==null&&u(),a}let y={_getRawProperties:()=>Object.entries(p).map(([w,U])=>zr(U)?U.rawKey:w),_getParsedProperties:()=>st(p),parse:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return cc({value:w,requiredKeys:u(),requiredKeysSet:h(),getProperty:O=>{let j=i()[O];if(j!=null)return{transformedKey:j.parsedKey,transform:B=>{let I=[...T,O];return j.valueSchema.parse(B,{...U,breadcrumbsPrefix:I})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},json:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return cc({value:w,requiredKeys:g(),requiredKeysSet:c(),getProperty:O=>{let j=p[O];if(j!=null)return zr(j)?{transformedKey:j.rawKey,transform:B=>{let I=[...T,O];return j.valueSchema.json(B,{...U,breadcrumbsPrefix:I})}}:{transformedKey:O,transform:B=>{let I=[...T,O];return j.json(B,{...U,breadcrumbsPrefix:I})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:T,omitUndefined:U?.omitUndefined})},getType:()=>D.OBJECT};return{...ye(y),...Y(y),...Ye(y),...ti(y)}}function cc({value:p,requiredKeys:t,requiredKeysSet:i,getProperty:o,unrecognizedObjectKeys:s="fail",skipValidation:r=!1,breadcrumbsPrefix:a=[]}){if(!br(p))return{ok:!1,errors:[{path:a,message:J(p,"object")}]};let u=t.length,g=[],h={};for(let c in p){if(!Sz.call(p,c))continue;let y=p[c],w=o(c);if(w!=null){u>0&&i.has(c)&&u--;let U=w.transform(y);U.ok?h[w.transformedKey]=U.value:(h[c]=y,g.push(...U.errors))}else switch(s){case"fail":g.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":h[c]=y;break}}if(u>0)for(let c of t)c in p||g.push({path:a,message:`Missing required key "${c}"`});return g.length===0||r?{ok:!0,value:h}:{ok:!1,errors:g}}function ti(p){return{extend:t=>{let i={_getParsedProperties:()=>[...p._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...p._getRawProperties(),...t._getRawProperties()],parse:(o,s)=>lc({extensionKeys:t._getRawProperties(),value:o,transformBase:r=>p.parse(r,s),transformExtension:r=>t.parse(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(o,s)=>lc({extensionKeys:t._getParsedProperties(),value:o,transformBase:r=>p.json(r,s),transformExtension:r=>t.json(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>D.OBJECT};return{...i,...Y(i),...Ye(i),...ti(i)}},passthrough:()=>{let t=new Set(p._getRawProperties()),i=new Set(p._getParsedProperties()),o={_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))t.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:()=>D.OBJECT};return{...o,...Y(o),...Ye(o),...ti(o)}}}}function lc({extensionKeys:p,value:t,transformBase:i,transformExtension:o,breadcrumbsPrefix:s=[]}){if(!br(t))return{ok:!1,errors:[{path:s,message:J(t,"object")}]};let r=new Set(p),[a,u]=nc(st(t),c=>r.has(c)),g=i(nt(t,u)),h=o(nt(t,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 Pz(p){return!xz(p)}function xz(p){switch(p.getType()){case D.ANY:case D.UNKNOWN:case D.OPTIONAL:case D.OPTIONAL_NULLABLE:return!0;default:return!1}}function pc(p){return vt(p)}function uc(p){let t={...Aa(p),_getRawProperties:()=>wi(p)._getRawProperties(),_getParsedProperties:()=>wi(p)._getParsedProperties()};return{...t,...Y(t),...Ye(t),...ti(t)}}function Tt(p){let t={parse:(i,o)=>dc(i,(s,r)=>p.parse(s,{...o,breadcrumbsPrefix:[...o?.breadcrumbsPrefix??[],`[${r}]`]})),json:(i,o)=>dc(i,(s,r)=>p.json(s,{...o,breadcrumbsPrefix:[...o?.breadcrumbsPrefix??[],`[${r}]`]})),getType:()=>D.LIST};return{...ye(t),...Y(t)}}function dc(p,t){if(!Array.isArray(p))return{ok:!1,errors:[{message:J(p,"list"),path:[]}]};let i=[],o=[];for(let s=0;s<p.length;s++){let r=t(p[s],s);r.ok?i.push(r.value):o.push(...r.errors)}return o.length===0?{ok:!0,value:i}:{ok:!1,errors:o}}function mc(p){return be(D.BOOLEAN_LITERAL,(i,{breadcrumbsPrefix:o=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(i,`${p.toString()}`)}]})()}function hc(p){return be(D.STRING_LITERAL,(i,{breadcrumbsPrefix:o=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(i,`"${p}"`)}]})()}var gc=be(D.ANY,p=>({ok:!0,value:p}));var yc=be(D.BOOLEAN,(p,{breadcrumbsPrefix:t=[]}={})=>typeof p=="boolean"?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(p,"boolean")}]});var wc=be(D.NEVER,(p,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var bc=be(D.NUMBER,(p,{breadcrumbsPrefix:t=[]}={})=>typeof p=="number"?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(p,"number")}]});var zc=be(D.STRING,(p,{breadcrumbsPrefix:t=[]}={})=>typeof p=="string"?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(p,"string")}]});var Rc=be(D.UNKNOWN,p=>({ok:!0,value:p}));var Ez=Object.prototype.hasOwnProperty;function fc(p,t){let i={parse:(o,s)=>Ot({value:o,isKeyNumeric:p.getType()===D.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>t.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(o,s)=>Ot({value:o,isKeyNumeric:p.getType()===D.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>t.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>D.RECORD};return{...ye(i),...Y(i)}}function _c(p,t){let i={parse:(o,s)=>Ot({value:o,isKeyNumeric:p.getType()===D.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>t.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(o,s)=>Ot({value:o,isKeyNumeric:p.getType()===D.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,a)=>t.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${a}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>D.RECORD};return{...ye(i),...Y(i)}}function Ot({value:p,isKeyNumeric:t,transformKey:i,transformValue:o,breadcrumbsPrefix:s=[]}){if(!br(p))return{ok:!1,errors:[{path:s,message:J(p,"object")}]};let r={},a=[];for(let u in p){if(!Ez.call(p,u))continue;let g=p[u];if(g===void 0)continue;let h=u;if(t){let w=u.length>0?Number(u):NaN;Number.isNaN(w)||(h=w)}let c=i(h),y=o(g,h);c.ok&&y.ok?r[c.value]=y.value:(c.ok||a.push(...c.errors),y.ok||a.push(...y.errors))}return a.length===0?{ok:!0,value:r}:{ok:!1,errors:a}}function Sc(p){let t=Tt(p),i={parse:(o,s)=>{let r=t.parse(o,s);return r.ok?{ok:!0,value:new Set(r.value)}:r},json:(o,s)=>o instanceof Set?t.json([...o],s):{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:J(o,"Set")}]},getType:()=>D.SET};return{...ye(i),...Y(i)}}function xc(p){let t={parse:(i,o)=>Pc((s,r)=>s.parse(i,r),p,o),json:(i,o)=>Pc((s,r)=>s.json(i,r),p,o),getType:()=>D.UNDISCRIMINATED_UNION};return{...ye(t),...Y(t)}}function Pc(p,t,i){let o=[];for(let[s,r]of t.entries()){let a=p(r,{...i,skipValidation:!1});if(a.ok)return a;for(let u of a.errors)o.push({path:u.path,message:`[Variant ${s}] ${u.message}`})}return{ok:!1,errors:o}}function Ec(p,t){return{parsedDiscriminant:p,rawDiscriminant:t}}var Cz=Object.prototype.hasOwnProperty;function Uc(p,t){let i=typeof p=="string"?p:p.rawDiscriminant,o=typeof p=="string"?p:p.parsedDiscriminant,s=at(st(t)),r={parse:(a,u)=>Cc({value:a,discriminant:i,transformedDiscriminant:o,transformDiscriminantValue:g=>s.parse(g,{allowUnrecognizedEnumValues:u?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...u?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:g=>t[g],allowUnrecognizedUnionMembers:u?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(g,h)=>h.parse(g,u),breadcrumbsPrefix:u?.breadcrumbsPrefix}),json:(a,u)=>Cc({value:a,discriminant:o,transformedDiscriminant:i,transformDiscriminantValue:g=>s.json(g,{allowUnrecognizedEnumValues:u?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...u?.breadcrumbsPrefix??[],o]}),getAdditionalPropertiesSchema:g=>t[g],allowUnrecognizedUnionMembers:u?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(g,h)=>h.json(g,u),breadcrumbsPrefix:u?.breadcrumbsPrefix}),getType:()=>D.UNION};return{...ye(r),...Y(r),...Ye(r)}}function Cc({value:p,discriminant:t,transformedDiscriminant:i,transformDiscriminantValue:o,getAdditionalPropertiesSchema:s,allowUnrecognizedUnionMembers:r=!1,transformAdditionalProperties:a,breadcrumbsPrefix:u=[]}){if(!br(p))return{ok:!1,errors:[{path:u,message:J(p,"object")}]};let g=p[t],h={};for(let U in p)Cz.call(p,U)&&U!==t&&(h[U]=p[U]);if(g==null)return{ok:!1,errors:[{path:u,message:`Missing discriminant ("${t}")`}]};let c=o(g);if(!c.ok)return{ok:!1,errors:c.errors};let y=s(c.value);if(y==null)return r?{ok:!0,value:{[i]:c.value,...h}}:{ok:!1,errors:[{path:[...u,t],message:"Unexpected discriminant value"}]};let w=a(h,y);return w.ok?{ok:!0,value:{[i]:g,...w.value}}:w}var d={};yr(d,{encodePathParam:()=>vc,join:()=>Et,queryBuilder:()=>Tc,toQueryString:()=>wr});function vc(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 Tc(){return new Ma}var Ma=class{constructor(){this.parts=new Map}add(t,i,o){if(i==null)return this;let s=wr({[t]:i},{arrayFormat:o?.style==="comma"?"comma":"repeat"});return s.length>0&&this.parts.set(t,s),this}addMany(t){if(t!=null)for(let[i,o]of Object.entries(t))this.add(i,o);return this}mergeAdditional(t){if(t!=null)for(let[i,o]of Object.entries(t)){if(o==null)continue;let s=wr({[i]:o},{arrayFormat:"repeat"});s.length>0&&this.parts.set(i,s)}return this}build(){return[...this.parts.values()].join("&")}};var Da="apiKey",Uz="X-Schematic-Api-Key",bi=class p{constructor(t){this.options=t}static canCreate(t){return t?.[Da]!=null}async getAuthRequest({endpointMetadata:t}={}){let i=await m.get(this.options[Da]);if(i==null)throw new b({message:p.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[Uz]:i}}}};(o=>{o.AUTH_SCHEME="ApiKeyAuth",o.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${Da}' when initializing the client`;function i(s){return new o(s)}o.createInstance=i})(bi||={});function f(...p){let t={};for(let[i,o]of p.filter(s=>s!=null).flatMap(s=>Object.entries(s))){let s=i.toLowerCase();o!=null?t[s]=o:s in t&&delete t[s]}return t}function vz(p){let t=f({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@schematichq/schematic-typescript-node","X-Fern-SDK-Version":"1.5.1","User-Agent":"@schematichq/schematic-typescript-node/1.5.1","X-Fern-Runtime":fe.type,"X-Fern-Runtime-Version":fe.version},p?.headers);return{...p,logging:Ct.createLogger(p?.logging),headers:t}}function K(p){let t=vz(p);if(p.auth===!1)return t.authProvider=new si,t;if(p.auth!=null){if(typeof p.auth=="function")return t.authProvider={getAuthRequest:p.auth},t;if(Pa(p.auth))return t.authProvider=p.auth,t;Object.assign(t,p.auth)}let i=Tz(t);return t.authProvider??=new bi(i),t}function Tz(p){return{...p,authProvider:new si}}var z={Default:"https://api.schematichq.com"};function C(p,t,i,o){switch(p.reason){case"non-json":throw new b({statusCode:p.statusCode,body:p.rawBody,rawResponse:t});case"body-is-null":throw new b({statusCode:p.statusCode,rawResponse:t});case"timeout":throw new ei(`Timeout exceeded when calling ${i} ${o}.`,{cause:p.cause});case"unknown":throw new b({message:p.errorMessage,rawResponse:t,cause:p.cause});default:throw new b({message:"Unknown error",rawResponse:t})}}var Ia=e.object({lookup:e.record(e.string(),e.string())});var Oc=e.stringLiteral("company");var kc=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",Oc),token:e.string(),updatedAt:e.property("updated_at",e.date())});var Bc=e.object({data:kc,params:e.record(e.string(),e.unknown())});var Fa=e.object({description:e.string().optional(),environmentId:e.property("environment_id",e.string().optional()),name:e.string(),readonly:e.boolean().optional()});var Ur=e.enum_(["development","production","staging"]);var Ka=e.object({environmentType:e.property("environment_type",Ur),name:e.string()});var La=e.object({description:e.string().optional(),name:e.string().optional()});var Ga=e.object({environmentType:e.property("environment_type",Ur.optional()),name:e.string().optional()});var jc=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var V=e.object({count:e.number().optional()});var Ac=e.object({data:V,params:jc});var Vc=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 qc=e.object({data:V,params:Vc});var Ee=e.enum_(["api_key","app_user","stripe_app","system","temporary_access_token"]);var Mc=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 Dc=e.object({data:V,params:Mc});var qe=e.enum_(["active","created","pending"]);var Se=e.enum_(["clerk","metronome","orb","stripe","unknown","workos"]);var kt=e.object({id:e.string(),state:qe,type:Se});var Bt=e.enum_(["admin","capture","read","write"]);var Pe=e.object({createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",Ur),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Ic=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:kt.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(Bt),secret:e.string(),updatedAt:e.property("updated_at",e.date())});var Fc=e.object({data:Ic,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:kt.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(Bt),updatedAt:e.property("updated_at",e.date())});var Kc=e.object({apiKeys:e.property("api_keys",e.list(xe)),createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",Ur),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Lc=e.object({data:Kc,params:e.record(e.string(),e.unknown())});var L=e.object({deleted:e.boolean().optional()});var Gc=e.object({data:L,params:e.record(e.string(),e.unknown())});var Wc=e.object({data:L,params:e.record(e.string(),e.unknown())});var Nc=e.enum_(["billing_credits_edit","companies_edit","company_users_edit","components_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 Hc=e.enum_(["admin","member"]);var vr=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(Nc)),role:Hc.optional(),updatedAt:e.property("updated_at",e.date())});var $c=e.object({data:vr,params:e.record(e.string(),e.unknown())});var Jc=e.object({data:xe,params:e.record(e.string(),e.unknown())});var Yc=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 Zc=e.object({data:Yc,params:e.record(e.string(),e.unknown())});var Xc=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var Qc=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 el=e.object({data:Qc,params:e.record(e.string(),e.unknown())});var rl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var il=e.object({data:e.list(vr),params:rl});var tl=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 ol=e.object({data:e.list(xe),params:tl});var al=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 jt=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 nl=e.object({data:e.list(jt),params:al});var sl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var cl=e.object({data:e.list(Pe),params:sl});var ll=e.object({ok:e.boolean()});var pl=e.object({data:ll,params:e.record(e.string(),e.unknown())});var ul=e.object({data:xe,params:e.record(e.string(),e.unknown())});var dl=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var k=e.enum_(["metronome","orb","schematic","stripe"]);var Wa=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 tr=e.enum_(["per_unit","tiered"]);var se=e.enum_(["licensed","metered"]);var me=e.enum_(["graduated","volume"]);var ml=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 Na=e.object({billingScheme:e.property("billing_scheme",tr),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(ml)),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k.optional()),tiersMode:e.property("tiers_mode",me.optional()),usageType:e.property("usage_type",se)});var Ha=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 hl=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",se)});var gl=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 Tr=e.enum_(["cancel","subscribe"]);var $a=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()),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(gl),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(hl)),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",Tr.optional())});var Ja=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 At=e.enum_(["draft","open","paid","uncollectible","void"]);var Ya=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()),externalId:e.property("external_id",e.string().optional()),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),status:At.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),url:e.string().optional()});var Za=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 Xa=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 yl=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",se.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 wl=e.object({data:V,params:yl});var bl=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 zl=e.object({data:V,params:bl});var Rl=e.object({data:L,params:e.record(e.string(),e.unknown())});var fl=e.object({data:L,params:e.record(e.string(),e.unknown())});var _l=e.object({data:L,params:e.record(e.string(),e.unknown())});var Sl=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(),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",me.optional()),usageType:e.property("usage_type",se.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var zi=e.enum_(["day","month","one-time","year"]);var Vt=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",tr),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:zi,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(Vt)),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",me.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",se)});var Pl=e.object({data:e.list(H),params:Sl});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(),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",me.optional()),usageType:e.property("usage_type",se.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var El=e.object({data:e.list(H),params:xl});var Cl=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",se.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 G=e.object({currency:e.string(),externalPriceId:e.property("external_price_id",e.string()),id:e.string(),interval:zi,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:tr});var or=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(G),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 Ul=e.object({data:e.list(or),params:Cl});var vl=e.object({isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var qt=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 Tl=e.object({data:e.list(qt),params:vl});var Ol=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 kl=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 Bl=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(kl),updatedAt:e.property("updated_at",e.date())});var jl=e.object({data:e.list(Bl),params:Ol});var Al=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 Ze=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()),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),status:At.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 Vl=e.object({data:e.list(Ze),params:Al});var ql=e.object({displayName:e.property("display_name",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var Mt=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 Ml=e.object({data:e.list(Mt),params:ql});var Dl=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 Xe=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 Il=e.object({data:e.list(Xe),params:Dl});var Fl=e.object({data:qt,params:e.record(e.string(),e.unknown())});var Kl=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 Ll=e.object({data:Kl,params:e.record(e.string(),e.unknown())});var Gl=e.object({data:Mt,params:e.record(e.string(),e.unknown())});var Wl=e.object({data:G,params:e.record(e.string(),e.unknown())});var Or=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 Nl=e.object({data:Or,params:e.record(e.string(),e.unknown())});var Hl=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",Tr.optional())});var $l=e.object({data:Hl,params:e.record(e.string(),e.unknown())});var Jl=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var Yl=e.object({data:Xe,params:e.record(e.string(),e.unknown())});var Qa=e.object({cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),prorate:e.boolean().optional()});var en=e.object({companyId:e.property("company_id",e.string()),selectedPlanId:e.property("selected_plan_id",e.string().optional())});var rn=e.object({trialEnd:e.property("trial_end",e.date().optional())});var Dt=e.object({billingScheme:e.property("billing_scheme",tr),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(Vt)),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",se)});var It=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 ct=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(It),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),latestInvoice:e.property("latest_invoice",Ze.optional()),metadata:e.record(e.string(),e.unknown()).optional(),paymentMethod:e.property("payment_method",Xe.optional()),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),products:e.list(Dt),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",Tr.optional())});var N=e.enum_(["all_time","current_day","current_month","current_week"]);var $=e.enum_(["billing_cycle","first_of_month"]);var Zl=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",$),period:N,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var Z=e.enum_(["duration","end_of_billing_period","end_of_next_billing_period","end_of_trial","no_expiry"]);var W=e.enum_(["billing_periods","days"]);var kr=e.enum_(["expiration_priority","first_in_first_out","last_in_first_out","plan_first_then_credit_bundles_first_in_first_out"]);var Xl=e.enum_(["schematic_authoritative","external_mirror","external_rated"]);var Br=e.enum_(["expire","none","rollover"]);var Ql=e.object({currency:e.string(),price:H.optional()});var Ft=e.object({accountId:e.property("account_id",e.string()),burnStrategy:e.property("burn_strategy",kr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Ql)),defaultExpiryUnit:e.property("default_expiry_unit",W),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Br),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:e.string().optional(),id:e.string(),ledgerAuthority:e.property("ledger_authority",Xl),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:Or.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Te=e.enum_(["daily","monthly","weekly","yearly"]);var Me=e.enum_(["billing_period","first_of_month"]);var ar=e.enum_(["no_reset","plan_period"]);var Ri=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var ep=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()),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",W.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()),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:Ft.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",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Ri.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",Te.optional()),resetStart:e.property("reset_start",Me.optional()),resetType:e.property("reset_type",ar),rolloverPercentage:e.property("rollover_percentage",e.number()),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var tn=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(ep)),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 fi=e.enum_(["on_payment","on_publish"]);var Rr=e.enum_(["active","expired","paid","pending"]);var jr=e.object({activationStrategy:e.property("activation_strategy",fi),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:Rr,stripeInvoiceUrl:e.property("stripe_invoice_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var te=e.enum_(["company","user"]);var Kt=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 Lt=e.object({createdAt:e.property("created_at",e.date()),definition:Kt.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 he=e.enum_(["boolean","currency","date","number","string","url"]);var ge=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",he),updatedAt:e.property("updated_at",e.date())});var Gt=e.object({createdAt:e.property("created_at",e.date()),definition:ge.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 re=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var Wt=e.object({allocation: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()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",N.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",re)});var Ar=e.enum_(["eq","gt","gte","is_empty","lt","lte","not_empty","ne"]);var _i=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var rp=e.enum_(["bool","date","int","string"]);var on=e.object({comparableType:e.property("comparable_type",rp),entityType:e.property("entity_type",te),id:e.string()});var Nt=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",on.optional()),conditionType:e.property("condition_type",_i),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",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ar,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",on.optional()),traitValue:e.property("trait_value",e.string())});var ip=e.object({conditions:e.list(Nt)});var Vr=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var tp=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(ip)),conditions:e.list(Nt),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",Vr),value:e.boolean()});var Ht=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 ee=e.object({addOns:e.property("add_ons",e.list(tn)),billingCreditBalances:e.property("billing_credit_balances",e.record(e.string(),e.number()).optional()),billingSubscription:e.property("billing_subscription",ct.optional()),billingSubscriptions:e.property("billing_subscriptions",e.list(ct)),createdAt:e.property("created_at",e.date()),customPlanBillings:e.property("custom_plan_billings",e.list(jr)),defaultPaymentMethod:e.property("default_payment_method",Xe.optional()),entitlements:e.list(Wt),entityTraits:e.property("entity_traits",e.list(Gt)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Lt),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),metrics:e.list(Zl),name:e.string(),paymentMethods:e.property("payment_methods",e.list(Xe)),plan:tn.optional(),plans:e.list(Ri),rules:e.list(tp),scheduledDowngrade:e.property("scheduled_downgrade",Ht.optional()),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date()),userCount:e.property("user_count",e.number())});var $t=e.object({company:ee.optional(),success:e.boolean()});var op=e.object({data:$t,params:e.record(e.string(),e.unknown())});var ap=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",Tr.optional())});var np=e.object({data:ap,params:e.record(e.string(),e.unknown())});var Ce=e.enum_(["active","inactive"]);var Ae=e.stringLiteral("fixed");var sp=e.object({currency:e.string(),price:G.optional()});var De=e.object({billingInvoiceId:e.property("billing_invoice_id",e.string().optional()),bundleType:e.property("bundle_type",Ae),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(sp)),expiryType:e.property("expiry_type",Z),expiryUnit:e.property("expiry_unit",W),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:G.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Ce,unitPrice:e.property("unit_price",G.optional()),updatedAt:e.property("updated_at",e.date())});var Jt=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 Si=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(It),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),latestInvoice:e.property("latest_invoice",Ze.optional()),paymentMethod:e.property("payment_method",Xe.optional()),products:e.list(Dt),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 cp=e.object({bundle:De.optional(),quantity:e.number(),total:e.number()});var Oe=e.enum_(["adjustment","billing_credit_auto_topup","free","plan","purchased","rollover"]);var lp=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 Ie=e.enum_(["add_on","alpha","beta","deprecated","ga","inactive","in_plan","internal_testing","legacy"]);var ce=e.enum_(["boolean","event","trait"]);var qr=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",ce),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Ie.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 Fe=e.object({company:ee.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:qr.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),metricPeriod:e.property("metric_period",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),notes:e.list(lp),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",ge.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re)});var Pi=e.object({creditTypeIcon:e.property("credit_type_icon",e.string().optional()),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",Oe),quantity:e.number()});var xi=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 ze=e.enum_(["credit_burndown","overage","pay_as_you_go","pay_in_advance","tier"]);var Mr=e.enum_(["company_override","plan_entitlement","unknown"]);var ke=e.object({billingProvider:e.property("billing_provider",k),externalResourceId:e.property("external_resource_id",e.string()),originator:k});var Ei=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 nr=e.stringLiteral("boolean");var Yt=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Zt=e.object({comparisonTrait:e.property("comparison_trait",ge.optional()),comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionGroupId:e.property("condition_group_id",e.string().optional()),conditionType:e.property("condition_type",_i),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",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ar,resourceIds:e.property("resource_ids",e.list(e.string())),resources:e.list(Yt),ruleId:e.property("rule_id",e.string()),trait:ge.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 pp=e.object({conditions:e.list(Zt),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 Ci=e.object({conditionGroups:e.property("condition_groups",e.list(pp)),conditions:e.list(Zt),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",Vr),updatedAt:e.property("updated_at",e.date()),value:e.boolean()});var up=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:qr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",nr),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(Ci),updatedAt:e.property("updated_at",e.date())});var Dr=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Ke=e.object({billingLinkedResource:e.property("billing_linked_resource",ke.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Ei.optional()),featureType:e.property("feature_type",ce),flags:e.list(up),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Ie.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Dr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:ge.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var dp=e.object({currency:e.string(),price:G.optional()});var Le=e.object({burnStrategy:e.property("burn_strategy",kr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(dp)),defaultExpiryUnit:e.property("default_expiry_unit",W),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Br),description:e.string(),icon:e.string().optional(),id:e.string(),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:G.optional(),product:Or.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var mp=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 le=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 oe=e.enum_(["plan","add_on"]);var sr=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:le,id:e.string(),name:e.string(),planType:e.property("plan_type",oe),updatedAt:e.property("updated_at",e.date())});var ie=e.object({billingLinkedResource:e.property("billing_linked_resource",ke.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(mp)),environmentId:e.property("environment_id",e.string()),feature:qr.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",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),plan:sr.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",Or.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCredit:e.property("value_credit",Le.optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",ge.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re)});var Ir=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",re),companyOverride:e.property("company_override",Fe.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(Pi).optional()),creditGrantReason:e.property("credit_grant_reason",Oe.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",xi.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",Mr),feature:Ke.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",$.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:N.optional(),plan:sr.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 Ui=e.object({features:e.list(Ir)});var Be=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",e.string().optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Z.optional()),autoTopupExpiryUnit:e.property("auto_topup_expiry_unit",W.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()),createdAt:e.property("created_at",e.date()),credit:Le.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",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Yt.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",Te.optional()),resetStart:e.property("reset_start",Me.optional()),resetType:e.property("reset_type",ar.optional()),rolloverPercentage:e.property("rollover_percentage",e.number()),updatedAt:e.property("updated_at",e.date())});var Ge=e.enum_(["schematic_managed","provider_managed","no_billing"]);var We=e.enum_(["free","none","one_time","recurring"]);var Fr=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",G.optional()),oneTimePrice:e.property("one_time_price",G.optional()),quarterlyPrice:e.property("quarterly_price",G.optional()),yearlyPrice:e.property("yearly_price",G.optional())});var hp=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:le,id:e.string(),name:e.string(),originalPlanId:e.property("original_plan_id",e.string().optional()),planType:e.property("plan_type",oe),status:hp,updatedAt:e.property("updated_at",e.date()),version:e.number()});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",ke.optional()),billingProduct:e.property("billing_product",or.optional()),billingStrategy:e.property("billing_strategy",Ge),chargeType:e.property("charge_type",We),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",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()),currencyPrices:e.property("currency_prices",e.list(Fr)),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ie).optional(),features:e.list(Ke),icon:le,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(Be).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",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",oe),quarterlyPrice:e.property("quarterly_price",G.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",G.optional())});var lt=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",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.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 gp=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(lt)),availableCreditBundles:e.property("available_credit_bundles",e.list(De)),company:ee.optional(),customCheckoutFields:e.property("custom_checkout_fields",e.list(Jt)),featureUsage:e.property("feature_usage",Ui.optional()),selectedCreditBundles:e.property("selected_credit_bundles",e.list(cp)),selectedPlan:e.property("selected_plan",we.optional()),selectedUsageBasedEntitlements:e.property("selected_usage_based_entitlements",e.list(lt)),subscription:Si.optional()});var yp=e.object({data:gp,params:e.record(e.string(),e.unknown())});var wp=e.object({data:$t,params:e.record(e.string(),e.unknown())});var bp=e.object({amount:e.number(),description:e.string(),priceId:e.property("price_id",e.string()),proration:e.boolean(),quantity:e.number()});var zp=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),newCharges:e.property("new_charges",e.number()),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(),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(bp))});var Xt=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),finance:zp.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(Ir))});var Rp=e.object({data:Xt,params:e.record(e.string(),e.unknown())});var fp=e.object({subscriptionChangePreview:e.property("subscription_change_preview",Xt.optional())});var _p=e.object({data:fp,params:e.record(e.string(),e.unknown())});var Sp=e.object({data:ct,params:e.record(e.string(),e.unknown())});var an=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",he)});var nn=e.object({companyId:e.property("company_id",e.string()),userId:e.property("user_id",e.string())});var sn=e.object({displayName:e.property("display_name",e.string().optional()),traitType:e.property("trait_type",he)});var vi=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(vi)});var je=e.enum_(["asc","desc"]);var fr=e.enum_(["active","canceled","expired","incomplete","incomplete_expired","past_due","paused","trialing","unpaid"]);var _r=e.enum_(["free","one_time","paid","trial"]);var Pp=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(fr).optional()),subscriptionTypes:e.property("subscription_types",e.list(_r).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 xp=e.object({data:V,params:Pp});var Ep=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 Cp=e.object({data:V,params:Ep});var Up=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",he.optional()),traitTypes:e.property("trait_types",e.list(he).optional())});var vp=e.object({data:V,params:Up});var Tp=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 Op=e.object({data:V,params:Tp});var kp=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 Bp=e.object({data:V,params:kp});var jp=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Ti=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 Oi=e.object({company:Ti.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(Oi)),createdAt:e.property("created_at",e.date()),entityTraits:e.property("entity_traits",e.list(Gt)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Lt),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 Ap=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Vp=e.object({data:Ti,params:e.record(e.string(),e.unknown())});var qp=e.object({data:L,params:e.record(e.string(),e.unknown())});var Mp=e.object({cancelSubscription:e.property("cancel_subscription",e.boolean().optional()),prorate:e.boolean().optional()});var Dp=e.object({data:L,params:Mp});var Qt=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 Ip=e.object({data:Qt,params:e.record(e.string(),e.unknown())});var Fp=e.object({data:L,params:e.record(e.string(),e.unknown())});var Kp=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 Lp=e.object({data:e.list(Si),params:Kp});var Gp=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Wp=e.object({data:ge,params:e.record(e.string(),e.unknown())});var Np=e.object({definitionId:e.property("definition_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Hp=e.object({definitionId:e.property("definition_id",e.string()),value:e.string()});var $p=e.object({data:e.list(Hp),params:Np});var Jp=e.object({data:Oi,params:e.record(e.string(),e.unknown())});var Yp=e.object({data:ge,params:e.record(e.string(),e.unknown())});var ki=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 Bi=e.enum_(["fallback","initial","trait","trial_expiry"]);var Zp=e.enum_(["adjustment","downgrade","invalid","subscribe","unsubscribe","upgrade","upgrade_trial"]);var pt=e.object({deleted:e.boolean(),description:e.string(),icon:e.string(),id:e.string(),name:e.string()});var ln=e.object({id:e.string(),name:e.string(),version:e.number()});var Xp=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",he),value:e.string()});var eo=e.object({action:ki,actorType:e.property("actor_type",Ee),addOnsAdded:e.property("add_ons_added",e.list(pt)),addOnsRemoved:e.property("add_ons_removed",e.list(pt)),apiKey:e.property("api_key",xe.optional()),auditLog:e.property("audit_log",jt.optional()),basePlan:e.property("base_plan",pt.optional()),basePlanAction:e.property("base_plan_action",Bi.optional()),basePlanVersion:e.property("base_plan_version",ln.optional()),company:Ti.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(),isVersionUpgrade:e.property("is_version_upgrade",e.boolean()),previousBasePlan:e.property("previous_base_plan",pt.optional()),previousBasePlanVersion:e.property("previous_base_plan_version",ln.optional()),requestId:e.property("request_id",e.string().optional()),subscriptionChangeAction:e.property("subscription_change_action",Zp.optional()),traitsUpdated:e.property("traits_updated",e.list(Xp)),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var Qp=e.object({data:eo,params:e.record(e.string(),e.unknown())});var Kr=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 eu=e.object({data:Kr,params:e.record(e.string(),e.unknown())});var ru=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var iu=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(fr).optional()),subscriptionTypes:e.property("subscription_types",e.list(_r).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 tu=e.object({data:e.list(ee),params:iu});var ou=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 au=e.object({data:e.list(Oi),params:ou});var nu=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 su=e.object({data:e.list(Kt),params:nu});var cu=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",he.optional()),traitTypes:e.property("trait_types",e.list(he).optional())});var lu=e.object({data:e.list(ge),params:cu});var pu=e.object({action:ki.optional(),basePlanAction:e.property("base_plan_action",Bi.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 uu=e.object({data:e.list(eo),params:pu});var du=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 mu=e.object({data:e.list(Kr),params:du});var hu=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 gu=e.object({data:e.list(Ne),params:hu});var yu=e.object({keys:e.record(e.string(),e.string()).optional()});var wu=e.object({data:ee,params:yu});var bu=e.object({keys:e.record(e.string(),e.string()).optional()});var zu=e.object({data:Ne,params:bu});var Ru=e.object({data:ge,params:e.record(e.string(),e.unknown())});var fu=e.object({data:e.list(Kr),params:e.record(e.string(),e.unknown())});var _u=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Su=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Pu=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var xu=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var ji=e.enum_(["billing","entitlement"]);var pn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",ji),name:e.string()});var ro=e.enum_(["draft","live"]);var un=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",ji.optional()),name:e.string().optional(),state:ro.optional()});var Eu=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Cu=e.object({data:V,params:Eu});var cr=e.object({ast:e.record(e.string(),e.number()).optional(),createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),state:ro,type:ji,updatedAt:e.property("updated_at",e.date())});var Uu=e.object({data:cr,params:e.record(e.string(),e.unknown())});var vu=e.object({data:L,params:e.record(e.string(),e.unknown())});var Tu=e.object({data:cr,params:e.record(e.string(),e.unknown())});var Ou=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var ku=e.object({data:e.list(cr),params:Ou});var Bu=e.object({companyId:e.property("company_id",e.string().optional()),componentId:e.property("component_id",e.string().optional())});var ut=e.object({billingScheme:e.property("billing_scheme",tr),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:zi,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",me.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",se)});var ju=e.object({currency:e.string(),price:H.optional()});var Au=e.object({bundleType:e.property("bundle_type",Ae),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(ju)),expiryType:e.property("expiry_type",Z),expiryUnit:e.property("expiry_unit",W),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:ut.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Ce,unitPrice:e.property("unit_price",ut.optional()),updatedAt:e.property("updated_at",e.date())});var Vu=e.enum_(["downgrade_not_permitted","feature_usage_exceeded"]);var Lr=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 io=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()),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",W.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()),createdAt:e.property("created_at",e.date()),credit:Ft.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",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Ri.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",Te.optional()),resetStart:e.property("reset_start",Me.optional()),resetType:e.property("reset_type",ar),rolloverPercentage:e.property("rollover_percentage",e.number()),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Ai=e.enum_(["monthly","quarterly","yearly"]);var dn=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ai)),billingLinkedResource:e.property("billing_linked_resource",ke.optional()),billingProduct:e.property("billing_product",or.optional()),billingStrategy:e.property("billing_strategy",Ge),chargeType:e.property("charge_type",We),companyCanTrial:e.property("company_can_trial",e.boolean()),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",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()),currencyPrices:e.property("currency_prices",e.list(Fr)),current:e.boolean(),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Lr.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ie).optional(),features:e.list(Ke),icon:le,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(io)),invalidReason:e.property("invalid_reason",Vu.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",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",oe),quarterlyPrice:e.property("quarterly_price",G.optional()),trialDays:e.property("trial_days",e.number().optional()),updatedAt:e.property("updated_at",e.date()),usageViolations:e.property("usage_violations",e.list(Ir)),valid:e.boolean(),versions:e.list(Re),yearlyPrice:e.property("yearly_price",G.optional())});var Gr=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var to=e.object({badgeVisibility:e.property("badge_visibility",e.boolean()),checkout:e.boolean()});var qu=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 oo=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 Wr=e.enum_(["expired","manual","plan_change","plan_period_reset","reconciled"]);var Mu=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 Du=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",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),grantReason:e.property("grant_reason",Oe),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:ut.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",Te.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(Mu).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",Wr.optional())});var Iu=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 Fu=e.object({activeAddOns:e.property("active_add_ons",e.list(dn)),activePlans:e.property("active_plans",e.list(dn)),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(lt)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr)),capabilities:to.optional(),checkoutSettings:e.property("checkout_settings",qu),company:ee.optional(),component:cr.optional(),creditBundles:e.property("credit_bundles",e.list(Au)),creditGrants:e.property("credit_grants",e.list(Du)),customCheckoutFields:e.property("custom_checkout_fields",e.list(Jt)),defaultPlan:e.property("default_plan",we.optional()),displaySettings:e.property("display_settings",oo),featureUsage:e.property("feature_usage",Ui.optional()),invoices:e.list(Ze),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",Ht.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",Iu.optional()),subscription:Si.optional(),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional()),upcomingInvoice:e.property("upcoming_invoice",Ze.optional())});var Ku=e.object({data:Fu,params:Bu});var Lu=e.object({data:cr,params:e.record(e.string(),e.unknown())});var mn=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ai)),billingLinkedResource:e.property("billing_linked_resource",ke.optional()),billingProduct:e.property("billing_product",or.optional()),billingStrategy:e.property("billing_strategy",Ge),chargeType:e.property("charge_type",We),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",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()),currencyPrices:e.property("currency_prices",e.list(Fr)),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Lr.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ie).optional(),features:e.list(Ke),icon:le,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(io)),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",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",oe),quarterlyPrice:e.property("quarterly_price",G.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",G.optional())});var Gu=e.object({activeAddOns:e.property("active_add_ons",e.list(mn)),activePlans:e.property("active_plans",e.list(mn)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr)),capabilities:to.optional(),displaySettings:e.property("display_settings",oo),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 Wu=e.object({data:Gu,params:e.record(e.string(),e.unknown())});var hn=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 ao=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 gn=e.object({burnStrategy:e.property("burn_strategy",kr.optional()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(ao).optional()),defaultExpiryUnit:e.property("default_expiry_unit",W.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Br.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 yn=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",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),quantity:e.number(),reason:Oe,renewalEnabled:e.property("renewal_enabled",e.boolean().optional()),renewalPeriod:e.property("renewal_period",Me.optional())});var no=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 wn=e.object({bundleName:e.property("bundle_name",e.string()),bundleType:e.property("bundle_type",Ae.optional()),creditId:e.property("credit_id",e.string()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(no).optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",W.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 bn=e.object({additionalAmount:e.property("additional_amount",e.number()),expiresAt:e.property("expires_at",e.date().optional())});var zn=e.object({burnStrategy:e.property("burn_strategy",kr.optional()),currencyPrices:e.property("currency_prices",e.list(ao).optional()),defaultExpiryUnit:e.property("default_expiry_unit",W.optional()),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Br.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 Rn=e.object({bundleName:e.property("bundle_name",e.string()),currencyPrices:e.property("currency_prices",e.list(no).optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",W.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 fn=e.object({reason:Wr.optional()});var Vi=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 Nu=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var Hu=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 $u=e.object({data:V,params:Hu});var Ju=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Yu=e.object({data:V,params:Ju});var Zu=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 Xu=e.object({data:V,params:Zu});var oi=e.enum_(["created_at","expires_at","quantity","quantity_remaining"]);var Qu=e.object({companyId:e.property("company_id",e.string().optional()),dir:je.optional(),limit:e.number().optional(),offset:e.number().optional(),order:oi.optional()});var ed=e.object({data:V,params:Qu});var rd=e.object({bundleType:e.property("bundle_type",Ae.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 id=e.object({data:V,params:rd});var Sr=e.enum_(["grant","transfer","usage","zero_out"]);var td=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",Sr.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 od=e.object({data:V,params:td});var ad=e.object({data:Le,params:e.record(e.string(),e.unknown())});var nd=e.object({data:Be,params:e.record(e.string(),e.unknown())});var sd=e.object({data:De,params:e.record(e.string(),e.unknown())});var cd=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var ld=e.object({data:L,params:cd});var pd=e.object({data:L,params:e.record(e.string(),e.unknown())});var ud=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var dd=e.object({data:De,params:e.record(e.string(),e.unknown())});var md=e.object({data:Le,params:e.record(e.string(),e.unknown())});var hd=e.object({data:Be,params:e.record(e.string(),e.unknown())});var gd=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 Nr=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",Oe),id:e.string(),planId:e.property("plan_id",e.string().optional()),planName:e.property("plan_name",e.string().optional()),price:G.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",Te.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(gd).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",Wr.optional())});var yd=e.object({data:Nr,params:e.record(e.string(),e.unknown())});var wd=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var bd=e.object({data:e.list(Le),params:wd});var zd=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 Rd=e.object({data:e.list(Be),params:zd});var fd=e.object({companyId:e.property("company_id",e.string().optional())});var _d=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 Sd=e.object({data:e.list(_d),params:fd});var Pd=e.object({companyId:e.property("company_id",e.string().optional()),dir:je.optional(),limit:e.number().optional(),offset:e.number().optional(),order:oi.optional()});var xd=e.object({data:e.list(Nr),params:Pd});var Ed=e.object({bundleType:e.property("bundle_type",Ae.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 Cd=e.object({data:e.list(De),params:Ed});var Ud=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",Sr.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 vd=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 Td=e.object({id:e.string(),logoUrl:e.property("logo_url",e.string().optional()),name:e.string()});var Od=e.enum_(["lease_hold","lease_release","manual_adjustment","reconciliation","track"]);var kd=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string()});var Bd=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:Td.optional(),companyId:e.property("company_id",e.string()),credit:vd.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",Sr),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),feature:kd.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",Oe.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",Od.optional()),zeroedOutReason:e.property("zeroed_out_reason",Wr.optional())});var jd=e.object({data:e.list(Bd),params:Ud});var Ad=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 Vd=e.object({data:e.list(Nr),params:Ad});var qd=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var Md=e.object({data:L,params:e.record(e.string(),e.unknown())});var Dd=e.object({data:Le,params:e.record(e.string(),e.unknown())});var Id=e.object({data:Be,params:e.record(e.string(),e.unknown())});var Fd=e.object({data:De,params:e.record(e.string(),e.unknown())});var Kd=e.object({data:Nr,params:e.record(e.string(),e.unknown())});var _n=e.object({metadata:e.string()});var Ld=e.stringLiteral("csv");var Gd=e.enum_(["failure","pending","success"]);var Wd=e.stringLiteral("company-feature-usage");var Nd=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",Wd),id:e.string(),metadata:e.string(),outputFileType:e.property("output_file_type",Ld),status:Gd,updatedAt:e.property("updated_at",e.date())});var Hd=e.object({data:Nd,params:e.record(e.string(),e.unknown())});var ne=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 Hr=e.object({currency:e.string(),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ne).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(ne).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(ne).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Sn=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(Hr).optional()),externalResourceId:e.property("external_resource_id",e.string()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ne).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(ne).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ne).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",me.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),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ne).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Pn=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",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.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 xn=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(Hr).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ne).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(ne).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ne).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",me.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),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ne).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var En=e.object({sourcePlanId:e.property("source_plan_id",e.string()),targetPlanId:e.property("target_plan_id",e.string())});var Cn=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),metricPeriod:e.property("metric_period",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.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 Un=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(Hr).optional()),metricPeriod:e.property("metric_period",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ne).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(ne).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ne).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",me.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),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ne).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var $d=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 Jd=e.object({data:V,params:$d});var Yd=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Zd=e.object({data:V,params:Yd});var Xd=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 Qd=e.object({data:V,params:Xd});var em=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var rm=e.object({data:V,params:em});var im=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 tm=e.object({data:V,params:im});var om=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var am=e.object({data:ie,params:e.record(e.string(),e.unknown())});var nm=e.object({data:L,params:e.record(e.string(),e.unknown())});var sm=e.object({data:L,params:e.record(e.string(),e.unknown())});var so=e.object({code:e.string(),description:e.string(),detail:e.string().optional(),id:e.string().optional()});var cm=e.object({message:e.string()});var lm=e.object({entitlementId:e.property("entitlement_id",e.string()),errors:e.list(cm),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string())});var pm=e.object({data:e.list(ie),issues:e.list(so),skipped:e.list(lm)});var um=e.object({data:pm,params:e.record(e.string(),e.unknown())});var dm=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var mm=e.object({keys:e.record(e.string(),e.string()).optional()});var hm=e.object({data:Ui,params:mm});var Qe=e.enum_(["daily","hourly","monthly","weekly"]);var gm=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 ym=e.object({effectiveAt:e.property("effective_at",e.date()),isSoftLimit:e.property("is_soft_limit",e.boolean()),limitSource:e.property("limit_source",Mr),limitValue:e.property("limit_value",e.number().optional()),planId:e.property("plan_id",e.string().optional()),priceBehavior:e.property("price_behavior",ze.optional())});var wm=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 bm=e.object({featureId:e.property("feature_id",e.string()),featureType:e.property("feature_type",ce),limits:e.list(ym),periodType:e.property("period_type",e.string().optional()),usagePoints:e.property("usage_points",e.list(wm))});var zm=e.object({data:bm,params:gm});var Rm=e.object({data:ie,params:e.record(e.string(),e.unknown())});var fm=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:e.list(Fe),params:fm});var Sm=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Pm=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(Pi).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",xi.optional())});var xm=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",re),company:ee.optional(),companyOverride:e.property("company_override",Fe.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(Pi).optional()),creditGrantReason:e.property("credit_grant_reason",Oe.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",Pm.optional()),creditUsageAggregation:e.property("credit_usage_aggregation",xi.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",Mr),feature:Ke.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",$.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:N.optional(),plan:sr.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 Em=e.object({data:e.list(xm),params:Sm});var Cm=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 Um=e.object({data:e.list(Ir),params:Cm});var vm=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var lr=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:qr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",nr),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainer:vr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Ci),updatedAt:e.property("updated_at",e.date())});var He=e.object({billingLinkedResource:e.property("billing_linked_resource",ke.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Ei.optional()),featureType:e.property("feature_type",ce),flags:e.list(lr),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Ie.optional()),maintainer:vr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Dr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:ge.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Tm=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",re),company:ee.optional(),entitlementId:e.property("entitlement_id",e.string()),entitlementType:e.property("entitlement_type",Mr),feature:He.optional(),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$.optional()),period:N.optional(),plan:sr.optional(),usage:e.number().optional(),user:Qt.optional()});var Om=e.object({data:e.list(Tm),params:vm});var km=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 Bm=e.object({data:e.list(ie),params:km});var jm=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var Am=e.object({data:ie,params:e.record(e.string(),e.unknown())});var Vm=e.object({data:ie,params:e.record(e.string(),e.unknown())});var qm=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 Mm=e.object({keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Dm=e.object({company:Mm.optional(),keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Im=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 co=e.undiscriminatedUnion([Im,qm,Dm]);var Pr=e.enum_(["flag_check","identify","track"]);var lo=e.object({backfill:e.boolean().optional(),body:co.optional(),eventType:e.property("event_type",Pr),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 vn=e.object({events:e.list(lo)});var po=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 Fm=e.object({events:e.list(po)});var Km=e.object({data:Fm,params:e.record(e.string(),e.unknown())});var Lm=e.object({data:po,params:e.record(e.string(),e.unknown())});var Gm=e.enum_(["enriched","failed","pending","processed","unknown"]);var uo=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:Dr.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(Dr),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:Gm,subtype:e.string().optional(),type:Pr,updatedAt:e.property("updated_at",e.date().optional()),user:Dr.optional(),userId:e.property("user_id",e.string().optional())});var Wm=e.object({data:uo,params:e.record(e.string(),e.unknown())});var Nm=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 Hm=e.object({data:e.list(Ei),params:Nm});var $m=e.object({connected:e.boolean(),environmentId:e.property("environment_id",e.string()),lastEventAt:e.property("last_event_at",e.date().optional())});var Jm=e.object({data:$m,params:e.record(e.string(),e.unknown())});var Ym=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(Pr).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 Zm=e.object({data:e.list(uo),params:Ym});var dt=e.object({company:e.record(e.string(),e.string()).optional(),user:e.record(e.string(),e.string()).optional()});var Tn=e.object({contexts:e.list(dt)});var qi=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",nr),id:e.string().optional(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var On=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",ce),flag:qi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ie.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 kn=e.object({description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ce),flag:qi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ie.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 Bn=e.object({description:e.string().optional(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ce.optional()),flag:qi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ie.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 mo=e.object({comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionType:e.property("condition_type",_i),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",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ar,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 Xm=e.object({conditions:e.list(mo),flagId:e.property("flag_id",e.string().optional()),id:e.string().optional()});var Qm=e.object({conditionGroups:e.property("condition_groups",e.list(Xm)),conditions:e.list(mo),id:e.string().optional(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Vr.optional()),value:e.boolean()});var jn=e.object({rules:e.list(Qm)});var ho=e.object({companyId:e.property("company_id",e.string().optional()),entitlement:Wt.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",N.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",Vr.optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var eh=e.object({data:ho,params:e.record(e.string(),e.unknown())});var rh=e.enum_(["active","converted","expired"]);var ih=e.object({id:e.string(),name:e.string(),trialEndDate:e.property("trial_end_date",e.date().optional()),trialStatus:e.property("trial_status",rh.optional())});var go=e.object({flags:e.list(ho),plan:ih.optional()});var th=e.object({data:e.list(go)});var oh=e.object({data:th,params:e.record(e.string(),e.unknown())});var ah=e.object({data:go,params:e.record(e.string(),e.unknown())});var nh=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(ce).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 sh=e.object({data:V,params:nh});var ch=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 lh=e.object({data:V,params:ch});var ph=e.object({data:He,params:e.record(e.string(),e.unknown())});var uh=e.object({data:lr,params:e.record(e.string(),e.unknown())});var dh=e.object({data:L,params:e.record(e.string(),e.unknown())});var mh=e.object({data:L,params:e.record(e.string(),e.unknown())});var hh=e.object({data:He,params:e.record(e.string(),e.unknown())});var gh=e.object({data:lr,params:e.record(e.string(),e.unknown())});var yh=e.object({booleanRequireEvent:e.property("boolean_require_event",e.boolean().optional()),featureType:e.property("feature_type",e.list(ce).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 wh=e.object({data:e.list(He),params:yh});var bh=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 zh=e.object({data:e.list(lr),params:bh});var Rh=e.object({data:He,params:e.record(e.string(),e.unknown())});var fh=e.object({data:lr,params:e.record(e.string(),e.unknown())});var _h=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",nr),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 Sh=e.object({flag:_h.optional(),rules:e.list(Ci)});var Ph=e.object({data:Sh,params:e.record(e.string(),e.unknown())});var xh=e.object({data:He,params:e.record(e.string(),e.unknown())});var Eh=e.object({limit:e.number().optional()});var Ch=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 Uh=e.object({entries:e.list(Ch)});var vh=e.object({data:Uh,params:Eh});var Th=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 yo=e.object({timestamp:e.date(),usage:e.number()});var Oh=e.object({eventSubtype:e.property("event_subtype",e.string()),featureId:e.property("feature_id",e.string()),points:e.list(yo)});var kh=e.object({data:Oh,params:Th});var Bh=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 jh=e.object({featureId:e.property("feature_id",e.string()),points:e.list(yo),traitDefinitionId:e.property("trait_definition_id",e.string())});var Ah=e.object({data:jh,params:Bh});var Vh=e.object({months:e.number().optional()});var qh=e.object({month:e.date(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),subscribers:e.number()});var Mh=e.object({points:e.list(qh)});var Dh=e.object({data:Mh,params:Vh});var Ih=e.object({amount:e.number(),currency:e.string()});var Fh=e.object({activeCredits:e.property("active_credits",e.number()),mrr:e.list(Ih),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 Kh=e.object({data:Fh,params:e.record(e.string(),e.unknown())});var Lh=e.object({endTime:e.property("end_time",e.date().optional()),limit:e.number().optional(),startTime:e.property("start_time",e.date().optional())});var Gh=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 Wh=e.object({features:e.list(Gh)});var Nh=e.object({data:Wh,params:Lh});var Mi=e.enum_(["billing_meta_object","manual_upsert"]);var An=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Mi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),integrationId:e.property("integration_id",e.string())});var wo=e.object({authorPlans:e.property("author_plans",e.boolean()),checkout:e.boolean(),editBilling:e.property("edit_billing",e.boolean())});var Hh=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var $h=e.object({});var Jh=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var Yh=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 Zh=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var bo=e.union("type",{clerk:Hh,metronome:$h,orb:Jh,stripe:Yh,workos:Zh}).transform({transform:p=>p,untransform:p=>p});var Xh=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Mi.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:bo.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 Qh=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:qe,type:Se,updatedAt:e.property("updated_at",e.date())});var Di=e.object({capabilities:wo,config:Xh,integration:Qh});var eg=e.object({data:Di,params:e.record(e.string(),e.unknown())});var rg=e.object({type:Se,url:e.string()});var ig=e.object({data:rg,params:e.record(e.string(),e.unknown())});var tg=e.object({data:Di,params:e.record(e.string(),e.unknown())});var og=e.object({data:Di,params:e.record(e.string(),e.unknown())});var ag=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:qe.optional(),type:Se.optional()});var ng=e.object({capabilities:wo,config:bo.optional(),id:e.string(),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),state:qe,type:Se});var sg=e.object({data:e.list(ng),params:ag});var cg=e.object({keys:e.list(e.string())});var lg=e.object({data:cg,params:e.record(e.string(),e.unknown())});var zo=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:qe,type:Se,updatedAt:e.property("updated_at",e.date())});var pg=e.object({data:zo,params:e.record(e.string(),e.unknown())});var ug=e.object({data:zo,params:e.record(e.string(),e.unknown())});var dg=e.object({data:L,params:e.record(e.string(),e.unknown())});var mg=e.object({companyId:e.property("company_id",e.string()),description:e.string(),icon:le.optional(),name:e.string()});var hg=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(Hr).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",N.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ne).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(ne).optional()),quarterlyMeteredPriceId:e.property("quarterly_metered_price_id",e.string().optional()),quarterlyPriceTiers:e.property("quarterly_price_tiers",e.list(ne).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",me.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),yearlyMeteredPriceId:e.property("yearly_metered_price_id",e.string().optional()),yearlyPriceTiers:e.property("yearly_price_tiers",e.list(ne).optional()),yearlyUnitPrice:e.property("yearly_unit_price",e.number().optional()),yearlyUnitPriceDecimal:e.property("yearly_unit_price_decimal",e.string().optional())});var Ro=e.enum_(["create","update","delete"]);var Ii=e.object({action:Ro,entitlementId:e.property("entitlement_id",e.string().optional()),req:hg.optional()});var gg=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 $r=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingStrategy:e.property("billing_strategy",Ge.optional()),chargeType:e.property("charge_type",We),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(gg).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 Vn=e.object({billingProduct:e.property("billing_product",$r.optional()),entitlements:e.list(Ii),plan:mg.optional()});var fo=e.object({description:e.string(),icon:le.optional(),name:e.string(),planType:e.property("plan_type",oe)});var _o=e.stringLiteral("credit");var So=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",_o.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",W.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()),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",W.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",Te),resetStart:e.property("reset_start",Me),resetType:e.property("reset_type",ar.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional())});var yg=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var Po=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",_o.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",W.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()),creditAmount:e.property("credit_amount",e.number().optional()),expiryType:e.property("expiry_type",Z.optional()),expiryUnit:e.property("expiry_unit",W.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),resetCadence:e.property("reset_cadence",Te),resetStart:e.property("reset_start",Me),resetType:e.property("reset_type",ar.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional())});var xo=e.object({action:Ro,createReq:e.property("create_req",So.optional()),creditGrantId:e.property("credit_grant_id",e.string().optional()),deleteReq:e.property("delete_req",yg.optional()),updateReq:e.property("update_req",Po.optional())});var qn=e.object({billingProduct:e.property("billing_product",$r.optional()),creditGrants:e.property("credit_grants",e.list(xo).optional()),entitlements:e.list(Ii),plan:fo.optional(),traits:e.list(vi).optional()});var Eo=e.object({description:e.string().optional(),icon:le.optional(),name:e.string()});var Mn=e.object({billingProduct:e.property("billing_product",$r.optional()),creditGrants:e.property("credit_grants",e.list(xo).optional()),entitlements:e.list(Ii),plan:Eo.optional(),planVersionId:e.property("plan_version_id",e.string().optional()),traits:e.list(vi).optional()});var Co=e.object({accountId:e.property("account_id",e.string()),billingProductId:e.property("billing_product_id",e.string()),billingStrategy:e.property("billing_strategy",Ge),chargeType:e.property("charge_type",We),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 Fi=e.object({billingProduct:e.property("billing_product",Co.optional()),creditGrants:e.property("credit_grants",e.list(Be).optional()),entitlements:e.list(ie).optional(),plan:sr.optional(),traits:e.list(Kr).optional()});var wg=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var bg=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var zg=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var Uo=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 Rg=e.object({entitlementId:e.property("entitlement_id",e.string()),visible:e.boolean().optional()});var xr=e.object({entitlements:e.list(Rg).optional(),planId:e.property("plan_id",e.string())});var Ki=e.object({bundleId:e.string()});var vo=e.enum_(["create_prorations","invoice_immediately"]);var To=e.enum_(["end_of_billing_period","none"]);var Dn=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr).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(Uo).optional()),customPlanConfig:e.property("custom_plan_config",Lr.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(xr)),orderedBundleList:e.property("ordered_bundle_list",e.list(Ki)),orderedPlans:e.property("ordered_plans",e.list(xr)),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",vo),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",To.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 In=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr).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(Uo).optional()),customPlanConfig:e.property("custom_plan_config",Lr.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(xr)),orderedBundleList:e.property("ordered_bundle_list",e.list(Ki)),orderedPlans:e.property("ordered_plans",e.list(xr)),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",vo),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",To.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 Oo=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 fg=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var ko=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 Bo=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(fg)),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutSettings:e.property("checkout_settings",Oo),componentSettings:e.property("component_settings",ko),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(xr)),planIds:e.property("plan_ids",e.list(xr)),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 _g=e.object({data:Bo,params:e.record(e.string(),e.unknown())});var Sg=e.object({includeCompanyCounts:e.property("include_company_counts",e.boolean().optional())});var Pg=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 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 ai=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ai)),billingLinkedResource:e.property("billing_linked_resource",ke.optional()),billingProduct:e.property("billing_product",or.optional()),billingStrategy:e.property("billing_strategy",Ge),chargeType:e.property("charge_type",We),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",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()),currencyPrices:e.property("currency_prices",e.list(Fr)),customPlanConfig:e.property("custom_plan_config",jo.optional()),description:e.string(),draftVersion:e.property("draft_version",Re.optional()),entitlements:e.list(ie).optional(),features:e.list(Ke),icon:le,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(Be).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",G.optional()),name:e.string(),oneTimePrice:e.property("one_time_price",G.optional()),planType:e.property("plan_type",oe),quarterlyPrice:e.property("quarterly_price",G.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",G.optional())});var xg=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var Fn=e.object({entitlements:e.list(xg).optional(),planId:e.property("plan_id",e.string())});var Eg=e.object({addOns:e.property("add_ons",e.list(ai)),checkoutSettings:e.property("checkout_settings",Oo),componentSettings:e.property("component_settings",ko),customCheckoutFields:e.property("custom_checkout_fields",e.list(Pg)),customPlanConfig:e.property("custom_plan_config",jo.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),defaultPlan:e.property("default_plan",ai.optional()),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlan:e.property("fallback_plan",ai.optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlan:e.property("initial_plan",ai.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(Fn)),orderedBundleList:e.property("ordered_bundle_list",e.list(Ki)),orderedPlanList:e.property("ordered_plan_list",e.list(Fn)),plans:e.list(ai),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",ai.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 Cg=e.object({data:Eg,params:Sg});var Ug=e.object({data:Bo,params:e.record(e.string(),e.unknown())});var Li=e.enum_(["immediate","leave"]);var Kn=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:Li,targetPlanType:e.property("target_plan_type",oe)});var Ao=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 Ln=e.object({errorCodes:e.property("error_codes",e.list(Ao))});var Er=e.enum_(["completed","failed","in_progress","pending","skipped"]);var vg=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Er.optional()});var Tg=e.object({data:V,params:vg});var Cr=e.enum_(["completed","failed","in_progress","pending"]);var Og=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Cr.optional()});var kg=e.object({data:V,params:Og});var Jr=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:Cr,strategy:Li,totalCompanies:e.property("total_companies",e.number()),updatedAt:e.property("updated_at",e.date())});var Bg=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var jg=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Ag=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Er.optional()});var Vo=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",Ao.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:Er,updatedAt:e.property("updated_at",e.date())});var Vg=e.object({data:e.list(Vo),params:Ag});var qg=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Cr.optional()});var Mg=e.object({data:e.list(Jr),params:qg});var Dg=e.object({data:Vo,params:e.record(e.string(),e.unknown())});var Ig=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Gn=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:le.optional(),name:e.string(),planType:e.property("plan_type",oe)});var Wn=e.object({companyId:e.property("company_id",e.string()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),description:e.string(),icon:le.optional(),name:e.string()});var Gi=e.object({priceId:e.property("price_id",e.string()),quantity:e.number()});var Nn=e.object({activationStrategy:e.property("activation_strategy",fi.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",Li),payInAdvance:e.property("pay_in_advance",e.list(Gi))});var Hn=e.object({activationStrategy:e.property("activation_strategy",fi.optional()),customerEmail:e.property("customer_email",e.string()),daysUntilDue:e.property("days_until_due",e.number().optional())});var $n=e.object({addOnIds:e.property("add_on_ids",e.list(e.string())),basePlanId:e.property("base_plan_id",e.string().optional())});var Fg=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Kg=e.object({data:V,params:Fg});var Lg=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",oe.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 Gg=e.object({data:V,params:Lg});var Wg=e.object({data:we,params:e.record(e.string(),e.unknown())});var Ng=e.object({data:we,params:e.record(e.string(),e.unknown())});var Hg=e.object({data:L,params:e.record(e.string(),e.unknown())});var $g=e.object({promoteArchivedVersion:e.property("promote_archived_version",e.boolean().optional())});var Jg=e.object({data:L,params:$g});var Yg=e.object({planVersionId:e.property("plan_version_id",e.string().optional())});var Zg=e.object({data:we,params:Yg});var Xg=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Qg=e.object({data:e.list(ee),params:Xg});var ey=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:Rr.optional(),statuses:e.list(Rr).optional()});var ry=e.object({data:e.list(jr),params:ey});var iy=e.object({planId:e.property("plan_id",e.string().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var ty=e.object({data:e.list(so),params:iy});var oy=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",oe.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 ay=e.object({data:e.list(we),params:oy});var ny=e.object({data:jr,params:e.record(e.string(),e.unknown())});var sy=e.object({data:Re,params:e.record(e.string(),e.unknown())});var cy=e.object({data:jr,params:e.record(e.string(),e.unknown())});var ly=e.object({data:ee,params:e.record(e.string(),e.unknown())});var py=e.object({data:we,params:e.record(e.string(),e.unknown())});var uy=e.object({data:Co,params:e.record(e.string(),e.unknown())});var dy=e.object({data:we,params:e.record(e.string(),e.unknown())});var Jn=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 Yr=e.enum_(["cancelled","error","executing","pending","success"]);var Yn=e.object({executeAfter:e.property("execute_after",e.date().optional()),status:Yr.optional()});var Zr=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:Yr,toPlanId:e.property("to_plan_id",e.string()),updatedAt:e.property("updated_at",e.date())});var my=e.object({data:Zr,params:e.record(e.string(),e.unknown())});var hy=e.object({data:Zr,params:e.record(e.string(),e.unknown())});var gy=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),status:Yr.optional()});var yy=e.object({data:e.list(Zr),params:gy});var wy=e.object({data:Zr,params:e.record(e.string(),e.unknown())});var Wi=e.object({creditId:e.property("credit_id",e.string())});var Ni=e.object({featureId:e.property("feature_id",e.string())});var Xr=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 Zn=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Wi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Ni).optional()),name:e.string(),requestTypes:e.property("request_types",e.list(Xr)),url:e.string()});var qo=e.enum_(["active","inactive"]);var Xn=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Wi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Ni).optional()),name:e.string().optional(),requestTypes:e.property("request_types",e.list(Xr).optional()),status:qo.optional(),url:e.string().optional()});var by=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 zy=e.object({data:V,params:by});var Ry=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var fy=e.object({data:V,params:Ry});var pr=e.object({createdAt:e.property("created_at",e.date()),creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Wi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Ni).optional()),id:e.string(),name:e.string(),requestTypes:e.property("request_types",e.list(Xr)),secret:e.string(),status:qo,updatedAt:e.property("updated_at",e.date()),url:e.string()});var _y=e.object({data:pr,params:e.record(e.string(),e.unknown())});var Sy=e.object({data:L,params:e.record(e.string(),e.unknown())});var Py=e.enum_(["failure","pending","success"]);var Mo=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),payload:e.string().optional(),requestType:e.property("request_type",Xr),responseCode:e.property("response_code",e.number().optional()),sentAt:e.property("sent_at",e.date().optional()),status:Py,updatedAt:e.property("updated_at",e.date()),webhook:pr.optional(),webhookId:e.property("webhook_id",e.string())});var xy=e.object({data:Mo,params:e.record(e.string(),e.unknown())});var Ey=e.object({data:pr,params:e.record(e.string(),e.unknown())});var Cy=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 Uy=e.object({data:e.list(Mo),params:Cy});var vy=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ty=e.object({data:e.list(pr),params:vy});var Oy=e.object({data:pr,params:e.record(e.string(),e.unknown())});var n=e.object({error:e.string()});var Do=e.object({id:e.string(),value:e.string()});var ky=e.object({addOnId:e.property("add_on_id",e.string()),priceId:e.property("price_id",e.string())});var By=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 Io=e.object({bundleId:e.property("bundle_id",e.string()),quantity:e.number()});var Qn=e.object({addOnIds:e.property("add_on_ids",e.list(ky)),autoTopupOverrides:e.property("auto_topup_overrides",e.list(By)),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(Io)),customFieldValues:e.property("custom_field_values",e.list(Do)),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(Gi)),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 es=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",nr),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var Fo=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Mi.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 rs=e.object({keys:e.record(e.string(),e.string())});var jy=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 is=e.object({addOnSelections:e.property("add_on_selections",e.list(jy)),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()),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(Io)),customFieldValues:e.property("custom_field_values",e.list(Do)),payInAdvanceEntitlements:e.property("pay_in_advance_entitlements",e.list(Gi)),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 Ay=e.record(e.string(),e.unknown());var Vy=e.record(e.string(),e.unknown());var qy=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var Hi=e.enum_(["all_time","current_day","current_month","current_week"]);var $i=e.enum_(["billing_cycle","first_of_month"]);var Ko=e.object({allocation: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()),featureId:e.property("feature_id",e.string()),featureKey:e.property("feature_key",e.string()),metricPeriod:e.property("metric_period",Hi.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",$i.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",qy)});var My=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var Lo=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",$i),period:Hi,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var Dy=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var Iy=e.enum_(["company","user"]);var Fy=e.enum_(["bool","date","int","string"]);var mt=e.object({comparableType:e.property("comparable_type",Fy),entityType:e.property("entity_type",Iy),id:e.string()});var Go=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",mt.optional()),conditionType:e.property("condition_type",Dy),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",Hi.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",$i.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ar,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",mt.optional()),traitValue:e.property("trait_value",e.string())});var Ky=e.object({conditions:e.list(Go)});var Ji=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(Ky)),conditions:e.list(Go),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",My),value:e.boolean()});var Ly=e.object({id:e.string(),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date())});var Wo=e.object({traitDefinition:e.property("trait_definition",mt.optional()),value:e.string()});var Gy=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(Ko).optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),metrics:e.list(Lo),planIds:e.property("plan_ids",e.list(e.string())),planVersionIds:e.property("plan_version_ids",e.list(e.string())),rules:e.list(Ji),subscription:Ly.optional(),traits:e.list(Wo)});var ts=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(Ji)});var Wy=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(Ji),traits:e.list(Wo)});var os=e.object({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 as=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 ns=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 No=class{constructor(t){this._options=K(t)}issueTemporaryAccessToken(t,i){return R.fromPromise(this.__issueTemporaryAccessToken(t,i))}async __issueTemporaryAccessToken(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:{...Ia.jsonOrThrow(t,{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:Bc.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 Ho=class{constructor(t){this._options=K(t)}listAccountMembers(t={},i){return R.fromPromise(this.__listAccountMembers(t,i))}async __listAccountMembers(t={},i){let{ids:o,q:s,limit:r,offset:a}=t,u={ids:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:il.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/account-members")}getAccountMember(t,i){return R.fromPromise(this.__getAccountMember(t,i))}async __getAccountMember(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:$c.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(t={},i){return R.fromPromise(this.__countAccountMembers(t,i))}async __countAccountMembers(t={},i){let{ids:o,q:s,limit:r,offset:a}=t,u={ids:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Ac.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/account-members/count")}listApiKeys(t,i){return R.fromPromise(this.__listApiKeys(t,i))}async __listApiKeys(t,i){let{environmentId:o,requireEnvironment:s,limit:r,offset:a}=t,u={environment_id:o,require_environment:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:ol.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/api-keys")}createApiKey(t,i){return R.fromPromise(this.__createApiKey(t,i))}async __createApiKey(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Fa.jsonOrThrow(t,{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:Fc.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(t,i){return R.fromPromise(this.__getApiKey(t,i))}async __getApiKey(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:Jc.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(t,i={},o){return R.fromPromise(this.__updateApiKey(t,i,o))}async __updateApiKey(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:La.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:ul.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(t,i){return R.fromPromise(this.__deleteApiKey(t,i))}async __deleteApiKey(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:Gc.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(t,i){return R.fromPromise(this.__countApiKeys(t,i))}async __countApiKeys(t,i){let{environmentId:o,requireEnvironment:s,limit:r,offset:a}=t,u={environment_id:o,require_environment:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:qc.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/api-keys/count")}listAuditLogs(t={},i){return R.fromPromise(this.__listAuditLogs(t,i))}async __listAuditLogs(t={},i){let{actorType:o,endTime:s,environmentId:r,q:a,startTime:u,limit:g,offset:h}=t,c={actor_type:o!=null?Ee.jsonOrThrow(o,{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(c).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:nl.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(t,i){return R.fromPromise(this.__getAuditLog(t,i))}async __getAuditLog(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t={},i){return R.fromPromise(this.__countAuditLogs(t,i))}async __countAuditLogs(t={},i){let{actorType:o,endTime:s,environmentId:r,q:a,startTime:u,limit:g,offset:h}=t,c={actor_type:o!=null?Ee.jsonOrThrow(o,{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(c).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Dc.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(t={},i){return R.fromPromise(this.__listEnvironments(t,i))}async __listEnvironments(t={},i){let{ids:o,limit:s,offset:r}=t,a={ids:o,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: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 C(h.error,h.rawResponse,"GET","/environments")}createEnvironment(t,i){return R.fromPromise(this.__createEnvironment(t,i))}async __createEnvironment(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Ka.jsonOrThrow(t,{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:Lc.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(t,i){return R.fromPromise(this.__getEnvironment(t,i))}async __getEnvironment(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:Xc.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(t,i={},o){return R.fromPromise(this.__updateEnvironment(t,i,o))}async __updateEnvironment(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Ga.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:dl.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(t,i){return R.fromPromise(this.__deleteEnvironment(t,i))}async __deleteEnvironment(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:Wc.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(t){return R.fromPromise(this.__quickstart(t))}async __quickstart(t){let i=await this._options.authProvider.getAuthRequest(),o=f(i.headers,this._options?.headers,t?.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:o,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(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 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(t){return R.fromPromise(this.__getWhoAmI(t))}async __getWhoAmI(t){let i=await this._options.authProvider.getAuthRequest(),o=f(i.headers,this._options?.headers,t?.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:o,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(s.ok)return{data:el.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 $o=class{constructor(t){this._options=K(t)}listCoupons(t={},i){return R.fromPromise(this.__listCoupons(t,i))}async __listCoupons(t={},i){let{isActive:o,q:s,limit:r,offset:a}=t,u={is_active:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Tl.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/billing/coupons")}upsertBillingCoupon(t,i){return R.fromPromise(this.__upsertBillingCoupon(t,i))}async __upsertBillingCoupon(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Ja.jsonOrThrow(t,{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: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,"POST","/billing/coupons")}upsertBillingCustomer(t,i){return R.fromPromise(this.__upsertBillingCustomer(t,i))}async __upsertBillingCustomer(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Wa.jsonOrThrow(t,{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: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,"POST","/billing/customer/upsert")}listCustomersWithSubscriptions(t={},i){return R.fromPromise(this.__listCustomersWithSubscriptions(t,i))}async __listCustomersWithSubscriptions(t={},i){let{companyIds:o,name:s,providerType:r,q:a,limit:u,offset:g}=t,h={company_ids:o,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:jl.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(t={},i){return R.fromPromise(this.__countCustomers(t,i))}async __countCustomers(t={},i){let{companyIds:o,name:s,providerType:r,q:a,limit:u,offset:g}=t,h={company_ids:o,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:a,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:zl.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(t,i){return R.fromPromise(this.__listInvoices(t,i))}async __listInvoices(t,i){let{companyId:o,customerExternalId:s,subscriptionExternalId:r,limit:a,offset:u}=t,g={company_id:o,customer_external_id:s,subscription_external_id:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:Vl.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(t,i){return R.fromPromise(this.__upsertInvoice(t,i))}async __upsertInvoice(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Ya.jsonOrThrow(t,{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: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 C(r.error,r.rawResponse,"POST","/billing/invoices")}listMeters(t={},i){return R.fromPromise(this.__listMeters(t,i))}async __listMeters(t={},i){let{displayName:o,limit:s,offset:r}=t,a={display_name:o,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:Ml.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(t,i){return R.fromPromise(this.__upsertBillingMeter(t,i))}async __upsertBillingMeter(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Za.jsonOrThrow(t,{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: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 C(r.error,r.rawResponse,"POST","/billing/meter/upsert")}listPaymentMethods(t,i){return R.fromPromise(this.__listPaymentMethods(t,i))}async __listPaymentMethods(t,i){let{companyId:o,customerExternalId:s,limit:r,offset:a}=t,u={company_id:o,customer_external_id:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Il.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/billing/payment-methods")}upsertPaymentMethod(t,i){return R.fromPromise(this.__upsertPaymentMethod(t,i))}async __upsertPaymentMethod(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Xa.jsonOrThrow(t,{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: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 C(r.error,r.rawResponse,"POST","/billing/payment-methods")}deletePaymentMethodByExternalId(t,i){return R.fromPromise(this.__deletePaymentMethodByExternalId(t,i))}async __deletePaymentMethodByExternalId(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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/payment-methods/{billing_id}")}listBillingPrices(t={},i){return R.fromPromise(this.__listBillingPrices(t,i))}async __listBillingPrices(t={},i){let{currency:o,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:u,isActive:g,price:h,productId:c,productIds:y,providerType:w,q:U,tiersMode:T,usageType:O,withMeter:j,limit:B,offset:I}=t,A={currency:o,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:u,is_active:g,price:h,product_id:c,product_ids:y,provider_type:w!=null?k.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,tiers_mode:T!=null?me.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:O!=null?se.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:j,limit:B,offset:I},X=await this._options.authProvider.getAuthRequest(),_e=f(X.headers,this._options?.headers,i?.headers),q=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:_e,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(q.ok)return{data:Pl.parseOrThrow(q.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:q.rawResponse};if(q.error.reason==="status-code")switch(q.error.statusCode){case 400:throw new v(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 401:throw new x(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 403:throw new _(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 404:throw new P(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 500:throw new S(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);default:throw new b({statusCode:q.error.statusCode,body:q.error.body,rawResponse:q.rawResponse})}return C(q.error,q.rawResponse,"GET","/billing/price")}upsertBillingPrice(t,i){return R.fromPromise(this.__upsertBillingPrice(t,i))}async __upsertBillingPrice(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Na.jsonOrThrow(t,{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: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 C(r.error,r.rawResponse,"POST","/billing/price/upsert")}deleteBillingProduct(t,i){return R.fromPromise(this.__deleteBillingProduct(t,i))}async __deleteBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:Rl.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(t={},i){return R.fromPromise(this.__listBillingProductPrices(t,i))}async __listBillingProductPrices(t={},i){let{currency:o,forInitialPlan:s,forTrialExpiryPlan:r,ids:a,interval:u,isActive:g,price:h,productId:c,productIds:y,providerType:w,q:U,tiersMode:T,usageType:O,withMeter:j,limit:B,offset:I}=t,A={currency:o,for_initial_plan:s,for_trial_expiry_plan:r,ids:a,interval:u,is_active:g,price:h,product_id:c,product_ids:y,provider_type:w!=null?k.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,tiers_mode:T!=null?me.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:O!=null?se.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:j,limit:B,offset:I},X=await this._options.authProvider.getAuthRequest(),_e=f(X.headers,this._options?.headers,i?.headers),q=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:_e,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(q.ok)return{data:El.parseOrThrow(q.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:q.rawResponse};if(q.error.reason==="status-code")switch(q.error.statusCode){case 400:throw new v(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 401:throw new x(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 403:throw new _(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 404:throw new P(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 500:throw new S(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);default:throw new b({statusCode:q.error.statusCode,body:q.error.body,rawResponse:q.rawResponse})}return C(q.error,q.rawResponse,"GET","/billing/product/prices")}deleteProductPrice(t,i){return R.fromPromise(this.__deleteProductPrice(t,i))}async __deleteProductPrice(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:_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 C(r.error,r.rawResponse,"DELETE","/billing/product/prices/{billing_id}")}upsertBillingProduct(t,i){return R.fromPromise(this.__upsertBillingProduct(t,i))}async __upsertBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Ha.jsonOrThrow(t,{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: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 C(r.error,r.rawResponse,"POST","/billing/product/upsert")}listBillingProducts(t={},i){return R.fromPromise(this.__listBillingProducts(t,i))}async __listBillingProducts(t={},i){let{ids:o,isActive:s,name:r,priceUsageType:a,providerType:u,q:g,recurringChargesOnly:h,withOneTimeCharges:c,withPricesOnly:y,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=t,j={ids:o,is_active:s,name:r,price_usage_type:a!=null?se.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:c,with_prices_only:y,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},B=await this._options.authProvider.getAuthRequest(),I=f(B.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,"billing/products"),method:"GET",headers:I,queryString:d.queryBuilder().addMany(j).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Ul.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","/billing/products")}countBillingProducts(t={},i){return R.fromPromise(this.__countBillingProducts(t,i))}async __countBillingProducts(t={},i){let{ids:o,isActive:s,name:r,priceUsageType:a,providerType:u,q:g,recurringChargesOnly:h,withOneTimeCharges:c,withPricesOnly:y,withZeroPrice:w,withoutLinkedToPlan:U,limit:T,offset:O}=t,j={ids:o,is_active:s,name:r,price_usage_type:a!=null?se.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:c,with_prices_only:y,with_zero_price:w,without_linked_to_plan:U,limit:T,offset:O},B=await this._options.authProvider.getAuthRequest(),I=f(B.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,"billing/products/count"),method:"GET",headers:I,queryString:d.queryBuilder().addMany(j).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:wl.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","/billing/products/count")}upsertBillingSubscription(t,i){return R.fromPromise(this.__upsertBillingSubscription(t,i))}async __upsertBillingSubscription(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:$a.jsonOrThrow(t,{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:$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 C(r.error,r.rawResponse,"POST","/billing/subscription/upsert")}};var Jo=class{constructor(t){this._options=K(t)}internal(t,i){return R.fromPromise(this.__internal(t,i))}async __internal(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Qn.jsonOrThrow(t,{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:np.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(t,i){return R.fromPromise(this.__getCheckoutData(t,i))}async __getCheckoutData(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:en.jsonOrThrow(t,{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","/checkout-internal/data")}previewCheckoutInternal(t,i){return R.fromPromise(this.__previewCheckoutInternal(t,i))}async __previewCheckoutInternal(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Qn.jsonOrThrow(t,{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","/checkout-internal/preview")}managePlan(t,i){return R.fromPromise(this.__managePlan(t,i))}async __managePlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:is.jsonOrThrow(t,{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","/manage-plan")}previewManagePlan(t,i){return R.fromPromise(this.__previewManagePlan(t,i))}async __previewManagePlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:is.jsonOrThrow(t,{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 C(r.error,r.rawResponse,"POST","/manage-plan/preview")}cancelSubscription(t,i){return R.fromPromise(this.__cancelSubscription(t,i))}async __cancelSubscription(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Qa.jsonOrThrow(t,{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:op.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(t,i={},o){return R.fromPromise(this.__updateCustomerSubscriptionTrialEnd(t,i,o))}async __updateCustomerSubscriptionTrialEnd(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/edit-trial-end`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Sp.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 Yo=class{constructor(t){this._options=K(t)}listCompanies(t={},i){return R.fromPromise(this.__listCompanies(t,i))}async __listCompanies(t={},i){let{creditTypeIds:o,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:u,planIds:g,planVersionId:h,planVersionIds:c,q:y,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:j,withoutFeatureOverrideFor:B,withoutPlan:I,withoutSubscription:A,withSubscription:X,limit:_e,offset:q}=t,M={credit_type_ids:o,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:u,plan_ids:g,plan_version_id:h,plan_version_ids:c,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(gr=>fr.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):T!=null?fr.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(gr=>_r.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):O!=null?_r.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:j,without_feature_override_for:B,without_plan:I,without_subscription:A,with_subscription:X,limit:_e,offset:q},hr=await this._options.authProvider.getAuthRequest(),Ve=f(hr.headers,this._options?.headers,i?.headers),F=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:Ve,queryString:d.queryBuilder().addMany(M).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(F.ok)return{data:tu.parseOrThrow(F.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:F.rawResponse};if(F.error.reason==="status-code")switch(F.error.statusCode){case 400:throw new v(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 401:throw new x(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 403:throw new _(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 404:throw new P(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 500:throw new S(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);default:throw new b({statusCode:F.error.statusCode,body:F.error.body,rawResponse:F.rawResponse})}return C(F.error,F.rawResponse,"GET","/companies")}upsertCompany(t,i){return R.fromPromise(this.__upsertCompany(t,i))}async __upsertCompany(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:os.jsonOrThrow(t,{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 C(r.error,r.rawResponse,"POST","/companies")}getCompany(t,i){return R.fromPromise(this.__getCompany(t,i))}async __getCompany(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i={},o){return R.fromPromise(this.__deleteCompany(t,i,o))}async __deleteCompany(t,i={},o){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,o?.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(t)}`),method:"DELETE",headers:g,queryString:d.queryBuilder().addMany(a).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(h.ok)return{data:Dp.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(t={},i){return R.fromPromise(this.__countCompanies(t,i))}async __countCompanies(t={},i){let{creditTypeIds:o,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:a,planId:u,planIds:g,planVersionId:h,planVersionIds:c,q:y,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:T,subscriptionTypes:O,withEntitlementFor:j,withoutFeatureOverrideFor:B,withoutPlan:I,withoutSubscription:A,withSubscription:X,limit:_e,offset:q}=t,M={credit_type_ids:o,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:a,plan_id:u,plan_ids:g,plan_version_id:h,plan_version_ids:c,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(gr=>fr.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):T!=null?fr.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(gr=>_r.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):O!=null?_r.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:j,without_feature_override_for:B,without_plan:I,without_subscription:A,with_subscription:X,limit:_e,offset:q},hr=await this._options.authProvider.getAuthRequest(),Ve=f(hr.headers,this._options?.headers,i?.headers),F=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:Ve,queryString:d.queryBuilder().addMany(M).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(F.ok)return{data:xp.parseOrThrow(F.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:F.rawResponse};if(F.error.reason==="status-code")switch(F.error.statusCode){case 400:throw new v(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 401:throw new x(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 403:throw new _(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 404:throw new P(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 500:throw new S(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);default:throw new b({statusCode:F.error.statusCode,body:F.error.body,rawResponse:F.rawResponse})}return C(F.error,F.rawResponse,"GET","/companies/count")}createCompany(t,i){return R.fromPromise(this.__createCompany(t,i))}async __createCompany(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:os.jsonOrThrow(t,{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: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 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(t,i){return R.fromPromise(this.__deleteCompanyByKeys(t,i))}async __deleteCompanyByKeys(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:rs.jsonOrThrow(t,{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:Vp.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(t,i){return R.fromPromise(this.__lookupCompany(t,i))}async __lookupCompany(t,i){let{keys:o}=t,s={keys:ve(o)},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:wu.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")}listCompanyMemberships(t={},i){return R.fromPromise(this.__listCompanyMemberships(t,i))}async __listCompanyMemberships(t={},i){let{companyId:o,userId:s,limit:r,offset:a}=t,u={company_id:o,user_id:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:au.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/company-memberships")}getOrCreateCompanyMembership(t,i){return R.fromPromise(this.__getOrCreateCompanyMembership(t,i))}async __getOrCreateCompanyMembership(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:nn.jsonOrThrow(t,{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: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 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(t,i){return R.fromPromise(this.__deleteCompanyMembership(t,i))}async __deleteCompanyMembership(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t={},i){return R.fromPromise(this.__getActiveCompanySubscription(t,i))}async __getActiveCompanySubscription(t={},i){let{companyId:o,companyIds:s,limit:r,offset:a}=t,u={company_id:o,company_ids:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Lp.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/company-subscriptions")}upsertCompanyTrait(t,i){return R.fromPromise(this.__upsertCompanyTrait(t,i))}async __upsertCompanyTrait(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:as.jsonOrThrow(t,{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 C(r.error,r.rawResponse,"POST","/company-traits")}listEntityKeyDefinitions(t={},i){return R.fromPromise(this.__listEntityKeyDefinitions(t,i))}async __listEntityKeyDefinitions(t={},i){let{entityType:o,ids:s,q:r,limit:a,offset:u}=t,g={entity_type:o!=null?te.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:su.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(t={},i){return R.fromPromise(this.__countEntityKeyDefinitions(t,i))}async __countEntityKeyDefinitions(t={},i){let{entityType:o,ids:s,q:r,limit:a,offset:u}=t,g={entity_type:o!=null?te.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:Cp.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(t={},i){return R.fromPromise(this.__listEntityTraitDefinitions(t,i))}async __listEntityTraitDefinitions(t={},i){let{entityType:o,ids:s,q:r,traitType:a,traitTypes:u,limit:g,offset:h}=t,c={entity_type:o!=null?te.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?he.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(u)?u.map(T=>he.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):u!=null?he.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(c).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:lu.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(t,i){return R.fromPromise(this.__getOrCreateEntityTraitDefinition(t,i))}async __getOrCreateEntityTraitDefinition(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:an.jsonOrThrow(t,{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","/entity-trait-definitions")}getEntityTraitDefinition(t,i){return R.fromPromise(this.__getEntityTraitDefinition(t,i))}async __getEntityTraitDefinition(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 C(r.error,r.rawResponse,"GET","/entity-trait-definitions/{entity_trait_definition_id}")}updateEntityTraitDefinition(t,i,o){return R.fromPromise(this.__updateEntityTraitDefinition(t,i,o))}async __updateEntityTraitDefinition(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:sn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Ru.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(t={},i){return R.fromPromise(this.__countEntityTraitDefinitions(t,i))}async __countEntityTraitDefinitions(t={},i){let{entityType:o,ids:s,q:r,traitType:a,traitTypes:u,limit:g,offset:h}=t,c={entity_type:o!=null?te.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:a!=null?he.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(u)?u.map(T=>he.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"})):u!=null?he.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(c).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:vp.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(t,i){return R.fromPromise(this.__getEntityTraitValues(t,i))}async __getEntityTraitValues(t,i){let{definitionId:o,q:s,limit:r,offset:a}=t,u={definition_id:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:$p.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/entity-trait-values")}listPlanChanges(t={},i){return R.fromPromise(this.__listPlanChanges(t,i))}async __listPlanChanges(t={},i){let{action:o,basePlanAction:s,companyId:r,companyIds:a,planIds:u,limit:g,offset:h}=t,c={action:o!=null?ki.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}):void 0,base_plan_action:s!=null?Bi.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(c).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:uu.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(t,i){return R.fromPromise(this.__getPlanChange(t,i))}async __getPlanChange(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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","/plan-changes/{plan_change_id}")}listPlanTraits(t={},i){return R.fromPromise(this.__listPlanTraits(t,i))}async __listPlanTraits(t={},i){let{ids:o,planId:s,traitId:r,traitIds:a,limit:u,offset:g}=t,h={ids:o,plan_id:s,trait_id:r,trait_ids:a,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:mu.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(t,i){return R.fromPromise(this.__getPlanTrait(t,i))}async __getPlanTrait(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i){return R.fromPromise(this.__updatePlanTraitsBulk(t,i))}async __updatePlanTraitsBulk(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:cn.jsonOrThrow(t,{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: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 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(t={},i){return R.fromPromise(this.__countPlanTraits(t,i))}async __countPlanTraits(t={},i){let{ids:o,planId:s,traitId:r,traitIds:a,limit:u,offset:g}=t,h={ids:o,plan_id:s,trait_id:r,trait_ids:a,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:Op.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(t,i){return R.fromPromise(this.__upsertUserTrait(t,i))}async __upsertUserTrait(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:as.jsonOrThrow(t,{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","/user-traits")}listUsers(t={},i){return R.fromPromise(this.__listUsers(t,i))}async __listUsers(t={},i){let{companyId:o,ids:s,planId:r,q:a,limit:u,offset:g}=t,h={company_id:o,ids:s,plan_id:r,q:a,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:gu.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(t,i){return R.fromPromise(this.__upsertUser(t,i))}async __upsertUser(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:ns.jsonOrThrow(t,{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","/users")}getUser(t,i){return R.fromPromise(this.__getUser(t,i))}async __getUser(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i){return R.fromPromise(this.__deleteUser(t,i))}async __deleteUser(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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","/users/{user_id}")}countUsers(t={},i){return R.fromPromise(this.__countUsers(t,i))}async __countUsers(t={},i){let{companyId:o,ids:s,planId:r,q:a,limit:u,offset:g}=t,h={company_id:o,ids:s,plan_id:r,q:a,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:Bp.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(t,i){return R.fromPromise(this.__createUser(t,i))}async __createUser(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:ns.jsonOrThrow(t,{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:Ap.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(t,i){return R.fromPromise(this.__deleteUserByKeys(t,i))}async __deleteUserByKeys(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:rs.jsonOrThrow(t,{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: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 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(t,i){return R.fromPromise(this.__lookupUser(t,i))}async __lookupUser(t,i){let{keys:o}=t,s={keys:ve(o)},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:zu.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 Zo=class{constructor(t){this._options=K(t)}listComponents(t={},i){return R.fromPromise(this.__listComponents(t,i))}async __listComponents(t={},i){let{q:o,limit:s,offset:r}=t,a={q:o,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:ku.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(t,i){return R.fromPromise(this.__createComponent(t,i))}async __createComponent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t,{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: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,"POST","/components")}getComponent(t,i){return R.fromPromise(this.__getComponent(t,i))}async __getComponent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:Tu.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(t,i={},o){return R.fromPromise(this.__updateComponent(t,i,o))}async __updateComponent(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:un.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Lu.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(t,i){return R.fromPromise(this.__deleteComponent(t,i))}async __deleteComponent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 C(r.error,r.rawResponse,"DELETE","/components/{component_id}")}countComponents(t={},i){return R.fromPromise(this.__countComponents(t,i))}async __countComponents(t={},i){let{q:o,limit:s,offset:r}=t,a={q:o,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:Cu.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(t={},i){return R.fromPromise(this.__previewComponentData(t,i))}async __previewComponentData(t={},i){let{companyId:o,componentId:s}=t,r={company_id:o,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:Ku.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 Xo=class{constructor(t){this._options=K(t)}getPublicPlans(t){return R.fromPromise(this.__getPublicPlans(t))}async __getPublicPlans(t){let i=await this._options.authProvider.getAuthRequest(),o=f(i.headers,this._options?.headers,t?.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:o,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(s.ok)return{data:Wu.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 Qo=class{constructor(t){this._options=K(t)}listBillingCredits(t={},i){return R.fromPromise(this.__listBillingCredits(t,i))}async __listBillingCredits(t={},i){let{ids:o,name:s,limit:r,offset:a}=t,u={ids:o,name:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:bd.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/billing/credits")}createBillingCredit(t,i){return R.fromPromise(this.__createBillingCredit(t,i))}async __createBillingCredit(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:gn.jsonOrThrow(t,{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:ad.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(t,i){return R.fromPromise(this.__getSingleBillingCredit(t,i))}async __getSingleBillingCredit(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 C(r.error,r.rawResponse,"GET","/billing/credits/{credit_id}")}updateBillingCredit(t,i,o){return R.fromPromise(this.__updateBillingCredit(t,i,o))}async __updateBillingCredit(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:zn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Dd.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(t,i){return R.fromPromise(this.__softDeleteBillingCredit(t,i))}async __softDeleteBillingCredit(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i){return R.fromPromise(this.__listCompanyCreditBalances(t,i))}async __listCompanyCreditBalances(t,i){let{companyId:o}=t,s={company_id:o},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:Sd.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(t={},i){return R.fromPromise(this.__listCreditBundles(t,i))}async __listCreditBundles(t={},i){let{ids:o,creditId:s,status:r,bundleType:a,limit:u,offset:g}=t,h={ids:o,credit_id:s,status:r!=null?Ce.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?Ae.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:Cd.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(t,i){return R.fromPromise(this.__createCreditBundle(t,i))}async __createCreditBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:wn.jsonOrThrow(t,{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: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 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(t,i){return R.fromPromise(this.__getCreditBundle(t,i))}async __getCreditBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i,o){return R.fromPromise(this.__updateCreditBundleDetails(t,i,o))}async __updateCreditBundleDetails(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(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","/billing/credits/bundles/{bundle_id}")}deleteCreditBundle(t,i){return R.fromPromise(this.__deleteCreditBundle(t,i))}async __deleteCreditBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:pd.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(t={},i){return R.fromPromise(this.__countCreditBundles(t,i))}async __countCreditBundles(t={},i){let{ids:o,creditId:s,status:r,bundleType:a,limit:u,offset:g}=t,h={ids:o,credit_id:s,status:r!=null?Ce.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:a!=null?Ae.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:id.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(t={},i){return R.fromPromise(this.__countBillingCredits(t,i))}async __countBillingCredits(t={},i){let{ids:o,name:s,limit:r,offset:a}=t,u={ids:o,name:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Yu.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/billing/credits/count")}zeroOutGrant(t,i={},o){return R.fromPromise(this.__zeroOutGrant(t,i,o))}async __zeroOutGrant(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/zero-out`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:fn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Kd.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(t,i){return R.fromPromise(this.__grantBillingCreditsToCompany(t,i))}async __grantBillingCreditsToCompany(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:yn.jsonOrThrow(t,{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:yd.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(t={},i){return R.fromPromise(this.__countCompanyGrants(t,i))}async __countCompanyGrants(t={},i){let{companyId:o,order:s,dir:r,limit:a,offset:u}=t,g={company_id:o,order:s!=null?oi.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(),c=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:c,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:ed.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(t={},i){return R.fromPromise(this.__listCompanyGrants(t,i))}async __listCompanyGrants(t={},i){let{companyId:o,order:s,dir:r,limit:a,offset:u}=t,g={company_id:o,order:s!=null?oi.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(),c=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:c,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/list")}countBillingCreditsGrants(t={},i){return R.fromPromise(this.__countBillingCreditsGrants(t,i))}async __countBillingCreditsGrants(t={},i){let{creditId:o,ids:s,limit:r,offset:a}=t,u={credit_id:o,ids:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:$u.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/billing/credits/grants/count")}listGrantsForCredit(t={},i){return R.fromPromise(this.__listGrantsForCredit(t,i))}async __listGrantsForCredit(t={},i){let{creditId:o,ids:s,limit:r,offset:a}=t,u={credit_id:o,ids:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Vd.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/billing/credits/grants/list")}acquireCreditLease(t,i){return R.fromPromise(this.__acquireCreditLease(t,i))}async __acquireCreditLease(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:hn.jsonOrThrow(t,{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","/billing/credits/lease")}extendCreditLease(t,i,o){return R.fromPromise(this.__extendCreditLease(t,i,o))}async __extendCreditLease(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/extend`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:bn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(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 C(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/extend")}releaseCreditLease(t,i,o){return R.fromPromise(this.__releaseCreditLease(t,i,o))}async __releaseCreditLease(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/release`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Vy.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:qd.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(t={},i){return R.fromPromise(this.__listBillingPlanCreditGrants(t,i))}async __listBillingPlanCreditGrants(t={},i){let{creditId:o,ids:s,planId:r,planIds:a,planVersionId:u,planVersionIds:g,limit:h,offset:c}=t,y={credit_id:o,ids:s,plan_id:r,plan_ids:a,plan_version_id:u,plan_version_ids:g,limit:h,offset:c},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:Rd.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(t,i){return R.fromPromise(this.__createBillingPlanCreditGrant(t,i))}async __createBillingPlanCreditGrant(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:So.jsonOrThrow(t,{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:nd.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(t,i){return R.fromPromise(this.__getSingleBillingPlanCreditGrant(t,i))}async __getSingleBillingPlanCreditGrant(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:hd.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(t,i,o){return R.fromPromise(this.__updateBillingPlanCreditGrant(t,i,o))}async __updateBillingPlanCreditGrant(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Po.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Id.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(t,i={},o){return R.fromPromise(this.__deleteBillingPlanCreditGrant(t,i,o))}async __deleteBillingPlanCreditGrant(t,i={},o){let{applyToExisting:s}=i,r={apply_to_existing:s},a=await this._options.authProvider.getAuthRequest(),u=f(a.headers,this._options?.headers,o?.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(t)}`),method:"DELETE",headers:u,queryString:d.queryBuilder().addMany(r).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(g.ok)return{data:ld.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(t={},i){return R.fromPromise(this.__countBillingPlanCreditGrants(t,i))}async __countBillingPlanCreditGrants(t={},i){let{creditId:o,ids:s,planId:r,planIds:a,planVersionId:u,planVersionIds:g,limit:h,offset:c}=t,y={credit_id:o,ids:s,plan_id:r,plan_ids:a,plan_version_id:u,plan_version_ids:g,limit:h,offset:c},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:Xu.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(t,i){return R.fromPromise(this.__listCreditEventLedger(t,i))}async __listCreditEventLedger(t,i){let{billingCreditId:o,companyId:s,endTime:r,eventType:a,featureId:u,startTime:g,limit:h,offset:c}=t,y={billing_credit_id:o,company_id:s,end_time:r,event_type:a!=null?Sr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:u,start_time:g,limit:h,offset:c},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:jd.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(t,i){return R.fromPromise(this.__countCreditEventLedger(t,i))}async __countCreditEventLedger(t,i){let{billingCreditId:o,companyId:s,endTime:r,eventType:a,featureId:u,startTime:g,limit:h,offset:c}=t,y={billing_credit_id:o,company_id:s,end_time:r,event_type:a!=null?Sr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:u,start_time:g,limit:h,offset:c},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:od.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 ea=class{constructor(t){this._options=K(t)}createDataExport(t,i){return R.fromPromise(this.__createDataExport(t,i))}async __createDataExport(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:{..._n.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),export_type:"company-feature-usage",output_file_type:"csv"},timeoutMs:(i?.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:Hd.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")}getDataExportArtifact(t,i){return R.fromPromise(this.__getDataExportArtifact(t,i))}async __getDataExportArtifact(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}/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 ra=class{constructor(t){this._options=K(t)}listCompanyOverrides(t={},i){return R.fromPromise(this.__listCompanyOverrides(t,i))}async __listCompanyOverrides(t={},i){let{companyId:o,companyIds:s,featureId:r,featureIds:a,ids:u,withoutExpired:g,q:h,limit:c,offset:y}=t,w={company_id:o,company_ids:s,feature_id:r,feature_ids:a,ids:u,without_expired:g,q:h,limit:c,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:_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")}createCompanyOverride(t,i){return R.fromPromise(this.__createCompanyOverride(t,i))}async __createCompanyOverride(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Pn.jsonOrThrow(t,{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","/company-overrides")}getCompanyOverride(t,i){return R.fromPromise(this.__getCompanyOverride(t,i))}async __getCompanyOverride(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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","/company-overrides/{company_override_id}")}updateCompanyOverride(t,i,o){return R.fromPromise(this.__updateCompanyOverride(t,i,o))}async __updateCompanyOverride(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Cn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(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 C(a.error,a.rawResponse,"PUT","/company-overrides/{company_override_id}")}deleteCompanyOverride(t,i){return R.fromPromise(this.__deleteCompanyOverride(t,i))}async __deleteCompanyOverride(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 C(r.error,r.rawResponse,"DELETE","/company-overrides/{company_override_id}")}countCompanyOverrides(t={},i){return R.fromPromise(this.__countCompanyOverrides(t,i))}async __countCompanyOverrides(t={},i){let{companyId:o,companyIds:s,featureId:r,featureIds:a,ids:u,withoutExpired:g,q:h,limit:c,offset:y}=t,w={company_id:o,company_ids:s,feature_id:r,feature_ids:a,ids:u,without_expired:g,q:h,limit:c,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:Jd.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(t,i){return R.fromPromise(this.__listFeatureCompanies(t,i))}async __listFeatureCompanies(t,i){let{featureId:o,q:s,limit:r,offset:a}=t,u={feature_id:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Em.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/feature-companies")}countFeatureCompanies(t,i){return R.fromPromise(this.__countFeatureCompanies(t,i))}async __countFeatureCompanies(t,i){let{featureId:o,q:s,limit:r,offset:a}=t,u={feature_id:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Zd.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/feature-companies/count")}listFeatureUsage(t={},i){return R.fromPromise(this.__listFeatureUsage(t,i))}async __listFeatureUsage(t={},i){let{companyId:o,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:u,q:g,withoutNegativeEntitlements:h,limit:c,offset:y}=t,w={company_id:o,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:c,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:Um.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(t,i){return R.fromPromise(this.__getFeatureUsageTimeSeries(t,i))}async __getFeatureUsageTimeSeries(t,i){let{companyId:o,endTime:s,featureId:r,granularity:a,startTime:u}=t,g={company_id:o,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(),c=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:c,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:zm.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(t={},i){return R.fromPromise(this.__countFeatureUsage(t,i))}async __countFeatureUsage(t={},i){let{companyId:o,companyKeys:s,featureIds:r,includeUsageAggregation:a,managedBy:u,q:g,withoutNegativeEntitlements:h,limit:c,offset:y}=t,w={company_id:o,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:c,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:Qd.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(t,i){return R.fromPromise(this.__listFeatureUsers(t,i))}async __listFeatureUsers(t,i){let{featureId:o,q:s,limit:r,offset:a}=t,u={feature_id:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Om.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/feature-users")}countFeatureUsers(t,i){return R.fromPromise(this.__countFeatureUsers(t,i))}async __countFeatureUsers(t,i){let{featureId:o,q:s,limit:r,offset:a}=t,u={feature_id:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:rm.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/feature-users/count")}listPlanEntitlements(t={},i){return R.fromPromise(this.__listPlanEntitlements(t,i))}async __listPlanEntitlements(t={},i){let{featureId:o,featureIds:s,ids:r,planId:a,planIds:u,planVersionId:g,planVersionIds:h,q:c,withMeteredProducts:y,limit:w,offset:U}=t,T={feature_id:o,feature_ids:s,ids:r,plan_id:a,plan_ids:u,plan_version_id:g,plan_version_ids:h,q:c,with_metered_products:y,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),j=f(O.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,"plan-entitlements"),method:"GET",headers:j,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(B.ok)return{data:Bm.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","/plan-entitlements")}createPlanEntitlement(t,i){return R.fromPromise(this.__createPlanEntitlement(t,i))}async __createPlanEntitlement(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:xn.jsonOrThrow(t,{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","/plan-entitlements")}getPlanEntitlement(t,i){return R.fromPromise(this.__getPlanEntitlement(t,i))}async __getPlanEntitlement(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i,o){return R.fromPromise(this.__updatePlanEntitlement(t,i,o))}async __updatePlanEntitlement(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Un.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(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","/plan-entitlements/{plan_entitlement_id}")}deletePlanEntitlement(t,i){return R.fromPromise(this.__deletePlanEntitlement(t,i))}async __deletePlanEntitlement(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i){return R.fromPromise(this.__upsertPlanEntitlementForBillingProduct(t,i))}async __upsertPlanEntitlementForBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Sn.jsonOrThrow(t,{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: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,"POST","/plan-entitlements/billing-linked")}countPlanEntitlements(t={},i){return R.fromPromise(this.__countPlanEntitlements(t,i))}async __countPlanEntitlements(t={},i){let{featureId:o,featureIds:s,ids:r,planId:a,planIds:u,planVersionId:g,planVersionIds:h,q:c,withMeteredProducts:y,limit:w,offset:U}=t,T={feature_id:o,feature_ids:s,ids:r,plan_id:a,plan_ids:u,plan_version_id:g,plan_version_ids:h,q:c,with_metered_products:y,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),j=f(O.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,"plan-entitlements/count"),method:"GET",headers:j,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(B.ok)return{data:tm.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","/plan-entitlements/count")}duplicatePlanEntitlements(t,i){return R.fromPromise(this.__duplicatePlanEntitlements(t,i))}async __duplicatePlanEntitlements(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:En.jsonOrThrow(t,{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: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 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(t,i){return R.fromPromise(this.__getFeatureUsageByCompany(t,i))}async __getFeatureUsageByCompany(t,i){let{keys:o}=t,s={keys:ve(o)},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:hm.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 ia=class{constructor(t){this._options=K(t)}createEventBatch(t,i){return R.fromPromise(this.__createEventBatch(t,i))}async __createEventBatch(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:vn.jsonOrThrow(t,{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:Km.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(t={},i){return R.fromPromise(this.__getEventSummaries(t,i))}async __getEventSummaries(t={},i){let{q:o,eventSubtypes:s,limit:r,offset:a}=t,u={q:o,event_subtypes:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Hm.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/event-types")}listEvents(t={},i){return R.fromPromise(this.__listEvents(t,i))}async __listEvents(t={},i){let{companyId:o,eventSubtype:s,eventTypes:r,flagId:a,idempotencyKey:u,userId:g,limit:h,offset:c}=t,y={company_id:o,event_subtype:s,event_types:Array.isArray(r)?r.map(O=>Pr.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"})):r!=null?Pr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,flag_id:a,idempotency_key:u,user_id:g,limit:h,offset:c},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:Zm.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(t,i){return R.fromPromise(this.__createEvent(t,i))}async __createEvent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:lo.jsonOrThrow(t,{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","/events")}getEvent(t,i){return R.fromPromise(this.__getEvent(t,i))}async __getEvent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:Wm.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(t){return R.fromPromise(this.__getSegmentIntegrationStatus(t))}async __getSegmentIntegrationStatus(t){let i=await this._options.authProvider.getAuthRequest(),o=f(i.headers,this._options?.headers,t?.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:o,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(s.ok)return{data:Jm.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 ta=class{constructor(t){this._options=K(t)}listFeatures(t={},i){return R.fromPromise(this.__listFeatures(t,i))}async __listFeatures(t={},i){let{booleanRequireEvent:o,featureType:s,ids:r,managedBy:a,planVersionId:u,q:g,withoutCompanyOverrideFor:h,withoutPlanEntitlementFor:c,limit:y,offset:w}=t,U={boolean_require_event:o,feature_type:Array.isArray(s)?s.map(B=>ce.jsonOrThrow(B,{unrecognizedObjectKeys:"strip"})):s!=null?ce.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:c,limit:y,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.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,"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(j.ok)return{data:wh.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","/features")}createFeature(t,i){return R.fromPromise(this.__createFeature(t,i))}async __createFeature(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:kn.jsonOrThrow(t,{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","/features")}getFeature(t,i){return R.fromPromise(this.__getFeature(t,i))}async __getFeature(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i={},o){return R.fromPromise(this.__updateFeature(t,i,o))}async __updateFeature(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Bn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Rh.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(t,i){return R.fromPromise(this.__deleteFeature(t,i))}async __deleteFeature(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:dh.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(t,i){return R.fromPromise(this.__upsertFeatureForBillingProduct(t,i))}async __upsertFeatureForBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:On.jsonOrThrow(t,{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:xh.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(t={},i){return R.fromPromise(this.__countFeatures(t,i))}async __countFeatures(t={},i){let{booleanRequireEvent:o,featureType:s,ids:r,managedBy:a,planVersionId:u,q:g,withoutCompanyOverrideFor:h,withoutPlanEntitlementFor:c,limit:y,offset:w}=t,U={boolean_require_event:o,feature_type:Array.isArray(s)?s.map(B=>ce.jsonOrThrow(B,{unrecognizedObjectKeys:"strip"})):s!=null?ce.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:c,limit:y,offset:w},T=await this._options.authProvider.getAuthRequest(),O=f(T.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,"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(j.ok)return{data:sh.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","/features/count")}listFlags(t={},i){return R.fromPromise(this.__listFlags(t,i))}async __listFlags(t={},i){let{featureId:o,ids:s,q:r,limit:a,offset:u}=t,g={feature_id:o,ids:s,q:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:zh.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(t,i){return R.fromPromise(this.__createFlag(t,i))}async __createFlag(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:es.jsonOrThrow(t,{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: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 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(t,i){return R.fromPromise(this.__getFlag(t,i))}async __getFlag(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i,o){return R.fromPromise(this.__updateFlag(t,i,o))}async __updateFlag(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:es.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:fh.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(t,i){return R.fromPromise(this.__deleteFlag(t,i))}async __deleteFlag(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:mh.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(t,i,o){return R.fromPromise(this.__updateFlagRules(t,i,o))}async __updateFlagRules(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/rules`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:jn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Ph.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(t,i,o){return R.fromPromise(this.__checkFlag(t,i,o))}async __checkFlag(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/check`),method:"POST",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:dt.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:eh.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(t,i){return R.fromPromise(this.__checkFlags(t,i))}async __checkFlags(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:dt.jsonOrThrow(t,{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","/flags/check")}checkFlagsBulk(t,i){return R.fromPromise(this.__checkFlagsBulk(t,i))}async __checkFlagsBulk(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Tn.jsonOrThrow(t,{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","/flags/check-bulk")}countFlags(t={},i){return R.fromPromise(this.__countFlags(t,i))}async __countFlags(t={},i){let{featureId:o,ids:s,q:r,limit:a,offset:u}=t,g={feature_id:o,ids:s,q:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:lh.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 oa=class{constructor(t){this._options=K(t)}getActivity(t={},i){return R.fromPromise(this.__getActivity(t,i))}async __getActivity(t={},i){let{limit:o}=t,s={limit:o},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:vh.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(t,i){return R.fromPromise(this.__getEnvironmentFeatureUsageTimeSeries(t,i))}async __getEnvironmentFeatureUsageTimeSeries(t,i){let{endTime:o,featureId:s,granularity:r,startTime:a}=t,u={end_time:o.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),c=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(c.ok)return{data:kh.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/insights/feature-usage-timeseries")}getPlanGrowth(t={},i){return R.fromPromise(this.__getPlanGrowth(t,i))}async __getPlanGrowth(t={},i){let{months:o}=t,s={months:o},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:Dh.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(t){return R.fromPromise(this.__getSummary(t))}async __getSummary(t){let i=await this._options.authProvider.getAuthRequest(),o=f(i.headers,this._options?.headers,t?.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:o,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(s.ok)return{data:Kh.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(t,i){return R.fromPromise(this.__getTopFeaturesByUsage(t,i))}async __getTopFeaturesByUsage(t,i){let{endTime:o,limit:s,startTime:r}=t,a={end_time:o.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:Nh.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(t,i){return R.fromPromise(this.__getEnvironmentTraitUsageTimeSeries(t,i))}async __getEnvironmentTraitUsageTimeSeries(t,i){let{endTime:o,featureId:s,granularity:r,startTime:a}=t,u={end_time:o.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),c=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(c.ok)return{data:Ah.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/insights/trait-usage-timeseries")}};var aa=class{constructor(t){this._options=K(t)}runIntegration(t,i){return R.fromPromise(this.__runIntegration(t,i))}async __runIntegration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t={},i){return R.fromPromise(this.__listIntegrations(t,i))}async __listIntegrations(t={},i){let{billingOnly:o,excludeIds:s,id:r,state:a,type:u,limit:g,offset:h}=t,c={billing_only:o,exclude_ids:s,id:r,state:a!=null?qe.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(c).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:sg.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(t,i){return R.fromPromise(this.__getIntegrationWebhookUrl(t,i))}async __getIntegrationWebhookUrl(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}/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: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 C(r.error,r.rawResponse,"GET","/integrations/{type}/webhook-url")}installIntegration(t,i){return R.fromPromise(this.__installIntegration(t,i))}async __installIntegration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Fo.jsonOrThrow(t,{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:tg.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(t,i){return R.fromPromise(this.__startDataImport(t,i))}async __startDataImport(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:An.jsonOrThrow(t,{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","/integrations/start-data-import")}loadSampleDataSet(t){return R.fromPromise(this.__loadSampleDataSet(t))}async __loadSampleDataSet(t){let i=await this._options.authProvider.getAuthRequest(),o=f(i.headers,this._options?.headers,t?.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:o,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(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","/integrations/stripe/dataset-sample-v2")}assumeStripeInstalled(t,i){return R.fromPromise(this.__assumeStripeInstalled(t,i))}async __assumeStripeInstalled(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Fo.jsonOrThrow(t,{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","/integrations/stripe/v2/assume-installed")}installStripe(t,i){return R.fromPromise(this.__installStripe(t,i))}async __installStripe(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Fo.jsonOrThrow(t,{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:og.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(t,i){return R.fromPromise(this.__uninstallIntegration(t,i))}async __uninstallIntegration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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,"DELETE","/integrations/uninstall/{integration_id}")}};var na=class{constructor(t){this._options=K(t)}createCustomPlanBundle(t,i){return R.fromPromise(this.__createCustomPlanBundle(t,i))}async __createCustomPlanBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Vn.jsonOrThrow(t,{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 C(r.error,r.rawResponse,"POST","/custom-plan-bundles")}createPlanBundle(t,i){return R.fromPromise(this.__createPlanBundle(t,i))}async __createPlanBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:qn.jsonOrThrow(t,{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:bg.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(t,i,o){return R.fromPromise(this.__updatePlanBundle(t,i,o))}async __updatePlanBundle(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Mn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(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 C(a.error,a.rawResponse,"PUT","/plan-bundles/{plan_bundle_id}")}};var sa=class{constructor(t){this._options=K(t)}getPlanGroup(t={},i){return R.fromPromise(this.__getPlanGroup(t,i))}async __getPlanGroup(t={},i){let{includeCompanyCounts:o}=t,s={include_company_counts:o},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:Cg.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(t,i){return R.fromPromise(this.__createPlanGroup(t,i))}async __createPlanGroup(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Dn.jsonOrThrow(t,{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 C(r.error,r.rawResponse,"POST","/plan-groups")}updatePlanGroup(t,i,o){return R.fromPromise(this.__updatePlanGroup(t,i,o))}async __updatePlanGroup(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:In.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(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 C(a.error,a.rawResponse,"PUT","/plan-groups/{plan_group_id}")}};var ca=class{constructor(t){this._options=K(t)}listCompanyMigrations(t={},i){return R.fromPromise(this.__listCompanyMigrations(t,i))}async __listCompanyMigrations(t={},i){let{migrationId:o,q:s,status:r,limit:a,offset:u}=t,g={migration_id:o,q:s,status:r!=null?Er.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:Vg.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(t,i){return R.fromPromise(this.__retryCompanyMigration(t,i))}async __retryCompanyMigration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}/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: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","/plan-version-company-migrations/{plan_version_company_migration_id}/retry")}countCompanyMigrations(t={},i){return R.fromPromise(this.__countCompanyMigrations(t,i))}async __countCompanyMigrations(t={},i){let{migrationId:o,q:s,status:r,limit:a,offset:u}=t,g={migration_id:o,q:s,status:r!=null?Er.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:Tg.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(t={},i){return R.fromPromise(this.__listMigrations(t,i))}async __listMigrations(t={},i){let{planVersionId:o,status:s,limit:r,offset:a}=t,u={plan_version_id:o,status:s!=null?Cr.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),c=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(c.ok)return{data:Mg.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/plan-version-migrations")}createMigration(t,i){return R.fromPromise(this.__createMigration(t,i))}async __createMigration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Kn.jsonOrThrow(t,{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:Bg.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(t,i){return R.fromPromise(this.__getMigration(t,i))}async __getMigration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:jg.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(t,i,o){return R.fromPromise(this.__retryMigration(t,i,o))}async __retryMigration(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/retry`),method:"POST",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Ln.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Ig.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(t={},i){return R.fromPromise(this.__countMigrations(t,i))}async __countMigrations(t={},i){let{planVersionId:o,status:s,limit:r,offset:a}=t,u={plan_version_id:o,status:s!=null?Cr.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),c=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(c.ok)return{data:kg.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/plan-version-migrations/count")}};var la=class{constructor(t){this._options=K(t)}updateCompanyPlans(t,i,o){return R.fromPromise(this.__updateCompanyPlans(t,i,o))}async __updateCompanyPlans(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:$n.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:ly.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(t={},i){return R.fromPromise(this.__listCustomPlanBillings(t,i))}async __listCustomPlanBillings(t={},i){let{companyId:o,planId:s,status:r,statuses:a,limit:u,offset:g}=t,h={company_id:o,plan_id:s,status:r!=null?Rr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,statuses:Array.isArray(a)?a.map(U=>Rr.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"})):a!=null?Rr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,limit:u,offset:g},c=await this._options.authProvider.getAuthRequest(),y=f(c.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:ry.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(t,i,o){return R.fromPromise(this.__markCustomPlanBillingPaid(t,i,o))}async __markCustomPlanBillingPaid(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/mark-paid`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Ay.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:ny.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(t,i,o){return R.fromPromise(this.__retryCustomPlanBilling(t,i,o))}async __retryCustomPlanBilling(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/retry`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Hn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:cy.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(t,i){return R.fromPromise(this.__createCustomPlan(t,i))}async __createCustomPlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Wn.jsonOrThrow(t,{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 C(r.error,r.rawResponse,"POST","/custom-plans")}listPlans(t={},i){return R.fromPromise(this.__listPlans(t,i))}async __listPlans(t={},i){let{companyId:o,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:u,forTrialExpiryPlan:g,hasProductId:h,ids:c,includeDraftVersions:y,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:j,withoutPaidProductId:B,limit:I,offset:A}=t,X={company_id:o,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:c,include_draft_versions:y,plan_type:w!=null?oe.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:j,without_paid_product_id:B,limit:I,offset:A},_e=await this._options.authProvider.getAuthRequest(),q=f(_e.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,"plans"),method:"GET",headers:q,queryString:d.queryBuilder().addMany(X).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:ay.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","/plans")}createPlan(t,i){return R.fromPromise(this.__createPlan(t,i))}async __createPlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:fo.jsonOrThrow(t,{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","/plans")}getPlan(t,i={},o){return R.fromPromise(this.__getPlan(t,i,o))}async __getPlan(t,i={},o){let{planVersionId:s}=i,r={plan_version_id:s},a=await this._options.authProvider.getAuthRequest(),u=f(a.headers,this._options?.headers,o?.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(t)}`),method:"GET",headers:u,queryString:d.queryBuilder().addMany(r).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(g.ok)return{data:Zg.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(t,i,o){return R.fromPromise(this.__updatePlan(t,i,o))}async __updatePlan(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Eo.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:py.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(t,i){return R.fromPromise(this.__deletePlan(t,i))}async __deletePlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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","/plans/{plan_id}")}upsertBillingProductPlan(t,i,o){return R.fromPromise(this.__upsertBillingProductPlan(t,i,o))}async __upsertBillingProductPlan(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/billing_products`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:$r.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(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","/plans/{plan_id}/billing_products")}upsertPlanForBillingProduct(t,i){return R.fromPromise(this.__upsertPlanForBillingProduct(t,i))}async __upsertPlanForBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Gn.jsonOrThrow(t,{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 C(r.error,r.rawResponse,"POST","/plans/billing-linked")}listBillingProductMatchCompanies(t,i){return R.fromPromise(this.__listBillingProductMatchCompanies(t,i))}async __listBillingProductMatchCompanies(t,i){let{planId:o,q:s,limit:r,offset:a}=t,u={plan_id:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Qg.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/plans/billing-product-match-companies")}countBillingProductMatchCompanies(t,i){return R.fromPromise(this.__countBillingProductMatchCompanies(t,i))}async __countBillingProductMatchCompanies(t,i){let{planId:o,q:s,limit:r,offset:a}=t,u={plan_id:o,q:s,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=f(g.headers,this._options?.headers,i?.headers),c=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(c.ok)return{data:Kg.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/plans/billing-product-match-companies/count")}countPlans(t={},i){return R.fromPromise(this.__countPlans(t,i))}async __countPlans(t={},i){let{companyId:o,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:a,forInitialPlan:u,forTrialExpiryPlan:g,hasProductId:h,ids:c,includeDraftVersions:y,planType:w,q:U,scopedToCompanyId:T,withEntitlements:O,withoutEntitlementFor:j,withoutPaidProductId:B,limit:I,offset:A}=t,X={company_id:o,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:c,include_draft_versions:y,plan_type:w!=null?oe.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,scoped_to_company_id:T,with_entitlements:O,without_entitlement_for:j,without_paid_product_id:B,limit:I,offset:A},_e=await this._options.authProvider.getAuthRequest(),q=f(_e.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,"plans/count"),method:"GET",headers:q,queryString:d.queryBuilder().addMany(X).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Gg.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","/plans/count")}listPlanIssues(t,i){return R.fromPromise(this.__listPlanIssues(t,i))}async __listPlanIssues(t,i){let{planId:o,planVersionId:s}=t,r={plan_id:o,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: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 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(t,i={},o){return R.fromPromise(this.__deletePlanVersion(t,i,o))}async __deletePlanVersion(t,i={},o){let{promoteArchivedVersion:s}=i,r={promote_archived_version:s},a=await this._options.authProvider.getAuthRequest(),u=f(a.headers,this._options?.headers,o?.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(t)}`),method:"DELETE",headers:u,queryString:d.queryBuilder().addMany(r).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(g.ok)return{data:Jg.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(t,i,o){return R.fromPromise(this.__publishPlanVersion(t,i,o))}async __publishPlanVersion(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}/publish`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Nn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:sy.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 pa=class{constructor(t){this._options=K(t)}listScheduledCheckouts(t={},i){return R.fromPromise(this.__listScheduledCheckouts(t,i))}async __listScheduledCheckouts(t={},i){let{companyId:o,status:s,limit:r,offset:a}=t,u={company_id:o,status:s!=null?Yr.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),c=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(c.ok)return{data:yy.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new v(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new x(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new P(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new b({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return C(c.error,c.rawResponse,"GET","/scheduled-checkout")}createScheduledCheckout(t,i){return R.fromPromise(this.__createScheduledCheckout(t,i))}async __createScheduledCheckout(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Jn.jsonOrThrow(t,{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: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","/scheduled-checkout")}getScheduledCheckout(t,i){return R.fromPromise(this.__getScheduledCheckout(t,i))}async __getScheduledCheckout(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i={},o){return R.fromPromise(this.__updateScheduledCheckout(t,i,o))}async __updateScheduledCheckout(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Yn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:wy.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 ua=class{constructor(t){this._options=K(t)}listWebhookEvents(t={},i){return R.fromPromise(this.__listWebhookEvents(t,i))}async __listWebhookEvents(t={},i){let{ids:o,q:s,webhookId:r,limit:a,offset:u}=t,g={ids:o,q:s,webhook_id:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:Uy.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(t,i){return R.fromPromise(this.__getWebhookEvent(t,i))}async __getWebhookEvent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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:xy.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(t={},i){return R.fromPromise(this.__countWebhookEvents(t,i))}async __countWebhookEvents(t={},i){let{ids:o,q:s,webhookId:r,limit:a,offset:u}=t,g={ids:o,q:s,webhook_id:r,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=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:c,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:zy.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(t={},i){return R.fromPromise(this.__listWebhooks(t,i))}async __listWebhooks(t={},i){let{q:o,limit:s,offset:r}=t,a={q:o,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:Ty.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(t,i){return R.fromPromise(this.__createWebhook(t,i))}async __createWebhook(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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:Zn.jsonOrThrow(t,{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","/webhooks")}getWebhook(t,i){return R.fromPromise(this.__getWebhook(t,i))}async __getWebhook(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 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(t,i={},o){return R.fromPromise(this.__updateWebhook(t,i,o))}async __updateWebhook(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=f(s.headers,this._options?.headers,o?.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(t)}`),method:"PUT",headers:r,contentType:"application/json",queryString:d.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:Xn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),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(a.ok)return{data:Oy.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(t,i){return R.fromPromise(this.__deleteWebhook(t,i))}async __deleteWebhook(t,i){let o=await this._options.authProvider.getAuthRequest(),s=f(o.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(t)}`),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: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 C(r.error,r.rawResponse,"DELETE","/webhooks/{webhook_id}")}countWebhooks(t={},i){return R.fromPromise(this.__countWebhooks(t,i))}async __countWebhooks(t={},i){let{q:o,limit:s,offset:r}=t,a={q:o,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:fy.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 da=class{constructor(t){this._options=K(t)}get accounts(){return this._accounts??=new Ho(this._options)}get billing(){return this._billing??=new $o(this._options)}get credits(){return this._credits??=new Qo(this._options)}get checkout(){return this._checkout??=new Jo(this._options)}get companies(){return this._companies??=new Yo(this._options)}get entitlements(){return this._entitlements??=new ra(this._options)}get plans(){return this._plans??=new la(this._options)}get components(){return this._components??=new Zo(this._options)}get planbundle(){return this._planbundle??=new na(this._options)}get dataexports(){return this._dataexports??=new ea(this._options)}get events(){return this._events??=new ia(this._options)}get features(){return this._features??=new ta(this._options)}get insights(){return this._insights??=new oa(this._options)}get integrationsapi(){return this._integrationsapi??=new aa(this._options)}get plangroups(){return this._plangroups??=new sa(this._options)}get planmigrations(){return this._planmigrations??=new ca(this._options)}get componentspublic(){return this._componentspublic??=new Xo(this._options)}get scheduledcheckout(){return this._scheduledcheckout??=new pa(this._options)}get accesstokens(){return this._accesstokens??=new No(this._options)}get webhooks(){return this._webhooks??=new ua(this._options)}getCreditLedger(t){return R.fromPromise(this.__getCreditLedger(t))}async __getCreditLedger(t){let i=await this._options.authProvider.getAuthRequest(),o=f(i.headers,this._options?.headers,t?.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:o,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(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(t,i,o){return ka(t,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},o)}};var er={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},ss={[er.Debug]:1,[er.Info]:2,[er.Warn]:3,[er.Error]:4},Ny=er.Warn,Qr=class{constructor(t=Ny){this.level=ss[t]??ss[Ny]}shouldLog(t){return ss[t]>=this.level}error(t,...i){this.shouldLog(er.Error)&&console.error(t,...i)}warn(t,...i){this.shouldLog(er.Warn)&&console.warn(t,...i)}info(t,...i){this.shouldLog(er.Info)&&console.info(t,...i)}debug(t,...i){this.shouldLog(er.Debug)&&console.debug(t,...i)}};var Oz=1e3,kz=1e3,Bz=3,jz=1e3,ma=class{constructor(t,i){this.events=[];this.intervalId=null;this.shutdown=!1;this.stopped=!1;this.flushing=!1;let{logger:o=new Qr,maxSize:s=kz,interval:r=Oz,offline:a=!1,maxRetries:u=Bz,initialRetryDelay:g=jz}=i||{};this.captureClient=t,this.interval=r,this.logger=o,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 t=[...this.events];this.events=[];let i=0,o=!1,s=null;for(;i<=this.maxRetries&&!o;)try{i>0&&this.logger.info(`Retrying event batch submission (attempt ${i} of ${this.maxRetries})`),await this.captureClient.sendBatch(t),o=!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))}}o?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(t){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(t)}}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 Az="https://c.schematichq.com",Vz=1e4,qz=p=>p.replace(/\/+$/,"")+"/batch",Mz=(p,t)=>{let i={api_key:t,type:p.eventType};return p.body!==void 0&&(i.body=co.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},Dz=(p,t)=>({events:p.map(i=>Mz(i,t))}),Iz=p=>{if(typeof p!="object"||p===null||!("reason"in p))return"unknown error";let t=p;switch(t.reason){case"status-code":{let i=typeof t.body=="string"?t.body:JSON.stringify(t.body??"");return`HTTP ${t.statusCode}: ${i}`}case"timeout":return"request timed out";case"non-json":return`non-JSON response (HTTP ${t.statusCode})`;case"body-is-null":return`empty response body (HTTP ${t.statusCode})`;default:return t.errorMessage??"unknown error"}},ha=class{constructor(t){this.apiKey=t.apiKey,this.baseUrl=t.baseUrl??Az,this.timeoutMs=t.timeoutMs??Vz,this.fetcher=t.fetcher,this.headers=t.headers??{}}async sendBatch(t){if(t.length===0)return;let i=await this.fetcher({url:qz(this.baseUrl),method:"POST",contentType:"application/json",requestType:"json",headers:{...this.headers,"X-Schematic-Api-Key":this.apiKey},body:Dz(t,this.apiKey),timeoutMs:this.timeoutMs,maxRetries:0});if(!i.ok)throw new Error(`capture service returned ${Iz(i.error)}`)}};function Hy(p){return async function(i){let o={};if(p&&Object.assign(o,p),i.body!==void 0&&i.contentType!=null&&(o["Content-Type"]=i.contentType),i.headers!=null)for(let[u,g]of Object.entries(i.headers))g!=null&&typeof g=="string"&&(o[u]=g);let s=i.queryString!=null&&i.queryString.length>0?`${i.url}?${i.queryString}`:Pt(i.url,i.queryParameters),r=await xt({body:i.body,type:i.requestType==="json"?"json":"other"}),a=await pi();try{let u=await hi(async()=>ui(a,s,i.method,o,r,i.timeoutMs,i.abortSignal,i.withCredentials,i.duplex),i.maxRetries),g=await li(u,i.responseType),h=ot(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:di}:u instanceof Error&&u.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:di}:u instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:u.message},rawResponse:mi}:{ok:!1,error:{reason:"unknown",errorMessage:JSON.stringify(u)},rawResponse:mi}}}}async function Fz(p){return{ok:!0,body:{},headers:{"Content-Type":"application/json"},rawResponse:{headers:new ir,redirected:!1,status:200,statusText:"OK",type:"basic",url:""}}}var $y=Fz;var Yi=class{constructor(){this.wasmInstance=null;this.initialized=!1}async initialize(){if(!this.initialized)try{let t=await import("./wasm/rulesengine.js"),i=t.RulesEngineJS?t:t.default??t;this.wasmInstance=new i.RulesEngineJS,this.initialized=!0}catch(t){throw new Error(`Failed to initialize WASM rules engine: ${t}`)}}async checkFlag(t,i,o){return this.checkFlagWithOptions(t,i,o)}async checkFlagWithOptions(t,i,o,s){this.ensureInitialized();let r=(a,u)=>u===null?void 0:u;try{let a=JSON.stringify(t,r),u=i?JSON.stringify(i,r):void 0,g=o?JSON.stringify(o,r):void 0,h=s?JSON.stringify(Kz(s),r):void 0,c=this.wasmInstance.checkFlagWithOptions(a,u,g,h);return JSON.parse(c)}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 Kz(p){let t={};return p.creditCost&&Object.keys(p.creditCost).length>0&&(t.credit_cost=p.creditCost),p.usage!==void 0&&(t.usage=p.usage),p.eventUsage&&(t.event_usage={event_subtype:p.eventUsage.eventSubtype,quantity:p.eventUsage.quantity}),t}cs();var Lz={unrecognizedObjectKeys:"passthrough"};function Jy(p,t){let i=p.parse(t,Lz);return i.ok?i.value:t}function ps(p){return JSON.parse(JSON.stringify(p))}function Gz(p){return JSON.parse(JSON.stringify(p))}function Yy(p,t){let i=ps(p),o,s=!1;for(let r of Object.keys(t))switch(r){case"id":i.id=t[r];break;case"account_id":i.accountId=t[r];break;case"environment_id":i.environmentId=t[r];break;case"base_plan_id":i.basePlanId=t[r]??null;break;case"billing_product_ids":i.billingProductIds=t[r];break;case"plan_ids":i.planIds=t[r];break;case"plan_version_ids":i.planVersionIds=t[r];break;case"entitlements":{let a=t[r]??[];i.entitlements=a.map(u=>Jy(Ko,u));break}case"rules":i.rules=t[r];break;case"traits":i.traits=t[r];break;case"subscription":i.subscription=t[r];break;case"keys":{let a=i.keys??{},u=t[r];i.keys={...a,...u};break}case"credit_balances":{let a=i.creditBalances??{},u=t[r]??{};i.creditBalances={...a,...u},o=u;break}case"metrics":{let a=i.metrics??[],u=(t[r]??[]).map(g=>Jy(Lo,g));i.metrics=Nz(a,u),s=!0;break}}return(o||s)&&!("entitlements"in t)&&Wz(i,o,s),i}function Wz(p,t,i){let o=p.entitlements??[];if(o.length===0)return;let s=new Map;if(i){let r=p.metrics??[];for(let a of r)a&&s.set(ga(ls(a)),a.value??0)}for(let r of o){let a=r.creditId??r.credit_id;t&&a&&a in t&&(r.creditRemaining=t[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",c=s.get(ga({eventSubtype:u,period:g,monthReset:h}));c!==void 0&&(r.usage=c)}}}function Zy(p,t){let i=Gz(p);for(let o of Object.keys(t))switch(o){case"id":i.id=t[o];break;case"account_id":i.accountId=t[o];break;case"environment_id":i.environmentId=t[o];break;case"keys":{let s=i.keys??{},r=t[o];i.keys={...s,...r};break}case"traits":i.traits=t[o];break;case"rules":i.rules=t[o];break}return i}function ga(p){return`${p.eventSubtype}|${p.period}|${p.monthReset}`}function ls(p){return{eventSubtype:(p.eventSubtype??p.event_subtype)||"",period:p.period||"",monthReset:(p.monthReset??p.month_reset)||""}}function Nz(p,t){let i=[...p],o=new Map;for(let s=0;s<i.length;s++){let r=i[s];if(r){let a=ga(ls(r));o.set(a,s)}}for(let s of t){if(!s)continue;let r=ga(ls(s)),a=o.get(r);a!==void 0?i[a]=s:i.push(s)}return i}var ur="company",dr="user",eR="flags",ds=30*1e3,rR=1440*60*1e3,iR=720*60*60*1e3,ht=class extends Zi{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??rR,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 Yi}createCacheProvider(i,o){let s;switch(o){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 ${o} cache`),s;let r=this.calculateCacheTTL(o);return i.redisClient?(this.logger.debug(`Using Redis cache provider for ${o} cache (TTL: ${r}ms)`),new ri({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:r})):(this.logger.debug(`Using memory cache provider for ${o} cache (TTL: ${r}ms)`),new rr({ttl:r}))}createKeyCacheProvider(i){let o=this.cacheTTL;return i.redisClient?new ri({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:o}):new rr({ttl:o})}calculateCacheTTL(i){return i==="flag"?Math.max(iR,this.cacheTTL):this.cacheTTL}async start(){try{await this.rulesEngine.initialize(),this.logger.debug("Rules engine initialized successfully")}catch(o){this.logger.warn(`Failed to initialize rules engine: ${o}`)}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}=(nw(),bs(aw));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",o=>{this.emit("error",o)}),this.wsClient.start()}isConnected(){return this.replicatorMode?this.isReplicatorReady():this.wsClient?.isConnected()??!1}async getCompany(i){let o=await this.getCompanyFromCache(i);if(o)return this.logger.debug(`Company found in cache for keys: ${JSON.stringify(i)}`),o;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"))},ds),h=c=>{clearTimeout(g),c?a(c):u(new Error("Company not found"))};for(let c of s)this.pendingCompanyRequests.has(c)||this.pendingCompanyRequests.set(c,[]),this.pendingCompanyRequests.get(c).push(h);r||this.sendDataStreamRequest({entity_type:"rulesengine.Company",keys:i}).catch(c=>{this.cleanupPendingCompanyRequests(s,h),u(c)})})}async getUser(i){let o=await this.getUserFromCache(i);if(o)return this.logger.debug(`User found in cache for keys: ${JSON.stringify(i)}`),o;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"))},ds),h=c=>{clearTimeout(g),c?a(c):u(new Error("User not found"))};for(let c of s)this.pendingUserRequests.has(c)||this.pendingUserRequests.set(c,[]),this.pendingUserRequests.get(c).push(h);r||this.sendDataStreamRequest({entity_type:"rulesengine.User",keys:i}).catch(c=>{this.cleanupPendingUserRequests(s,h),u(c)})})}async getFlag(i){let o=this.flagCacheKey(i);this.logger.debug(`Retrieving flag from cache: ${i} (cache key: ${o})`);try{return await this.flagsCacheProvider.get(o)||null}catch(s){return this.logger.warn(`Failed to retrieve flag from cache: ${s}`),null}}async getAllFlags(){return this.pendingFlagRequest?new Promise((i,o)=>{let s=this.pendingFlagRequest;this.pendingFlagRequest=r=>{s(r),r?i():o(new Error("Failed to refresh flags"))}}):new Promise((i,o)=>{let s=setTimeout(()=>{this.pendingFlagRequest=void 0,o(new Error("Timeout while waiting for flags data"))},ds);this.pendingFlagRequest=r=>{clearTimeout(s),this.pendingFlagRequest=void 0,r?i():o(new Error("Failed to refresh flags"))},this.sendDataStreamRequest({entity_type:"rulesengine.Flags"}).catch(r=>{clearTimeout(s),this.pendingFlagRequest=void 0,o(r)})})}async checkFlag(i,o,s){let r=await this.getFlag(o);if(!r)throw new Error(`Flag not found: ${o}`);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 ${o} evaluation`),this.evaluateFlag(r,g,h,s);if(!this.isConnected())throw new Error("Datastream not connected and required entities not in cache");let c=a&&!g?this.getCompany(i.company):Promise.resolve(g),y=u&&!h?this.getUser(i.user):Promise.resolve(h),[w,U]=await Promise.all([c,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,o,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)===o&&(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 o=new AbortController,s=setTimeout(()=>o.abort(),i),r=await fetch(this.replicatorHealthURL,{method:"GET",signal:o.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(o){this.logger.debug(`Failed to fetch replicator cache version: ${o}`)}}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(o){this.logger.error(`Error processing datastream message: ${o}`),this.emit("error",o)}}async handleCompanyMessage(i){let o;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(ur,s),a=await this.companyCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial company '${s}', skipping`);return}try{o=Yy(a,i.data)}catch(u){this.logger.error(`Failed to merge partial company: ${u}`);return}}else try{o=Gy.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize company payload: ${s}`);return}if(o){if(i.message_type==="delete"){if(o.keys)for(let[r,a]of Object.entries(o.keys)){let u=this.resourceKeyToCacheKey(ur,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(ur,o.id);try{await this.companyCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete company resource from cache: ${r}`)}return}await this.cacheCompanyForKeys(o),this.notifyPendingCompanyRequests(o.keys||{},o)}}async handleUserMessage(i){let o;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(dr,s),a=await this.userCacheProvider.get(r);if(!a){this.logger.warn(`Cache miss for partial user '${s}', skipping`);return}try{o=Zy(a,i.data)}catch(u){this.logger.error(`Failed to merge partial user: ${u}`);return}}else try{o=Wy.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(s){this.logger.warn(`Failed to deserialize user payload: ${s}`);return}if(o){if(i.message_type==="delete"){if(o.keys)for(let[r,a]of Object.entries(o.keys)){let u=this.resourceKeyToCacheKey(dr,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(dr,o.id);try{await this.userCacheProvider.delete(s)}catch(r){this.logger.warn(`Failed to delete user resource from cache: ${r}`)}return}await this.cacheUserForKeys(o),this.notifyPendingUserRequests(o.keys||{},o)}}async handleFlagsMessage(i){let o=i.data;if(!Array.isArray(o)){this.logger.warn("Expected flags array in bulk flags message");return}let s=[],r=0,a;for(let c of o)try{s.push(ts.parseOrThrow(c,{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(c=>c?.key).map(async c=>{let y=this.flagCacheKey(c.key);return await this.flagsCacheProvider.set(y,c),y})),g=u.filter(c=>c.status==="fulfilled").map(c=>c.value),h=u.filter(c=>c.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(c){this.logger.warn(`Failed to delete missing flags: ${c}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleFlagMessage(i){let o;try{o=ts.parseOrThrow(i.data,{unrecognizedObjectKeys:"passthrough"})}catch(r){this.logger.warn(`Failed to deserialize flag payload: ${r}`);return}if(!o?.key)return;let s=this.flagCacheKey(o.key);try{switch(i.message_type){case"delete":await this.flagsCacheProvider.delete(s);break;case"full":await this.flagsCacheProvider.set(s,o);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 o=i.data;if(o?.keys&&o?.entity_type)switch(o.entity_type){case"rulesengine.Company":this.notifyPendingCompanyRequests(o.keys,null);break;case"rulesengine.User":this.notifyPendingUserRequests(o.keys,null);break;default:this.logger.warn(`Received error for unsupported entity type: ${o.entity_type}`)}let s=o?.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 o={data:i};await this.wsClient.sendMessage(o)}async getCompanyFromCache(i){for(let[o,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(ur,o,s);try{let a=await this.companyKeyCacheProvider.get(r);if(a){let u=this.resourceIdCacheKey(ur,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[o,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(dr,o,s);try{let a=await this.userKeyCacheProvider.get(r);if(a){let u=this.resourceIdCacheKey(dr,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 o=this.resourceIdCacheKey(ur,i.id),s=await this.companyCacheProvider.get(o);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(ur,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(o,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let u=this.resourceKeyToCacheKey(ur,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 o=this.resourceIdCacheKey(dr,i.id),s=await this.userCacheProvider.get(o);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(dr,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(o,i,this.cacheTTL);for(let[r,a]of Object.entries(i.keys)){let u=this.resourceKeyToCacheKey(dr,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(([o,s])=>this.resourceKeyToCacheKey(ur,o,s))}generateCacheKeysForUser(i){return Object.entries(i).map(([o,s])=>this.resourceKeyToCacheKey(dr,o,s))}notifyPendingCompanyRequests(i,o){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(ur,s,r),u=this.pendingCompanyRequests.get(a);u&&(this.pendingCompanyRequests.delete(a),u.forEach(g=>{try{g(o)}catch(h){this.logger.error(`Error in company request handler: ${h}`)}}))}}notifyPendingUserRequests(i,o){for(let[s,r]of Object.entries(i)){let a=this.resourceKeyToCacheKey(dr,s,r),u=this.pendingUserRequests.get(a);u&&(this.pendingUserRequests.delete(a),u.forEach(g=>{try{g(o)}catch(h){this.logger.error(`Error in user request handler: ${h}`)}}))}}cleanupPendingCompanyRequests(i,o){for(let s of i){let r=this.pendingCompanyRequests.get(s);if(r){let a=r.indexOf(o);a!==-1&&r.splice(a,1),r.length===0&&this.pendingCompanyRequests.delete(s)}}}cleanupPendingUserRequests(i,o){for(let s of i){let r=this.pendingUserRequests.get(s);if(r){let a=r.indexOf(o);a!==-1&&r.splice(a,1),r.length===0&&this.pendingUserRequests.delete(s)}}}clearPendingRequests(){for(let[,i]of this.pendingCompanyRequests)i.forEach(o=>{try{o(null)}catch(s){this.logger.error(`Error clearing company request: ${s}`)}});this.pendingCompanyRequests.clear();for(let[,i]of this.pendingUserRequests)i.forEach(o=>{try{o(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,o=setTimeout(()=>i.abort(),5e3),s=await fetch(this.replicatorHealthURL,{method:"GET",signal:i.signal});if(clearTimeout(o),!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 o=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey(),s=`${eR}:${o}:${i.toLowerCase()}`;return this.logger.debug(`Generated flag cache key - flag: ${i}, mode: ${this.replicatorMode?"replicator":"datastream"}, version: ${o}, cacheKey: ${s}`),s}resourceIdCacheKey(i,o){let s=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${s}:${o}`}resourceKeyToCacheKey(i,o,s){let r=this.replicatorMode&&this.replicatorCacheVersion?this.replicatorCacheVersion:this.getRulesEngineVersionKey();return`${i}:${r}:${o.toLowerCase()}:${s.toLowerCase()}`}deepCopyCompany(i){return ps(i)}async evaluateFlag(i,o,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:o?.id,userId:s?.id})}`);let u=await this.rulesEngine.checkFlagWithOptions(i,o,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:o?.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:o?.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:o?.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 $e(p,t){return`${p}:${t}`}var gt=class{constructor(){this.leases=new Map;this.locks=new Map}get(t,i){let o=this.leases.get($e(t,i));return o?{...o}:void 0}async replace(t){let i=$e(t.companyId,t.creditTypeId);return this.withLock(i,()=>{let o=this.leases.get(i);return o&&o.expiresAt.getTime()>Date.now()?!1:(this.leases.set(i,{...t,localRemainingCredits:t.grantedAmount}),!0)})}async extend(t,i,o,s,r){let a=$e(t,i);return this.withLock(a,()=>{let u=this.leases.get(a);if(!u||r!==void 0&&u.leaseId!==r)return;let g=o-u.grantedAmount;g>0&&(u.grantedAmount=o,u.localRemainingCredits+=g),s&&s.getTime()>u.expiresAt.getTime()&&(u.expiresAt=s)})}async drop(t,i){let o=$e(t,i);return this.withLock(o,()=>{this.leases.delete(o)})}async tryReserve(t,i,o){if(!Number.isFinite(o)||o<0)return null;let s=$e(t,i);return this.withLock(s,()=>{let r=this.leases.get(s);return!r||r.expiresAt.getTime()<=Date.now()||r.localRemainingCredits<o?null:(r.localRemainingCredits-=o,r.localRemainingCredits)})}async refund(t,i,o,s){if(o<=0)return;let r=$e(t,i);return this.withLock(r,()=>{let a=this.leases.get(r);a&&(s!==void 0&&a.leaseId!==s||(a.localRemainingCredits=Math.min(a.localRemainingCredits+o,a.grantedAmount)))})}list(){return Array.from(this.leases.values(),t=>({...t}))}async withLock(t,i){let o=this.locks.get(t)??Promise.resolve(),s,r=new Promise(u=>s=u),a=o.then(()=>r);this.locks.set(t,a),await o;try{return await i()}finally{s(),this.locks.get(t)===a&&this.locks.delete(t)}}};var yt=class{constructor(t,i=1e3){this.leaseStore=t;this.sweepIntervalMs=i;this.reservations=new Map;this.sweepInterval=null;this.stopped=!1}add(t){this.reservations.set(t.id,t)}get(t){return this.reservations.get(t)}reservedCredits(t,i){let o=0;for(let s of this.reservations.values())s.companyId===t&&s.creditTypeId===i&&(o+=s.creditsReserved);return o}async consume(t,i){let o=this.reservations.get(t);if(!o)return null;this.reservations.delete(t);let s=Math.max(0,Math.min(i,o.creditsReserved)),r=o.creditsReserved-s;return r>0&&await this.leaseStore.refund(o.companyId,o.creditTypeId,r,o.leaseId),s}startSweep(){this.sweepInterval||this.stopped||(this.sweepInterval=setInterval(()=>{this.sweepExpired().catch(()=>{})},this.sweepIntervalMs),this.sweepInterval.unref&&this.sweepInterval.unref())}async sweepExpired(t=new Date){let i=0;for(let[o,s]of this.reservations)s.expiresAt.getTime()<=t.getTime()&&(this.reservations.delete(o),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 wt=class{constructor(t){this.inflightAcquire=new Map;this.inflightExtend=new Map;this.creditsClient=t.creditsClient,this.leaseStore=t.leaseStore,this.logger=t.logger,this.config=t.config}resolveConfig(t){let i=this.config.overrides?.[t];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(t,i,o){let s;try{s=await this.leaseStore.get(t,i)}catch(g){this.logger.error(`Failed to read lease store for ${t}/${i}: ${g}`);return}if(s&&s.expiresAt.getTime()>Date.now())return s;let r=$e(t,i),a=this.inflightAcquire.get(r);if(a)return a;let u=this.acquire(t,i,o).finally(()=>{this.inflightAcquire.delete(r)});return this.inflightAcquire.set(r,u),u}async acquire(t,i,o){let s=this.resolveConfig(i),r={companyId:t,creditTypeId:i,requestedAmount:s.leaseSize,expiresAt:new Date(Date.now()+s.leaseDuration)};try{let u=(await this.creditsClient.acquireCreditLease(r,o)).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 ${t}/${i} (granted=${u.grantedAmount}, expires=${u.expiresAt.toISOString()})`);else{let h=await this.leaseStore.get(t,i);return h&&h.leaseId!==u.id?(this.logger.debug(`Lost acquire race for ${t}/${i}; releasing redundant lease ${u.id}`),this.creditsClient.releaseCreditLease(u.id,{}).catch(c=>this.logger.warn(`Failed to release redundant credit lease ${u.id}: ${c}`))):this.logger.debug(`Lost acquire race for ${t}/${i}; server returned the installed lease ${u.id}, nothing to release`),h}return await this.leaseStore.get(t,i)}catch(a){this.logger.error(`Failed to acquire credit lease for ${t}/${i}: ${a}`);return}}async maybeExtendInBackground(t,i,o,s){let r;try{r=await this.leaseStore.get(t,i)}catch(U){this.logger.warn(`Failed to read lease store for ${t}/${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=o!==void 0&&r.localRemainingCredits<o;if(!g&&!h)return r;let c=$e(t,i),y=this.inflightExtend.get(c);if(y)return y;let w=this.extend(r,a,o,s).finally(()=>{this.inflightExtend.delete(c)});return this.inflightExtend.set(c,w),w}async extend(t,i,o,s){let r=o!==void 0?o-t.localRemainingCredits:0,a={additionalAmount:Math.max(i.leaseSize,r),expiresAt:new Date(Date.now()+i.leaseDuration)};try{let g=(await this.creditsClient.extendCreditLease(t.leaseId,a,s)).data;return await this.leaseStore.extend(t.companyId,t.creditTypeId,g.grantedAmount,g.expiresAt,t.leaseId),this.logger.debug(`Extended credit lease ${t.leaseId} to ${g.grantedAmount} (was ${t.grantedAmount} at last read, expires ${g.expiresAt.toISOString()})`),await this.leaseStore.get(t.companyId,t.creditTypeId)}catch(u){this.logger.warn(`Failed to extend credit lease ${t.leaseId}: ${u}`);return}}async releaseAllLocalLeases(){let t=this.leaseStore.list?.();!t||t.length===0||await Promise.all(t.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(o){this.logger.warn(`Failed to release credit lease ${i.leaseId} on close (it will expire server-side): ${o}`)}}))}};var oR="schematic:",aR="credit-lease:",sw=6e4,cw=`
1
+ "use strict";var Tw=Object.create;var fo=Object.defineProperty;var Ow=Object.getOwnPropertyDescriptor;var kw=Object.getOwnPropertyNames;var Bw=Object.getPrototypeOf,jw=Object.prototype.hasOwnProperty;var ni=(p,o)=>()=>(p&&(o=p(p=0)),o);var Aw=(p,o)=>()=>(o||p((o={exports:{}}).exports,o),o.exports),yr=(p,o)=>{for(var i in o)fo(p,i,{get:o[i],enumerable:!0})},bs=(p,o,i,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of kw(o))!jw.call(p,s)&&s!==i&&fo(p,s,{get:()=>o[s],enumerable:!(t=Ow(o,s))||t.enumerable});return p};var Zi=(p,o,i)=>(i=p!=null?Tw(Bw(p)):{},bs(o||!p||!p.__esModule?fo(i,"default",{value:p,enumerable:!0}):i,p)),zs=p=>bs(fo({},"__esModule",{value:!0}),p);var Ks={};yr(Ks,{Node18UniversalStreamWrapper:()=>xa});var xa,Ls=ni(()=>{"use strict";xa=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 Gs={};yr(Gs,{UndiciStreamWrapper:()=>Ea});var Ea,Ws=ni(()=>{"use strict";Ea=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 Ns={};yr(Ns,{NodePre18StreamWrapper:()=>Ca});var Ca,Hs=ni(()=>{"use strict";Ca=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 Yi,ss=ni(()=>{"use strict";Yi=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 aw=Aw((Fre,Qz)=>{Qz.exports={name:"@schematichq/schematic-typescript-node",version:"1.5.2",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 nw,sw,cw,lw=ni(()=>{"use strict";nw=aw(),sw=nw.name,cw=nw.version});var dw={};yr(dw,{DatastreamWSClient:()=>ps});function aR(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 pw,eR,uw,rR,iR,oR,tR,ps,mw=ni(()=>{"use strict";pw=Zi(require("ws"));lw();ss();eR=10*1e3,uw=60*1e3,rR=uw*9/10,iR=10,oR=1*1e3,tR=30*1e3;ps=class extends Yi{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=aR(i.url):this.url=i.url,this.headers={"X-Schematic-Api-Key":i.apiKey,"X-Schematic-Client":sw,"X-Schematic-Client-Version":cw,"X-Schematic-Datastream-Mode":"datastream"},this.logger=i.logger,this.messageHandler=i.messageHandler,this.connectionReadyHandler=i.connectionReadyHandler,this.maxReconnectAttempts=i.maxReconnectAttempts??iR,this.minReconnectDelay=i.minReconnectDelay??oR,this.maxReconnectDelay=i.maxReconnectDelay??tR}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"))},eR);try{this.ws.send(JSON.stringify(i),n=>{clearTimeout(r),n?s(n):t()})}catch(n){clearTimeout(r),s(n)}})}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=n=>{this.logger.error(`WebSocket error: ${n.message}`),this.emit("error",n),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 pw.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",n=>{clearTimeout(r),t(n)})})}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()},rR),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()},uw),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 BR={};yr(BR,{ConsoleLogger:()=>Xr,LocalCache:()=>er,LogLevel:()=>Qe,RedisCacheProvider:()=>ri,RulesEngineClient:()=>Ji,Schematic:()=>te,SchematicClient:()=>ba,SchematicEnvironment:()=>z,SchematicError:()=>b,SchematicTimeoutError:()=>ei,WEBHOOK_SIGNATURE_HEADER:()=>hs,WEBHOOK_TIMESTAMP_HEADER:()=>gs,WebhookSignatureError:()=>mr,computeHexSignature:()=>Ew,computeSignature:()=>Ra,verifySignature:()=>ys,verifyWebhookSignature:()=>Cw});module.exports=zs(BR);var te={};yr(te,{AccountMemberPermission:()=>qw,AccountMemberRole:()=>Dw,ActorType:()=>Mw,ApiKeyScope:()=>Iw,BadRequestError:()=>v,BillingCreditBundleStatus:()=>Fw,BillingCreditBurnStrategy:()=>Kw,BillingCreditExpiryType:()=>Lw,BillingCreditExpiryUnit:()=>Gw,BillingCreditGrantReason:()=>Ww,BillingCreditGrantZeroedOutReason:()=>Nw,BillingCreditLedgerAuthority:()=>Hw,BillingCreditRolloverPolicy:()=>$w,BillingPlanCreditGrantResetCadence:()=>Jw,BillingPlanCreditGrantResetStart:()=>Yw,BillingPlanCreditGrantResetType:()=>Zw,BillingPriceScheme:()=>Xw,BillingPriceUsageType:()=>Qw,BillingProductPriceInterval:()=>eb,BillingProviderType:()=>rb,BillingStrategy:()=>ib,BillingSubscriptionTrialEndSetting:()=>ob,BillingTiersMode:()=>tb,ChargeType:()=>ab,CompanyMatchingCriteria:()=>nb,CompanyPlanInvalidReason:()=>sb,ComparableOperator:()=>cb,ComponentEntityType:()=>lb,ComponentState:()=>pb,ConditionType:()=>ub,CreditEventType:()=>db,CreditGrantSortOrder:()=>mb,CreditUsageReason:()=>hb,CustomPlanActivationStrategy:()=>gb,CustomPlanBillingStatus:()=>yb,DataExportStatus:()=>wb,EntitlementPriceBehavior:()=>bb,EntitlementType:()=>zb,EntitlementValueType:()=>Rb,EntityType:()=>fb,EnvironmentType:()=>_b,EventStatus:()=>Sb,EventType:()=>_o,FeatureLifecyclePhase:()=>Pb,FeatureType:()=>xb,ForbiddenError:()=>_,IntegrationState:()=>Eb,IntegrationType:()=>Cb,InternalServerError:()=>S,InvoiceStatus:()=>Ub,MetricPeriod:()=>vb,MetricPeriodMonthReset:()=>Tb,MigrationErrorCode:()=>Ob,NotFoundError:()=>P,PlanBundleAction:()=>kb,PlanChangeAction:()=>Bb,PlanChangeBasePlanAction:()=>jb,PlanChangeSubscriptionAction:()=>Ab,PlanIcon:()=>Vb,PlanPriceCadence:()=>qb,PlanType:()=>Db,PlanVersionCompanyMigrationStatus:()=>Mb,PlanVersionMigrationStatus:()=>Ib,PlanVersionMigrationStrategy:()=>Fb,PlanVersionStatus:()=>Kb,ProrationBehavior:()=>Lb,RuleType:()=>Zb,RulesEngineSchemaVersion:()=>Gb,RulesengineConditionType:()=>Wb,RulesengineEntitlementValueType:()=>fa,RulesengineEntityType:()=>Nb,RulesengineMetricPeriod:()=>Hb,RulesengineMetricPeriodMonthReset:()=>$b,RulesengineRuleType:()=>Jb,RulesengineTraitDefinitionComparableType:()=>Yb,ScheduledCheckoutStatus:()=>Xb,ScheduledDowngradeConfigBehavior:()=>Qb,SortDirection:()=>ez,SubscriptionStatus:()=>rz,SubscriptionType:()=>iz,TimeSeriesGranularity:()=>oz,TraitDefinitionComparableType:()=>tz,TraitType:()=>az,TrialStatus:()=>nz,UnauthorizedError:()=>x,WebhookEventStatus:()=>sz,WebhookRequestType:()=>cz,WebhookStatus:()=>lz,accesstokens:()=>Rs,accounts:()=>fs,billing:()=>_s,checkout:()=>Ss,companies:()=>Ps,components:()=>xs,componentspublic:()=>Es,credits:()=>Cs,dataexports:()=>Us,entitlements:()=>vs,events:()=>Ts,features:()=>Os,insights:()=>ks,integrationsapi:()=>Bs,planbundle:()=>js,plangroups:()=>As,planmigrations:()=>Vs,plans:()=>qs,scheduledcheckout:()=>Ds,webhooks:()=>Ms});var Ue=(p,o,i)=>JSON.stringify(p,o,i);function Xi(p,o){return JSON.parse(p,o)}var b=class extends Error{constructor({message:o,statusCode:i,body:t,rawResponse:s,cause:r}){super(Vw({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 Vw({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: ${Ue(i,void 0,2)}`),t.join(`
2
+ `)}var ei=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 Rs={};var fs={};var _s={};var Ss={};var Ps={};var xs={};var Es={};var Cs={};var Us={};var vs={};var Ts={};var Os={};var ks={};var Bs={};var js={};var As={};var Vs={};var qs={};var Ds={};var Ms={};var qw={CompaniesEdit:"companies_edit",CompanyUsersEdit:"company_users_edit",ComponentsEdit:"components_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 Dw={Admin:"admin",Member:"member"};var Mw={ApiKey:"api_key",AppUser:"app_user",StripeApp:"stripe_app",System:"system",TemporaryAccessToken:"temporary_access_token"};var Iw={Admin:"admin",Capture:"capture",Read:"read",Write:"write"};var Fw={Active:"active",Inactive:"inactive"};var Kw={ExpirationPriority:"expiration_priority",FirstInFirstOut:"first_in_first_out",LastInFirstOut:"last_in_first_out",PlanFirstThenCreditBundlesFirstInFirstOut:"plan_first_then_credit_bundles_first_in_first_out"};var Lw={Duration:"duration",EndOfBillingPeriod:"end_of_billing_period",EndOfNextBillingPeriod:"end_of_next_billing_period",EndOfTrial:"end_of_trial",NoExpiry:"no_expiry"};var Gw={BillingPeriods:"billing_periods",Days:"days"};var Ww={Adjustment:"adjustment",BillingCreditAutoTopup:"billing_credit_auto_topup",Free:"free",Plan:"plan",Purchased:"purchased",Rollover:"rollover"};var Nw={Expired:"expired",Manual:"manual",PlanChange:"plan_change",PlanPeriodReset:"plan_period_reset",Reconciled:"reconciled"};var Hw={SchematicAuthoritative:"schematic_authoritative",ExternalMirror:"external_mirror",ExternalRated:"external_rated"};var $w={Expire:"expire",None:"none",Rollover:"rollover"};var Jw={Daily:"daily",Monthly:"monthly",Weekly:"weekly",Yearly:"yearly"};var Yw={BillingPeriod:"billing_period",FirstOfMonth:"first_of_month"};var Zw={NoReset:"no_reset",PlanPeriod:"plan_period"};var Xw={PerUnit:"per_unit",Tiered:"tiered"};var Qw={Licensed:"licensed",Metered:"metered"};var eb={Day:"day",Month:"month",OneTime:"one-time",Year:"year"};var rb={Metronome:"metronome",Orb:"orb",Schematic:"schematic",Stripe:"stripe"};var ib={SchematicManaged:"schematic_managed",ProviderManaged:"provider_managed",NoBilling:"no_billing"};var ob={Cancel:"cancel",Subscribe:"subscribe"};var tb={Graduated:"graduated",Volume:"volume"};var ab={Free:"free",None:"none",OneTime:"one_time",Recurring:"recurring"};var nb={BillingMetaObject:"billing_meta_object",ManualUpsert:"manual_upsert"};var sb={DowngradeNotPermitted:"downgrade_not_permitted",FeatureUsageExceeded:"feature_usage_exceeded"};var cb={Eq:"eq",Gt:"gt",Gte:"gte",IsEmpty:"is_empty",Lt:"lt",Lte:"lte",NotEmpty:"not_empty",Ne:"ne"};var lb={Billing:"billing",Entitlement:"entitlement"};var pb={Draft:"draft",Live:"live"};var ub={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var db={Grant:"grant",Transfer:"transfer",Usage:"usage",ZeroOut:"zero_out"};var mb={CreatedAt:"created_at",ExpiresAt:"expires_at",Quantity:"quantity",QuantityRemaining:"quantity_remaining"};var hb={LeaseHold:"lease_hold",LeaseRelease:"lease_release",ManualAdjustment:"manual_adjustment",Reconciliation:"reconciliation",Track:"track"};var gb={OnPayment:"on_payment",OnPublish:"on_publish"};var yb={Active:"active",Expired:"expired",Paid:"paid",Pending:"pending"};var wb={Failure:"failure",Pending:"pending",Success:"success"};var bb={CreditBurndown:"credit_burndown",Overage:"overage",PayAsYouGo:"pay_as_you_go",PayInAdvance:"pay_in_advance",Tier:"tier"};var zb={CompanyOverride:"company_override",PlanEntitlement:"plan_entitlement",Unknown:"unknown"};var Rb={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var fb={Company:"company",User:"user"};var _b={Development:"development",Production:"production",Staging:"staging"};var Sb={Enriched:"enriched",Failed:"failed",Pending:"pending",Processed:"processed",Unknown:"unknown"};var _o={FlagCheck:"flag_check",Identify:"identify",Track:"track"};var Pb={AddOn:"add_on",Alpha:"alpha",Beta:"beta",Deprecated:"deprecated",Ga:"ga",Inactive:"inactive",InPlan:"in_plan",InternalTesting:"internal_testing",Legacy:"legacy"};var xb={Boolean:"boolean",Event:"event",Trait:"trait"};var Eb={Active:"active",Created:"created",Pending:"pending"};var Cb={Clerk:"clerk",Metronome:"metronome",Orb:"orb",Stripe:"stripe",Unknown:"unknown",Workos:"workos"};var Ub={Draft:"draft",Open:"open",Paid:"paid",Uncollectible:"uncollectible",Void:"void"};var vb={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var Tb={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Ob={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 kb={Create:"create",Update:"update",Delete:"delete"};var Bb={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 jb={Fallback:"fallback",Initial:"initial",Trait:"trait",TrialExpiry:"trial_expiry"};var Ab={Adjustment:"adjustment",Downgrade:"downgrade",Invalid:"invalid",Subscribe:"subscribe",Unsubscribe:"unsubscribe",Upgrade:"upgrade",UpgradeTrial:"upgrade_trial"};var Vb={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 qb={Monthly:"monthly",Quarterly:"quarterly",Yearly:"yearly"};var Db={Plan:"plan",AddOn:"add_on"};var Mb={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending",Skipped:"skipped"};var Ib={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending"};var Fb={Immediate:"immediate",Leave:"leave"};var Kb={Published:"published",Draft:"draft",Archived:"archived"};var Lb={CreateProrations:"create_prorations",InvoiceImmediately:"invoice_immediately"};var Gb={V97288F60:"v97288f60",PlaceholderForFernCompatibility:"placeholder-for-fern-compatibility"};var Wb={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var fa={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var Nb={Company:"company",User:"user"};var Hb={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var $b={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Jb={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Yb={Bool:"bool",Date:"date",Int:"int",String:"string"};var Zb={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Xb={Cancelled:"cancelled",Error:"error",Executing:"executing",Pending:"pending",Success:"success"};var Qb={EndOfBillingPeriod:"end_of_billing_period",None:"none"};var ez={Asc:"asc",Desc:"desc"};var rz={Active:"active",Canceled:"canceled",Expired:"expired",Incomplete:"incomplete",IncompleteExpired:"incomplete_expired",PastDue:"past_due",Paused:"paused",Trialing:"trialing",Unpaid:"unpaid"};var iz={Free:"free",OneTime:"one_time",Paid:"paid",Trial:"trial"};var oz={Daily:"daily",Hourly:"hourly",Monthly:"monthly",Weekly:"weekly"};var tz={Bool:"bool",Date:"date",Int:"int",String:"string"};var az={Boolean:"boolean",Currency:"currency",Date:"date",Number:"number",String:"string",Url:"url"};var nz={Active:"active",Converted:"converted",Expired:"expired"};var sz={Failure:"failure",Pending:"pending",Success:"success"};var cz={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 lz={Active:"active",Inactive:"inactive"};var pz=2147483647,er=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 n={value:i,accessCounter:this.accessCounter,expiration:Date.now()+s};n.timeoutId=setTimeout(()=>this.evictItem(o,n),Math.min(s,pz)),typeof n.timeoutId=="object"&&typeof n.timeoutId.unref=="function"&&n.timeoutId.unref(),this.cache.set(o,n)}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 ri=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),n=t?Math.floor(t/1e3):this.defaultTTL;n>0?await this.client.setEx(s,n,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=[],n=1e3;for await(let u of this.client.scanIterator({MATCH:t,COUNT:1e3}))s.has(u)||(r.push(u),r.length>=n&&(await this.client.del(r),r.length=0));r.length>0&&await this.client.del(r)}};function _a(p){return typeof p=="object"&&p!==null&&"getAuthRequest"in p&&typeof p.getAuthRequest=="function"}var si=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var So={get:async(p,o)=>typeof p=="function"?p(o):p};var $e={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Is={[$e.Debug]:1,[$e.Info]:2,[$e.Warn]:3,[$e.Error]:4},Qi=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)}},ci=class{constructor(o){this.level=Is[o.level],this.logger=o.logger,this.silent=o.silent}shouldLog(o){return!this.silent&&this.level<=Is[o]}isDebug(){return this.shouldLog($e.Debug)}debug(o,...i){this.isDebug()&&this.logger.debug(o,...i)}isInfo(){return this.shouldLog($e.Info)}info(o,...i){this.isInfo()&&this.logger.info(o,...i)}isWarn(){return this.shouldLog($e.Warn)}warn(o,...i){this.isWarn()&&this.logger.warn(o,...i)}isError(){return this.shouldLog($e.Error)}error(o,...i){this.isError()&&this.logger.error(o,...i)}};function eo(p){return p==null?uz:p instanceof ci?p:(p=p??{},p.level??=$e.Info,p.logger??=new Qi,p.silent??=!0,new ci(p))}var uz=new ci({level:$e.Info,logger:new Qi,silent:!0});var dz={arrayFormat:"indices",encode:!0};function Sa(p,o){if(p===void 0||p===null)return"";let i=String(p);return o?encodeURIComponent(i):i}function Pa(p,o="",i){let t=[];for(let[s,r]of Object.entries(p)){let n=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(n):n,h=r.filter(l=>l!=null).map(l=>Sa(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"?`${n}[${g}]`:n;t.push(...Pa(h,l,i))}else{let l=u==="indices"?`${n}[${g}]`:n,y=i.encode?encodeURIComponent(l):l;t.push(`${y}=${Sa(h,i.encode)}`)}}}else if(typeof r=="object"&&r!==null){if(Object.keys(r).length===0)continue;t.push(...Pa(r,n,i))}else{let u=i.encode?encodeURIComponent(n):n;t.push(`${u}=${Sa(r,i.encode)}`)}}return t}function wr(p,o){return p==null||typeof p!="object"?"":Pa(p,"",{...dz,...o}).join("&")}function Po(p,o){let i=wr(o,{arrayFormat:"repeat"});return i?`${p}?${i}`:p}function Fs(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 Re=mz();function mz(){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 $s(p){return Re.type==="node"&&Re.parsedVersion!=null&&Re.parsedVersion>=18?new(await Promise.resolve().then(()=>(Ls(),Ks))).Node18UniversalStreamWrapper(p):Re.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(Ws(),Gs))).UndiciStreamWrapper(p):new(await Promise.resolve().then(()=>(Hs(),Ns))).NodePre18StreamWrapper(p)}async function li(p,o){switch(o){case"binary-response":return Fs(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}}:$s(p.body);case"text":return await p.text()}let i=await p.text();if(i.length>0)try{return Xi(i)}catch{return{ok:!1,error:{reason:"non-json",statusCode:p.status,rawBody:i}}}}async function Js(p){let o=p.headers.get("Content-Type")?.toLowerCase();if(o==null||o.length===0)return li(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?Xi(i):void 0}default:if(o.startsWith("application/vnd.")&&o.endsWith("+json")){let i=await p.text();return i.length>0?Xi(i):void 0}return await p.text()}}async function pi(){return Re.type==="node"&&Re.parsedVersion!=null&&Re.parsedVersion>=18?fetch:Re.type==="node"?(await import("node-fetch")).default:typeof fetch=="function"?fetch:(await import("node-fetch")).default}async function xo({body:p,type:o}){return o==="form"?wr(p,{arrayFormat:"repeat",encode:!0}):o.includes("json")?Ue(p):p}var rr;typeof globalThis.Headers<"u"?rr=globalThis.Headers:rr=class Ys{constructor(o){if(this.headers=new Map,o)if(o instanceof Ys)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 hz="timeout";function Zs(p){let o=new AbortController,i=setTimeout(()=>o.abort(hz),p);return{signal:o.signal,abortId:i}}function Xs(...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 ro;function gz(){if(ro!=null)return ro;try{new Request("http://localhost",{cache:"no-store"}),ro=!0}catch{ro=!1}return ro}var ui=async(p,o,i,t,s,r,n,u,g,h)=>{let l=[],y;if(r!=null){let{signal:T,abortId:O}=Zs(r);y=O,l.push(T)}n!=null&&l.push(n);let w=Xs(l),U=await p(o,{method:i,headers:t,body:s,signal:w,credentials:u?"include":void 0,duplex:g,...h&&gz()?{cache:"no-store"}:{}});return y!=null&&clearTimeout(y),U};var di={headers:new rr,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},mi={headers:new rr,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function io(p){return{headers:p.headers,redirected:p.redirected,status:p.status,statusText:p.statusText,type:p.type,url:p.url}}function yz(p){return[408,429].includes(p)||p>=500}function wz(p){let o=1+Math.random()*.2;return p*o}function bz(p){let o=1+(Math.random()-.5)*.2;return p*o}function zz(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 n=r.getTime()-Date.now();if(n>0)return Math.min(Math.max(n,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 wz(Math.min(r,6e4))}}return bz(Math.min(1e3*2**o,6e4))}async function hi(p,o=2){let i=await p();for(let t=0;t<o&&yz(i.status);++t){let s=zz(i,t);await new Promise(r=>setTimeout(r,s)),i=await p()}return i}var Rz=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 Ua(p){let o={};for(let[i,t]of p instanceof rr?p.entries():Object.entries(p))Rz.has(i.toLowerCase())?o[i]="[REDACTED]":o[i]=t;return o}var va=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 fz(p){if(p==null)return;let o={};for(let[i,t]of Object.entries(p))o[i]=va.has(i.toLowerCase())?"[REDACTED]":t;return o}function ii(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),n=Math.min(t===-1?p.length:t,s===-1?p.length:s,r===-1?p.length:r),u=-1;for(let T=i;T<n;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=va.has(A.toLowerCase());if(!j&&A.includes("%"))try{let D=decodeURIComponent(A);j=va.has(D.toLowerCase())}catch{}w.push(j?`${A}=[REDACTED]`:T)}return p.slice(0,s+1)+w.join("&")+p.slice(g)}async function _z(p){let o=new rr;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 So.get(t,{endpointMetadata:p.endpointMetadata??{}});if(typeof s=="string"){o.set(i,s);continue}s!=null&&o.set(i,`${s}`)}return o}async function Sz(p){let o=p.url;p.queryString!=null&&p.queryString.length>0?o=`${o}?${p.queryString}`:o=Po(p.url,p.queryParameters);let i=await xo({body:p.body,type:p.requestType??"other"}),t=p.fetchFn??await pi(),s=await _z(p),r=eo(p.logging);if(r.isDebug()){let n={method:p.method,url:ii(o),headers:Ua(s),queryParameters:fz(p.queryParameters),hasBody:i!=null};r.debug("Making HTTP request",n)}try{let n=await hi(async()=>ui(t,o,p.method,s,i,p.timeoutMs,p.abortSignal,p.withCredentials,p.duplex,p.responseType==="streaming"||p.responseType==="sse"),p.maxRetries);if(n.status>=200&&n.status<400){if(r.isDebug()){let g={method:p.method,url:ii(o),statusCode:n.status,responseHeaders:Ua(n.headers)};r.debug("HTTP request succeeded",g)}return{ok:!0,body:await li(n,p.responseType),headers:n.headers,rawResponse:io(n)}}else{if(r.isError()){let u={method:p.method,url:ii(o),statusCode:n.status,responseHeaders:Ua(Object.fromEntries(n.headers.entries()))};r.error("HTTP request failed with error status",u)}return{ok:!1,error:{reason:"status-code",statusCode:n.status,body:await Js(n)},rawResponse:io(n)}}}catch(n){if(p.abortSignal?.aborted){if(r.isError()){let u={method:p.method,url:ii(o)};r.error("HTTP request was aborted",u)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:n},rawResponse:di}}else if(n instanceof Error&&n.name==="AbortError"){if(r.isError()){let u={method:p.method,url:ii(o),timeoutMs:p.timeoutMs};r.error("HTTP request timed out",u)}return{ok:!1,error:{reason:"timeout",cause:n},rawResponse:di}}else if(n instanceof Error){if(r.isError()){let u={method:p.method,url:ii(o),errorMessage:n.message};r.error("HTTP request failed with error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:n.message,cause:n},rawResponse:mi}}if(r.isError()){let u={method:p.method,url:ii(o),error:Ue(n)};r.error("HTTP request failed with unknown error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:Ue(n),cause:n},rawResponse:mi}}}var E=Sz;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 Eo(p,...o){if(!p)return"";if(o.length===0)return p;if(p.includes("://")){let i;try{i=new URL(p)}catch{return Qs(p,...o)}let s=o[o.length-1]?.endsWith("/");for(let r of o){let n=rc(r);n&&(i.pathname=ec(i.pathname,n))}return s&&!i.pathname.endsWith("/")&&(i.pathname+="/"),i.toString()}return Qs(p,...o)}function Qs(p,...o){if(o.length===0)return p;let i=p,s=o[o.length-1]?.endsWith("/");for(let r of o){let n=rc(r);n&&(i=ec(i,n))}return s&&!i.endsWith("/")&&(i+="/"),i}function ec(p,o){return p.endsWith("/")?p+o:`${p}/${o}`}function rc(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 Ta(p,o,i,t){let s=eo(i.logging),r,n=o;p instanceof Request?(r=p.url,o==null&&(n={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=Eo(u,r):g=r;let h={};if(i.headers!=null)for(let[D,V]of Object.entries(i.headers)){let re=await So.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(n?.headers!=null){let D=n.headers instanceof Headers?Object.fromEntries(n.headers.entries()):Array.isArray(n.headers)?Object.fromEntries(n.headers):n.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=n?.method??"GET",y=n?.body,w=t?.timeoutInSeconds??i.timeoutInSeconds,U=w!=null?w*1e3:void 0,T=t?.maxRetries??i.maxRetries,O=t?.abortSignal??n?.signal??void 0,A=i.fetch??await pi();s.isDebug()&&s.debug("Making passthrough HTTP request",{method:l,url:g,hasBody:y!=null});let j=await hi(async()=>ui(A,g,l,h,y??void 0,U,O,n?.credentials==="include",void 0,!1),T);return s.isDebug()&&s.debug("Passthrough HTTP request completed",{method:l,url:g,statusCode:j.status}),j}var Co={};yr(Co,{ConsoleLogger:()=>Qi,LogLevel:()=>$e,Logger:()=>ci,createLogger:()=>eo});var e={};yr(e,{JsonError:()=>gi,ParseError:()=>yi,any:()=>yc,bigint:()=>oc,boolean:()=>wc,booleanLiteral:()=>hc,date:()=>tc,discriminant:()=>Cc,enum_:()=>oo,forwardCompatibleEnum_:()=>ac,getObjectLikeUtils:()=>Je,getObjectUtils:()=>oi,getSchemaUtils:()=>J,isProperty:()=>zr,lazy:()=>nc,lazyObject:()=>dc,list:()=>To,never:()=>bc,number:()=>zc,object:()=>vo,objectWithoutOptionalProperties:()=>uc,optional:()=>Oa,partialRecord:()=>Sc,property:()=>cc,record:()=>_c,set:()=>Pc,string:()=>Rc,stringLiteral:()=>gc,transform:()=>ka,undiscriminatedUnion:()=>Ec,union:()=>vc,unknown:()=>fc,withParsedProperties:()=>Aa});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 ${Pz(p)}.`}function Pz(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 ge(p){return{...p,json:ic(p.json),parse:ic(p.parse)}}function ic(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 Uo(p){return p.path.length===0?p.message:`${p.path.join(" -> ")}: ${p.message}`}var gi=class extends Error{constructor(i){super(i.map(Uo).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};var yi=class extends Error{constructor(i){super(i.map(Uo).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};function J(p){return{nullable:()=>xz(p),optional:()=>Oa(p),optionalNullable:()=>Ez(p),transform:o=>ka(p,o),parseOrThrow:(o,i)=>{let t=p.parse(o,i);if(t.ok)return t.value;throw new yi(t.errors)},jsonOrThrow:(o,i)=>{let t=p.json(o,i);if(t.ok)return t.value;throw new gi(t.errors)}}}function xz(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 Oa(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 Ez(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 oc(){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{...ge(p),...J(p)}}var Cz=/^([+-]?\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 tc(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="string"?{ok:!1,errors:[{path:i,message:$(o,"string")}]}:Cz.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{...ge(p),...J(p)}}function we(p,o){return()=>{let i={parse:o,json:o,getType:()=>p};return{...ge(i),...J(i)}}}function oo(p){let o=new Set(p);return we(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 ac(p){return oo(p).transform({transform:o=>o,untransform:o=>o})}function nc(p){let o=Ba(p);return{...o,...J(o)}}function Ba(p){return{parse:(o,i)=>wi(p).parse(o,i),json:(o,i)=>wi(p).json(o,i),getType:()=>wi(p).getType()}}function wi(p){let o=p;return o.__zurg_memoized==null&&(o.__zurg_memoized=p()),o.__zurg_memoized}function ja(p){return Object.entries(p)}function to(p,o){let i=new Set(o);return Object.entries(p).reduce((t,[s,r])=>(i.has(s)&&(t[s]=r),t),{})}function br(p){if(typeof p!="object"||p===null)return!1;let o=Object.getPrototypeOf(p);return o===null?!0:Object.getPrototypeOf(o)===null}function ao(p){return Object.keys(p)}function sc(p,o){let i=[],t=[];for(let s of p)o(s)?i.push(s):t.push(s);return[i,t]}var Uz=Object.prototype.hasOwnProperty;function Je(p){return{withParsedProperties:o=>Aa(p,o)}}function Aa(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);if(!r.ok)return r;let n={};for(let u in o)if(Uz.call(o,u)){let g=o[u];n[u]=typeof g=="function"?g(r.value):g}return{ok:!0,value:{...r.value,...n}}},json:(t,s)=>{if(!br(t))return{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:$(t,"object")}]};let r=new Set(Object.keys(o)),n=to(t,Object.keys(t).filter(u=>!r.has(u)));return p.json(n,s)},getType:()=>p.getType()};return{...i,...J(i),...Je(i)}}function cc(p,o){return{rawKey:p,valueSchema:o,isProperty:!0}}function zr(p){return p.isProperty}var vz=Object.prototype.hasOwnProperty;function vo(p){let o;function i(){if(o==null){o={};for(let[w,U]of ja(p)){let T=zr(U)?U.rawKey:w,O=zr(U)?U.valueSchema:U;o[T]={rawKey:T,parsedKey:w,valueSchema:O}}}return o}let t,s,r,n;function u(){if(t==null){t=[],s=[];for(let[w,U]of ja(p)){let T=zr(U)?U.rawKey:w,O=zr(U)?U.valueSchema:U;Tz(O)&&(t.push(T),s.push(w))}r=new Set(t),n=new Set(s)}return t}function g(){return s==null&&u(),s}function h(){return r==null&&u(),r}function l(){return n==null&&u(),n}let y={_getRawProperties:()=>Object.entries(p).map(([w,U])=>zr(U)?U.rawKey:w),_getParsedProperties:()=>ao(p),parse:(w,U)=>{let T=U?.breadcrumbsPrefix??[];return lc({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 lc({value:w,requiredKeys:g(),requiredKeysSet:l(),getProperty:O=>{let A=p[O];if(A!=null)return zr(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{...ge(y),...J(y),...Je(y),...oi(y)}}function lc({value:p,requiredKeys:o,requiredKeysSet:i,getProperty:t,unrecognizedObjectKeys:s="fail",skipValidation:r=!1,breadcrumbsPrefix:n=[]}){if(!br(p))return{ok:!1,errors:[{path:n,message:$(p,"object")}]};let u=o.length,g=[],h={};for(let l in p){if(!vz.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:[...n,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:n,message:`Missing required key "${l}"`});return g.length===0||r?{ok:!0,value:h}:{ok:!1,errors:g}}function oi(p){return{extend:o=>{let i={_getParsedProperties:()=>[...p._getParsedProperties(),...o._getParsedProperties()],_getRawProperties:()=>[...p._getRawProperties(),...o._getRawProperties()],parse:(t,s)=>pc({extensionKeys:o._getRawProperties(),value:t,transformBase:r=>p.parse(r,s),transformExtension:r=>o.parse(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>pc({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),...Je(i),...oi(i)}},passthrough:()=>{let o=new Set(p._getRawProperties()),i=new Set(p._getParsedProperties()),t={_getParsedProperties:()=>p._getParsedProperties(),_getRawProperties:()=>p._getRawProperties(),parse:(s,r)=>{let n=p.parse(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!n.ok)return n;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,...n.value}}},json:(s,r)=>{let n=p.json(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!n.ok)return n;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,...n.value}}},getType:()=>I.OBJECT};return{...t,...J(t),...Je(t),...oi(t)}}}}function pc({extensionKeys:p,value:o,transformBase:i,transformExtension:t,breadcrumbsPrefix:s=[]}){if(!br(o))return{ok:!1,errors:[{path:s,message:$(o,"object")}]};let r=new Set(p),[n,u]=sc(ao(o),l=>r.has(l)),g=i(to(o,u)),h=t(to(o,n));return g.ok&&h.ok?{ok:!0,value:{...g.value,...h.value}}:{ok:!1,errors:[...g.ok?[]:g.errors,...h.ok?[]:h.errors]}}function Tz(p){return!Oz(p)}function Oz(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 vo(p)}function dc(p){let o={...Ba(p),_getRawProperties:()=>wi(p)._getRawProperties(),_getParsedProperties:()=>wi(p)._getParsedProperties()};return{...o,...J(o),...Je(o),...oi(o)}}function To(p){let o={parse:(i,t)=>mc(i,(s,r)=>p.parse(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),json:(i,t)=>mc(i,(s,r)=>p.json(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),getType:()=>I.LIST};return{...ge(o),...J(o)}}function mc(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 hc(p){return we(I.BOOLEAN_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:$(i,`${p.toString()}`)}]})()}function gc(p){return we(I.STRING_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:$(i,`"${p}"`)}]})()}var yc=we(I.ANY,p=>({ok:!0,value:p}));var wc=we(I.BOOLEAN,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="boolean"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"boolean")}]});var bc=we(I.NEVER,(p,{breadcrumbsPrefix:o=[]}={})=>({ok:!1,errors:[{path:o,message:"Expected never"}]}));var zc=we(I.NUMBER,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="number"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"number")}]});var Rc=we(I.STRING,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="string"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:$(p,"string")}]});var fc=we(I.UNKNOWN,p=>({ok:!0,value:p}));var kz=Object.prototype.hasOwnProperty;function _c(p,o){let i={parse:(t,s)=>Oo({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,n)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${n}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Oo({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,n)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${n}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.RECORD};return{...ge(i),...J(i)}}function Sc(p,o){let i={parse:(t,s)=>Oo({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,n)=>o.parse(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${n}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>Oo({value:t,isKeyNumeric:p.getType()===I.NUMBER,transformKey:r=>p.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${r} (key)`]}),transformValue:(r,n)=>o.json(r,{...s,breadcrumbsPrefix:[...s?.breadcrumbsPrefix??[],`${n}`]}),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>I.RECORD};return{...ge(i),...J(i)}}function Oo({value:p,isKeyNumeric:o,transformKey:i,transformValue:t,breadcrumbsPrefix:s=[]}){if(!br(p))return{ok:!1,errors:[{path:s,message:$(p,"object")}]};let r={},n=[];for(let u in p){if(!kz.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||n.push(...l.errors),y.ok||n.push(...y.errors))}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function Pc(p){let o=To(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{...ge(i),...J(i)}}function Ec(p){let o={parse:(i,t)=>xc((s,r)=>s.parse(i,r),p,t),json:(i,t)=>xc((s,r)=>s.json(i,r),p,t),getType:()=>I.UNDISCRIMINATED_UNION};return{...ge(o),...J(o)}}function xc(p,o,i){let t=[];for(let[s,r]of o.entries()){let n=p(r,{...i,skipValidation:!1});if(n.ok)return n;for(let u of n.errors)t.push({path:u.path,message:`[Variant ${s}] ${u.message}`})}return{ok:!1,errors:t}}function Cc(p,o){return{parsedDiscriminant:p,rawDiscriminant:o}}var Bz=Object.prototype.hasOwnProperty;function vc(p,o){let i=typeof p=="string"?p:p.rawDiscriminant,t=typeof p=="string"?p:p.parsedDiscriminant,s=oo(ao(o)),r={parse:(n,u)=>Uc({value:n,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:(n,u)=>Uc({value:n,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{...ge(r),...J(r),...Je(r)}}function Uc({value:p,discriminant:o,transformedDiscriminant:i,transformDiscriminantValue:t,getAdditionalPropertiesSchema:s,allowUnrecognizedUnionMembers:r=!1,transformAdditionalProperties:n,breadcrumbsPrefix:u=[]}){if(!br(p))return{ok:!1,errors:[{path:u,message:$(p,"object")}]};let g=p[o],h={};for(let U in p)Bz.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=n(h,y);return w.ok?{ok:!0,value:{[i]:g,...w.value}}:w}var d={};yr(d,{encodePathParam:()=>Tc,join:()=>Eo,queryBuilder:()=>Oc,toQueryString:()=>wr});function Tc(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 Oc(){return new Va}var Va=class{constructor(){this.parts=new Map}add(o,i,t){if(i==null)return this;let s=wr({[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=wr({[i]:t},{arrayFormat:"repeat"});s.length>0&&this.parts.set(i,s)}return this}build(){return[...this.parts.values()].join("&")}};var qa="apiKey",jz="X-Schematic-Api-Key",bi=class p{constructor(o){this.options=o}static canCreate(o){return o?.[qa]!=null}async getAuthRequest({endpointMetadata:o}={}){let i=await m.get(this.options[qa]);if(i==null)throw new b({message:p.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[jz]:i}}}};(t=>{t.AUTH_SCHEME="ApiKeyAuth",t.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${qa}' when initializing the client`;function i(s){return new t(s)}t.createInstance=i})(bi||={});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 Az(p){let o=f({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@schematichq/schematic-typescript-node","X-Fern-SDK-Version":"1.5.2","User-Agent":"@schematichq/schematic-typescript-node/1.5.2","X-Fern-Runtime":Re.type,"X-Fern-Runtime-Version":Re.version},p?.headers);return{...p,logging:Co.createLogger(p?.logging),headers:o}}function K(p){let o=Az(p);if(p.auth===!1)return o.authProvider=new si,o;if(p.auth!=null){if(typeof p.auth=="function")return o.authProvider={getAuthRequest:p.auth},o;if(_a(p.auth))return o.authProvider=p.auth,o;Object.assign(o,p.auth)}let i=Vz(o);return o.authProvider??=new bi(i),o}function Vz(p){return{...p,authProvider:new si}}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 ei(`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 Da=e.object({lookup:e.record(e.string(),e.string())});var kc=e.stringLiteral("company");var Bc=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",kc),token:e.string(),updatedAt:e.property("updated_at",e.date())});var jc=e.object({data:Bc,params:e.record(e.string(),e.unknown())});var Ma=e.object({description:e.string().optional(),environmentId:e.property("environment_id",e.string().optional()),name:e.string(),readonly:e.boolean().optional()});var Ur=e.enum_(["development","production","staging"]);var Ia=e.object({environmentType:e.property("environment_type",Ur),name:e.string()});var Fa=e.object({description:e.string().optional(),name:e.string().optional()});var Ka=e.object({environmentType:e.property("environment_type",Ur.optional()),name:e.string().optional()});var Ac=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 Vc=e.object({data:q,params:Ac});var qc=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 Dc=e.object({data:q,params:qc});var xe=e.enum_(["api_key","app_user","stripe_app","system","temporary_access_token"]);var Mc=e.object({actorType:e.property("actor_type",xe.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 Ic=e.object({data:q,params:Mc});var Ve=e.enum_(["active","created","pending"]);var _e=e.enum_(["clerk","metronome","orb","stripe","unknown","workos"]);var ko=e.object({id:e.string(),state:Ve,type:_e});var Bo=e.enum_(["admin","capture","read","write"]);var Se=e.object({createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",Ur),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Fc=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Se.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:ko.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(Bo),secret:e.string(),updatedAt:e.property("updated_at",e.date())});var Kc=e.object({data:Fc,params:e.record(e.string(),e.unknown())});var Pe=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:Se.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:ko.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(Bo),updatedAt:e.property("updated_at",e.date())});var Lc=e.object({apiKeys:e.property("api_keys",e.list(Pe)),createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",Ur),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var Gc=e.object({data:Lc,params:e.record(e.string(),e.unknown())});var F=e.object({deleted:e.boolean().optional()});var Wc=e.object({data:F,params:e.record(e.string(),e.unknown())});var Nc=e.object({data:F,params:e.record(e.string(),e.unknown())});var Hc=e.enum_(["companies_edit","company_users_edit","components_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 $c=e.enum_(["admin","member"]);var vr=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(Hc)),role:$c.optional(),updatedAt:e.property("updated_at",e.date())});var Jc=e.object({data:vr,params:e.record(e.string(),e.unknown())});var Yc=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var Zc=e.object({actorType:e.property("actor_type",xe),apiKey:e.property("api_key",Pe.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Se.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 Xc=e.object({data:Zc,params:e.record(e.string(),e.unknown())});var Qc=e.object({data:Se,params:e.record(e.string(),e.unknown())});var el=e.object({accountId:e.property("account_id",e.string()),accountName:e.property("account_name",e.string()),actorType:e.property("actor_type",xe),apiKeyId:e.property("api_key_id",e.string().optional()),environmentId:e.property("environment_id",e.string().optional()),environments:e.list(Se),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 rl=e.object({data:el,params:e.record(e.string(),e.unknown())});var il=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var ol=e.object({data:e.list(vr),params:il});var tl=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 al=e.object({data:e.list(Pe),params:tl});var nl=e.object({actorType:e.property("actor_type",xe.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 jo=e.object({actorType:e.property("actor_type",xe),apiKey:e.property("api_key",Pe.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Se.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 sl=e.object({data:e.list(jo),params:nl});var cl=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var ll=e.object({data:e.list(Se),params:cl});var pl=e.object({ok:e.boolean()});var ul=e.object({data:pl,params:e.record(e.string(),e.unknown())});var dl=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var ml=e.object({data:Se,params:e.record(e.string(),e.unknown())});var k=e.enum_(["metronome","orb","schematic","stripe"]);var La=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 ir=e.enum_(["per_unit","tiered"]);var ne=e.enum_(["licensed","metered"]);var de=e.enum_(["graduated","volume"]);var hl=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 Ga=e.object({billingScheme:e.property("billing_scheme",ir),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(hl)),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 Wa=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 gl=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 yl=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 Tr=e.enum_(["cancel","subscribe"]);var Na=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()),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(yl),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(gl)),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",Tr.optional())});var Ha=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 Ao=e.enum_(["draft","open","paid","uncollectible","void"]);var $a=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()),externalId:e.property("external_id",e.string().optional()),paymentMethodExternalId:e.property("payment_method_external_id",e.string().optional()),status:Ao.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),url:e.string().optional()});var Ja=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 Ya=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 wl=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 bl=e.object({data:q,params:wl});var zl=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 Rl=e.object({data:q,params:zl});var fl=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 Sl=e.object({data:F,params:e.record(e.string(),e.unknown())});var Pl=e.object({data:F,params:e.record(e.string(),e.unknown())});var xl=e.object({data:F,params:e.record(e.string(),e.unknown())});var El=e.object({data:F,params:e.record(e.string(),e.unknown())});var Cl=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 zi=e.enum_(["day","month","one-time","year"]);var Vo=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 N=e.object({billingScheme:e.property("billing_scheme",ir),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:zi,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(Vo)),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 Ul=e.object({data:e.list(N),params:Cl});var vl=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 Tl=e.object({data:e.list(N),params:vl});var Ol=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:zi,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:ir});var or=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 kl=e.object({data:e.list(or),params:Ol});var Bl=e.object({isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var qo=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 jl=e.object({data:e.list(qo),params:Bl});var Al=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 Vl=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 ql=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(Vl),updatedAt:e.property("updated_at",e.date())});var Dl=e.object({data:e.list(ql),params:Al});var Ml=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 Ye=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()),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),status:Ao.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 Il=e.object({data:e.list(Ye),params:Ml});var Fl=e.object({displayName:e.property("display_name",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var Do=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 Kl=e.object({data:e.list(Do),params:Fl});var Ll=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 Ze=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 Gl=e.object({data:e.list(Ze),params:Ll});var Wl=e.object({data:qo,params:e.record(e.string(),e.unknown())});var Nl=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 Hl=e.object({data:Nl,params:e.record(e.string(),e.unknown())});var $l=e.object({data:Do,params:e.record(e.string(),e.unknown())});var Jl=e.object({data:L,params:e.record(e.string(),e.unknown())});var Or=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 Yl=e.object({data:Or,params:e.record(e.string(),e.unknown())});var Zl=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",Tr.optional())});var Xl=e.object({data:Zl,params:e.record(e.string(),e.unknown())});var Ql=e.object({data:Ye,params:e.record(e.string(),e.unknown())});var ep=e.object({data:Ze,params:e.record(e.string(),e.unknown())});var Za=e.object({cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),prorate:e.boolean().optional()});var Xa=e.object({companyId:e.property("company_id",e.string()),selectedPlanId:e.property("selected_plan_id",e.string().optional())});var Qa=e.object({trialEnd:e.property("trial_end",e.date().optional())});var Mo=e.object({billingScheme:e.property("billing_scheme",ir),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(Vo)),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 Io=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 no=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(Io),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),latestInvoice:e.property("latest_invoice",Ye.optional()),metadata:e.record(e.string(),e.unknown()).optional(),paymentMethod:e.property("payment_method",Ze.optional()),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),products:e.list(Mo),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",Tr.optional())});var W=e.enum_(["all_time","current_day","current_month","current_week"]);var H=e.enum_(["billing_cycle","first_of_month"]);var rp=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",H),period:W,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var Y=e.enum_(["duration","end_of_billing_period","end_of_next_billing_period","end_of_trial","no_expiry"]);var G=e.enum_(["billing_periods","days"]);var kr=e.enum_(["expiration_priority","first_in_first_out","last_in_first_out","plan_first_then_credit_bundles_first_in_first_out"]);var ip=e.enum_(["schematic_authoritative","external_mirror","external_rated"]);var Br=e.enum_(["expire","none","rollover"]);var op=e.object({currency:e.string(),price:N.optional()});var Fo=e.object({accountId:e.property("account_id",e.string()),burnStrategy:e.property("burn_strategy",kr),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",Br),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:e.string().optional(),id:e.string(),ledgerAuthority:e.property("ledger_authority",ip),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),price:N.optional(),pricePerUnit:e.property("price_per_unit",e.number().optional()),pricePerUnitDecimal:e.property("price_per_unit_decimal",e.string().optional()),product:Or.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var ve=e.enum_(["daily","monthly","weekly","yearly"]);var qe=e.enum_(["billing_period","first_of_month"]);var tr=e.enum_(["no_reset","plan_period"]);var Ri=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var tp=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()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Y.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()),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:Fo.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",Y.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Ri.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",ve.optional()),resetStart:e.property("reset_start",qe.optional()),resetType:e.property("reset_type",tr),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({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(tp)),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 fi=e.enum_(["on_payment","on_publish"]);var Rr=e.enum_(["active","expired","paid","pending"]);var jr=e.object({activationStrategy:e.property("activation_strategy",fi),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:Rr,stripeInvoiceUrl:e.property("stripe_invoice_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var ie=e.enum_(["company","user"]);var Ko=e.object({createdAt:e.property("created_at",e.date()),entityType:e.property("entity_type",ie),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date())});var Lo=e.object({createdAt:e.property("created_at",e.date()),definition:Ko.optional(),definitionId:e.property("definition_id",e.string()),entityId:e.property("entity_id",e.string()),entityType:e.property("entity_type",ie),environmentId:e.property("environment_id",e.string()),id:e.string(),key:e.string(),updatedAt:e.property("updated_at",e.date()),value:e.string()});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",ie),hierarchy:e.list(e.string()),id:e.string(),traitType:e.property("trait_type",me),updatedAt:e.property("updated_at",e.date())});var Go=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 Q=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var Wo=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",H.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",Q)});var Ar=e.enum_(["eq","gt","gte","is_empty","lt","lte","not_empty","ne"]);var _i=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var ap=e.enum_(["bool","date","int","string"]);var rn=e.object({comparableType:e.property("comparable_type",ap),entityType:e.property("entity_type",ie),id:e.string()});var No=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",rn.optional()),conditionType:e.property("condition_type",_i),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",H.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ar,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",rn.optional()),traitValue:e.property("trait_value",e.string())});var np=e.object({conditions:e.list(No)});var Vr=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var sp=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(np)),conditions:e.list(No),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",Vr),value:e.boolean()});var Ho=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(en)),billingCreditBalances:e.property("billing_credit_balances",e.record(e.string(),e.number()).optional()),billingSubscription:e.property("billing_subscription",no.optional()),billingSubscriptions:e.property("billing_subscriptions",e.list(no)),createdAt:e.property("created_at",e.date()),customPlanBillings:e.property("custom_plan_billings",e.list(jr)),defaultPaymentMethod:e.property("default_payment_method",Ze.optional()),entitlements:e.list(Wo),entityTraits:e.property("entity_traits",e.list(Go)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Lo),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),metrics:e.list(rp),name:e.string(),paymentMethods:e.property("payment_methods",e.list(Ze)),plan:en.optional(),plans:e.list(Ri),rules:e.list(sp),scheduledDowngrade:e.property("scheduled_downgrade",Ho.optional()),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date()),userCount:e.property("user_count",e.number())});var $o=e.object({company:X.optional(),success:e.boolean()});var cp=e.object({data:$o,params:e.record(e.string(),e.unknown())});var lp=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",Tr.optional())});var pp=e.object({data:lp,params:e.record(e.string(),e.unknown())});var Ee=e.enum_(["active","inactive"]);var Ae=e.stringLiteral("fixed");var up=e.object({currency:e.string(),price:L.optional()});var De=e.object({billingInvoiceId:e.property("billing_invoice_id",e.string().optional()),bundleType:e.property("bundle_type",Ae),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(up)),expiryType:e.property("expiry_type",Y),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 Jo=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 Si=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(Io),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),isInitial:e.property("is_initial",e.boolean()),latestInvoice:e.property("latest_invoice",Ye.optional()),paymentMethod:e.property("payment_method",Ze.optional()),products:e.list(Mo),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 dp=e.object({bundle:De.optional(),quantity:e.number(),total:e.number()});var Te=e.enum_(["adjustment","billing_credit_auto_topup","free","plan","purchased","rollover"]);var mp=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 Me=e.enum_(["add_on","alpha","beta","deprecated","ga","inactive","in_plan","internal_testing","legacy"]);var se=e.enum_(["boolean","event","trait"]);var qr=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",Me.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 Ie=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:qr.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",H.optional()),notes:e.list(mp),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 Pi=e.object({creditTypeIcon:e.property("credit_type_icon",e.string().optional()),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",Te),quantity:e.number()});var xi=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 be=e.enum_(["credit_burndown","overage","pay_as_you_go","pay_in_advance","tier"]);var Dr=e.enum_(["company_override","plan_entitlement","unknown"]);var Oe=e.object({billingProvider:e.property("billing_provider",k),externalResourceId:e.property("external_resource_id",e.string()),originator:k});var Ei=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 ar=e.stringLiteral("boolean");var Yo=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Zo=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",_i),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",H.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ar,resourceIds:e.property("resource_ids",e.list(e.string())),resources:e.list(Yo),ruleId:e.property("rule_id",e.string()),trait:he.optional(),traitEntityType:e.property("trait_entity_type",ie.optional()),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var hp=e.object({conditions:e.list(Zo),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 Ci=e.object({conditionGroups:e.property("condition_groups",e.list(hp)),conditions:e.list(Zo),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",Vr),updatedAt:e.property("updated_at",e.date()),value:e.boolean()});var gp=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:qr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ar),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(Ci),updatedAt:e.property("updated_at",e.date())});var Mr=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Fe=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Ei.optional()),featureType:e.property("feature_type",se),flags:e.list(gp),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Me.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Mr),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 yp=e.object({currency:e.string(),price:L.optional()});var Ke=e.object({burnStrategy:e.property("burn_strategy",kr),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(yp)),defaultExpiryUnit:e.property("default_expiry_unit",G),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Br),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:Or.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var wp=e.object({currency:e.string(),monthlyPrice:e.property("monthly_price",N.optional()),quarterlyPrice:e.property("quarterly_price",N.optional()),yearlyPrice:e.property("yearly_price",N.optional())});var ce=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 oe=e.enum_(["plan","add_on"]);var nr=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:ce,id:e.string(),name:e.string(),planType:e.property("plan_type",oe),updatedAt:e.property("updated_at",e.date())});var ee=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.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(wp)),environmentId:e.property("environment_id",e.string()),feature:qr.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),meteredMonthlyPrice:e.property("metered_monthly_price",N.optional()),meteredQuarterlyPrice:e.property("metered_quarterly_price",N.optional()),meteredYearlyPrice:e.property("metered_yearly_price",N.optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",H.optional()),plan:nr.optional(),planId:e.property("plan_id",e.string()),priceBehavior:e.property("price_behavior",be.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",Or.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCredit:e.property("value_credit",Ke.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 Ir=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",Q),companyOverride:e.property("company_override",Ie.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(Pi).optional()),creditGrantReason:e.property("credit_grant_reason",Te.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",xi.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",Dr),feature:Fe.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",H.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:W.optional(),plan:nr.optional(),planEntitlement:e.property("plan_entitlement",ee.optional()),priceBehavior:e.property("price_behavior",be.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",N.optional())});var Ui=e.object({features:e.list(Ir)});var ke=e.object({autoTopupAmount:e.property("auto_topup_amount",e.number().optional()),autoTopupAmountType:e.property("auto_topup_amount_type",e.string().optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Y.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()),createdAt:e.property("created_at",e.date()),credit:Ke.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",Y.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Yo.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",ve.optional()),resetStart:e.property("reset_start",qe.optional()),resetType:e.property("reset_type",tr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number()),updatedAt:e.property("updated_at",e.date())});var Le=e.enum_(["schematic_managed","provider_managed","no_billing"]);var Ge=e.enum_(["free","none","one_time","recurring"]);var Fr=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 bp=e.enum_(["published","draft","archived"]);var ze=e.object({createdAt:e.property("created_at",e.date()),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:ce,id:e.string(),name:e.string(),originalPlanId:e.property("original_plan_id",e.string().optional()),planType:e.property("plan_type",oe),status:bp,updatedAt:e.property("updated_at",e.date()),version:e.number()});var ye=e.object({activeVersion:e.property("active_version",ze.optional()),audienceType:e.property("audience_type",e.string().optional()),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",or.optional()),billingStrategy:e.property("billing_strategy",Le),chargeType:e.property("charge_type",Ge),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",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()),currencyPrices:e.property("currency_prices",e.list(Fr)),description:e.string(),draftVersion:e.property("draft_version",ze.optional()),entitlements:e.list(ee).optional(),features:e.list(Fe),icon:ce,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",oe),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(ze),yearlyPrice:e.property("yearly_price",L.optional())});var so=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",N.optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",H.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),priceBehavior:e.property("price_behavior",be.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.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",N.optional())});var zp=e.object({activeAddOns:e.property("active_add_ons",e.list(ye)),activePlan:e.property("active_plan",ye.optional()),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(so)),availableCreditBundles:e.property("available_credit_bundles",e.list(De)),company:X.optional(),customCheckoutFields:e.property("custom_checkout_fields",e.list(Jo)),featureUsage:e.property("feature_usage",Ui.optional()),selectedCreditBundles:e.property("selected_credit_bundles",e.list(dp)),selectedPlan:e.property("selected_plan",ye.optional()),selectedUsageBasedEntitlements:e.property("selected_usage_based_entitlements",e.list(so)),subscription:Si.optional()});var Rp=e.object({data:zp,params:e.record(e.string(),e.unknown())});var fp=e.object({data:$o,params:e.record(e.string(),e.unknown())});var _p=e.object({amount:e.number(),description:e.string(),priceId:e.property("price_id",e.string()),proration:e.boolean(),quantity:e.number()});var Sp=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),newCharges:e.property("new_charges",e.number()),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(),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(_p))});var Xo=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),finance:Sp.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(Ir))});var Pp=e.object({data:Xo,params:e.record(e.string(),e.unknown())});var xp=e.object({subscriptionChangePreview:e.property("subscription_change_preview",Xo.optional())});var Ep=e.object({data:xp,params:e.record(e.string(),e.unknown())});var Cp=e.object({data:no,params:e.record(e.string(),e.unknown())});var on=e.object({displayName:e.property("display_name",e.string().optional()),entityType:e.property("entity_type",ie),hierarchy:e.list(e.string()),traitType:e.property("trait_type",me)});var tn=e.object({companyId:e.property("company_id",e.string()),userId:e.property("user_id",e.string())});var an=e.object({displayName:e.property("display_name",e.string().optional()),traitType:e.property("trait_type",me)});var vi=e.object({traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string())});var nn=e.object({applyToExistingCompanies:e.property("apply_to_existing_companies",e.boolean()),planId:e.property("plan_id",e.string()),traits:e.list(vi)});var Be=e.enum_(["asc","desc"]);var fr=e.enum_(["active","canceled","expired","incomplete","incomplete_expired","past_due","paused","trialing","unpaid"]);var _r=e.enum_(["free","one_time","paid","trial"]);var Up=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",Be.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(fr).optional()),subscriptionTypes:e.property("subscription_types",e.list(_r).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 vp=e.object({data:q,params:Up});var Tp=e.object({entityType:e.property("entity_type",ie.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Op=e.object({data:q,params:Tp});var kp=e.object({entityType:e.property("entity_type",ie.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 Bp=e.object({data:q,params:kp});var jp=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 Ap=e.object({data:q,params:jp});var Vp=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 qp=e.object({data:q,params:Vp});var Dp=e.object({data:X,params:e.record(e.string(),e.unknown())});var Ti=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 Oi=e.object({company:Ti.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 We=e.object({companyMemberships:e.property("company_memberships",e.list(Oi)),createdAt:e.property("created_at",e.date()),entityTraits:e.property("entity_traits",e.list(Go)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Lo),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 Mp=e.object({data:We,params:e.record(e.string(),e.unknown())});var Ip=e.object({data:Ti,params:e.record(e.string(),e.unknown())});var Fp=e.object({data:F,params:e.record(e.string(),e.unknown())});var Kp=e.object({cancelSubscription:e.property("cancel_subscription",e.boolean().optional()),prorate:e.boolean().optional()});var Lp=e.object({data:F,params:Kp});var Qo=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 Gp=e.object({data:Qo,params:e.record(e.string(),e.unknown())});var Wp=e.object({data:F,params:e.record(e.string(),e.unknown())});var Np=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 Hp=e.object({data:e.list(Si),params:Np});var $p=e.object({data:X,params:e.record(e.string(),e.unknown())});var Jp=e.object({data:he,params:e.record(e.string(),e.unknown())});var Yp=e.object({definitionId:e.property("definition_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Zp=e.object({definitionId:e.property("definition_id",e.string()),value:e.string()});var Xp=e.object({data:e.list(Zp),params:Yp});var Qp=e.object({data:Oi,params:e.record(e.string(),e.unknown())});var eu=e.object({data:he,params:e.record(e.string(),e.unknown())});var ki=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 Bi=e.enum_(["fallback","initial","trait","trial_expiry"]);var ru=e.enum_(["adjustment","downgrade","invalid","subscribe","unsubscribe","upgrade","upgrade_trial"]);var co=e.object({deleted:e.boolean(),description:e.string(),icon:e.string(),id:e.string(),name:e.string()});var sn=e.object({id:e.string(),name:e.string(),version:e.number()});var iu=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 et=e.object({action:ki,actorType:e.property("actor_type",xe),addOnsAdded:e.property("add_ons_added",e.list(co)),addOnsRemoved:e.property("add_ons_removed",e.list(co)),apiKey:e.property("api_key",Pe.optional()),auditLog:e.property("audit_log",jo.optional()),basePlan:e.property("base_plan",co.optional()),basePlanAction:e.property("base_plan_action",Bi.optional()),basePlanVersion:e.property("base_plan_version",sn.optional()),company:Ti.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(),isVersionUpgrade:e.property("is_version_upgrade",e.boolean()),previousBasePlan:e.property("previous_base_plan",co.optional()),previousBasePlanVersion:e.property("previous_base_plan_version",sn.optional()),requestId:e.property("request_id",e.string().optional()),subscriptionChangeAction:e.property("subscription_change_action",ru.optional()),traitsUpdated:e.property("traits_updated",e.list(iu)),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var ou=e.object({data:et,params:e.record(e.string(),e.unknown())});var Kr=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 tu=e.object({data:Kr,params:e.record(e.string(),e.unknown())});var au=e.object({data:We,params:e.record(e.string(),e.unknown())});var nu=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",Be.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(fr).optional()),subscriptionTypes:e.property("subscription_types",e.list(_r).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 su=e.object({data:e.list(X),params:nu});var cu=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 lu=e.object({data:e.list(Oi),params:cu});var pu=e.object({entityType:e.property("entity_type",ie.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var uu=e.object({data:e.list(Ko),params:pu});var du=e.object({entityType:e.property("entity_type",ie.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 mu=e.object({data:e.list(he),params:du});var hu=e.object({action:ki.optional(),basePlanAction:e.property("base_plan_action",Bi.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 gu=e.object({data:e.list(et),params:hu});var yu=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 wu=e.object({data:e.list(Kr),params:yu});var bu=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 zu=e.object({data:e.list(We),params:bu});var Ru=e.object({keys:e.record(e.string(),e.string()).optional()});var fu=e.object({data:X,params:Ru});var _u=e.object({keys:e.record(e.string(),e.string()).optional()});var Su=e.object({data:We,params:_u});var Pu=e.object({data:he,params:e.record(e.string(),e.unknown())});var xu=e.object({data:e.list(Kr),params:e.record(e.string(),e.unknown())});var Eu=e.object({data:X,params:e.record(e.string(),e.unknown())});var Cu=e.object({data:X,params:e.record(e.string(),e.unknown())});var Uu=e.object({data:We,params:e.record(e.string(),e.unknown())});var vu=e.object({data:We,params:e.record(e.string(),e.unknown())});var ji=e.enum_(["billing","entitlement"]);var cn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",ji),name:e.string()});var rt=e.enum_(["draft","live"]);var ln=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",ji.optional()),name:e.string().optional(),state:rt.optional()});var Tu=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ou=e.object({data:q,params:Tu});var sr=e.object({ast:e.record(e.string(),e.number()).optional(),createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),state:rt,type:ji,updatedAt:e.property("updated_at",e.date())});var ku=e.object({data:sr,params:e.record(e.string(),e.unknown())});var Bu=e.object({data:F,params:e.record(e.string(),e.unknown())});var ju=e.object({data:sr,params:e.record(e.string(),e.unknown())});var Au=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Vu=e.object({data:e.list(sr),params:Au});var qu=e.object({companyId:e.property("company_id",e.string().optional()),componentId:e.property("component_id",e.string().optional())});var lo=e.object({billingScheme:e.property("billing_scheme",ir),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:zi,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 Du=e.object({currency:e.string(),price:N.optional()});var Mu=e.object({bundleType:e.property("bundle_type",Ae),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(Du)),expiryType:e.property("expiry_type",Y),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:lo.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Ee,unitPrice:e.property("unit_price",lo.optional()),updatedAt:e.property("updated_at",e.date())});var Iu=e.enum_(["downgrade_not_permitted","feature_usage_exceeded"]);var Lr=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 it=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()),billingCreditAutoTopupEnabled:e.property("billing_credit_auto_topup_enabled",e.boolean()),billingCreditAutoTopupExpiryType:e.property("billing_credit_auto_topup_expiry_type",Y.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()),createdAt:e.property("created_at",e.date()),credit:Fo.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",Y.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),id:e.string(),plan:Ri.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",ve.optional()),resetStart:e.property("reset_start",qe.optional()),resetType:e.property("reset_type",tr),rolloverPercentage:e.property("rollover_percentage",e.number()),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Ai=e.enum_(["monthly","quarterly","yearly"]);var pn=e.object({activeVersion:e.property("active_version",ze.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ai)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",or.optional()),billingStrategy:e.property("billing_strategy",Le),chargeType:e.property("charge_type",Ge),companyCanTrial:e.property("company_can_trial",e.boolean()),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",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()),currencyPrices:e.property("currency_prices",e.list(Fr)),current:e.boolean(),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Lr.optional()),description:e.string(),draftVersion:e.property("draft_version",ze.optional()),entitlements:e.list(ee).optional(),features:e.list(Fe),icon:ce,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(it)),invalidReason:e.property("invalid_reason",Iu.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",oe),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(Ir)),valid:e.boolean(),versions:e.list(ze),yearlyPrice:e.property("yearly_price",L.optional())});var Gr=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var ot=e.object({badgeVisibility:e.property("badge_visibility",e.boolean()),checkout:e.boolean()});var Fu=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 tt=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 Wr=e.enum_(["expired","manual","plan_change","plan_period_reset","reconciled"]);var Ku=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 Lu=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",Y.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),grantReason:e.property("grant_reason",Te),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:lo.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",ve.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(Ku).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",Wr.optional())});var Gu=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 Wu=e.object({activeAddOns:e.property("active_add_ons",e.list(pn)),activePlans:e.property("active_plans",e.list(pn)),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(so)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr)),capabilities:ot.optional(),checkoutSettings:e.property("checkout_settings",Fu),company:X.optional(),component:sr.optional(),creditBundles:e.property("credit_bundles",e.list(Mu)),creditGrants:e.property("credit_grants",e.list(Lu)),customCheckoutFields:e.property("custom_checkout_fields",e.list(Jo)),defaultPlan:e.property("default_plan",ye.optional()),displaySettings:e.property("display_settings",tt),featureUsage:e.property("feature_usage",Ui.optional()),invoices:e.list(Ye),postTrialPlan:e.property("post_trial_plan",ye.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",Ho.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",Gu.optional()),subscription:Si.optional(),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional()),upcomingInvoice:e.property("upcoming_invoice",Ye.optional())});var Nu=e.object({data:Wu,params:qu});var Hu=e.object({data:sr,params:e.record(e.string(),e.unknown())});var un=e.object({activeVersion:e.property("active_version",ze.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ai)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",or.optional()),billingStrategy:e.property("billing_strategy",Le),chargeType:e.property("charge_type",Ge),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",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()),currencyPrices:e.property("currency_prices",e.list(Fr)),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Lr.optional()),description:e.string(),draftVersion:e.property("draft_version",ze.optional()),entitlements:e.list(ee).optional(),features:e.list(Fe),icon:ce,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(it)),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",oe),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(ze),yearlyPrice:e.property("yearly_price",L.optional())});var $u=e.object({activeAddOns:e.property("active_add_ons",e.list(un)),activePlans:e.property("active_plans",e.list(un)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr)),capabilities:ot.optional(),displaySettings:e.property("display_settings",tt),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 Ju=e.object({data:$u,params:e.record(e.string(),e.unknown())});var dn=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 at=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 mn=e.object({burnStrategy:e.property("burn_strategy",kr.optional()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(at).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",Br.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 hn=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",Y.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),quantity:e.number(),reason:Te,renewalEnabled:e.property("renewal_enabled",e.boolean().optional()),renewalPeriod:e.property("renewal_period",qe.optional())});var nt=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 gn=e.object({bundleName:e.property("bundle_name",e.string()),bundleType:e.property("bundle_type",Ae.optional()),creditId:e.property("credit_id",e.string()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(nt).optional()),expiryType:e.property("expiry_type",Y.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 yn=e.object({additionalAmount:e.property("additional_amount",e.number()),expiresAt:e.property("expires_at",e.date().optional())});var wn=e.object({burnStrategy:e.property("burn_strategy",kr.optional()),currencyPrices:e.property("currency_prices",e.list(at).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",Br.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 bn=e.object({bundleName:e.property("bundle_name",e.string()),currencyPrices:e.property("currency_prices",e.list(nt).optional()),expiryType:e.property("expiry_type",Y.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 zn=e.object({reason:Wr.optional()});var Vi=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 Yu=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var Zu=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 Xu=e.object({data:q,params:Zu});var Qu=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var ed=e.object({data:q,params:Qu});var rd=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 id=e.object({data:q,params:rd});var ti=e.enum_(["created_at","expires_at","quantity","quantity_remaining"]);var od=e.object({companyId:e.property("company_id",e.string().optional()),dir:Be.optional(),limit:e.number().optional(),offset:e.number().optional(),order:ti.optional()});var td=e.object({data:q,params:od});var ad=e.object({bundleType:e.property("bundle_type",Ae.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 nd=e.object({data:q,params:ad});var Sr=e.enum_(["grant","transfer","usage","zero_out"]);var sd=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",Sr.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 cd=e.object({data:q,params:sd});var ld=e.object({data:Ke,params:e.record(e.string(),e.unknown())});var pd=e.object({data:ke,params:e.record(e.string(),e.unknown())});var ud=e.object({data:De,params:e.record(e.string(),e.unknown())});var dd=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var md=e.object({data:F,params:dd});var hd=e.object({data:F,params:e.record(e.string(),e.unknown())});var gd=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var yd=e.object({data:De,params:e.record(e.string(),e.unknown())});var wd=e.object({data:Ke,params:e.record(e.string(),e.unknown())});var bd=e.object({data:ke,params:e.record(e.string(),e.unknown())});var zd=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 Nr=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",Te),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",ve.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(zd).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",Wr.optional())});var Rd=e.object({data:Nr,params:e.record(e.string(),e.unknown())});var fd=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:e.list(Ke),params:fd});var Sd=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 Pd=e.object({data:e.list(ke),params:Sd});var xd=e.object({companyId:e.property("company_id",e.string().optional())});var Ed=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 Cd=e.object({data:e.list(Ed),params:xd});var Ud=e.object({companyId:e.property("company_id",e.string().optional()),dir:Be.optional(),limit:e.number().optional(),offset:e.number().optional(),order:ti.optional()});var vd=e.object({data:e.list(Nr),params:Ud});var Td=e.object({bundleType:e.property("bundle_type",Ae.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 Od=e.object({data:e.list(De),params:Td});var kd=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",Sr.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 Bd=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 jd=e.object({id:e.string(),logoUrl:e.property("logo_url",e.string().optional()),name:e.string()});var Ad=e.enum_(["lease_hold","lease_release","manual_adjustment","reconciliation","track"]);var Vd=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string()});var qd=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:jd.optional(),companyId:e.property("company_id",e.string()),credit:Bd.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",Sr),expiryType:e.property("expiry_type",Y.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),feature:Vd.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",Te.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",Ad.optional()),zeroedOutReason:e.property("zeroed_out_reason",Wr.optional())});var Dd=e.object({data:e.list(qd),params:kd});var Md=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 Id=e.object({data:e.list(Nr),params:Md});var Fd=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var Kd=e.object({data:F,params:e.record(e.string(),e.unknown())});var Ld=e.object({data:Ke,params:e.record(e.string(),e.unknown())});var Gd=e.object({data:ke,params:e.record(e.string(),e.unknown())});var Wd=e.object({data:De,params:e.record(e.string(),e.unknown())});var Nd=e.object({data:Nr,params:e.record(e.string(),e.unknown())});var Rn=e.object({metadata:e.string()});var Hd=e.stringLiteral("csv");var $d=e.enum_(["failure","pending","success"]);var Jd=e.stringLiteral("company-feature-usage");var Yd=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",Jd),id:e.string(),metadata:e.string(),outputFileType:e.property("output_file_type",Hd),status:$d,updatedAt:e.property("updated_at",e.date())});var Zd=e.object({data:Yd,params:e.record(e.string(),e.unknown())});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 Hr=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 fn=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(Hr).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",H.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",be.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 _n=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",H.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 Sn=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(Hr).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",H.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",be.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 Pn=e.object({sourcePlanId:e.property("source_plan_id",e.string()),targetPlanId:e.property("target_plan_id",e.string())});var xn=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",H.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 En=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(Hr).optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",H.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",be.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 Xd=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 Qd=e.object({data:q,params:Xd});var em=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var rm=e.object({data:q,params:em});var im=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 om=e.object({data:q,params:im});var tm=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var am=e.object({data:q,params:tm});var nm=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 sm=e.object({data:q,params:nm});var cm=e.object({data:Ie,params:e.record(e.string(),e.unknown())});var lm=e.object({data:ee,params:e.record(e.string(),e.unknown())});var pm=e.object({data:F,params:e.record(e.string(),e.unknown())});var um=e.object({data:F,params:e.record(e.string(),e.unknown())});var st=e.object({code:e.string(),description:e.string(),detail:e.string().optional(),id:e.string().optional()});var dm=e.object({message:e.string()});var mm=e.object({entitlementId:e.property("entitlement_id",e.string()),errors:e.list(dm),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string())});var hm=e.object({data:e.list(ee),issues:e.list(st),skipped:e.list(mm)});var gm=e.object({data:hm,params:e.record(e.string(),e.unknown())});var ym=e.object({data:Ie,params:e.record(e.string(),e.unknown())});var wm=e.object({keys:e.record(e.string(),e.string()).optional()});var bm=e.object({data:Ui,params:wm});var Xe=e.enum_(["daily","hourly","monthly","weekly"]);var zm=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:Xe.optional(),startTime:e.property("start_time",e.date().optional())});var Rm=e.object({effectiveAt:e.property("effective_at",e.date()),isSoftLimit:e.property("is_soft_limit",e.boolean()),limitSource:e.property("limit_source",Dr),limitValue:e.property("limit_value",e.number().optional()),planId:e.property("plan_id",e.string().optional()),priceBehavior:e.property("price_behavior",be.optional())});var fm=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 _m=e.object({featureId:e.property("feature_id",e.string()),featureType:e.property("feature_type",se),limits:e.list(Rm),periodType:e.property("period_type",e.string().optional()),usagePoints:e.property("usage_points",e.list(fm))});var Sm=e.object({data:_m,params:zm});var Pm=e.object({data:ee,params:e.record(e.string(),e.unknown())});var xm=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 Em=e.object({data:e.list(Ie),params:xm});var Cm=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Um=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(Pi).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",xi.optional())});var vm=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",Q),company:X.optional(),companyOverride:e.property("company_override",Ie.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(Pi).optional()),creditGrantReason:e.property("credit_grant_reason",Te.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",Um.optional()),creditUsageAggregation:e.property("credit_usage_aggregation",xi.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",Dr),feature:Fe.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",H.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",N.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:W.optional(),plan:nr.optional(),planEntitlement:e.property("plan_entitlement",ee.optional()),priceBehavior:e.property("price_behavior",be.optional()),quarterlyUsageBasedPrice:e.property("quarterly_usage_based_price",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",N.optional())});var Tm=e.object({data:e.list(vm),params:Cm});var Om=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 km=e.object({data:e.list(Ir),params:Om});var Bm=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var cr=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:qr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ar),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainer:vr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Ci),updatedAt:e.property("updated_at",e.date())});var Ne=e.object({billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Ei.optional()),featureType:e.property("feature_type",se),flags:e.list(cr),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Me.optional()),maintainer:vr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(Mr),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 jm=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",Dr),feature:Ne.optional(),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",H.optional()),period:W.optional(),plan:nr.optional(),usage:e.number().optional(),user:Qo.optional()});var Am=e.object({data:e.list(jm),params:Bm});var Vm=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 qm=e.object({data:e.list(ee),params:Vm});var Dm=e.object({data:Ie,params:e.record(e.string(),e.unknown())});var Mm=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Im=e.object({data:ee,params:e.record(e.string(),e.unknown())});var Fm=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 Km=e.object({keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Lm=e.object({company:Km.optional(),keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Gm=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 ct=e.undiscriminatedUnion([Gm,Fm,Lm]);var Pr=e.enum_(["flag_check","identify","track"]);var lt=e.object({backfill:e.boolean().optional(),body:ct.optional(),eventType:e.property("event_type",Pr),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 Cn=e.object({events:e.list(lt)});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 Wm=e.object({events:e.list(pt)});var Nm=e.object({data:Wm,params:e.record(e.string(),e.unknown())});var Hm=e.object({data:pt,params:e.record(e.string(),e.unknown())});var $m=e.enum_(["enriched","failed","pending","processed","unknown"]);var ut=e.object({apiKey:e.property("api_key",e.string().optional()),apiKeyView:e.property("api_key_view",Pe.optional()),body:e.record(e.string(),e.unknown()),bodyPreview:e.property("body_preview",e.string()),capturedAt:e.property("captured_at",e.date()),company:Mr.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(Mr),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:$m,subtype:e.string().optional(),type:Pr,updatedAt:e.property("updated_at",e.date().optional()),user:Mr.optional(),userId:e.property("user_id",e.string().optional())});var Jm=e.object({data:ut,params:e.record(e.string(),e.unknown())});var Ym=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 Zm=e.object({data:e.list(Ei),params:Ym});var Xm=e.object({connected:e.boolean(),environmentId:e.property("environment_id",e.string()),lastEventAt:e.property("last_event_at",e.date().optional())});var Qm=e.object({data:Xm,params:e.record(e.string(),e.unknown())});var eh=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(Pr).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 rh=e.object({data:e.list(ut),params:eh});var po=e.object({company:e.record(e.string(),e.string()).optional(),user:e.record(e.string(),e.string()).optional()});var Un=e.object({contexts:e.list(po)});var qi=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",ar),id:e.string().optional(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var vn=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:qi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Me.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 Tn=e.object({description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",se),flag:qi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Me.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 On=e.object({description:e.string().optional(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",se.optional()),flag:qi.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Me.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 dt=e.object({comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionType:e.property("condition_type",_i),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",H.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ar,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 ih=e.object({conditions:e.list(dt),flagId:e.property("flag_id",e.string().optional()),id:e.string().optional()});var oh=e.object({conditionGroups:e.property("condition_groups",e.list(ih)),conditions:e.list(dt),id:e.string().optional(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Vr.optional()),value:e.boolean()});var kn=e.object({rules:e.list(oh)});var mt=e.object({companyId:e.property("company_id",e.string().optional()),entitlement:Wo.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",Vr.optional()),userId:e.property("user_id",e.string().optional()),value:e.boolean()});var th=e.object({data:mt,params:e.record(e.string(),e.unknown())});var ah=e.object({remaining:e.number(),reserved:e.number(),settled:e.number()});var nh=e.enum_(["active","converted","expired"]);var sh=e.object({id:e.string(),name:e.string(),trialEndDate:e.property("trial_end_date",e.date().optional()),trialStatus:e.property("trial_status",nh.optional())});var ht=e.object({creditBalances:e.property("credit_balances",e.record(e.string(),ah).optional()),flags:e.list(mt),plan:sh.optional()});var ch=e.object({data:e.list(ht)});var lh=e.object({data:ch,params:e.record(e.string(),e.unknown())});var ph=e.object({data:ht,params:e.record(e.string(),e.unknown())});var uh=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 dh=e.object({data:q,params:uh});var mh=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 hh=e.object({data:q,params:mh});var gh=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var yh=e.object({data:cr,params:e.record(e.string(),e.unknown())});var wh=e.object({data:F,params:e.record(e.string(),e.unknown())});var bh=e.object({data:F,params:e.record(e.string(),e.unknown())});var zh=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Rh=e.object({data:cr,params:e.record(e.string(),e.unknown())});var fh=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 _h=e.object({data:e.list(Ne),params:fh});var Sh=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 Ph=e.object({data:e.list(cr),params:Sh});var xh=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Eh=e.object({data:cr,params:e.record(e.string(),e.unknown())});var Ch=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",ar),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 Uh=e.object({flag:Ch.optional(),rules:e.list(Ci)});var vh=e.object({data:Uh,params:e.record(e.string(),e.unknown())});var Th=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Oh=e.object({limit:e.number().optional()});var kh=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 Bh=e.object({entries:e.list(kh)});var jh=e.object({data:Bh,params:Oh});var Ah=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:Xe.optional(),startTime:e.property("start_time",e.date().optional())});var gt=e.object({timestamp:e.date(),usage:e.number()});var Vh=e.object({eventSubtype:e.property("event_subtype",e.string()),featureId:e.property("feature_id",e.string()),points:e.list(gt)});var qh=e.object({data:Vh,params:Ah});var Dh=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:Xe.optional(),startTime:e.property("start_time",e.date().optional())});var Mh=e.object({featureId:e.property("feature_id",e.string()),points:e.list(gt),traitDefinitionId:e.property("trait_definition_id",e.string())});var Ih=e.object({data:Mh,params:Dh});var Fh=e.object({months:e.number().optional()});var Kh=e.object({month:e.date(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),subscribers:e.number()});var Lh=e.object({points:e.list(Kh)});var Gh=e.object({data:Lh,params:Fh});var Wh=e.object({amount:e.number(),currency:e.string()});var Nh=e.object({activeCredits:e.property("active_credits",e.number()),mrr:e.list(Wh),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 Hh=e.object({data:Nh,params:e.record(e.string(),e.unknown())});var $h=e.object({endTime:e.property("end_time",e.date().optional()),limit:e.number().optional(),startTime:e.property("start_time",e.date().optional())});var Jh=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 Yh=e.object({features:e.list(Jh)});var Zh=e.object({data:Yh,params:$h});var Di=e.enum_(["billing_meta_object","manual_upsert"]);var Bn=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Di.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),integrationId:e.property("integration_id",e.string())});var yt=e.object({authorPlans:e.property("author_plans",e.boolean()),checkout:e.boolean(),editBilling:e.property("edit_billing",e.boolean())});var Xh=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Qh=e.object({});var eg=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var rg=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 ig=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var wt=e.union("type",{clerk:Xh,metronome:Qh,orb:eg,stripe:rg,workos:ig}).transform({transform:p=>p,untransform:p=>p});var og=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Di.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:wt.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 tg=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Ve,type:_e,updatedAt:e.property("updated_at",e.date())});var Mi=e.object({capabilities:yt,config:og,integration:tg});var ag=e.object({data:Mi,params:e.record(e.string(),e.unknown())});var ng=e.object({type:_e,url:e.string()});var sg=e.object({data:ng,params:e.record(e.string(),e.unknown())});var cg=e.object({data:Mi,params:e.record(e.string(),e.unknown())});var lg=e.object({data:Mi,params:e.record(e.string(),e.unknown())});var pg=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:Ve.optional(),type:_e.optional()});var ug=e.object({capabilities:yt,config:wt.optional(),id:e.string(),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),state:Ve,type:_e});var dg=e.object({data:e.list(ug),params:pg});var mg=e.object({keys:e.list(e.string())});var hg=e.object({data:mg,params:e.record(e.string(),e.unknown())});var bt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Ve,type:_e,updatedAt:e.property("updated_at",e.date())});var gg=e.object({data:bt,params:e.record(e.string(),e.unknown())});var yg=e.object({data:bt,params:e.record(e.string(),e.unknown())});var wg=e.object({data:F,params:e.record(e.string(),e.unknown())});var bg=e.object({companyId:e.property("company_id",e.string()),description:e.string(),icon:ce.optional(),name:e.string()});var zg=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(Hr).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",H.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",be.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 zt=e.enum_(["create","update","delete"]);var Ii=e.object({action:zt,entitlementId:e.property("entitlement_id",e.string().optional()),req:zg.optional()});var Rg=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 $r=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingStrategy:e.property("billing_strategy",Le.optional()),chargeType:e.property("charge_type",Ge),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Rg).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 jn=e.object({billingProduct:e.property("billing_product",$r.optional()),entitlements:e.list(Ii),plan:bg.optional()});var Rt=e.object({description:e.string(),icon:ce.optional(),name:e.string(),planType:e.property("plan_type",oe)});var ft=e.stringLiteral("credit");var _t=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",ft.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Y.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()),creditAmount:e.property("credit_amount",e.number()),creditId:e.property("credit_id",e.string()),expiryType:e.property("expiry_type",Y.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",ve),resetStart:e.property("reset_start",qe),resetType:e.property("reset_type",tr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional())});var fg=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var St=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",ft.optional()),autoTopupEnabled:e.property("auto_topup_enabled",e.boolean().optional()),autoTopupExpiryType:e.property("auto_topup_expiry_type",Y.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()),creditAmount:e.property("credit_amount",e.number().optional()),expiryType:e.property("expiry_type",Y.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),resetCadence:e.property("reset_cadence",ve),resetStart:e.property("reset_start",qe),resetType:e.property("reset_type",tr.optional()),rolloverPercentage:e.property("rollover_percentage",e.number().optional())});var Pt=e.object({action:zt,createReq:e.property("create_req",_t.optional()),creditGrantId:e.property("credit_grant_id",e.string().optional()),deleteReq:e.property("delete_req",fg.optional()),updateReq:e.property("update_req",St.optional())});var An=e.object({billingProduct:e.property("billing_product",$r.optional()),creditGrants:e.property("credit_grants",e.list(Pt).optional()),entitlements:e.list(Ii),plan:Rt.optional(),traits:e.list(vi).optional()});var xt=e.object({description:e.string().optional(),icon:ce.optional(),name:e.string()});var Vn=e.object({billingProduct:e.property("billing_product",$r.optional()),creditGrants:e.property("credit_grants",e.list(Pt).optional()),entitlements:e.list(Ii),plan:xt.optional(),planVersionId:e.property("plan_version_id",e.string().optional()),traits:e.list(vi).optional()});var Et=e.object({accountId:e.property("account_id",e.string()),billingProductId:e.property("billing_product_id",e.string()),billingStrategy:e.property("billing_strategy",Le),chargeType:e.property("charge_type",Ge),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 Fi=e.object({billingProduct:e.property("billing_product",Et.optional()),creditGrants:e.property("credit_grants",e.list(ke).optional()),entitlements:e.list(ee).optional(),plan:nr.optional(),traits:e.list(Kr).optional()});var _g=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var Sg=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var Pg=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var Ct=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 xg=e.object({entitlementId:e.property("entitlement_id",e.string()),visible:e.boolean().optional()});var xr=e.object({entitlements:e.list(xg).optional(),planId:e.property("plan_id",e.string())});var Ki=e.object({bundleId:e.string()});var Ut=e.enum_(["create_prorations","invoice_immediately"]);var vt=e.enum_(["end_of_billing_period","none"]);var qn=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr).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(Ct).optional()),customPlanConfig:e.property("custom_plan_config",Lr.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(xr)),orderedBundleList:e.property("ordered_bundle_list",e.list(Ki)),orderedPlans:e.property("ordered_plans",e.list(xr)),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",Ut),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",vt.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 Dn=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr).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(Ct).optional()),customPlanConfig:e.property("custom_plan_config",Lr.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(xr)),orderedBundleList:e.property("ordered_bundle_list",e.list(Ki)),orderedPlans:e.property("ordered_plans",e.list(xr)),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",Ut),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",vt.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 Tt=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 Eg=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var Ot=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(Eg)),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutSettings:e.property("checkout_settings",Tt),componentSettings:e.property("component_settings",Ot),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(xr)),planIds:e.property("plan_ids",e.list(xr)),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 Cg=e.object({data:kt,params:e.record(e.string(),e.unknown())});var Ug=e.object({includeCompanyCounts:e.property("include_company_counts",e.boolean().optional())});var vg=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 Bt=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 ai=e.object({activeVersion:e.property("active_version",ze.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(Ai)),billingLinkedResource:e.property("billing_linked_resource",Oe.optional()),billingProduct:e.property("billing_product",or.optional()),billingStrategy:e.property("billing_strategy",Le),chargeType:e.property("charge_type",Ge),companyCount:e.property("company_count",e.number()),companyId:e.property("company_id",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()),currencyPrices:e.property("currency_prices",e.list(Fr)),customPlanConfig:e.property("custom_plan_config",Bt.optional()),description:e.string(),draftVersion:e.property("draft_version",ze.optional()),entitlements:e.list(ee).optional(),features:e.list(Fe),icon:ce,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",oe),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(ze),yearlyPrice:e.property("yearly_price",L.optional())});var Tg=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var Mn=e.object({entitlements:e.list(Tg).optional(),planId:e.property("plan_id",e.string())});var Og=e.object({addOns:e.property("add_ons",e.list(ai)),checkoutSettings:e.property("checkout_settings",Tt),componentSettings:e.property("component_settings",Ot),customCheckoutFields:e.property("custom_checkout_fields",e.list(vg)),customPlanConfig:e.property("custom_plan_config",Bt.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),defaultPlan:e.property("default_plan",ai.optional()),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlan:e.property("fallback_plan",ai.optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlan:e.property("initial_plan",ai.optional()),initialPlanId:e.property("initial_plan_id",e.string().optional()),initialPlanPrice:e.property("initial_plan_price",N.optional()),initialPlanPriceId:e.property("initial_plan_price_id",e.string().optional()),orderedAddOnList:e.property("ordered_add_on_list",e.list(Mn)),orderedBundleList:e.property("ordered_bundle_list",e.list(Ki)),orderedPlanList:e.property("ordered_plan_list",e.list(Mn)),plans:e.list(ai),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",ai.optional()),trialExpiryPlanId:e.property("trial_expiry_plan_id",e.string().optional()),trialExpiryPlanPrice:e.property("trial_expiry_plan_price",N.optional()),trialExpiryPlanPriceId:e.property("trial_expiry_plan_price_id",e.string().optional()),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional())});var kg=e.object({data:Og,params:Ug});var Bg=e.object({data:kt,params:e.record(e.string(),e.unknown())});var Li=e.enum_(["immediate","leave"]);var In=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:Li,targetPlanType:e.property("target_plan_type",oe)});var jt=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 Fn=e.object({errorCodes:e.property("error_codes",e.list(jt))});var Er=e.enum_(["completed","failed","in_progress","pending","skipped"]);var jg=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Er.optional()});var Ag=e.object({data:q,params:jg});var Cr=e.enum_(["completed","failed","in_progress","pending"]);var Vg=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Cr.optional()});var qg=e.object({data:q,params:Vg});var Jr=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:Cr,strategy:Li,totalCompanies:e.property("total_companies",e.number()),updatedAt:e.property("updated_at",e.date())});var Dg=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Mg=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Ig=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Er.optional()});var At=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",jt.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:Er,updatedAt:e.property("updated_at",e.date())});var Fg=e.object({data:e.list(At),params:Ig});var Kg=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Cr.optional()});var Lg=e.object({data:e.list(Jr),params:Kg});var Gg=e.object({data:At,params:e.record(e.string(),e.unknown())});var Wg=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Kn=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:ce.optional(),name:e.string(),planType:e.property("plan_type",oe)});var Ln=e.object({companyId:e.property("company_id",e.string()),copiedFromPlanId:e.property("copied_from_plan_id",e.string().optional()),description:e.string(),icon:ce.optional(),name:e.string()});var Gn=e.object({activationStrategy:e.property("activation_strategy",fi.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",Li)});var Wn=e.object({activationStrategy:e.property("activation_strategy",fi.optional()),customerEmail:e.property("customer_email",e.string()),daysUntilDue:e.property("days_until_due",e.number().optional())});var Nn=e.object({addOnIds:e.property("add_on_ids",e.list(e.string())),basePlanId:e.property("base_plan_id",e.string().optional())});var Ng=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var Hg=e.object({data:q,params:Ng});var $g=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",oe.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 Jg=e.object({data:q,params:$g});var Yg=e.object({data:ye,params:e.record(e.string(),e.unknown())});var Zg=e.object({data:ye,params:e.record(e.string(),e.unknown())});var Xg=e.object({data:F,params:e.record(e.string(),e.unknown())});var Qg=e.object({promoteArchivedVersion:e.property("promote_archived_version",e.boolean().optional())});var ey=e.object({data:F,params:Qg});var ry=e.object({planVersionId:e.property("plan_version_id",e.string().optional())});var iy=e.object({data:ye,params:ry});var oy=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var ty=e.object({data:e.list(X),params:oy});var ay=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:Rr.optional(),statuses:e.list(Rr).optional()});var ny=e.object({data:e.list(jr),params:ay});var sy=e.object({planId:e.property("plan_id",e.string().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var cy=e.object({data:e.list(st),params:sy});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",oe.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 py=e.object({data:e.list(ye),params:ly});var uy=e.object({data:jr,params:e.record(e.string(),e.unknown())});var dy=e.object({data:ze,params:e.record(e.string(),e.unknown())});var my=e.object({data:jr,params:e.record(e.string(),e.unknown())});var hy=e.object({data:X,params:e.record(e.string(),e.unknown())});var gy=e.object({data:ye,params:e.record(e.string(),e.unknown())});var yy=e.object({data:Et,params:e.record(e.string(),e.unknown())});var wy=e.object({data:ye,params:e.record(e.string(),e.unknown())});var Hn=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 Yr=e.enum_(["cancelled","error","executing","pending","success"]);var $n=e.object({executeAfter:e.property("execute_after",e.date().optional()),status:Yr.optional()});var Zr=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:Yr,toPlanId:e.property("to_plan_id",e.string()),updatedAt:e.property("updated_at",e.date())});var by=e.object({data:Zr,params:e.record(e.string(),e.unknown())});var zy=e.object({data:Zr,params:e.record(e.string(),e.unknown())});var Ry=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),status:Yr.optional()});var fy=e.object({data:e.list(Zr),params:Ry});var _y=e.object({data:Zr,params:e.record(e.string(),e.unknown())});var Gi=e.object({creditId:e.property("credit_id",e.string())});var Wi=e.object({featureId:e.property("feature_id",e.string())});var lr=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 Jn=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Gi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Wi).optional()),name:e.string(),requestTypes:e.property("request_types",e.list(lr)),url:e.string()});var Yn=e.object({requestType:e.property("request_type",lr)});var Vt=e.enum_(["active","inactive"]);var Zn=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Gi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Wi).optional()),name:e.string().optional(),requestTypes:e.property("request_types",e.list(lr).optional()),status:Vt.optional(),url:e.string().optional()});var Sy=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 Py=e.object({data:q,params:Sy});var xy=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ey=e.object({data:q,params:xy});var pr=e.object({createdAt:e.property("created_at",e.date()),creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Gi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Wi).optional()),id:e.string(),name:e.string(),requestTypes:e.property("request_types",e.list(lr)),secret:e.string(),status:Vt,updatedAt:e.property("updated_at",e.date()),url:e.string()});var Cy=e.object({data:pr,params:e.record(e.string(),e.unknown())});var Uy=e.object({data:F,params:e.record(e.string(),e.unknown())});var vy=e.enum_(["failure","pending","success"]);var qt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),payload:e.string().optional(),requestType:e.property("request_type",lr),responseCode:e.property("response_code",e.number().optional()),sentAt:e.property("sent_at",e.date().optional()),status:vy,updatedAt:e.property("updated_at",e.date()),webhook:pr.optional(),webhookId:e.property("webhook_id",e.string())});var Ty=e.object({data:qt,params:e.record(e.string(),e.unknown())});var Oy=e.object({data:pr,params:e.record(e.string(),e.unknown())});var ky=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 By=e.object({data:e.list(qt),params:ky});var jy=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ay=e.object({data:e.list(pr),params:jy});var Vy=e.object({responseCode:e.property("response_code",e.number()),success:e.boolean()});var qy=e.object({data:Vy,params:e.record(e.string(),e.unknown())});var Dy=e.object({data:pr,params:e.record(e.string(),e.unknown())});var a=e.object({error:e.string()});var Dt=e.object({id:e.string(),value:e.string()});var My=e.object({addOnId:e.property("add_on_id",e.string()),priceId:e.property("price_id",e.string())});var Iy=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 Mt=e.object({bundleId:e.property("bundle_id",e.string()),quantity:e.number()});var It=e.object({priceId:e.property("price_id",e.string()),quantity:e.number()});var Xn=e.object({addOnIds:e.property("add_on_ids",e.list(My)),autoTopupOverrides:e.property("auto_topup_overrides",e.list(Iy)),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(Mt)),customFieldValues:e.property("custom_field_values",e.list(Dt)),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(It)),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 Qn=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",ar),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var Ft=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Di.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:_e});var es=e.object({keys:e.record(e.string(),e.string())});var Fy=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 rs=e.object({addOnSelections:e.property("add_on_selections",e.list(Fy)),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()),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(Mt)),customFieldValues:e.property("custom_field_values",e.list(Dt)),payInAdvanceEntitlements:e.property("pay_in_advance_entitlements",e.list(It)),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 Ky=e.record(e.string(),e.unknown());var Ly=e.record(e.string(),e.unknown());var Gy=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var Ni=e.enum_(["all_time","current_day","current_month","current_week"]);var Hi=e.enum_(["billing_cycle","first_of_month"]);var Kt=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",Ni.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",Hi.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",Gy)});var Wy=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var Lt=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",Hi),period:Ni,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var Ny=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var Hy=e.enum_(["company","user"]);var $y=e.enum_(["bool","date","int","string"]);var uo=e.object({comparableType:e.property("comparable_type",$y),entityType:e.property("entity_type",Hy),id:e.string()});var Gt=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",uo.optional()),conditionType:e.property("condition_type",Ny),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",Ni.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",Hi.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:Ar,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",uo.optional()),traitValue:e.property("trait_value",e.string())});var Jy=e.object({conditions:e.list(Gt)});var $i=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(Jy)),conditions:e.list(Gt),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",Wy),value:e.boolean()});var Yy=e.object({id:e.string(),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date())});var Wt=e.object({traitDefinition:e.property("trait_definition",uo.optional()),value:e.string()});var Zy=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(Kt).optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),metrics:e.list(Lt),planIds:e.property("plan_ids",e.list(e.string())),planVersionIds:e.property("plan_version_ids",e.list(e.string())),rules:e.list($i),subscription:Yy.optional(),traits:e.list(Wt)});var is=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($i)});var Xy=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($i),traits:e.list(Wt)});var os=e.object({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 ts=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 as=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 Nt=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:{...Da.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:jc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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 Ht=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:n}=o,u={ids:t,q:s,limit:r,offset:n},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:ol.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:Jc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n}=o,u={ids:t,q:s,limit:r,offset:n},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:Vc.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n}=o,u={environment_id:t,require_environment:s,limit:r,offset:n},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:al.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:Ma.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:Kc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Yc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:Fa.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(n.ok)return{data:dl.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:Wc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n}=o,u={environment_id:t,require_environment:s,limit:r,offset:n},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:Dc.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n,startTime:u,limit:g,offset:h}=o,l={actor_type:t!=null?xe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:n,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:sl.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(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(a.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:Xc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,startTime:u,limit:g,offset:h}=o,l={actor_type:t!=null?xe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:n,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:Ic.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(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(a.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,n={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(n).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:ll.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(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(a.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:Ia.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:Gc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Qc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:Ka.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(n.ok)return{data:ml.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:Nc.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 401:throw new x(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(a.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:rl.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(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(a.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 $t=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:n}=o,u={is_active:t,q:s,limit:r,offset:n},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:jl.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:Ha.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:_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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:La.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,limit:u,offset:g}=o,h={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:n,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:Dl.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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:n,limit:u,offset:g}=o,h={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:n,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:Rl.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={company_id:t,customer_external_id:s,subscription_external_id:r,limit:n,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:Il.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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:$a.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:Ql.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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,n={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(n).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Kl.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(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(a.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: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:$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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n}=o,u={company_id:t,customer_external_id:s,limit:r,offset:n},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:Gl.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:xl.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,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:n,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},pe=await this._options.authProvider.getAuthRequest(),Ce=f(pe.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:Ce,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:Ul.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(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(a.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:Ga.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Pl.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,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:n,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},pe=await this._options.authProvider.getAuthRequest(),Ce=f(pe.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:Ce,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:Tl.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(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(a.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:El.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Wa.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,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:n!=null?ne.jsonOrThrow(n,{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:kl.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(a.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 401:throw new x(a.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 403:throw new _(a.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 404:throw new P(a.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 500:throw new S(a.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:n,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:n!=null?ne.jsonOrThrow(n,{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:bl.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(a.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 401:throw new x(a.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 403:throw new _(a.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 404:throw new P(a.parseOrThrow(V.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),V.rawResponse);case 500:throw new S(a.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:Na.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:Xl.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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 Jt=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:Xn.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Xa.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Xn.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Za.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:Qa.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(n.ok)return{data:Cp.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.rawResponse,"PUT","/subscription/{subscription_id}/edit-trial-end")}};var Yt=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:n,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:pe,offset:Ce}=o,B={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:n,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?Be.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(gr=>fr.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):T!=null?fr.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(gr=>_r.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):O!=null?_r.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:pe,offset:Ce},Qr=await this._options.authProvider.getAuthRequest(),hr=f(Qr.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:hr,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:su.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(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new x(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new P(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(a.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:os.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:$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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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,n={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(n).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: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(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(a.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:n,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:pe,offset:Ce}=o,B={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:n,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?Be.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(T)?T.map(gr=>fr.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):T!=null?fr.jsonOrThrow(T,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map(gr=>_r.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):O!=null?_r.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:pe,offset:Ce},Qr=await this._options.authProvider.getAuthRequest(),hr=f(Qr.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:hr,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:vp.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(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new x(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new _(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new P(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new S(a.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:os.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Ue(t)},r=await this._options.authProvider.getAuthRequest(),n=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:n,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:fu.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(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(a.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")}listCompanyMemberships(o={},i){return R.fromPromise(this.__listCompanyMemberships(o,i))}async __listCompanyMemberships(o={},i){let{companyId:t,userId:s,limit:r,offset:n}=o,u={company_id:t,user_id:s,limit:r,offset:n},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:lu.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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: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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n}=o,u={company_id:t,company_ids:s,limit:r,offset:n},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:Hp.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={entity_type:t!=null?ie.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:n,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:uu.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={entity_type:t!=null?ie.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:n,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: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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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:n,traitTypes:u,limit:g,offset:h}=o,l={entity_type:t!=null?ie.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:n!=null?me.jsonOrThrow(n,{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:mu.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(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:Pu.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:n,traitTypes:u,limit:g,offset:h}=o,l={entity_type:t!=null?ie.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,trait_type:n!=null?me.jsonOrThrow(n,{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:Bp.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(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(a.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:n}=o,u={definition_id:t,q:s,limit:r,offset:n},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:Xp.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n,planIds:u,limit:g,offset:h}=o,l={action:t!=null?ki.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,base_plan_action:s!=null?Bi.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,company_id:r,company_ids:n,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:gu.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(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(a.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: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 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,limit:u,offset:g}=o,h={ids:t,plan_id:s,trait_id:r,trait_ids:n,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:wu.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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:tu.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,limit:u,offset:g}=o,h={ids:t,plan_id:s,trait_id:r,trait_ids:n,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:Ap.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,limit:u,offset:g}=o,h={company_id:t,ids:s,plan_id:r,q:n,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:zu.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,limit:u,offset:g}=o,h={company_id:t,ids:s,plan_id:r,q:n,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:qp.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Ue(t)},r=await this._options.authProvider.getAuthRequest(),n=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:n,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:Su.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(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(a.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 Zt=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,n={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(n).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:ju.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:ln.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(n.ok)return{data:Hu.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:Bu.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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}")}countComponents(o={},i){return R.fromPromise(this.__countComponents(o,i))}async __countComponents(o={},i){let{q:t,limit:s,offset:r}=o,n={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(n).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Ou.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(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(a.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},n=await this._options.authProvider.getAuthRequest(),u=f(n.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:Nu.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(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(a.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 Xt=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:Ju.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(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(a.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 Qt=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:n}=o,u={ids:t,name:s,limit:r,offset:n},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:_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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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: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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:wd.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:wn.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(n.ok)return{data:Ld.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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(),n=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:n,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: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(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 401:throw new x(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(a.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:n,limit:u,offset:g}=o,h={ids:t,credit_id:s,status:r!=null?Ee.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:n!=null?Ae.jsonOrThrow(n,{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:Od.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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: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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:yd.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:Wd.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:hd.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,limit:u,offset:g}=o,h={ids:t,credit_id:s,status:r!=null?Ee.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:n!=null?Ae.jsonOrThrow(n,{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:nd.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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:n}=o,u={ids:t,name:s,limit:r,offset:n},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:ed.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:Nd.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={company_id:t,order:s!=null?ti.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?Be.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:n,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: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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={company_id:t,order:s!=null?ti.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?Be.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:n,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:vd.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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:n}=o,u={credit_id:t,ids:s,limit:r,offset:n},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:Xu.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n}=o,u={credit_id:t,ids:s,limit:r,offset:n},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: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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:yn.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(n.ok)return{data:gd.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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),n=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:Ly.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(n.ok)return{data:Fd.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:n,planVersionId:u,planVersionIds:g,limit:h,offset:l}=o,y={credit_id:t,ids:s,plan_id:r,plan_ids:n,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:Pd.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(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(a.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:_t.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:pd.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:St.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(n.ok)return{data:Gd.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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},n=await this._options.authProvider.getAuthRequest(),u=f(n.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:md.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(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(a.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:n,planVersionId:u,planVersionIds:g,limit:h,offset:l}=o,y={credit_id:t,ids:s,plan_id:r,plan_ids:n,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:id.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(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(a.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:n,featureId:u,startTime:g,limit:h,offset:l}=o,y={billing_credit_id:t,company_id:s,end_time:r,event_type:n!=null?Sr.jsonOrThrow(n,{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:Dd.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(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(a.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:n,featureId:u,startTime:g,limit:h,offset:l}=o,y={billing_credit_id:t,company_id:s,end_time:r,event_type:n!=null?Sr.jsonOrThrow(n,{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:cd.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(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(a.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 ea=class{constructor(o){this._options=K(o)}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:{...Rn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),export_type:"company-feature-usage",output_file_type:"csv"},timeoutMs:(i?.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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")}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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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 ra=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:n,ids:u,withoutExpired:g,q:h,limit:l,offset:y}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:n,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:Em.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(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(a.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:_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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:Dm.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,ids:u,withoutExpired:g,q:h,limit:l,offset:y}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:n,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:Qd.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(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(a.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:n}=o,u={feature_id:t,q:s,limit:r,offset:n},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:Tm.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n}=o,u={feature_id:t,q:s,limit:r,offset:n},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:rm.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n,managedBy:u,q:g,withoutNegativeEntitlements:h,limit:l,offset:y}=o,w={company_id:t,company_keys:s!=null?Ue(s):void 0,feature_ids:r,include_usage_aggregation:n,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:km.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(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(a.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:n,startTime:u}=o,g={company_id:t,end_time:s.toISOString(),feature_id:r,granularity:n!=null?Xe.jsonOrThrow(n,{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: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 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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:n,managedBy:u,q:g,withoutNegativeEntitlements:h,limit:l,offset:y}=o,w={company_id:t,company_keys:s!=null?Ue(s):void 0,feature_ids:r,include_usage_aggregation:n,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:om.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(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new x(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new _(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new P(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new S(a.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:n}=o,u={feature_id:t,q:s,limit:r,offset:n},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: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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n}=o,u={feature_id:t,q:s,limit:r,offset:n},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: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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n,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:n,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:qm.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(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new x(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new P(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:En.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(n.ok)return{data:Mm.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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:Im.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,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:n,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:sm.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(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new x(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new _(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new P(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Ue(t)},r=await this._options.authProvider.getAuthRequest(),n=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:n,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:bm.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(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(a.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 ia=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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n}=o,u={q:t,event_subtypes:s,limit:r,offset:n},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:Zm.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n,idempotencyKey:u,userId:g,limit:h,offset:l}=o,y={company_id:t,event_subtype:s,event_types:Array.isArray(r)?r.map(O=>Pr.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"})):r!=null?Pr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,flag_id:n,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:rh.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(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 401:throw new x(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 403:throw new _(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 404:throw new P(a.parseOrThrow(T.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),T.rawResponse);case 500:throw new S(a.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:lt.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Jm.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Qm.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(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(a.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 oa=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:n,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:n!=null?k.jsonOrThrow(n,{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:_h.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(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new x(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new P(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:xh.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,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:n!=null?k.jsonOrThrow(n,{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:dh.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(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new x(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new _(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new P(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={feature_id:t,ids:s,q:r,limit:n,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:Ph.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:Eh.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:bh.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:vh.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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),n=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:po.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(n.ok)return{data:th.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:po.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={feature_id:t,ids:s,q:r,limit:n,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:hh.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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 ta=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(),n=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:n,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:jh.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(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(a.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:n}=o,u={end_time:t.toISOString(),feature_id:s,granularity:r!=null?Xe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:n.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:qh.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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(),n=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:n,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:Gh.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(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(a.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:Hh.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(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(a.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,n={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(n).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Zh.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(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(a.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:n}=o,u={end_time:t.toISOString(),feature_id:s,granularity:r!=null?Xe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:n.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:Ih.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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 aa=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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,type:u,limit:g,offset:h}=o,l={billing_only:t,exclude_ids:s,id:r,state:n!=null?Ve.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,type:u!=null?_e.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:dg.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(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new x(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new P(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new S(a.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: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 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Ft.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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:hg.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(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new P(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new S(a.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:Ft.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:Ft.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:lg.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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 na=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: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:_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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:Vn.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(n.ok)return{data:Pg.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.rawResponse,"PUT","/plan-bundles/{plan_bundle_id}")}};var sa=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(),n=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:n,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:kg.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(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new _(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new P(a.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new S(a.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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:Bg.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.rawResponse,"PUT","/plan-groups/{plan_group_id}")}};var ca=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:n,offset:u}=o,g={migration_id:t,q:s,status:r!=null?Er.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:n,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:Fg.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={migration_id:t,q:s,status:r!=null?Er.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:n,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:Ag.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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:n}=o,u={plan_version_id:t,status:s!=null?Cr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:n},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:Lg.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:Wg.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:n}=o,u={plan_version_id:t,status:s!=null?Cr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:n},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:qg.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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 la=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),n=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: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(n.ok)return{data:hy.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:n,limit:u,offset:g}=o,h={company_id:t,plan_id:s,status:r!=null?Rr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,statuses:Array.isArray(n)?n.map(U=>Rr.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"})):n!=null?Rr.jsonOrThrow(n,{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:ny.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(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new x(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new P(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new S(a.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),n=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:Ky.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(n.ok)return{data:uy.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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),n=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:Wn.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(n.ok)return{data:my.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,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:n,for_initial_plan:u,for_trial_expiry_plan:g,has_product_id:h,ids:l,include_draft_versions:y,plan_type:w!=null?oe.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},pe=await this._options.authProvider.getAuthRequest(),Ce=f(pe.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:Ce,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:py.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(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(a.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: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:Zg.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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},n=await this._options.authProvider.getAuthRequest(),u=f(n.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:iy.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(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(a.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),n=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:xt.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(n.ok)return{data:gy.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:$r.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(n.ok)return{data:yy.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n}=o,u={plan_id:t,q:s,limit:r,offset:n},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:ty.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n}=o,u={plan_id:t,q:s,limit:r,offset:n},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:Hg.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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:n,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:n,for_initial_plan:u,for_trial_expiry_plan:g,has_product_id:h,ids:l,include_draft_versions:y,plan_type:w!=null?oe.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},pe=await this._options.authProvider.getAuthRequest(),Ce=f(pe.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:Ce,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:Jg.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(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new x(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new _(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new P(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new S(a.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},n=await this._options.authProvider.getAuthRequest(),u=f(n.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:cy.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(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(a.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},n=await this._options.authProvider.getAuthRequest(),u=f(n.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:ey.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(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new x(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new P(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:dy.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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:n}=o,u={company_id:t,status:s!=null?Yr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:n},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:fy.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(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new x(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new P(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new S(a.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: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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:zy.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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:$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(n.ok)return{data:_y.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.rawResponse,"PUT","/scheduled-checkout/{scheduled_checkout_id}")}};var ua=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:n,offset:u}=o,g={ids:t,q:s,webhook_id:r,limit:n,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:By.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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: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 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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:n,offset:u}=o,g={ids:t,q:s,webhook_id:r,limit:n,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:Py.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(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new x(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new P(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new S(a.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,n={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(n).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Ay.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(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(a.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: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: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 400:throw new v(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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: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 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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: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(n.ok)return{data:Dy.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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: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(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new x(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new P(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new S(a.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),n=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:Yn.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(n.ok)return{data:qy.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new v(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new x(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new P(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new S(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);default:throw new b({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}return C(n.error,n.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,n={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(n).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Ey.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(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new x(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new P(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new S(a.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 da=class{constructor(o){this._options=K(o)}get accounts(){return this._accounts??=new Ht(this._options)}get billing(){return this._billing??=new $t(this._options)}get credits(){return this._credits??=new Qt(this._options)}get checkout(){return this._checkout??=new Jt(this._options)}get companies(){return this._companies??=new Yt(this._options)}get entitlements(){return this._entitlements??=new ra(this._options)}get plans(){return this._plans??=new la(this._options)}get components(){return this._components??=new Zt(this._options)}get planbundle(){return this._planbundle??=new na(this._options)}get dataexports(){return this._dataexports??=new ea(this._options)}get events(){return this._events??=new ia(this._options)}get features(){return this._features??=new oa(this._options)}get insights(){return this._insights??=new ta(this._options)}get integrationsapi(){return this._integrationsapi??=new aa(this._options)}get plangroups(){return this._plangroups??=new sa(this._options)}get planmigrations(){return this._planmigrations??=new ca(this._options)}get componentspublic(){return this._componentspublic??=new Xt(this._options)}get scheduledcheckout(){return this._scheduledcheckout??=new pa(this._options)}get accesstokens(){return this._accesstokens??=new Nt(this._options)}get webhooks(){return this._webhooks??=new ua(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 Ta(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 Qe={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},ns={[Qe.Debug]:1,[Qe.Info]:2,[Qe.Warn]:3,[Qe.Error]:4},Qy=Qe.Warn,Xr=class{constructor(o=Qy){this.level=ns[o]??ns[Qy]}shouldLog(o){return ns[o]>=this.level}error(o,...i){this.shouldLog(Qe.Error)&&console.error(o,...i)}warn(o,...i){this.shouldLog(Qe.Warn)&&console.warn(o,...i)}info(o,...i){this.shouldLog(Qe.Info)&&console.info(o,...i)}debug(o,...i){this.shouldLog(Qe.Debug)&&console.debug(o,...i)}};var qz=1e3,Dz=1e3,Mz=3,Iz=1e3,ma=class{constructor(o,i){this.events=[];this.intervalId=null;this.shutdown=!1;this.stopped=!1;this.flushing=!1;let{logger:t=new Xr,maxSize:s=Dz,interval:r=qz,offline:n=!1,maxRetries:u=Mz,initialRetryDelay:g=Iz}=i||{};this.captureClient=o,this.interval=r,this.logger=t,this.maxSize=s,this.offline=n,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 n=this.initialRetryDelay*Math.pow(2,i-1),u=Math.random()*.1*n,g=n+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 Fz="https://c.schematichq.com",Kz=1e4,Lz=p=>p.replace(/\/+$/,"")+"/batch",Gz=(p,o)=>{let i={api_key:o,type:p.eventType};return p.body!==void 0&&(i.body=ct.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},Wz=(p,o)=>({events:p.map(i=>Gz(i,o))}),Nz=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"}},ha=class{constructor(o){this.apiKey=o.apiKey,this.baseUrl=o.baseUrl??Fz,this.timeoutMs=o.timeoutMs??Kz,this.fetcher=o.fetcher,this.headers=o.headers??{}}async sendBatch(o){if(o.length===0)return;let i=await this.fetcher({url:Lz(this.baseUrl),method:"POST",contentType:"application/json",requestType:"json",headers:{...this.headers,"X-Schematic-Api-Key":this.apiKey},body:Wz(o,this.apiKey),timeoutMs:this.timeoutMs,maxRetries:0});if(!i.ok)throw new Error(`capture service returned ${Nz(i.error)}`)}};function ew(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}`:Po(i.url,i.queryParameters),r=await xo({body:i.body,type:i.requestType==="json"?"json":"other"}),n=await pi();try{let u=await hi(async()=>ui(n,s,i.method,t,r,i.timeoutMs,i.abortSignal,i.withCredentials,i.duplex),i.maxRetries),g=await li(u,i.responseType),h=io(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:di}:u instanceof Error&&u.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:di}:u instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:u.message},rawResponse:mi}:{ok:!1,error:{reason:"unknown",errorMessage:JSON.stringify(u)},rawResponse:mi}}}}async function Hz(p){return{ok:!0,body:{},headers:{"Content-Type":"application/json"},rawResponse:{headers:new rr,redirected:!1,status:200,statusText:"OK",type:"basic",url:""}}}var rw=Hz;var Ji=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=(n,u)=>u===null?void 0:u;try{let n=JSON.stringify(o,r),u=i?JSON.stringify(i,r):void 0,g=t?JSON.stringify(t,r):void 0,h=s?JSON.stringify($z(s),r):void 0,l=this.wasmInstance.checkFlagWithOptions(n,u,g,h);return JSON.parse(l)}catch(n){throw new Error(`WASM flag check failed: ${n}`)}}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 $z(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 Jz={unrecognizedObjectKeys:"passthrough"};function iw(p,o){let i=p.parse(o,Jz);return i.ok?i.value:o}function ls(p){return JSON.parse(JSON.stringify(p))}function Yz(p){return JSON.parse(JSON.stringify(p))}function ow(p,o){let i=ls(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 n=o[r]??[];i.entitlements=n.map(u=>iw(Kt,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 n=i.keys??{},u=o[r];i.keys={...n,...u};break}case"credit_balances":{let n=i.creditBalances??{},u=o[r]??{};i.creditBalances={...n,...u},t=u;break}case"credit_lease_balance":{let n=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={...n,...g},t={...t??{},...g};break}case"metrics":{let n=i.metrics??[],u=(o[r]??[]).map(g=>iw(Lt,g));i.metrics=Xz(n,u),s=!0;break}}return(t||s)&&!("entitlements"in o)&&Zz(i,t,s),i}function Zz(p,o,i){let t=p.entitlements??[];if(t.length===0)return;let s=new Map;if(i){let r=p.metrics??[];for(let n of r)n&&s.set(ga(cs(n)),n.value??0)}for(let r of t){let n=r.creditId??r.credit_id;o&&n&&n in o&&(r.creditRemaining=o[n],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(ga({eventSubtype:u,period:g,monthReset:h}));l!==void 0&&(r.usage=l)}}}function tw(p,o){let i=Yz(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 ga(p){return`${p.eventSubtype}|${p.period}|${p.monthReset}`}function cs(p){return{eventSubtype:(p.eventSubtype??p.event_subtype)||"",period:p.period||"",monthReset:(p.monthReset??p.month_reset)||""}}function Xz(p,o){let i=[...p],t=new Map;for(let s=0;s<i.length;s++){let r=i[s];if(r){let n=ga(cs(r));t.set(n,s)}}for(let s of o){if(!s)continue;let r=ga(cs(s)),n=t.get(r);n!==void 0?i[n]=s:i.push(s)}return i}var ur="company",dr="user",nR="flags",us=30*1e3,sR=1440*60*1e3,cR=720*60*60*1e3,mo=class extends Yi{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??sR,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 Ji}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 ri({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:r})):(this.logger.debug(`Using memory cache provider for ${t} cache (TTL: ${r}ms)`),new er({ttl:r}))}createKeyCacheProvider(i){let t=this.cacheTTL;return i.redisClient?new ri({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:t}):new er({ttl:t})}calculateCacheTTL(i){return i==="flag"?Math.max(cR,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}=(mw(),zs(dw));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 n of s)if(this.pendingCompanyRequests.has(n)){r=!0;break}return new Promise((n,u)=>{let g=setTimeout(()=>{this.cleanupPendingCompanyRequests(s,h),u(new Error("Timeout while waiting for company data"))},us),h=l=>{clearTimeout(g),l?n(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 n of s)if(this.pendingUserRequests.has(n)){r=!0;break}return new Promise((n,u)=>{let g=setTimeout(()=>{this.cleanupPendingUserRequests(s,h),u(new Error("Timeout while waiting for user data"))},us),h=l=>{clearTimeout(g),l?n(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"))},us);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 n=i.company&&Object.keys(i.company).length>0,u=i.user&&Object.keys(i.user).length>0,g=null,h=null;if(n&&(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((!n||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=n&&!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 n=this.deepCopyCompany(r);if(n.metrics)for(let u of n.metrics)(u.eventSubtype??u.event_subtype)===t&&(u.value=(u.value||0)+s);await this.cacheCompanyForKeys(n)}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 n=await r.json(),u=n.cache_version||n.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(ur,s),n=await this.companyCacheProvider.get(r);if(!n){this.logger.warn(`Cache miss for partial company '${s}', skipping`);return}try{t=ow(n,i.data)}catch(u){this.logger.error(`Failed to merge partial company: ${u}`);return}}else try{t=Zy.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,n]of Object.entries(t.keys)){let u=this.resourceKeyToCacheKey(ur,r,n);try{await this.companyKeyCacheProvider.delete(u)}catch(g){this.logger.warn(`Failed to delete company key mapping from cache: ${g}`)}}let s=this.resourceIdCacheKey(ur,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(dr,s),n=await this.userCacheProvider.get(r);if(!n){this.logger.warn(`Cache miss for partial user '${s}', skipping`);return}try{t=tw(n,i.data)}catch(u){this.logger.error(`Failed to merge partial user: ${u}`);return}}else try{t=Xy.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,n]of Object.entries(t.keys)){let u=this.resourceKeyToCacheKey(dr,r,n);try{await this.userKeyCacheProvider.delete(u)}catch(g){this.logger.warn(`Failed to delete user key mapping from cache: ${g}`)}}let s=this.resourceIdCacheKey(dr,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,n;for(let l of t)try{s.push(is.parseOrThrow(l,{unrecognizedObjectKeys:"passthrough"}))}catch(y){r++,n===void 0&&(n=y)}r>0&&this.logger.warn(`Failed to deserialize ${r} flag(s) in bulk message: ${String(n)}`);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=is.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(ur,t,s);try{let n=await this.companyKeyCacheProvider.get(r);if(n){let u=this.resourceIdCacheKey(ur,n),g=await this.companyCacheProvider.get(u);if(g)return g}}catch(n){this.logger.warn(`Failed to retrieve company from cache: ${n}`)}}return null}async getUserFromCache(i){for(let[t,s]of Object.entries(i)){let r=this.resourceKeyToCacheKey(dr,t,s);try{let n=await this.userKeyCacheProvider.get(r);if(n){let u=this.resourceIdCacheKey(dr,n),g=await this.userCacheProvider.get(u);if(g)return g}}catch(n){this.logger.warn(`Failed to retrieve user from cache: ${n}`)}}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(ur,i.id),s=await this.companyCacheProvider.get(t);if(s?.keys){for(let[r,n]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==n){let u=this.resourceKeyToCacheKey(ur,r,n);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,n]of Object.entries(i.keys)){let u=this.resourceKeyToCacheKey(ur,r,n);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(dr,i.id),s=await this.userCacheProvider.get(t);if(s?.keys){for(let[r,n]of Object.entries(s.keys))if(i.keys[r]===void 0||i.keys[r]!==n){let u=this.resourceKeyToCacheKey(dr,r,n);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,n]of Object.entries(i.keys)){let u=this.resourceKeyToCacheKey(dr,r,n);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(ur,t,s))}generateCacheKeysForUser(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(dr,t,s))}notifyPendingCompanyRequests(i,t){for(let[s,r]of Object.entries(i)){let n=this.resourceKeyToCacheKey(ur,s,r),u=this.pendingCompanyRequests.get(n);u&&(this.pendingCompanyRequests.delete(n),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 n=this.resourceKeyToCacheKey(dr,s,r),u=this.pendingUserRequests.get(n);u&&(this.pendingUserRequests.delete(n),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 n=r.indexOf(t);n!==-1&&r.splice(n,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 n=r.indexOf(t);n!==-1&&r.splice(n,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(),n=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&&!n?(this.logger.info("External replicator is now ready"),this.emit("replicator-health-changed",!0)):!this.replicatorReady&&n&&(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=`${nR}:${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 ls(i)}async evaluateFlag(i,t,s,r){let n=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??n,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:n,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:n,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 He(p,o){return`${p}:${o}`}var ho=class{constructor(){this.leases=new Map;this.locks=new Map}get(o,i){let t=this.leases.get(He(o,i));return t?{...t}:void 0}async replace(o){let i=He(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 n=He(o,i);return this.withLock(n,()=>{let u=this.leases.get(n);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=He(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=He(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=He(o,i);return this.withLock(r,()=>{let n=this.leases.get(r);n&&(s!==void 0&&n.leaseId!==s||(n.localRemainingCredits=Math.min(n.localRemainingCredits+t,n.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),n=t.then(()=>r);this.locks.set(o,n),await t;try{return await i()}finally{s(),this.locks.get(o)===n&&this.locks.delete(o)}}};var go=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 yo=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=He(o,i),n=this.inflightAcquire.get(r);if(n)return n;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(n){this.logger.error(`Failed to acquire credit lease for ${o}/${i}: ${n}`);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 n=this.resolveConfig(i),g=r.localRemainingCredits/Math.max(r.grantedAmount,1)<=n.lowWaterMark,h=t!==void 0&&r.localRemainingCredits<t;if(!g&&!h)return r;let l=He(o,i),y=this.inflightExtend.get(l);if(y)return y;let w=this.extend(r,n,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,n={additionalAmount:Math.max(i.leaseSize,r),expiresAt:new Date(Date.now()+i.leaseDuration)};try{let g=(await this.creditsClient.extendCreditLease(o.leaseId,n,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 pR="schematic:",uR="credit-lease:",hw=6e4,gw=`
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
- `,nR=cw+`
7
+ `,dR=gw+`
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
- `,sR=cw+`
29
+ `,mR=gw+`
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
- `,cR=`
40
+ `,hR=`
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
- `,lR=`
55
+ `,gR=`
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
- `,bt=class{constructor(t){this.client=t.client,this.keyPrefix=t.keyPrefix??oR,this.defaultLeaseDurationMs=t.defaultLeaseDurationMs??3e5}hashKey(t,i){return`${this.keyPrefix}${aR}${$e(t,i)}`}async get(t,i){let o=await this.client.hGetAll(this.hashKey(t,i));if(!(!o||!o.leaseId))return pR(o)}async replace(t){let i=await this.client.eval(nR,{keys:[this.hashKey(t.companyId,t.creditTypeId)],arguments:[t.leaseId,String(t.grantedAmount),String(t.expiresAt.getTime()),String(sw),t.companyId,t.creditTypeId]});return Number(i)===1}async extend(t,i,o,s,r){let a=(s??new Date(Date.now()+this.defaultLeaseDurationMs)).getTime();await this.client.eval(lR,{keys:[this.hashKey(t,i)],arguments:[String(o),String(a),String(sw),r??""]})}async drop(t,i){await this.client.del(this.hashKey(t,i))}async tryReserve(t,i,o){if(!Number.isFinite(o)||o<0)return null;let s=await this.client.eval(sR,{keys:[this.hashKey(t,i)],arguments:[String(o)]});return s==null?null:Number(s)}async refund(t,i,o,s){o<=0||await this.client.eval(cR,{keys:[this.hashKey(t,i)],arguments:[String(o),s??""]})}};function pR(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 uR="schematic:",dR="credit-reservation:",mR="credit-reservations:byExpiry",hR="credit-reservations:byCredit:";var gR=`
80
+ `,wo=class{constructor(o){this.client=o.client,this.keyPrefix=o.keyPrefix??pR,this.defaultLeaseDurationMs=o.defaultLeaseDurationMs??3e5}hashKey(o,i){return`${this.keyPrefix}${uR}${He(o,i)}`}async get(o,i){let t=await this.client.hGetAll(this.hashKey(o,i));if(!(!t||!t.leaseId))return yR(t)}async replace(o){let i=await this.client.eval(dR,{keys:[this.hashKey(o.companyId,o.creditTypeId)],arguments:[o.leaseId,String(o.grantedAmount),String(o.expiresAt.getTime()),String(hw),o.companyId,o.creditTypeId]});return Number(i)===1}async extend(o,i,t,s,r){let n=(s??new Date(Date.now()+this.defaultLeaseDurationMs)).getTime();await this.client.eval(gR,{keys:[this.hashKey(o,i)],arguments:[String(t),String(n),String(hw),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(mR,{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(hR,{keys:[this.hashKey(o,i)],arguments:[String(t),s??""]})}};function yR(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 wR="schematic:",bR="credit-reservation:",zR="credit-reservations:byExpiry",RR="credit-reservations:byCredit:";var fR=`
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 lw(p){return`${p.companyId}|${p.creditTypeId}|${p.id}`}function yR(p){let t=p.split("|");if(t.length===3)return{companyId:t[0],creditTypeId:t[1],id:t[2]}}var pw=256,wR=16,zt=class{constructor(t){this.sweepInterval=null;this.stopped=!1;this.client=t.client,this.leaseStore=t.leaseStore,this.sweepIntervalMs=t.sweepIntervalMs??1e3,this.keyPrefix=t.keyPrefix??uR}hashKey(t){return`${this.keyPrefix}${dR}${t}`}indexKey(){return`${this.keyPrefix}${mR}`}byCreditKey(t,i){return`${this.keyPrefix}${hR}${t}:${i}`}async add(t){let i=t.expiresAt.getTime(),o=this.hashKey(t.id);await this.client.hSet(o,{id:t.id,leaseId:t.leaseId,companyId:t.companyId,creditTypeId:t.creditTypeId,eventSubtype:t.eventSubtype,quantityReserved:String(t.quantityReserved),creditsReserved:String(t.creditsReserved),consumptionRate:String(t.consumptionRate),expiresAt:String(i),evalCtx:JSON.stringify(t.evalCtx)}),await Promise.all([this.client.pExpireAt(o,i+3e4),this.client.zAdd(this.indexKey(),{score:i,value:lw(t)}),this.client.hSet(this.byCreditKey(t.companyId,t.creditTypeId),t.id,String(t.creditsReserved))])}async get(t){let i=await this.client.hGetAll(this.hashKey(t));if(!(!i||!i.id))return zR(i)}async reservedCredits(t,i){let o=await this.client.hGetAll(this.byCreditKey(t,i)).catch(()=>({})),s=0;for(let r of Object.values(o))s+=Number(r)||0;return s}async consume(t,i){let o=await this.client.eval(gR,{keys:[this.hashKey(t)],arguments:[]}),s=bR(o);if(!s||!s.id)return null;let r=s.companyId,a=s.creditTypeId,u=Number(s.creditsReserved)||0;await this.client.zRem(this.indexKey(),lw({companyId:r,creditTypeId:a,id:t})).catch(()=>{}),await this.client.hDel(this.byCreditKey(r,a),t).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(t=new Date){let i=t.getTime(),o=0;for(let s=0;s<wR;s++){let r=await this.client.zRangeByScore(this.indexKey(),0,i,{LIMIT:{offset:0,count:pw}});if(r.length===0)break;for(let a of r){let u=yR(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){o++;continue}await this.client.hDel(this.byCreditKey(u.companyId,u.creditTypeId),u.id).catch(()=>{})}if(r.length<pw)break}return o}stop(){this.stopped=!0,this.sweepInterval&&(clearInterval(this.sweepInterval),this.sweepInterval=null)}async size(){return this.client.zCard(this.indexKey()).catch(()=>0)}};function bR(p){if(!Array.isArray(p)||p.length===0)return;let t={};for(let i=0;i+1<p.length;i+=2)t[String(p[i])]=String(p[i+1]);return t}function zR(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 mw=require("crypto");function Xi(p,t,i,o){return p.enqueueFlagCheckEvent({flagKey:i.flagKey,value:i.value,reason:i.reason,error:i.err,flagId:i.flagId,companyId:o?.companyId,userId:o?.userId,ruleId:o?.ruleId,reqCompany:t.company,reqUser:t.user}),i}async function hw(p,t,i,o,s){let{datastream:r,leaseStore:a,reservations:u,manager:g,logger:h}=p,c=o.onAcquireFailure??"fail-closed";if(o.usage===void 0||!Number.isFinite(o.usage)||o.usage<0)return h.error(`Lease check: invalid usage ${o.usage} for flag ${t} \u2014 must be a finite, non-negative number`),Xi(p,i,wa(c,t,"invalid_usage",null));if(o.usage===0)return h.debug(`Lease check: usage is 0 for flag ${t} \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(t)}catch(Ue){h.warn(`Lease check: failed to load flag ${t}: ${Ue}`)}if(!y)return h.debug(`Lease check: no cached flag for ${t}, falling back`),s();let{eventSubtype:w,quantity:U}=fR(o);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(Ue){h.debug(`Lease check: company fetch failed for keys ${JSON.stringify(i.company)} (${Ue}), falling back`)}if(!T)return s();let O=null;if(i.user){try{O=await r.getUser(i.user)}catch(Ue){h.debug(`Lease check: user fetch failed for keys ${JSON.stringify(i.user)} (${Ue}), falling back`)}if(!O)return s()}let j=await _R(r,y,T,O,w,h);if(!j)return h.debug(`Lease check: flag ${t} has no matching credit condition (subtype=${w??"<none>"}), falling back`),s();let B=j.condition.creditId,I=j.condition.consumptionRate??0;if(I<=0)return h.debug("Lease check: condition has no consumption_rate, falling back"),s();let A=w??j.condition.eventSubtype;if(!A)return h.debug("Lease check: credit condition has no event subtype, falling back"),s();let X=U*I,_e=o.timeoutMs!==void 0?{timeoutInSeconds:o.timeoutMs/1e3}:void 0,q=Ue=>ER({datastream:r,logger:h,mode:c,key:t,reason:Ue,flag:y,company:T,user:O,creditId:B,options:o}).then(Rt=>Xi(p,i,Rt,{companyId:T.id,userId:O?.id})),M=await g.acquireIfNeeded(T.id,B,_e);if(!M)return q("lease_acquire_failed");let hr;try{hr=await a.tryReserve(T.id,B,X),hr===null&&(await g.maybeExtendInBackground(T.id,B,X,_e),hr=await a.tryReserve(T.id,B,X))}catch(Ue){return h.error(`Lease check: reserve against ${T.id}/${B} failed: ${Ue}`),q("lease_store_error")}if(hr===null)return q("insufficient_lease_balance");let Ve=PR({leaseId:M.leaseId,companyId:T.id,creditTypeId:B,eventSubtype:A,quantityReserved:U,creditsReserved:X,consumptionRate:I,reservationTTL:RR(p,B),evalCtx:i});try{await u.add(Ve)}catch(Ue){h.error(`Lease check: failed to persist reservation ${Ve.id}: ${Ue}`);try{await u.consume(Ve.id,0)===null&&await a.refund(T.id,B,X,M.leaseId)}catch(Rt){h.warn(`Lease check: could not undo local debit for ${Ve.id} (${Rt}); the slice is reclaimed at lease expiry`)}return q("lease_store_error")}let F=hr+X,gr=gw(T,B,F),_w=ba(o),ue;try{ue=await r.getRulesEngine().checkFlagWithOptions(y,gr,O??null,_w)}catch(Ue){return h.error(`Lease check: WASM eval failed: ${Ue}`),await ms(u,Ve,h),Xi(p,i,wa(c,t,`wasm_error: ${Ue}`,y),{companyId:T.id,userId:O?.id})}let Sa={companyId:ue.companyId??T.id,userId:ue.userId??O?.id,ruleId:ue.ruleId};return ue.value?ue.ruleId!==void 0&&ue.ruleId!==j.ruleId?(h.debug(`Lease check: flag ${t} allowed by rule ${ue.ruleId} (${ue.ruleType??"unknown type"}), not the credit-metered rule ${j.ruleId} \u2014 cancelling reservation, no credits billed`),await ms(u,Ve,h),Xi(p,i,{allowed:!0,value:!0,reason:ue.reason??"allowed_without_credit_rule",entitlement:ya(ue.entitlement),flagKey:ue.flagKey??t,flagId:ue.flagId},Sa)):(g.maybeExtendInBackground(T.id,B),Xi(p,i,{allowed:!0,value:!0,reservation:Ve,reason:ue.reason??"lease_reserved",entitlement:ya(ue.entitlement),flagKey:ue.flagKey??t,flagId:ue.flagId},Sa)):(await ms(u,Ve,h),Xi(p,i,{allowed:!1,value:!1,reason:ue.reason??"denied_by_engine",entitlement:ya(ue.entitlement),flagKey:ue.flagKey??t,flagId:ue.flagId},Sa))}function RR(p,t){return p.manager.resolveConfig(t)}function fR(p){return{eventSubtype:p.eventSubtype,quantity:p.usage??0}}function ba(p){if(p.usage!==void 0)return p.eventSubtype!==void 0?{eventUsage:{eventSubtype:p.eventSubtype,quantity:p.usage}}:{usage:p.usage}}async function _R(p,t,i,o,s,r){let a=uw(t,s);if(!a)return null;if(SR(t,s).size<=1)return a;try{let g=(await p.getRulesEngine().checkFlagWithOptions(t,i,o,null)).entitlement?.creditId;if(g){let h=uw(t,s,g);if(h)return h;r.debug(`Lease check: entitlement credit ${g} has no matching condition on flag, falling back to first credit condition`)}}catch(u){r.warn(`Lease check: credit-resolution probe failed (${u}), falling back to first credit condition`)}return a}function SR(p,t){let i=new Set,o=s=>{for(let r of s)r.conditionType!=="credit"||!r.creditId||t!==void 0&&r.eventSubtype!==t||i.add(r.creditId)};for(let s of p.rules??[]){o(s.conditions??[]);for(let r of s.conditionGroups??[])o(r.conditions??[])}return i}function uw(p,t,i){for(let o of p.rules??[]){let s=dw(o.conditions??[],t,i);if(s)return{...s,ruleId:o.id};for(let r of o.conditionGroups??[]){let a=dw(r.conditions??[],t,i);if(a)return{...a,ruleId:o.id}}}return null}function dw(p,t,i){for(let o of p)if(o.conditionType==="credit"&&o.creditId&&!(t!==void 0&&o.eventSubtype!==t)&&!(i!==void 0&&o.creditId!==i))return{condition:o};return null}function gw(p,t,i){return{...p,creditBalances:{...p.creditBalances??{},[t]:i}}}function PR(p){return{id:(0,mw.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 ya(p){if(p)return{...p,metricResetAt:p.metricResetAt?new Date(p.metricResetAt):void 0}}async function ms(p,t,i){try{await p.consume(t.id,0)}catch(o){i.warn(`Lease check: failed to cancel reservation ${t.id} (${o}); its hold is reclaimed by the sweeper or at lease expiry`)}}var xR=Number.MAX_SAFE_INTEGER;async function ER(p){let{datastream:t,logger:i,mode:o,key:s,reason:r,flag:a,company:u,user:g,creditId:h,options:c}=p;if(o==="fail-closed")return wa(o,s,r,a);try{let y=gw(u,h,xR),w=await t.getRulesEngine().checkFlagWithOptions(a,y,g,ba(c));return{allowed:w.value,value:w.value,reason:`${w.reason??"evaluated"} (${r}_fail_open)`,entitlement:ya(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`),wa(o,s,r,a)}}function wa(p,t,i,o){return p==="fail-closed"?{allowed:!1,value:!1,reason:i,flagKey:t,flagId:o?.id,err:i}:{allowed:!0,value:!0,reason:`${i}_fail_open`,flagKey:t,flagId:o?.id,err:i}}async function yw(p,t,i,o){let s=i*t.consumptionRate,r=await p.consume(t.id,s);return{track:za(t,i,o),settledLocally:r!==null}}function za(p,t,i){let o={event:p.eventSubtype,quantity:t,leaseId:p.leaseId};return p.evalCtx.company&&(o.company=p.evalCtx.company),p.evalCtx.user&&(o.user=p.evalCtx.user),i?.traits&&(o.traits=i.traits),o}var bw="lease-reservation:",Ra=class extends da{constructor(i){let{apiKey:o="",basePath:s,eventBufferInterval:r,eventCaptureBaseURL:a,flagDefaults:u={},logLevel:g,timeoutMs:h}=i??{},{offline:c=!1}=i??{},y=i?.logger??new Qr(g),w={};i?.environmentId&&(w["X-Schematic-Environment-Id"]=i.environmentId),i?.headers&&Object.assign(w,i.headers),c?o!==""&&y.debug("Offline mode enabled, ignoring API key"):o===""&&!c&&(y.warn("No API key was provided, running in offline mode"),c=!0);let U=c?$y:Hy(w);super({apiKey:o,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[B,I]of Object.entries(O))typeof I=="string"&&(T[B]=I);let j=new ha({apiKey:o,fetcher:U,headers:T,baseUrl:a,timeoutMs:h});if(this.eventBuffer=new ma(j,{interval:r,logger:y,offline:c}),this.flagCheckCacheProviders=i?.cacheProviders?.flagChecks??[new rr],this.flagDefaults=u,this.offline=c,i?.useDataStream&&!c){let I=["workerd","edge-runtime","browser","web-worker"].includes(fe.type),A=i.dataStream?.replicatorMode===!0;if(I&&!A)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 X={apiKey:o,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 ht(X),this.datastreamClient.start().catch(_e=>{y.error(`Failed to start DataStream client: ${_e}`),this.datastreamClient=void 0})}}if(i?.creditLeases&&c&&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&&!c){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 B=i.creditLeases.sweepIntervalMs??1e3,I=i.creditLeases.redisClient??i.dataStream?.redisClient,A=i.creditLeases.redisKeyPrefix??i.dataStream?.redisKeyPrefix;I?(this.leaseBackendShared=!0,this.leaseStore=new bt({client:I,keyPrefix:A,defaultLeaseDurationMs:i.creditLeases.defaultLeaseDuration}),this.reservations=new zt({client:I,leaseStore:this.leaseStore,sweepIntervalMs:B,keyPrefix:A})):(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 gt,this.reservations=new yt(this.leaseStore,B)),this.reservations.startSweep(),this.creditLeaseManager=new wt({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,o,s){return(await this.checkFlagWithEntitlement(i,o,s)).value}async checkFlagWithEntitlement(i,o,s){let r=()=>s?.defaultValue===void 0?this.getFlagDefault(o):typeof s.defaultValue=="function"?s.defaultValue():s.defaultValue;if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag value for flag ${o}`),{flagKey:o,reason:"flag default",value:r()};if(this.useDataStream())try{let a=await this.datastreamClient.checkFlag(i,o,s);return this.enqueueEvent(_t.FlagCheck,{flagKey:o,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??o,flagId:a.flagId,reason:a.reason,ruleId:a.ruleId,ruleType:a.ruleType,userId:a.userId,value:a.value??this.getFlagDefault(o)}}catch(a){return this.logger.debug(`Datastream flag check failed (${a}), falling back to API`),this.checkFlagViaAPI(i,o,s,r)}return this.checkFlagViaAPI(i,o,s,r)}async checkFlagViaAPI(i,o,s,r){let a=r??(()=>this.getFlagDefault(o));try{let u=JSON.stringify({evalCtx:i,key:o});for(let c of this.flagCheckCacheProviders){let y=await c.get(u);if(y!=null)return this.logger.debug(`${c.constructor.name} cache hit for flag ${o}`),y}let g=await this.features.checkFlag(o,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 ${o}, falling back to default`),{flagKey:o,reason:"flag default",value:a()};this.logger.debug(`Feature flag API response for ${o}: ${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 c of this.flagCheckCacheProviders)this.logger.debug(`Caching value for flag ${o} in ${c.constructor.name}`),await c.set(u,h)}catch(c){this.logger.warn(`Cache write failed for flag ${o}: ${c}`)}return h}catch(u){return this.logger.error(`Error checking flag ${o}: ${u}`),{flagKey:o,reason:"flag default",value:a()}}}async checkFlags(i,o){if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag values for flags ${o?o.join(", "):"all"}`),o&&o.length>0?o.map(s=>({flag:s,value:this.getFlagDefault(s),reason:"Offline mode - using default value"})):[];try{if(this.useDataStream()&&this.datastreamClient.isConnected()&&o&&o.length>0){let w=await this.checkFlagsViaDataStream(i,o);if(w)return w}if(!o||o.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(o.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 ${o.length} flags found in cache`),o.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=[],c=new Map(g.map(w=>[w.flag,w])),y=[];for(let w of o){let U=c.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 ${o.length} flags: used fresh API values for consistency (${r.length} were cache misses)`),h}catch(s){return this.logger.error(`Error checking flags ${o?o.join(", "):"all"}: ${s}`),o&&o.length>0?o.map(r=>({flag:r,value:this.getFlagDefault(r),reason:`Error occurred - using default value: ${s}`})):[]}}async checkFlagsViaDataStream(i,o){let s=[];for(let r of o)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 ${o.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,o){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(o.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 o=this.datastreamClient;if(!o||this.prewarmResolveTimeoutMs<=0)return this.resolveCompanyId(i);let s=i.company,r=await o.getCachedCompany(s);if(r?.id)return r.id;let a=Date.now()+this.prewarmResolveTimeoutMs;for(;;){try{let u=await o.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,o,s){let r=async()=>{let u=await this.checkFlagWithEntitlement(i,o,{defaultValue:s?.defaultValue,timeoutMs:s?.timeoutMs,...s?ba(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():hw({leaseStore:this.leaseStore,reservations:this.reservations,manager:this.creditLeaseManager,datastream:this.datastreamClient,logger:this.logger,enqueueFlagCheckEvent:u=>this.enqueueEvent(_t.FlagCheck,u)},o,i,s,r)}async trackWithReservation(i,o,s){if(this.offline)return;if(!Number.isFinite(o)||o<0){this.logger.error(`trackWithReservation: invalid actualQuantity ${o} 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(za(i,o,s),{idempotencyKey:`${bw}${i.id}`});return}let r,a;try{({track:r,settledLocally:a}=await yw(this.reservations,i,o,s))}catch(u){this.logger.warn(`trackWithReservation: failed to settle reservation ${i.id} locally (${u}) \u2014 emitting track anyway`),r=za(i,o,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:`${bw}${i.id}`})}async getCreditBalance(i,o){let s={remaining:0,reserved:0,settled:0},r=this.datastreamClient;if(!r||!i||Object.keys(i).length===0)return s;let a=await r.getCachedCompany(i);if(!a)try{a=await r.getCompany(i)}catch(U){return this.logger.debug(`getCreditBalance: company fetch failed (${U})`),s}if(!a?.id)return s;let u=a.creditBalances?.[o]??0,g=await Promise.resolve().then(()=>this.leaseStore?.get(a.id,o)).catch(U=>{this.logger.debug(`getCreditBalance: lease store read failed (${U})`)}),h=g!==void 0&&new Date(g.expiresAt).getTime()>Date.now(),c=h?g.localRemainingCredits:0,y=h?await this.reservations?.reservedCredits(a.id,o)??0:0,w=c+y;return{remaining:u,reserved:w,settled:u+w}}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,o){if(!this.offline){try{await this.enqueueEvent("identify",i,o)}catch(s){this.logger.error(`Error sending identify event: ${s}`)}if(o?.prewarm&&o.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,o.prewarm).catch(r=>{this.logger.warn(`identify prewarm failed: ${r}`)})}}}async track(i,o){if(!this.offline)try{if(await this.enqueueEvent("track",i,o),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,o){this.flagDefaults[i]=o}setFlagDefaults(i){Object.assign(this.flagDefaults,i)}getFlagDefault(i){return this.flagDefaults[i]??!1}async enqueueEvent(i,o,s){try{let r={eventType:i,body:o,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 fa=Qi(require("crypto")),hs="X-Schematic-Webhook-Signature",gs="X-Schematic-Webhook-Timestamp",mr=class p extends Error{constructor(t){super(t),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 _a(p,t,i){let o=Buffer.isBuffer(p)?p:Buffer.from(p),s=Buffer.concat([o,Buffer.from(`+${t}`)]),r=fa.createHmac("sha256",i);return r.update(s),r.digest()}function Rw(p,t,i){return _a(p,t,i).toString("hex")}function ys(p,t,i,o){if(!t)throw mr.missingSignature();if(!i)throw mr.missingTimestamp();let s;try{s=Buffer.from(t,"hex")}catch(a){throw new mr(`Invalid signature format: ${a?.message||"Unknown error"}`)}let r=_a(p,i,o);if(s.length!==r.length||!fa.timingSafeEqual(s,r))throw mr.invalidSignature()}function fw(p,t,i,o={}){let s=p.headers,r=o.signatureHeader||hs,a=o.timestampHeader||gs,u=zw(s,r),g=zw(s,a),h;if(i!==void 0)h=i;else if("rawBody"in p&&p.rawBody)h=p.rawBody;else throw new mr("Request body is not available. Provide the body as a parameter or ensure req.rawBody exists.");ys(h,u,g,t)}function zw(p,t){let i=p[t]||p[t.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 yw(p){return`${p.companyId}|${p.creditTypeId}|${p.id}`}function _R(p){let o=p.split("|");if(o.length===3)return{companyId:o[0],creditTypeId:o[1],id:o[2]}}var ww=256,SR=16,bo=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??wR}hashKey(o){return`${this.keyPrefix}${bR}${o}`}indexKey(){return`${this.keyPrefix}${zR}`}byCreditKey(o,i){return`${this.keyPrefix}${RR}${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:yw(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 xR(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(fR,{keys:[this.hashKey(o)],arguments:[]}),s=PR(t);if(!s||!s.id)return null;let r=s.companyId,n=s.creditTypeId,u=Number(s.creditsReserved)||0;await this.client.zRem(this.indexKey(),yw({companyId:r,creditTypeId:n,id:o})).catch(()=>{}),await this.client.hDel(this.byCreditKey(r,n),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,n,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<SR;s++){let r=await this.client.zRangeByScore(this.indexKey(),0,i,{LIMIT:{offset:0,count:ww}});if(r.length===0)break;for(let n of r){let u=_R(n);if(!u){await this.client.zRem(this.indexKey(),n).catch(()=>{});continue}let g=await this.consume(u.id,0);if(await this.client.zRem(this.indexKey(),n).catch(()=>{}),g!==null){t++;continue}await this.client.hDel(this.byCreditKey(u.companyId,u.creditTypeId),u.id).catch(()=>{})}if(r.length<ww)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 PR(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 xR(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 zw=require("crypto");function zo(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 Rw(p,o,i,t,s){let{datastream:r,leaseStore:n,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`),zo(p,i,ya(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(fe){h.warn(`Lease check: failed to load flag ${o}: ${fe}`)}if(!y)return h.debug(`Lease check: no cached flag for ${o}, falling back`),s();let{eventSubtype:w,quantity:U}=CR(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(fe){h.debug(`Lease check: company fetch failed for keys ${JSON.stringify(i.company)} (${fe}), falling back`)}if(!T)return s();let O=null;if(i.user){try{O=await r.getUser(i.user)}catch(fe){h.debug(`Lease check: user fetch failed for keys ${JSON.stringify(i.user)} (${fe}), falling back`)}if(!O)return s()}let A;try{A=await r.getRulesEngine().checkFlagWithOptions(y,T,O??null,null)}catch(fe){return h.warn(`Lease check: entitlement probe failed for flag ${o} (${fe}), falling back`),s()}let j=A.entitlement;if(!j||j.valueType!==fa.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 pe=U*V,Ce=t.timeoutMs!==void 0?{timeoutInSeconds:t.timeoutMs/1e3}:void 0,B=fe=>TR({datastream:r,logger:h,mode:l,key:o,reason:fe,flag:y,company:T,user:O,creditId:D,options:t}).then(Ro=>zo(p,i,Ro,{companyId:T.id,userId:O?.id})),Qr=await g.acquireIfNeeded(T.id,D,Ce);if(!Qr)return B("lease_acquire_failed");let hr;try{hr=await n.tryReserve(T.id,D,pe),hr===null&&(await g.maybeExtendInBackground(T.id,D,pe,Ce),hr=await n.tryReserve(T.id,D,pe))}catch(fe){return h.error(`Lease check: reserve against ${T.id}/${D} failed: ${fe}`),B("lease_store_error")}if(hr===null)return B("insufficient_lease_balance");let M=UR({leaseId:Qr.leaseId,companyId:T.id,creditTypeId:D,eventSubtype:re,quantityReserved:U,creditsReserved:pe,consumptionRate:V,reservationTTL:ER(p,D),evalCtx:i});try{await u.add(M)}catch(fe){h.error(`Lease check: failed to persist reservation ${M.id}: ${fe}`);try{await u.consume(M.id,0)===null&&await n.refund(T.id,D,pe,Qr.leaseId)}catch(Ro){h.warn(`Lease check: could not undo local debit for ${M.id} (${Ro}); the slice is reclaimed at lease expiry`)}return B("lease_store_error")}let gr=hr+pe,Uw=fw(T,D,gr),vw={creditCost:{[D]:pe}},je;try{je=await r.getRulesEngine().checkFlagWithOptions(y,Uw,O??null,vw)}catch(fe){return h.error(`Lease check: WASM eval failed: ${fe}`),await bw(u,M,h),zo(p,i,ya(l,o,`wasm_error: ${fe}`,y),{companyId:T.id,userId:O?.id})}let ws={companyId:je.companyId??T.id,userId:je.userId??O?.id,ruleId:je.ruleId};return je.value?(g.maybeExtendInBackground(T.id,D),zo(p,i,{allowed:!0,value:!0,reservation:M,reason:je.reason??"lease_reserved",entitlement:ds(je.entitlement),flagKey:je.flagKey??o,flagId:je.flagId},ws)):(await bw(u,M,h),zo(p,i,{allowed:!1,value:!1,reason:je.reason??"denied_by_engine",entitlement:ds(je.entitlement),flagKey:je.flagKey??o,flagId:je.flagId},ws))}function ER(p,o){return p.manager.resolveConfig(o)}function CR(p){return{eventSubtype:p.eventSubtype,quantity:p.usage??0}}function ms(p){if(p.usage!==void 0)return p.eventSubtype!==void 0?{eventUsage:{eventSubtype:p.eventSubtype,quantity:p.usage}}:{usage:p.usage}}function fw(p,o,i){return{...p,creditBalances:{...p.creditBalances??{},[o]:i}}}function UR(p){return{id:(0,zw.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 ds(p){if(p)return{...p,metricResetAt:p.metricResetAt?new Date(p.metricResetAt):void 0}}async function bw(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 vR=Number.MAX_SAFE_INTEGER;async function TR(p){let{datastream:o,logger:i,mode:t,key:s,reason:r,flag:n,company:u,user:g,creditId:h,options:l}=p;if(t==="fail-closed")return ya(t,s,r,n);try{let y=fw(u,h,vR),w=await o.getRulesEngine().checkFlagWithOptions(n,y,g,ms(l));return{allowed:w.value,value:w.value,reason:`${w.reason??"evaluated"} (${r}_fail_open)`,entitlement:ds(w.entitlement),flagKey:w.flagKey??s,flagId:w.flagId??n.id,err:r}}catch(y){return i.warn(`Lease check: fail-open evaluation failed (${y}); allowing`),ya(t,s,r,n)}}function ya(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 _w(p,o,i,t){let s=i*o.consumptionRate,r=await p.consume(o.id,s);return{track:wa(o,i,t),settledLocally:r!==null}}function wa(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 Pw="lease-reservation:",ba=class extends da{constructor(i){let{apiKey:t="",basePath:s,eventBufferInterval:r,eventCaptureBaseURL:n,flagDefaults:u={},logLevel:g,timeoutMs:h}=i??{},{offline:l=!1}=i??{},y=i?.logger??new Xr(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?rw:ew(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 ha({apiKey:t,fetcher:U,headers:T,baseUrl:n,timeoutMs:h});if(this.eventBuffer=new ma(A,{interval:r,logger:y,offline:l}),this.flagCheckCacheProviders=i?.cacheProviders?.flagChecks??[new er],this.flagDefaults=u,this.offline=l,i?.useDataStream&&!l){let D=["workerd","edge-runtime","browser","web-worker"].includes(Re.type),V=i.dataStream?.replicatorMode===!0;if(D&&!V)y.warn(`DataStream is not supported in ${Re.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 mo(re),this.datastreamClient.start().catch(pe=>{y.error(`Failed to start DataStream client: ${pe}`),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 wo({client:D,keyPrefix:V,defaultLeaseDurationMs:i.creditLeases.defaultLeaseDuration}),this.reservations=new bo({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 ho,this.reservations=new go(this.leaseStore,j)),this.reservations.startSweep(),this.creditLeaseManager=new yo({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 n=await this.datastreamClient.checkFlag(i,t,s);return this.enqueueEvent(_o.FlagCheck,{flagKey:t,value:n?.value??!1,reason:n?.reason??"unknown",ruleId:n?.ruleId,companyId:n?.companyId,userId:n?.userId,flagId:n?.flagId,reqCompany:i.company,reqUser:i.user}),{companyId:n.companyId,entitlement:n.entitlement,err:n.err,flagKey:n.flagKey??t,flagId:n.flagId,reason:n.reason,ruleId:n.ruleId,ruleType:n.ruleType,userId:n.userId,value:n.value??this.getFlagDefault(t)}}catch(n){return this.logger.debug(`Datastream flag check failed (${n}), falling back to API`),this.checkFlagViaAPI(i,t,s,r)}return this.checkFlagViaAPI(i,t,s,r)}async checkFlagViaAPI(i,t,s,r){let n=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:n()};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:n()}}}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=[],n=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 n)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 n=await this.datastreamClient.checkFlag(i,r);s.push({flag:n.flagKey??r,value:n.value??this.getFlagDefault(r),reason:n.reason,flagId:n.flagId,ruleId:n.ruleId,ruleType:n.ruleType,companyId:n.companyId,userId:n.userId,entitlement:n.entitlement,error:n.err})}catch(n){return this.logger.debug(`Datastream checkFlags falling back to API (${n})`),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(n=>this.logger.warn(`prewarm: failed to acquire lease for ${r}: ${n}`))))}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 n=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()>=n)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?ms(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():Rw({leaseStore:this.leaseStore,reservations:this.reservations,manager:this.creditLeaseManager,datastream:this.datastreamClient,logger:this.logger,enqueueFlagCheckEvent:u=>this.enqueueEvent(_o.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(wa(i,t,s),{idempotencyKey:`${Pw}${i.id}`});return}let r,n;try{({track:r,settledLocally:n}=await _w(this.reservations,i,t,s))}catch(u){this.logger.warn(`trackWithReservation: failed to settle reservation ${i.id} locally (${u}) \u2014 emitting track anyway`),r=wa(i,t,s),n=!1}n||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:`${Pw}${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 za=Zi(require("crypto")),hs="X-Schematic-Webhook-Signature",gs="X-Schematic-Webhook-Timestamp",mr=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 Ra(p,o,i){let t=Buffer.isBuffer(p)?p:Buffer.from(p),s=Buffer.concat([t,Buffer.from(`+${o}`)]),r=za.createHmac("sha256",i);return r.update(s),r.digest()}function Ew(p,o,i){return Ra(p,o,i).toString("hex")}function ys(p,o,i,t){if(!o)throw mr.missingSignature();if(!i)throw mr.missingTimestamp();let s;try{s=Buffer.from(o,"hex")}catch(n){throw new mr(`Invalid signature format: ${n?.message||"Unknown error"}`)}let r=Ra(p,i,t);if(s.length!==r.length||!za.timingSafeEqual(s,r))throw mr.invalidSignature()}function Cw(p,o,i,t={}){let s=p.headers,r=t.signatureHeader||hs,n=t.timestampHeader||gs,u=xw(s,r),g=xw(s,n),h;if(i!==void 0)h=i;else if("rawBody"in p&&p.rawBody)h=p.rawBody;else throw new mr("Request body is not available. Provide the body as a parameter or ensure req.rawBody exists.");ys(h,u,g,o)}function xw(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});