@schematichq/schematic-typescript-node 1.4.7 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +111 -6
  2. package/dist/api/resources/accounts/client/Client.d.ts +20 -0
  3. package/dist/api/resources/accounts/client/requests/CountAccountMembersRequest.d.ts +18 -0
  4. package/dist/api/resources/accounts/client/requests/index.d.ts +1 -0
  5. package/dist/api/resources/accounts/types/CountAccountMembersParams.d.ts +12 -0
  6. package/dist/api/resources/accounts/types/CountAccountMembersResponse.d.ts +6 -0
  7. package/dist/api/resources/accounts/types/index.d.ts +2 -0
  8. package/dist/api/resources/billing/client/Client.d.ts +6 -6
  9. package/dist/api/resources/billing/client/requests/CountBillingProductsRequest.d.ts +1 -1
  10. package/dist/api/resources/billing/client/requests/CountCustomersRequest.d.ts +1 -1
  11. package/dist/api/resources/billing/client/requests/ListBillingPricesRequest.d.ts +1 -1
  12. package/dist/api/resources/billing/client/requests/ListBillingProductPricesRequest.d.ts +1 -1
  13. package/dist/api/resources/billing/client/requests/ListBillingProductsRequest.d.ts +1 -1
  14. package/dist/api/resources/billing/client/requests/ListCustomersWithSubscriptionsRequest.d.ts +1 -1
  15. package/dist/api/resources/checkout/client/Client.d.ts +16 -0
  16. package/dist/api/resources/entitlements/client/Client.d.ts +3 -3
  17. package/dist/api/resources/entitlements/client/requests/CountFeatureUsageRequest.d.ts +1 -1
  18. package/dist/api/resources/entitlements/client/requests/CreateBillingLinkedPlanEntitlementRequestBody.d.ts +1 -1
  19. package/dist/api/resources/entitlements/client/requests/ListFeatureUsageRequest.d.ts +1 -1
  20. package/dist/api/resources/features/client/Client.d.ts +3 -3
  21. package/dist/api/resources/features/client/requests/CountFeaturesRequest.d.ts +1 -1
  22. package/dist/api/resources/features/client/requests/CreateBillingLinkedFeatureRequestBody.d.ts +1 -1
  23. package/dist/api/resources/features/client/requests/ListFeaturesRequest.d.ts +1 -1
  24. package/dist/api/resources/integrationsapi/client/Client.d.ts +54 -3
  25. package/dist/api/resources/integrationsapi/types/AssumeStripeInstalledResponse.d.ts +6 -0
  26. package/dist/api/resources/integrationsapi/types/InstallIntegrationResponse.d.ts +6 -0
  27. package/dist/api/resources/integrationsapi/types/InstallStripeResponse.d.ts +6 -0
  28. package/dist/api/resources/integrationsapi/types/{LoadSampleDataSetV2Response.d.ts → LoadSampleDataSetResponse.d.ts} +1 -1
  29. package/dist/api/resources/integrationsapi/types/index.d.ts +4 -1
  30. package/dist/api/resources/plangroups/client/requests/CreatePlanGroupRequestBody.d.ts +1 -0
  31. package/dist/api/resources/plangroups/client/requests/UpdatePlanGroupRequestBody.d.ts +1 -0
  32. package/dist/api/resources/plans/client/Client.d.ts +1 -1
  33. package/dist/api/resources/plans/client/requests/CreateBillingLinkedPlanRequestBody.d.ts +1 -1
  34. package/dist/api/types/AccountMemberResponseData.d.ts +2 -0
  35. package/dist/api/types/BillingCreditGrantReason.d.ts +1 -0
  36. package/dist/api/types/BillingCreditGrantResponseData.d.ts +4 -0
  37. package/dist/api/types/BillingCreditLedgerAuthority.d.ts +6 -0
  38. package/dist/api/types/BillingCreditView.d.ts +1 -0
  39. package/dist/api/types/BillingPlanCreditGrantResponseData.d.ts +2 -0
  40. package/dist/api/types/BillingProviderType.d.ts +1 -0
  41. package/dist/api/types/ChangeSubscriptionInternalRequestBody.d.ts +1 -0
  42. package/dist/api/types/ChangeSubscriptionRequestBody.d.ts +1 -0
  43. package/dist/api/types/CheckoutDataResponseData.d.ts +1 -0
  44. package/dist/api/types/CheckoutFieldInput.d.ts +8 -0
  45. package/dist/api/types/CheckoutFieldResponseData.d.ts +12 -0
  46. package/dist/api/types/CheckoutFieldValue.d.ts +4 -0
  47. package/dist/api/types/CheckoutFieldWithValue.d.ts +9 -0
  48. package/dist/api/types/CompanyCreditBalanceResponseData.d.ts +2 -0
  49. package/dist/api/types/CompanyPlanCreditGrantView.d.ts +1 -0
  50. package/dist/api/types/ComponentHydrateResponseData.d.ts +1 -0
  51. package/dist/api/types/ComponentPreviewResponseData.d.ts +1 -0
  52. package/dist/api/types/CreateBillingPlanCreditGrantRequestBody.d.ts +2 -0
  53. package/dist/api/types/CreditCompanyGrantView.d.ts +3 -0
  54. package/dist/api/types/CreditEventLedgerResponseData.d.ts +1 -0
  55. package/dist/api/types/CreditUsageReason.d.ts +8 -0
  56. package/dist/api/types/EventDetailResponseData.d.ts +1 -0
  57. package/dist/api/types/EventResponseData.d.ts +1 -0
  58. package/dist/api/types/InstallIntegrationRequestBody.d.ts +9 -0
  59. package/dist/api/types/IntegrationConfig.d.ts +4 -1
  60. package/dist/api/types/IntegrationInstallConfig.d.ts +13 -0
  61. package/dist/api/types/IntegrationInstallResponseData.d.ts +6 -0
  62. package/dist/api/types/IntegrationType.d.ts +1 -0
  63. package/dist/api/types/ManagePlanRequest.d.ts +1 -0
  64. package/dist/api/types/MetronomeIntegrationConfig.d.ts +1 -0
  65. package/dist/api/types/MigrationErrorCode.d.ts +1 -0
  66. package/dist/api/types/PlanCreditGrantView.d.ts +1 -0
  67. package/dist/api/types/PlanGroupDetailResponseData.d.ts +1 -0
  68. package/dist/api/types/UpdateBillingPlanCreditGrantRequestBody.d.ts +2 -0
  69. package/dist/api/types/index.d.ts +10 -0
  70. package/dist/cache/redis.d.ts +29 -2
  71. package/dist/credits/check.d.ts +49 -0
  72. package/dist/credits/index.d.ts +7 -0
  73. package/dist/credits/lease-manager.d.ts +68 -0
  74. package/dist/credits/lease-store.d.ts +133 -0
  75. package/dist/credits/redis-lease-store.d.ts +30 -0
  76. package/dist/credits/redis-reservation-store.d.ts +46 -0
  77. package/dist/credits/reservation-store.d.ts +64 -0
  78. package/dist/credits/track.d.ts +44 -0
  79. package/dist/credits/types.d.ts +175 -0
  80. package/dist/datastream/datastream-client.d.ts +19 -3
  81. package/dist/datastream/merge.d.ts +5 -11
  82. package/dist/index.d.ts +1 -0
  83. package/dist/index.js +85 -3
  84. package/dist/rules-engine.d.ts +3 -1
  85. package/dist/serialization/resources/accounts/types/CountAccountMembersParams.d.ts +12 -0
  86. package/dist/serialization/resources/accounts/types/CountAccountMembersResponse.d.ts +12 -0
  87. package/dist/serialization/resources/accounts/types/index.d.ts +2 -0
  88. package/dist/serialization/resources/integrationsapi/types/AssumeStripeInstalledResponse.d.ts +11 -0
  89. package/dist/serialization/resources/integrationsapi/types/InstallIntegrationResponse.d.ts +11 -0
  90. package/dist/serialization/resources/integrationsapi/types/InstallStripeResponse.d.ts +11 -0
  91. package/dist/serialization/resources/integrationsapi/types/{LoadSampleDataSetV2Response.d.ts → LoadSampleDataSetResponse.d.ts} +2 -2
  92. package/dist/serialization/resources/integrationsapi/types/index.d.ts +4 -1
  93. package/dist/serialization/resources/plangroups/client/requests/CreatePlanGroupRequestBody.d.ts +2 -0
  94. package/dist/serialization/resources/plangroups/client/requests/UpdatePlanGroupRequestBody.d.ts +2 -0
  95. package/dist/serialization/types/AccountMemberResponseData.d.ts +2 -0
  96. package/dist/serialization/types/BillingCreditGrantReason.d.ts +1 -1
  97. package/dist/serialization/types/BillingCreditGrantResponseData.d.ts +3 -0
  98. package/dist/serialization/types/BillingCreditLedgerAuthority.d.ts +7 -0
  99. package/dist/serialization/types/BillingCreditView.d.ts +2 -0
  100. package/dist/serialization/types/BillingPlanCreditGrantResponseData.d.ts +1 -0
  101. package/dist/serialization/types/BillingProviderType.d.ts +1 -1
  102. package/dist/serialization/types/ChangeSubscriptionInternalRequestBody.d.ts +2 -0
  103. package/dist/serialization/types/ChangeSubscriptionRequestBody.d.ts +2 -0
  104. package/dist/serialization/types/CheckoutDataResponseData.d.ts +2 -0
  105. package/dist/serialization/types/CheckoutFieldInput.d.ts +14 -0
  106. package/dist/serialization/types/CheckoutFieldResponseData.d.ts +18 -0
  107. package/dist/serialization/types/CheckoutFieldValue.d.ts +10 -0
  108. package/dist/serialization/types/CheckoutFieldWithValue.d.ts +15 -0
  109. package/dist/serialization/types/CompanyCreditBalanceResponseData.d.ts +2 -0
  110. package/dist/serialization/types/CompanyPlanCreditGrantView.d.ts +1 -0
  111. package/dist/serialization/types/ComponentHydrateResponseData.d.ts +2 -0
  112. package/dist/serialization/types/ComponentPreviewResponseData.d.ts +2 -0
  113. package/dist/serialization/types/CreateBillingPlanCreditGrantRequestBody.d.ts +1 -0
  114. package/dist/serialization/types/CreditCompanyGrantView.d.ts +3 -0
  115. package/dist/serialization/types/CreditEventLedgerResponseData.d.ts +2 -0
  116. package/dist/serialization/types/CreditUsageReason.d.ts +7 -0
  117. package/dist/serialization/types/EventDetailResponseData.d.ts +1 -0
  118. package/dist/serialization/types/EventResponseData.d.ts +1 -0
  119. package/dist/serialization/types/InstallIntegrationRequestBody.d.ts +16 -0
  120. package/dist/serialization/types/IntegrationConfig.d.ts +5 -1
  121. package/dist/serialization/types/IntegrationInstallConfig.d.ts +20 -0
  122. package/dist/serialization/types/IntegrationInstallResponseData.d.ts +14 -0
  123. package/dist/serialization/types/IntegrationType.d.ts +1 -1
  124. package/dist/serialization/types/ManagePlanRequest.d.ts +2 -0
  125. package/dist/serialization/types/MetronomeIntegrationConfig.d.ts +7 -0
  126. package/dist/serialization/types/MigrationErrorCode.d.ts +1 -1
  127. package/dist/serialization/types/PlanCreditGrantView.d.ts +1 -0
  128. package/dist/serialization/types/PlanGroupDetailResponseData.d.ts +2 -0
  129. package/dist/serialization/types/UpdateBillingPlanCreditGrantRequestBody.d.ts +1 -0
  130. package/dist/serialization/types/index.d.ts +10 -0
  131. package/dist/wasm/rulesengine.js +5 -5
  132. package/dist/wrapper.d.ts +158 -6
  133. package/package.json +5 -4
  134. package/dist/wasm/rulesengine_bg.wasm +0 -0
package/dist/index.js CHANGED
@@ -1,3 +1,85 @@
1
- "use strict";var Ry=Object.create;var to=Object.defineProperty;var fy=Object.getOwnPropertyDescriptor;var _y=Object.getOwnPropertyNames;var Sy=Object.getPrototypeOf,Py=Object.prototype.hasOwnProperty;var ii=(p,o)=>()=>(p&&(o=p(p=0)),o);var xy=(p,o)=>()=>(o||p((o={exports:{}}).exports,o),o.exports),pr=(p,o)=>{for(var i in o)to(p,i,{get:o[i],enumerable:!0})},Ln=(p,o,i,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of _y(o))!Py.call(p,s)&&s!==i&&to(p,s,{get:()=>o[s],enumerable:!(t=fy(o,s))||t.enumerable});return p};var ao=(p,o,i)=>(i=p!=null?Ry(Sy(p)):{},Ln(o||!p||!p.__esModule?to(i,"default",{value:p,enumerable:!0}):i,p)),Gn=p=>Ln(to({},"__esModule",{value:!0}),p);var ms={};pr(ms,{Node18UniversalStreamWrapper:()=>ra});var ra,hs=ii(()=>{"use strict";ra=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={};pr(gs,{UndiciStreamWrapper:()=>ia});var ia,ys=ii(()=>{"use strict";ia=class p{constructor(o){this.readableStream=o,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=!1,this.resumeCallback=null,this.encoding=null}on(o,i){this.events[o]?.push(i)}off(o,i){this.events[o]=this.events[o]?.filter(t=>t!==i)}pipe(o){return this.on("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.on("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.on("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)}),this._startReading(),o}pipeTo(o){return this.pipe(o)}unpipe(o){this.off("data",i=>{if(o instanceof p)o._write(i);else{let t=o.getWriter();t.write(i).then(()=>t.releaseLock())}}),this.off("end",()=>{o instanceof p?o._end():o.getWriter().close()}),this.off("error",i=>{o instanceof p?o._error(i):o.getWriter().abort(i)})}destroy(o){this.reader.cancel(o).then(()=>{this._emit("close")}).catch(i=>{this._emit("error",i)})}pause(){this.paused=!0,this._emit("pause")}resume(){this.paused&&(this.paused=!1,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null))}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(!o)return i}setEncoding(o){this.encoding=o}async text(){let o=[];for(;;){let{done:t,value:s}=await this.reader.read();if(t)break;s&&o.push(s)}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(o).arrayBuffer())}async json(){let o=await this.text();return JSON.parse(o)}_write(o){this._emit("data",o)}_end(){this._emit("end")}_error(o){this._emit("error",o)}_emit(o,i){if(this.events[o])for(let t of this.events[o]||[])t(i)}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();if(o){this._emit("end"),this._emit("close");break}i&&this._emit("data",i)}}catch(o){this._emit("error",o)}}[Symbol.asyncIterator](){return{next:async()=>{this.paused&&await new Promise(t=>{this.resumeCallback=t});let{done:o,value:i}=await this.reader.read();return o?{done:!0,value:void 0}:{done:!1,value:i}},[Symbol.asyncIterator](){return this}}}}});var ws={};pr(ws,{NodePre18StreamWrapper:()=>oa});var oa,bs=ii(()=>{"use strict";oa=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 Ki,An=ii(()=>{"use strict";Ki=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 cy=xy((T9,Fb)=>{Fb.exports={name:"@schematichq/schematic-typescript-node",version:"1.4.7",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","@types/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"},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 ly,py,uy,dy=ii(()=>{"use strict";ly=cy(),py=ly.name,uy=ly.version});var gy={};pr(gy,{DatastreamWSClient:()=>Dn});function Nb(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 my,Kb,hy,Lb,Gb,Wb,Hb,Dn,yy=ii(()=>{"use strict";my=ao(require("ws"));dy();An();Kb=10*1e3,hy=60*1e3,Lb=hy*9/10,Gb=10,Wb=1*1e3,Hb=30*1e3;Dn=class extends Ki{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=Nb(i.url):this.url=i.url,this.headers={"X-Schematic-Api-Key":i.apiKey,"X-Schematic-Client":py,"X-Schematic-Client-Version":uy,"X-Schematic-Datastream-Mode":"datastream"},this.logger=i.logger,this.messageHandler=i.messageHandler,this.connectionReadyHandler=i.connectionReadyHandler,this.maxReconnectAttempts=i.maxReconnectAttempts??Gb,this.minReconnectDelay=i.minReconnectDelay??Wb,this.maxReconnectDelay=i.maxReconnectDelay??Hb}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"))},Kb);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 my.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()},Lb),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()},hy),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 Yb={};pr(Yb,{ConsoleLogger:()=>Nr,LocalCache:()=>Ze,LogLevel:()=>Je,RedisCacheProvider:()=>Zr,RulesEngineClient:()=>Fi,Schematic:()=>te,SchematicClient:()=>Ht,SchematicEnvironment:()=>x,SchematicError:()=>b,SchematicTimeoutError:()=>Jr,WEBHOOK_SIGNATURE_HEADER:()=>In,WEBHOOK_TIMESTAMP_HEADER:()=>Fn,WebhookSignatureError:()=>lr,computeHexSignature:()=>by,computeSignature:()=>$t,verifySignature:()=>Kn,verifyWebhookSignature:()=>zy});module.exports=Gn(Yb);var te={};pr(te,{AccountMemberPermission:()=>Cy,AccountMemberRole:()=>Uy,ActorType:()=>vy,ApiKeyScope:()=>Ty,BadRequestError:()=>T,BillingCreditBundleStatus:()=>Oy,BillingCreditBurnStrategy:()=>ky,BillingCreditExpiryType:()=>By,BillingCreditExpiryUnit:()=>jy,BillingCreditGrantReason:()=>Ay,BillingCreditGrantZeroedOutReason:()=>Vy,BillingCreditRolloverPolicy:()=>qy,BillingPlanCreditGrantResetCadence:()=>Dy,BillingPlanCreditGrantResetStart:()=>My,BillingPlanCreditGrantResetType:()=>Iy,BillingPriceScheme:()=>Fy,BillingPriceUsageType:()=>Ky,BillingProductPriceInterval:()=>Ly,BillingProviderType:()=>Gy,BillingStrategy:()=>Wy,BillingSubscriptionTrialEndSetting:()=>Hy,BillingTiersMode:()=>Ny,ChargeType:()=>$y,CompanyMatchingCriteria:()=>Jy,CompanyPlanInvalidReason:()=>Zy,ComparableOperator:()=>Yy,ComponentEntityType:()=>Qy,ComponentState:()=>Xy,ConditionType:()=>ew,CreditEventType:()=>rw,CreditGrantSortOrder:()=>iw,CreditLedgerPeriod:()=>ow,CustomPlanActivationStrategy:()=>tw,CustomPlanBillingStatus:()=>aw,DataExportStatus:()=>nw,EntitlementPriceBehavior:()=>sw,EntitlementType:()=>cw,EntitlementValueType:()=>lw,EntityType:()=>pw,EnvironmentType:()=>uw,EventStatus:()=>dw,EventType:()=>Yt,FeatureLifecyclePhase:()=>mw,FeatureType:()=>hw,ForbiddenError:()=>z,IntegrationState:()=>gw,IntegrationType:()=>yw,InternalServerError:()=>R,InvoiceStatus:()=>ww,MetricPeriod:()=>bw,MetricPeriodMonthReset:()=>zw,MigrationErrorCode:()=>Rw,NotFoundError:()=>f,PlanBundleAction:()=>fw,PlanChangeAction:()=>_w,PlanChangeBasePlanAction:()=>Sw,PlanChangeSubscriptionAction:()=>Pw,PlanIcon:()=>xw,PlanPriceCadence:()=>Ew,PlanType:()=>Cw,PlanVersionCompanyMigrationStatus:()=>Uw,PlanVersionMigrationStatus:()=>vw,PlanVersionMigrationStrategy:()=>Tw,PlanVersionStatus:()=>Ow,ProrationBehavior:()=>kw,RuleType:()=>Fw,RulesEngineSchemaVersion:()=>Bw,RulesengineConditionType:()=>jw,RulesengineEntitlementValueType:()=>Aw,RulesengineEntityType:()=>Vw,RulesengineMetricPeriod:()=>qw,RulesengineMetricPeriodMonthReset:()=>Dw,RulesengineRuleType:()=>Mw,RulesengineTraitDefinitionComparableType:()=>Iw,ScheduledCheckoutStatus:()=>Kw,ScheduledDowngradeConfigBehavior:()=>Lw,SortDirection:()=>Gw,SubscriptionStatus:()=>Ww,SubscriptionType:()=>Hw,TimeSeriesGranularity:()=>Nw,TraitDefinitionComparableType:()=>$w,TraitType:()=>Jw,TrialStatus:()=>Zw,UnauthorizedError:()=>_,WebhookEventStatus:()=>Yw,WebhookRequestType:()=>Qw,WebhookStatus:()=>Xw,accesstokens:()=>Wn,accounts:()=>Hn,billing:()=>Nn,checkout:()=>$n,companies:()=>Jn,components:()=>Zn,componentspublic:()=>Yn,credits:()=>Qn,dataexports:()=>Xn,entitlements:()=>es,events:()=>rs,features:()=>is,insights:()=>os,integrationsapi:()=>ts,planbundle:()=>as,plangroups:()=>ns,planmigrations:()=>ss,plans:()=>cs,scheduledcheckout:()=>ls,webhooks:()=>ps});var xe=(p,o,i)=>JSON.stringify(p,o,i);function Gi(p,o){return JSON.parse(p,o)}var b=class extends Error{constructor({message:o,statusCode:i,body:t,rawResponse:s,cause:r}){super(Ey({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 Ey({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: ${xe(i,void 0,2)}`),t.join(`
2
- `)}var Jr=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 T=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 z=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 R=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 f=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 _=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 Wn={};var Hn={};var Nn={};var $n={};var Jn={};var Zn={};var Yn={};var Qn={};var Xn={};var es={};var rs={};var is={};var os={};var ts={};var as={};var ns={};var ss={};var cs={};var ls={};var ps={};var Cy={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 Uy={Admin:"admin",Member:"member"};var vy={ApiKey:"api_key",AppUser:"app_user",StripeApp:"stripe_app",System:"system",TemporaryAccessToken:"temporary_access_token"};var Ty={Admin:"admin",Capture:"capture",Read:"read",Write:"write"};var Oy={Active:"active",Inactive:"inactive"};var ky={ExpirationPriority:"expiration_priority",FirstInFirstOut:"first_in_first_out",LastInFirstOut:"last_in_first_out",PlanFirstThenCreditBundlesFirstInFirstOut:"plan_first_then_credit_bundles_first_in_first_out"};var By={Duration:"duration",EndOfBillingPeriod:"end_of_billing_period",EndOfNextBillingPeriod:"end_of_next_billing_period",EndOfTrial:"end_of_trial",NoExpiry:"no_expiry"};var jy={BillingPeriods:"billing_periods",Days:"days"};var Ay={Adjustment:"adjustment",BillingCreditAutoTopup:"billing_credit_auto_topup",Free:"free",Plan:"plan",Purchased:"purchased"};var Vy={Expired:"expired",Manual:"manual",PlanChange:"plan_change",PlanPeriodReset:"plan_period_reset"};var qy={Expire:"expire",None:"none",Rollover:"rollover"};var Dy={Daily:"daily",Monthly:"monthly",Weekly:"weekly",Yearly:"yearly"};var My={BillingPeriod:"billing_period",FirstOfMonth:"first_of_month"};var Iy={NoReset:"no_reset",PlanPeriod:"plan_period"};var Fy={PerUnit:"per_unit",Tiered:"tiered"};var Ky={Licensed:"licensed",Metered:"metered"};var Ly={Day:"day",Month:"month",OneTime:"one-time",Year:"year"};var Gy={Orb:"orb",Schematic:"schematic",Stripe:"stripe"};var Wy={SchematicManaged:"schematic_managed",ProviderManaged:"provider_managed",NoBilling:"no_billing"};var Hy={Cancel:"cancel",Subscribe:"subscribe"};var Ny={Graduated:"graduated",Volume:"volume"};var $y={Free:"free",None:"none",OneTime:"one_time",Recurring:"recurring"};var Jy={BillingMetaObject:"billing_meta_object",ManualUpsert:"manual_upsert"};var Zy={DowngradeNotPermitted:"downgrade_not_permitted",FeatureUsageExceeded:"feature_usage_exceeded"};var Yy={Eq:"eq",Gt:"gt",Gte:"gte",IsEmpty:"is_empty",Lt:"lt",Lte:"lte",NotEmpty:"not_empty",Ne:"ne"};var Qy={Billing:"billing",Entitlement:"entitlement"};var Xy={Draft:"draft",Live:"live"};var ew={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var rw={Grant:"grant",Transfer:"transfer",Usage:"usage",ZeroOut:"zero_out"};var iw={CreatedAt:"created_at",ExpiresAt:"expires_at",Quantity:"quantity",QuantityRemaining:"quantity_remaining"};var ow={Daily:"daily",Monthly:"monthly",Raw:"raw",Weekly:"weekly"};var tw={OnPayment:"on_payment",OnPublish:"on_publish"};var aw={Active:"active",Expired:"expired",Paid:"paid",Pending:"pending"};var nw={Failure:"failure",Pending:"pending",Success:"success"};var sw={CreditBurndown:"credit_burndown",Overage:"overage",PayAsYouGo:"pay_as_you_go",PayInAdvance:"pay_in_advance",Tier:"tier"};var cw={CompanyOverride:"company_override",PlanEntitlement:"plan_entitlement",Unknown:"unknown"};var lw={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var pw={Company:"company",User:"user"};var uw={Development:"development",Production:"production",Staging:"staging"};var dw={Enriched:"enriched",Failed:"failed",Pending:"pending",Processed:"processed",Unknown:"unknown"};var Yt={FlagCheck:"flag_check",Identify:"identify",Track:"track"};var mw={AddOn:"add_on",Alpha:"alpha",Beta:"beta",Deprecated:"deprecated",Ga:"ga",Inactive:"inactive",InPlan:"in_plan",InternalTesting:"internal_testing",Legacy:"legacy"};var hw={Boolean:"boolean",Event:"event",Trait:"trait"};var gw={Active:"active",Created:"created",Pending:"pending"};var yw={Clerk:"clerk",Orb:"orb",Stripe:"stripe",Unknown:"unknown",Workos:"workos"};var ww={Draft:"draft",Open:"open",Paid:"paid",Uncollectible:"uncollectible",Void:"void"};var bw={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var zw={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Rw={AmbiguousSubscriptionItem:"ambiguous_subscription_item",MultipleSubscriptions:"multiple_subscriptions",NoPriceForInterval:"no_price_for_interval",NotOnOriginVersion:"not_on_origin_version",PermanentConfig:"permanent_config",PermanentDecline:"permanent_decline",TransientDecline:"transient_decline",TransientInfra:"transient_infra",TransientStripe:"transient_stripe",Unknown:"unknown",WouldLeaveEmptySubscription:"would_leave_empty_subscription"};var fw={Create:"create",Update:"update",Delete:"delete"};var _w={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 Sw={Fallback:"fallback",Initial:"initial",Trait:"trait",TrialExpiry:"trial_expiry"};var Pw={Adjustment:"adjustment",Downgrade:"downgrade",Invalid:"invalid",Subscribe:"subscribe",Unsubscribe:"unsubscribe",Upgrade:"upgrade",UpgradeTrial:"upgrade_trial"};var xw={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 Ew={Monthly:"monthly",Quarterly:"quarterly",Yearly:"yearly"};var Cw={Plan:"plan",AddOn:"add_on"};var Uw={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending",Skipped:"skipped"};var vw={Completed:"completed",Failed:"failed",InProgress:"in_progress",Pending:"pending"};var Tw={Immediate:"immediate",Leave:"leave"};var Ow={Published:"published",Draft:"draft",Archived:"archived"};var kw={CreateProrations:"create_prorations",InvoiceImmediately:"invoice_immediately"};var Bw={V97288F60:"v97288f60",PlaceholderForFernCompatibility:"placeholder-for-fern-compatibility"};var jw={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var Aw={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var Vw={Company:"company",User:"user"};var qw={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var Dw={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Mw={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Iw={Bool:"bool",Date:"date",Int:"int",String:"string"};var Fw={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Kw={Cancelled:"cancelled",Error:"error",Executing:"executing",Pending:"pending",Success:"success"};var Lw={EndOfBillingPeriod:"end_of_billing_period",None:"none"};var Gw={Asc:"asc",Desc:"desc"};var Ww={Active:"active",Canceled:"canceled",Expired:"expired",Incomplete:"incomplete",IncompleteExpired:"incomplete_expired",PastDue:"past_due",Paused:"paused",Trialing:"trialing",Unpaid:"unpaid"};var Hw={Free:"free",OneTime:"one_time",Paid:"paid",Trial:"trial"};var Nw={Daily:"daily",Hourly:"hourly",Monthly:"monthly",Weekly:"weekly"};var $w={Bool:"bool",Date:"date",Int:"int",String:"string"};var Jw={Boolean:"boolean",Currency:"currency",Date:"date",Number:"number",String:"string",Url:"url"};var Zw={Active:"active",Converted:"converted",Expired:"expired"};var Yw={Failure:"failure",Pending:"pending",Success:"success"};var Qw={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 Xw={Active:"active",Inactive:"inactive"};var eb=2147483647,Ze=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,eb)),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 Zr=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(d=>this.getFullKey(d))),r=[],n=1e3;for await(let d of this.client.scanIterator({MATCH:t,COUNT:1e3}))s.has(d)||(r.push(d),r.length>=n&&(await this.client.del(r),r.length=0));r.length>0&&await this.client.del(r)}};function Qt(p){return typeof p=="object"&&p!==null&&"getAuthRequest"in p&&typeof p.getAuthRequest=="function"}var oi=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var no={get:async(p,o)=>typeof p=="function"?p(o):p};var Ge={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},us={[Ge.Debug]:1,[Ge.Info]:2,[Ge.Warn]:3,[Ge.Error]:4},Wi=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)}},ti=class{constructor(o){this.level=us[o.level],this.logger=o.logger,this.silent=o.silent}shouldLog(o){return!this.silent&&this.level<=us[o]}isDebug(){return this.shouldLog(Ge.Debug)}debug(o,...i){this.isDebug()&&this.logger.debug(o,...i)}isInfo(){return this.shouldLog(Ge.Info)}info(o,...i){this.isInfo()&&this.logger.info(o,...i)}isWarn(){return this.shouldLog(Ge.Warn)}warn(o,...i){this.isWarn()&&this.logger.warn(o,...i)}isError(){return this.shouldLog(Ge.Error)}error(o,...i){this.isError()&&this.logger.error(o,...i)}};function Hi(p){return p==null?rb:p instanceof ti?p:(p=p??{},p.level??=Ge.Info,p.logger??=new Wi,p.silent??=!0,new ti(p))}var rb=new ti({level:Ge.Info,logger:new Wi,silent:!0});var ib={arrayFormat:"indices",encode:!0};function Xt(p,o){if(p===void 0||p===null)return"";let i=String(p);return o?encodeURIComponent(i):i}function ea(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 d=i.arrayFormat;if(d==="comma"){let g=i.encode?encodeURIComponent(n):n,h=r.filter(l=>l!=null).map(l=>Xt(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=d==="indices"?`${n}[${g}]`:n;t.push(...ea(h,l,i))}else{let l=d==="indices"?`${n}[${g}]`:n,y=i.encode?encodeURIComponent(l):l;t.push(`${y}=${Xt(h,i.encode)}`)}}}else if(typeof r=="object"&&r!==null){if(Object.keys(r).length===0)continue;t.push(...ea(r,n,i))}else{let d=i.encode?encodeURIComponent(n):n;t.push(`${d}=${Xt(r,i.encode)}`)}}return t}function ur(p,o){return p==null||typeof p!="object"?"":ea(p,"",{...ib,...o}).join("&")}function so(p,o){let i=ur(o,{arrayFormat:"repeat"});return i?`${p}?${i}`:p}function ds(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=ob();function ob(){if(typeof window<"u"&&typeof window.document<"u")return{type:"browser",version:window.navigator.userAgent};if(typeof globalThis<"u"&&globalThis?.navigator?.userAgent==="Cloudflare-Workers")return{type:"workerd"};if(typeof EdgeRuntime=="string")return{type:"edge-runtime"};if(typeof self=="object"&&typeof self?.importScripts=="function"&&(self.constructor?.name==="DedicatedWorkerGlobalScope"||self.constructor?.name==="ServiceWorkerGlobalScope"||self.constructor?.name==="SharedWorkerGlobalScope"))return{type:"web-worker"};if(typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u")return{type:"deno",version:Deno.version.deno};if(typeof Bun<"u"&&typeof Bun.version<"u")return{type:"bun",version:Bun.version};if(typeof navigator<"u"&&navigator?.product==="ReactNative")return{type:"react-native"};let d=typeof process<"u"?process:void 0;return typeof d<"u"&&typeof d.versions?.node=="string"?{type:"node",version:d.versions.node,parsedVersion:Number(d.versions.node.split(".")[0])}:{type:"unknown"}}async function zs(p){return Re.type==="node"&&Re.parsedVersion!=null&&Re.parsedVersion>=18?new(await Promise.resolve().then(()=>(hs(),ms))).Node18UniversalStreamWrapper(p):Re.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(ys(),gs))).UndiciStreamWrapper(p):new(await Promise.resolve().then(()=>(bs(),ws))).NodePre18StreamWrapper(p)}async function ai(p,o){switch(o){case"binary-response":return ds(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}}:zs(p.body);case"text":return await p.text()}let i=await p.text();if(i.length>0)try{return Gi(i)}catch{return{ok:!1,error:{reason:"non-json",statusCode:p.status,rawBody:i}}}}async function Rs(p){let o=p.headers.get("Content-Type")?.toLowerCase();if(o==null||o.length===0)return ai(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?Gi(i):void 0}default:if(o.startsWith("application/vnd.")&&o.endsWith("+json")){let i=await p.text();return i.length>0?Gi(i):void 0}return await p.text()}}async function ni(){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 co({body:p,type:o}){return o==="form"?ur(p,{arrayFormat:"repeat",encode:!0}):o.includes("json")?xe(p):p}var Ye;typeof globalThis.Headers<"u"?Ye=globalThis.Headers:Ye=class fs{constructor(o){if(this.headers=new Map,o)if(o instanceof fs)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 tb="timeout";function _s(p){let o=new AbortController,i=setTimeout(()=>o.abort(tb),p);return{signal:o.signal,abortId:i}}function Ss(...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 Ni;function ab(){if(Ni!=null)return Ni;try{new Request("http://localhost",{cache:"no-store"}),Ni=!0}catch{Ni=!1}return Ni}var si=async(p,o,i,t,s,r,n,d,g,h)=>{let l=[],y;if(r!=null){let{signal:v,abortId:O}=_s(r);y=O,l.push(v)}n!=null&&l.push(n);let w=Ss(l),U=await p(o,{method:i,headers:t,body:s,signal:w,credentials:d?"include":void 0,duplex:g,...h&&ab()?{cache:"no-store"}:{}});return y!=null&&clearTimeout(y),U};var ci={headers:new Ye,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},li={headers:new Ye,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function $i(p){return{headers:p.headers,redirected:p.redirected,status:p.status,statusText:p.statusText,type:p.type,url:p.url}}function nb(p){return[408,429].includes(p)||p>=500}function sb(p){let o=1+Math.random()*.2;return p*o}function cb(p){let o=1+(Math.random()-.5)*.2;return p*o}function lb(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 sb(Math.min(r,6e4))}}return cb(Math.min(1e3*2**o,6e4))}async function pi(p,o=2){let i=await p();for(let t=0;t<o&&nb(i.status);++t){let s=lb(i,t);await new Promise(r=>setTimeout(r,s)),i=await p()}return i}var pb=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 o={};for(let[i,t]of p instanceof Ye?p.entries():Object.entries(p))pb.has(i.toLowerCase())?o[i]="[REDACTED]":o[i]=t;return o}var aa=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 ub(p){if(p==null)return;let o={};for(let[i,t]of Object.entries(p))o[i]=aa.has(i.toLowerCase())?"[REDACTED]":t;return o}function Yr(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),d=-1;for(let v=i;v<n;v++)p[v]==="@"&&(d=v);if(d!==-1&&(p=`${p.slice(0,i)}[REDACTED]@${p.slice(d+1)}`),s=p.indexOf("?"),s===-1)return p;r=p.indexOf("#",s);let 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 v of U){let O=v.indexOf("=");if(O===-1){w.push(v);continue}let B=v.slice(0,O),j=aa.has(B.toLowerCase());if(!j&&B.includes("%"))try{let $=decodeURIComponent(B);j=aa.has($.toLowerCase())}catch{}w.push(j?`${B}=[REDACTED]`:v)}return p.slice(0,s+1)+w.join("&")+p.slice(g)}async function db(p){let o=new Ye;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 no.get(t,{endpointMetadata:p.endpointMetadata??{}});if(typeof s=="string"){o.set(i,s);continue}s!=null&&o.set(i,`${s}`)}return o}async function mb(p){let o=p.url;p.queryString!=null&&p.queryString.length>0?o=`${o}?${p.queryString}`:o=so(p.url,p.queryParameters);let i=await co({body:p.body,type:p.requestType??"other"}),t=p.fetchFn??await ni(),s=await db(p),r=Hi(p.logging);if(r.isDebug()){let n={method:p.method,url:Yr(o),headers:ta(s),queryParameters:ub(p.queryParameters),hasBody:i!=null};r.debug("Making HTTP request",n)}try{let n=await pi(async()=>si(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:Yr(o),statusCode:n.status,responseHeaders:ta(n.headers)};r.debug("HTTP request succeeded",g)}return{ok:!0,body:await ai(n,p.responseType),headers:n.headers,rawResponse:$i(n)}}else{if(r.isError()){let d={method:p.method,url:Yr(o),statusCode:n.status,responseHeaders:ta(Object.fromEntries(n.headers.entries()))};r.error("HTTP request failed with error status",d)}return{ok:!1,error:{reason:"status-code",statusCode:n.status,body:await Rs(n)},rawResponse:$i(n)}}}catch(n){if(p.abortSignal?.aborted){if(r.isError()){let d={method:p.method,url:Yr(o)};r.error("HTTP request was aborted",d)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:n},rawResponse:ci}}else if(n instanceof Error&&n.name==="AbortError"){if(r.isError()){let d={method:p.method,url:Yr(o),timeoutMs:p.timeoutMs};r.error("HTTP request timed out",d)}return{ok:!1,error:{reason:"timeout",cause:n},rawResponse:ci}}else if(n instanceof Error){if(r.isError()){let d={method:p.method,url:Yr(o),errorMessage:n.message};r.error("HTTP request failed with error",d)}return{ok:!1,error:{reason:"unknown",errorMessage:n.message,cause:n},rawResponse:li}}if(r.isError()){let d={method:p.method,url:Yr(o),error:xe(n)};r.error("HTTP request failed with unknown error",d)}return{ok:!1,error:{reason:"unknown",errorMessage:xe(n),cause:n},rawResponse:li}}}var E=mb;var S=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 lo(p,...o){if(!p)return"";if(o.length===0)return p;if(p.includes("://")){let i;try{i=new URL(p)}catch{return Ps(p,...o)}let s=o[o.length-1]?.endsWith("/");for(let r of o){let n=Es(r);n&&(i.pathname=xs(i.pathname,n))}return s&&!i.pathname.endsWith("/")&&(i.pathname+="/"),i.toString()}return Ps(p,...o)}function Ps(p,...o){if(o.length===0)return p;let i=p,s=o[o.length-1]?.endsWith("/");for(let r of o){let n=Es(r);n&&(i=xs(i,n))}return s&&!i.endsWith("/")&&(i+="/"),i}function xs(p,o){return p.endsWith("/")?p+o:`${p}/${o}`}function Es(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 na(p,o,i,t){let s=Hi(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 d=(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:d!=null?g=lo(d,r):g=r;let h={};if(i.headers!=null)for(let[$,A]of Object.entries(i.headers)){let le=await no.get(A,{endpointMetadata:{}});le!=null&&(h[$.toLowerCase()]=`${le}`)}if(i.getAuthHeaders!=null){let $=await i.getAuthHeaders();for(let[A,le]of Object.entries($))h[A.toLowerCase()]=le}if(n?.headers!=null){let $=n.headers instanceof Headers?Object.fromEntries(n.headers.entries()):Array.isArray(n.headers)?Object.fromEntries(n.headers):n.headers;for(let[A,le]of Object.entries($))le!=null&&(h[A.toLowerCase()]=le)}if(t?.headers!=null)for(let[$,A]of Object.entries(t.headers))h[$.toLowerCase()]=A;let l=n?.method??"GET",y=n?.body,w=t?.timeoutInSeconds??i.timeoutInSeconds,U=w!=null?w*1e3:void 0,v=t?.maxRetries??i.maxRetries,O=t?.abortSignal??n?.signal??void 0,B=i.fetch??await ni();s.isDebug()&&s.debug("Making passthrough HTTP request",{method:l,url:g,hasBody:y!=null});let j=await pi(async()=>si(B,g,l,h,y??void 0,U,O,n?.credentials==="include",void 0,!1),v);return s.isDebug()&&s.debug("Passthrough HTTP request completed",{method:l,url:g,statusCode:j.status}),j}var po={};pr(po,{ConsoleLogger:()=>Wi,LogLevel:()=>Ge,Logger:()=>ti,createLogger:()=>Hi});var e={};pr(e,{JsonError:()=>ui,ParseError:()=>di,any:()=>Fs,bigint:()=>Us,boolean:()=>Ks,booleanLiteral:()=>Ms,date:()=>vs,discriminant:()=>Qs,enum_:()=>Ji,forwardCompatibleEnum_:()=>Ts,getObjectLikeUtils:()=>We,getObjectUtils:()=>Qr,getSchemaUtils:()=>Z,isProperty:()=>mr,lazy:()=>Os,lazyObject:()=>qs,list:()=>ho,never:()=>Ls,number:()=>Gs,object:()=>mo,objectWithoutOptionalProperties:()=>Vs,optional:()=>sa,partialRecord:()=>$s,property:()=>Bs,record:()=>Ns,set:()=>Js,string:()=>Ws,stringLiteral:()=>Is,transform:()=>ca,undiscriminatedUnion:()=>Ys,union:()=>ec,unknown:()=>Hs,withParsedProperties:()=>ua});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,o){return`Expected ${o}. Received ${hb(p)}.`}function hb(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:Cs(p.json),parse:Cs(p.parse)}}function Cs(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 ui=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 di=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 Z(p){return{nullable:()=>gb(p),optional:()=>sa(p),optionalNullable:()=>yb(p),transform:o=>ca(p,o),parseOrThrow:(o,i)=>{let t=p.parse(o,i);if(t.ok)return t.value;throw new di(t.errors)},jsonOrThrow:(o,i)=>{let t=p.json(o,i);if(t.ok)return t.value;throw new ui(t.errors)}}}function gb(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:()=>D.NULLABLE};return{...o,...Z(o)}}function sa(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:()=>D.OPTIONAL};return{...o,...Z(o)}}function yb(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:()=>D.OPTIONAL_NULLABLE};return{...o,...Z(o)}}function ca(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,...Z(i)}}function Us(){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:J(o,"bigint | number")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="bigint"?{ok:!1,errors:[{path:i,message:J(o,"bigint")}]}:{ok:!0,value:o},getType:()=>D.BIGINT};return{...ge(p),...Z(p)}}var wb=/^([+-]?\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 vs(){let p={parse:(o,{breadcrumbsPrefix:i=[]}={})=>typeof o!="string"?{ok:!1,errors:[{path:i,message:J(o,"string")}]}:wb.test(o)?{ok:!0,value:new Date(o)}:{ok:!1,errors:[{path:i,message:J(o,"ISO 8601 date string")}]},json:(o,{breadcrumbsPrefix:i=[]}={})=>o instanceof Date?{ok:!0,value:o.toISOString()}:{ok:!1,errors:[{path:i,message:J(o,"Date object")}]},getType:()=>D.DATE};return{...ge(p),...Z(p)}}function we(p,o){return()=>{let i={parse:o,json:o,getType:()=>p};return{...ge(i),...Z(i)}}}function Ji(p){let o=new Set(p);return we(D.ENUM,(t,{allowUnrecognizedEnumValues:s,breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:J(t,"string")}]}:!o.has(t)&&!s?{ok:!1,errors:[{path:r,message:J(t,"enum")}]}:{ok:!0,value:t})()}function Ts(p){return Ji(p).transform({transform:o=>o,untransform:o=>o})}function Os(p){let o=la(p);return{...o,...Z(o)}}function la(p){return{parse:(o,i)=>mi(p).parse(o,i),json:(o,i)=>mi(p).json(o,i),getType:()=>mi(p).getType()}}function mi(p){let o=p;return o.__zurg_memoized==null&&(o.__zurg_memoized=p()),o.__zurg_memoized}function pa(p){return Object.entries(p)}function Zi(p,o){let i=new Set(o);return Object.entries(p).reduce((t,[s,r])=>(i.has(s)&&(t[s]=r),t),{})}function dr(p){if(typeof p!="object"||p===null)return!1;let o=Object.getPrototypeOf(p);return o===null?!0:Object.getPrototypeOf(o)===null}function Yi(p){return Object.keys(p)}function ks(p,o){let i=[],t=[];for(let s of p)o(s)?i.push(s):t.push(s);return[i,t]}var bb=Object.prototype.hasOwnProperty;function We(p){return{withParsedProperties:o=>ua(p,o)}}function ua(p,o){let i={parse:(t,s)=>{let r=p.parse(t,s);if(!r.ok)return r;let n={};for(let d in o)if(bb.call(o,d)){let g=o[d];n[d]=typeof g=="function"?g(r.value):g}return{ok:!0,value:{...r.value,...n}}},json:(t,s)=>{if(!dr(t))return{ok:!1,errors:[{path:s?.breadcrumbsPrefix??[],message:J(t,"object")}]};let r=new Set(Object.keys(o)),n=Zi(t,Object.keys(t).filter(d=>!r.has(d)));return p.json(n,s)},getType:()=>p.getType()};return{...i,...Z(i),...We(i)}}function Bs(p,o){return{rawKey:p,valueSchema:o,isProperty:!0}}function mr(p){return p.isProperty}var zb=Object.prototype.hasOwnProperty;function mo(p){let o;function i(){if(o==null){o={};for(let[w,U]of pa(p)){let v=mr(U)?U.rawKey:w,O=mr(U)?U.valueSchema:U;o[v]={rawKey:v,parsedKey:w,valueSchema:O}}}return o}let t,s,r,n;function d(){if(t==null){t=[],s=[];for(let[w,U]of pa(p)){let v=mr(U)?U.rawKey:w,O=mr(U)?U.valueSchema:U;Rb(O)&&(t.push(v),s.push(w))}r=new Set(t),n=new Set(s)}return t}function g(){return s==null&&d(),s}function h(){return r==null&&d(),r}function l(){return n==null&&d(),n}let y={_getRawProperties:()=>Object.entries(p).map(([w,U])=>mr(U)?U.rawKey:w),_getParsedProperties:()=>Yi(p),parse:(w,U)=>{let v=U?.breadcrumbsPrefix??[];return js({value:w,requiredKeys:d(),requiredKeysSet:h(),getProperty:O=>{let B=i()[O];if(B!=null)return{transformedKey:B.parsedKey,transform:j=>{let $=[...v,O];return B.valueSchema.parse(j,{...U,breadcrumbsPrefix:$})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:v,omitUndefined:U?.omitUndefined})},json:(w,U)=>{let v=U?.breadcrumbsPrefix??[];return js({value:w,requiredKeys:g(),requiredKeysSet:l(),getProperty:O=>{let B=p[O];if(B!=null)return mr(B)?{transformedKey:B.rawKey,transform:j=>{let $=[...v,O];return B.valueSchema.json(j,{...U,breadcrumbsPrefix:$})}}:{transformedKey:O,transform:j=>{let $=[...v,O];return B.json(j,{...U,breadcrumbsPrefix:$})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:v,omitUndefined:U?.omitUndefined})},getType:()=>D.OBJECT};return{...ge(y),...Z(y),...We(y),...Qr(y)}}function js({value:p,requiredKeys:o,requiredKeysSet:i,getProperty:t,unrecognizedObjectKeys:s="fail",skipValidation:r=!1,breadcrumbsPrefix:n=[]}){if(!dr(p))return{ok:!1,errors:[{path:n,message:J(p,"object")}]};let d=o.length,g=[],h={};for(let l in p){if(!zb.call(p,l))continue;let y=p[l],w=t(l);if(w!=null){d>0&&i.has(l)&&d--;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(d>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 Qr(p){return{extend:o=>{let i={_getParsedProperties:()=>[...p._getParsedProperties(),...o._getParsedProperties()],_getRawProperties:()=>[...p._getRawProperties(),...o._getRawProperties()],parse:(t,s)=>As({extensionKeys:o._getRawProperties(),value:t,transformBase:r=>p.parse(r,s),transformExtension:r=>o.parse(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(t,s)=>As({extensionKeys:o._getParsedProperties(),value:t,transformBase:r=>p.json(r,s),transformExtension:r=>o.json(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),getType:()=>D.OBJECT};return{...i,...Z(i),...We(i),...Qr(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 d={};if(typeof s=="object"&&s!=null)for(let[g,h]of Object.entries(s))o.has(g)||(d[g]=h);return{ok:!0,value:{...d,...n.value}}},json:(s,r)=>{let n=p.json(s,{...r,unrecognizedObjectKeys:"passthrough"});if(!n.ok)return n;let d={};if(typeof s=="object"&&s!=null)for(let[g,h]of Object.entries(s))i.has(g)||(d[g]=h);return{ok:!0,value:{...d,...n.value}}},getType:()=>D.OBJECT};return{...t,...Z(t),...We(t),...Qr(t)}}}}function As({extensionKeys:p,value:o,transformBase:i,transformExtension:t,breadcrumbsPrefix:s=[]}){if(!dr(o))return{ok:!1,errors:[{path:s,message:J(o,"object")}]};let r=new Set(p),[n,d]=ks(Yi(o),l=>r.has(l)),g=i(Zi(o,d)),h=t(Zi(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 Rb(p){return!fb(p)}function fb(p){switch(p.getType()){case D.ANY:case D.UNKNOWN:case D.OPTIONAL:case D.OPTIONAL_NULLABLE:return!0;default:return!1}}function Vs(p){return mo(p)}function qs(p){let o={...la(p),_getRawProperties:()=>mi(p)._getRawProperties(),_getParsedProperties:()=>mi(p)._getParsedProperties()};return{...o,...Z(o),...We(o),...Qr(o)}}function ho(p){let o={parse:(i,t)=>Ds(i,(s,r)=>p.parse(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),json:(i,t)=>Ds(i,(s,r)=>p.json(s,{...t,breadcrumbsPrefix:[...t?.breadcrumbsPrefix??[],`[${r}]`]})),getType:()=>D.LIST};return{...ge(o),...Z(o)}}function Ds(p,o){if(!Array.isArray(p))return{ok:!1,errors:[{message:J(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 Ms(p){return we(D.BOOLEAN_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(i,`${p.toString()}`)}]})()}function Is(p){return we(D.STRING_LITERAL,(i,{breadcrumbsPrefix:t=[]}={})=>i===p?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(i,`"${p}"`)}]})()}var Fs=we(D.ANY,p=>({ok:!0,value:p}));var Ks=we(D.BOOLEAN,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="boolean"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"boolean")}]});var Ls=we(D.NEVER,(p,{breadcrumbsPrefix:o=[]}={})=>({ok:!1,errors:[{path:o,message:"Expected never"}]}));var Gs=we(D.NUMBER,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="number"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"number")}]});var Ws=we(D.STRING,(p,{breadcrumbsPrefix:o=[]}={})=>typeof p=="string"?{ok:!0,value:p}:{ok:!1,errors:[{path:o,message:J(p,"string")}]});var Hs=we(D.UNKNOWN,p=>({ok:!0,value:p}));var _b=Object.prototype.hasOwnProperty;function Ns(p,o){let i={parse:(t,s)=>go({value:t,isKeyNumeric:p.getType()===D.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)=>go({value:t,isKeyNumeric:p.getType()===D.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:()=>D.RECORD};return{...ge(i),...Z(i)}}function $s(p,o){let i={parse:(t,s)=>go({value:t,isKeyNumeric:p.getType()===D.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)=>go({value:t,isKeyNumeric:p.getType()===D.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:()=>D.RECORD};return{...ge(i),...Z(i)}}function go({value:p,isKeyNumeric:o,transformKey:i,transformValue:t,breadcrumbsPrefix:s=[]}){if(!dr(p))return{ok:!1,errors:[{path:s,message:J(p,"object")}]};let r={},n=[];for(let d in p){if(!_b.call(p,d))continue;let g=p[d];if(g===void 0)continue;let h=d;if(o){let w=d.length>0?Number(d):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 Js(p){let o=ho(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:J(t,"Set")}]},getType:()=>D.SET};return{...ge(i),...Z(i)}}function Ys(p){let o={parse:(i,t)=>Zs((s,r)=>s.parse(i,r),p,t),json:(i,t)=>Zs((s,r)=>s.json(i,r),p,t),getType:()=>D.UNDISCRIMINATED_UNION};return{...ge(o),...Z(o)}}function Zs(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 d of n.errors)t.push({path:d.path,message:`[Variant ${s}] ${d.message}`})}return{ok:!1,errors:t}}function Qs(p,o){return{parsedDiscriminant:p,rawDiscriminant:o}}var Sb=Object.prototype.hasOwnProperty;function ec(p,o){let i=typeof p=="string"?p:p.rawDiscriminant,t=typeof p=="string"?p:p.parsedDiscriminant,s=Ji(Yi(o)),r={parse:(n,d)=>Xs({value:n,discriminant:i,transformedDiscriminant:t,transformDiscriminantValue:g=>s.parse(g,{allowUnrecognizedEnumValues:d?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...d?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:g=>o[g],allowUnrecognizedUnionMembers:d?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(g,h)=>h.parse(g,d),breadcrumbsPrefix:d?.breadcrumbsPrefix}),json:(n,d)=>Xs({value:n,discriminant:t,transformedDiscriminant:i,transformDiscriminantValue:g=>s.json(g,{allowUnrecognizedEnumValues:d?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...d?.breadcrumbsPrefix??[],t]}),getAdditionalPropertiesSchema:g=>o[g],allowUnrecognizedUnionMembers:d?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(g,h)=>h.json(g,d),breadcrumbsPrefix:d?.breadcrumbsPrefix}),getType:()=>D.UNION};return{...ge(r),...Z(r),...We(r)}}function Xs({value:p,discriminant:o,transformedDiscriminant:i,transformDiscriminantValue:t,getAdditionalPropertiesSchema:s,allowUnrecognizedUnionMembers:r=!1,transformAdditionalProperties:n,breadcrumbsPrefix:d=[]}){if(!dr(p))return{ok:!1,errors:[{path:d,message:J(p,"object")}]};let g=p[o],h={};for(let U in p)Sb.call(p,U)&&U!==o&&(h[U]=p[U]);if(g==null)return{ok:!1,errors:[{path:d,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:[...d,o],message:"Unexpected discriminant value"}]};let w=n(h,y);return w.ok?{ok:!0,value:{[i]:g,...w.value}}:w}var u={};pr(u,{encodePathParam:()=>rc,join:()=>lo,queryBuilder:()=>ic,toQueryString:()=>ur});function rc(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 ic(){return new da}var da=class{constructor(){this.parts=new Map}add(o,i,t){if(i==null)return this;let s=ur({[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=ur({[i]:t},{arrayFormat:"repeat"});s.length>0&&this.parts.set(i,s)}return this}build(){return[...this.parts.values()].join("&")}};var ma="apiKey",Pb="X-Schematic-Api-Key",hi=class p{constructor(o){this.options=o}static canCreate(o){return o?.[ma]!=null}async getAuthRequest({endpointMetadata:o}={}){let i=await m.get(this.options[ma]);if(i==null)throw new b({message:p.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[Pb]:i}}}};(t=>{t.AUTH_SCHEME="ApiKeyAuth",t.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${ma}' when initializing the client`;function i(s){return new t(s)}t.createInstance=i})(hi||={});function P(...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 xb(p){let o=P({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@schematichq/schematic-typescript-node","X-Fern-SDK-Version":"1.4.7","User-Agent":"@schematichq/schematic-typescript-node/1.4.7","X-Fern-Runtime":Re.type,"X-Fern-Runtime-Version":Re.version},p?.headers);return{...p,logging:po.createLogger(p?.logging),headers:o}}function I(p){let o=xb(p);if(p.auth===!1)return o.authProvider=new oi,o;if(p.auth!=null){if(typeof p.auth=="function")return o.authProvider={getAuthRequest:p.auth},o;if(Qt(p.auth))return o.authProvider=p.auth,o;Object.assign(o,p.auth)}let i=Eb(o);return o.authProvider??=new hi(i),o}function Eb(p){return{...p,authProvider:new oi}}var x={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 Jr(`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 ha=e.object({lookup:e.record(e.string(),e.string())});var oc=e.stringLiteral("company");var tc=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 ac=e.object({data:tc,params:e.record(e.string(),e.unknown())});var ga=e.object({description:e.string().optional(),environmentId:e.property("environment_id",e.string().optional()),name:e.string(),readonly:e.boolean().optional()});var _r=e.enum_(["development","production","staging"]);var ya=e.object({environmentType:e.property("environment_type",_r),name:e.string()});var wa=e.object({description:e.string().optional(),name:e.string().optional()});var ba=e.object({environmentType:e.property("environment_type",_r.optional()),name:e.string().optional()});var nc=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 V=e.object({count:e.number().optional()});var sc=e.object({data:V,params:nc});var Se=e.enum_(["api_key","app_user","stripe_app","system","temporary_access_token"]);var cc=e.object({actorType:e.property("actor_type",Se.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 lc=e.object({data:V,params:cc});var Qe=e.enum_(["active","created","pending"]);var ke=e.enum_(["clerk","orb","stripe","unknown","workos"]);var yo=e.object({id:e.string(),state:Qe,type:ke});var wo=e.enum_(["admin","capture","read","write"]);var fe=e.object({createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",_r),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var pc=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:fe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:yo.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(wo),secret:e.string(),updatedAt:e.property("updated_at",e.date())});var uc=e.object({data:pc,params:e.record(e.string(),e.unknown())});var _e=e.object({createdAt:e.property("created_at",e.date()),description:e.string().optional(),environment:fe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),integration:yo.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(wo),updatedAt:e.property("updated_at",e.date())});var dc=e.object({apiKeys:e.property("api_keys",e.list(_e)),createdAt:e.property("created_at",e.date()),environmentType:e.property("environment_type",_r),id:e.string(),name:e.string(),updatedAt:e.property("updated_at",e.date())});var mc=e.object({data:dc,params:e.record(e.string(),e.unknown())});var K=e.object({deleted:e.boolean().optional()});var hc=e.object({data:K,params:e.record(e.string(),e.unknown())});var gc=e.object({data:K,params:e.record(e.string(),e.unknown())});var yc=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 wc=e.enum_(["admin","member"]);var Sr=e.object({createdAt:e.property("created_at",e.date()),email:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string().optional(),permissions:e.record(e.string(),e.list(yc)),role:wc.optional(),updatedAt:e.property("updated_at",e.date())});var bc=e.object({data:Sr,params:e.record(e.string(),e.unknown())});var zc=e.object({data:_e,params:e.record(e.string(),e.unknown())});var Rc=e.object({actorType:e.property("actor_type",Se),apiKey:e.property("api_key",_e.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:fe.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 fc=e.object({data:Rc,params:e.record(e.string(),e.unknown())});var _c=e.object({data:fe,params:e.record(e.string(),e.unknown())});var Sc=e.object({accountId:e.property("account_id",e.string()),accountName:e.property("account_name",e.string()),actorType:e.property("actor_type",Se),apiKeyId:e.property("api_key_id",e.string().optional()),environmentId:e.property("environment_id",e.string().optional()),environments:e.list(fe),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 Pc=e.object({data:Sc,params:e.record(e.string(),e.unknown())});var xc=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ec=e.object({data:e.list(Sr),params:xc});var Cc=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 Uc=e.object({data:e.list(_e),params:Cc});var vc=e.object({actorType:e.property("actor_type",Se.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 bo=e.object({actorType:e.property("actor_type",Se),apiKey:e.property("api_key",_e.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:fe.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 Tc=e.object({data:e.list(bo),params:vc});var Oc=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var kc=e.object({data:e.list(fe),params:Oc});var Bc=e.object({ok:e.boolean()});var jc=e.object({data:Bc,params:e.record(e.string(),e.unknown())});var Ac=e.object({data:_e,params:e.record(e.string(),e.unknown())});var Vc=e.object({data:fe,params:e.record(e.string(),e.unknown())});var k=e.enum_(["orb","schematic","stripe"]);var za=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 Xe=e.enum_(["per_unit","tiered"]);var ne=e.enum_(["licensed","metered"]);var pe=e.enum_(["graduated","volume"]);var qc=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 Ra=e.object({billingScheme:e.property("billing_scheme",Xe),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(qc)),productExternalId:e.property("product_external_id",e.string()),providerType:e.property("provider_type",k.optional()),tiersMode:e.property("tiers_mode",pe.optional()),usageType:e.property("usage_type",ne)});var fa=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 Dc=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 Mc=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 Pr=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(Mc),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(Dc)),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",Pr.optional())});var Sa=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 zo=e.enum_(["draft","open","paid","uncollectible","void"]);var Pa=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:zo.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),url:e.string().optional()});var xa=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 Ea=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 Ic=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 Fc=e.object({data:V,params:Ic});var Kc=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 Lc=e.object({data:V,params:Kc});var Gc=e.object({data:K,params:e.record(e.string(),e.unknown())});var Wc=e.object({data:K,params:e.record(e.string(),e.unknown())});var Hc=e.object({data:K,params:e.record(e.string(),e.unknown())});var Nc=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",pe.optional()),usageType:e.property("usage_type",ne.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var gi=e.enum_(["day","month","one-time","year"]);var Ro=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",Xe),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:gi,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(Ro)),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",pe.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",ne)});var $c=e.object({data:e.list(H),params:Nc});var Jc=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",pe.optional()),usageType:e.property("usage_type",ne.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var Zc=e.object({data:e.list(H),params:Jc});var Yc=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:gi,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:Xe});var er=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 Qc=e.object({data:e.list(er),params:Yc});var Xc=e.object({isActive:e.property("is_active",e.boolean().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var fo=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 el=e.object({data:e.list(fo),params:Xc});var rl=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 il=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 ol=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(il),updatedAt:e.property("updated_at",e.date())});var tl=e.object({data:e.list(ol),params:rl});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 He=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:zo.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 nl=e.object({data:e.list(He),params:al});var sl=e.object({displayName:e.property("display_name",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var _o=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 cl=e.object({data:e.list(_o),params:sl});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 Ne=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 pl=e.object({data:e.list(Ne),params:ll});var ul=e.object({data:fo,params:e.record(e.string(),e.unknown())});var dl=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 ml=e.object({data:dl,params:e.record(e.string(),e.unknown())});var hl=e.object({data:_o,params:e.record(e.string(),e.unknown())});var gl=e.object({data:L,params:e.record(e.string(),e.unknown())});var xr=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:xr,params:e.record(e.string(),e.unknown())});var wl=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",Pr.optional())});var bl=e.object({data:wl,params:e.record(e.string(),e.unknown())});var zl=e.object({data:He,params:e.record(e.string(),e.unknown())});var Rl=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Ca=e.object({cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),prorate:e.boolean().optional()});var Ua=e.object({companyId:e.property("company_id",e.string()),selectedPlanId:e.property("selected_plan_id",e.string().optional())});var va=e.object({trialEnd:e.property("trial_end",e.date().optional())});var So=e.object({billingScheme:e.property("billing_scheme",Xe),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(Ro)),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 Po=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 Qi=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(Po),expiredAt:e.property("expired_at",e.date().optional()),id:e.string(),interval:e.string(),latestInvoice:e.property("latest_invoice",He.optional()),metadata:e.record(e.string(),e.unknown()).optional(),paymentMethod:e.property("payment_method",Ne.optional()),periodEnd:e.property("period_end",e.number()),periodStart:e.property("period_start",e.number()),products:e.list(So),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",Pr.optional())});var W=e.enum_(["all_time","current_day","current_month","current_week"]);var N=e.enum_(["billing_cycle","first_of_month"]);var fl=e.object({accountId:e.property("account_id",e.string()),capturedAtMax:e.property("captured_at_max",e.date()),capturedAtMin:e.property("captured_at_min",e.date()),companyId:e.property("company_id",e.string()),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string()),monthReset:e.property("month_reset",N),period:W,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var 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 Er=e.enum_(["expiration_priority","first_in_first_out","last_in_first_out","plan_first_then_credit_bundles_first_in_first_out"]);var Cr=e.enum_(["expire","none","rollover"]);var _l=e.object({currency:e.string(),price:H.optional()});var xo=e.object({accountId:e.property("account_id",e.string()),burnStrategy:e.property("burn_strategy",Er),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(_l)),defaultExpiryUnit:e.property("default_expiry_unit",G),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Cr),description:e.string(),environmentId:e.property("environment_id",e.string()),icon:e.string().optional(),id:e.string(),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:xr.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Ee=e.enum_(["daily","monthly","weekly","yearly"]);var Be=e.enum_(["billing_period","first_of_month"]);var rr=e.enum_(["no_reset","plan_period"]);var yi=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Sl=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:xo.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:yi.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",Ee.optional()),resetStart:e.property("reset_start",Be.optional()),resetType:e.property("reset_type",rr),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Ta=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(Sl)),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 wi=e.enum_(["on_payment","on_publish"]);var hr=e.enum_(["active","expired","paid","pending"]);var Ur=e.object({activationStrategy:e.property("activation_strategy",wi),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:hr,stripeInvoiceUrl:e.property("stripe_invoice_url",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var ie=e.enum_(["company","user"]);var Eo=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 Co=e.object({createdAt:e.property("created_at",e.date()),definition:Eo.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 ue=e.enum_(["boolean","currency","date","number","string","url"]);var de=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",ue),updatedAt:e.property("updated_at",e.date())});var Uo=e.object({createdAt:e.property("created_at",e.date()),definition:de.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 ee=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var vo=e.object({allocation:e.number().optional(),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",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",W.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",ee)});var bi=e.enum_(["eq","gt","gte","is_empty","lt","lte","not_empty","ne"]);var zi=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var Pl=e.enum_(["bool","date","int","string"]);var Oa=e.object({comparableType:e.property("comparable_type",Pl),entityType:e.property("entity_type",ie),id:e.string()});var To=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",Oa.optional()),conditionType:e.property("condition_type",zi),consumptionRate:e.property("consumption_rate",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:bi,resourceIds:e.property("resource_ids",e.list(e.string())),traitDefinition:e.property("trait_definition",Oa.optional()),traitValue:e.property("trait_value",e.string())});var xl=e.object({conditions:e.list(To)});var vr=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var El=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list(xl)),conditions:e.list(To),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 Oo=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 Q=e.object({addOns:e.property("add_ons",e.list(Ta)),billingCreditBalances:e.property("billing_credit_balances",e.record(e.string(),e.number()).optional()),billingSubscription:e.property("billing_subscription",Qi.optional()),billingSubscriptions:e.property("billing_subscriptions",e.list(Qi)),createdAt:e.property("created_at",e.date()),customPlanBillings:e.property("custom_plan_billings",e.list(Ur)),defaultPaymentMethod:e.property("default_payment_method",Ne.optional()),entitlements:e.list(vo),entityTraits:e.property("entity_traits",e.list(Uo)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Co),lastSeenAt:e.property("last_seen_at",e.date().optional()),logoUrl:e.property("logo_url",e.string().optional()),metrics:e.list(fl),name:e.string(),paymentMethods:e.property("payment_methods",e.list(Ne)),plan:Ta.optional(),plans:e.list(yi),rules:e.list(El),scheduledDowngrade:e.property("scheduled_downgrade",Oo.optional()),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date()),userCount:e.property("user_count",e.number())});var ko=e.object({company:Q.optional(),success:e.boolean()});var Cl=e.object({data:ko,params:e.record(e.string(),e.unknown())});var Ul=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",Pr.optional())});var vl=e.object({data:Ul,params:e.record(e.string(),e.unknown())});var Pe=e.enum_(["active","inactive"]);var Oe=e.stringLiteral("fixed");var Tl=e.object({currency:e.string(),price:L.optional()});var je=e.object({billingInvoiceId:e.property("billing_invoice_id",e.string().optional()),bundleType:e.property("bundle_type",Oe),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(Tl)),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:Pe,unitPrice:e.property("unit_price",L.optional()),updatedAt:e.property("updated_at",e.date())});var Ri=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(Po),expiredAt:e.property("expired_at",e.date().optional()),interval:e.string(),latestInvoice:e.property("latest_invoice",He.optional()),paymentMethod:e.property("payment_method",Ne.optional()),products:e.list(So),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 Ol=e.object({bundle:je.optional(),quantity:e.number(),total:e.number()});var Ce=e.enum_(["adjustment","billing_credit_auto_topup","free","plan","purchased"]);var kl=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 Ae=e.enum_(["add_on","alpha","beta","deprecated","ga","inactive","in_plan","internal_testing","legacy"]);var se=e.enum_(["boolean","event","trait"]);var Tr=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",Ae.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 Ve=e.object({company:Q.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:Tr.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),notes:e.list(kl),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",de.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",ee)});var fi=e.object({creditTypeIcon:e.property("credit_type_icon",e.string().optional()),expiresAt:e.property("expires_at",e.date().optional()),grantReason:e.property("grant_reason",Ce),quantity:e.number()});var _i=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 Or=e.enum_(["company_override","plan_entitlement","unknown"]);var Ue=e.object({billingProvider:e.property("billing_provider",k),externalResourceId:e.property("external_resource_id",e.string()),originator:k});var Si=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 ir=e.stringLiteral("boolean");var Bo=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var jo=e.object({comparisonTrait:e.property("comparison_trait",de.optional()),comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionGroupId:e.property("condition_group_id",e.string().optional()),conditionType:e.property("condition_type",zi),createdAt:e.property("created_at",e.date()),environmentId:e.property("environment_id",e.string()),eventSubtype:e.property("event_subtype",e.string().optional()),flagId:e.property("flag_id",e.string().optional()),id:e.string(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:bi,resourceIds:e.property("resource_ids",e.list(e.string())),resources:e.list(Bo),ruleId:e.property("rule_id",e.string()),trait:de.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 Bl=e.object({conditions:e.list(jo),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 Pi=e.object({conditionGroups:e.property("condition_groups",e.list(Bl)),conditions:e.list(jo),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 jl=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:Tr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ir),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(Pi),updatedAt:e.property("updated_at",e.date())});var kr=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var qe=e.object({billingLinkedResource:e.property("billing_linked_resource",Ue.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Si.optional()),featureType:e.property("feature_type",se),flags:e.list(jl),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Ae.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(kr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:de.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Al=e.object({currency:e.string(),price:L.optional()});var De=e.object({burnStrategy:e.property("burn_strategy",Er),costEditable:e.property("cost_editable",e.boolean()),createdAt:e.property("created_at",e.date()),currencyPrices:e.property("currency_prices",e.list(Al)),defaultExpiryUnit:e.property("default_expiry_unit",G),defaultExpiryUnitCount:e.property("default_expiry_unit_count",e.number().optional()),defaultRolloverPolicy:e.property("default_rollover_policy",Cr),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:xr.optional(),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Vl=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 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 or=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 re=e.object({billingLinkedResource:e.property("billing_linked_resource",Ue.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(Vl)),environmentId:e.property("environment_id",e.string()),feature:Tr.optional(),featureId:e.property("feature_id",e.string()),id:e.string(),meteredMonthlyPrice:e.property("metered_monthly_price",H.optional()),meteredQuarterlyPrice:e.property("metered_quarterly_price",H.optional()),meteredYearlyPrice:e.property("metered_yearly_price",H.optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),plan:or.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",xr.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCredit:e.property("value_credit",De.optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTrait:e.property("value_trait",de.optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",ee)});var Br=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",ee),companyOverride:e.property("company_override",Ve.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(fi).optional()),creditGrantReason:e.property("credit_grant_reason",Ce.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",_i.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",Or),feature:qe.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:W.optional(),plan:or.optional(),planEntitlement:e.property("plan_entitlement",re.optional()),priceBehavior:e.property("price_behavior",be.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 xi=e.object({features:e.list(Br)});var ve=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:De.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:Bo.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",Ee.optional()),resetStart:e.property("reset_start",Be.optional()),resetType:e.property("reset_type",rr.optional()),updatedAt:e.property("updated_at",e.date())});var Me=e.enum_(["schematic_managed","provider_managed","no_billing"]);var Ie=e.enum_(["free","none","one_time","recurring"]);var jr=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 ql=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:ql,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",Ue.optional()),billingProduct:e.property("billing_product",er.optional()),billingStrategy:e.property("billing_strategy",Me),chargeType:e.property("charge_type",Ie),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(jr)),description:e.string(),draftVersion:e.property("draft_version",ze.optional()),entitlements:e.list(re).optional(),features:e.list(qe),icon:ce,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ve).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 Xi=e.object({billingThreshold:e.property("billing_threshold",e.number().optional()),consumptionRate:e.property("consumption_rate",e.number().optional()),featureId:e.property("feature_id",e.string()),meteredPrice:e.property("metered_price",H.optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),priceBehavior:e.property("price_behavior",be.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",ee),yearlyUsageBasedPrice:e.property("yearly_usage_based_price",H.optional())});var Dl=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(Xi)),availableCreditBundles:e.property("available_credit_bundles",e.list(je)),company:Q.optional(),featureUsage:e.property("feature_usage",xi.optional()),selectedCreditBundles:e.property("selected_credit_bundles",e.list(Ol)),selectedPlan:e.property("selected_plan",ye.optional()),selectedUsageBasedEntitlements:e.property("selected_usage_based_entitlements",e.list(Xi)),subscription:Ri.optional()});var Ml=e.object({data:Dl,params:e.record(e.string(),e.unknown())});var Il=e.object({data:ko,params:e.record(e.string(),e.unknown())});var Fl=e.object({amount:e.number(),description:e.string(),priceId:e.property("price_id",e.string()),proration:e.boolean(),quantity:e.number()});var Kl=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(Fl))});var Ao=e.object({amountOff:e.property("amount_off",e.number()),dueNow:e.property("due_now",e.number()),finance:Kl.optional(),isScheduledDowngrade:e.property("is_scheduled_downgrade",e.boolean()),newCharges:e.property("new_charges",e.number()),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(Br))});var Ll=e.object({data:Ao,params:e.record(e.string(),e.unknown())});var Gl=e.object({subscriptionChangePreview:e.property("subscription_change_preview",Ao.optional())});var Wl=e.object({data:Gl,params:e.record(e.string(),e.unknown())});var Hl=e.object({data:Qi,params:e.record(e.string(),e.unknown())});var ka=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",ue)});var Ba=e.object({companyId:e.property("company_id",e.string()),userId:e.property("user_id",e.string())});var ja=e.object({displayName:e.property("display_name",e.string().optional()),traitType:e.property("trait_type",ue)});var Ei=e.object({traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string())});var Aa=e.object({applyToExistingCompanies:e.property("apply_to_existing_companies",e.boolean()),planId:e.property("plan_id",e.string()),traits:e.list(Ei)});var Te=e.enum_(["asc","desc"]);var gr=e.enum_(["active","canceled","expired","incomplete","incomplete_expired","past_due","paused","trialing","unpaid"]);var yr=e.enum_(["free","one_time","paid","trial"]);var Nl=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",Te.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(gr).optional()),subscriptionTypes:e.property("subscription_types",e.list(yr).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 $l=e.object({data:V,params:Nl});var Jl=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 Zl=e.object({data:V,params:Jl});var Yl=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",ue.optional()),traitTypes:e.property("trait_types",e.list(ue).optional())});var Ql=e.object({data:V,params:Yl});var Xl=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 ep=e.object({data:V,params:Xl});var rp=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 ip=e.object({data:V,params:rp});var op=e.object({data:Q,params:e.record(e.string(),e.unknown())});var Ci=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 Ui=e.object({company:Ci.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 Fe=e.object({companyMemberships:e.property("company_memberships",e.list(Ui)),createdAt:e.property("created_at",e.date()),entityTraits:e.property("entity_traits",e.list(Uo)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Co),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 tp=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var ap=e.object({data:Ci,params:e.record(e.string(),e.unknown())});var np=e.object({data:K,params:e.record(e.string(),e.unknown())});var sp=e.object({cancelSubscription:e.property("cancel_subscription",e.boolean().optional()),prorate:e.boolean().optional()});var cp=e.object({data:K,params:sp});var Vo=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 lp=e.object({data:Vo,params:e.record(e.string(),e.unknown())});var pp=e.object({data:K,params:e.record(e.string(),e.unknown())});var up=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 dp=e.object({data:e.list(Ri),params:up});var mp=e.object({data:Q,params:e.record(e.string(),e.unknown())});var hp=e.object({data:de,params:e.record(e.string(),e.unknown())});var gp=e.object({definitionId:e.property("definition_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var yp=e.object({definitionId:e.property("definition_id",e.string()),value:e.string()});var wp=e.object({data:e.list(yp),params:gp});var bp=e.object({data:Ui,params:e.record(e.string(),e.unknown())});var zp=e.object({data:de,params:e.record(e.string(),e.unknown())});var vi=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 Ti=e.enum_(["fallback","initial","trait","trial_expiry"]);var Rp=e.enum_(["adjustment","downgrade","invalid","subscribe","unsubscribe","upgrade","upgrade_trial"]);var eo=e.object({deleted:e.boolean(),description:e.string(),icon:e.string(),id:e.string(),name:e.string()});var Va=e.object({id:e.string(),name:e.string(),version:e.number()});var fp=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",ue),value:e.string()});var qo=e.object({action:vi,actorType:e.property("actor_type",Se),addOnsAdded:e.property("add_ons_added",e.list(eo)),addOnsRemoved:e.property("add_ons_removed",e.list(eo)),apiKey:e.property("api_key",_e.optional()),auditLog:e.property("audit_log",bo.optional()),basePlan:e.property("base_plan",eo.optional()),basePlanAction:e.property("base_plan_action",Ti.optional()),basePlanVersion:e.property("base_plan_version",Va.optional()),company:Ci.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(),previousBasePlan:e.property("previous_base_plan",eo.optional()),previousBasePlanVersion:e.property("previous_base_plan_version",Va.optional()),requestId:e.property("request_id",e.string().optional()),subscriptionChangeAction:e.property("subscription_change_action",Rp.optional()),traitsUpdated:e.property("traits_updated",e.list(fp)),updatedAt:e.property("updated_at",e.date()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var _p=e.object({data:qo,params:e.record(e.string(),e.unknown())});var Ar=e.object({accountId:e.property("account_id",e.string()),createdAt:e.property("created_at",e.date()),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 Sp=e.object({data:Ar,params:e.record(e.string(),e.unknown())});var Pp=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var xp=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",Te.optional()),subscriptionStatuses:e.property("subscription_statuses",e.list(gr).optional()),subscriptionTypes:e.property("subscription_types",e.list(yr).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 Ep=e.object({data:e.list(Q),params:xp});var Cp=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 Up=e.object({data:e.list(Ui),params:Cp});var vp=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 Tp=e.object({data:e.list(Eo),params:vp});var Op=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",ue.optional()),traitTypes:e.property("trait_types",e.list(ue).optional())});var kp=e.object({data:e.list(de),params:Op});var Bp=e.object({action:vi.optional(),basePlanAction:e.property("base_plan_action",Ti.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 jp=e.object({data:e.list(qo),params:Bp});var Ap=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 Vp=e.object({data:e.list(Ar),params:Ap});var qp=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 Dp=e.object({data:e.list(Fe),params:qp});var Mp=e.object({keys:e.record(e.string(),e.string()).optional()});var Ip=e.object({data:Q,params:Mp});var Fp=e.object({keys:e.record(e.string(),e.string()).optional()});var Kp=e.object({data:Fe,params:Fp});var Lp=e.object({data:de,params:e.record(e.string(),e.unknown())});var Gp=e.object({data:e.list(Ar),params:e.record(e.string(),e.unknown())});var Wp=e.object({data:Q,params:e.record(e.string(),e.unknown())});var Hp=e.object({data:Q,params:e.record(e.string(),e.unknown())});var Np=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var $p=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var Oi=e.enum_(["billing","entitlement"]);var qa=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Oi),name:e.string()});var Do=e.enum_(["draft","live"]);var Da=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Oi.optional()),name:e.string().optional(),state:Do.optional()});var Jp=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Zp=e.object({data:V,params:Jp});var tr=e.object({ast:e.record(e.string(),e.number()).optional(),createdAt:e.property("created_at",e.date()),id:e.string(),name:e.string(),state:Do,type:Oi,updatedAt:e.property("updated_at",e.date())});var Yp=e.object({data:tr,params:e.record(e.string(),e.unknown())});var Qp=e.object({data:K,params:e.record(e.string(),e.unknown())});var Xp=e.object({data:tr,params:e.record(e.string(),e.unknown())});var eu=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var ru=e.object({data:e.list(tr),params:eu});var iu=e.object({companyId:e.property("company_id",e.string().optional()),componentId:e.property("component_id",e.string().optional())});var ro=e.object({billingScheme:e.property("billing_scheme",Xe),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:gi,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",pe.optional()),updatedAt:e.property("updated_at",e.date()),usageType:e.property("usage_type",ne)});var ou=e.object({currency:e.string(),price:H.optional()});var tu=e.object({bundleType:e.property("bundle_type",Oe),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(ou)),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:ro.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Pe,unitPrice:e.property("unit_price",ro.optional()),updatedAt:e.property("updated_at",e.date())});var au=e.enum_(["downgrade_not_permitted","feature_usage_exceeded"]);var Vr=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 Mo=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:xo.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:yi.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",Ee.optional()),resetStart:e.property("reset_start",Be.optional()),resetType:e.property("reset_type",rr),singularName:e.property("singular_name",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var ki=e.enum_(["monthly","quarterly","yearly"]);var Ma=e.object({activeVersion:e.property("active_version",ze.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Ue.optional()),billingProduct:e.property("billing_product",er.optional()),billingStrategy:e.property("billing_strategy",Me),chargeType:e.property("charge_type",Ie),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(jr)),current:e.boolean(),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Vr.optional()),description:e.string(),draftVersion:e.property("draft_version",ze.optional()),entitlements:e.list(re).optional(),features:e.list(qe),icon:ce,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(Mo)),invalidReason:e.property("invalid_reason",au.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(Br)),valid:e.boolean(),versions:e.list(ze),yearlyPrice:e.property("yearly_price",L.optional())});var qr=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var Io=e.object({badgeVisibility:e.property("badge_visibility",e.boolean()),checkout:e.boolean()});var nu=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 Fo=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 Dr=e.enum_(["expired","manual","plan_change","plan_period_reset"]);var su=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 cu=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",Ce),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:ro.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",Ee.optional()),singularName:e.property("singular_name",e.string().optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(su).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",Dr.optional())});var lu=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 pu=e.object({activeAddOns:e.property("active_add_ons",e.list(Ma)),activePlans:e.property("active_plans",e.list(Ma)),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(Xi)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(qr)),capabilities:Io.optional(),checkoutSettings:e.property("checkout_settings",nu),company:Q.optional(),component:tr.optional(),creditBundles:e.property("credit_bundles",e.list(tu)),creditGrants:e.property("credit_grants",e.list(cu)),defaultPlan:e.property("default_plan",ye.optional()),displaySettings:e.property("display_settings",Fo),featureUsage:e.property("feature_usage",xi.optional()),invoices:e.list(He),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",Oo.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",lu.optional()),subscription:Ri.optional(),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional()),upcomingInvoice:e.property("upcoming_invoice",He.optional())});var uu=e.object({data:pu,params:iu});var du=e.object({data:tr,params:e.record(e.string(),e.unknown())});var Ia=e.object({activeVersion:e.property("active_version",ze.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Ue.optional()),billingProduct:e.property("billing_product",er.optional()),billingStrategy:e.property("billing_strategy",Me),chargeType:e.property("charge_type",Ie),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(jr)),custom:e.boolean(),customPlanConfig:e.property("custom_plan_config",Vr.optional()),description:e.string(),draftVersion:e.property("draft_version",ze.optional()),entitlements:e.list(re).optional(),features:e.list(qe),icon:ce,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(Mo)),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 mu=e.object({activeAddOns:e.property("active_add_ons",e.list(Ia)),activePlans:e.property("active_plans",e.list(Ia)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(qr)),capabilities:Io.optional(),displaySettings:e.property("display_settings",Fo),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 hu=e.object({data:mu,params:e.record(e.string(),e.unknown())});var Fa=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 Ko=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 Ka=e.object({burnStrategy:e.property("burn_strategy",Er.optional()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(Ko).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",Cr.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 La=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:Ce,renewalEnabled:e.property("renewal_enabled",e.boolean().optional()),renewalPeriod:e.property("renewal_period",Be.optional())});var Lo=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 Ga=e.object({bundleName:e.property("bundle_name",e.string()),bundleType:e.property("bundle_type",Oe.optional()),creditId:e.property("credit_id",e.string()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(Lo).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:Pe.optional()});var Wa=e.object({additionalAmount:e.property("additional_amount",e.number()),expiresAt:e.property("expires_at",e.date().optional())});var Ha=e.object({burnStrategy:e.property("burn_strategy",Er.optional()),currencyPrices:e.property("currency_prices",e.list(Ko).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",Cr.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 Na=e.object({bundleName:e.property("bundle_name",e.string()),currencyPrices:e.property("currency_prices",e.list(Lo).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:Pe.optional()});var $a=e.object({reason:Dr.optional()});var Bi=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 gu=e.object({data:Bi,params:e.record(e.string(),e.unknown())});var yu=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 wu=e.object({data:V,params:yu});var bu=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var zu=e.object({data:V,params:bu});var Ru=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 fu=e.object({data:V,params:Ru});var Xr=e.enum_(["created_at","expires_at","quantity","quantity_remaining"]);var _u=e.object({companyId:e.property("company_id",e.string().optional()),dir:Te.optional(),limit:e.number().optional(),offset:e.number().optional(),order:Xr.optional()});var Su=e.object({data:V,params:_u});var Pu=e.object({bundleType:e.property("bundle_type",Oe.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:Pe.optional()});var xu=e.object({data:V,params:Pu});var wr=e.enum_(["grant","transfer","usage","zero_out"]);var Eu=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",wr.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 Cu=e.object({data:V,params:Eu});var ei=e.enum_(["daily","monthly","raw","weekly"]);var Uu=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()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),period:ei.optional(),startTime:e.property("start_time",e.string().optional())});var vu=e.object({data:V,params:Uu});var Tu=e.object({data:De,params:e.record(e.string(),e.unknown())});var Ou=e.object({data:ve,params:e.record(e.string(),e.unknown())});var ku=e.object({data:je,params:e.record(e.string(),e.unknown())});var Bu=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var ju=e.object({data:K,params:Bu});var Au=e.object({data:K,params:e.record(e.string(),e.unknown())});var Vu=e.object({data:Bi,params:e.record(e.string(),e.unknown())});var qu=e.object({data:je,params:e.record(e.string(),e.unknown())});var Du=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()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),period:ei.optional(),startTime:e.property("start_time",e.string().optional())});var Go=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 Wo=e.object({id:e.string(),logoUrl:e.property("logo_url",e.string().optional()),name:e.string()});var Ho=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string()});var Mu=e.object({billingCreditAutoTopupGrantCount:e.property("billing_credit_auto_topup_grant_count",e.number()),billingCreditId:e.property("billing_credit_id",e.string()),company:Wo.optional(),companyId:e.property("company_id",e.string()),credit:Go.optional(),expiredGrantCount:e.property("expired_grant_count",e.number()),feature:Ho.optional(),featureId:e.property("feature_id",e.string().optional()),firstTransactionAt:e.property("first_transaction_at",e.date()),freeGrantCount:e.property("free_grant_count",e.number()),grantCount:e.property("grant_count",e.number()),lastTransactionAt:e.property("last_transaction_at",e.date()),manuallyZeroedCount:e.property("manually_zeroed_count",e.number()),netChange:e.property("net_change",e.number()),planGrantCount:e.property("plan_grant_count",e.number()),purchasedGrantCount:e.property("purchased_grant_count",e.number()),timeBucket:e.property("time_bucket",e.date()),totalConsumed:e.property("total_consumed",e.number()),totalGranted:e.property("total_granted",e.number()),transactionCount:e.property("transaction_count",e.number()),usageCount:e.property("usage_count",e.number()),zeroedOutCount:e.property("zeroed_out_count",e.number())});var Iu=e.object({data:e.list(Mu),params:Du});var Fu=e.object({data:De,params:e.record(e.string(),e.unknown())});var Ku=e.object({data:ve,params:e.record(e.string(),e.unknown())});var Lu=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 Mr=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",Ce),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",Ee.optional()),sourceLabel:e.property("source_label",e.string()),transfers:e.list(Lu).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",Dr.optional())});var Gu=e.object({data:Mr,params:e.record(e.string(),e.unknown())});var Wu=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),name:e.string().optional(),offset:e.number().optional()});var Hu=e.object({data:e.list(De),params:Wu});var Nu=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 $u=e.object({data:e.list(ve),params:Nu});var Ju=e.object({companyId:e.property("company_id",e.string().optional())});var Zu=e.object({creditId:e.property("credit_id",e.string()),remaining:e.number(),source:k,total:e.number().optional()});var Yu=e.object({data:e.list(Zu),params:Ju});var Qu=e.object({companyId:e.property("company_id",e.string().optional()),dir:Te.optional(),limit:e.number().optional(),offset:e.number().optional(),order:Xr.optional()});var Xu=e.object({data:e.list(Mr),params:Qu});var ed=e.object({bundleType:e.property("bundle_type",Oe.optional()),creditId:e.property("credit_id",e.string().optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),status:Pe.optional()});var rd=e.object({data:e.list(je),params:ed});var id=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",wr.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({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:Wo.optional(),companyId:e.property("company_id",e.string()),credit:Go.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",wr),expiryType:e.property("expiry_type",Y.optional()),expiryUnit:e.property("expiry_unit",G.optional()),expiryUnitCount:e.property("expiry_unit_count",e.number().optional()),feature:Ho.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",Ce.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()),zeroedOutReason:e.property("zeroed_out_reason",Dr.optional())});var td=e.object({data:e.list(od),params:id});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 nd=e.object({data:e.list(Mr),params:ad});var sd=e.object({data:Bi,params:e.record(e.string(),e.unknown())});var cd=e.object({data:K,params:e.record(e.string(),e.unknown())});var ld=e.object({data:De,params:e.record(e.string(),e.unknown())});var pd=e.object({data:ve,params:e.record(e.string(),e.unknown())});var ud=e.object({data:je,params:e.record(e.string(),e.unknown())});var dd=e.object({data:Mr,params:e.record(e.string(),e.unknown())});var Ja=e.object({metadata:e.string()});var md=e.stringLiteral("csv");var hd=e.enum_(["failure","pending","success"]);var gd=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",gd),id:e.string(),metadata:e.string(),outputFileType:e.property("output_file_type",md),status:hd,updatedAt:e.property("updated_at",e.date())});var wd=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 Ir=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 Za=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(Ir).optional()),externalResourceId:e.property("external_resource_id",e.string()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",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",pe.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",ee),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 Ya=e.object({companyId:e.property("company_id",e.string()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",ee)});var Qa=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(Ir).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",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",pe.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",ee),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 Xa=e.object({sourcePlanId:e.property("source_plan_id",e.string()),targetPlanId:e.property("target_plan_id",e.string())});var en=e.object({creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),expirationDate:e.property("expiration_date",e.date().optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),note:e.string().optional(),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",ee)});var rn=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(Ir).optional()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),priceBehavior:e.property("price_behavior",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",pe.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",ee),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 bd=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 zd=e.object({data:V,params:bd});var Rd=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var fd=e.object({data:V,params:Rd});var _d=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 Sd=e.object({data:V,params:_d});var Pd=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var xd=e.object({data:V,params:Pd});var Ed=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 Cd=e.object({data:V,params:Ed});var Ud=e.object({data:Ve,params:e.record(e.string(),e.unknown())});var vd=e.object({data:re,params:e.record(e.string(),e.unknown())});var Td=e.object({data:K,params:e.record(e.string(),e.unknown())});var Od=e.object({data:K,params:e.record(e.string(),e.unknown())});var No=e.object({code:e.string(),description:e.string(),detail:e.string().optional(),id:e.string().optional()});var kd=e.object({message:e.string()});var Bd=e.object({entitlementId:e.property("entitlement_id",e.string()),errors:e.list(kd),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string())});var jd=e.object({data:e.list(re),issues:e.list(No),skipped:e.list(Bd)});var Ad=e.object({data:jd,params:e.record(e.string(),e.unknown())});var Vd=e.object({data:Ve,params:e.record(e.string(),e.unknown())});var qd=e.object({keys:e.record(e.string(),e.string()).optional()});var Dd=e.object({data:xi,params:qd});var $e=e.enum_(["daily","hourly","monthly","weekly"]);var Md=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:$e.optional(),startTime:e.property("start_time",e.date().optional())});var Id=e.object({effectiveAt:e.property("effective_at",e.date()),isSoftLimit:e.property("is_soft_limit",e.boolean()),limitSource:e.property("limit_source",Or),limitValue:e.property("limit_value",e.number().optional()),planId:e.property("plan_id",e.string().optional()),priceBehavior:e.property("price_behavior",be.optional())});var Fd=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 Kd=e.object({featureId:e.property("feature_id",e.string()),featureType:e.property("feature_type",se),limits:e.list(Id),periodType:e.property("period_type",e.string().optional()),usagePoints:e.property("usage_points",e.list(Fd))});var Ld=e.object({data:Kd,params:Md});var Gd=e.object({data:re,params:e.record(e.string(),e.unknown())});var Wd=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 Hd=e.object({data:e.list(Ve),params:Wd});var Nd=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var $d=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(fi).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",_i.optional())});var Jd=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",ee),company:Q.optional(),companyOverride:e.property("company_override",Ve.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(fi).optional()),creditGrantReason:e.property("credit_grant_reason",Ce.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",$d.optional()),creditUsageAggregation:e.property("credit_usage_aggregation",_i.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",Or),feature:qe.optional(),hasValidAllocation:e.property("has_valid_allocation",e.boolean().optional()),isUnlimited:e.property("is_unlimited",e.boolean().optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),monthlyUsageBasedPrice:e.property("monthly_usage_based_price",H.optional()),overuse:e.number().optional(),percentUsed:e.property("percent_used",e.number().optional()),period:W.optional(),plan:or.optional(),planEntitlement:e.property("plan_entitlement",re.optional()),priceBehavior:e.property("price_behavior",be.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 Zd=e.object({data:e.list(Jd),params:Nd});var Yd=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:e.list(Br),params:Yd});var Xd=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var ar=e.object({createdAt:e.property("created_at",e.date()),defaultValue:e.property("default_value",e.boolean()),description:e.string(),feature:Tr.optional(),featureId:e.property("feature_id",e.string().optional()),flagType:e.property("flag_type",ir),id:e.string(),key:e.string(),lastCheckedAt:e.property("last_checked_at",e.date().optional()),maintainer:Sr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),rules:e.list(Pi),updatedAt:e.property("updated_at",e.date())});var Ke=e.object({billingLinkedResource:e.property("billing_linked_resource",Ue.optional()),createdAt:e.property("created_at",e.date()),description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),eventSummary:e.property("event_summary",Si.optional()),featureType:e.property("feature_type",se),flags:e.list(ar),icon:e.string(),id:e.string(),lifecyclePhase:e.property("lifecycle_phase",Ae.optional()),maintainer:Sr.optional(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),plans:e.list(kr),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),trait:de.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var em=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",ee),company:Q.optional(),entitlementId:e.property("entitlement_id",e.string()),entitlementType:e.property("entitlement_type",Or),feature:Ke.optional(),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",N.optional()),period:W.optional(),plan:or.optional(),usage:e.number().optional(),user:Vo.optional()});var rm=e.object({data:e.list(em),params:Xd});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 om=e.object({data:e.list(re),params:im});var tm=e.object({data:Ve,params:e.record(e.string(),e.unknown())});var am=e.object({data:re,params:e.record(e.string(),e.unknown())});var nm=e.object({data:re,params:e.record(e.string(),e.unknown())});var sm=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 cm=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:cm.optional(),keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var pm=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 $o=e.undiscriminatedUnion([pm,sm,lm]);var br=e.enum_(["flag_check","identify","track"]);var Jo=e.object({backfill:e.boolean().optional(),body:$o.optional(),eventType:e.property("event_type",br),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 on=e.object({events:e.list(Jo)});var Zo=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 um=e.object({events:e.list(Zo)});var dm=e.object({data:um,params:e.record(e.string(),e.unknown())});var mm=e.object({data:Zo,params:e.record(e.string(),e.unknown())});var hm=e.enum_(["enriched","failed","pending","processed","unknown"]);var Yo=e.object({apiKey:e.property("api_key",e.string().optional()),apiKeyView:e.property("api_key_view",_e.optional()),body:e.record(e.string(),e.unknown()),bodyPreview:e.property("body_preview",e.string()),capturedAt:e.property("captured_at",e.date()),company:kr.optional(),companyId:e.property("company_id",e.string().optional()),enrichedAt:e.property("enriched_at",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),errorMessage:e.property("error_message",e.string().optional()),featureIds:e.property("feature_ids",e.list(e.string())),features:e.list(kr),id:e.string(),idempotencyKey:e.property("idempotency_key",e.string().optional()),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:hm,subtype:e.string().optional(),type:br,updatedAt:e.property("updated_at",e.date().optional()),user:kr.optional(),userId:e.property("user_id",e.string().optional())});var gm=e.object({data:Yo,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 wm=e.object({data:e.list(Si),params:ym});var bm=e.object({connected:e.boolean(),environmentId:e.property("environment_id",e.string()),lastEventAt:e.property("last_event_at",e.date().optional())});var zm=e.object({data:bm,params:e.record(e.string(),e.unknown())});var Rm=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(br).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 fm=e.object({data:e.list(Yo),params:Rm});var io=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(io)});var ji=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",ir),id:e.string().optional(),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var an=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:ji.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ae.optional()),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string(),pluralName:e.property("plural_name",e.string().optional()),singularName:e.property("singular_name",e.string().optional()),traitId:e.property("trait_id",e.string().optional())});var nn=e.object({description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",se),flag:ji.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ae.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 sn=e.object({description:e.string().optional(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",se.optional()),flag:ji.optional(),icon:e.string().optional(),lifecyclePhase:e.property("lifecycle_phase",Ae.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 Qo=e.object({comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionType:e.property("condition_type",zi),creditCost:e.property("credit_cost",e.number().optional()),creditId:e.property("credit_id",e.string().optional()),eventSubtype:e.property("event_subtype",e.string().optional()),id:e.string().optional(),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),metricValue:e.property("metric_value",e.number().optional()),operator:bi,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 _m=e.object({conditions:e.list(Qo),flagId:e.property("flag_id",e.string().optional()),id:e.string().optional()});var Sm=e.object({conditionGroups:e.property("condition_groups",e.list(_m)),conditions:e.list(Qo),id:e.string().optional(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",vr.optional()),value:e.boolean()});var cn=e.object({rules:e.list(Sm)});var Xo=e.object({companyId:e.property("company_id",e.string().optional()),entitlement:vo.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 Pm=e.object({data:Xo,params:e.record(e.string(),e.unknown())});var xm=e.enum_(["active","converted","expired"]);var Em=e.object({id:e.string(),name:e.string(),trialEndDate:e.property("trial_end_date",e.date().optional()),trialStatus:e.property("trial_status",xm.optional())});var et=e.object({flags:e.list(Xo),plan:Em.optional()});var Cm=e.object({data:e.list(et)});var Um=e.object({data:Cm,params:e.record(e.string(),e.unknown())});var vm=e.object({data:et,params:e.record(e.string(),e.unknown())});var Tm=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 Om=e.object({data:V,params:Tm});var km=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 Bm=e.object({data:V,params:km});var jm=e.object({data:Ke,params:e.record(e.string(),e.unknown())});var Am=e.object({data:ar,params:e.record(e.string(),e.unknown())});var Vm=e.object({data:K,params:e.record(e.string(),e.unknown())});var qm=e.object({data:K,params:e.record(e.string(),e.unknown())});var Dm=e.object({data:Ke,params:e.record(e.string(),e.unknown())});var Mm=e.object({data:ar,params:e.record(e.string(),e.unknown())});var Im=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 Fm=e.object({data:e.list(Ke),params:Im});var Km=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 Lm=e.object({data:e.list(ar),params:Km});var Gm=e.object({data:Ke,params:e.record(e.string(),e.unknown())});var Wm=e.object({data:ar,params:e.record(e.string(),e.unknown())});var Hm=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",ir),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 Nm=e.object({flag:Hm.optional(),rules:e.list(Pi)});var $m=e.object({data:Nm,params:e.record(e.string(),e.unknown())});var Jm=e.object({data:Ke,params:e.record(e.string(),e.unknown())});var Zm=e.object({limit:e.number().optional()});var Ym=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 Qm=e.object({entries:e.list(Ym)});var Xm=e.object({data:Qm,params:Zm});var eh=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:$e.optional(),startTime:e.property("start_time",e.date().optional())});var rt=e.object({timestamp:e.date(),usage:e.number()});var rh=e.object({eventSubtype:e.property("event_subtype",e.string()),featureId:e.property("feature_id",e.string()),points:e.list(rt)});var ih=e.object({data:rh,params:eh});var oh=e.object({endTime:e.property("end_time",e.date().optional()),featureId:e.property("feature_id",e.string().optional()),granularity:$e.optional(),startTime:e.property("start_time",e.date().optional())});var th=e.object({featureId:e.property("feature_id",e.string()),points:e.list(rt),traitDefinitionId:e.property("trait_definition_id",e.string())});var ah=e.object({data:th,params:oh});var nh=e.object({months:e.number().optional()});var sh=e.object({month:e.date(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),subscribers:e.number()});var ch=e.object({points:e.list(sh)});var lh=e.object({data:ch,params:nh});var ph=e.object({amount:e.number(),currency:e.string()});var uh=e.object({activeCredits:e.property("active_credits",e.number()),mrr:e.list(ph),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 dh=e.object({data:uh,params:e.record(e.string(),e.unknown())});var mh=e.object({endTime:e.property("end_time",e.date().optional()),limit:e.number().optional(),startTime:e.property("start_time",e.date().optional())});var hh=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 gh=e.object({features:e.list(hh)});var yh=e.object({data:gh,params:mh});var wh=e.enum_(["billing_meta_object","manual_upsert"]);var ln=e.object({companyMatchingCriteria:e.property("company_matching_criteria",wh.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),integrationId:e.property("integration_id",e.string())});var bh=e.object({type:ke,url:e.string()});var zh=e.object({data:bh,params:e.record(e.string(),e.unknown())});var Rh=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:ke.optional()});var fh=e.object({authorPlans:e.property("author_plans",e.boolean()),checkout:e.boolean(),editBilling:e.property("edit_billing",e.boolean())});var _h=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Sh=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var Ph=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 xh=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var Eh=e.union("type",{clerk:_h,orb:Sh,stripe:Ph,workos:xh}).transform({transform:p=>p,untransform:p=>p});var Ch=e.object({capabilities:fh,config:Eh.optional(),id:e.string(),isAppInstall:e.property("is_app_install",e.boolean()),isConnectInstall:e.property("is_connect_install",e.boolean()),state:Qe,type:ke});var Uh=e.object({data:e.list(Ch),params:Rh});var vh=e.object({keys:e.list(e.string())});var Th=e.object({data:vh,params:e.record(e.string(),e.unknown())});var it=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:Qe,type:ke,updatedAt:e.property("updated_at",e.date())});var Oh=e.object({data:it,params:e.record(e.string(),e.unknown())});var kh=e.object({data:it,params:e.record(e.string(),e.unknown())});var Bh=e.object({data:K,params:e.record(e.string(),e.unknown())});var jh=e.object({companyId:e.property("company_id",e.string()),description:e.string(),icon:ce.optional(),name:e.string()});var Ah=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(Ir).optional()),featureId:e.property("feature_id",e.string()),metricPeriod:e.property("metric_period",W.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",N.optional()),monthlyMeteredPriceId:e.property("monthly_metered_price_id",e.string().optional()),monthlyPriceTiers:e.property("monthly_price_tiers",e.list(ae).optional()),monthlyUnitPrice:e.property("monthly_unit_price",e.number().optional()),monthlyUnitPriceDecimal:e.property("monthly_unit_price_decimal",e.string().optional()),overageBillingProductId:e.property("overage_billing_product_id",e.string().optional()),planId:e.property("plan_id",e.string()),planVersionId:e.property("plan_version_id",e.string().optional()),priceBehavior:e.property("price_behavior",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",pe.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",ee),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 ot=e.enum_(["create","update","delete"]);var Ai=e.object({action:ot,entitlementId:e.property("entitlement_id",e.string().optional()),req:Ah.optional()});var Vh=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 Fr=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingStrategy:e.property("billing_strategy",Me.optional()),chargeType:e.property("charge_type",Ie),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(Vh).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 pn=e.object({billingProduct:e.property("billing_product",Fr.optional()),entitlements:e.list(Ai),plan:jh.optional()});var tt=e.object({description:e.string(),icon:ce.optional(),name:e.string(),planType:e.property("plan_type",oe)});var at=e.stringLiteral("credit");var nt=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",at.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",Ee),resetStart:e.property("reset_start",Be),resetType:e.property("reset_type",rr.optional())});var qh=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",at.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",Ee),resetStart:e.property("reset_start",Be),resetType:e.property("reset_type",rr.optional())});var ct=e.object({action:ot,createReq:e.property("create_req",nt.optional()),creditGrantId:e.property("credit_grant_id",e.string().optional()),deleteReq:e.property("delete_req",qh.optional()),updateReq:e.property("update_req",st.optional())});var un=e.object({billingProduct:e.property("billing_product",Fr.optional()),creditGrants:e.property("credit_grants",e.list(ct).optional()),entitlements:e.list(Ai),plan:tt.optional(),traits:e.list(Ei).optional()});var lt=e.object({description:e.string().optional(),icon:ce.optional(),name:e.string()});var dn=e.object({billingProduct:e.property("billing_product",Fr.optional()),creditGrants:e.property("credit_grants",e.list(ct).optional()),entitlements:e.list(Ai),plan:lt.optional(),planVersionId:e.property("plan_version_id",e.string().optional()),traits:e.list(Ei).optional()});var pt=e.object({accountId:e.property("account_id",e.string()),billingProductId:e.property("billing_product_id",e.string()),billingStrategy:e.property("billing_strategy",Me),chargeType:e.property("charge_type",Ie),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 Vi=e.object({billingProduct:e.property("billing_product",pt.optional()),creditGrants:e.property("credit_grants",e.list(ve).optional()),entitlements:e.list(re).optional(),plan:or.optional(),traits:e.list(Ar).optional()});var Dh=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var Mh=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var Ih=e.object({data:Vi,params:e.record(e.string(),e.unknown())});var Fh=e.object({entitlementId:e.property("entitlement_id",e.string()),visible:e.boolean().optional()});var zr=e.object({entitlements:e.list(Fh).optional(),planId:e.property("plan_id",e.string())});var qi=e.object({bundleId:e.string()});var ut=e.enum_(["create_prorations","invoice_immediately"]);var dt=e.enum_(["end_of_billing_period","none"]);var mn=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(qr).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()),customPlanConfig:e.property("custom_plan_config",Vr.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()),orderedAddOns:e.property("ordered_add_ons",e.list(zr)),orderedBundleList:e.property("ordered_bundle_list",e.list(qi)),orderedPlans:e.property("ordered_plans",e.list(zr)),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",dt.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 hn=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(qr).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()),customPlanConfig:e.property("custom_plan_config",Vr.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()),orderedAddOns:e.property("ordered_add_ons",e.list(zr)),orderedBundleList:e.property("ordered_bundle_list",e.list(qi)),orderedPlans:e.property("ordered_plans",e.list(zr)),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",dt.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 mt=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean())});var Kh=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var ht=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 gt=e.object({addOnCompatibilities:e.property("add_on_compatibilities",e.list(Kh)),addOnIds:e.property("add_on_ids",e.list(e.string())),checkoutSettings:e.property("checkout_settings",mt),componentSettings:e.property("component_settings",ht),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(zr)),planIds:e.property("plan_ids",e.list(zr)),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 Lh=e.object({data:gt,params:e.record(e.string(),e.unknown())});var Gh=e.object({includeCompanyCounts:e.property("include_company_counts",e.boolean().optional())});var yt=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 ri=e.object({activeVersion:e.property("active_version",ze.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(ki)),billingLinkedResource:e.property("billing_linked_resource",Ue.optional()),billingProduct:e.property("billing_product",er.optional()),billingStrategy:e.property("billing_strategy",Me),chargeType:e.property("charge_type",Ie),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(jr)),customPlanConfig:e.property("custom_plan_config",yt.optional()),description:e.string(),draftVersion:e.property("draft_version",ze.optional()),entitlements:e.list(re).optional(),features:e.list(qe),icon:ce,id:e.string(),includedCreditGrants:e.property("included_credit_grants",e.list(ve).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 Wh=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var gn=e.object({entitlements:e.list(Wh).optional(),planId:e.property("plan_id",e.string())});var Hh=e.object({addOns:e.property("add_ons",e.list(ri)),checkoutSettings:e.property("checkout_settings",mt),componentSettings:e.property("component_settings",ht),customPlanConfig:e.property("custom_plan_config",yt.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),defaultPlan:e.property("default_plan",ri.optional()),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlan:e.property("fallback_plan",ri.optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlan:e.property("initial_plan",ri.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(gn)),orderedBundleList:e.property("ordered_bundle_list",e.list(qi)),orderedPlanList:e.property("ordered_plan_list",e.list(gn)),plans:e.list(ri),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",ri.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 Nh=e.object({data:Hh,params:Gh});var $h=e.object({data:gt,params:e.record(e.string(),e.unknown())});var Di=e.enum_(["immediate","leave"]);var yn=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:Di,targetPlanType:e.property("target_plan_type",oe)});var wt=e.enum_(["ambiguous_subscription_item","multiple_subscriptions","no_price_for_interval","not_on_origin_version","permanent_config","permanent_decline","transient_decline","transient_infra","transient_stripe","unknown","would_leave_empty_subscription"]);var wn=e.object({errorCodes:e.property("error_codes",e.list(wt))});var Rr=e.enum_(["completed","failed","in_progress","pending","skipped"]);var Jh=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Rr.optional()});var Zh=e.object({data:V,params:Jh});var fr=e.enum_(["completed","failed","in_progress","pending"]);var Yh=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:fr.optional()});var Qh=e.object({data:V,params:Yh});var Kr=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:fr,strategy:Di,totalCompanies:e.property("total_companies",e.number()),updatedAt:e.property("updated_at",e.date())});var Xh=e.object({data:Kr,params:e.record(e.string(),e.unknown())});var eg=e.object({data:Kr,params:e.record(e.string(),e.unknown())});var rg=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Rr.optional()});var bt=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",wt.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:Rr,updatedAt:e.property("updated_at",e.date())});var ig=e.object({data:e.list(bt),params:rg});var og=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:fr.optional()});var tg=e.object({data:e.list(Kr),params:og});var ag=e.object({data:bt,params:e.record(e.string(),e.unknown())});var ng=e.object({data:Kr,params:e.record(e.string(),e.unknown())});var bn=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 zn=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 Lr=e.object({priceId:e.property("price_id",e.string()),quantity:e.number()});var Rn=e.object({activationStrategy:e.property("activation_strategy",wi.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",Di),payInAdvance:e.property("pay_in_advance",e.list(Lr))});var fn=e.object({activationStrategy:e.property("activation_strategy",wi.optional()),customerEmail:e.property("customer_email",e.string()),daysUntilDue:e.property("days_until_due",e.number().optional()),payInAdvance:e.property("pay_in_advance",e.list(Lr))});var _n=e.object({addOnIds:e.property("add_on_ids",e.list(e.string())),basePlanId:e.property("base_plan_id",e.string().optional())});var sg=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var cg=e.object({data:V,params:sg});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 pg=e.object({data:V,params:lg});var ug=e.object({data:ye,params:e.record(e.string(),e.unknown())});var dg=e.object({data:ye,params:e.record(e.string(),e.unknown())});var mg=e.object({data:K,params:e.record(e.string(),e.unknown())});var hg=e.object({promoteArchivedVersion:e.property("promote_archived_version",e.boolean().optional())});var gg=e.object({data:K,params:hg});var yg=e.object({planVersionId:e.property("plan_version_id",e.string().optional())});var wg=e.object({data:ye,params:yg});var bg=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var zg=e.object({data:e.list(Q),params:bg});var Rg=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:hr.optional(),statuses:e.list(hr).optional()});var fg=e.object({data:e.list(Ur),params:Rg});var _g=e.object({planId:e.property("plan_id",e.string().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var Sg=e.object({data:e.list(No),params:_g});var Pg=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 xg=e.object({data:e.list(ye),params:Pg});var Eg=e.object({data:Ur,params:e.record(e.string(),e.unknown())});var Cg=e.object({data:ze,params:e.record(e.string(),e.unknown())});var Ug=e.object({data:Ur,params:e.record(e.string(),e.unknown())});var vg=e.object({data:Q,params:e.record(e.string(),e.unknown())});var Tg=e.object({data:ye,params:e.record(e.string(),e.unknown())});var Og=e.object({data:pt,params:e.record(e.string(),e.unknown())});var kg=e.object({data:ye,params:e.record(e.string(),e.unknown())});var Sn=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 Gr=e.enum_(["cancelled","error","executing","pending","success"]);var Pn=e.object({executeAfter:e.property("execute_after",e.date().optional()),status:Gr.optional()});var Wr=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:Gr,toPlanId:e.property("to_plan_id",e.string()),updatedAt:e.property("updated_at",e.date())});var Bg=e.object({data:Wr,params:e.record(e.string(),e.unknown())});var jg=e.object({data:Wr,params:e.record(e.string(),e.unknown())});var Ag=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),status:Gr.optional()});var Vg=e.object({data:e.list(Wr),params:Ag});var qg=e.object({data:Wr,params:e.record(e.string(),e.unknown())});var Mi=e.object({creditId:e.property("credit_id",e.string())});var Ii=e.object({featureId:e.property("feature_id",e.string())});var Hr=e.enum_(["subscription.trial.ended","company.created","company.deleted","company.override.created","company.override.deleted","company.override.expired","company.override.updated","company.plan_changed","company.scheduled_downgrade","company.updated","credit.limit.reached","credit.limit.warning","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 xn=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Mi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Ii).optional()),name:e.string(),requestTypes:e.property("request_types",e.list(Hr)),url:e.string()});var zt=e.enum_(["active","inactive"]);var En=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Mi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Ii).optional()),name:e.string().optional(),requestTypes:e.property("request_types",e.list(Hr).optional()),status:zt.optional(),url:e.string().optional()});var Dg=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 Mg=e.object({data:V,params:Dg});var Ig=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Fg=e.object({data:V,params:Ig});var nr=e.object({createdAt:e.property("created_at",e.date()),creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Mi).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Ii).optional()),id:e.string(),name:e.string(),requestTypes:e.property("request_types",e.list(Hr)),secret:e.string(),status:zt,updatedAt:e.property("updated_at",e.date()),url:e.string()});var Kg=e.object({data:nr,params:e.record(e.string(),e.unknown())});var Lg=e.object({data:K,params:e.record(e.string(),e.unknown())});var Gg=e.enum_(["failure","pending","success"]);var Rt=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),payload:e.string().optional(),requestType:e.property("request_type",Hr),responseCode:e.property("response_code",e.number().optional()),sentAt:e.property("sent_at",e.date().optional()),status:Gg,updatedAt:e.property("updated_at",e.date()),webhook:nr.optional(),webhookId:e.property("webhook_id",e.string())});var Wg=e.object({data:Rt,params:e.record(e.string(),e.unknown())});var Hg=e.object({data:nr,params:e.record(e.string(),e.unknown())});var Ng=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 $g=e.object({data:e.list(Rt),params:Ng});var Jg=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Zg=e.object({data:e.list(nr),params:Jg});var Yg=e.object({data:nr,params:e.record(e.string(),e.unknown())});var a=e.object({error:e.string()});var Qg=e.object({addOnId:e.property("add_on_id",e.string()),priceId:e.property("price_id",e.string())});var Xg=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 ft=e.object({bundleId:e.property("bundle_id",e.string()),quantity:e.number()});var Cn=e.object({addOnIds:e.property("add_on_ids",e.list(Qg)),autoTopupOverrides:e.property("auto_topup_overrides",e.list(Xg)),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(ft)),newPlanId:e.property("new_plan_id",e.string()),newPriceId:e.property("new_price_id",e.string()),payInAdvance:e.property("pay_in_advance",e.list(Lr)),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 Un=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",ir),key:e.string(),maintainerAccountMemberId:e.property("maintainer_account_member_id",e.string().optional()),name:e.string()});var vn=e.object({keys:e.record(e.string(),e.string())});var ey=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 Tn=e.object({addOnSelections:e.property("add_on_selections",e.list(ey)),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(ft)),payInAdvanceEntitlements:e.property("pay_in_advance_entitlements",e.list(Lr)),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 ry=e.record(e.string(),e.unknown());var iy=e.record(e.string(),e.unknown());var On=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 kn=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 Bn=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 _t=class{constructor(o){this._options=I(o)}issueTemporaryAccessToken(o,i){return S.fromPromise(this.__issueTemporaryAccessToken(o,i))}async __issueTemporaryAccessToken(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"temporary-access-tokens"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:{...ha.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:ac.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 St=class{constructor(o){this._options=I(o)}listAccountMembers(o={},i){return S.fromPromise(this.__listAccountMembers(o,i))}async __listAccountMembers(o={},i){let{ids:t,q:s,limit:r,offset:n}=o,d={ids:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"account-members"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Ec.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getAccountMember(o,i))}async __getAccountMember(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`account-members/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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}")}listApiKeys(o,i){return S.fromPromise(this.__listApiKeys(o,i))}async __listApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:n}=o,d={environment_id:t,require_environment:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"api-keys"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Uc.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createApiKey(o,i))}async __createApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"api-keys"),method:"POST",headers:s,contentType:"application/json",queryString:u.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:uc.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getApiKey(o,i))}async __getApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`api-keys/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateApiKey(o,i,t))}async __updateApiKey(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`api-keys/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:wa.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:Ac.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteApiKey(o,i))}async __deleteApiKey(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`api-keys/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hc.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countApiKeys(o,i))}async __countApiKeys(o,i){let{environmentId:t,requireEnvironment:s,limit:r,offset:n}=o,d={environment_id:t,require_environment:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"api-keys/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:sc.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listAuditLogs(o,i))}async __listAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:n,startTime:d,limit:g,offset:h}=o,l={actor_type:t!=null?Se.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:n,start_time:d?.toISOString(),limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=P(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"audit-log"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Tc.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 T(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new z(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new f(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getAuditLog(o,i))}async __getAuditLog(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`audit-log/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countAuditLogs(o,i))}async __countAuditLogs(o={},i){let{actorType:t,endTime:s,environmentId:r,q:n,startTime:d,limit:g,offset:h}=o,l={actor_type:t!=null?Se.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,end_time:s?.toISOString(),environment_id:r,q:n,start_time:d?.toISOString(),limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=P(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"audit-log/count"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:lc.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 T(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new z(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new f(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listEnvironments(o,i))}async __listEnvironments(o={},i){let{ids:t,limit:s,offset:r}=o,n={ids:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),g=P(d.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"environments"),method:"GET",headers:g,queryString:u.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:kc.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 T(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new z(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new f(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createEnvironment(o,i))}async __createEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"environments"),method:"POST",headers:s,contentType:"application/json",queryString:u.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:mc.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getEnvironment(o,i))}async __getEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`environments/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_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 _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateEnvironment(o,i,t))}async __updateEnvironment(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`environments/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ba.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:Vc.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteEnvironment(o,i))}async __deleteEnvironment(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`environments/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__quickstart(o))}async __quickstart(o){let i=await this._options.authProvider.getAuthRequest(),t=P(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"quickstart"),method:"POST",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:jc.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 T(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 401:throw new _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new z(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new f(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getWhoAmI(o))}async __getWhoAmI(o){let i=await this._options.authProvider.getAuthRequest(),t=P(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"whoami"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Pc.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 _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new z(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new f(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new R(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 Pt=class{constructor(o){this._options=I(o)}listCoupons(o={},i){return S.fromPromise(this.__listCoupons(o,i))}async __listCoupons(o={},i){let{isActive:t,q:s,limit:r,offset:n}=o,d={is_active:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/coupons"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:el.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertBillingCoupon(o,i))}async __upsertBillingCoupon(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/coupons"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Sa.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:ul.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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")}upsertBillingCustomer(o,i){return S.fromPromise(this.__upsertBillingCustomer(o,i))}async __upsertBillingCustomer(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/customer/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.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:ml.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listCustomersWithSubscriptions(o,i))}async __listCustomersWithSubscriptions(o={},i){let{companyIds:t,name:s,providerType:r,q:n,limit:d,offset:g}=o,h={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:n,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/customers"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:tl.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countCustomers(o,i))}async __countCustomers(o={},i){let{companyIds:t,name:s,providerType:r,q:n,limit:d,offset:g}=o,h={company_ids:t,name:s,provider_type:r!=null?k.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,q:n,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/customers/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Lc.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listInvoices(o,i))}async __listInvoices(o,i){let{companyId:t,customerExternalId:s,subscriptionExternalId:r,limit:n,offset:d}=o,g={company_id:t,customer_external_id:s,subscription_external_id:r,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/invoices"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:nl.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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertInvoice(o,i))}async __upsertInvoice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/invoices"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Pa.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:zl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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")}listMeters(o={},i){return S.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},d=await this._options.authProvider.getAuthRequest(),g=P(d.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/meter"),method:"GET",headers:g,queryString:u.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: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 T(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new z(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new f(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertBillingMeter(o,i))}async __upsertBillingMeter(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/meter/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listPaymentMethods(o,i))}async __listPaymentMethods(o,i){let{companyId:t,customerExternalId:s,limit:r,offset:n}=o,d={company_id:t,customer_external_id:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/payment-methods"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:pl.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertPaymentMethod(o,i))}async __upsertPaymentMethod(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/payment-methods"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ea.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deletePaymentMethodByExternalId(o,i))}async __deletePaymentMethodByExternalId(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/payment-methods/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listBillingPrices(o,i))}async __listBillingPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:n,interval:d,isActive:g,price:h,productId:l,productIds:y,providerType:w,q:U,tiersMode:v,usageType:O,withMeter:B,limit:j,offset:$}=o,A={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:n,interval:d,is_active:g,price:h,product_id:l,product_ids:y,provider_type:w!=null?k.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,tiers_mode:v!=null?pe.jsonOrThrow(v,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:O!=null?ne.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:B,limit:j,offset:$},le=await this._options.authProvider.getAuthRequest(),Le=P(le.headers,this._options?.headers,i?.headers),q=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/price"),method:"GET",headers:Le,queryString:u.queryBuilder().addMany(A).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(q.ok)return{data:$c.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 T(a.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 401:throw new _(a.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 403:throw new z(a.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 404:throw new f(a.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 500:throw new R(a.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(o,i){return S.fromPromise(this.__upsertBillingPrice(o,i))}async __upsertBillingPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/price/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ra.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteBillingProduct(o,i))}async __deleteBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/product/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listBillingProductPrices(o,i))}async __listBillingProductPrices(o={},i){let{currency:t,forInitialPlan:s,forTrialExpiryPlan:r,ids:n,interval:d,isActive:g,price:h,productId:l,productIds:y,providerType:w,q:U,tiersMode:v,usageType:O,withMeter:B,limit:j,offset:$}=o,A={currency:t,for_initial_plan:s,for_trial_expiry_plan:r,ids:n,interval:d,is_active:g,price:h,product_id:l,product_ids:y,provider_type:w!=null?k.jsonOrThrow(w,{unrecognizedObjectKeys:"strip"}):void 0,q:U,tiers_mode:v!=null?pe.jsonOrThrow(v,{unrecognizedObjectKeys:"strip"}):void 0,usage_type:O!=null?ne.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_meter:B,limit:j,offset:$},le=await this._options.authProvider.getAuthRequest(),Le=P(le.headers,this._options?.headers,i?.headers),q=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/product/prices"),method:"GET",headers:Le,queryString:u.queryBuilder().addMany(A).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(q.ok)return{data:Zc.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 T(a.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 401:throw new _(a.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 403:throw new z(a.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 404:throw new f(a.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 500:throw new R(a.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(o,i){return S.fromPromise(this.__deleteProductPrice(o,i))}async __deleteProductPrice(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/product/prices/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hc.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertBillingProduct(o,i))}async __upsertBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/product/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:fa.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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listBillingProducts(o,i))}async __listBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:n,providerType:d,q:g,recurringChargesOnly:h,withOneTimeCharges:l,withPricesOnly:y,withZeroPrice:w,withoutLinkedToPlan:U,limit:v,offset:O}=o,B={ids:t,is_active:s,name:r,price_usage_type:n!=null?ne.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:d!=null?k.jsonOrThrow(d,{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:v,offset:O},j=await this._options.authProvider.getAuthRequest(),$=P(j.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/products"),method:"GET",headers:$,queryString:u.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:Qc.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 T(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new _(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new z(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new f(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new R(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","/billing/products")}countBillingProducts(o={},i){return S.fromPromise(this.__countBillingProducts(o,i))}async __countBillingProducts(o={},i){let{ids:t,isActive:s,name:r,priceUsageType:n,providerType:d,q:g,recurringChargesOnly:h,withOneTimeCharges:l,withPricesOnly:y,withZeroPrice:w,withoutLinkedToPlan:U,limit:v,offset:O}=o,B={ids:t,is_active:s,name:r,price_usage_type:n!=null?ne.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,provider_type:d!=null?k.jsonOrThrow(d,{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:v,offset:O},j=await this._options.authProvider.getAuthRequest(),$=P(j.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/products/count"),method:"GET",headers:$,queryString:u.queryBuilder().addMany(B).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(A.ok)return{data:Fc.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 T(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new _(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new z(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new f(a.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new R(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","/billing/products/count")}upsertBillingSubscription(o,i){return S.fromPromise(this.__upsertBillingSubscription(o,i))}async __upsertBillingSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/subscription/upsert"),method:"POST",headers:s,contentType:"application/json",queryString:u.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:bl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 xt=class{constructor(o){this._options=I(o)}internal(o,i){return S.fromPromise(this.__internal(o,i))}async __internal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"checkout-internal"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Cn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:vl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getCheckoutData(o,i))}async __getCheckoutData(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"checkout-internal/data"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ua.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:Ml.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__previewCheckoutInternal(o,i))}async __previewCheckoutInternal(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"checkout-internal/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Cn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__managePlan(o,i))}async __managePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"manage-plan"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Tn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Il.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__previewManagePlan(o,i))}async __previewManagePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"manage-plan/preview"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Tn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__cancelSubscription(o,i))}async __cancelSubscription(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"manage-plan/subscription/cancel"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ca.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:Cl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateCustomerSubscriptionTrialEnd(o,i,t))}async __updateCustomerSubscriptionTrialEnd(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`subscription/${u.encodePathParam(o)}/edit-trial-end`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:va.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:Hl.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 Et=class{constructor(o){this._options=I(o)}listCompanies(o={},i){return S.fromPromise(this.__listCompanies(o,i))}async __listCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:n,planId:d,planIds:g,planVersionId:h,planVersionIds:l,q:y,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:v,subscriptionTypes:O,withEntitlementFor:B,withoutFeatureOverrideFor:j,withoutPlan:$,withoutSubscription:A,withSubscription:le,limit:Le,offset:q}=o,M={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:n,plan_id:d,plan_ids:g,plan_version_id:h,plan_version_ids:l,q:y,sort_order_column:w,sort_order_direction:U!=null?Te.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(v)?v.map($r=>gr.jsonOrThrow($r,{unrecognizedObjectKeys:"strip"})):v!=null?gr.jsonOrThrow(v,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map($r=>yr.jsonOrThrow($r,{unrecognizedObjectKeys:"strip"})):O!=null?yr.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:B,without_feature_override_for:j,without_plan:$,without_subscription:A,with_subscription:le,limit:Le,offset:q},Jt=await this._options.authProvider.getAuthRequest(),Zt=P(Jt.headers,this._options?.headers,i?.headers),F=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"companies"),method:"GET",headers:Zt,queryString:u.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:Ep.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 T(a.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 401:throw new _(a.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 403:throw new z(a.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 404:throw new f(a.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 500:throw new R(a.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(o,i){return S.fromPromise(this.__upsertCompany(o,i))}async __upsertCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"companies"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getCompany(o,i))}async __getCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`companies/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:mp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteCompany(o,i,t))}async __deleteCompany(o,i={},t){let{cancelSubscription:s,prorate:r}=i,n={cancel_subscription:s,prorate:r},d=await this._options.authProvider.getAuthRequest(),g=P(d.headers,this._options?.headers,t?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`companies/${u.encodePathParam(o)}`),method:"DELETE",headers:g,queryString:u.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:cp.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 T(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new z(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new f(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countCompanies(o,i))}async __countCompanies(o={},i){let{creditTypeIds:t,hasScheduledDowngrade:s,ids:r,monetizedSubscriptions:n,planId:d,planIds:g,planVersionId:h,planVersionIds:l,q:y,sortOrderColumn:w,sortOrderDirection:U,subscriptionStatuses:v,subscriptionTypes:O,withEntitlementFor:B,withoutFeatureOverrideFor:j,withoutPlan:$,withoutSubscription:A,withSubscription:le,limit:Le,offset:q}=o,M={credit_type_ids:t,has_scheduled_downgrade:s,ids:r,monetized_subscriptions:n,plan_id:d,plan_ids:g,plan_version_id:h,plan_version_ids:l,q:y,sort_order_column:w,sort_order_direction:U!=null?Te.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"}):void 0,subscription_statuses:Array.isArray(v)?v.map($r=>gr.jsonOrThrow($r,{unrecognizedObjectKeys:"strip"})):v!=null?gr.jsonOrThrow(v,{unrecognizedObjectKeys:"strip"}):void 0,subscription_types:Array.isArray(O)?O.map($r=>yr.jsonOrThrow($r,{unrecognizedObjectKeys:"strip"})):O!=null?yr.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"}):void 0,with_entitlement_for:B,without_feature_override_for:j,without_plan:$,without_subscription:A,with_subscription:le,limit:Le,offset:q},Jt=await this._options.authProvider.getAuthRequest(),Zt=P(Jt.headers,this._options?.headers,i?.headers),F=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"companies/count"),method:"GET",headers:Zt,queryString:u.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:$l.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 T(a.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 401:throw new _(a.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 403:throw new z(a.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 404:throw new f(a.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 500:throw new R(a.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(o,i){return S.fromPromise(this.__createCompany(o,i))}async __createCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"companies/create"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteCompanyByKeys(o,i))}async __deleteCompanyByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"companies/delete"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:vn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__lookupCompany(o,i))}async __lookupCompany(o,i){let{keys:t}=o,s={keys:xe(t)},r=await this._options.authProvider.getAuthRequest(),n=P(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"companies/lookup"),method:"GET",headers:n,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Ip.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new _(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new z(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new f(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new R(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/companies/lookup")}listCompanyMemberships(o={},i){return S.fromPromise(this.__listCompanyMemberships(o,i))}async __listCompanyMemberships(o={},i){let{companyId:t,userId:s,limit:r,offset:n}=o,d={company_id:t,user_id:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"company-memberships"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Up.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getOrCreateCompanyMembership(o,i))}async __getOrCreateCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"company-memberships"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ba.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:bp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteCompanyMembership(o,i))}async __deleteCompanyMembership(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`company-memberships/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getActiveCompanySubscription(o,i))}async __getActiveCompanySubscription(o={},i){let{companyId:t,companyIds:s,limit:r,offset:n}=o,d={company_id:t,company_ids:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"company-subscriptions"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:dp.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertCompanyTrait(o,i))}async __upsertCompanyTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"company-traits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:kn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Hp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listEntityKeyDefinitions(o,i))}async __listEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:n,offset:d}=o,g={entity_type:t!=null?ie.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"entity-key-definitions"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Tp.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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countEntityKeyDefinitions(o,i))}async __countEntityKeyDefinitions(o={},i){let{entityType:t,ids:s,q:r,limit:n,offset:d}=o,g={entity_type:t!=null?ie.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,ids:s,q:r,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"entity-key-definitions/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Zl.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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listEntityTraitDefinitions(o,i))}async __listEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:n,traitTypes:d,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?ue.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(d)?d.map(v=>ue.jsonOrThrow(v,{unrecognizedObjectKeys:"strip"})):d!=null?ue.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=P(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"entity-trait-definitions"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:kp.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 T(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new z(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new f(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getOrCreateEntityTraitDefinition(o,i))}async __getOrCreateEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"entity-trait-definitions"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ka.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:zp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getEntityTraitDefinition(o,i))}async __getEntityTraitDefinition(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`entity-trait-definitions/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:hp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateEntityTraitDefinition(o,i,t))}async __updateEntityTraitDefinition(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`entity-trait-definitions/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ja.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:Lp.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countEntityTraitDefinitions(o,i))}async __countEntityTraitDefinitions(o={},i){let{entityType:t,ids:s,q:r,traitType:n,traitTypes:d,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?ue.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(d)?d.map(v=>ue.jsonOrThrow(v,{unrecognizedObjectKeys:"strip"})):d!=null?ue.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=P(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"entity-trait-definitions/count"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Ql.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 T(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new z(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new f(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getEntityTraitValues(o,i))}async __getEntityTraitValues(o,i){let{definitionId:t,q:s,limit:r,offset:n}=o,d={definition_id:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"entity-trait-values"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:wp.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listPlanChanges(o,i))}async __listPlanChanges(o={},i){let{action:t,basePlanAction:s,companyId:r,companyIds:n,planIds:d,limit:g,offset:h}=o,l={action:t!=null?vi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}):void 0,base_plan_action:s!=null?Ti.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,company_id:r,company_ids:n,plan_ids:d,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=P(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-changes"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:jp.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 T(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new z(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new f(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getPlanChange(o,i))}async __getPlanChange(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-changes/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:_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 _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listPlanTraits(o,i))}async __listPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:n,limit:d,offset:g}=o,h={ids:t,plan_id:s,trait_id:r,trait_ids:n,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-traits"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Vp.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getPlanTrait(o,i))}async __getPlanTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-traits/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Sp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updatePlanTraitsBulk(o,i))}async __updatePlanTraitsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-traits/bulk"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Aa.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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countPlanTraits(o,i))}async __countPlanTraits(o={},i){let{ids:t,planId:s,traitId:r,traitIds:n,limit:d,offset:g}=o,h={ids:t,plan_id:s,trait_id:r,trait_ids:n,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-traits/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:ep.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertUserTrait(o,i))}async __upsertUserTrait(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"user-traits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:kn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:$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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listUsers(o,i))}async __listUsers(o={},i){let{companyId:t,ids:s,planId:r,q:n,limit:d,offset:g}=o,h={company_id:t,ids:s,plan_id:r,q:n,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"users"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:Dp.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertUser(o,i))}async __upsertUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"users"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Bn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getUser(o,i))}async __getUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`users/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteUser(o,i))}async __deleteUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`users/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countUsers(o,i))}async __countUsers(o={},i){let{companyId:t,ids:s,planId:r,q:n,limit:d,offset:g}=o,h={company_id:t,ids:s,plan_id:r,q:n,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"users/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:ip.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createUser(o,i))}async __createUser(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"users/create"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Bn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:tp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteUserByKeys(o,i))}async __deleteUserByKeys(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"users/delete"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:vn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:lp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__lookupUser(o,i))}async __lookupUser(o,i){let{keys:t}=o,s={keys:xe(t)},r=await this._options.authProvider.getAuthRequest(),n=P(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"users/lookup"),method:"GET",headers:n,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Kp.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new _(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new z(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new f(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new R(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/users/lookup")}};var Ct=class{constructor(o){this._options=I(o)}listComponents(o={},i){return S.fromPromise(this.__listComponents(o,i))}async __listComponents(o={},i){let{q:t,limit:s,offset:r}=o,n={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),g=P(d.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"components"),method:"GET",headers:g,queryString:u.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:ru.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 T(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new z(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new f(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createComponent(o,i))}async __createComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"components"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:qa.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getComponent(o,i))}async __getComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`components/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Xp.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateComponent(o,i,t))}async __updateComponent(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`components/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Da.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:du.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteComponent(o,i))}async __deleteComponent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`components/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countComponents(o,i))}async __countComponents(o={},i){let{q:t,limit:s,offset:r}=o,n={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),g=P(d.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"components/count"),method:"GET",headers:g,queryString:u.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:Zp.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 T(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new z(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new f(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new R(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 S.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(),d=P(n.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"components/preview-data"),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:uu.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 _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new z(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new f(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new R(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 Ut=class{constructor(o){this._options=I(o)}getPublicPlans(o){return S.fromPromise(this.__getPublicPlans(o))}async __getPublicPlans(o){let i=await this._options.authProvider.getAuthRequest(),t=P(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"public/plans"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:hu.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 _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new z(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new f(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new R(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 vt=class{constructor(o){this._options=I(o)}listBillingCredits(o={},i){return S.fromPromise(this.__listBillingCredits(o,i))}async __listBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:n}=o,d={ids:t,name:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Hu.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createBillingCredit(o,i))}async __createBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Ka.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: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 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getSingleBillingCredit(o,i))}async __getSingleBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Fu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateBillingCredit(o,i,t))}async __updateBillingCredit(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Ha.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__softDeleteBillingCredit(o,i))}async __softDeleteBillingCredit(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:cd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listCompanyCreditBalances(o,i))}async __listCompanyCreditBalances(o,i){let{companyId:t}=o,s={company_id:t},r=await this._options.authProvider.getAuthRequest(),n=P(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/balance"),method:"GET",headers:n,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Yu.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new T(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new _(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new z(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new f(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new R(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/billing/credits/balance")}listCreditBundles(o={},i){return S.fromPromise(this.__listCreditBundles(o,i))}async __listCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:n,limit:d,offset:g}=o,h={ids:t,credit_id:s,status:r!=null?Pe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:n!=null?Oe.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/bundles"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:rd.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createCreditBundle(o,i))}async __createCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getCreditBundle(o,i))}async __getCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateCreditBundleDetails(o,i,t))}async __updateCreditBundleDetails(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Na.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:ud.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteCreditBundle(o,i))}async __deleteCreditBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/bundles/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Au.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countCreditBundles(o,i))}async __countCreditBundles(o={},i){let{ids:t,creditId:s,status:r,bundleType:n,limit:d,offset:g}=o,h={ids:t,credit_id:s,status:r!=null?Pe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,bundle_type:n!=null?Oe.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/bundles/count"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:xu.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countBillingCredits(o,i))}async __countBillingCredits(o={},i){let{ids:t,name:s,limit:r,offset:n}=o,d={ids:t,name:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:zu.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__zeroOutGrant(o,i,t))}async __zeroOutGrant(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/grants/${u.encodePathParam(o)}/zero-out`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:$a.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:dd.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__grantBillingCreditsToCompany(o,i))}async __grantBillingCreditsToCompany(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/grants/company"),method:"POST",headers:s,contentType:"application/json",queryString:u.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:Gu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countCompanyGrants(o,i))}async __countCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:n,offset:d}=o,g={company_id:t,order:s!=null?Xr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?Te.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/grants/company/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listCompanyGrants(o,i))}async __listCompanyGrants(o={},i){let{companyId:t,order:s,dir:r,limit:n,offset:d}=o,g={company_id:t,order:s!=null?Xr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,dir:r!=null?Te.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/grants/company/list"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Xu.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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countBillingCreditsGrants(o,i))}async __countBillingCreditsGrants(o={},i){let{creditId:t,ids:s,limit:r,offset:n}=o,d={credit_id:t,ids:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/grants/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:wu.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listGrantsForCredit(o,i))}async __listGrantsForCredit(o={},i){let{creditId:t,ids:s,limit:r,offset:n}=o,d={credit_id:t,ids:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/grants/list"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:nd.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__acquireCreditLease(o,i))}async __acquireCreditLease(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/lease"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Fa.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:gu.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__extendCreditLease(o,i,t))}async __extendCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/lease/${u.encodePathParam(o)}/extend`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Wa.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:Vu.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__releaseCreditLease(o,i,t))}async __releaseCreditLease(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/lease/${u.encodePathParam(o)}/release`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:iy.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:sd.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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")}getEnrichedCreditLedger(o,i){return S.fromPromise(this.__getEnrichedCreditLedger(o,i))}async __getEnrichedCreditLedger(o,i){let{companyId:t,billingCreditId:s,featureId:r,period:n,startTime:d,endTime:g,limit:h,offset:l}=o,y={company_id:t,billing_credit_id:s,feature_id:r,period:ei.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}),start_time:d,end_time:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=P(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/ledger"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(v.ok)return{data:Iu.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 T(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new _(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new z(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new f(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new R(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/credits/ledger")}countCreditLedger(o,i){return S.fromPromise(this.__countCreditLedger(o,i))}async __countCreditLedger(o,i){let{companyId:t,billingCreditId:s,featureId:r,period:n,startTime:d,endTime:g,limit:h,offset:l}=o,y={company_id:t,billing_credit_id:s,feature_id:r,period:ei.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}),start_time:d,end_time:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=P(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/ledger/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(v.ok)return{data:vu.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 T(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new _(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new z(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new f(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new R(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/credits/ledger/count")}listBillingPlanCreditGrants(o={},i){return S.fromPromise(this.__listBillingPlanCreditGrants(o,i))}async __listBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:n,planVersionId:d,planVersionIds:g,limit:h,offset:l}=o,y={credit_id:t,ids:s,plan_id:r,plan_ids:n,plan_version_id:d,plan_version_ids:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=P(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/plan-grants"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(v.ok)return{data:$u.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 T(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new _(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new z(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new f(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new R(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/credits/plan-grants")}createBillingPlanCreditGrant(o,i){return S.fromPromise(this.__createBillingPlanCreditGrant(o,i))}async __createBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/plan-grants"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:nt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ou.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getSingleBillingPlanCreditGrant(o,i))}async __getSingleBillingPlanCreditGrant(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Ku.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateBillingPlanCreditGrant(o,i,t))}async __updateBillingPlanCreditGrant(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body: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:pd.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.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(),d=P(n.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`billing/credits/plan-grants/${u.encodePathParam(o)}`),method:"DELETE",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:ju.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 T(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new z(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new f(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countBillingPlanCreditGrants(o,i))}async __countBillingPlanCreditGrants(o={},i){let{creditId:t,ids:s,planId:r,planIds:n,planVersionId:d,planVersionIds:g,limit:h,offset:l}=o,y={credit_id:t,ids:s,plan_id:r,plan_ids:n,plan_version_id:d,plan_version_ids:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=P(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"billing/credits/plan-grants/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(v.ok)return{data:fu.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 T(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new _(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new z(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new f(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new R(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/credits/plan-grants/count")}listCreditEventLedger(o,i){return S.fromPromise(this.__listCreditEventLedger(o,i))}async __listCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:n,featureId:d,startTime:g,limit:h,offset:l}=o,y={billing_credit_id:t,company_id:s,end_time:r,event_type:n!=null?wr.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:d,start_time:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=P(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"v2/billing/credits/ledger"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(v.ok)return{data:td.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 T(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new _(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new z(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new f(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new R(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","/v2/billing/credits/ledger")}countCreditEventLedger(o,i){return S.fromPromise(this.__countCreditEventLedger(o,i))}async __countCreditEventLedger(o,i){let{billingCreditId:t,companyId:s,endTime:r,eventType:n,featureId:d,startTime:g,limit:h,offset:l}=o,y={billing_credit_id:t,company_id:s,end_time:r,event_type:n!=null?wr.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,feature_id:d,start_time:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=P(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"v2/billing/credits/ledger/count"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(v.ok)return{data:Cu.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 T(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new _(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new z(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new f(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new R(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","/v2/billing/credits/ledger/count")}};var Tt=class{constructor(o){this._options=I(o)}createDataExport(o,i){return S.fromPromise(this.__createDataExport(o,i))}async __createDataExport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"data-exports"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:{...Ja.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: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 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getDataExportArtifact(o,i))}async __getDataExportArtifact(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`data-exports/${u.encodePathParam(o)}/artifact`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),responseType:"streaming",timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:r.body,rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 Ot=class{constructor(o){this._options=I(o)}listCompanyOverrides(o={},i){return S.fromPromise(this.__listCompanyOverrides(o,i))}async __listCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:n,ids:d,withoutExpired:g,q:h,limit:l,offset:y}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:n,ids:d,without_expired:g,q:h,limit:l,offset:y},U=await this._options.authProvider.getAuthRequest(),v=P(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"company-overrides"),method:"GET",headers:v,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:Hd.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 T(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new _(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new z(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new f(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createCompanyOverride(o,i))}async __createCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"company-overrides"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getCompanyOverride(o,i))}async __getCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`company-overrides/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Vd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateCompanyOverride(o,i,t))}async __updateCompanyOverride(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`company-overrides/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.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:tm.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteCompanyOverride(o,i))}async __deleteCompanyOverride(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`company-overrides/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Td.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countCompanyOverrides(o,i))}async __countCompanyOverrides(o={},i){let{companyId:t,companyIds:s,featureId:r,featureIds:n,ids:d,withoutExpired:g,q:h,limit:l,offset:y}=o,w={company_id:t,company_ids:s,feature_id:r,feature_ids:n,ids:d,without_expired:g,q:h,limit:l,offset:y},U=await this._options.authProvider.getAuthRequest(),v=P(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"company-overrides/count"),method:"GET",headers:v,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:zd.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 T(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new _(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new z(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new f(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listFeatureCompanies(o,i))}async __listFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:n}=o,d={feature_id:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"feature-companies"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Zd.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countFeatureCompanies(o,i))}async __countFeatureCompanies(o,i){let{featureId:t,q:s,limit:r,offset:n}=o,d={feature_id:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"feature-companies/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:fd.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listFeatureUsage(o,i))}async __listFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:n,managedBy:d,q:g,withoutNegativeEntitlements:h,limit:l,offset:y}=o,w={company_id:t,company_keys:s!=null?xe(s):void 0,feature_ids:r,include_usage_aggregation:n,managed_by:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:g,without_negative_entitlements:h,limit:l,offset:y},U=await this._options.authProvider.getAuthRequest(),v=P(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"feature-usage"),method:"GET",headers:v,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data: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 T(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new _(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new z(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new f(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getFeatureUsageTimeSeries(o,i))}async __getFeatureUsageTimeSeries(o,i){let{companyId:t,endTime:s,featureId:r,granularity:n,startTime:d}=o,g={company_id:t,end_time:s.toISOString(),feature_id:r,granularity:n!=null?$e.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,start_time:d.toISOString()},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"feature-usage-timeseries"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Ld.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 _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countFeatureUsage(o,i))}async __countFeatureUsage(o={},i){let{companyId:t,companyKeys:s,featureIds:r,includeUsageAggregation:n,managedBy:d,q:g,withoutNegativeEntitlements:h,limit:l,offset:y}=o,w={company_id:t,company_keys:s!=null?xe(s):void 0,feature_ids:r,include_usage_aggregation:n,managed_by:d!=null?k.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,q:g,without_negative_entitlements:h,limit:l,offset:y},U=await this._options.authProvider.getAuthRequest(),v=P(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"feature-usage/count"),method:"GET",headers:v,queryString:u.queryBuilder().addMany(w).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(O.ok)return{data:Sd.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 T(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new _(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new z(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new f(a.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listFeatureUsers(o,i))}async __listFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:n}=o,d={feature_id:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"feature-users"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data: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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countFeatureUsers(o,i))}async __countFeatureUsers(o,i){let{featureId:t,q:s,limit:r,offset:n}=o,d={feature_id:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"feature-users/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:xd.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listPlanEntitlements(o,i))}async __listPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:n,planIds:d,planVersionId:g,planVersionIds:h,q:l,withMeteredProducts:y,limit:w,offset:U}=o,v={feature_id:t,feature_ids:s,ids:r,plan_id:n,plan_ids:d,plan_version_id:g,plan_version_ids:h,q:l,with_metered_products:y,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),B=P(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-entitlements"),method:"GET",headers:B,queryString:u.queryBuilder().addMany(v).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:om.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 T(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new _(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new z(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new f(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createPlanEntitlement(o,i))}async __createPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-entitlements"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Qa.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:vd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getPlanEntitlement(o,i))}async __getPlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Gd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updatePlanEntitlement(o,i,t))}async __updatePlanEntitlement(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(n.ok)return{data:am.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deletePlanEntitlement(o,i))}async __deletePlanEntitlement(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-entitlements/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Od.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertPlanEntitlementForBillingProduct(o,i))}async __upsertPlanEntitlementForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-entitlements/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countPlanEntitlements(o,i))}async __countPlanEntitlements(o={},i){let{featureId:t,featureIds:s,ids:r,planId:n,planIds:d,planVersionId:g,planVersionIds:h,q:l,withMeteredProducts:y,limit:w,offset:U}=o,v={feature_id:t,feature_ids:s,ids:r,plan_id:n,plan_ids:d,plan_version_id:g,plan_version_ids:h,q:l,with_metered_products:y,limit:w,offset:U},O=await this._options.authProvider.getAuthRequest(),B=P(O.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-entitlements/count"),method:"GET",headers:B,queryString:u.queryBuilder().addMany(v).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Cd.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 T(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new _(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new z(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new f(a.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new R(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 S.fromPromise(this.__duplicatePlanEntitlements(o,i))}async __duplicatePlanEntitlements(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-entitlements/duplicate"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getFeatureUsageByCompany(o,i))}async __getFeatureUsageByCompany(o,i){let{keys:t}=o,s={keys:xe(t)},r=await this._options.authProvider.getAuthRequest(),n=P(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"usage-by-company"),method:"GET",headers:n,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Dd.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new _(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new z(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new f(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new R(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/usage-by-company")}};var kt=class{constructor(o){this._options=I(o)}createEventBatch(o,i){return S.fromPromise(this.__createEventBatch(o,i))}async __createEventBatch(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"event-batch"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getEventSummaries(o,i))}async __getEventSummaries(o={},i){let{q:t,eventSubtypes:s,limit:r,offset:n}=o,d={q:t,event_subtypes:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"event-types"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:wm.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listEvents(o,i))}async __listEvents(o={},i){let{companyId:t,eventSubtype:s,eventTypes:r,flagId:n,idempotencyKey:d,userId:g,limit:h,offset:l}=o,y={company_id:t,event_subtype:s,event_types:Array.isArray(r)?r.map(O=>br.jsonOrThrow(O,{unrecognizedObjectKeys:"strip"})):r!=null?br.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,flag_id:n,idempotency_key:d,user_id:g,limit:h,offset:l},w=await this._options.authProvider.getAuthRequest(),U=P(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"events"),method:"GET",headers:U,queryString:u.queryBuilder().addMany(y).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(v.ok)return{data:fm.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 T(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new _(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new z(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new f(a.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new R(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","/events")}createEvent(o,i){return S.fromPromise(this.__createEvent(o,i))}async __createEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"events"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Jo.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:mm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getEvent(o,i))}async __getEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`events/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:gm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getSegmentIntegrationStatus(o))}async __getSegmentIntegrationStatus(o){let i=await this._options.authProvider.getAuthRequest(),t=P(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"segment-integration"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:zm.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 _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new z(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new f(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new R(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 Bt=class{constructor(o){this._options=I(o)}listFeatures(o={},i){return S.fromPromise(this.__listFeatures(o,i))}async __listFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:n,planVersionId:d,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:d,q:g,without_company_override_for:h,without_plan_entitlement_for:l,limit:y,offset:w},v=await this._options.authProvider.getAuthRequest(),O=P(v.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"features"),method:"GET",headers:O,queryString:u.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Fm.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 T(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new _(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new z(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new f(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new R(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","/features")}createFeature(o,i){return S.fromPromise(this.__createFeature(o,i))}async __createFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"features"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:nn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getFeature(o,i))}async __getFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`features/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateFeature(o,i,t))}async __updateFeature(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`features/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:sn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(n.ok)return{data:Gm.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteFeature(o,i))}async __deleteFeature(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`features/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertFeatureForBillingProduct(o,i))}async __upsertFeatureForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"features/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:an.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countFeatures(o,i))}async __countFeatures(o={},i){let{booleanRequireEvent:t,featureType:s,ids:r,managedBy:n,planVersionId:d,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:d,q:g,without_company_override_for:h,without_plan_entitlement_for:l,limit:y,offset:w},v=await this._options.authProvider.getAuthRequest(),O=P(v.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"features/count"),method:"GET",headers:O,queryString:u.queryBuilder().addMany(U).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(B.ok)return{data:Om.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 T(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new _(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new z(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new f(a.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new R(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","/features/count")}listFlags(o={},i){return S.fromPromise(this.__listFlags(o,i))}async __listFlags(o={},i){let{featureId:t,ids:s,q:r,limit:n,offset:d}=o,g={feature_id:t,ids:s,q:r,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"flags"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Lm.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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createFlag(o,i))}async __createFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"flags"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Un.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getFlag(o,i))}async __getFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`flags/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:Mm.parseOrThrow(r.body,{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 _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateFlag(o,i,t))}async __updateFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`flags/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Un.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(n.ok)return{data:Wm.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteFlag(o,i))}async __deleteFlag(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`flags/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:qm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateFlagRules(o,i,t))}async __updateFlagRules(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`flags/${u.encodePathParam(o)}/rules`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:cn.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:$m.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__checkFlag(o,i,t))}async __checkFlag(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`flags/${u.encodePathParam(o)}/check`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:io.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:Pm.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__checkFlags(o,i))}async __checkFlags(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"flags/check"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:io.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__checkFlagsBulk(o,i))}async __checkFlagsBulk(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"flags/check-bulk"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:tn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countFlags(o,i))}async __countFlags(o={},i){let{featureId:t,ids:s,q:r,limit:n,offset:d}=o,g={feature_id:t,ids:s,q:r,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"flags/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Bm.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 400:throw new T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 jt=class{constructor(o){this._options=I(o)}getActivity(o={},i){return S.fromPromise(this.__getActivity(o,i))}async __getActivity(o={},i){let{limit:t}=o,s={limit:t},r=await this._options.authProvider.getAuthRequest(),n=P(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"insights/activity"),method:"GET",headers:n,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Xm.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new _(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new z(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new f(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new R(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/insights/activity")}getEnvironmentFeatureUsageTimeSeries(o,i){return S.fromPromise(this.__getEnvironmentFeatureUsageTimeSeries(o,i))}async __getEnvironmentFeatureUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:n}=o,d={end_time:t.toISOString(),feature_id:s,granularity:r!=null?$e.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:n.toISOString()},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"insights/feature-usage-timeseries"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data: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 _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getPlanGrowth(o,i))}async __getPlanGrowth(o={},i){let{months:t}=o,s={months:t},r=await this._options.authProvider.getAuthRequest(),n=P(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"insights/plan-growth"),method:"GET",headers:n,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:lh.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new _(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new z(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new f(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new R(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/insights/plan-growth")}getSummary(o){return S.fromPromise(this.__getSummary(o))}async __getSummary(o){let i=await this._options.authProvider.getAuthRequest(),t=P(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"insights/summary"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:dh.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 _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new z(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new f(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new R(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 S.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()},d=await this._options.authProvider.getAuthRequest(),g=P(d.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"insights/top-features"),method:"GET",headers:g,queryString:u.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:yh.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 _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new z(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new f(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getEnvironmentTraitUsageTimeSeries(o,i))}async __getEnvironmentTraitUsageTimeSeries(o,i){let{endTime:t,featureId:s,granularity:r,startTime:n}=o,d={end_time:t.toISOString(),feature_id:s,granularity:r!=null?$e.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,start_time:n.toISOString()},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"insights/trait-usage-timeseries"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:ah.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 _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 At=class{constructor(o){this._options=I(o)}runIntegration(o,i){return S.fromPromise(this.__runIntegration(o,i))}async __runIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`integration/start/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listIntegrations(o,i))}async __listIntegrations(o={},i){let{billingOnly:t,excludeIds:s,id:r,state:n,type:d,limit:g,offset:h}=o,l={billing_only:t,exclude_ids:s,id:r,state:n!=null?Qe.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,type:d!=null?ke.jsonOrThrow(d,{unrecognizedObjectKeys:"strip"}):void 0,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=P(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"integrations"),method:"GET",headers:w,queryString:u.queryBuilder().addMany(l).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(U.ok)return{data:Uh.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 T(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new _(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new z(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new f(a.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getIntegrationWebhookUrl(o,i))}async __getIntegrationWebhookUrl(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`integrations/${u.encodePathParam(o)}/webhook-url`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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")}startDataImport(o,i){return S.fromPromise(this.__startDataImport(o,i))}async __startDataImport(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"integrations/start-data-import"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:ln.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:kh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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")}loadSampleDataSetV2(o){return S.fromPromise(this.__loadSampleDataSetV2(o))}async __loadSampleDataSetV2(o){let i=await this._options.authProvider.getAuthRequest(),t=P(i.headers,this._options?.headers,o?.headers),s=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"integrations/stripe/dataset-sample-v2"),method:"GET",headers:t,queryString:u.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:(o?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:o?.maxRetries??this._options?.maxRetries,abortSignal:o?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(s.ok)return{data:Th.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 _(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new z(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new f(a.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new R(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")}uninstallIntegration(o,i){return S.fromPromise(this.__uninstallIntegration(o,i))}async __uninstallIntegration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`integrations/uninstall/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 Vt=class{constructor(o){this._options=I(o)}createCustomPlanBundle(o,i){return S.fromPromise(this.__createCustomPlanBundle(o,i))}async __createCustomPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"custom-plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:pn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createPlanBundle(o,i))}async __createPlanBundle(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-bundles"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:un.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updatePlanBundle(o,i,t))}async __updatePlanBundle(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-bundles/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:dn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(n.ok)return{data:Ih.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 qt=class{constructor(o){this._options=I(o)}getPlanGroup(o={},i){return S.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=P(r.headers,this._options?.headers,i?.headers),d=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-groups"),method:"GET",headers:n,queryString:u.queryBuilder().addMany(s).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(d.ok)return{data:Nh.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 401:throw new _(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new z(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new f(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 500:throw new R(a.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new b({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return C(d.error,d.rawResponse,"GET","/plan-groups")}createPlanGroup(o,i){return S.fromPromise(this.__createPlanGroup(o,i))}async __createPlanGroup(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-groups"),method:"POST",headers:s,contentType:"application/json",queryString:u.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: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updatePlanGroup(o,i,t))}async __updatePlanGroup(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-groups/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:hn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(n.ok)return{data:$h.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 Dt=class{constructor(o){this._options=I(o)}listCompanyMigrations(o={},i){return S.fromPromise(this.__listCompanyMigrations(o,i))}async __listCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:n,offset:d}=o,g={migration_id:t,q:s,status:r!=null?Rr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-version-company-migrations"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:ig.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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__retryCompanyMigration(o,i))}async __retryCompanyMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-version-company-migrations/${u.encodePathParam(o)}/retry`),method:"POST",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countCompanyMigrations(o,i))}async __countCompanyMigrations(o={},i){let{migrationId:t,q:s,status:r,limit:n,offset:d}=o,g={migration_id:t,q:s,status:r!=null?Rr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-version-company-migrations/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listMigrations(o,i))}async __listMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:n}=o,d={plan_version_id:t,status:s!=null?fr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-version-migrations"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:tg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createMigration(o,i))}async __createMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-version-migrations"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:yn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getMigration(o,i))}async __getMigration(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-version-migrations/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:eg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__retryMigration(o,i,t))}async __retryMigration(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plan-version-migrations/${u.encodePathParam(o)}/retry`),method:"POST",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body: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:ng.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countMigrations(o,i))}async __countMigrations(o={},i){let{planVersionId:t,status:s,limit:r,offset:n}=o,d={plan_version_id:t,status:s!=null?fr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plan-version-migrations/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data: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 400:throw new T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 Mt=class{constructor(o){this._options=I(o)}updateCompanyPlans(o,i,t){return S.fromPromise(this.__updateCompanyPlans(o,i,t))}async __updateCompanyPlans(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`company-plans/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.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:vg.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listCustomPlanBillings(o,i))}async __listCustomPlanBillings(o={},i){let{companyId:t,planId:s,status:r,statuses:n,limit:d,offset:g}=o,h={company_id:t,plan_id:s,status:r!=null?hr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,statuses:Array.isArray(n)?n.map(U=>hr.jsonOrThrow(U,{unrecognizedObjectKeys:"strip"})):n!=null?hr.jsonOrThrow(n,{unrecognizedObjectKeys:"strip"}):void 0,limit:d,offset:g},l=await this._options.authProvider.getAuthRequest(),y=P(l.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"custom-plan-billings"),method:"GET",headers:y,queryString:u.queryBuilder().addMany(h).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(w.ok)return{data:fg.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 T(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new _(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new z(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new f(a.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new R(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 S.fromPromise(this.__markCustomPlanBillingPaid(o,i,t))}async __markCustomPlanBillingPaid(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`custom-plan-billings/${u.encodePathParam(o)}/mark-paid`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:ry.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:Eg.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__retryCustomPlanBilling(o,i,t))}async __retryCustomPlanBilling(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`custom-plan-billings/${u.encodePathParam(o)}/retry`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body: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:Ug.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createCustomPlan(o,i))}async __createCustomPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"custom-plans"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:zn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listPlans(o,i))}async __listPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:n,forInitialPlan:d,forTrialExpiryPlan:g,hasProductId:h,ids:l,includeDraftVersions:y,planType:w,q:U,scopedToCompanyId:v,withEntitlements:O,withoutEntitlementFor:B,withoutPaidProductId:j,limit:$,offset:A}=o,le={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:n,for_initial_plan:d,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:v,with_entitlements:O,without_entitlement_for:B,without_paid_product_id:j,limit:$,offset:A},Le=await this._options.authProvider.getAuthRequest(),q=P(Le.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plans"),method:"GET",headers:q,queryString:u.queryBuilder().addMany(le).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:xg.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 T(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new _(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new z(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new f(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new R(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","/plans")}createPlan(o,i){return S.fromPromise(this.__createPlan(o,i))}async __createPlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plans"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:tt.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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.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(),d=P(n.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plans/${u.encodePathParam(o)}`),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:wg.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 _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new z(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new f(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updatePlan(o,i,t))}async __updatePlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plans/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:lt.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:Tg.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deletePlan(o,i))}async __deletePlan(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plans/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:mg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertBillingProductPlan(o,i,t))}async __upsertBillingProductPlan(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plans/${u.encodePathParam(o)}/billing_products`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Fr.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:Og.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__upsertPlanForBillingProduct(o,i))}async __upsertPlanForBillingProduct(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plans/billing-linked"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:bn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data:kg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listBillingProductMatchCompanies(o,i))}async __listBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:n}=o,d={plan_id:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plans/billing-product-match-companies"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:zg.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countBillingProductMatchCompanies(o,i))}async __countBillingProductMatchCompanies(o,i){let{planId:t,q:s,limit:r,offset:n}=o,d={plan_id:t,q:s,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plans/billing-product-match-companies/count"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:cg.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 T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countPlans(o,i))}async __countPlans(o={},i){let{companyId:t,companyScopedOnly:s,excludeCompanyScoped:r,forFallbackPlan:n,forInitialPlan:d,forTrialExpiryPlan:g,hasProductId:h,ids:l,includeDraftVersions:y,planType:w,q:U,scopedToCompanyId:v,withEntitlements:O,withoutEntitlementFor:B,withoutPaidProductId:j,limit:$,offset:A}=o,le={company_id:t,company_scoped_only:s,exclude_company_scoped:r,for_fallback_plan:n,for_initial_plan:d,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:v,with_entitlements:O,without_entitlement_for:B,without_paid_product_id:j,limit:$,offset:A},Le=await this._options.authProvider.getAuthRequest(),q=P(Le.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plans/count"),method:"GET",headers:q,queryString:u.queryBuilder().addMany(le).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:pg.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 T(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new _(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new z(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new f(a.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new R(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","/plans/count")}listPlanIssues(o,i){return S.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(),d=P(n.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"plans/issues"),method:"GET",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:Sg.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 T(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new z(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new f(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new R(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 S.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(),d=P(n.headers,this._options?.headers,t?.headers),g=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plans/version/${u.encodePathParam(o)}`),method:"DELETE",headers:d,queryString:u.queryBuilder().addMany(r).mergeAdditional(t?.queryParams).build(),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(g.ok)return{data:gg.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 T(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new _(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new z(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new f(a.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new R(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 S.fromPromise(this.__publishPlanVersion(o,i,t))}async __publishPlanVersion(o,i,t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`plans/version/${u.encodePathParam(o)}/publish`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Rn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(n.ok)return{data:Cg.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 It=class{constructor(o){this._options=I(o)}listScheduledCheckouts(o={},i){return S.fromPromise(this.__listScheduledCheckouts(o,i))}async __listScheduledCheckouts(o={},i){let{companyId:t,status:s,limit:r,offset:n}=o,d={company_id:t,status:s!=null?Gr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:n},g=await this._options.authProvider.getAuthRequest(),h=P(g.headers,this._options?.headers,i?.headers),l=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"scheduled-checkout"),method:"GET",headers:h,queryString:u.queryBuilder().addMany(d).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(l.ok)return{data:Vg.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new T(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new _(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new z(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new f(a.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createScheduledCheckout(o,i))}async __createScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"scheduled-checkout"),method:"POST",headers:s,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),requestType:"json",body:Sn.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getScheduledCheckout(o,i))}async __getScheduledCheckout(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`scheduled-checkout/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateScheduledCheckout(o,i,t))}async __updateScheduledCheckout(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`scheduled-checkout/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:Pn.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(t?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:t?.maxRetries??this._options?.maxRetries,abortSignal:t?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(n.ok)return{data:qg.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 Ft=class{constructor(o){this._options=I(o)}listWebhookEvents(o={},i){return S.fromPromise(this.__listWebhookEvents(o,i))}async __listWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:n,offset:d}=o,g={ids:t,q:s,webhook_id:r,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"webhook-events"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:$g.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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getWebhookEvent(o,i))}async __getWebhookEvent(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`webhook-events/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__countWebhookEvents(o,i))}async __countWebhookEvents(o={},i){let{ids:t,q:s,webhookId:r,limit:n,offset:d}=o,g={ids:t,q:s,webhook_id:r,limit:n,offset:d},h=await this._options.authProvider.getAuthRequest(),l=P(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"webhook-events/count"),method:"GET",headers:l,queryString:u.queryBuilder().addMany(g).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(y.ok)return{data:Mg.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 T(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new _(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new z(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new f(a.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new R(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 S.fromPromise(this.__listWebhooks(o,i))}async __listWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,n={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),g=P(d.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"webhooks"),method:"GET",headers:g,queryString:u.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:Zg.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 T(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new z(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new f(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new R(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 S.fromPromise(this.__createWebhook(o,i))}async __createWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"webhooks"),method:"POST",headers:s,contentType:"application/json",queryString:u.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:Kg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__getWebhook(o,i))}async __getWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`webhooks/${u.encodePathParam(o)}`),method:"GET",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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 S.fromPromise(this.__updateWebhook(o,i,t))}async __updateWebhook(o,i={},t){let s=await this._options.authProvider.getAuthRequest(),r=P(s.headers,this._options?.headers,t?.headers),n=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`webhooks/${u.encodePathParam(o)}`),method:"PUT",headers:r,contentType:"application/json",queryString:u.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:Yg.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 T(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 401:throw new _(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 403:throw new z(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 404:throw new f(a.parseOrThrow(n.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),n.rawResponse);case 500:throw new R(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 S.fromPromise(this.__deleteWebhook(o,i))}async __deleteWebhook(o,i){let t=await this._options.authProvider.getAuthRequest(),s=P(t.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,`webhooks/${u.encodePathParam(o)}`),method:"DELETE",headers:s,queryString:u.queryBuilder().mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.timeoutInSeconds??this._options?.timeoutInSeconds??60)*1e3,maxRetries:i?.maxRetries??this._options?.maxRetries,abortSignal:i?.abortSignal,fetchFn:this._options?.fetch,logging:this._options.logging});if(r.ok)return{data: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 T(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new _(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new z(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new f(a.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new R(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}")}countWebhooks(o={},i){return S.fromPromise(this.__countWebhooks(o,i))}async __countWebhooks(o={},i){let{q:t,limit:s,offset:r}=o,n={q:t,limit:s,offset:r},d=await this._options.authProvider.getAuthRequest(),g=P(d.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??E)({url:u.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??x.Default,"webhooks/count"),method:"GET",headers:g,queryString:u.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:Fg.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new T(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new _(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new z(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new f(a.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new R(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 Kt=class{constructor(o){this._options=I(o)}get accounts(){return this._accounts??=new St(this._options)}get billing(){return this._billing??=new Pt(this._options)}get credits(){return this._credits??=new vt(this._options)}get checkout(){return this._checkout??=new xt(this._options)}get companies(){return this._companies??=new Et(this._options)}get entitlements(){return this._entitlements??=new Ot(this._options)}get plans(){return this._plans??=new Mt(this._options)}get components(){return this._components??=new Ct(this._options)}get planbundle(){return this._planbundle??=new Vt(this._options)}get dataexports(){return this._dataexports??=new Tt(this._options)}get events(){return this._events??=new kt(this._options)}get features(){return this._features??=new Bt(this._options)}get insights(){return this._insights??=new jt(this._options)}get integrationsapi(){return this._integrationsapi??=new At(this._options)}get plangroups(){return this._plangroups??=new qt(this._options)}get planmigrations(){return this._planmigrations??=new Dt(this._options)}get componentspublic(){return this._componentspublic??=new Ut(this._options)}get scheduledcheckout(){return this._scheduledcheckout??=new It(this._options)}get accesstokens(){return this._accesstokens??=new _t(this._options)}get webhooks(){return this._webhooks??=new Ft(this._options)}async fetch(o,i,t){return na(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 Je={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},jn={[Je.Debug]:1,[Je.Info]:2,[Je.Warn]:3,[Je.Error]:4},oy=Je.Warn,Nr=class{constructor(o=oy){this.level=jn[o]??jn[oy]}shouldLog(o){return jn[o]>=this.level}error(o,...i){this.shouldLog(Je.Error)&&console.error(o,...i)}warn(o,...i){this.shouldLog(Je.Warn)&&console.warn(o,...i)}info(o,...i){this.shouldLog(Je.Info)&&console.info(o,...i)}debug(o,...i){this.shouldLog(Je.Debug)&&console.debug(o,...i)}};var Cb=1e3,Ub=1e3,vb=3,Tb=1e3,Lt=class{constructor(o,i){this.events=[];this.intervalId=null;this.shutdown=!1;this.stopped=!1;this.flushing=!1;let{logger:t=new Nr,maxSize:s=Ub,interval:r=Cb,offline:n=!1,maxRetries:d=vb,initialRetryDelay:g=Tb}=i||{};this.captureClient=o,this.interval=r,this.logger=t,this.maxSize=s,this.offline=n,this.maxRetries=d,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),d=Math.random()*.1*n,g=n+d;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 Ob="https://c.schematichq.com",kb=1e4,Bb=p=>p.replace(/\/+$/,"")+"/batch",jb=(p,o)=>{let i={api_key:o,type:p.eventType};return p.body!==void 0&&(i.body=$o.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},Ab=(p,o)=>({events:p.map(i=>jb(i,o))}),Vb=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"}},Gt=class{constructor(o){this.apiKey=o.apiKey,this.baseUrl=o.baseUrl??Ob,this.timeoutMs=o.timeoutMs??kb,this.fetcher=o.fetcher,this.headers=o.headers??{}}async sendBatch(o){if(o.length===0)return;let i=await this.fetcher({url:Bb(this.baseUrl),method:"POST",contentType:"application/json",requestType:"json",headers:{...this.headers,"X-Schematic-Api-Key":this.apiKey},body:Ab(o,this.apiKey),timeoutMs:this.timeoutMs,maxRetries:0});if(!i.ok)throw new Error(`capture service returned ${Vb(i.error)}`)}};function ty(p){return async function(i){let t={};if(p&&Object.assign(t,p),i.body!==void 0&&i.contentType!=null&&(t["Content-Type"]=i.contentType),i.headers!=null)for(let[d,g]of Object.entries(i.headers))g!=null&&typeof g=="string"&&(t[d]=g);let s=so(i.url,i.queryParameters),r=await co({body:i.body,type:i.requestType==="json"?"json":"other"}),n=await ni();try{let d=await pi(async()=>si(n,s,i.method,t,r,i.timeoutMs,i.abortSignal,i.withCredentials,i.duplex),i.maxRetries),g=await ai(d,i.responseType),h=$i(d);return d.status>=200&&d.status<400?{ok:!0,body:g,headers:d.headers,rawResponse:h}:{ok:!1,error:{reason:"status-code",statusCode:d.status,body:g},rawResponse:h}}catch(d){return i.abortSignal!=null&&i.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:ci}:d instanceof Error&&d.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:ci}:d instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:d.message},rawResponse:li}:{ok:!1,error:{reason:"unknown",errorMessage:JSON.stringify(d)},rawResponse:li}}}}async function qb(p){return{ok:!0,body:{},headers:{"Content-Type":"application/json"},rawResponse:{headers:new Ye,redirected:!1,status:200,statusText:"OK",type:"basic",url:""}}}var ay=qb;var Fi=class{constructor(){this.wasmInstance=null;this.initialized=!1}async initialize(){if(!this.initialized)try{let i=require("./wasm/rulesengine.js");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){this.ensureInitialized();let s=(r,n)=>n===null?void 0:n;try{let r=JSON.stringify(o,s),n=i?JSON.stringify(i,s):void 0,d=t?JSON.stringify(t,s):void 0,g=this.wasmInstance.checkFlag(r,n,d);return JSON.parse(g)}catch(r){throw new Error(`WASM flag check failed: ${r}`)}}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.")}};An();function Li(p,o,i){return p[o]??p[i]}function qn(p){return JSON.parse(JSON.stringify(p))}function Db(p){return JSON.parse(JSON.stringify(p))}function ny(p,o){let i=qn(p),t,s=!1;for(let r of Object.keys(o))switch(r){case"id":case"account_id":case"environment_id":i[r]=o[r];break;case"base_plan_id":i[r]=o[r]??null;break;case"billing_product_ids":case"plan_ids":case"plan_version_ids":case"entitlements":case"rules":case"traits":case"subscription":i[r]=o[r];break;case"keys":{let n=Li(i,"keys","keys")??{},d=o[r];i[r]={...n,...d};break}case"credit_balances":{let n=Li(i,"creditBalances","credit_balances")??{},d=o[r]??{};i[r]={...n,...d},t=d;break}case"metrics":{let n=Li(i,"metrics","metrics")??[],d=o[r]??[];i[r]=Ib(n,d),s=!0;break}}return(t||s)&&!("entitlements"in o)&&Mb(i,t,s),i}function Mb(p,o,i){let t=Li(p,"entitlements","entitlements")??[];if(t.length===0)return;let s=new Map;if(i){let r=Li(p,"metrics","metrics")??[];for(let n of r)n&&s.set(Wt(Vn(n)),n.value??0)}for(let r of t){let n=r.creditId??r.credit_id;o&&n&&n in o&&(r.credit_remaining=o[n]);let d=r.eventName??r.event_name;if(s.size>0&&d){let g=(r.metricPeriod??r.metric_period)||"all_time",h=(r.monthReset??r.month_reset)||"first_of_month",l=s.get(Wt({eventSubtype:d,period:g,monthReset:h}));l!==void 0&&(r.usage=l)}}}function sy(p,o){let i=Db(p);for(let t of Object.keys(o))switch(t){case"id":case"account_id":case"environment_id":i[t]=o[t];break;case"keys":{let s=Li(i,"keys","keys")??{},r=o[t];i[t]={...s,...r};break}case"traits":case"rules":i[t]=o[t];break}return i}function Wt(p){return`${p.eventSubtype}|${p.period}|${p.monthReset}`}function Vn(p){return{eventSubtype:(p.eventSubtype??p.event_subtype)||"",period:p.period||"",monthReset:(p.monthReset??p.month_reset)||""}}function Ib(p,o){let i=[...p],t=new Map;for(let s=0;s<i.length;s++){let r=i[s];if(r){let n=Wt(Vn(r));t.set(n,s)}}for(let s of o){if(!s)continue;let r=Wt(Vn(s)),n=t.get(r);n!==void 0?i[n]=s:i.push(s)}return i}var sr="company",cr="user",$b="flags",Mn=30*1e3,Jb=1440*60*1e3,Zb=720*60*60*1e3,oo=class extends Ki{constructor(i){super();this.replicatorReady=!1;this.pendingCompanyRequests=new Map;this.pendingUserRequests=new Map;if(this.apiKey=i.apiKey,this.baseURL=i.baseURL,this.logger=i.logger,this.cacheTTL=i.cacheTTL??Jb,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 Fi}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 Zr({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:r})):(this.logger.debug(`Using memory cache provider for ${t} cache (TTL: ${r}ms)`),new Ze({ttl:r}))}createKeyCacheProvider(i){let t=this.cacheTTL;return i.redisClient?new Zr({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:t}):new Ze({ttl:t})}calculateCacheTTL(i){return i==="flag"?Math.max(Zb,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}if(!this.baseURL)throw new Error("BaseURL is required when not in replicator mode");this.logger.info("Starting DataStream client");let{DatastreamWSClient:i}=(yy(),Gn(gy));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,d)=>{let g=setTimeout(()=>{this.cleanupPendingCompanyRequests(s,h),d(new Error("Timeout while waiting for company data"))},Mn),h=l=>{clearTimeout(g),l?n(l):d(new Error("Company not found"))};for(let l of s)this.pendingCompanyRequests.has(l)||this.pendingCompanyRequests.set(l,[]),this.pendingCompanyRequests.get(l).push(h);r||this.sendDataStreamRequest({entity_type:"rulesengine.Company",keys:i}).catch(l=>{this.cleanupPendingCompanyRequests(s,h),d(l)})})}async getUser(i){let t=await this.getUserFromCache(i);if(t)return this.logger.debug(`User found in cache for keys: ${JSON.stringify(i)}`),t;if(this.replicatorMode)throw new Error("User not found in cache and replicator mode is enabled");if(!this.isConnected())throw new Error("DataStream client is not connected");let s=this.generateCacheKeysForUser(i),r=!1;for(let n of s)if(this.pendingUserRequests.has(n)){r=!0;break}return new Promise((n,d)=>{let g=setTimeout(()=>{this.cleanupPendingUserRequests(s,h),d(new Error("Timeout while waiting for user data"))},Mn),h=l=>{clearTimeout(g),l?n(l):d(new Error("User not found"))};for(let l of s)this.pendingUserRequests.has(l)||this.pendingUserRequests.set(l,[]),this.pendingUserRequests.get(l).push(h);r||this.sendDataStreamRequest({entity_type:"rulesengine.User",keys:i}).catch(l=>{this.cleanupPendingUserRequests(s,h),d(l)})})}async getFlag(i){let t=this.flagCacheKey(i);this.logger.debug(`Retrieving flag from cache: ${i} (cache key: ${t})`);try{return await this.flagsCacheProvider.get(t)||null}catch(s){return this.logger.warn(`Failed to retrieve flag from cache: ${s}`),null}}async getAllFlags(){return this.pendingFlagRequest?new Promise((i,t)=>{let s=this.pendingFlagRequest;this.pendingFlagRequest=r=>{s(r),r?i():t(new Error("Failed to refresh flags"))}}):new Promise((i,t)=>{let s=setTimeout(()=>{this.pendingFlagRequest=void 0,t(new Error("Timeout while waiting for flags data"))},Mn);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){let s=await this.getFlag(t);if(!s)throw new Error(`Flag not found: ${t}`);let r=i.company&&Object.keys(i.company).length>0,n=i.user&&Object.keys(i.user).length>0,d=null,g=null;if(r&&(d=await this.getCompanyFromCache(i.company),this.logger.debug(`Company ${d?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.company)}`)),n&&(g=await this.getUserFromCache(i.user),this.logger.debug(`User ${g?"found in cache":"not found in cache"} for keys: ${JSON.stringify(i.user)}`)),this.replicatorMode)return this.evaluateFlag(s,d,g);if((!r||d)&&(!n||g))return this.logger.debug(`All required resources found in cache for flag ${t} evaluation`),this.evaluateFlag(s,d,g);if(!this.isConnected())throw new Error("Datastream not connected and required entities not in cache");let h=r&&!d?this.getCompany(i.company):Promise.resolve(d),l=n&&!g?this.getUser(i.user):Promise.resolve(g),[y,w]=await Promise.all([h,l]);return this.evaluateFlag(s,y,w)}async updateCompanyMetrics(i,t,s){let r=await this.getCompanyFromCache(i);if(!r)return;let n=this.deepCopyCompany(r);if(n.metrics)for(let d of n.metrics)(d.eventSubtype??d.event_subtype)===t&&(d.value=(d.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(),d=n.cache_version||n.cacheVersion;if(d)return this.replicatorCacheVersion=d,d}}catch(t){this.logger.debug(`Failed to fetch replicator cache version: ${t}`)}}async handleMessage(i){this.logger.debug(`Processing datastream message: EntityType=${i.entity_type}, MessageType=${i.message_type}`);try{if(i.message_type==="error"){await this.handleErrorMessage(i);return}switch(i.entity_type){case"rulesengine.Company":case"rulesengine.Companies":await this.handleCompanyMessage(i);break;case"rulesengine.User":case"rulesengine.Users":await this.handleUserMessage(i);break;case"rulesengine.Flags":await this.handleFlagsMessage(i);break;case"rulesengine.Flag":await this.handleFlagMessage(i);break;default:this.logger.warn(`Unknown entity type in datastream message: ${i.entity_type}`)}}catch(t){this.logger.error(`Error processing datastream message: ${t}`),this.emit("error",t)}}async handleCompanyMessage(i){let t;if(i.message_type==="partial"){let s=i.entity_id;if(!s){this.logger.error("Partial company message missing entity_id");return}let r=this.resourceIdCacheKey(sr,s),n=await this.companyCacheProvider.get(r);if(!n){this.logger.warn(`Cache miss for partial company '${s}', skipping`);return}try{t=ny(n,i.data)}catch(d){this.logger.error(`Failed to merge partial company: ${d}`);return}}else t=i.data;if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,n]of Object.entries(t.keys)){let d=this.resourceKeyToCacheKey(sr,r,n);try{await this.companyKeyCacheProvider.delete(d)}catch(g){this.logger.warn(`Failed to delete company key mapping from cache: ${g}`)}}let s=this.resourceIdCacheKey(sr,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(cr,s),n=await this.userCacheProvider.get(r);if(!n){this.logger.warn(`Cache miss for partial user '${s}', skipping`);return}try{t=sy(n,i.data)}catch(d){this.logger.error(`Failed to merge partial user: ${d}`);return}}else t=i.data;if(t){if(i.message_type==="delete"){if(t.keys)for(let[r,n]of Object.entries(t.keys)){let d=this.resourceKeyToCacheKey(cr,r,n);try{await this.userKeyCacheProvider.delete(d)}catch(g){this.logger.warn(`Failed to delete user key mapping from cache: ${g}`)}}let s=this.resourceIdCacheKey(cr,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=await Promise.allSettled(t.filter(d=>d?.key).map(async d=>{let g=this.flagCacheKey(d.key);return await this.flagsCacheProvider.set(g,d),g})),r=s.filter(d=>d.status==="fulfilled").map(d=>d.value),n=s.filter(d=>d.status==="rejected");if(n.length>0&&this.logger.warn(`Failed to cache ${n.length} flag(s)`),this.flagsCacheProvider.deleteMissing)try{await this.flagsCacheProvider.deleteMissing(r,{scanPattern:"flags:*"})}catch(d){this.logger.warn(`Failed to delete missing flags: ${d}`)}this.pendingFlagRequest&&this.pendingFlagRequest(!0)}async handleFlagMessage(i){let t=i.data;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(sr,t,s);try{let n=await this.companyKeyCacheProvider.get(r);if(n){let d=this.resourceIdCacheKey(sr,n),g=await this.companyCacheProvider.get(d);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(cr,t,s);try{let n=await this.userKeyCacheProvider.get(r);if(n){let d=this.resourceIdCacheKey(cr,n),g=await this.userCacheProvider.get(d);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(sr,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 d=this.resourceKeyToCacheKey(sr,r,n);try{await this.companyKeyCacheProvider.delete(d)}catch(g){this.logger.warn(`Failed to delete stale company key mapping '${d}': ${g}`)}}}await this.companyCacheProvider.set(t,i,this.cacheTTL);for(let[r,n]of Object.entries(i.keys)){let d=this.resourceKeyToCacheKey(sr,r,n);try{await this.companyKeyCacheProvider.set(d,i.id,this.cacheTTL)}catch(g){this.logger.warn(`Failed to cache company key mapping '${d}': ${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(cr,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 d=this.resourceKeyToCacheKey(cr,r,n);try{await this.userKeyCacheProvider.delete(d)}catch(g){this.logger.warn(`Failed to delete stale user key mapping '${d}': ${g}`)}}}await this.userCacheProvider.set(t,i,this.cacheTTL);for(let[r,n]of Object.entries(i.keys)){let d=this.resourceKeyToCacheKey(cr,r,n);try{await this.userKeyCacheProvider.set(d,i.id,this.cacheTTL)}catch(g){this.logger.warn(`Failed to cache user key mapping '${d}': ${g}`)}}}generateCacheKeysForCompany(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(sr,t,s))}generateCacheKeysForUser(i){return Object.entries(i).map(([t,s])=>this.resourceKeyToCacheKey(cr,t,s))}notifyPendingCompanyRequests(i,t){for(let[s,r]of Object.entries(i)){let n=this.resourceKeyToCacheKey(sr,s,r),d=this.pendingCompanyRequests.get(n);d&&(this.pendingCompanyRequests.delete(n),d.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(cr,s,r),d=this.pendingUserRequests.get(n);d&&(this.pendingUserRequests.delete(n),d.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 d=r.cache_version||r.cacheVersion;if(d&&d!==this.replicatorCacheVersion){let g=this.replicatorCacheVersion;this.replicatorCacheVersion=d,this.logger.info(`Cache version changed from ${g||"(null)"} to ${d}`)}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=`${$b}:${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 qn(i)}async evaluateFlag(i,t,s){let r=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 n=await this.rulesEngine.checkFlag(i,t,s);return this.logger.debug(`Rules engine evaluation result: ${JSON.stringify(n)}`),{flagKey:i.key,value:n.value??r,reason:n.reason||"RULES_ENGINE_EVALUATION",companyId:t?.id,userId:s?.id,flagId:i.id,ruleId:n.ruleId,ruleType:n.ruleType,entitlement:n.entitlement?{...n.entitlement,metricResetAt:n.entitlement.metricResetAt?new Date(n.entitlement.metricResetAt):void 0}:void 0}}else return this.logger.warn("Rules engine not initialized, using default flag value"),{flagKey:i.key,value:r,reason:"RULES_ENGINE_UNAVAILABLE",companyId:t?.id,userId:s?.id,flagId:i.id}}catch(n){return this.logger.error(`Rules engine evaluation failed: ${n}`),{flagKey:i.key,value:r,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"}};var Ht=class extends Kt{constructor(o){let{apiKey:i="",basePath:t,eventBufferInterval:s,eventCaptureBaseURL:r,flagDefaults:n={},logLevel:d,timeoutMs:g}=o??{},{offline:h=!1}=o??{},l=o?.logger??new Nr(d),y={};o?.environmentId&&(y["X-Schematic-Environment-Id"]=o.environmentId),o?.headers&&Object.assign(y,o.headers),h?i!==""&&l.debug("Offline mode enabled, ignoring API key"):i===""&&!h&&(l.warn("No API key was provided, running in offline mode"),h=!0);let w=h?ay:ty(y);super({apiKey:i,environment:t,fetcher:w,timeoutInSeconds:g!==void 0?g/1e3:void 0}),this.logger=l;let U={},v=this._options?.headers;if(v)for(let[B,j]of Object.entries(v))typeof j=="string"&&(U[B]=j);let O=new Gt({apiKey:i,fetcher:w,headers:U,baseUrl:r,timeoutMs:g});if(this.eventBuffer=new Lt(O,{interval:s,logger:l,offline:h}),this.flagCheckCacheProviders=o?.cacheProviders?.flagChecks??[new Ze],this.flagDefaults=n,this.offline=h,o?.useDataStream&&!h){let j=["workerd","edge-runtime","browser","web-worker"].includes(Re.type),$=o.dataStream?.replicatorMode===!0;if(j&&!$)l.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 A={apiKey:i,baseURL:t,logger:l,cacheTTL:o.dataStream?.cacheTTL,redisClient:o.dataStream?.redisClient,redisKeyPrefix:o.dataStream?.redisKeyPrefix,replicatorMode:o.dataStream?.replicatorMode,replicatorHealthURL:o.dataStream?.replicatorHealthURL,replicatorHealthCheck:o.dataStream?.replicatorHealthCheck};this.datastreamClient=new oo(A),this.datastreamClient.start().catch(le=>{l.error(`Failed to start DataStream client: ${le}`),this.datastreamClient=void 0})}}}useDataStream(){return this.datastreamClient!==void 0}async checkFlag(o,i,t){return(await this.checkFlagWithEntitlement(o,i,t)).value}async checkFlagWithEntitlement(o,i,t){let s=()=>t?.defaultValue===void 0?this.getFlagDefault(i):typeof t.defaultValue=="function"?t.defaultValue():t.defaultValue;if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag value for flag ${i}`),{flagKey:i,reason:"flag default",value:s()};if(this.useDataStream())try{let r=await this.datastreamClient.checkFlag(o,i);return this.enqueueEvent(Yt.FlagCheck,{flagKey:i,value:r?.value??!1,reason:r?.reason??"unknown",ruleId:r?.ruleId,companyId:r?.companyId,userId:r?.userId,flagId:r?.flagId,reqCompany:o.company,reqUser:o.user}),{companyId:r.companyId,entitlement:r.entitlement,err:r.err,flagKey:r.flagKey??i,flagId:r.flagId,reason:r.reason,ruleId:r.ruleId,ruleType:r.ruleType,userId:r.userId,value:r.value??this.getFlagDefault(i)}}catch(r){return this.logger.debug(`Datastream flag check failed (${r}), falling back to API`),this.checkFlagViaAPI(o,i,t,s)}return this.checkFlagViaAPI(o,i,t,s)}async checkFlagViaAPI(o,i,t,s){let r=s??(()=>this.getFlagDefault(i));try{let n=JSON.stringify({evalCtx:o,key:i});for(let h of this.flagCheckCacheProviders){let l=await h.get(n);if(l!=null)return this.logger.debug(`${h.constructor.name} cache hit for flag ${i}`),l}let d=await this.features.checkFlag(i,o,{timeoutInSeconds:t?.timeoutMs!==void 0?t.timeoutMs/1e3:void 0});if(d.data.value===void 0)return this.logger.debug(`No value returned from feature flag API for flag ${i}, falling back to default`),{flagKey:i,reason:"flag default",value:r()};this.logger.debug(`Feature flag API response for ${i}: ${JSON.stringify(d.data)}`);let g={companyId:d.data.companyId,entitlement:d.data.entitlement,err:d.data.error,flagKey:d.data.flag,flagId:d.data.flagId,reason:d.data.reason,ruleId:d.data.ruleId,ruleType:d.data.ruleType,userId:d.data.userId,value:d.data.value};try{for(let h of this.flagCheckCacheProviders)this.logger.debug(`Caching value for flag ${i} in ${h.constructor.name}`),await h.set(n,g)}catch(h){this.logger.warn(`Cache write failed for flag ${i}: ${h}`)}return g}catch(n){return this.logger.error(`Error checking flag ${i}: ${n}`),{flagKey:i,reason:"flag default",value:r()}}}async checkFlags(o,i){if(this.offline)return this.logger.debug(`Offline mode enabled, returning default flag values for flags ${i?i.join(", "):"all"}`),i&&i.length>0?i.map(t=>({flag:t,value:this.getFlagDefault(t),reason:"Offline mode - using default value"})):[];try{if(this.useDataStream()&&this.datastreamClient.isConnected()&&i&&i.length>0){let g=await this.checkFlagsViaDataStream(o,i);if(g)return g}if(!i||i.length===0)return this.logger.debug("No specific flag keys provided, calling standard checkFlags API"),(await this.features.checkFlags(o)).data.flags;let t=new Map,s=[];for(let g of i){let h=JSON.stringify({evalCtx:o,key:g}),l=!1;for(let y of this.flagCheckCacheProviders){let w=await y.get(h);if(w!=null){this.logger.debug(`${y.constructor.name} cache hit for flag ${g}`),t.set(g,{flag:g,value:w.value,reason:w.reason}),l=!0;break}}l||s.push(g)}if(s.length===0)return this.logger.debug(`All ${i.length} flags found in cache`),i.map(g=>t.get(g));this.logger.debug(`Cache miss for ${s.length} flags: ${s.join(", ")}, calling API`);let n=(await this.features.checkFlags(o)).data.flags,d=[];for(let g of i){let h=n.find(l=>l.flag===g);if(h){let l=JSON.stringify({evalCtx:o,key:g}),y={companyId:h.companyId,entitlement:h.entitlement,err:h.error,flagKey:h.flag,flagId:h.flagId,reason:h.reason,ruleId:h.ruleId,ruleType:h.ruleType,userId:h.userId,value:h.value};try{for(let w of this.flagCheckCacheProviders)this.logger.debug(`Caching value for flag ${l} in ${w.constructor.name}`),await w.set(l,y)}catch(w){this.logger.warn(`Cache write failed for flag ${g}: ${w}`)}d.push(h)}else{let l=t.get(g);if(l)d.push(l);else{this.logger.debug(`Flag ${g} not found in API response or cache, using default value`);let y={flag:g,value:this.getFlagDefault(g),reason:"Flag not found - using default value"};d.push(y)}}}return this.logger.debug(`Checked ${i.length} flags: used fresh API values for consistency (${s.length} were cache misses)`),d}catch(t){return this.logger.error(`Error checking flags ${i?i.join(", "):"all"}: ${t}`),i&&i.length>0?i.map(s=>({flag:s,value:this.getFlagDefault(s),reason:`Error occurred - using default value: ${t}`})):[]}}async checkFlagsViaDataStream(o,i){let t=[];for(let s of i)try{let r=await this.datastreamClient.checkFlag(o,s);t.push({flag:r.flagKey??s,value:r.value??this.getFlagDefault(s),reason:r.reason,flagId:r.flagId,ruleId:r.ruleId,ruleType:r.ruleType,companyId:r.companyId,userId:r.userId,entitlement:r.entitlement,error:r.err})}catch(r){return this.logger.debug(`Datastream checkFlags falling back to API (${r})`),null}return this.logger.debug(`All ${i.length} flags evaluated via DataStream`),t}async close(){return this.datastreamClient&&this.datastreamClient.close(),this.eventBuffer.stop()}async identify(o,i){if(!this.offline)try{await this.enqueueEvent("identify",o,i)}catch(t){this.logger.error(`Error sending identify event: ${t}`)}}async track(o,i){if(!this.offline)try{if(await this.enqueueEvent("track",o,i),o.company&&this.useDataStream()&&this.datastreamClient.isConnected())try{await this.datastreamClient.updateCompanyMetrics(o.company,o.event,o.quantity||1)}catch(t){this.logger.error(`Failed to update company metrics: ${t}`)}}catch(t){this.logger.error(`Error sending track event: ${t}`)}}setFlagDefault(o,i){this.flagDefaults[o]=i}setFlagDefaults(o){Object.assign(this.flagDefaults,o)}getFlagDefault(o){return this.flagDefaults[o]??!1}async enqueueEvent(o,i,t){try{let s={eventType:o,body:i,sentAt:new Date};t&&(t.idempotencyKey!==void 0&&(s.idempotencyKey=t.idempotencyKey),"sentAt"in t&&t.sentAt!==void 0&&(s.sentAt=t.sentAt),"trustedClientClock"in t&&t.trustedClientClock!==void 0&&(s.trustedClientClock=t.trustedClientClock),"backfill"in t&&t.backfill!==void 0&&(s.backfill=t.backfill)),this.eventBuffer.push(s)}catch(s){this.logger.error(`Error enqueueing ${o} event: ${s}`)}}};var Nt=ao(require("crypto")),In="X-Schematic-Webhook-Signature",Fn="X-Schematic-Webhook-Timestamp",lr=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 $t(p,o,i){let t=Buffer.isBuffer(p)?p:Buffer.from(p),s=Buffer.concat([t,Buffer.from(`+${o}`)]),r=Nt.createHmac("sha256",i);return r.update(s),r.digest()}function by(p,o,i){return $t(p,o,i).toString("hex")}function Kn(p,o,i,t){if(!o)throw lr.missingSignature();if(!i)throw lr.missingTimestamp();let s;try{s=Buffer.from(o,"hex")}catch(n){throw new lr(`Invalid signature format: ${n?.message||"Unknown error"}`)}let r=$t(p,i,t);if(s.length!==r.length||!Nt.timingSafeEqual(s,r))throw lr.invalidSignature()}function zy(p,o,i,t={}){let s=p.headers,r=t.signatureHeader||In,n=t.timestampHeader||Fn,d=wy(s,r),g=wy(s,n),h;if(i!==void 0)h=i;else if("rawBody"in p&&p.rawBody)h=p.rawBody;else throw new lr("Request body is not available. Provide the body as a parameter or ensure req.rawBody exists.");Kn(h,d,g,o)}function wy(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});
1
+ "use strict";var vw=Object.create;var _t=Object.defineProperty;var Tw=Object.getOwnPropertyDescriptor;var Ow=Object.getOwnPropertyNames;var kw=Object.getPrototypeOf,Bw=Object.prototype.hasOwnProperty;var ci=(p,t)=>()=>(p&&(t=p(p=0)),t);var jw=(p,t)=>()=>(t||p((t={exports:{}}).exports,t),t.exports),yr=(p,t)=>{for(var i in t)_t(p,i,{get:t[i],enumerable:!0})},fs=(p,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ow(t))!Bw.call(p,s)&&s!==i&&_t(p,s,{get:()=>t[s],enumerable:!(o=Tw(t,s))||o.enumerable});return p};var et=(p,t,i)=>(i=p!=null?vw(kw(p)):{},fs(t||!p||!p.__esModule?_t(i,"default",{value:p,enumerable:!0}):i,p)),_s=p=>fs(_t({},"__esModule",{value:!0}),p);var Ws={};yr(Ws,{Node18UniversalStreamWrapper:()=>Oa});var Oa,Ns=ci(()=>{"use strict";Oa=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 Hs={};yr(Hs,{UndiciStreamWrapper:()=>ka});var ka,$s=ci(()=>{"use strict";ka=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 Js={};yr(Js,{NodePre18StreamWrapper:()=>Ba});var Ba,Ys=ci(()=>{"use strict";Ba=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 Xi,ds=ci(()=>{"use strict";Xi=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 ow=jw((Nre,eR)=>{eR.exports={name:"@schematichq/schematic-typescript-node",version:"1.5.0",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 aw,nw,sw,cw=ci(()=>{"use strict";aw=ow(),nw=aw.name,sw=aw.version});var uw={};yr(uw,{DatastreamWSClient:()=>gs});function nR(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 lw,rR,pw,iR,tR,oR,aR,gs,dw=ci(()=>{"use strict";lw=et(require("ws"));cw();ds();rR=10*1e3,pw=60*1e3,iR=pw*9/10,tR=10,oR=1*1e3,aR=30*1e3;gs=class extends Xi{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=nR(i.url):this.url=i.url,this.headers={"X-Schematic-Api-Key":i.apiKey,"X-Schematic-Client":nw,"X-Schematic-Client-Version":sw,"X-Schematic-Datastream-Mode":"datastream"},this.logger=i.logger,this.messageHandler=i.messageHandler,this.connectionReadyHandler=i.connectionReadyHandler,this.maxReconnectAttempts=i.maxReconnectAttempts??tR,this.minReconnectDelay=i.minReconnectDelay??oR,this.maxReconnectDelay=i.maxReconnectDelay??aR}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"))},rR);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 lw.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()},iR),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()},pw),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:()=>ei,LocalCache:()=>rr,LogLevel:()=>er,RedisCacheProvider:()=>ii,RulesEngineClient:()=>Zi,Schematic:()=>ae,SchematicClient:()=>Pa,SchematicEnvironment:()=>z,SchematicError:()=>b,SchematicTimeoutError:()=>ri,WEBHOOK_SIGNATURE_HEADER:()=>bs,WEBHOOK_TIMESTAMP_HEADER:()=>zs,WebhookSignatureError:()=>mr,computeHexSignature:()=>Cw,computeSignature:()=>Ca,verifySignature:()=>Rs,verifyWebhookSignature:()=>Ew});module.exports=_s(VR);var ae={};yr(ae,{AccountMemberPermission:()=>Vw,AccountMemberRole:()=>qw,ActorType:()=>Mw,ApiKeyScope:()=>Dw,BadRequestError:()=>T,BillingCreditBundleStatus:()=>Iw,BillingCreditBurnStrategy:()=>Fw,BillingCreditExpiryType:()=>Kw,BillingCreditExpiryUnit:()=>Lw,BillingCreditGrantReason:()=>Gw,BillingCreditGrantZeroedOutReason:()=>Ww,BillingCreditLedgerAuthority:()=>Nw,BillingCreditRolloverPolicy:()=>Hw,BillingPlanCreditGrantResetCadence:()=>$w,BillingPlanCreditGrantResetStart:()=>Jw,BillingPlanCreditGrantResetType:()=>Yw,BillingPriceScheme:()=>Zw,BillingPriceUsageType:()=>Xw,BillingProductPriceInterval:()=>Qw,BillingProviderType:()=>eb,BillingStrategy:()=>rb,BillingSubscriptionTrialEndSetting:()=>ib,BillingTiersMode:()=>tb,ChargeType:()=>ob,CompanyMatchingCriteria:()=>ab,CompanyPlanInvalidReason:()=>nb,ComparableOperator:()=>sb,ComponentEntityType:()=>cb,ComponentState:()=>lb,ConditionType:()=>pb,CreditEventType:()=>ub,CreditGrantSortOrder:()=>db,CreditLedgerPeriod:()=>mb,CreditUsageReason:()=>hb,CustomPlanActivationStrategy:()=>gb,CustomPlanBillingStatus:()=>yb,DataExportStatus:()=>wb,EntitlementPriceBehavior:()=>bb,EntitlementType:()=>zb,EntitlementValueType:()=>Rb,EntityType:()=>fb,EnvironmentType:()=>_b,EventStatus:()=>Sb,EventType:()=>St,FeatureLifecyclePhase:()=>Pb,FeatureType:()=>xb,ForbiddenError:()=>R,IntegrationState:()=>Cb,IntegrationType:()=>Eb,InternalServerError:()=>f,InvoiceStatus:()=>Ub,MetricPeriod:()=>vb,MetricPeriodMonthReset:()=>Tb,MigrationErrorCode:()=>Ob,NotFoundError:()=>_,PlanBundleAction:()=>kb,PlanChangeAction:()=>Bb,PlanChangeBasePlanAction:()=>jb,PlanChangeSubscriptionAction:()=>Ab,PlanIcon:()=>Vb,PlanPriceCadence:()=>qb,PlanType:()=>Mb,PlanVersionCompanyMigrationStatus:()=>Db,PlanVersionMigrationStatus:()=>Ib,PlanVersionMigrationStrategy:()=>Fb,PlanVersionStatus:()=>Kb,ProrationBehavior:()=>Lb,RuleType:()=>Xb,RulesEngineSchemaVersion:()=>Gb,RulesengineConditionType:()=>Wb,RulesengineEntitlementValueType:()=>Nb,RulesengineEntityType:()=>Hb,RulesengineMetricPeriod:()=>$b,RulesengineMetricPeriodMonthReset:()=>Jb,RulesengineRuleType:()=>Yb,RulesengineTraitDefinitionComparableType:()=>Zb,ScheduledCheckoutStatus:()=>Qb,ScheduledDowngradeConfigBehavior:()=>ez,SortDirection:()=>rz,SubscriptionStatus:()=>iz,SubscriptionType:()=>tz,TimeSeriesGranularity:()=>oz,TraitDefinitionComparableType:()=>az,TraitType:()=>nz,TrialStatus:()=>sz,UnauthorizedError:()=>S,WebhookEventStatus:()=>cz,WebhookRequestType:()=>lz,WebhookStatus:()=>pz,accesstokens:()=>Ss,accounts:()=>Ps,billing:()=>xs,checkout:()=>Cs,companies:()=>Es,components:()=>Us,componentspublic:()=>vs,credits:()=>Ts,dataexports:()=>Os,entitlements:()=>ks,events:()=>Bs,features:()=>js,insights:()=>As,integrationsapi:()=>Vs,planbundle:()=>qs,plangroups:()=>Ms,planmigrations:()=>Ds,plans:()=>Is,scheduledcheckout:()=>Fs,webhooks:()=>Ks});var ve=(p,t,i)=>JSON.stringify(p,t,i);function rt(p,t){return JSON.parse(p,t)}var b=class extends Error{constructor({message:t,statusCode:i,body:o,rawResponse:s,cause:r}){super(Aw({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 Aw({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 ri=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 T=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 R=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 f=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 _=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 S=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 Ss={};var Ps={};var xs={};var Cs={};var Es={};var Us={};var vs={};var Ts={};var Os={};var ks={};var Bs={};var js={};var As={};var Vs={};var qs={};var Ms={};var Ds={};var Is={};var Fs={};var Ks={};var Vw={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 qw={Admin:"admin",Member:"member"};var Mw={ApiKey:"api_key",AppUser:"app_user",StripeApp:"stripe_app",System:"system",TemporaryAccessToken:"temporary_access_token"};var Dw={Admin:"admin",Capture:"capture",Read:"read",Write:"write"};var Iw={Active:"active",Inactive:"inactive"};var Fw={ExpirationPriority:"expiration_priority",FirstInFirstOut:"first_in_first_out",LastInFirstOut:"last_in_first_out",PlanFirstThenCreditBundlesFirstInFirstOut:"plan_first_then_credit_bundles_first_in_first_out"};var Kw={Duration:"duration",EndOfBillingPeriod:"end_of_billing_period",EndOfNextBillingPeriod:"end_of_next_billing_period",EndOfTrial:"end_of_trial",NoExpiry:"no_expiry"};var Lw={BillingPeriods:"billing_periods",Days:"days"};var Gw={Adjustment:"adjustment",BillingCreditAutoTopup:"billing_credit_auto_topup",Free:"free",Plan:"plan",Purchased:"purchased",Rollover:"rollover"};var Ww={Expired:"expired",Manual:"manual",PlanChange:"plan_change",PlanPeriodReset:"plan_period_reset"};var Nw={SchematicAuthoritative:"schematic_authoritative",ExternalMirror:"external_mirror",ExternalRated:"external_rated"};var Hw={Expire:"expire",None:"none",Rollover:"rollover"};var $w={Daily:"daily",Monthly:"monthly",Weekly:"weekly",Yearly:"yearly"};var Jw={BillingPeriod:"billing_period",FirstOfMonth:"first_of_month"};var Yw={NoReset:"no_reset",PlanPeriod:"plan_period"};var Zw={PerUnit:"per_unit",Tiered:"tiered"};var Xw={Licensed:"licensed",Metered:"metered"};var Qw={Day:"day",Month:"month",OneTime:"one-time",Year:"year"};var eb={Metronome:"metronome",Orb:"orb",Schematic:"schematic",Stripe:"stripe"};var rb={SchematicManaged:"schematic_managed",ProviderManaged:"provider_managed",NoBilling:"no_billing"};var ib={Cancel:"cancel",Subscribe:"subscribe"};var tb={Graduated:"graduated",Volume:"volume"};var ob={Free:"free",None:"none",OneTime:"one_time",Recurring:"recurring"};var ab={BillingMetaObject:"billing_meta_object",ManualUpsert:"manual_upsert"};var nb={DowngradeNotPermitted:"downgrade_not_permitted",FeatureUsageExceeded:"feature_usage_exceeded"};var sb={Eq:"eq",Gt:"gt",Gte:"gte",IsEmpty:"is_empty",Lt:"lt",Lte:"lte",NotEmpty:"not_empty",Ne:"ne"};var cb={Billing:"billing",Entitlement:"entitlement"};var lb={Draft:"draft",Live:"live"};var pb={BasePlan:"base_plan",BillingProduct:"billing_product",Company:"company",Credit:"credit",Metric:"metric",Plan:"plan",PlanVersion:"plan_version",Trait:"trait",User:"user"};var ub={Grant:"grant",Transfer:"transfer",Usage:"usage",ZeroOut:"zero_out"};var db={CreatedAt:"created_at",ExpiresAt:"expires_at",Quantity:"quantity",QuantityRemaining:"quantity_remaining"};var mb={Daily:"daily",Monthly:"monthly",Raw:"raw",Weekly:"weekly"};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 St={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 Cb={Active:"active",Created:"created",Pending:"pending"};var Eb={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 Mb={Plan:"plan",AddOn:"add_on"};var Db={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 Nb={Boolean:"boolean",Credit:"credit",Numeric:"numeric",Trait:"trait",Unknown:"unknown",Unlimited:"unlimited"};var Hb={Company:"company",User:"user"};var $b={AllTime:"all_time",CurrentDay:"current_day",CurrentMonth:"current_month",CurrentWeek:"current_week"};var Jb={BillingCycle:"billing_cycle",FirstOfMonth:"first_of_month"};var Yb={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Zb={Bool:"bool",Date:"date",Int:"int",String:"string"};var Xb={CompanyOverride:"company_override",CompanyOverrideUsageExceeded:"company_override_usage_exceeded",Default:"default",GlobalOverride:"global_override",PlanEntitlement:"plan_entitlement",PlanEntitlementUsageExceeded:"plan_entitlement_usage_exceeded",Standard:"standard"};var Qb={Cancelled:"cancelled",Error:"error",Executing:"executing",Pending:"pending",Success:"success"};var ez={EndOfBillingPeriod:"end_of_billing_period",None:"none"};var rz={Asc:"asc",Desc:"desc"};var iz={Active:"active",Canceled:"canceled",Expired:"expired",Incomplete:"incomplete",IncompleteExpired:"incomplete_expired",PastDue:"past_due",Paused:"paused",Trialing:"trialing",Unpaid:"unpaid"};var tz={Free:"free",OneTime:"one_time",Paid:"paid",Trial:"trial"};var oz={Daily:"daily",Hourly:"hourly",Monthly:"monthly",Weekly:"weekly"};var az={Bool:"bool",Date:"date",Int:"int",String:"string"};var nz={Boolean:"boolean",Currency:"currency",Date:"date",Number:"number",String:"string",Url:"url"};var sz={Active:"active",Converted:"converted",Expired:"expired"};var cz={Failure:"failure",Pending:"pending",Success:"success"};var lz={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 pz={Active:"active",Inactive:"inactive"};var uz=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,uz)),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 ii=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 Ua(p){return typeof p=="object"&&p!==null&&"getAuthRequest"in p&&typeof p.getAuthRequest=="function"}var li=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var Pt={get:async(p,t)=>typeof p=="function"?p(t):p};var Je={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Ls={[Je.Debug]:1,[Je.Info]:2,[Je.Warn]:3,[Je.Error]:4},it=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)}},pi=class{constructor(t){this.level=Ls[t.level],this.logger=t.logger,this.silent=t.silent}shouldLog(t){return!this.silent&&this.level<=Ls[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 tt(p){return p==null?dz:p instanceof pi?p:(p=p??{},p.level??=Je.Info,p.logger??=new it,p.silent??=!0,new pi(p))}var dz=new pi({level:Je.Info,logger:new it,silent:!0});var mz={arrayFormat:"indices",encode:!0};function va(p,t){if(p===void 0||p===null)return"";let i=String(p);return t?encodeURIComponent(i):i}function Ta(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=>va(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(...Ta(h,c,i))}else{let c=u==="indices"?`${a}[${g}]`:a,y=i.encode?encodeURIComponent(c):c;o.push(`${y}=${va(h,i.encode)}`)}}}else if(typeof r=="object"&&r!==null){if(Object.keys(r).length===0)continue;o.push(...Ta(r,a,i))}else{let u=i.encode?encodeURIComponent(a):a;o.push(`${u}=${va(r,i.encode)}`)}}return o}function wr(p,t){return p==null||typeof p!="object"?"":Ta(p,"",{...mz,...t}).join("&")}function xt(p,t){let i=wr(t,{arrayFormat:"repeat"});return i?`${p}?${i}`:p}function Gs(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=hz();function hz(){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 Zs(p){return fe.type==="node"&&fe.parsedVersion!=null&&fe.parsedVersion>=18?new(await Promise.resolve().then(()=>(Ns(),Ws))).Node18UniversalStreamWrapper(p):fe.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>($s(),Hs))).UndiciStreamWrapper(p):new(await Promise.resolve().then(()=>(Ys(),Js))).NodePre18StreamWrapper(p)}async function ui(p,t){switch(t){case"binary-response":return Gs(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}}:Zs(p.body);case"text":return await p.text()}let i=await p.text();if(i.length>0)try{return rt(i)}catch{return{ok:!1,error:{reason:"non-json",statusCode:p.status,rawBody:i}}}}async function Xs(p){let t=p.headers.get("Content-Type")?.toLowerCase();if(t==null||t.length===0)return ui(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?rt(i):void 0}default:if(t.startsWith("application/vnd.")&&t.endsWith("+json")){let i=await p.text();return i.length>0?rt(i):void 0}return await p.text()}}async function di(){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 Ct({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 Qs{constructor(t){if(this.headers=new Map,t)if(t instanceof Qs)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 gz="timeout";function ec(p){let t=new AbortController,i=setTimeout(()=>t.abort(gz),p);return{signal:t.signal,abortId:i}}function rc(...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 ot;function yz(){if(ot!=null)return ot;try{new Request("http://localhost",{cache:"no-store"}),ot=!0}catch{ot=!1}return ot}var mi=async(p,t,i,o,s,r,a,u,g,h)=>{let c=[],y;if(r!=null){let{signal:v,abortId:O}=ec(r);y=O,c.push(v)}a!=null&&c.push(a);let w=rc(c),U=await p(t,{method:i,headers:o,body:s,signal:w,credentials:u?"include":void 0,duplex:g,...h&&yz()?{cache:"no-store"}:{}});return y!=null&&clearTimeout(y),U};var hi={headers:new ir,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},gi={headers:new ir,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function at(p){return{headers:p.headers,redirected:p.redirected,status:p.status,statusText:p.statusText,type:p.type,url:p.url}}function wz(p){return[408,429].includes(p)||p>=500}function bz(p){let t=1+Math.random()*.2;return p*t}function zz(p){let t=1+(Math.random()-.5)*.2;return p*t}function Rz(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 bz(Math.min(r,6e4))}}return zz(Math.min(1e3*2**t,6e4))}async function yi(p,t=2){let i=await p();for(let o=0;o<t&&wz(i.status);++o){let s=Rz(i,o);await new Promise(r=>setTimeout(r,s)),i=await p()}return i}var fz=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 ja(p){let t={};for(let[i,o]of p instanceof ir?p.entries():Object.entries(p))fz.has(i.toLowerCase())?t[i]="[REDACTED]":t[i]=o;return t}var Aa=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 _z(p){if(p==null)return;let t={};for(let[i,o]of Object.entries(p))t[i]=Aa.has(i.toLowerCase())?"[REDACTED]":o;return t}function ti(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 v=i;v<a;v++)p[v]==="@"&&(u=v);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 v of U){let O=v.indexOf("=");if(O===-1){w.push(v);continue}let j=v.slice(0,O),B=Aa.has(j.toLowerCase());if(!B&&j.includes("%"))try{let I=decodeURIComponent(j);B=Aa.has(I.toLowerCase())}catch{}w.push(B?`${j}=[REDACTED]`:v)}return p.slice(0,s+1)+w.join("&")+p.slice(g)}async function Sz(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 Pt.get(o,{endpointMetadata:p.endpointMetadata??{}});if(typeof s=="string"){t.set(i,s);continue}s!=null&&t.set(i,`${s}`)}return t}async function Pz(p){let t=p.url;p.queryString!=null&&p.queryString.length>0?t=`${t}?${p.queryString}`:t=xt(p.url,p.queryParameters);let i=await Ct({body:p.body,type:p.requestType??"other"}),o=p.fetchFn??await di(),s=await Sz(p),r=tt(p.logging);if(r.isDebug()){let a={method:p.method,url:ti(t),headers:ja(s),queryParameters:_z(p.queryParameters),hasBody:i!=null};r.debug("Making HTTP request",a)}try{let a=await yi(async()=>mi(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:ti(t),statusCode:a.status,responseHeaders:ja(a.headers)};r.debug("HTTP request succeeded",g)}return{ok:!0,body:await ui(a,p.responseType),headers:a.headers,rawResponse:at(a)}}else{if(r.isError()){let u={method:p.method,url:ti(t),statusCode:a.status,responseHeaders:ja(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 Xs(a)},rawResponse:at(a)}}}catch(a){if(p.abortSignal?.aborted){if(r.isError()){let u={method:p.method,url:ti(t)};r.error("HTTP request was aborted",u)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:a},rawResponse:hi}}else if(a instanceof Error&&a.name==="AbortError"){if(r.isError()){let u={method:p.method,url:ti(t),timeoutMs:p.timeoutMs};r.error("HTTP request timed out",u)}return{ok:!1,error:{reason:"timeout",cause:a},rawResponse:hi}}else if(a instanceof Error){if(r.isError()){let u={method:p.method,url:ti(t),errorMessage:a.message};r.error("HTTP request failed with error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:a.message,cause:a},rawResponse:gi}}if(r.isError()){let u={method:p.method,url:ti(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:gi}}}var C=Pz;var P=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 ic(p,...t)}let s=t[t.length-1]?.endsWith("/");for(let r of t){let a=oc(r);a&&(i.pathname=tc(i.pathname,a))}return s&&!i.pathname.endsWith("/")&&(i.pathname+="/"),i.toString()}return ic(p,...t)}function ic(p,...t){if(t.length===0)return p;let i=p,s=t[t.length-1]?.endsWith("/");for(let r of t){let a=oc(r);a&&(i=tc(i,a))}return s&&!i.endsWith("/")&&(i+="/"),i}function tc(p,t){return p.endsWith("/")?p+t:`${p}/${t}`}function oc(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 Va(p,t,i,o){let s=tt(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 Pt.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,v=o?.maxRetries??i.maxRetries,O=o?.abortSignal??a?.signal??void 0,j=i.fetch??await di();s.isDebug()&&s.debug("Making passthrough HTTP request",{method:c,url:g,hasBody:y!=null});let B=await yi(async()=>mi(j,g,c,h,y??void 0,U,O,a?.credentials==="include",void 0,!1),v);return s.isDebug()&&s.debug("Passthrough HTTP request completed",{method:c,url:g,statusCode:B.status}),B}var Ut={};yr(Ut,{ConsoleLogger:()=>it,LogLevel:()=>Je,Logger:()=>pi,createLogger:()=>tt});var e={};yr(e,{JsonError:()=>wi,ParseError:()=>bi,any:()=>zc,bigint:()=>nc,boolean:()=>Rc,booleanLiteral:()=>wc,date:()=>sc,discriminant:()=>Tc,enum_:()=>nt,forwardCompatibleEnum_:()=>cc,getObjectLikeUtils:()=>Ye,getObjectUtils:()=>oi,getSchemaUtils:()=>Y,isProperty:()=>zr,lazy:()=>lc,lazyObject:()=>gc,list:()=>Ot,never:()=>fc,number:()=>_c,object:()=>Tt,objectWithoutOptionalProperties:()=>hc,optional:()=>qa,partialRecord:()=>Cc,property:()=>uc,record:()=>xc,set:()=>Ec,string:()=>Sc,stringLiteral:()=>bc,transform:()=>Ma,undiscriminatedUnion:()=>vc,union:()=>kc,unknown:()=>Pc,withParsedProperties:()=>Fa});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 ${xz(p)}.`}function xz(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:ac(p.json),parse:ac(p.parse)}}function ac(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 vt(p){return p.path.length===0?p.message:`${p.path.join(" -> ")}: ${p.message}`}var wi=class extends Error{constructor(i){super(i.map(vt).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};var bi=class extends Error{constructor(i){super(i.map(vt).join("; "));this.errors=i;Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};function Y(p){return{nullable:()=>Cz(p),optional:()=>qa(p),optionalNullable:()=>Ez(p),transform:t=>Ma(p,t),parseOrThrow:(t,i)=>{let o=p.parse(t,i);if(o.ok)return o.value;throw new bi(o.errors)},jsonOrThrow:(t,i)=>{let o=p.json(t,i);if(o.ok)return o.value;throw new wi(o.errors)}}}function Cz(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 qa(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 Ez(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 Ma(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 nc(){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 Uz=/^([+-]?\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 sc(){let p={parse:(t,{breadcrumbsPrefix:i=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:i,message:J(t,"string")}]}:Uz.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 nt(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 cc(p){return nt(p).transform({transform:t=>t,untransform:t=>t})}function lc(p){let t=Da(p);return{...t,...Y(t)}}function Da(p){return{parse:(t,i)=>zi(p).parse(t,i),json:(t,i)=>zi(p).json(t,i),getType:()=>zi(p).getType()}}function zi(p){let t=p;return t.__zurg_memoized==null&&(t.__zurg_memoized=p()),t.__zurg_memoized}function Ia(p){return Object.entries(p)}function st(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 ct(p){return Object.keys(p)}function pc(p,t){let i=[],o=[];for(let s of p)t(s)?i.push(s):o.push(s);return[i,o]}var vz=Object.prototype.hasOwnProperty;function Ye(p){return{withParsedProperties:t=>Fa(p,t)}}function Fa(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(vz.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=st(o,Object.keys(o).filter(u=>!r.has(u)));return p.json(a,s)},getType:()=>p.getType()};return{...i,...Y(i),...Ye(i)}}function uc(p,t){return{rawKey:p,valueSchema:t,isProperty:!0}}function zr(p){return p.isProperty}var Tz=Object.prototype.hasOwnProperty;function Tt(p){let t;function i(){if(t==null){t={};for(let[w,U]of Ia(p)){let v=zr(U)?U.rawKey:w,O=zr(U)?U.valueSchema:U;t[v]={rawKey:v,parsedKey:w,valueSchema:O}}}return t}let o,s,r,a;function u(){if(o==null){o=[],s=[];for(let[w,U]of Ia(p)){let v=zr(U)?U.rawKey:w,O=zr(U)?U.valueSchema:U;Oz(O)&&(o.push(v),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:()=>ct(p),parse:(w,U)=>{let v=U?.breadcrumbsPrefix??[];return dc({value:w,requiredKeys:u(),requiredKeysSet:h(),getProperty:O=>{let j=i()[O];if(j!=null)return{transformedKey:j.parsedKey,transform:B=>{let I=[...v,O];return j.valueSchema.parse(B,{...U,breadcrumbsPrefix:I})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:v,omitUndefined:U?.omitUndefined})},json:(w,U)=>{let v=U?.breadcrumbsPrefix??[];return dc({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=[...v,O];return j.valueSchema.json(B,{...U,breadcrumbsPrefix:I})}}:{transformedKey:O,transform:B=>{let I=[...v,O];return j.json(B,{...U,breadcrumbsPrefix:I})}}},unrecognizedObjectKeys:U?.unrecognizedObjectKeys,skipValidation:U?.skipValidation,breadcrumbsPrefix:v,omitUndefined:U?.omitUndefined})},getType:()=>D.OBJECT};return{...ye(y),...Y(y),...Ye(y),...oi(y)}}function dc({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(!Tz.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 oi(p){return{extend:t=>{let i={_getParsedProperties:()=>[...p._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...p._getRawProperties(),...t._getRawProperties()],parse:(o,s)=>mc({extensionKeys:t._getRawProperties(),value:o,transformBase:r=>p.parse(r,s),transformExtension:r=>t.parse(r,s),breadcrumbsPrefix:s?.breadcrumbsPrefix}),json:(o,s)=>mc({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),...oi(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),...oi(o)}}}}function mc({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]=pc(ct(t),c=>r.has(c)),g=i(st(t,u)),h=o(st(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 Oz(p){return!kz(p)}function kz(p){switch(p.getType()){case D.ANY:case D.UNKNOWN:case D.OPTIONAL:case D.OPTIONAL_NULLABLE:return!0;default:return!1}}function hc(p){return Tt(p)}function gc(p){let t={...Da(p),_getRawProperties:()=>zi(p)._getRawProperties(),_getParsedProperties:()=>zi(p)._getParsedProperties()};return{...t,...Y(t),...Ye(t),...oi(t)}}function Ot(p){let t={parse:(i,o)=>yc(i,(s,r)=>p.parse(s,{...o,breadcrumbsPrefix:[...o?.breadcrumbsPrefix??[],`[${r}]`]})),json:(i,o)=>yc(i,(s,r)=>p.json(s,{...o,breadcrumbsPrefix:[...o?.breadcrumbsPrefix??[],`[${r}]`]})),getType:()=>D.LIST};return{...ye(t),...Y(t)}}function yc(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 wc(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 bc(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 zc=be(D.ANY,p=>({ok:!0,value:p}));var Rc=be(D.BOOLEAN,(p,{breadcrumbsPrefix:t=[]}={})=>typeof p=="boolean"?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(p,"boolean")}]});var fc=be(D.NEVER,(p,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var _c=be(D.NUMBER,(p,{breadcrumbsPrefix:t=[]}={})=>typeof p=="number"?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(p,"number")}]});var Sc=be(D.STRING,(p,{breadcrumbsPrefix:t=[]}={})=>typeof p=="string"?{ok:!0,value:p}:{ok:!1,errors:[{path:t,message:J(p,"string")}]});var Pc=be(D.UNKNOWN,p=>({ok:!0,value:p}));var Bz=Object.prototype.hasOwnProperty;function xc(p,t){let i={parse:(o,s)=>kt({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)=>kt({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 Cc(p,t){let i={parse:(o,s)=>kt({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)=>kt({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 kt({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(!Bz.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 Ec(p){let t=Ot(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 vc(p){let t={parse:(i,o)=>Uc((s,r)=>s.parse(i,r),p,o),json:(i,o)=>Uc((s,r)=>s.json(i,r),p,o),getType:()=>D.UNDISCRIMINATED_UNION};return{...ye(t),...Y(t)}}function Uc(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 Tc(p,t){return{parsedDiscriminant:p,rawDiscriminant:t}}var jz=Object.prototype.hasOwnProperty;function kc(p,t){let i=typeof p=="string"?p:p.rawDiscriminant,o=typeof p=="string"?p:p.parsedDiscriminant,s=nt(ct(t)),r={parse:(a,u)=>Oc({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)=>Oc({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 Oc({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)jz.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:()=>Bc,join:()=>Et,queryBuilder:()=>jc,toQueryString:()=>wr});function Bc(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 jc(){return new Ka}var Ka=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 La="apiKey",Az="X-Schematic-Api-Key",Ri=class p{constructor(t){this.options=t}static canCreate(t){return t?.[La]!=null}async getAuthRequest({endpointMetadata:t}={}){let i=await m.get(this.options[La]);if(i==null)throw new b({message:p.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[Az]:i}}}};(o=>{o.AUTH_SCHEME="ApiKeyAuth",o.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${La}' when initializing the client`;function i(s){return new o(s)}o.createInstance=i})(Ri||={});function x(...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=x({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@schematichq/schematic-typescript-node","X-Fern-SDK-Version":"1.5.0","User-Agent":"@schematichq/schematic-typescript-node/1.5.0","X-Fern-Runtime":fe.type,"X-Fern-Runtime-Version":fe.version},p?.headers);return{...p,logging:Ut.createLogger(p?.logging),headers:t}}function K(p){let t=Vz(p);if(p.auth===!1)return t.authProvider=new li,t;if(p.auth!=null){if(typeof p.auth=="function")return t.authProvider={getAuthRequest:p.auth},t;if(Ua(p.auth))return t.authProvider=p.auth,t;Object.assign(t,p.auth)}let i=qz(t);return t.authProvider??=new Ri(i),t}function qz(p){return{...p,authProvider:new li}}var z={Default:"https://api.schematichq.com"};function E(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 ri(`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 Ga=e.object({lookup:e.record(e.string(),e.string())});var Ac=e.stringLiteral("company");var Vc=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",Ac),token:e.string(),updatedAt:e.property("updated_at",e.date())});var qc=e.object({data:Vc,params:e.record(e.string(),e.unknown())});var Wa=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 Na=e.object({environmentType:e.property("environment_type",Ur),name:e.string()});var Ha=e.object({description:e.string().optional(),name:e.string().optional()});var $a=e.object({environmentType:e.property("environment_type",Ur.optional()),name:e.string().optional()});var Mc=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 Dc=e.object({data:V,params:Mc});var Ic=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 Fc=e.object({data:V,params:Ic});var Ce=e.enum_(["api_key","app_user","stripe_app","system","temporary_access_token"]);var Kc=e.object({actorType:e.property("actor_type",Ce.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var Lc=e.object({data:V,params:Kc});var qe=e.enum_(["active","created","pending"]);var Se=e.enum_(["clerk","metronome","orb","stripe","unknown","workos"]);var Bt=e.object({id:e.string(),state:qe,type:Se});var jt=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 Gc=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:Bt.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(jt),secret:e.string(),updatedAt:e.property("updated_at",e.date())});var Wc=e.object({data:Gc,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:Bt.optional(),lastUsedAt:e.property("last_used_at",e.date().optional()),name:e.string(),readonly:e.boolean(),scopes:e.list(jt),updatedAt:e.property("updated_at",e.date())});var Nc=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 Hc=e.object({data:Nc,params:e.record(e.string(),e.unknown())});var L=e.object({deleted:e.boolean().optional()});var $c=e.object({data:L,params:e.record(e.string(),e.unknown())});var Jc=e.object({data:L,params:e.record(e.string(),e.unknown())});var Yc=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 Zc=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(Yc)),role:Zc.optional(),updatedAt:e.property("updated_at",e.date())});var Xc=e.object({data:vr,params:e.record(e.string(),e.unknown())});var Qc=e.object({data:xe,params:e.record(e.string(),e.unknown())});var el=e.object({actorType:e.property("actor_type",Ce),apiKey:e.property("api_key",xe.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),reqBody:e.property("req_body",e.string().optional()),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respBody:e.property("resp_body",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var rl=e.object({data:el,params:e.record(e.string(),e.unknown())});var il=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var tl=e.object({accountId:e.property("account_id",e.string()),accountName:e.property("account_name",e.string()),actorType:e.property("actor_type",Ce),apiKeyId:e.property("api_key_id",e.string().optional()),environmentId:e.property("environment_id",e.string().optional()),environments:e.list(Pe),stripeUserId:e.property("stripe_user_id",e.string().optional()),userId:e.property("user_id",e.string().optional()),userName:e.property("user_name",e.string().optional())});var ol=e.object({data:tl,params:e.record(e.string(),e.unknown())});var al=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var nl=e.object({data:e.list(vr),params:al});var sl=e.object({environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),requireEnvironment:e.property("require_environment",e.boolean().optional())});var cl=e.object({data:e.list(xe),params:sl});var ll=e.object({actorType:e.property("actor_type",Ce.optional()),endTime:e.property("end_time",e.date().optional()),environmentId:e.property("environment_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),startTime:e.property("start_time",e.date().optional())});var At=e.object({actorType:e.property("actor_type",Ce),apiKey:e.property("api_key",xe.optional()),apiKeyId:e.property("api_key_id",e.string().optional()),endedAt:e.property("ended_at",e.date().optional()),environment:Pe.optional(),environmentId:e.property("environment_id",e.string().optional()),id:e.string(),method:e.string(),resourceId:e.property("resource_id",e.number().optional()),resourceIdString:e.property("resource_id_string",e.string().optional()),resourceName:e.property("resource_name",e.string().optional()),resourceType:e.property("resource_type",e.string().optional()),respCode:e.property("resp_code",e.number().optional()),secondaryResource:e.property("secondary_resource",e.string().optional()),startedAt:e.property("started_at",e.date()),url:e.string(),userName:e.property("user_name",e.string().optional())});var pl=e.object({data:e.list(At),params:ll});var ul=e.object({ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional()});var dl=e.object({data:e.list(Pe),params:ul});var ml=e.object({ok:e.boolean()});var hl=e.object({data:ml,params:e.record(e.string(),e.unknown())});var gl=e.object({data:xe,params:e.record(e.string(),e.unknown())});var yl=e.object({data:Pe,params:e.record(e.string(),e.unknown())});var k=e.enum_(["metronome","orb","schematic","stripe"]);var Ja=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 de=e.enum_(["graduated","volume"]);var wl=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 Ya=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(wl)),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",se)});var Za=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 bl=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 zl=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 Xa=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(zl),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(bl)),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 Qa=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 Vt=e.enum_(["draft","open","paid","uncollectible","void"]);var en=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:Vt.optional(),subscriptionExternalId:e.property("subscription_external_id",e.string().optional()),subtotal:e.number(),url:e.string().optional()});var rn=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 tn=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 Rl=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 fl=e.object({data:V,params:Rl});var _l=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 Sl=e.object({data:V,params:_l});var Pl=e.object({data:L,params:e.record(e.string(),e.unknown())});var xl=e.object({data:L,params:e.record(e.string(),e.unknown())});var Cl=e.object({data:L,params:e.record(e.string(),e.unknown())});var El=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",de.optional()),usageType:e.property("usage_type",se.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var fi=e.enum_(["day","month","one-time","year"]);var qt=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:fi,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(qt)),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",se)});var Ul=e.object({data:e.list(H),params:El});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(),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",se.optional()),withMeter:e.property("with_meter",e.boolean().optional())});var Tl=e.object({data:e.list(H),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",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:fi,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 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 Mt=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(Mt),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 Ml=e.object({data:e.list(ql),params:Al});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(),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:Vt.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(Ze),params:Dl});var Fl=e.object({displayName:e.property("display_name",e.string().optional()),limit:e.number().optional(),offset:e.number().optional()});var Dt=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(Dt),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 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 Gl=e.object({data:e.list(Xe),params:Ll});var Wl=e.object({data:Mt,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:Dt,params:e.record(e.string(),e.unknown())});var Jl=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 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:Ze,params:e.record(e.string(),e.unknown())});var ep=e.object({data:Xe,params:e.record(e.string(),e.unknown())});var on=e.object({cancelImmediately:e.property("cancel_immediately",e.boolean().optional()),companyId:e.property("company_id",e.string()),prorate:e.boolean().optional()});var an=e.object({companyId:e.property("company_id",e.string()),selectedPlanId:e.property("selected_plan_id",e.string().optional())});var nn=e.object({trialEnd:e.property("trial_end",e.date().optional())});var It=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(qt)),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 Ft=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 lt=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(Ft),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(It),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 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",$),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 ip=e.enum_(["schematic_authoritative","external_mirror","external_rated"]);var Br=e.enum_(["expire","none","rollover"]);var tp=e.object({currency:e.string(),price:H.optional()});var Kt=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(tp)),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",ip),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 _i=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var op=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:Kt.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:_i.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 sn=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(op)),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 Si=e.enum_(["on_payment","on_publish"]);var Rr=e.enum_(["active","expired","paid","pending"]);var jr=e.object({activationStrategy:e.property("activation_strategy",Si),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 Lt=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 Gt=e.object({createdAt:e.property("created_at",e.date()),definition:Lt.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 me=e.enum_(["boolean","currency","date","number","string","url"]);var he=e.object({createdAt:e.property("created_at",e.date()),displayName:e.property("display_name",e.string()),entityType:e.property("entity_type",te),hierarchy:e.list(e.string()),id:e.string(),traitType:e.property("trait_type",me),updatedAt:e.property("updated_at",e.date())});var Wt=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 re=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var Nt=e.object({allocation:e.number().optional(),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",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 Pi=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var ap=e.enum_(["bool","date","int","string"]);var cn=e.object({comparableType:e.property("comparable_type",ap),entityType:e.property("entity_type",te),id:e.string()});var Ht=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",cn.optional()),conditionType:e.property("condition_type",Pi),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",cn.optional()),traitValue:e.property("trait_value",e.string())});var np=e.object({conditions:e.list(Ht)});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(Ht),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 $t=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 Q=e.object({addOns:e.property("add_ons",e.list(sn)),billingCreditBalances:e.property("billing_credit_balances",e.record(e.string(),e.number()).optional()),billingSubscription:e.property("billing_subscription",lt.optional()),billingSubscriptions:e.property("billing_subscriptions",e.list(lt)),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(Nt),entityTraits:e.property("entity_traits",e.list(Wt)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Gt),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(Xe)),plan:sn.optional(),plans:e.list(_i),rules:e.list(sp),scheduledDowngrade:e.property("scheduled_downgrade",$t.optional()),traits:e.record(e.string(),e.unknown()).optional(),updatedAt:e.property("updated_at",e.date()),userCount:e.property("user_count",e.number())});var Jt=e.object({company:Q.optional(),success:e.boolean()});var cp=e.object({data:Jt,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: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(up)),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:Ee,unitPrice:e.property("unit_price",G.optional()),updatedAt:e.property("updated_at",e.date())});var Yt=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 xi=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(Ft),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(It),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 Oe=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 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:Q.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(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",re)});var Ci=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 Ei=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 Ui=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 Zt=e.object({description:e.string().optional(),id:e.string(),imageUrl:e.property("image_url",e.string().optional()),name:e.string()});var Xt=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",Pi),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(Zt),ruleId:e.property("rule_id",e.string()),trait:he.optional(),traitEntityType:e.property("trait_entity_type",te.optional()),traitId:e.property("trait_id",e.string().optional()),traitValue:e.property("trait_value",e.string()),updatedAt:e.property("updated_at",e.date())});var hp=e.object({conditions:e.list(Xt),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 vi=e.object({conditionGroups:e.property("condition_groups",e.list(hp)),conditions:e.list(Xt),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",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(vi),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",Ui.optional()),featureType:e.property("feature_type",ce),flags:e.list(gp),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: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: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(yp)),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 wp=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(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",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",he.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(Ci).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",Ei.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 Ti=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:Zt.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 bp=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:bp,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 pt=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 zp=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(pt)),availableCreditBundles:e.property("available_credit_bundles",e.list(De)),company:Q.optional(),customCheckoutFields:e.property("custom_checkout_fields",e.list(Yt)),featureUsage:e.property("feature_usage",Ti.optional()),selectedCreditBundles:e.property("selected_credit_bundles",e.list(dp)),selectedPlan:e.property("selected_plan",we.optional()),selectedUsageBasedEntitlements:e.property("selected_usage_based_entitlements",e.list(pt)),subscription:xi.optional()});var Rp=e.object({data:zp,params:e.record(e.string(),e.unknown())});var fp=e.object({data:Jt,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 Qt=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()),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:Qt,params:e.record(e.string(),e.unknown())});var xp=e.object({subscriptionChangePreview:e.property("subscription_change_preview",Qt.optional())});var Cp=e.object({data:xp,params:e.record(e.string(),e.unknown())});var Ep=e.object({data:lt,params:e.record(e.string(),e.unknown())});var ln=e.object({displayName:e.property("display_name",e.string().optional()),entityType:e.property("entity_type",te),hierarchy:e.list(e.string()),traitType:e.property("trait_type",me)});var pn=e.object({companyId:e.property("company_id",e.string()),userId:e.property("user_id",e.string())});var un=e.object({displayName:e.property("display_name",e.string().optional()),traitType:e.property("trait_type",me)});var Oi=e.object({traitId:e.property("trait_id",e.string()),traitValue:e.property("trait_value",e.string())});var dn=e.object({applyToExistingCompanies:e.property("apply_to_existing_companies",e.boolean()),planId:e.property("plan_id",e.string()),traits:e.list(Oi)});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 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",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 vp=e.object({data:V,params:Up});var Tp=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 Op=e.object({data:V,params:Tp});var kp=e.object({entityType:e.property("entity_type",te.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",me.optional()),traitTypes:e.property("trait_types",e.list(me).optional())});var Bp=e.object({data:V,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:V,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:V,params:Vp});var Mp=e.object({data:Q,params:e.record(e.string(),e.unknown())});var ki=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 Bi=e.object({company:ki.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(Bi)),createdAt:e.property("created_at",e.date()),entityTraits:e.property("entity_traits",e.list(Wt)),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.list(Gt),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 Dp=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Ip=e.object({data:ki,params:e.record(e.string(),e.unknown())});var Fp=e.object({data:L,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:L,params:Kp});var eo=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:eo,params:e.record(e.string(),e.unknown())});var Wp=e.object({data:L,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(xi),params:Np});var $p=e.object({data:Q,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:Bi,params:e.record(e.string(),e.unknown())});var eu=e.object({data:he,params:e.record(e.string(),e.unknown())});var ji=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 Ai=e.enum_(["fallback","initial","trait","trial_expiry"]);var ru=e.enum_(["adjustment","downgrade","invalid","subscribe","unsubscribe","upgrade","upgrade_trial"]);var ut=e.object({deleted:e.boolean(),description:e.string(),icon:e.string(),id:e.string(),name:e.string()});var mn=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 ro=e.object({action:ji,actorType:e.property("actor_type",Ce),addOnsAdded:e.property("add_ons_added",e.list(ut)),addOnsRemoved:e.property("add_ons_removed",e.list(ut)),apiKey:e.property("api_key",xe.optional()),auditLog:e.property("audit_log",At.optional()),basePlan:e.property("base_plan",ut.optional()),basePlanAction:e.property("base_plan_action",Ai.optional()),basePlanVersion:e.property("base_plan_version",mn.optional()),company:ki.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(),previousBasePlan:e.property("previous_base_plan",ut.optional()),previousBasePlanVersion:e.property("previous_base_plan_version",mn.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 tu=e.object({data:ro,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 ou=e.object({data:Kr,params:e.record(e.string(),e.unknown())});var au=e.object({data:Ne,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",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 su=e.object({data:e.list(Q),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(Bi),params:cu});var pu=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 uu=e.object({data:e.list(Lt),params:pu});var du=e.object({entityType:e.property("entity_type",te.optional()),ids:e.list(e.string()).optional(),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional(),traitType:e.property("trait_type",me.optional()),traitTypes:e.property("trait_types",e.list(me).optional())});var mu=e.object({data:e.list(he),params:du});var hu=e.object({action:ji.optional(),basePlanAction:e.property("base_plan_action",Ai.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(ro),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(Ne),params:bu});var Ru=e.object({keys:e.record(e.string(),e.string()).optional()});var fu=e.object({data:Q,params:Ru});var _u=e.object({keys:e.record(e.string(),e.string()).optional()});var Su=e.object({data:Ne,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 Cu=e.object({data:Q,params:e.record(e.string(),e.unknown())});var Eu=e.object({data:Q,params:e.record(e.string(),e.unknown())});var Uu=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var vu=e.object({data:Ne,params:e.record(e.string(),e.unknown())});var Vi=e.enum_(["billing","entitlement"]);var hn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Vi),name:e.string()});var io=e.enum_(["draft","live"]);var gn=e.object({ast:e.record(e.string(),e.number()).optional(),entityType:e.property("entity_type",Vi.optional()),name:e.string().optional(),state:io.optional()});var Tu=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ou=e.object({data:V,params:Tu});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:io,type:Vi,updatedAt:e.property("updated_at",e.date())});var ku=e.object({data:cr,params:e.record(e.string(),e.unknown())});var Bu=e.object({data:L,params:e.record(e.string(),e.unknown())});var ju=e.object({data:cr,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(cr),params:Au});var qu=e.object({companyId:e.property("company_id",e.string().optional()),componentId:e.property("component_id",e.string().optional())});var dt=e.object({billingScheme:e.property("billing_scheme",tr),createdAt:e.property("created_at",e.date()),currency:e.string(),id:e.string(),interval:fi,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",se)});var Mu=e.object({currency:e.string(),price:H.optional()});var Du=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(Mu)),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:dt.optional(),quantity:e.number().optional(),singularName:e.property("singular_name",e.string().optional()),status:Ee,unitPrice:e.property("unit_price",dt.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 to=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:Kt.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:_i.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 qi=e.enum_(["monthly","quarterly","yearly"]);var yn=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(qi)),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(to)),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",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 oo=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 ao=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"]);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",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:dt.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(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(yn)),activePlans:e.property("active_plans",e.list(yn)),activeUsageBasedEntitlements:e.property("active_usage_based_entitlements",e.list(pt)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr)),capabilities:oo.optional(),checkoutSettings:e.property("checkout_settings",Fu),company:Q.optional(),component:cr.optional(),creditBundles:e.property("credit_bundles",e.list(Du)),creditGrants:e.property("credit_grants",e.list(Lu)),customCheckoutFields:e.property("custom_checkout_fields",e.list(Yt)),defaultPlan:e.property("default_plan",we.optional()),displaySettings:e.property("display_settings",ao),featureUsage:e.property("feature_usage",Ti.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",$t.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:xi.optional(),trialPaymentMethodRequired:e.property("trial_payment_method_required",e.boolean().optional()),upcomingInvoice:e.property("upcoming_invoice",Ze.optional())});var Nu=e.object({data:Wu,params:qu});var Hu=e.object({data:cr,params:e.record(e.string(),e.unknown())});var wn=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(qi)),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(to)),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 $u=e.object({activeAddOns:e.property("active_add_ons",e.list(wn)),activePlans:e.property("active_plans",e.list(wn)),addOnCompatibilities:e.property("add_on_compatibilities",e.list(Gr)),capabilities:oo.optional(),displaySettings:e.property("display_settings",ao),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 bn=e.object({companyId:e.property("company_id",e.string()),creditTypeId:e.property("credit_type_id",e.string()),expiresAt:e.property("expires_at",e.date().optional()),requestedAmount:e.property("requested_amount",e.number())});var 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 zn=e.object({burnStrategy:e.property("burn_strategy",kr.optional()),currency:e.string(),currencyPrices:e.property("currency_prices",e.list(no).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({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 so=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 fn=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(so).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:Ee.optional()});var _n=e.object({additionalAmount:e.property("additional_amount",e.number()),expiresAt:e.property("expires_at",e.date().optional())});var Sn=e.object({burnStrategy:e.property("burn_strategy",kr.optional()),currencyPrices:e.property("currency_prices",e.list(no).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 Pn=e.object({bundleName:e.property("bundle_name",e.string()),currencyPrices:e.property("currency_prices",e.list(so).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:Ee.optional()});var xn=e.object({reason:Wr.optional()});var Mi=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:Mi,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:V,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:V,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:V,params:rd});var ai=e.enum_(["created_at","expires_at","quantity","quantity_remaining"]);var td=e.object({companyId:e.property("company_id",e.string().optional()),dir:je.optional(),limit:e.number().optional(),offset:e.number().optional(),order:ai.optional()});var od=e.object({data:V,params:td});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:V,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:V,params:sd});var ni=e.enum_(["daily","monthly","raw","weekly"]);var ld=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()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),period:ni.optional(),startTime:e.property("start_time",e.string().optional())});var pd=e.object({data:V,params:ld});var ud=e.object({data:Le,params:e.record(e.string(),e.unknown())});var dd=e.object({data:Be,params:e.record(e.string(),e.unknown())});var md=e.object({data:De,params:e.record(e.string(),e.unknown())});var hd=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var gd=e.object({data:L,params:hd});var yd=e.object({data:L,params:e.record(e.string(),e.unknown())});var wd=e.object({data:Mi,params:e.record(e.string(),e.unknown())});var bd=e.object({data:De,params:e.record(e.string(),e.unknown())});var zd=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()),featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),period:ni.optional(),startTime:e.property("start_time",e.string().optional())});var co=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 lo=e.object({id:e.string(),logoUrl:e.property("logo_url",e.string().optional()),name:e.string()});var po=e.object({description:e.string().optional(),icon:e.string().optional(),id:e.string(),name:e.string()});var Rd=e.object({billingCreditAutoTopupGrantCount:e.property("billing_credit_auto_topup_grant_count",e.number()),billingCreditId:e.property("billing_credit_id",e.string()),company:lo.optional(),companyId:e.property("company_id",e.string()),credit:co.optional(),expiredGrantCount:e.property("expired_grant_count",e.number()),feature:po.optional(),featureId:e.property("feature_id",e.string().optional()),firstTransactionAt:e.property("first_transaction_at",e.date()),freeGrantCount:e.property("free_grant_count",e.number()),grantCount:e.property("grant_count",e.number()),lastTransactionAt:e.property("last_transaction_at",e.date()),manuallyZeroedCount:e.property("manually_zeroed_count",e.number()),netChange:e.property("net_change",e.number()),planGrantCount:e.property("plan_grant_count",e.number()),purchasedGrantCount:e.property("purchased_grant_count",e.number()),timeBucket:e.property("time_bucket",e.date()),totalConsumed:e.property("total_consumed",e.number()),totalGranted:e.property("total_granted",e.number()),transactionCount:e.property("transaction_count",e.number()),usageCount:e.property("usage_count",e.number()),zeroedOutCount:e.property("zeroed_out_count",e.number())});var fd=e.object({data:e.list(Rd),params:zd});var _d=e.object({data:Le,params:e.record(e.string(),e.unknown())});var Sd=e.object({data:Be,params:e.record(e.string(),e.unknown())});var Pd=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(Pd).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 xd=e.object({data:Nr,params:e.record(e.string(),e.unknown())});var Cd=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:e.list(Le),params:Cd});var Ud=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 vd=e.object({data:e.list(Be),params:Ud});var Td=e.object({companyId:e.property("company_id",e.string().optional())});var Od=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 kd=e.object({data:e.list(Od),params:Td});var Bd=e.object({companyId:e.property("company_id",e.string().optional()),dir:je.optional(),limit:e.number().optional(),offset:e.number().optional(),order:ai.optional()});var jd=e.object({data:e.list(Nr),params:Bd});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 Vd=e.object({data:e.list(De),params:Ad});var qd=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 Md=e.enum_(["lease_hold","lease_release","manual_adjustment","reconciliation","track"]);var Dd=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:lo.optional(),companyId:e.property("company_id",e.string()),credit:co.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:po.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",Md.optional()),zeroedOutReason:e.property("zeroed_out_reason",Wr.optional())});var Id=e.object({data:e.list(Dd),params:qd});var Fd=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 Kd=e.object({data:e.list(Nr),params:Fd});var Ld=e.object({data:Mi,params:e.record(e.string(),e.unknown())});var Gd=e.object({data:L,params:e.record(e.string(),e.unknown())});var Wd=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 Hd=e.object({data:De,params:e.record(e.string(),e.unknown())});var $d=e.object({data:Nr,params:e.record(e.string(),e.unknown())});var Cn=e.object({metadata:e.string()});var Jd=e.stringLiteral("csv");var Yd=e.enum_(["failure","pending","success"]);var Zd=e.stringLiteral("company-feature-usage");var Xd=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",Zd),id:e.string(),metadata:e.string(),outputFileType:e.property("output_file_type",Jd),status:Yd,updatedAt:e.property("updated_at",e.date())});var Qd=e.object({data:Xd,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 En=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",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),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 Un=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 vn=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",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),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 Tn=e.object({sourcePlanId:e.property("source_plan_id",e.string()),targetPlanId:e.property("target_plan_id",e.string())});var On=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 kn=e.object({billingProductId:e.property("billing_product_id",e.string().optional()),billingThreshold:e.property("billing_threshold",e.number().optional()),creditConsumptionRate:e.property("credit_consumption_rate",e.number().optional()),currency:e.string().optional(),currencyPrices:e.property("currency_prices",e.list(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",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),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 em=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 rm=e.object({data:V,params:em});var im=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var tm=e.object({data:V,params:im});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 am=e.object({data:V,params:om});var nm=e.object({featureId:e.property("feature_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var sm=e.object({data:V,params:nm});var cm=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 lm=e.object({data:V,params:cm});var pm=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var um=e.object({data:ie,params:e.record(e.string(),e.unknown())});var dm=e.object({data:L,params:e.record(e.string(),e.unknown())});var mm=e.object({data:L,params:e.record(e.string(),e.unknown())});var uo=e.object({code:e.string(),description:e.string(),detail:e.string().optional(),id:e.string().optional()});var hm=e.object({message:e.string()});var gm=e.object({entitlementId:e.property("entitlement_id",e.string()),errors:e.list(hm),featureId:e.property("feature_id",e.string()),featureName:e.property("feature_name",e.string())});var ym=e.object({data:e.list(ie),issues:e.list(uo),skipped:e.list(gm)});var wm=e.object({data:ym,params:e.record(e.string(),e.unknown())});var bm=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var zm=e.object({keys:e.record(e.string(),e.string()).optional()});var Rm=e.object({data:Ti,params:zm});var Qe=e.enum_(["daily","hourly","monthly","weekly"]);var fm=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 _m=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 Sm=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 Pm=e.object({featureId:e.property("feature_id",e.string()),featureType:e.property("feature_type",ce),limits:e.list(_m),periodType:e.property("period_type",e.string().optional()),usagePoints:e.property("usage_points",e.list(Sm))});var xm=e.object({data:Pm,params:fm});var Cm=e.object({data:ie,params:e.record(e.string(),e.unknown())});var Em=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 Um=e.object({data:e.list(Fe),params:Em});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 Tm=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(Ci).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",Ei.optional())});var Om=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",re),company:Q.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(Ci).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",Tm.optional()),creditUsageAggregation:e.property("credit_usage_aggregation",Ei.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 km=e.object({data:e.list(Om),params:vm});var Bm=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 jm=e.object({data:e.list(Ir),params:Bm});var Am=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(vi),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",Ui.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:he.optional(),traitId:e.property("trait_id",e.string().optional()),updatedAt:e.property("updated_at",e.date())});var Vm=e.object({access:e.boolean(),allocation:e.number().optional(),allocationType:e.property("allocation_type",re),company:Q.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:eo.optional()});var qm=e.object({data:e.list(Vm),params:Am});var Mm=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 Dm=e.object({data:e.list(ie),params:Mm});var Im=e.object({data:Fe,params:e.record(e.string(),e.unknown())});var Fm=e.object({data:ie,params:e.record(e.string(),e.unknown())});var Km=e.object({data:ie,params:e.record(e.string(),e.unknown())});var Lm=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 Gm=e.object({keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Wm=e.object({company:Gm.optional(),keys:e.record(e.string(),e.string()),name:e.string().optional(),traits:e.record(e.string(),e.unknown()).optional()});var Nm=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 mo=e.undiscriminatedUnion([Nm,Lm,Wm]);var Pr=e.enum_(["flag_check","identify","track"]);var ho=e.object({backfill:e.boolean().optional(),body:mo.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 Bn=e.object({events:e.list(ho)});var go=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 Hm=e.object({events:e.list(go)});var $m=e.object({data:Hm,params:e.record(e.string(),e.unknown())});var Jm=e.object({data:go,params:e.record(e.string(),e.unknown())});var Ym=e.enum_(["enriched","failed","pending","processed","unknown"]);var yo=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:Ym,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 Zm=e.object({data:yo,params:e.record(e.string(),e.unknown())});var Xm=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 Qm=e.object({data:e.list(Ui),params:Xm});var eh=e.object({connected:e.boolean(),environmentId:e.property("environment_id",e.string()),lastEventAt:e.property("last_event_at",e.date().optional())});var rh=e.object({data:eh,params:e.record(e.string(),e.unknown())});var ih=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 th=e.object({data:e.list(yo),params:ih});var mt=e.object({company:e.record(e.string(),e.string()).optional(),user:e.record(e.string(),e.string()).optional()});var jn=e.object({contexts:e.list(mt)});var Di=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 An=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:Di.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 Vn=e.object({description:e.string(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ce),flag:Di.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 qn=e.object({description:e.string().optional(),eventSubtype:e.property("event_subtype",e.string().optional()),featureType:e.property("feature_type",ce.optional()),flag:Di.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 wo=e.object({comparisonTraitId:e.property("comparison_trait_id",e.string().optional()),conditionType:e.property("condition_type",Pi),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 oh=e.object({conditions:e.list(wo),flagId:e.property("flag_id",e.string().optional()),id:e.string().optional()});var ah=e.object({conditionGroups:e.property("condition_groups",e.list(oh)),conditions:e.list(wo),id:e.string().optional(),name:e.string(),priority:e.number(),ruleType:e.property("rule_type",Vr.optional()),value:e.boolean()});var Mn=e.object({rules:e.list(ah)});var bo=e.object({companyId:e.property("company_id",e.string().optional()),entitlement:Nt.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 nh=e.object({data:bo,params:e.record(e.string(),e.unknown())});var sh=e.enum_(["active","converted","expired"]);var ch=e.object({id:e.string(),name:e.string(),trialEndDate:e.property("trial_end_date",e.date().optional()),trialStatus:e.property("trial_status",sh.optional())});var zo=e.object({flags:e.list(bo),plan:ch.optional()});var lh=e.object({data:e.list(zo)});var ph=e.object({data:lh,params:e.record(e.string(),e.unknown())});var uh=e.object({data:zo,params:e.record(e.string(),e.unknown())});var dh=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 mh=e.object({data:V,params:dh});var hh=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 gh=e.object({data:V,params:hh});var yh=e.object({data:He,params:e.record(e.string(),e.unknown())});var wh=e.object({data:lr,params:e.record(e.string(),e.unknown())});var bh=e.object({data:L,params:e.record(e.string(),e.unknown())});var zh=e.object({data:L,params:e.record(e.string(),e.unknown())});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({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:e.list(He),params:_h});var Ph=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 xh=e.object({data:e.list(lr),params:Ph});var Ch=e.object({data:He,params:e.record(e.string(),e.unknown())});var Eh=e.object({data:lr,params:e.record(e.string(),e.unknown())});var Uh=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 vh=e.object({flag:Uh.optional(),rules:e.list(vi)});var Th=e.object({data:vh,params:e.record(e.string(),e.unknown())});var Oh=e.object({data:He,params:e.record(e.string(),e.unknown())});var kh=e.object({limit:e.number().optional()});var Bh=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 jh=e.object({entries:e.list(Bh)});var Ah=e.object({data:jh,params:kh});var Vh=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 Ro=e.object({timestamp:e.date(),usage:e.number()});var qh=e.object({eventSubtype:e.property("event_subtype",e.string()),featureId:e.property("feature_id",e.string()),points:e.list(Ro)});var Mh=e.object({data:qh,params:Vh});var Dh=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 Ih=e.object({featureId:e.property("feature_id",e.string()),points:e.list(Ro),traitDefinitionId:e.property("trait_definition_id",e.string())});var Fh=e.object({data:Ih,params:Dh});var Kh=e.object({months:e.number().optional()});var Lh=e.object({month:e.date(),planId:e.property("plan_id",e.string()),planName:e.property("plan_name",e.string()),subscribers:e.number()});var Gh=e.object({points:e.list(Lh)});var Wh=e.object({data:Gh,params:Kh});var Nh=e.object({amount:e.number(),currency:e.string()});var Hh=e.object({activeCredits:e.property("active_credits",e.number()),mrr:e.list(Nh),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 $h=e.object({data:Hh,params:e.record(e.string(),e.unknown())});var Jh=e.object({endTime:e.property("end_time",e.date().optional()),limit:e.number().optional(),startTime:e.property("start_time",e.date().optional())});var Yh=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 Zh=e.object({features:e.list(Yh)});var Xh=e.object({data:Zh,params:Jh});var Ii=e.enum_(["billing_meta_object","manual_upsert"]);var Dn=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Ii.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),integrationId:e.property("integration_id",e.string())});var fo=e.object({authorPlans:e.property("author_plans",e.boolean()),checkout:e.boolean(),editBilling:e.property("edit_billing",e.boolean())});var Qh=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var eg=e.object({});var rg=e.object({externalCustomerIdKey:e.property("external_customer_id_key",e.string().optional())});var ig=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 tg=e.object({firstEventsReceived:e.property("first_events_received",e.boolean().optional()),webhookUrl:e.property("webhook_url",e.string().optional())});var _o=e.union("type",{clerk:Qh,metronome:eg,orb:rg,stripe:ig,workos:tg}).transform({transform:p=>p,untransform:p=>p});var og=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Ii.optional()),companyMatchingField:e.property("company_matching_field",e.string().optional()),config:_o.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 ag=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:qe,type:Se,updatedAt:e.property("updated_at",e.date())});var Fi=e.object({capabilities:fo,config:og,integration:ag});var ng=e.object({data:Fi,params:e.record(e.string(),e.unknown())});var sg=e.object({type:Se,url:e.string()});var cg=e.object({data:sg,params:e.record(e.string(),e.unknown())});var lg=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 ug=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 dg=e.object({capabilities:fo,config:_o.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 mg=e.object({data:e.list(dg),params:ug});var hg=e.object({keys:e.list(e.string())});var gg=e.object({data:hg,params:e.record(e.string(),e.unknown())});var So=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),state:qe,type:Se,updatedAt:e.property("updated_at",e.date())});var yg=e.object({data:So,params:e.record(e.string(),e.unknown())});var wg=e.object({data:So,params:e.record(e.string(),e.unknown())});var bg=e.object({data:L,params:e.record(e.string(),e.unknown())});var zg=e.object({companyId:e.property("company_id",e.string()),description:e.string(),icon:le.optional(),name:e.string()});var Rg=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",de.optional()),usageQuantity:e.property("usage_quantity",e.number().optional()),valueBool:e.property("value_bool",e.boolean().optional()),valueCreditId:e.property("value_credit_id",e.string().optional()),valueNumeric:e.property("value_numeric",e.number().optional()),valueTraitId:e.property("value_trait_id",e.string().optional()),valueType:e.property("value_type",re),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 Po=e.enum_(["create","update","delete"]);var Ki=e.object({action:Po,entitlementId:e.property("entitlement_id",e.string().optional()),req:Rg.optional()});var fg=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(fg).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 In=e.object({billingProduct:e.property("billing_product",$r.optional()),entitlements:e.list(Ki),plan:zg.optional()});var xo=e.object({description:e.string(),icon:le.optional(),name:e.string(),planType:e.property("plan_type",oe)});var Co=e.stringLiteral("credit");var Eo=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",Co.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 _g=e.object({applyToExisting:e.property("apply_to_existing",e.boolean().optional())});var Uo=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",Co.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 vo=e.object({action:Po,createReq:e.property("create_req",Eo.optional()),creditGrantId:e.property("credit_grant_id",e.string().optional()),deleteReq:e.property("delete_req",_g.optional()),updateReq:e.property("update_req",Uo.optional())});var Fn=e.object({billingProduct:e.property("billing_product",$r.optional()),creditGrants:e.property("credit_grants",e.list(vo).optional()),entitlements:e.list(Ki),plan:xo.optional(),traits:e.list(Oi).optional()});var To=e.object({description:e.string().optional(),icon:le.optional(),name:e.string()});var Kn=e.object({billingProduct:e.property("billing_product",$r.optional()),creditGrants:e.property("credit_grants",e.list(vo).optional()),entitlements:e.list(Ki),plan:To.optional(),planVersionId:e.property("plan_version_id",e.string().optional()),traits:e.list(Oi).optional()});var Oo=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 Li=e.object({billingProduct:e.property("billing_product",Oo.optional()),creditGrants:e.property("credit_grants",e.list(Be).optional()),entitlements:e.list(ie).optional(),plan:sr.optional(),traits:e.list(Kr).optional()});var Sg=e.object({data:Li,params:e.record(e.string(),e.unknown())});var Pg=e.object({data:Li,params:e.record(e.string(),e.unknown())});var xg=e.object({data:Li,params:e.record(e.string(),e.unknown())});var ko=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 Cg=e.object({entitlementId:e.property("entitlement_id",e.string()),visible:e.boolean().optional()});var xr=e.object({entitlements:e.list(Cg).optional(),planId:e.property("plan_id",e.string())});var Gi=e.object({bundleId:e.string()});var Bo=e.enum_(["create_prorations","invoice_immediately"]);var jo=e.enum_(["end_of_billing_period","none"]);var Ln=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(ko).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()),orderedAddOns:e.property("ordered_add_ons",e.list(xr)),orderedBundleList:e.property("ordered_bundle_list",e.list(Gi)),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",Bo),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",jo.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 Gn=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(ko).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()),orderedAddOns:e.property("ordered_add_ons",e.list(xr)),orderedBundleList:e.property("ordered_bundle_list",e.list(Gi)),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",Bo),scheduledDowngradeBehavior:e.property("scheduled_downgrade_behavior",jo.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 Ao=e.object({collectAddress:e.property("collect_address",e.boolean()),collectEmail:e.property("collect_email",e.boolean()),collectPhone:e.property("collect_phone",e.boolean())});var Eg=e.object({compatiblePlanIds:e.property("compatible_plan_ids",e.list(e.string())),sourcePlanId:e.property("source_plan_id",e.string())});var Vo=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 qo=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",Ao),componentSettings:e.property("component_settings",Vo),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 Ug=e.object({data:qo,params:e.record(e.string(),e.unknown())});var vg=e.object({includeCompanyCounts:e.property("include_company_counts",e.boolean().optional())});var Tg=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 Mo=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 si=e.object({activeVersion:e.property("active_version",Re.optional()),audienceType:e.property("audience_type",e.string().optional()),availablePeriods:e.property("available_periods",e.list(qi)),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",Mo.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 Og=e.object({planEntitlementId:e.property("plan_entitlement_id",e.string()),visible:e.boolean().optional()});var Wn=e.object({entitlements:e.list(Og).optional(),planId:e.property("plan_id",e.string())});var kg=e.object({addOns:e.property("add_ons",e.list(si)),checkoutSettings:e.property("checkout_settings",Ao),componentSettings:e.property("component_settings",Vo),customCheckoutFields:e.property("custom_checkout_fields",e.list(Tg)),customPlanConfig:e.property("custom_plan_config",Mo.optional()),customPlanId:e.property("custom_plan_id",e.string().optional()),defaultPlan:e.property("default_plan",si.optional()),defaultPlanId:e.property("default_plan_id",e.string().optional()),fallbackPlan:e.property("fallback_plan",si.optional()),fallbackPlanId:e.property("fallback_plan_id",e.string().optional()),id:e.string(),initialPlan:e.property("initial_plan",si.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(Wn)),orderedBundleList:e.property("ordered_bundle_list",e.list(Gi)),orderedPlanList:e.property("ordered_plan_list",e.list(Wn)),plans:e.list(si),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",si.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 Bg=e.object({data:kg,params:vg});var jg=e.object({data:qo,params:e.record(e.string(),e.unknown())});var Wi=e.enum_(["immediate","leave"]);var Nn=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:Wi,targetPlanType:e.property("target_plan_type",oe)});var Do=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 Hn=e.object({errorCodes:e.property("error_codes",e.list(Do))});var Cr=e.enum_(["completed","failed","in_progress","pending","skipped"]);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:Cr.optional()});var Vg=e.object({data:V,params:Ag});var Er=e.enum_(["completed","failed","in_progress","pending"]);var qg=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Er.optional()});var Mg=e.object({data:V,params:qg});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:Er,strategy:Wi,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 Ig=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var Fg=e.object({limit:e.number().optional(),migrationId:e.property("migration_id",e.string().optional()),offset:e.number().optional(),q:e.string().optional(),status:Cr.optional()});var Io=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",Do.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:Cr,updatedAt:e.property("updated_at",e.date())});var Kg=e.object({data:e.list(Io),params:Fg});var Lg=e.object({limit:e.number().optional(),offset:e.number().optional(),planVersionId:e.property("plan_version_id",e.string().optional()),status:Er.optional()});var Gg=e.object({data:e.list(Jr),params:Lg});var Wg=e.object({data:Io,params:e.record(e.string(),e.unknown())});var Ng=e.object({data:Jr,params:e.record(e.string(),e.unknown())});var $n=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 Jn=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 Yr=e.object({priceId:e.property("price_id",e.string()),quantity:e.number()});var Yn=e.object({activationStrategy:e.property("activation_strategy",Si.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",Wi),payInAdvance:e.property("pay_in_advance",e.list(Yr))});var Zn=e.object({activationStrategy:e.property("activation_strategy",Si.optional()),customerEmail:e.property("customer_email",e.string()),daysUntilDue:e.property("days_until_due",e.number().optional()),payInAdvance:e.property("pay_in_advance",e.list(Yr))});var Xn=e.object({addOnIds:e.property("add_on_ids",e.list(e.string())),basePlanId:e.property("base_plan_id",e.string().optional())});var Hg=e.object({limit:e.number().optional(),offset:e.number().optional(),planId:e.property("plan_id",e.string().optional()),q:e.string().optional()});var $g=e.object({data:V,params:Hg});var Jg=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 Yg=e.object({data:V,params:Jg});var Zg=e.object({data:we,params:e.record(e.string(),e.unknown())});var Xg=e.object({data:we,params:e.record(e.string(),e.unknown())});var Qg=e.object({data:L,params:e.record(e.string(),e.unknown())});var ey=e.object({promoteArchivedVersion:e.property("promote_archived_version",e.boolean().optional())});var ry=e.object({data:L,params:ey});var iy=e.object({planVersionId:e.property("plan_version_id",e.string().optional())});var ty=e.object({data:we,params:iy});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 ay=e.object({data:e.list(Q),params:oy});var ny=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 sy=e.object({data:e.list(jr),params:ny});var cy=e.object({planId:e.property("plan_id",e.string().optional()),planVersionId:e.property("plan_version_id",e.string().optional())});var ly=e.object({data:e.list(uo),params:cy});var py=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 uy=e.object({data:e.list(we),params:py});var dy=e.object({data:jr,params:e.record(e.string(),e.unknown())});var my=e.object({data:Re,params:e.record(e.string(),e.unknown())});var hy=e.object({data:jr,params:e.record(e.string(),e.unknown())});var gy=e.object({data:Q,params:e.record(e.string(),e.unknown())});var yy=e.object({data:we,params:e.record(e.string(),e.unknown())});var wy=e.object({data:Oo,params:e.record(e.string(),e.unknown())});var by=e.object({data:we,params:e.record(e.string(),e.unknown())});var Qn=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 Zr=e.enum_(["cancelled","error","executing","pending","success"]);var es=e.object({executeAfter:e.property("execute_after",e.date().optional()),status:Zr.optional()});var Xr=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:Zr,toPlanId:e.property("to_plan_id",e.string()),updatedAt:e.property("updated_at",e.date())});var zy=e.object({data:Xr,params:e.record(e.string(),e.unknown())});var Ry=e.object({data:Xr,params:e.record(e.string(),e.unknown())});var fy=e.object({companyId:e.property("company_id",e.string().optional()),limit:e.number().optional(),offset:e.number().optional(),status:Zr.optional()});var _y=e.object({data:e.list(Xr),params:fy});var Sy=e.object({data:Xr,params:e.record(e.string(),e.unknown())});var Ni=e.object({creditId:e.property("credit_id",e.string())});var Hi=e.object({featureId:e.property("feature_id",e.string())});var Qr=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 rs=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Ni).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Hi).optional()),name:e.string(),requestTypes:e.property("request_types",e.list(Qr)),url:e.string()});var Fo=e.enum_(["active","inactive"]);var is=e.object({creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Ni).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Hi).optional()),name:e.string().optional(),requestTypes:e.property("request_types",e.list(Qr).optional()),status:Fo.optional(),url:e.string().optional()});var Py=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 xy=e.object({data:V,params:Py});var Cy=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Ey=e.object({data:V,params:Cy});var pr=e.object({createdAt:e.property("created_at",e.date()),creditTriggerConfigs:e.property("credit_trigger_configs",e.list(Ni).optional()),entitlementTriggerConfigs:e.property("entitlement_trigger_configs",e.list(Hi).optional()),id:e.string(),name:e.string(),requestTypes:e.property("request_types",e.list(Qr)),secret:e.string(),status:Fo,updatedAt:e.property("updated_at",e.date()),url:e.string()});var Uy=e.object({data:pr,params:e.record(e.string(),e.unknown())});var vy=e.object({data:L,params:e.record(e.string(),e.unknown())});var Ty=e.enum_(["failure","pending","success"]);var Ko=e.object({createdAt:e.property("created_at",e.date()),id:e.string(),payload:e.string().optional(),requestType:e.property("request_type",Qr),responseCode:e.property("response_code",e.number().optional()),sentAt:e.property("sent_at",e.date().optional()),status:Ty,updatedAt:e.property("updated_at",e.date()),webhook:pr.optional(),webhookId:e.property("webhook_id",e.string())});var Oy=e.object({data:Ko,params:e.record(e.string(),e.unknown())});var ky=e.object({data:pr,params:e.record(e.string(),e.unknown())});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 jy=e.object({data:e.list(Ko),params:By});var Ay=e.object({limit:e.number().optional(),offset:e.number().optional(),q:e.string().optional()});var Vy=e.object({data:e.list(pr),params:Ay});var qy=e.object({data:pr,params:e.record(e.string(),e.unknown())});var n=e.object({error:e.string()});var Lo=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 Dy=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 Go=e.object({bundleId:e.property("bundle_id",e.string()),quantity:e.number()});var ts=e.object({addOnIds:e.property("add_on_ids",e.list(My)),autoTopupOverrides:e.property("auto_topup_overrides",e.list(Dy)),companyId:e.property("company_id",e.string()),couponExternalId:e.property("coupon_external_id",e.string().optional()),creditBundles:e.property("credit_bundles",e.list(Go)),customFieldValues:e.property("custom_field_values",e.list(Lo)),newPlanId:e.property("new_plan_id",e.string()),newPriceId:e.property("new_price_id",e.string()),payInAdvance:e.property("pay_in_advance",e.list(Yr)),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 os=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 Wo=e.object({companyMatchingCriteria:e.property("company_matching_criteria",Ii.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 as=e.object({keys:e.record(e.string(),e.string())});var Iy=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 ns=e.object({addOnSelections:e.property("add_on_selections",e.list(Iy)),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(Go)),customFieldValues:e.property("custom_field_values",e.list(Lo)),payInAdvanceEntitlements:e.property("pay_in_advance_entitlements",e.list(Yr)),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 Fy=e.record(e.string(),e.unknown());var Ky=e.record(e.string(),e.unknown());var Ly=e.enum_(["boolean","credit","numeric","trait","unknown","unlimited"]);var $i=e.enum_(["all_time","current_day","current_month","current_week"]);var Ji=e.enum_(["billing_cycle","first_of_month"]);var No=e.object({allocation:e.number().optional(),creditId:e.property("credit_id",e.string().optional()),creditRemaining:e.property("credit_remaining",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",$i.optional()),metricResetAt:e.property("metric_reset_at",e.date().optional()),monthReset:e.property("month_reset",Ji.optional()),softLimit:e.property("soft_limit",e.number().optional()),usage:e.number().optional(),valueType:e.property("value_type",Ly)});var Gy=e.enum_(["company_override","company_override_usage_exceeded","default","global_override","plan_entitlement","plan_entitlement_usage_exceeded","standard"]);var Ho=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",Ji),period:$i,validUntil:e.property("valid_until",e.date().optional()),value:e.number()});var Wy=e.enum_(["base_plan","billing_product","company","credit","metric","plan","plan_version","trait","user"]);var Ny=e.enum_(["company","user"]);var Hy=e.enum_(["bool","date","int","string"]);var ht=e.object({comparableType:e.property("comparable_type",Hy),entityType:e.property("entity_type",Ny),id:e.string()});var $o=e.object({accountId:e.property("account_id",e.string()),comparisonTraitDefinition:e.property("comparison_trait_definition",ht.optional()),conditionType:e.property("condition_type",Wy),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",$i.optional()),metricPeriodMonthReset:e.property("metric_period_month_reset",Ji.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",ht.optional()),traitValue:e.property("trait_value",e.string())});var $y=e.object({conditions:e.list($o)});var Yi=e.object({accountId:e.property("account_id",e.string()),conditionGroups:e.property("condition_groups",e.list($y)),conditions:e.list($o),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",Gy),value:e.boolean()});var Jy=e.object({id:e.string(),periodEnd:e.property("period_end",e.date()),periodStart:e.property("period_start",e.date())});var Jo=e.object({traitDefinition:e.property("trait_definition",ht.optional()),value:e.string()});var Yy=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(No).optional(),environmentId:e.property("environment_id",e.string()),id:e.string(),keys:e.record(e.string(),e.string()),metrics:e.list(Ho),planIds:e.property("plan_ids",e.list(e.string())),planVersionIds:e.property("plan_version_ids",e.list(e.string())),rules:e.list(Yi),subscription:Jy.optional(),traits:e.list(Jo)});var ss=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(Yi)});var Zy=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(Yi),traits:e.list(Jo)});var cs=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 ls=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 ps=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 Yo=class{constructor(t){this._options=K(t)}issueTemporaryAccessToken(t,i){return P.fromPromise(this.__issueTemporaryAccessToken(t,i))}async __issueTemporaryAccessToken(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:{...Ga.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: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 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/temporary-access-tokens")}};var Zo=class{constructor(t){this._options=K(t)}listAccountMembers(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:nl.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/account-members")}getAccountMember(t,i){return P.fromPromise(this.__getAccountMember(t,i))}async __getAccountMember(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/account-members/{account_member_id}")}countAccountMembers(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Dc.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/account-members/count")}listApiKeys(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:cl.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/api-keys")}createApiKey(t,i){return P.fromPromise(this.__createApiKey(t,i))}async __createApiKey(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/api-keys")}getApiKey(t,i){return P.fromPromise(this.__getApiKey(t,i))}async __getApiKey(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/api-keys/{api_key_id}")}updateApiKey(t,i={},o){return P.fromPromise(this.__updateApiKey(t,i,o))}async __updateApiKey(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:Ha.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:gl.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/api-keys/{api_key_id}")}deleteApiKey(t,i){return P.fromPromise(this.__deleteApiKey(t,i))}async __deleteApiKey(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:$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 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/api-keys/{api_key_id}")}countApiKeys(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Fc.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/api-keys/count")}listAuditLogs(t={},i){return P.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?Ce.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=x(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({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:pl.parseOrThrow(U.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new T(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new R(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new f(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/audit-log")}getAuditLog(t,i){return P.fromPromise(this.__getAuditLog(t,i))}async __getAuditLog(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/audit-log/{audit_log_id}")}countAuditLogs(t={},i){return P.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?Ce.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=x(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({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:Lc.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 T(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new R(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new f(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/audit-log/count")}listEnvironments(t={},i){return P.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=x(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({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:dl.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 T(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new R(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new f(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/environments")}createEnvironment(t,i){return P.fromPromise(this.__createEnvironment(t,i))}async __createEnvironment(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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:Hc.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/environments")}getEnvironment(t,i){return P.fromPromise(this.__getEnvironment(t,i))}async __getEnvironment(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:il.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/environments/{environment_id}")}updateEnvironment(t,i={},o){return P.fromPromise(this.__updateEnvironment(t,i,o))}async __updateEnvironment(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:$a.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:yl.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/environments/{environment_id}")}deleteEnvironment(t,i){return P.fromPromise(this.__deleteEnvironment(t,i))}async __deleteEnvironment(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/environments/{environment_id}")}quickstart(t){return P.fromPromise(this.__quickstart(t))}async __quickstart(t){let i=await this._options.authProvider.getAuthRequest(),o=x(i.headers,this._options?.headers,t?.headers),s=await(this._options.fetcher??C)({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:hl.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 T(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 401:throw new S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new R(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new f(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"POST","/quickstart")}getWhoAmI(t){return P.fromPromise(this.__getWhoAmI(t))}async __getWhoAmI(t){let i=await this._options.authProvider.getAuthRequest(),o=x(i.headers,this._options?.headers,t?.headers),s=await(this._options.fetcher??C)({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:ol.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 S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new R(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new f(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/whoami")}};var Xo=class{constructor(t){this._options=K(t)}listCoupons(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:jl.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/billing/coupons")}upsertBillingCoupon(t,i){return P.fromPromise(this.__upsertBillingCoupon(t,i))}async __upsertBillingCoupon(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/coupons")}upsertBillingCustomer(t,i){return P.fromPromise(this.__upsertBillingCustomer(t,i))}async __upsertBillingCustomer(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/customer/upsert")}listCustomersWithSubscriptions(t={},i){return P.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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:Ml.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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/customers")}countCustomers(t={},i){return P.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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:Sl.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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/customers/count")}listInvoices(t,i){return P.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/billing/invoices")}upsertInvoice(t,i){return P.fromPromise(this.__upsertInvoice(t,i))}async __upsertInvoice(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/invoices")}listMeters(t={},i){return P.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=x(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new R(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new f(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/billing/meter")}upsertBillingMeter(t,i){return P.fromPromise(this.__upsertBillingMeter(t,i))}async __upsertBillingMeter(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:rn.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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/meter/upsert")}listPaymentMethods(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Gl.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/billing/payment-methods")}upsertPaymentMethod(t,i){return P.fromPromise(this.__upsertPaymentMethod(t,i))}async __upsertPaymentMethod(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/payment-methods")}deletePaymentMethodByExternalId(t,i){return P.fromPromise(this.__deletePaymentMethodByExternalId(t,i))}async __deletePaymentMethodByExternalId(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/payment-methods/{billing_id}")}listBillingPrices(t={},i){return P.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:v,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:v!=null?de.jsonOrThrow(v,{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=x(X.headers,this._options?.headers,i?.headers),q=await(this._options.fetcher??C)({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:Ul.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 T(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 401:throw new S(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 403:throw new R(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 404:throw new _(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 500:throw new f(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 E(q.error,q.rawResponse,"GET","/billing/price")}upsertBillingPrice(t,i){return P.fromPromise(this.__upsertBillingPrice(t,i))}async __upsertBillingPrice(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/price/upsert")}deleteBillingProduct(t,i){return P.fromPromise(this.__deleteBillingProduct(t,i))}async __deleteBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/product/{billing_id}")}listBillingProductPrices(t={},i){return P.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:v,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:v!=null?de.jsonOrThrow(v,{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=x(X.headers,this._options?.headers,i?.headers),q=await(this._options.fetcher??C)({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:Tl.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 T(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 401:throw new S(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 403:throw new R(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 404:throw new _(n.parseOrThrow(q.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),q.rawResponse);case 500:throw new f(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 E(q.error,q.rawResponse,"GET","/billing/product/prices")}deleteProductPrice(t,i){return P.fromPromise(this.__deleteProductPrice(t,i))}async __deleteProductPrice(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Cl.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/product/prices/{billing_id}")}upsertBillingProduct(t,i){return P.fromPromise(this.__upsertBillingProduct(t,i))}async __upsertBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/product/upsert")}listBillingProducts(t={},i){return P.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:v,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:v,offset:O},B=await this._options.authProvider.getAuthRequest(),I=x(B.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??C)({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:kl.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 T(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new R(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new f(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return E(A.error,A.rawResponse,"GET","/billing/products")}countBillingProducts(t={},i){return P.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:v,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:v,offset:O},B=await this._options.authProvider.getAuthRequest(),I=x(B.headers,this._options?.headers,i?.headers),A=await(this._options.fetcher??C)({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:fl.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 T(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 401:throw new S(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 403:throw new R(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 404:throw new _(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);case 500:throw new f(n.parseOrThrow(A.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),A.rawResponse);default:throw new b({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}return E(A.error,A.rawResponse,"GET","/billing/products/count")}upsertBillingSubscription(t,i){return P.fromPromise(this.__upsertBillingSubscription(t,i))}async __upsertBillingSubscription(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/subscription/upsert")}};var Qo=class{constructor(t){this._options=K(t)}internal(t,i){return P.fromPromise(this.__internal(t,i))}async __internal(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ts.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal")}getCheckoutData(t,i){return P.fromPromise(this.__getCheckoutData(t,i))}async __getCheckoutData(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal/data")}previewCheckoutInternal(t,i){return P.fromPromise(this.__previewCheckoutInternal(t,i))}async __previewCheckoutInternal(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ts.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/checkout-internal/preview")}managePlan(t,i){return P.fromPromise(this.__managePlan(t,i))}async __managePlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan")}previewManagePlan(t,i){return P.fromPromise(this.__previewManagePlan(t,i))}async __previewManagePlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan/preview")}cancelSubscription(t,i){return P.fromPromise(this.__cancelSubscription(t,i))}async __cancelSubscription(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/manage-plan/subscription/cancel")}updateCustomerSubscriptionTrialEnd(t,i={},o){return P.fromPromise(this.__updateCustomerSubscriptionTrialEnd(t,i,o))}async __updateCustomerSubscriptionTrialEnd(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:Ep.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/subscription/{subscription_id}/edit-trial-end")}};var ea=class{constructor(t){this._options=K(t)}listCompanies(t={},i){return P.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:v,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(v)?v.map(gr=>fr.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):v!=null?fr.jsonOrThrow(v,{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=x(hr.headers,this._options?.headers,i?.headers),F=await(this._options.fetcher??C)({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:su.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 T(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 401:throw new S(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 403:throw new R(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 404:throw new _(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 500:throw new f(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 E(F.error,F.rawResponse,"GET","/companies")}upsertCompany(t,i){return P.fromPromise(this.__upsertCompany(t,i))}async __upsertCompany(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:cs.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies")}getCompany(t,i){return P.fromPromise(this.__getCompany(t,i))}async __getCompany(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:$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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/companies/{company_id}")}deleteCompany(t,i={},o){return P.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=x(u.headers,this._options?.headers,o?.headers),h=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new R(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new f(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"DELETE","/companies/{company_id}")}countCompanies(t={},i){return P.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:v,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(v)?v.map(gr=>fr.jsonOrThrow(gr,{unrecognizedObjectKeys:"strip"})):v!=null?fr.jsonOrThrow(v,{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=x(hr.headers,this._options?.headers,i?.headers),F=await(this._options.fetcher??C)({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:vp.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 T(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 401:throw new S(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 403:throw new R(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 404:throw new _(n.parseOrThrow(F.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),F.rawResponse);case 500:throw new f(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 E(F.error,F.rawResponse,"GET","/companies/count")}createCompany(t,i){return P.fromPromise(this.__createCompany(t,i))}async __createCompany(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:cs.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies/create")}deleteCompanyByKeys(t,i){return P.fromPromise(this.__deleteCompanyByKeys(t,i))}async __deleteCompanyByKeys(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/companies/delete")}lookupCompany(t,i){return P.fromPromise(this.__lookupCompany(t,i))}async __lookupCompany(t,i){let{keys:o}=t,s={keys:ve(o)},r=await this._options.authProvider.getAuthRequest(),a=x(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new R(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new f(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return E(u.error,u.rawResponse,"GET","/companies/lookup")}listCompanyMemberships(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:lu.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/company-memberships")}getOrCreateCompanyMembership(t,i){return P.fromPromise(this.__getOrCreateCompanyMembership(t,i))}async __getOrCreateCompanyMembership(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-memberships")}deleteCompanyMembership(t,i){return P.fromPromise(this.__deleteCompanyMembership(t,i))}async __deleteCompanyMembership(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/company-memberships/{company_membership_id}")}getActiveCompanySubscription(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Hp.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/company-subscriptions")}upsertCompanyTrait(t,i){return P.fromPromise(this.__upsertCompanyTrait(t,i))}async __upsertCompanyTrait(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ls.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-traits")}listEntityKeyDefinitions(t={},i){return P.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/entity-key-definitions")}countEntityKeyDefinitions(t={},i){return P.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/entity-key-definitions/count")}listEntityTraitDefinitions(t={},i){return P.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?me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(u)?u.map(v=>me.jsonOrThrow(v,{unrecognizedObjectKeys:"strip"})):u!=null?me.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=x(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new R(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new f(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/entity-trait-definitions")}getOrCreateEntityTraitDefinition(t,i){return P.fromPromise(this.__getOrCreateEntityTraitDefinition(t,i))}async __getOrCreateEntityTraitDefinition(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ln.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/entity-trait-definitions")}getEntityTraitDefinition(t,i){return P.fromPromise(this.__getEntityTraitDefinition(t,i))}async __getEntityTraitDefinition(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/entity-trait-definitions/{entity_trait_definition_id}")}updateEntityTraitDefinition(t,i,o){return P.fromPromise(this.__updateEntityTraitDefinition(t,i,o))}async __updateEntityTraitDefinition(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:Pu.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/entity-trait-definitions/{entity_trait_definition_id}")}countEntityTraitDefinitions(t={},i){return P.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?me.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}):void 0,trait_types:Array.isArray(u)?u.map(v=>me.jsonOrThrow(v,{unrecognizedObjectKeys:"strip"})):u!=null?me.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}):void 0,limit:g,offset:h},y=await this._options.authProvider.getAuthRequest(),w=x(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new R(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new f(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/entity-trait-definitions/count")}getEntityTraitValues(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Xp.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/entity-trait-values")}listPlanChanges(t={},i){return P.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?ji.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}):void 0,base_plan_action:s!=null?Ai.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=x(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new R(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new f(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/plan-changes")}getPlanChange(t,i){return P.fromPromise(this.__getPlanChange(t,i))}async __getPlanChange(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-changes/{plan_change_id}")}listPlanTraits(t={},i){return P.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/plan-traits")}getPlanTrait(t,i){return P.fromPromise(this.__getPlanTrait(t,i))}async __getPlanTrait(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-traits/{plan_trait_id}")}updatePlanTraitsBulk(t,i){return P.fromPromise(this.__updatePlanTraitsBulk(t,i))}async __updatePlanTraitsBulk(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-traits/bulk")}countPlanTraits(t={},i){return P.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/plan-traits/count")}upsertUserTrait(t,i){return P.fromPromise(this.__upsertUserTrait(t,i))}async __upsertUserTrait(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ls.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/user-traits")}listUsers(t={},i){return P.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/users")}upsertUser(t,i){return P.fromPromise(this.__upsertUser(t,i))}async __upsertUser(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ps.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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users")}getUser(t,i){return P.fromPromise(this.__getUser(t,i))}async __getUser(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/users/{user_id}")}deleteUser(t,i){return P.fromPromise(this.__deleteUser(t,i))}async __deleteUser(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/users/{user_id}")}countUsers(t={},i){return P.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/users/count")}createUser(t,i){return P.fromPromise(this.__createUser(t,i))}async __createUser(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ps.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users/create")}deleteUserByKeys(t,i){return P.fromPromise(this.__deleteUserByKeys(t,i))}async __deleteUserByKeys(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/users/delete")}lookupUser(t,i){return P.fromPromise(this.__lookupUser(t,i))}async __lookupUser(t,i){let{keys:o}=t,s={keys:ve(o)},r=await this._options.authProvider.getAuthRequest(),a=x(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new R(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new f(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return E(u.error,u.rawResponse,"GET","/users/lookup")}};var ra=class{constructor(t){this._options=K(t)}listComponents(t={},i){return P.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=x(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new R(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new f(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/components")}createComponent(t,i){return P.fromPromise(this.__createComponent(t,i))}async __createComponent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/components")}getComponent(t,i){return P.fromPromise(this.__getComponent(t,i))}async __getComponent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/components/{component_id}")}updateComponent(t,i={},o){return P.fromPromise(this.__updateComponent(t,i,o))}async __updateComponent(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:gn.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:Hu.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/components/{component_id}")}deleteComponent(t,i){return P.fromPromise(this.__deleteComponent(t,i))}async __deleteComponent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/components/{component_id}")}countComponents(t={},i){return P.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=x(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new R(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new f(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/components/count")}previewComponentData(t={},i){return P.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=x(a.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({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 S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new R(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new f(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/components/preview-data")}};var ia=class{constructor(t){this._options=K(t)}getPublicPlans(t){return P.fromPromise(this.__getPublicPlans(t))}async __getPublicPlans(t){let i=await this._options.authProvider.getAuthRequest(),o=x(i.headers,this._options?.headers,t?.headers),s=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new R(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new f(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/public/plans")}};var ta=class{constructor(t){this._options=K(t)}listBillingCredits(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Ed.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/billing/credits")}createBillingCredit(t,i){return P.fromPromise(this.__createBillingCredit(t,i))}async __createBillingCredit(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits")}getSingleBillingCredit(t,i){return P.fromPromise(this.__getSingleBillingCredit(t,i))}async __getSingleBillingCredit(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:_d.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/{credit_id}")}updateBillingCredit(t,i,o){return P.fromPromise(this.__updateBillingCredit(t,i,o))}async __updateBillingCredit(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:Wd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/{credit_id}")}softDeleteBillingCredit(t,i){return P.fromPromise(this.__softDeleteBillingCredit(t,i))}async __softDeleteBillingCredit(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Gd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/credits/{credit_id}")}listCompanyCreditBalances(t,i){return P.fromPromise(this.__listCompanyCreditBalances(t,i))}async __listCompanyCreditBalances(t,i){let{companyId:o}=t,s={company_id:o},r=await this._options.authProvider.getAuthRequest(),a=x(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??C)({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:kd.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 T(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 401:throw new S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new R(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new f(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return E(u.error,u.rawResponse,"GET","/billing/credits/balance")}listCreditBundles(t={},i){return P.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?Ee.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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:Vd.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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/credits/bundles")}createCreditBundle(t,i){return P.fromPromise(this.__createCreditBundle(t,i))}async __createCreditBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:fn.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/bundles")}getCreditBundle(t,i){return P.fromPromise(this.__getCreditBundle(t,i))}async __getCreditBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/bundles/{bundle_id}")}updateCreditBundleDetails(t,i,o){return P.fromPromise(this.__updateCreditBundleDetails(t,i,o))}async __updateCreditBundleDetails(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:Pn.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:Hd.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/bundles/{bundle_id}")}deleteCreditBundle(t,i){return P.fromPromise(this.__deleteCreditBundle(t,i))}async __deleteCreditBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/billing/credits/bundles/{bundle_id}")}countCreditBundles(t={},i){return P.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?Ee.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/billing/credits/bundles/count")}countBillingCredits(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:ed.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/billing/credits/count")}zeroOutGrant(t,i={},o){return P.fromPromise(this.__zeroOutGrant(t,i,o))}async __zeroOutGrant(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:$d.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/grants/{grant_id}/zero-out")}grantBillingCreditsToCompany(t,i){return P.fromPromise(this.__grantBillingCreditsToCompany(t,i))}async __grantBillingCreditsToCompany(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Rn.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:xd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/grants/company")}countCompanyGrants(t={},i){return P.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?ai.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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:od.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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/billing/credits/grants/company/count")}listCompanyGrants(t={},i){return P.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?ai.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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:jd.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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/billing/credits/grants/company/list")}countBillingCreditsGrants(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Xu.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/billing/credits/grants/count")}listGrantsForCredit(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Kd.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/billing/credits/grants/list")}acquireCreditLease(t,i){return P.fromPromise(this.__acquireCreditLease(t,i))}async __acquireCreditLease(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:bn.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/lease")}extendCreditLease(t,i,o){return P.fromPromise(this.__extendCreditLease(t,i,o))}async __extendCreditLease(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:_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:wd.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/extend")}releaseCreditLease(t,i,o){return P.fromPromise(this.__releaseCreditLease(t,i,o))}async __releaseCreditLease(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:Ky.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:Ld.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/lease/{lease_id}/release")}getEnrichedCreditLedger(t,i){return P.fromPromise(this.__getEnrichedCreditLedger(t,i))}async __getEnrichedCreditLedger(t,i){let{companyId:o,billingCreditId:s,featureId:r,period:a,startTime:u,endTime:g,limit:h,offset:c}=t,y={company_id:o,billing_credit_id:s,feature_id:r,period:ni.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}),start_time:u,end_time:g,limit:h,offset:c},w=await this._options.authProvider.getAuthRequest(),U=x(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??C)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"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(v.ok)return{data:fd.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 T(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new S(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new R(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new _(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new f(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);default:throw new b({statusCode:v.error.statusCode,body:v.error.body,rawResponse:v.rawResponse})}return E(v.error,v.rawResponse,"GET","/billing/credits/ledger")}countCreditLedger(t,i){return P.fromPromise(this.__countCreditLedger(t,i))}async __countCreditLedger(t,i){let{companyId:o,billingCreditId:s,featureId:r,period:a,startTime:u,endTime:g,limit:h,offset:c}=t,y={company_id:o,billing_credit_id:s,feature_id:r,period:ni.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}),start_time:u,end_time:g,limit:h,offset:c},w=await this._options.authProvider.getAuthRequest(),U=x(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??C)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"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(v.ok)return{data:pd.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 T(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new S(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new R(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new _(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new f(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);default:throw new b({statusCode:v.error.statusCode,body:v.error.body,rawResponse:v.rawResponse})}return E(v.error,v.rawResponse,"GET","/billing/credits/ledger/count")}listBillingPlanCreditGrants(t={},i){return P.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=x(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??C)({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(v.ok)return{data:vd.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 T(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new S(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new R(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new _(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new f(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);default:throw new b({statusCode:v.error.statusCode,body:v.error.body,rawResponse:v.rawResponse})}return E(v.error,v.rawResponse,"GET","/billing/credits/plan-grants")}createBillingPlanCreditGrant(t,i){return P.fromPromise(this.__createBillingPlanCreditGrant(t,i))}async __createBillingPlanCreditGrant(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Eo.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:dd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/billing/credits/plan-grants")}getSingleBillingPlanCreditGrant(t,i){return P.fromPromise(this.__getSingleBillingPlanCreditGrant(t,i))}async __getSingleBillingPlanCreditGrant(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Sd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/billing/credits/plan-grants/{plan_grant_id}")}updateBillingPlanCreditGrant(t,i,o){return P.fromPromise(this.__updateBillingPlanCreditGrant(t,i,o))}async __updateBillingPlanCreditGrant(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:Uo.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:Nd.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/billing/credits/plan-grants/{plan_grant_id}")}deleteBillingPlanCreditGrant(t,i={},o){return P.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=x(a.headers,this._options?.headers,o?.headers),g=await(this._options.fetcher??C)({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:gd.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 T(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new R(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new f(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"DELETE","/billing/credits/plan-grants/{plan_grant_id}")}countBillingPlanCreditGrants(t={},i){return P.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=x(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??C)({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(v.ok)return{data:id.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 T(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new S(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new R(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new _(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new f(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);default:throw new b({statusCode:v.error.statusCode,body:v.error.body,rawResponse:v.rawResponse})}return E(v.error,v.rawResponse,"GET","/billing/credits/plan-grants/count")}listCreditEventLedger(t,i){return P.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=x(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??C)({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(v.ok)return{data:Id.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 T(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new S(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new R(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new _(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new f(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);default:throw new b({statusCode:v.error.statusCode,body:v.error.body,rawResponse:v.rawResponse})}return E(v.error,v.rawResponse,"GET","/v2/billing/credits/ledger")}countCreditEventLedger(t,i){return P.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=x(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??C)({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(v.ok)return{data:cd.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 T(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new S(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new R(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new _(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new f(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);default:throw new b({statusCode:v.error.statusCode,body:v.error.body,rawResponse:v.rawResponse})}return E(v.error,v.rawResponse,"GET","/v2/billing/credits/ledger/count")}};var oa=class{constructor(t){this._options=K(t)}createDataExport(t,i){return P.fromPromise(this.__createDataExport(t,i))}async __createDataExport(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:{...Cn.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:Qd.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/data-exports")}getDataExportArtifact(t,i){return P.fromPromise(this.__getDataExportArtifact(t,i))}async __getDataExportArtifact(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/data-exports/{data_export_id}/artifact")}};var aa=class{constructor(t){this._options=K(t)}listCompanyOverrides(t={},i){return P.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(),v=x(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides"),method:"GET",headers:v,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 T(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new R(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new f(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/company-overrides")}createCompanyOverride(t,i){return P.fromPromise(this.__createCompanyOverride(t,i))}async __createCompanyOverride(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Un.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/company-overrides")}getCompanyOverride(t,i){return P.fromPromise(this.__getCompanyOverride(t,i))}async __getCompanyOverride(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:bm.parseOrThrow(r.body,{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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/company-overrides/{company_override_id}")}updateCompanyOverride(t,i,o){return P.fromPromise(this.__updateCompanyOverride(t,i,o))}async __updateCompanyOverride(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:On.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:Im.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/company-overrides/{company_override_id}")}deleteCompanyOverride(t,i){return P.fromPromise(this.__deleteCompanyOverride(t,i))}async __deleteCompanyOverride(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/company-overrides/{company_override_id}")}countCompanyOverrides(t={},i){return P.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(),v=x(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"company-overrides/count"),method:"GET",headers:v,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:rm.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 T(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new R(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new f(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/company-overrides/count")}listFeatureCompanies(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:km.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/feature-companies")}countFeatureCompanies(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:tm.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/feature-companies/count")}listFeatureUsage(t={},i){return P.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(),v=x(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage"),method:"GET",headers:v,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:jm.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 T(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new R(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new f(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/feature-usage")}getFeatureUsageTimeSeries(t,i){return P.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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:xm.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 S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/feature-usage-timeseries")}countFeatureUsage(t={},i){return P.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(),v=x(U.headers,this._options?.headers,i?.headers),O=await(this._options.fetcher??C)({url:d.join(await m.get(this._options.baseUrl)??await m.get(this._options.environment)??z.Default,"feature-usage/count"),method:"GET",headers:v,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:am.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 T(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 401:throw new S(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 403:throw new R(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 404:throw new _(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);case 500:throw new f(n.parseOrThrow(O.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),O.rawResponse);default:throw new b({statusCode:O.error.statusCode,body:O.error.body,rawResponse:O.rawResponse})}return E(O.error,O.rawResponse,"GET","/feature-usage/count")}listFeatureUsers(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:qm.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/feature-users")}countFeatureUsers(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:sm.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/feature-users/count")}listPlanEntitlements(t={},i){return P.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,v={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=x(O.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??C)({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(v).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:Dm.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 T(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new R(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new f(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return E(B.error,B.rawResponse,"GET","/plan-entitlements")}createPlanEntitlement(t,i){return P.fromPromise(this.__createPlanEntitlement(t,i))}async __createPlanEntitlement(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements")}getPlanEntitlement(t,i){return P.fromPromise(this.__getPlanEntitlement(t,i))}async __getPlanEntitlement(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-entitlements/{plan_entitlement_id}")}updatePlanEntitlement(t,i,o){return P.fromPromise(this.__updatePlanEntitlement(t,i,o))}async __updatePlanEntitlement(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:kn.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:Fm.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-entitlements/{plan_entitlement_id}")}deletePlanEntitlement(t,i){return P.fromPromise(this.__deletePlanEntitlement(t,i))}async __deletePlanEntitlement(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:mm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/plan-entitlements/{plan_entitlement_id}")}upsertPlanEntitlementForBillingProduct(t,i){return P.fromPromise(this.__upsertPlanEntitlementForBillingProduct(t,i))}async __upsertPlanEntitlementForBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements/billing-linked")}countPlanEntitlements(t={},i){return P.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,v={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=x(O.headers,this._options?.headers,i?.headers),B=await(this._options.fetcher??C)({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(v).mergeAdditional(i?.queryParams).build(),timeoutMs:(i?.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:lm.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 T(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 401:throw new S(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 403:throw new R(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 404:throw new _(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);case 500:throw new f(n.parseOrThrow(B.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),B.rawResponse);default:throw new b({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}return E(B.error,B.rawResponse,"GET","/plan-entitlements/count")}duplicatePlanEntitlements(t,i){return P.fromPromise(this.__duplicatePlanEntitlements(t,i))}async __duplicatePlanEntitlements(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-entitlements/duplicate")}getFeatureUsageByCompany(t,i){return P.fromPromise(this.__getFeatureUsageByCompany(t,i))}async __getFeatureUsageByCompany(t,i){let{keys:o}=t,s={keys:ve(o)},r=await this._options.authProvider.getAuthRequest(),a=x(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??C)({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:Rm.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 S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new R(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new f(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return E(u.error,u.rawResponse,"GET","/usage-by-company")}};var na=class{constructor(t){this._options=K(t)}createEventBatch(t,i){return P.fromPromise(this.__createEventBatch(t,i))}async __createEventBatch(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Bn.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:$m.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/event-batch")}getEventSummaries(t={},i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Qm.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/event-types")}listEvents(t={},i){return P.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=x(w.headers,this._options?.headers,i?.headers),v=await(this._options.fetcher??C)({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(v.ok)return{data:th.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 T(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 401:throw new S(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 403:throw new R(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 404:throw new _(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);case 500:throw new f(n.parseOrThrow(v.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),v.rawResponse);default:throw new b({statusCode:v.error.statusCode,body:v.error.body,rawResponse:v.rawResponse})}return E(v.error,v.rawResponse,"GET","/events")}createEvent(t,i){return P.fromPromise(this.__createEvent(t,i))}async __createEvent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ho.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: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 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/events")}getEvent(t,i){return P.fromPromise(this.__getEvent(t,i))}async __getEvent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Zm.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/events/{event_id}")}getSegmentIntegrationStatus(t){return P.fromPromise(this.__getSegmentIntegrationStatus(t))}async __getSegmentIntegrationStatus(t){let i=await this._options.authProvider.getAuthRequest(),o=x(i.headers,this._options?.headers,t?.headers),s=await(this._options.fetcher??C)({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:rh.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 S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new R(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new f(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/segment-integration")}};var sa=class{constructor(t){this._options=K(t)}listFeatures(t={},i){return P.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},v=await this._options.authProvider.getAuthRequest(),O=x(v.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new R(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new f(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return E(j.error,j.rawResponse,"GET","/features")}createFeature(t,i){return P.fromPromise(this.__createFeature(t,i))}async __createFeature(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/features")}getFeature(t,i){return P.fromPromise(this.__getFeature(t,i))}async __getFeature(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/features/{feature_id}")}updateFeature(t,i={},o){return P.fromPromise(this.__updateFeature(t,i,o))}async __updateFeature(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:qn.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:Ch.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/features/{feature_id}")}deleteFeature(t,i){return P.fromPromise(this.__deleteFeature(t,i))}async __deleteFeature(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/features/{feature_id}")}upsertFeatureForBillingProduct(t,i){return P.fromPromise(this.__upsertFeatureForBillingProduct(t,i))}async __upsertFeatureForBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/features/billing-linked")}countFeatures(t={},i){return P.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},v=await this._options.authProvider.getAuthRequest(),O=x(v.headers,this._options?.headers,i?.headers),j=await(this._options.fetcher??C)({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:mh.parseOrThrow(j.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:j.rawResponse};if(j.error.reason==="status-code")switch(j.error.statusCode){case 400:throw new T(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 401:throw new S(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 403:throw new R(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 404:throw new _(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);case 500:throw new f(n.parseOrThrow(j.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),j.rawResponse);default:throw new b({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse})}return E(j.error,j.rawResponse,"GET","/features/count")}listFlags(t={},i){return P.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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:xh.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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/flags")}createFlag(t,i){return P.fromPromise(this.__createFlag(t,i))}async __createFlag(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags")}getFlag(t,i){return P.fromPromise(this.__getFlag(t,i))}async __getFlag(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:fh.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/flags/{flag_id}")}updateFlag(t,i,o){return P.fromPromise(this.__updateFlag(t,i,o))}async __updateFlag(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:os.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/flags/{flag_id}")}deleteFlag(t,i){return P.fromPromise(this.__deleteFlag(t,i))}async __deleteFlag(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/flags/{flag_id}")}updateFlagRules(t,i,o){return P.fromPromise(this.__updateFlagRules(t,i,o))}async __updateFlagRules(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:Th.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/flags/{flag_id}/rules")}checkFlag(t,i,o){return P.fromPromise(this.__checkFlag(t,i,o))}async __checkFlag(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:mt.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:nh.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/flags/{key}/check")}checkFlags(t,i){return P.fromPromise(this.__checkFlags(t,i))}async __checkFlags(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:mt.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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags/check")}checkFlagsBulk(t,i){return P.fromPromise(this.__checkFlagsBulk(t,i))}async __checkFlagsBulk(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/flags/check-bulk")}countFlags(t={},i){return P.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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:gh.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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/flags/count")}};var ca=class{constructor(t){this._options=K(t)}getActivity(t={},i){return P.fromPromise(this.__getActivity(t,i))}async __getActivity(t={},i){let{limit:o}=t,s={limit:o},r=await this._options.authProvider.getAuthRequest(),a=x(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??C)({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:Ah.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 S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new R(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new f(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return E(u.error,u.rawResponse,"GET","/insights/activity")}getEnvironmentFeatureUsageTimeSeries(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Mh.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 S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/insights/feature-usage-timeseries")}getPlanGrowth(t={},i){return P.fromPromise(this.__getPlanGrowth(t,i))}async __getPlanGrowth(t={},i){let{months:o}=t,s={months:o},r=await this._options.authProvider.getAuthRequest(),a=x(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??C)({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:Wh.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 S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new R(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new f(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return E(u.error,u.rawResponse,"GET","/insights/plan-growth")}getSummary(t){return P.fromPromise(this.__getSummary(t))}async __getSummary(t){let i=await this._options.authProvider.getAuthRequest(),o=x(i.headers,this._options?.headers,t?.headers),s=await(this._options.fetcher??C)({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:$h.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 S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new R(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new f(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/insights/summary")}getTopFeaturesByUsage(t,i){return P.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=x(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({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:Xh.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 S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new R(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new f(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/insights/top-features")}getEnvironmentTraitUsageTimeSeries(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Fh.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 S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/insights/trait-usage-timeseries")}};var la=class{constructor(t){this._options=K(t)}runIntegration(t,i){return P.fromPromise(this.__runIntegration(t,i))}async __runIntegration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:yg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/integration/start/{integration_id}")}listIntegrations(t={},i){return P.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=x(y.headers,this._options?.headers,i?.headers),U=await(this._options.fetcher??C)({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:mg.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 T(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 401:throw new S(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 403:throw new R(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 404:throw new _(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);case 500:throw new f(n.parseOrThrow(U.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),U.rawResponse);default:throw new b({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}return E(U.error,U.rawResponse,"GET","/integrations")}getIntegrationWebhookUrl(t,i){return P.fromPromise(this.__getIntegrationWebhookUrl(t,i))}async __getIntegrationWebhookUrl(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:cg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/integrations/{type}/webhook-url")}installIntegration(t,i){return P.fromPromise(this.__installIntegration(t,i))}async __installIntegration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Wo.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/install")}startDataImport(t,i){return P.fromPromise(this.__startDataImport(t,i))}async __startDataImport(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/start-data-import")}loadSampleDataSet(t){return P.fromPromise(this.__loadSampleDataSet(t))}async __loadSampleDataSet(t){let i=await this._options.authProvider.getAuthRequest(),o=x(i.headers,this._options?.headers,t?.headers),s=await(this._options.fetcher??C)({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:gg.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 S(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new R(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new _(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new f(n.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new b({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return E(s.error,s.rawResponse,"GET","/integrations/stripe/dataset-sample-v2")}assumeStripeInstalled(t,i){return P.fromPromise(this.__assumeStripeInstalled(t,i))}async __assumeStripeInstalled(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Wo.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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/stripe/v2/assume-installed")}installStripe(t,i){return P.fromPromise(this.__installStripe(t,i))}async __installStripe(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Wo.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:pg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/integrations/stripe/v2/install")}uninstallIntegration(t,i){return P.fromPromise(this.__uninstallIntegration(t,i))}async __uninstallIntegration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/integrations/uninstall/{integration_id}")}};var pa=class{constructor(t){this._options=K(t)}createCustomPlanBundle(t,i){return P.fromPromise(this.__createCustomPlanBundle(t,i))}async __createCustomPlanBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:In.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/custom-plan-bundles")}createPlanBundle(t,i){return P.fromPromise(this.__createPlanBundle(t,i))}async __createPlanBundle(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Fn.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:Pg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-bundles")}updatePlanBundle(t,i,o){return P.fromPromise(this.__updatePlanBundle(t,i,o))}async __updatePlanBundle(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:Kn.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:xg.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-bundles/{plan_bundle_id}")}};var ua=class{constructor(t){this._options=K(t)}getPlanGroup(t={},i){return P.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=x(r.headers,this._options?.headers,i?.headers),u=await(this._options.fetcher??C)({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:Bg.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 S(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 403:throw new R(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 404:throw new _(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);case 500:throw new f(n.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new b({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return E(u.error,u.rawResponse,"GET","/plan-groups")}createPlanGroup(t,i){return P.fromPromise(this.__createPlanGroup(t,i))}async __createPlanGroup(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Ln.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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-groups")}updatePlanGroup(t,i,o){return P.fromPromise(this.__updatePlanGroup(t,i,o))}async __updatePlanGroup(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:Gn.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:jg.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plan-groups/{plan_group_id}")}};var da=class{constructor(t){this._options=K(t)}listCompanyMigrations(t={},i){return P.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?Cr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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:Kg.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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/plan-version-company-migrations")}retryCompanyMigration(t,i){return P.fromPromise(this.__retryCompanyMigration(t,i))}async __retryCompanyMigration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-version-company-migrations/{plan_version_company_migration_id}/retry")}countCompanyMigrations(t={},i){return P.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?Cr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}):void 0,limit:a,offset:u},h=await this._options.authProvider.getAuthRequest(),c=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/plan-version-company-migrations/count")}listMigrations(t={},i){return P.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?Er.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:Gg.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/plan-version-migrations")}createMigration(t,i){return P.fromPromise(this.__createMigration(t,i))}async __createMigration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plan-version-migrations")}getMigration(t,i){return P.fromPromise(this.__getMigration(t,i))}async __getMigration(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/plan-version-migrations/{plan_version_migration_id}")}retryMigration(t,i,o){return P.fromPromise(this.__retryMigration(t,i,o))}async __retryMigration(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:Ng.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"POST","/plan-version-migrations/{plan_version_migration_id}/retry")}countMigrations(t={},i){return P.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?Er.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/plan-version-migrations/count")}};var ma=class{constructor(t){this._options=K(t)}updateCompanyPlans(t,i,o){return P.fromPromise(this.__updateCompanyPlans(t,i,o))}async __updateCompanyPlans(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:gy.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/company-plans/{company_plan_id}")}listCustomPlanBillings(t={},i){return P.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=x(c.headers,this._options?.headers,i?.headers),w=await(this._options.fetcher??C)({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:sy.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 T(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 401:throw new S(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 403:throw new R(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 404:throw new _(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);case 500:throw new f(n.parseOrThrow(w.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),w.rawResponse);default:throw new b({statusCode:w.error.statusCode,body:w.error.body,rawResponse:w.rawResponse})}return E(w.error,w.rawResponse,"GET","/custom-plan-billings")}markCustomPlanBillingPaid(t,i,o){return P.fromPromise(this.__markCustomPlanBillingPaid(t,i,o))}async __markCustomPlanBillingPaid(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:Fy.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:dy.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/mark-paid")}retryCustomPlanBilling(t,i,o){return P.fromPromise(this.__retryCustomPlanBilling(t,i,o))}async __retryCustomPlanBilling(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:hy.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/custom-plan-billings/{custom_plan_billing_id}/retry")}createCustomPlan(t,i){return P.fromPromise(this.__createCustomPlan(t,i))}async __createCustomPlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/custom-plans")}listPlans(t={},i){return P.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:v,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:v,with_entitlements:O,without_entitlement_for:j,without_paid_product_id:B,limit:I,offset:A},_e=await this._options.authProvider.getAuthRequest(),q=x(_e.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??C)({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:uy.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 T(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new R(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new f(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return E(M.error,M.rawResponse,"GET","/plans")}createPlan(t,i){return P.fromPromise(this.__createPlan(t,i))}async __createPlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:xo.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plans")}getPlan(t,i={},o){return P.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=x(a.headers,this._options?.headers,o?.headers),g=await(this._options.fetcher??C)({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:ty.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 401:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new R(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new f(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/plans/{plan_id}")}updatePlan(t,i,o){return P.fromPromise(this.__updatePlan(t,i,o))}async __updatePlan(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:To.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:yy.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/{plan_id}")}deletePlan(t,i){return P.fromPromise(this.__deletePlan(t,i))}async __deletePlan(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Qg.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/plans/{plan_id}")}upsertBillingProductPlan(t,i,o){return P.fromPromise(this.__upsertBillingProductPlan(t,i,o))}async __upsertBillingProductPlan(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/{plan_id}/billing_products")}upsertPlanForBillingProduct(t,i){return P.fromPromise(this.__upsertPlanForBillingProduct(t,i))}async __upsertPlanForBillingProduct(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:$n.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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/plans/billing-linked")}listBillingProductMatchCompanies(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:ay.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/plans/billing-product-match-companies")}countBillingProductMatchCompanies(t,i){return P.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=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:$g.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/plans/billing-product-match-companies/count")}countPlans(t={},i){return P.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:v,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:v,with_entitlements:O,without_entitlement_for:j,without_paid_product_id:B,limit:I,offset:A},_e=await this._options.authProvider.getAuthRequest(),q=x(_e.headers,this._options?.headers,i?.headers),M=await(this._options.fetcher??C)({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:Yg.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 T(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 401:throw new S(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 403:throw new R(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 404:throw new _(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);case 500:throw new f(n.parseOrThrow(M.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),M.rawResponse);default:throw new b({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}return E(M.error,M.rawResponse,"GET","/plans/count")}listPlanIssues(t,i){return P.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=x(a.headers,this._options?.headers,i?.headers),g=await(this._options.fetcher??C)({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:ly.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 T(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new R(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new f(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"GET","/plans/issues")}deletePlanVersion(t,i={},o){return P.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=x(a.headers,this._options?.headers,o?.headers),g=await(this._options.fetcher??C)({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:ry.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 T(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new S(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new R(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 500:throw new f(n.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new b({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return E(g.error,g.rawResponse,"DELETE","/plans/version/{plan_id}")}publishPlanVersion(t,i,o){return P.fromPromise(this.__publishPlanVersion(t,i,o))}async __publishPlanVersion(t,i,o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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:my.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/plans/version/{plan_id}/publish")}};var ha=class{constructor(t){this._options=K(t)}listScheduledCheckouts(t={},i){return P.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?Zr.jsonOrThrow(s,{unrecognizedObjectKeys:"strip"}):void 0,limit:r,offset:a},g=await this._options.authProvider.getAuthRequest(),h=x(g.headers,this._options?.headers,i?.headers),c=await(this._options.fetcher??C)({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:_y.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 T(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 401:throw new S(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new R(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _(n.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 500:throw new f(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 E(c.error,c.rawResponse,"GET","/scheduled-checkout")}createScheduledCheckout(t,i){return P.fromPromise(this.__createScheduledCheckout(t,i))}async __createScheduledCheckout(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/scheduled-checkout")}getScheduledCheckout(t,i){return P.fromPromise(this.__getScheduledCheckout(t,i))}async __getScheduledCheckout(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:Ry.parseOrThrow(r.body,{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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/scheduled-checkout/{scheduled_checkout_id}")}updateScheduledCheckout(t,i={},o){return P.fromPromise(this.__updateScheduledCheckout(t,i,o))}async __updateScheduledCheckout(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/scheduled-checkout/{scheduled_checkout_id}")}};var ga=class{constructor(t){this._options=K(t)}listWebhookEvents(t={},i){return P.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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:jy.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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/webhook-events")}getWebhookEvent(t,i){return P.fromPromise(this.__getWebhookEvent(t,i))}async __getWebhookEvent(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/webhook-events/{webhook_event_id}")}countWebhookEvents(t={},i){return P.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=x(h.headers,this._options?.headers,i?.headers),y=await(this._options.fetcher??C)({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:xy.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 T(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 401:throw new S(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 403:throw new R(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 404:throw new _(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);case 500:throw new f(n.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new b({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}return E(y.error,y.rawResponse,"GET","/webhook-events/count")}listWebhooks(t={},i){return P.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=x(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({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:Vy.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 T(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new R(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new f(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/webhooks")}createWebhook(t,i){return P.fromPromise(this.__createWebhook(t,i))}async __createWebhook(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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: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: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 T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"POST","/webhooks")}getWebhook(t,i){return P.fromPromise(this.__getWebhook(t,i))}async __getWebhook(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:ky.parseOrThrow(r.body,{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 S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"GET","/webhooks/{webhook_id}")}updateWebhook(t,i={},o){return P.fromPromise(this.__updateWebhook(t,i,o))}async __updateWebhook(t,i={},o){let s=await this._options.authProvider.getAuthRequest(),r=x(s.headers,this._options?.headers,o?.headers),a=await(this._options.fetcher??C)({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:is.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:qy.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 T(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new S(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new R(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 500:throw new f(n.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new b({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return E(a.error,a.rawResponse,"PUT","/webhooks/{webhook_id}")}deleteWebhook(t,i){return P.fromPromise(this.__deleteWebhook(t,i))}async __deleteWebhook(t,i){let o=await this._options.authProvider.getAuthRequest(),s=x(o.headers,this._options?.headers,i?.headers),r=await(this._options.fetcher??C)({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:vy.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:r.rawResponse};if(r.error.reason==="status-code")switch(r.error.statusCode){case 400:throw new T(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 401:throw new S(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 403:throw new R(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 404:throw new _(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);case 500:throw new f(n.parseOrThrow(r.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),r.rawResponse);default:throw new b({statusCode:r.error.statusCode,body:r.error.body,rawResponse:r.rawResponse})}return E(r.error,r.rawResponse,"DELETE","/webhooks/{webhook_id}")}countWebhooks(t={},i){return P.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=x(u.headers,this._options?.headers,i?.headers),h=await(this._options.fetcher??C)({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: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 T(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 401:throw new S(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 403:throw new R(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 404:throw new _(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);case 500:throw new f(n.parseOrThrow(h.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),h.rawResponse);default:throw new b({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}return E(h.error,h.rawResponse,"GET","/webhooks/count")}};var ya=class{constructor(t){this._options=K(t)}get accounts(){return this._accounts??=new Zo(this._options)}get billing(){return this._billing??=new Xo(this._options)}get credits(){return this._credits??=new ta(this._options)}get checkout(){return this._checkout??=new Qo(this._options)}get companies(){return this._companies??=new ea(this._options)}get entitlements(){return this._entitlements??=new aa(this._options)}get plans(){return this._plans??=new ma(this._options)}get components(){return this._components??=new ra(this._options)}get planbundle(){return this._planbundle??=new pa(this._options)}get dataexports(){return this._dataexports??=new oa(this._options)}get events(){return this._events??=new na(this._options)}get features(){return this._features??=new sa(this._options)}get insights(){return this._insights??=new ca(this._options)}get integrationsapi(){return this._integrationsapi??=new la(this._options)}get plangroups(){return this._plangroups??=new ua(this._options)}get planmigrations(){return this._planmigrations??=new da(this._options)}get componentspublic(){return this._componentspublic??=new ia(this._options)}get scheduledcheckout(){return this._scheduledcheckout??=new ha(this._options)}get accesstokens(){return this._accesstokens??=new Yo(this._options)}get webhooks(){return this._webhooks??=new ga(this._options)}async fetch(t,i,o){return Va(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"},us={[er.Debug]:1,[er.Info]:2,[er.Warn]:3,[er.Error]:4},Xy=er.Warn,ei=class{constructor(t=Xy){this.level=us[t]??us[Xy]}shouldLog(t){return us[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 Mz=1e3,Dz=1e3,Iz=3,Fz=1e3,wa=class{constructor(t,i){this.events=[];this.intervalId=null;this.shutdown=!1;this.stopped=!1;this.flushing=!1;let{logger:o=new ei,maxSize:s=Dz,interval:r=Mz,offline:a=!1,maxRetries:u=Iz,initialRetryDelay:g=Fz}=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 Kz="https://c.schematichq.com",Lz=1e4,Gz=p=>p.replace(/\/+$/,"")+"/batch",Wz=(p,t)=>{let i={api_key:t,type:p.eventType};return p.body!==void 0&&(i.body=mo.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},Nz=(p,t)=>({events:p.map(i=>Wz(i,t))}),Hz=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"}},ba=class{constructor(t){this.apiKey=t.apiKey,this.baseUrl=t.baseUrl??Kz,this.timeoutMs=t.timeoutMs??Lz,this.fetcher=t.fetcher,this.headers=t.headers??{}}async sendBatch(t){if(t.length===0)return;let i=await this.fetcher({url:Gz(this.baseUrl),method:"POST",contentType:"application/json",requestType:"json",headers:{...this.headers,"X-Schematic-Api-Key":this.apiKey},body:Nz(t,this.apiKey),timeoutMs:this.timeoutMs,maxRetries:0});if(!i.ok)throw new Error(`capture service returned ${Hz(i.error)}`)}};function Qy(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}`:xt(i.url,i.queryParameters),r=await Ct({body:i.body,type:i.requestType==="json"?"json":"other"}),a=await di();try{let u=await yi(async()=>mi(a,s,i.method,o,r,i.timeoutMs,i.abortSignal,i.withCredentials,i.duplex),i.maxRetries),g=await ui(u,i.responseType),h=at(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:hi}:u instanceof Error&&u.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:hi}:u instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:u.message},rawResponse:gi}:{ok:!1,error:{reason:"unknown",errorMessage:JSON.stringify(u)},rawResponse:gi}}}}async function $z(p){return{ok:!0,body:{},headers:{"Content-Type":"application/json"},rawResponse:{headers:new ir,redirected:!1,status:200,statusText:"OK",type:"basic",url:""}}}var ew=$z;var Zi=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(Jz(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 Jz(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}ds();var Yz={unrecognizedObjectKeys:"passthrough"};function rw(p,t){let i=p.parse(t,Yz);return i.ok?i.value:t}function hs(p){return JSON.parse(JSON.stringify(p))}function Zz(p){return JSON.parse(JSON.stringify(p))}function iw(p,t){let i=hs(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=>rw(No,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=>rw(Ho,g));i.metrics=Qz(a,u),s=!0;break}}return(o||s)&&!("entitlements"in t)&&Xz(i,o,s),i}function Xz(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(za(ms(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(za({eventSubtype:u,period:g,monthReset:h}));c!==void 0&&(r.usage=c)}}}function tw(p,t){let i=Zz(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 za(p){return`${p.eventSubtype}|${p.period}|${p.monthReset}`}function ms(p){return{eventSubtype:(p.eventSubtype??p.event_subtype)||"",period:p.period||"",monthReset:(p.monthReset??p.month_reset)||""}}function Qz(p,t){let i=[...p],o=new Map;for(let s=0;s<i.length;s++){let r=i[s];if(r){let a=za(ms(r));o.set(a,s)}}for(let s of t){if(!s)continue;let r=za(ms(s)),a=o.get(r);a!==void 0?i[a]=s:i.push(s)}return i}var ur="company",dr="user",sR="flags",ys=30*1e3,cR=1440*60*1e3,lR=720*60*60*1e3,gt=class extends Xi{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??cR,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 Zi}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 ii({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 ii({client:i.redisClient,keyPrefix:i.redisKeyPrefix||"schematic:",ttl:o}):new rr({ttl:o})}calculateCacheTTL(i){return i==="flag"?Math.max(lR,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}=(dw(),_s(uw));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"))},ys),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"))},ys),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"))},ys);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=iw(a,i.data)}catch(u){this.logger.error(`Failed to merge partial company: ${u}`);return}}else try{o=Yy.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=tw(a,i.data)}catch(u){this.logger.error(`Failed to merge partial user: ${u}`);return}}else try{o=Zy.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(ss.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=ss.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=`${sR}:${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 hs(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 yt=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 wt=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 bt=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 uR="schematic:",dR="credit-lease:",mw=6e4,hw=`
4
+ redis.replicate_commands()
5
+ local t = redis.call('TIME')
6
+ local now = (tonumber(t[1]) * 1000) + math.floor(tonumber(t[2]) / 1000)
7
+ `,mR=hw+`
8
+ local existing_id = redis.call('HGET', KEYS[1], 'leaseId')
9
+ local existing_expiry = tonumber(redis.call('HGET', KEYS[1], 'expiresAt') or '0')
10
+ local new_id = ARGV[1]
11
+ local new_granted = ARGV[2]
12
+ local new_expiry = tonumber(ARGV[3])
13
+ local grace = tonumber(ARGV[4])
14
+
15
+ if existing_id and existing_expiry > now then
16
+ return 0
17
+ end
18
+
19
+ redis.call('DEL', KEYS[1])
20
+ redis.call('HSET', KEYS[1],
21
+ 'leaseId', new_id,
22
+ 'companyId', ARGV[5],
23
+ 'creditTypeId', ARGV[6],
24
+ 'grantedAmount', new_granted,
25
+ 'localRemainingCredits', new_granted,
26
+ 'expiresAt', ARGV[3])
27
+ redis.call('PEXPIREAT', KEYS[1], new_expiry + grace)
28
+ return 1
29
+ `,hR=hw+`
30
+ local raw = redis.call('HGET', KEYS[1], 'localRemainingCredits')
31
+ if not raw then return false end
32
+ local expiry = tonumber(redis.call('HGET', KEYS[1], 'expiresAt') or '0')
33
+ if expiry <= now then return false end
34
+ local remaining = tonumber(raw)
35
+ local requested = tonumber(ARGV[1])
36
+ if remaining < requested then return false end
37
+ local new_remaining = remaining - requested
38
+ redis.call('HSET', KEYS[1], 'localRemainingCredits', tostring(new_remaining))
39
+ return tostring(new_remaining)
40
+ `,gR=`
41
+ local raw_remaining = redis.call('HGET', KEYS[1], 'localRemainingCredits')
42
+ if not raw_remaining then return 0 end
43
+ local required_lease = ARGV[2]
44
+ if required_lease and required_lease ~= '' then
45
+ local current_lease = redis.call('HGET', KEYS[1], 'leaseId')
46
+ if current_lease ~= required_lease then return 0 end
47
+ end
48
+ local remaining = tonumber(raw_remaining)
49
+ local granted = tonumber(redis.call('HGET', KEYS[1], 'grantedAmount') or '0')
50
+ local refund = tonumber(ARGV[1])
51
+ local new_balance = remaining + refund
52
+ if new_balance > granted then new_balance = granted end
53
+ redis.call('HSET', KEYS[1], 'localRemainingCredits', tostring(new_balance))
54
+ return 1
55
+ `,yR=`
56
+ local raw_granted = redis.call('HGET', KEYS[1], 'grantedAmount')
57
+ if not raw_granted then return 0 end
58
+ local required_lease = ARGV[4]
59
+ if required_lease and required_lease ~= '' then
60
+ local current_lease = redis.call('HGET', KEYS[1], 'leaseId')
61
+ if current_lease ~= required_lease then return 0 end
62
+ end
63
+ local granted = tonumber(raw_granted)
64
+ local target = tonumber(ARGV[1])
65
+ local add = target - granted
66
+ if add > 0 then
67
+ local remaining = tonumber(redis.call('HGET', KEYS[1], 'localRemainingCredits') or '0')
68
+ redis.call('HSET', KEYS[1],
69
+ 'grantedAmount', tostring(target),
70
+ 'localRemainingCredits', tostring(remaining + add))
71
+ end
72
+ local new_expiry = tonumber(ARGV[2])
73
+ local grace = tonumber(ARGV[3])
74
+ local current_expiry = tonumber(redis.call('HGET', KEYS[1], 'expiresAt') or '0')
75
+ if new_expiry > current_expiry then
76
+ redis.call('HSET', KEYS[1], 'expiresAt', ARGV[2])
77
+ redis.call('PEXPIREAT', KEYS[1], new_expiry + grace)
78
+ end
79
+ return 1
80
+ `,zt=class{constructor(t){this.client=t.client,this.keyPrefix=t.keyPrefix??uR,this.defaultLeaseDurationMs=t.defaultLeaseDurationMs??3e5}hashKey(t,i){return`${this.keyPrefix}${dR}${$e(t,i)}`}async get(t,i){let o=await this.client.hGetAll(this.hashKey(t,i));if(!(!o||!o.leaseId))return wR(o)}async replace(t){let i=await this.client.eval(mR,{keys:[this.hashKey(t.companyId,t.creditTypeId)],arguments:[t.leaseId,String(t.grantedAmount),String(t.expiresAt.getTime()),String(mw),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(yR,{keys:[this.hashKey(t,i)],arguments:[String(o),String(a),String(mw),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(hR,{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(gR,{keys:[this.hashKey(t,i)],arguments:[String(o),s??""]})}};function wR(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 bR="schematic:",zR="credit-reservation:",RR="credit-reservations:byExpiry",fR="credit-reservations:byCredit:";var _R=`
81
+ local raw = redis.call('HGETALL', KEYS[1])
82
+ if #raw == 0 then return nil end
83
+ redis.call('DEL', KEYS[1])
84
+ return raw
85
+ `;function gw(p){return`${p.companyId}|${p.creditTypeId}|${p.id}`}function SR(p){let t=p.split("|");if(t.length===3)return{companyId:t[0],creditTypeId:t[1],id:t[2]}}var yw=256,PR=16,Rt=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??bR}hashKey(t){return`${this.keyPrefix}${zR}${t}`}indexKey(){return`${this.keyPrefix}${RR}`}byCreditKey(t,i){return`${this.keyPrefix}${fR}${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:gw(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 CR(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(_R,{keys:[this.hashKey(t)],arguments:[]}),s=xR(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(),gw({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<PR;s++){let r=await this.client.zRangeByScore(this.indexKey(),0,i,{LIMIT:{offset:0,count:yw}});if(r.length===0)break;for(let a of r){let u=SR(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<yw)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 xR(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 CR(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 Qi(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 Rw(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`),Qi(p,i,fa(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}=UR(o);if(!i.company)return h.debug("Lease check: no company on evalCtx, falling back"),s();let v=null;try{v=await r.getCompany(i.company)}catch(Ue){h.debug(`Lease check: company fetch failed for keys ${JSON.stringify(i.company)} (${Ue}), falling back`)}if(!v)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 vR(r,y,v,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=>BR({datastream:r,logger:h,mode:c,key:t,reason:Ue,flag:y,company:v,user:O,creditId:B,options:o}).then(ft=>Qi(p,i,ft,{companyId:v.id,userId:O?.id})),M=await g.acquireIfNeeded(v.id,B,_e);if(!M)return q("lease_acquire_failed");let hr;try{hr=await a.tryReserve(v.id,B,X),hr===null&&(await g.maybeExtendInBackground(v.id,B,X,_e),hr=await a.tryReserve(v.id,B,X))}catch(Ue){return h.error(`Lease check: reserve against ${v.id}/${B} failed: ${Ue}`),q("lease_store_error")}if(hr===null)return q("insufficient_lease_balance");let Ve=OR({leaseId:M.leaseId,companyId:v.id,creditTypeId:B,eventSubtype:A,quantityReserved:U,creditsReserved:X,consumptionRate:I,reservationTTL:ER(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(v.id,B,X,M.leaseId)}catch(ft){h.warn(`Lease check: could not undo local debit for ${Ve.id} (${ft}); the slice is reclaimed at lease expiry`)}return q("lease_store_error")}let F=hr+X,gr=fw(v,B,F),Uw=_a(o),ue;try{ue=await r.getRulesEngine().checkFlagWithOptions(y,gr,O??null,Uw)}catch(Ue){return h.error(`Lease check: WASM eval failed: ${Ue}`),await ws(u,Ve,h),Qi(p,i,fa(c,t,`wasm_error: ${Ue}`,y),{companyId:v.id,userId:O?.id})}let Ea={companyId:ue.companyId??v.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 ws(u,Ve,h),Qi(p,i,{allowed:!0,value:!0,reason:ue.reason??"allowed_without_credit_rule",entitlement:Ra(ue.entitlement),flagKey:ue.flagKey??t,flagId:ue.flagId},Ea)):(g.maybeExtendInBackground(v.id,B),Qi(p,i,{allowed:!0,value:!0,reservation:Ve,reason:ue.reason??"lease_reserved",entitlement:Ra(ue.entitlement),flagKey:ue.flagKey??t,flagId:ue.flagId},Ea)):(await ws(u,Ve,h),Qi(p,i,{allowed:!1,value:!1,reason:ue.reason??"denied_by_engine",entitlement:Ra(ue.entitlement),flagKey:ue.flagKey??t,flagId:ue.flagId},Ea))}function ER(p,t){return p.manager.resolveConfig(t)}function UR(p){return{eventSubtype:p.eventSubtype,quantity:p.usage??0}}function _a(p){if(p.usage!==void 0)return p.eventSubtype!==void 0?{eventUsage:{eventSubtype:p.eventSubtype,quantity:p.usage}}:{usage:p.usage}}async function vR(p,t,i,o,s,r){let a=ww(t,s);if(!a)return null;if(TR(t,s).size<=1)return a;try{let g=(await p.getRulesEngine().checkFlagWithOptions(t,i,o,null)).entitlement?.creditId;if(g){let h=ww(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 TR(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 ww(p,t,i){for(let o of p.rules??[]){let s=bw(o.conditions??[],t,i);if(s)return{...s,ruleId:o.id};for(let r of o.conditionGroups??[]){let a=bw(r.conditions??[],t,i);if(a)return{...a,ruleId:o.id}}}return null}function bw(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 fw(p,t,i){return{...p,creditBalances:{...p.creditBalances??{},[t]:i}}}function OR(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 Ra(p){if(p)return{...p,metricResetAt:p.metricResetAt?new Date(p.metricResetAt):void 0}}async function ws(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 kR=Number.MAX_SAFE_INTEGER;async function BR(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 fa(o,s,r,a);try{let y=fw(u,h,kR),w=await t.getRulesEngine().checkFlagWithOptions(a,y,g,_a(c));return{allowed:w.value,value:w.value,reason:`${w.reason??"evaluated"} (${r}_fail_open)`,entitlement:Ra(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`),fa(o,s,r,a)}}function fa(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 _w(p,t,i,o){let s=i*t.consumptionRate,r=await p.consume(t.id,s);return{track:Sa(t,i,o),settledLocally:r!==null}}function Sa(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 Pw="lease-reservation:",Pa=class extends ya{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 ei(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?ew:Qy(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 v={},O=this._options?.headers;if(O)for(let[B,I]of Object.entries(O))typeof I=="string"&&(v[B]=I);let j=new ba({apiKey:o,fetcher:U,headers:v,baseUrl:a,timeoutMs:h});if(this.eventBuffer=new wa(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 gt(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 zt({client:I,keyPrefix:A,defaultLeaseDurationMs:i.creditLeases.defaultLeaseDuration}),this.reservations=new Rt({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 yt,this.reservations=new wt(this.leaseStore,B)),this.reservations.startSweep(),this.creditLeaseManager=new bt({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(St.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 h=await this.checkFlagsViaDataStream(i,o);if(h)return h}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=[];for(let h of o){let c=JSON.stringify({evalCtx:i,key:h}),y=!1;for(let w of this.flagCheckCacheProviders){let U=await w.get(c);if(U!=null){this.logger.debug(`${w.constructor.name} cache hit for flag ${h}`),s.set(h,{flag:h,value:U.value,reason:U.reason}),y=!0;break}}y||r.push(h)}if(r.length===0)return this.logger.debug(`All ${o.length} flags found in cache`),o.map(h=>s.get(h));this.logger.debug(`Cache miss for ${r.length} flags: ${r.join(", ")}, calling API`);let u=(await this.features.checkFlags(i)).data.flags,g=[];for(let h of o){let c=u.find(y=>y.flag===h);if(c){let y=JSON.stringify({evalCtx:i,key:h}),w={companyId:c.companyId,entitlement:c.entitlement,err:c.error,flagKey:c.flag,flagId:c.flagId,reason:c.reason,ruleId:c.ruleId,ruleType:c.ruleType,userId:c.userId,value:c.value};try{for(let U of this.flagCheckCacheProviders)this.logger.debug(`Caching value for flag ${y} in ${U.constructor.name}`),await U.set(y,w)}catch(U){this.logger.warn(`Cache write failed for flag ${h}: ${U}`)}g.push(c)}else{let y=s.get(h);if(y)g.push(y);else{this.logger.debug(`Flag ${h} not found in API response or cache, using default value`);let w={flag:h,value:this.getFlagDefault(h),reason:"Flag not found - using default value"};g.push(w)}}}return this.logger.debug(`Checked ${o.length} flags: used fresh API values for consistency (${r.length} were cache misses)`),g}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?_a(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(St.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(Sa(i,o,s),{idempotencyKey:`${Pw}${i.id}`});return}let r,a;try{({track:r,settledLocally:a}=await _w(this.reservations,i,o,s))}catch(u){this.logger.warn(`trackWithReservation: failed to settle reservation ${i.id} locally (${u}) \u2014 emitting track anyway`),r=Sa(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:`${Pw}${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 xa=et(require("crypto")),bs="X-Schematic-Webhook-Signature",zs="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 Ca(p,t,i){let o=Buffer.isBuffer(p)?p:Buffer.from(p),s=Buffer.concat([o,Buffer.from(`+${t}`)]),r=xa.createHmac("sha256",i);return r.update(s),r.digest()}function Cw(p,t,i){return Ca(p,t,i).toString("hex")}function Rs(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=Ca(p,i,o);if(s.length!==r.length||!xa.timingSafeEqual(s,r))throw mr.invalidSignature()}function Ew(p,t,i,o={}){let s=p.headers,r=o.signatureHeader||bs,a=o.timestampHeader||zs,u=xw(s,r),g=xw(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.");Rs(h,u,g,t)}function xw(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});