@stacksjs/orm 0.72.61 → 0.72.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ Signature verification is impossible without access to the original signed mater
|
|
|
12
12
|
If a webhook request is being forwarded by a third-party tool, ensure that the exact request body, including JSON formatting and new line style, is preserved.
|
|
13
13
|
`+x+`
|
|
14
14
|
`+P})}let U=Math.floor((typeof R==="number"?R:Date.now())/1000)-p.timestamp;if(k>0&&U>k)throw new N(m,u,{message:"Timestamp outside the tolerance zone"});return!0}function s(u,m){if(typeof u!=="string")return null;return m=m||n.EXPECTED_SCHEME,u.split(",").reduce((p,_)=>{let k=_.split("=");if(k[0]==="t")p.timestamp=parseInt(k[1],10);if(k[0]===m)p.signatures.push(k[1]);return p},{timestamp:-1,signatures:[]})}let a=null;function c(){if(!a)a=e.createDefaultCryptoProvider();return a}function l(u){if(!u)throw new j({message:"Options are required"});let m=u.timestamp&&Math.floor(u.timestamp)||Math.floor(Date.now()/1000),p=u.scheme||n.EXPECTED_SCHEME,_=u.cryptoProvider||c(),k=`${m}.${u.payload}`;return{...u,timestamp:m,scheme:p,cryptoProvider:_,payloadString:k,generateHeaderString:(y)=>`t=${m},${p}=${y}`}}return t.signature=n,t}var El=f(()=>{xi();yi()});var qr="2026-06-24.dahlia";function Yd(e,t){for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let i=n[0].toLowerCase()+n.substring(1),r=new t[n](e);this[i]=r}}function S(e,t){return function(n){return new Yd(n,t)}}var Ce;var Or=f(()=>{b();Ce=class Ce extends d{create(e,t){return this._makeRequest("POST","/v2/core/account_links",e,t)}}});var je;var Ar=f(()=>{b();je=class je extends d{create(e,t){return this._makeRequest("POST","/v2/core/account_tokens",e,t,{requestSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v2/core/account_tokens/${encodeURIComponent(e)}`,t,n)}}});var Pe;var Ir=f(()=>{b();Pe=class Pe extends d{list(e,t){return this._makeRequest("GET","/v1/financial_connections/accounts",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/financial_connections/accounts/${encodeURIComponent(e)}`,t,n)}disconnect(e,t,n){return this._makeRequest("POST",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/disconnect`,t,n)}refresh(e,t,n){return this._makeRequest("POST",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/refresh`,t,n)}subscribe(e,t,n){return this._makeRequest("POST",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/subscribe`,t,n)}unsubscribe(e,t,n){return this._makeRequest("POST",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/unsubscribe`,t,n)}listOwners(e,t,n){return this._makeRequest("GET",`/v1/financial_connections/accounts/${encodeURIComponent(e)}/owners`,t,n,{methodType:"list"})}}});var $r;var ql=f(()=>{b();$r=class $r extends d{list(e,t,n){return this._makeRequest("GET",`/v2/core/accounts/${encodeURIComponent(e)}/persons`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}})}create(e,t,n){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}/persons`,t,n,{requestSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}})}del(e,t,n,i){return this._makeRequest("DELETE",`/v2/core/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i)}retrieve(e,t,n,i){return this._makeRequest("GET",`/v2/core/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i,{responseSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}})}update(e,t,n,i){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i,{requestSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}})}}});var Ur;var Ol=f(()=>{b();Ur=class Ur extends d{create(e,t,n){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}/person_tokens`,t,n,{requestSchema:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}})}retrieve(e,t,n,i){return this._makeRequest("GET",`/v2/core/accounts/${encodeURIComponent(e)}/person_tokens/${encodeURIComponent(t)}`,n,i)}}});var Ee;var Mr=f(()=>{b();ql();Ol();Ee=class Ee extends d{constructor(e){super(e);this.stripe=e,this.persons=new $r(e),this.personTokens=new Ur(e)}list(e,t){return this._makeRequest("GET","/v2/core/accounts",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v2/core/accounts",e,t,{requestSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}},responseSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v2/core/accounts/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}},responseSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}close(e,t,n){return this._makeRequest("POST",`/v2/core/accounts/${encodeURIComponent(e)}/close`,t,n,{responseSchema:{kind:"object",fields:{identity:{kind:"object",fields:{individual:{kind:"object",fields:{relationship:{kind:"object",fields:{percent_ownership:{kind:"decimal_string"}}}}}}}}}})}}});var qe;var Dr=f(()=>{b();qe=class qe extends d{list(e,t){return this._makeRequest("GET","/v1/entitlements/active_entitlements",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/entitlements/active_entitlements/${encodeURIComponent(e)}`,t,n)}}});var Oe;var Fr=f(()=>{b();Oe=class Oe extends d{list(e,t){return this._makeRequest("GET","/v1/billing/alerts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/billing/alerts",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing/alerts/${encodeURIComponent(e)}`,t,n)}activate(e,t,n){return this._makeRequest("POST",`/v1/billing/alerts/${encodeURIComponent(e)}/activate`,t,n)}archive(e,t,n){return this._makeRequest("POST",`/v1/billing/alerts/${encodeURIComponent(e)}/archive`,t,n)}deactivate(e,t,n){return this._makeRequest("POST",`/v1/billing/alerts/${encodeURIComponent(e)}/deactivate`,t,n)}}});var Ae;var Nr=f(()=>{b();Ae=class Ae extends d{find(e,t){return this._makeRequest("GET","/v1/tax/associations/find",e,t)}}});var Ie;var Gr=f(()=>{b();Ie=class Ie extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/authorizations",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/authorizations/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/authorizations/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}approve(e,t,n){return this._makeRequest("POST",`/v1/issuing/authorizations/${encodeURIComponent(e)}/approve`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}decline(e,t,n){return this._makeRequest("POST",`/v1/issuing/authorizations/${encodeURIComponent(e)}/decline`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}}});var $e;var Br=f(()=>{b();$e=class $e extends d{create(e,t){return this._makeRequest("POST","/v1/test_helpers/issuing/authorizations",e,t,{requestSchema:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}capture(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/capture`,t,n,{requestSchema:{kind:"object",fields:{purchase_details:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}},receipt:{kind:"array",element:{kind:"object",fields:{quantity:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}expire(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/expire`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}finalizeAmount(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/finalize_amount`,t,n,{requestSchema:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}respond(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/fraud_challenges/respond`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}increment(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/increment`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}reverse(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/authorizations/${encodeURIComponent(e)}/reverse`,t,n,{responseSchema:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}}});var Ue;var Lr=f(()=>{b();Ue=class Ue extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax/calculations/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/tax/calculations",e,t)}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/tax/calculations/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list"})}}});var Me;var Kr=f(()=>{b();Me=class Me extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/cardholders",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/issuing/cardholders",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/cardholders/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/cardholders/${encodeURIComponent(e)}`,t,n)}}});var De;var Hr=f(()=>{b();De=class De extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/cards",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/issuing/cards",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/cards/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/cards/${encodeURIComponent(e)}`,t,n)}}});var Fe;var Vr=f(()=>{b();Fe=class Fe extends d{deliverCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/deliver`,t,n)}failCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/fail`,t,n)}returnCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/return`,t,n)}shipCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/ship`,t,n)}submitCard(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/cards/${encodeURIComponent(e)}/shipping/submit`,t,n)}}});var Ne;var zr=f(()=>{b();Ne=class Ne extends d{list(e,t){return this._makeRequest("GET","/v1/billing_portal/configurations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/billing_portal/configurations",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing_portal/configurations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/billing_portal/configurations/${encodeURIComponent(e)}`,t,n)}}});var Ge;var Wr=f(()=>{b();Ge=class Ge extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/terminal/configurations/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/terminal/configurations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/terminal/configurations/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/terminal/configurations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/terminal/configurations",e,t)}}});var Be;var Qr=f(()=>{b();Be=class Be extends d{create(e,t){return this._makeRequest("POST","/v1/test_helpers/confirmation_tokens",e,t)}}});var Le;var Jr=f(()=>{b();Le=class Le extends d{create(e,t){return this._makeRequest("POST","/v1/terminal/connection_tokens",e,t)}}});var Ke;var Xr=f(()=>{b();Ke=class Ke extends d{retrieve(e,t){return this._makeRequest("GET","/v1/billing/credit_balance_summary",e,t)}}});var He;var Yr=f(()=>{b();He=class He extends d{list(e,t){return this._makeRequest("GET","/v1/billing/credit_balance_transactions",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing/credit_balance_transactions/${encodeURIComponent(e)}`,t,n)}}});var Ve;var Zr=f(()=>{b();Ve=class Ve extends d{list(e,t){return this._makeRequest("GET","/v1/billing/credit_grants",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/billing/credit_grants",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing/credit_grants/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/billing/credit_grants/${encodeURIComponent(e)}`,t,n)}expire(e,t,n){return this._makeRequest("POST",`/v1/billing/credit_grants/${encodeURIComponent(e)}/expire`,t,n)}voidGrant(e,t,n){return this._makeRequest("POST",`/v1/billing/credit_grants/${encodeURIComponent(e)}/void`,t,n)}}});var ze;var eo=f(()=>{b();ze=class ze extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/credit_reversals",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/credit_reversals",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/credit_reversals/${encodeURIComponent(e)}`,t,n)}}});var We;var to=f(()=>{b();We=class We extends d{fundCashBalance(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/customers/${encodeURIComponent(e)}/fund_cash_balance`,t,n)}}});var Qe;var no=f(()=>{b();Qe=class Qe extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/debit_reversals",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/debit_reversals",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/debit_reversals/${encodeURIComponent(e)}`,t,n)}}});var Je;var io=f(()=>{b();Je=class Je extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/disputes",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/issuing/disputes",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/disputes/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/disputes/${encodeURIComponent(e)}`,t,n)}submit(e,t,n){return this._makeRequest("POST",`/v1/issuing/disputes/${encodeURIComponent(e)}/submit`,t,n)}}});var Xe;var ro=f(()=>{b();Xe=class Xe extends d{list(e,t){return this._makeRequest("GET","/v1/radar/early_fraud_warnings",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/radar/early_fraud_warnings/${encodeURIComponent(e)}`,t,n)}}});var Ye;var oo=f(()=>{b();Ye=class Ye extends d{list(e,t){return this._makeRequest("GET","/v2/core/event_destinations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v2/core/event_destinations",e,t)}del(e,t,n){return this._makeRequest("DELETE",`/v2/core/event_destinations/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v2/core/event_destinations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v2/core/event_destinations/${encodeURIComponent(e)}`,t,n)}disable(e,t,n){return this._makeRequest("POST",`/v2/core/event_destinations/${encodeURIComponent(e)}/disable`,t,n)}enable(e,t,n){return this._makeRequest("POST",`/v2/core/event_destinations/${encodeURIComponent(e)}/enable`,t,n)}ping(e,t,n){return this._makeRequest("POST",`/v2/core/event_destinations/${encodeURIComponent(e)}/ping`,t,n)}}});var Ze;var so=f(()=>{b();Ze=class Ze extends d{list(e,t){let n=(i)=>({...i,data:i.data.map(this.addFetchRelatedObjectIfNeeded.bind(this))});return this._makeRequest("GET","/v2/core/events",e,t,{methodType:"list",transformResponseData:n})}retrieve(e,t,n){let i=(r)=>this.addFetchRelatedObjectIfNeeded(r);return this._makeRequest("GET",`/v2/core/events/${encodeURIComponent(e)}`,t,n,{transformResponseData:i})}addFetchRelatedObjectIfNeeded(e){if(!e.related_object||!e.related_object.url)return e;return{...e,fetchRelatedObject:()=>this._makeRequest("GET",e.related_object.url,void 0,{stripeContext:e.context,headers:{"Stripe-Request-Trigger":`event=${e.id}`}})}}}});var et;var ao=f(()=>{b();et=class et extends d{list(e,t){return this._makeRequest("GET","/v1/entitlements/features",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/entitlements/features",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/entitlements/features/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/entitlements/features/${encodeURIComponent(e)}`,t,n)}}});var tt;var lo=f(()=>{b();tt=class tt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/financial_accounts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/financial_accounts",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}`,t,n)}close(e,t,n){return this._makeRequest("POST",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}/close`,t,n)}updateFeatures(e,t,n){return this._makeRequest("POST",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}/features`,t,n)}retrieveFeatures(e,t,n){return this._makeRequest("GET",`/v1/treasury/financial_accounts/${encodeURIComponent(e)}/features`,t,n)}}});var nt;var co=f(()=>{b();nt=class nt extends d{list(e,t){return this._makeRequest("GET","/v2/commerce/product_catalog/imports",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{status_details:{kind:"object",fields:{processing:{kind:"object",fields:{error_count:{kind:"int64_string"},success_count:{kind:"int64_string"}}},succeeded:{kind:"object",fields:{success_count:{kind:"int64_string"}}},succeeded_with_errors:{kind:"object",fields:{error_count:{kind:"int64_string"},error_file:{kind:"object",fields:{size:{kind:"int64_string"}}},samples:{kind:"array",element:{kind:"object",fields:{row:{kind:"int64_string"}}}},success_count:{kind:"int64_string"}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v2/commerce/product_catalog/imports",e,t,{responseSchema:{kind:"object",fields:{status_details:{kind:"object",fields:{processing:{kind:"object",fields:{error_count:{kind:"int64_string"},success_count:{kind:"int64_string"}}},succeeded:{kind:"object",fields:{success_count:{kind:"int64_string"}}},succeeded_with_errors:{kind:"object",fields:{error_count:{kind:"int64_string"},error_file:{kind:"object",fields:{size:{kind:"int64_string"}}},samples:{kind:"array",element:{kind:"object",fields:{row:{kind:"int64_string"}}}},success_count:{kind:"int64_string"}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v2/commerce/product_catalog/imports/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{status_details:{kind:"object",fields:{processing:{kind:"object",fields:{error_count:{kind:"int64_string"},success_count:{kind:"int64_string"}}},succeeded:{kind:"object",fields:{success_count:{kind:"int64_string"}}},succeeded_with_errors:{kind:"object",fields:{error_count:{kind:"int64_string"},error_file:{kind:"object",fields:{size:{kind:"int64_string"}}},samples:{kind:"array",element:{kind:"object",fields:{row:{kind:"int64_string"}}}},success_count:{kind:"int64_string"}}}}}}}})}}});var it;var uo=f(()=>{b();it=class it extends d{fail(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/inbound_transfers/${encodeURIComponent(e)}/fail`,t,n)}returnInboundTransfer(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/inbound_transfers/${encodeURIComponent(e)}/return`,t,n)}succeed(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/inbound_transfers/${encodeURIComponent(e)}/succeed`,t,n)}}});var rt;var mo=f(()=>{b();rt=class rt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/inbound_transfers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/inbound_transfers",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/inbound_transfers/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/treasury/inbound_transfers/${encodeURIComponent(e)}/cancel`,t,n)}}});var ot;var po=f(()=>{b();ot=class ot extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/terminal/locations/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/terminal/locations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/terminal/locations/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/terminal/locations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/terminal/locations",e,t)}}});var st;var fo=f(()=>{b();st=class st extends d{create(e,t){return this._makeRequest("POST","/v1/billing/meter_event_adjustments",e,t)}}});var at;var _o=f(()=>{b();at=class at extends d{create(e,t){return this._makeRequest("POST","/v2/billing/meter_event_adjustments",e,t)}}});var lt;var ko=f(()=>{b();lt=class lt extends d{create(e,t){return this._makeRequest("POST","/v2/billing/meter_event_session",e,t)}}});var ct;var bo=f(()=>{b();ct=class ct extends d{create(e,t){return this._makeRequest("POST","/v2/billing/meter_event_stream",e,t,{apiBase:"meter_events"})}}});var dt;var go=f(()=>{b();dt=class dt extends d{create(e,t){return this._makeRequest("POST","/v1/billing/meter_events",e,t)}}});var ut;var ho=f(()=>{b();ut=class ut extends d{create(e,t){return this._makeRequest("POST","/v2/billing/meter_events",e,t)}}});var mt;var yo=f(()=>{b();mt=class mt extends d{list(e,t){return this._makeRequest("GET","/v1/billing/meters",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/billing/meters",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/billing/meters/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/billing/meters/${encodeURIComponent(e)}`,t,n)}deactivate(e,t,n){return this._makeRequest("POST",`/v1/billing/meters/${encodeURIComponent(e)}/deactivate`,t,n)}reactivate(e,t,n){return this._makeRequest("POST",`/v1/billing/meters/${encodeURIComponent(e)}/reactivate`,t,n)}listEventSummaries(e,t,n){return this._makeRequest("GET",`/v1/billing/meters/${encodeURIComponent(e)}/event_summaries`,t,n,{methodType:"list"})}}});var pt;var Ro=f(()=>{b();pt=class pt extends d{create(e,t){return this._makeRequest("POST","/v1/terminal/onboarding_links",e,t)}}});var ft;var To=f(()=>{b();ft=class ft extends d{list(e,t){return this._makeRequest("GET","/v1/climate/orders",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/climate/orders",e,t,{requestSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/climate/orders/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/climate/orders/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}})}cancel(e,t,n){return this._makeRequest("POST",`/v1/climate/orders/${encodeURIComponent(e)}/cancel`,t,n,{responseSchema:{kind:"object",fields:{metric_tons:{kind:"decimal_string"}}}})}}});var _t;var wo=f(()=>{b();_t=class _t extends d{update(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_payments/${encodeURIComponent(e)}`,t,n)}fail(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_payments/${encodeURIComponent(e)}/fail`,t,n)}post(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_payments/${encodeURIComponent(e)}/post`,t,n)}returnOutboundPayment(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_payments/${encodeURIComponent(e)}/return`,t,n)}}});var kt;var vo=f(()=>{b();kt=class kt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/outbound_payments",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/outbound_payments",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/outbound_payments/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/treasury/outbound_payments/${encodeURIComponent(e)}/cancel`,t,n)}}});var bt;var So=f(()=>{b();bt=class bt extends d{update(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_transfers/${encodeURIComponent(e)}`,t,n)}fail(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_transfers/${encodeURIComponent(e)}/fail`,t,n)}post(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_transfers/${encodeURIComponent(e)}/post`,t,n)}returnOutboundTransfer(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/treasury/outbound_transfers/${encodeURIComponent(e)}/return`,t,n)}}});var gt;var xo=f(()=>{b();gt=class gt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/outbound_transfers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/treasury/outbound_transfers",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/outbound_transfers/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/treasury/outbound_transfers/${encodeURIComponent(e)}/cancel`,t,n)}}});var ht;var Co=f(()=>{b();ht=class ht extends d{create(e,t){return this._makeRequest("POST","/v1/radar/payment_evaluations",e,t)}}});var yt;var jo=f(()=>{b();yt=class yt extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/personalization_designs",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/issuing/personalization_designs",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/personalization_designs/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/personalization_designs/${encodeURIComponent(e)}`,t,n)}}});var Rt;var Po=f(()=>{b();Rt=class Rt extends d{activate(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/personalization_designs/${encodeURIComponent(e)}/activate`,t,n)}deactivate(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/personalization_designs/${encodeURIComponent(e)}/deactivate`,t,n)}reject(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/personalization_designs/${encodeURIComponent(e)}/reject`,t,n)}}});var Tt;var Eo=f(()=>{b();Tt=class Tt extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/physical_bundles",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/physical_bundles/${encodeURIComponent(e)}`,t,n)}}});var wt;var qo=f(()=>{b();wt=class wt extends d{list(e,t){return this._makeRequest("GET","/v1/climate/products",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{metric_tons_available:{kind:"decimal_string"}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/climate/products/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{metric_tons_available:{kind:"decimal_string"}}}})}}});var vt;var Oo=f(()=>{b();vt=class vt extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/terminal/readers/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/terminal/readers/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/terminal/readers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/terminal/readers",e,t)}cancelAction(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/cancel_action`,t,n)}collectInputs(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/collect_inputs`,t,n)}collectPaymentMethod(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/collect_payment_method`,t,n)}confirmPaymentIntent(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/confirm_payment_intent`,t,n)}processPaymentIntent(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/process_payment_intent`,t,n)}processSetupIntent(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/process_setup_intent`,t,n)}refundPayment(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/refund_payment`,t,n)}setReaderDisplay(e,t,n){return this._makeRequest("POST",`/v1/terminal/readers/${encodeURIComponent(e)}/set_reader_display`,t,n)}}});var St;var Ao=f(()=>{b();St=class St extends d{presentPaymentMethod(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/terminal/readers/${encodeURIComponent(e)}/present_payment_method`,t,n)}succeedInputCollection(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/terminal/readers/${encodeURIComponent(e)}/succeed_input_collection`,t,n)}timeoutInputCollection(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/terminal/readers/${encodeURIComponent(e)}/timeout_input_collection`,t,n)}}});var xt;var Io=f(()=>{b();xt=class xt extends d{create(e,t){return this._makeRequest("POST","/v1/test_helpers/treasury/received_credits",e,t)}}});var Ct;var $o=f(()=>{b();Ct=class Ct extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/received_credits",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/received_credits/${encodeURIComponent(e)}`,t,n)}}});var jt;var Uo=f(()=>{b();jt=class jt extends d{create(e,t){return this._makeRequest("POST","/v1/test_helpers/treasury/received_debits",e,t)}}});var Pt;var Mo=f(()=>{b();Pt=class Pt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/received_debits",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/received_debits/${encodeURIComponent(e)}`,t,n)}}});var Et;var Do=f(()=>{b();Et=class Et extends d{expire(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/refunds/${encodeURIComponent(e)}/expire`,t,n)}}});var qt;var Fo=f(()=>{b();qt=class qt extends d{list(e,t){return this._makeRequest("GET","/v1/tax/registrations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/tax/registrations",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax/registrations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/tax/registrations/${encodeURIComponent(e)}`,t,n)}}});var Ot;var No=f(()=>{b();Ot=class Ot extends d{list(e,t){return this._makeRequest("GET","/v1/reporting/report_runs",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/reporting/report_runs",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/reporting/report_runs/${encodeURIComponent(e)}`,t,n)}}});var At;var Go=f(()=>{b();At=class At extends d{list(e,t){return this._makeRequest("GET","/v1/reporting/report_types",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/reporting/report_types/${encodeURIComponent(e)}`,t,n)}}});var It;var Bo=f(()=>{b();It=class It extends d{list(e,t){return this._makeRequest("GET","/v1/forwarding/requests",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/forwarding/requests",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/forwarding/requests/${encodeURIComponent(e)}`,t,n)}}});var $t;var Lo=f(()=>{b();$t=class $t extends d{list(e,t){return this._makeRequest("GET","/v1/sigma/scheduled_query_runs",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/sigma/scheduled_query_runs/${encodeURIComponent(e)}`,t,n)}}});var Ut;var Ko=f(()=>{b();Ut=class Ut extends d{list(e,t){return this._makeRequest("GET","/v1/apps/secrets",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/apps/secrets",e,t)}find(e,t){return this._makeRequest("GET","/v1/apps/secrets/find",e,t)}deleteWhere(e,t){return this._makeRequest("POST","/v1/apps/secrets/delete",e,t)}}});var Mt;var Ho=f(()=>{b();Mt=class Mt extends d{create(e,t){return this._makeRequest("POST","/v1/billing_portal/sessions",e,t)}}});var Dt;var Vo=f(()=>{b();Dt=class Dt extends d{list(e,t){return this._makeRequest("GET","/v1/checkout/sessions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/checkout/sessions",e,t,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/checkout/sessions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/checkout/sessions/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}expire(e,t,n){return this._makeRequest("POST",`/v1/checkout/sessions/${encodeURIComponent(e)}/expire`,t,n,{responseSchema:{kind:"object",fields:{currency_conversion:{kind:"nullable",inner:{kind:"object",fields:{fx_rate:{kind:"decimal_string"}}}},line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/checkout/sessions/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}}});var Ft;var zo=f(()=>{b();Ft=class Ft extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/financial_connections/sessions/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/financial_connections/sessions",e,t)}}});var Nt;var Wo=f(()=>{b();Nt=class Nt extends d{retrieve(e,t){return this._makeRequest("GET","/v1/tax/settings",e,t)}update(e,t){return this._makeRequest("POST","/v1/tax/settings",e,t)}}});var Gt;var Qo=f(()=>{b();Gt=class Gt extends d{list(e,t){return this._makeRequest("GET","/v1/climate/suppliers",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/climate/suppliers/${encodeURIComponent(e)}`,t,n)}}});var Bt;var Jo=f(()=>{b();Bt=class Bt extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/test_helpers/test_clocks/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/test_helpers/test_clocks/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/test_helpers/test_clocks",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/test_helpers/test_clocks",e,t)}advance(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/test_clocks/${encodeURIComponent(e)}/advance`,t,n)}}});var Lt;var Xo=f(()=>{b();Lt=class Lt extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/tokens",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/tokens/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/tokens/${encodeURIComponent(e)}`,t,n)}}});var Kt;var Yo=f(()=>{b();Kt=class Kt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/transaction_entries",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{flow_details:{kind:"nullable",inner:{kind:"object",fields:{issuing_authorization:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/transaction_entries/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{flow_details:{kind:"nullable",inner:{kind:"object",fields:{issuing_authorization:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}}}})}}});var Ht;var Zo=f(()=>{b();Ht=class Ht extends d{list(e,t){return this._makeRequest("GET","/v1/financial_connections/transactions",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/financial_connections/transactions/${encodeURIComponent(e)}`,t,n)}}});var Vt;var es=f(()=>{b();Vt=class Vt extends d{list(e,t){return this._makeRequest("GET","/v1/issuing/transactions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/issuing/transactions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/issuing/transactions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}}});var zt;var ts=f(()=>{b();zt=class zt extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax/transactions/${encodeURIComponent(e)}`,t,n)}createFromCalculation(e,t){return this._makeRequest("POST","/v1/tax/transactions/create_from_calculation",e,t)}createReversal(e,t){return this._makeRequest("POST","/v1/tax/transactions/create_reversal",e,t)}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/tax/transactions/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list"})}}});var Wt;var ns=f(()=>{b();Wt=class Wt extends d{refund(e,t,n){return this._makeRequest("POST",`/v1/test_helpers/issuing/transactions/${encodeURIComponent(e)}/refund`,t,n,{responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}createForceCapture(e,t){return this._makeRequest("POST","/v1/test_helpers/issuing/transactions/create_force_capture",e,t,{requestSchema:{kind:"object",fields:{purchase_details:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}},receipt:{kind:"array",element:{kind:"object",fields:{quantity:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}createUnlinkedRefund(e,t){return this._makeRequest("POST","/v1/test_helpers/issuing/transactions/create_unlinked_refund",e,t,{requestSchema:{kind:"object",fields:{purchase_details:{kind:"object",fields:{fleet:{kind:"object",fields:{reported_breakdown:{kind:"object",fields:{fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},non_fuel:{kind:"object",fields:{gross_amount_decimal:{kind:"decimal_string"}}},tax:{kind:"object",fields:{local_amount_decimal:{kind:"decimal_string"},national_amount_decimal:{kind:"decimal_string"}}}}}}},fuel:{kind:"object",fields:{quantity_decimal:{kind:"decimal_string"},unit_cost_decimal:{kind:"decimal_string"}}},receipt:{kind:"array",element:{kind:"object",fields:{quantity:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}})}}});var Qt;var is=f(()=>{b();Qt=class Qt extends d{list(e,t){return this._makeRequest("GET","/v1/treasury/transactions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{entries:{kind:"nullable",inner:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{flow_details:{kind:"nullable",inner:{kind:"object",fields:{issuing_authorization:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/treasury/transactions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{entries:{kind:"nullable",inner:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{flow_details:{kind:"nullable",inner:{kind:"object",fields:{issuing_authorization:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},transactions:{kind:"array",element:{kind:"object",fields:{purchase_details:{kind:"nullable",inner:{kind:"object",fields:{fleet:{kind:"nullable",inner:{kind:"object",fields:{reported_breakdown:{kind:"nullable",inner:{kind:"object",fields:{fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},non_fuel:{kind:"nullable",inner:{kind:"object",fields:{gross_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tax:{kind:"nullable",inner:{kind:"object",fields:{local_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},national_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}},fuel:{kind:"nullable",inner:{kind:"object",fields:{quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_cost_decimal:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}}}}}})}}});var Jt;var rs=f(()=>{b();Jt=class Jt extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/radar/value_list_items/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/radar/value_list_items/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/radar/value_list_items",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/radar/value_list_items",e,t)}}});var Xt;var os=f(()=>{b();Xt=class Xt extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/radar/value_lists/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/radar/value_lists/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/radar/value_lists/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/radar/value_lists",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/radar/value_lists",e,t)}}});var Yt;var ss=f(()=>{b();Yt=class Yt extends d{list(e,t){return this._makeRequest("GET","/v1/identity/verification_reports",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/identity/verification_reports/${encodeURIComponent(e)}`,t,n)}}});var Zt;var as=f(()=>{b();Zt=class Zt extends d{list(e,t){return this._makeRequest("GET","/v1/identity/verification_sessions",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/identity/verification_sessions",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/identity/verification_sessions/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/identity/verification_sessions/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/identity/verification_sessions/${encodeURIComponent(e)}/cancel`,t,n)}redact(e,t,n){return this._makeRequest("POST",`/v1/identity/verification_sessions/${encodeURIComponent(e)}/redact`,t,n)}}});var oe;var Ci=f(()=>{b();oe=class oe extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/accounts/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){if(typeof e==="string")return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}`,t,n);else return this._makeRequest("GET","/v1/account",t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}`,t,n)}retrieveCurrent(e,t){return this._makeRequest("GET","/v1/account",e,t)}list(e,t){return this._makeRequest("GET","/v1/accounts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/accounts",e,t)}reject(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/reject`,t,n)}listCapabilities(e,t,n){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/capabilities`,t,n,{methodType:"list"})}retrieveCapability(e,t,n,i){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/capabilities/${encodeURIComponent(t)}`,n,i)}updateCapability(e,t,n,i){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/capabilities/${encodeURIComponent(t)}`,n,i)}deleteExternalAccount(e,t,n,i){return this._makeRequest("DELETE",`/v1/accounts/${encodeURIComponent(e)}/external_accounts/${encodeURIComponent(t)}`,n,i)}retrieveExternalAccount(e,t,n,i){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/external_accounts/${encodeURIComponent(t)}`,n,i)}updateExternalAccount(e,t,n,i){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/external_accounts/${encodeURIComponent(t)}`,n,i)}listExternalAccounts(e,t,n){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/external_accounts`,t,n,{methodType:"list"})}createExternalAccount(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/external_accounts`,t,n)}createLoginLink(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/login_links`,t,n)}deletePerson(e,t,n,i){return this._makeRequest("DELETE",`/v1/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i)}retrievePerson(e,t,n,i){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i)}updatePerson(e,t,n,i){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/persons/${encodeURIComponent(t)}`,n,i)}listPersons(e,t,n){return this._makeRequest("GET",`/v1/accounts/${encodeURIComponent(e)}/persons`,t,n,{methodType:"list"})}createPerson(e,t,n){return this._makeRequest("POST",`/v1/accounts/${encodeURIComponent(e)}/persons`,t,n)}}});var en;var ls=f(()=>{b();en=class en extends d{create(e,t){return this._makeRequest("POST","/v1/account_links",e,t)}}});var tn;var cs=f(()=>{b();tn=class tn extends d{create(e,t){return this._makeRequest("POST","/v1/account_sessions",e,t)}}});var nn;var ds=f(()=>{b();nn=class nn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/apple_pay/domains/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/apple_pay/domains/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/apple_pay/domains",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/apple_pay/domains",e,t)}}});var rn;var us=f(()=>{b();rn=class rn extends d{list(e,t){return this._makeRequest("GET","/v1/application_fees",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/application_fees/${encodeURIComponent(e)}`,t,n)}retrieveRefund(e,t,n,i){return this._makeRequest("GET",`/v1/application_fees/${encodeURIComponent(e)}/refunds/${encodeURIComponent(t)}`,n,i)}updateRefund(e,t,n,i){return this._makeRequest("POST",`/v1/application_fees/${encodeURIComponent(e)}/refunds/${encodeURIComponent(t)}`,n,i)}listRefunds(e,t,n){return this._makeRequest("GET",`/v1/application_fees/${encodeURIComponent(e)}/refunds`,t,n,{methodType:"list"})}createRefund(e,t,n){return this._makeRequest("POST",`/v1/application_fees/${encodeURIComponent(e)}/refunds`,t,n)}}});var se;var ji=f(()=>{b();se=class se extends d{retrieve(e,t){return this._makeRequest("GET","/v1/balance",e,t)}}});var on;var ms=f(()=>{b();on=class on extends d{retrieve(e,t){return this._makeRequest("GET","/v1/balance_settings",e,t)}update(e,t){return this._makeRequest("POST","/v1/balance_settings",e,t)}}});var sn;var ps=f(()=>{b();sn=class sn extends d{list(e,t){return this._makeRequest("GET","/v1/balance_transactions",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/balance_transactions/${encodeURIComponent(e)}`,t,n)}}});var an;var fs=f(()=>{b();an=class an extends d{list(e,t){return this._makeRequest("GET","/v1/charges",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/charges",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/charges/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/charges/${encodeURIComponent(e)}`,t,n)}search(e,t){return this._makeRequest("GET","/v1/charges/search",e,t,{methodType:"search"})}capture(e,t,n){return this._makeRequest("POST",`/v1/charges/${encodeURIComponent(e)}/capture`,t,n)}}});var ln;var _s=f(()=>{b();ln=class ln extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/confirmation_tokens/${encodeURIComponent(e)}`,t,n)}}});var cn;var ks=f(()=>{b();cn=class cn extends d{list(e,t){return this._makeRequest("GET","/v1/country_specs",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/country_specs/${encodeURIComponent(e)}`,t,n)}}});var dn;var bs=f(()=>{b();dn=class dn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/coupons/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/coupons/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/coupons/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/coupons",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/coupons",e,t)}}});var un;var gs=f(()=>{b();un=class un extends d{list(e,t){return this._makeRequest("GET","/v1/credit_notes",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/credit_notes",e,t,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/credit_notes/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/credit_notes/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}preview(e,t){return this._makeRequest("GET","/v1/credit_notes/preview",e,t,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}voidCreditNote(e,t,n){return this._makeRequest("POST",`/v1/credit_notes/${encodeURIComponent(e)}/void`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}listPreviewLineItems(e,t){return this._makeRequest("GET","/v1/credit_notes/preview/lines",e,t,{methodType:"list",requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/credit_notes/${encodeURIComponent(e)}/lines`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}}});var mn;var hs=f(()=>{b();mn=class mn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/customers/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{subscriptions:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}deleteDiscount(e,t,n){return this._makeRequest("DELETE",`/v1/customers/${encodeURIComponent(e)}/discount`,t,n)}list(e,t){return this._makeRequest("GET","/v1/customers",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{subscriptions:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/customers",e,t,{responseSchema:{kind:"object",fields:{subscriptions:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}search(e,t){return this._makeRequest("GET","/v1/customers/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{subscriptions:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}})}listBalanceTransactions(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/balance_transactions`,t,n,{methodType:"list"})}createBalanceTransaction(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/balance_transactions`,t,n)}retrieveBalanceTransaction(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/balance_transactions/${encodeURIComponent(t)}`,n,i)}updateBalanceTransaction(e,t,n,i){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/balance_transactions/${encodeURIComponent(t)}`,n,i)}retrieveCashBalance(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/cash_balance`,t,n)}updateCashBalance(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/cash_balance`,t,n)}listCashBalanceTransactions(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/cash_balance_transactions`,t,n,{methodType:"list"})}retrieveCashBalanceTransaction(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/cash_balance_transactions/${encodeURIComponent(t)}`,n,i)}createFundingInstructions(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/funding_instructions`,t,n)}listPaymentMethods(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/payment_methods`,t,n,{methodType:"list"})}retrievePaymentMethod(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/payment_methods/${encodeURIComponent(t)}`,n,i)}listSources(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/sources`,t,n,{methodType:"list"})}createSource(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/sources`,t,n)}retrieveSource(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/sources/${encodeURIComponent(t)}`,n,i)}updateSource(e,t,n,i){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/sources/${encodeURIComponent(t)}`,n,i)}deleteSource(e,t,n,i){return this._makeRequest("DELETE",`/v1/customers/${encodeURIComponent(e)}/sources/${encodeURIComponent(t)}`,n,i)}verifySource(e,t,n,i){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/sources/${encodeURIComponent(t)}/verify`,n,i)}deleteTaxId(e,t,n,i){return this._makeRequest("DELETE",`/v1/customers/${encodeURIComponent(e)}/tax_ids/${encodeURIComponent(t)}`,n,i)}retrieveTaxId(e,t,n,i){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/tax_ids/${encodeURIComponent(t)}`,n,i)}listTaxIds(e,t,n){return this._makeRequest("GET",`/v1/customers/${encodeURIComponent(e)}/tax_ids`,t,n,{methodType:"list"})}createTaxId(e,t,n){return this._makeRequest("POST",`/v1/customers/${encodeURIComponent(e)}/tax_ids`,t,n)}}});var pn;var ys=f(()=>{b();pn=class pn extends d{create(e,t){return this._makeRequest("POST","/v1/customer_sessions",e,t)}}});var fn;var Rs=f(()=>{b();fn=class fn extends d{list(e,t){return this._makeRequest("GET","/v1/disputes",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/disputes/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/disputes/${encodeURIComponent(e)}`,t,n)}close(e,t,n){return this._makeRequest("POST",`/v1/disputes/${encodeURIComponent(e)}/close`,t,n)}}});var _n;var Ts=f(()=>{b();_n=class _n extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/ephemeral_keys/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/ephemeral_keys",e,t,{validator:(n,i)=>{if(!i.headers||!i.headers["Stripe-Version"])throw Error("Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node")}})}}});var kn;var ws=f(()=>{b();kn=class kn extends d{list(e,t){return this._makeRequest("GET","/v1/events",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/events/${encodeURIComponent(e)}`,t,n)}}});var bn;var vs=f(()=>{b();bn=class bn extends d{list(e,t){return this._makeRequest("GET","/v1/exchange_rates",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/exchange_rates/${encodeURIComponent(e)}`,t,n)}}});function Al(e,t,n,i){if(t=t||{},e!=="POST")return i(null,z(t));this._stripe._platformFunctions.tryBufferData(t).then((r)=>{let o=Zd(e,r,n);return i(null,o)}).catch((r)=>i(r,null))}var Zd=(e,t,n)=>{let i=(Math.round(Math.random()*10000000000000000)+Math.round(Math.random()*10000000000000000)).toString();n["Content-Type"]=`multipart/form-data; boundary=${i}`;let r=new TextEncoder,o=new Uint8Array(0),s=r.encode(`\r
|
|
15
|
-
`);function a(u){let m=o,p=u instanceof Uint8Array?u:new Uint8Array(r.encode(u));o=new Uint8Array(m.length+p.length+2),o.set(m),o.set(p,m.length),o.set(s,o.length-2)}function c(u){return`"${u.replace(/"|"/g,"%22").replace(/\r\n|\r|\n/g," ")}"`}let l=ml(t);for(let u in l){if(!Object.prototype.hasOwnProperty.call(l,u))continue;let m=l[u];if(a(`--${i}`),Object.prototype.hasOwnProperty.call(m,"data")){let p=m;a(`Content-Disposition: form-data; name=${c(u)}; filename=${c(p.name||"blob")}`),a(`Content-Type: ${p.type||"application/octet-stream"}`),a(""),a(p.data)}else a(`Content-Disposition: form-data; name=${c(u)}`),a(""),a(m)}return a(`--${i}--`),o};var Il=f(()=>{W()});var gn;var Ss=f(()=>{Il();b();gn=class gn extends d{constructor(){super(...arguments);this.requestDataProcessor=Al}list(e,t){return this._makeRequest("GET","/v1/files",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/files",e,t,{headers:{"Content-Type":"multipart/form-data"},apiBase:"files"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/files/${encodeURIComponent(e)}`,t,n)}}});var hn;var xs=f(()=>{b();hn=class hn extends d{list(e,t){return this._makeRequest("GET","/v1/file_links",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/file_links",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/file_links/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/file_links/${encodeURIComponent(e)}`,t,n)}}});var yn;var Cs=f(()=>{b();yn=class yn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/invoices/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/invoices",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/invoices",e,t,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}search(e,t){return this._makeRequest("GET","/v1/invoices/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}addLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/add_lines`,t,n,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}attachPayment(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/attach_payment`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}finalizeInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/finalize`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}markUncollectible(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/mark_uncollectible`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}pay(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/pay`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}removeLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/remove_lines`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}sendInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/send`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}updateLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/update_lines`,t,n,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}voidInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/void`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}createPreview(e,t){return this._makeRequest("POST","/v1/invoices/create_preview",e,t,{requestSchema:{kind:"object",fields:{invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},schedule_details:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}},subscription_details:{kind:"object",fields:{items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/invoices/${encodeURIComponent(e)}/lines`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}updateLineItem(e,t,n,i){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/lines/${encodeURIComponent(t)}`,n,i,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}}});var Rn;var js=f(()=>{b();Rn=class Rn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}list(e,t){return this._makeRequest("GET","/v1/invoiceitems",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/invoiceitems",e,t,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}}});var Tn;var Ps=f(()=>{b();Tn=class Tn extends d{list(e,t){return this._makeRequest("GET","/v1/invoice_payments",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoice_payments/${encodeURIComponent(e)}`,t,n)}}});var wn;var Es=f(()=>{b();wn=class wn extends d{list(e,t){return this._makeRequest("GET","/v1/invoice_rendering_templates",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}`,t,n)}archive(e,t,n){return this._makeRequest("POST",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}/archive`,t,n)}unarchive(e,t,n){return this._makeRequest("POST",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}/unarchive`,t,n)}}});var vn;var qs=f(()=>{b();vn=class vn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/mandates/${encodeURIComponent(e)}`,t,n)}}});var Sn;var $l=f(()=>{b();W();Sn=class Sn extends d{constructor(){super(...arguments);this.basePath=be("/")}authorizeUrl(e,t){e=e||{},t=t||{};let n="oauth/authorize";if(t.express)n=`express/${n}`;if(!e.response_type)e.response_type="code";if(!e.client_id)e.client_id=this._stripe.getClientId();if(!e.scope)e.scope="read_write";return`https://${this._stripe.resolveBaseAddress("connect")}/${n}?${z(e)}`}token(e,t){return this._makeRequest("POST","/oauth/token",e,t,{apiBase:"connect"})}deauthorize(e,t){if(!e.client_id)e.client_id=this._stripe.getClientId();return this._makeRequest("POST","/oauth/deauthorize",e,t,{apiBase:"connect"})}}});var xn;var Os=f(()=>{b();xn=class xn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_attempt_records",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_attempt_records/${encodeURIComponent(e)}`,t,n)}}});var Cn;var As=f(()=>{b();Cn=class Cn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_intents",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_intents",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_intents/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}`,t,n)}search(e,t){return this._makeRequest("GET","/v1/payment_intents/search",e,t,{methodType:"search"})}applyCustomerBalance(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/apply_customer_balance`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/cancel`,t,n)}capture(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/capture`,t,n)}confirm(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/confirm`,t,n)}incrementAuthorization(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/increment_authorization`,t,n)}verifyMicrodeposits(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/verify_microdeposits`,t,n)}listAmountDetailsLineItems(e,t,n){return this._makeRequest("GET",`/v1/payment_intents/${encodeURIComponent(e)}/amount_details_line_items`,t,n,{methodType:"list"})}}});var jn;var Is=f(()=>{b();jn=class jn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_links",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/payment_links",e,t,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_links/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/payment_links/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/payment_links/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}}});var Pn;var $s=f(()=>{b();Pn=class Pn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_methods",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_methods",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_methods/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}`,t,n)}attach(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}/attach`,t,n)}detach(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}/detach`,t,n)}}});var En;var Us=f(()=>{b();En=class En extends d{list(e,t){return this._makeRequest("GET","/v1/payment_method_configurations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_method_configurations",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_method_configurations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_method_configurations/${encodeURIComponent(e)}`,t,n)}}});var qn;var Ms=f(()=>{b();qn=class qn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_method_domains",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_method_domains",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_method_domains/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_method_domains/${encodeURIComponent(e)}`,t,n)}validate(e,t,n){return this._makeRequest("POST",`/v1/payment_method_domains/${encodeURIComponent(e)}/validate`,t,n)}}});var On;var Ds=f(()=>{b();On=class On extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_records/${encodeURIComponent(e)}`,t,n)}reportPaymentAttempt(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt`,t,n)}reportPaymentAttemptCanceled(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_canceled`,t,n)}reportPaymentAttemptFailed(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_failed`,t,n)}reportPaymentAttemptGuaranteed(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_guaranteed`,t,n)}reportPaymentAttemptInformational(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_informational`,t,n)}reportRefund(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_refund`,t,n)}reportPayment(e,t){return this._makeRequest("POST","/v1/payment_records/report_payment",e,t)}}});var An;var Fs=f(()=>{b();An=class An extends d{list(e,t){return this._makeRequest("GET","/v1/payouts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payouts",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payouts/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}/cancel`,t,n)}reverse(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}/reverse`,t,n)}}});var In;var Ns=f(()=>{b();In=class In extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/plans/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/plans/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/plans/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/plans",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/plans",e,t,{requestSchema:{kind:"object",fields:{amount_decimal:{kind:"decimal_string"},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}}});var $n;var Gs=f(()=>{b();$n=class $n extends d{list(e,t){return this._makeRequest("GET","/v1/prices",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/prices",e,t,{requestSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/prices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/prices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}search(e,t){return this._makeRequest("GET","/v1/prices/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}}});var Un;var Bs=f(()=>{b();Un=class Un extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/products/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/products/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/products",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/products",e,t,{requestSchema:{kind:"object",fields:{default_price_data:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}}}})}search(e,t){return this._makeRequest("GET","/v1/products/search",e,t,{methodType:"search"})}deleteFeature(e,t,n,i){return this._makeRequest("DELETE",`/v1/products/${encodeURIComponent(e)}/features/${encodeURIComponent(t)}`,n,i)}retrieveFeature(e,t,n,i){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}/features/${encodeURIComponent(t)}`,n,i)}listFeatures(e,t,n){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}/features`,t,n,{methodType:"list"})}createFeature(e,t,n){return this._makeRequest("POST",`/v1/products/${encodeURIComponent(e)}/features`,t,n)}}});var Mn;var Ls=f(()=>{b();Mn=class Mn extends d{list(e,t){return this._makeRequest("GET","/v1/promotion_codes",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/promotion_codes",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/promotion_codes/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/promotion_codes/${encodeURIComponent(e)}`,t,n)}}});var Dn;var Ks=f(()=>{b();Dn=class Dn extends d{list(e,t){return this._makeRequest("GET","/v1/quotes",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/quotes",e,t,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}accept(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/accept`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}cancel(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/cancel`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}finalizeQuote(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/finalize`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}pdf(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/pdf`,t,n,{apiBase:"files",streaming:!0})}listComputedUpfrontLineItems(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/computed_upfront_line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}}});var Fn;var Hs=f(()=>{b();Fn=class Fn extends d{list(e,t){return this._makeRequest("GET","/v1/refunds",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/refunds",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/refunds/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/refunds/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/refunds/${encodeURIComponent(e)}/cancel`,t,n)}}});var Nn;var Vs=f(()=>{b();Nn=class Nn extends d{list(e,t){return this._makeRequest("GET","/v1/reviews",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/reviews/${encodeURIComponent(e)}`,t,n)}approve(e,t,n){return this._makeRequest("POST",`/v1/reviews/${encodeURIComponent(e)}/approve`,t,n)}}});var Gn;var zs=f(()=>{b();Gn=class Gn extends d{list(e,t){return this._makeRequest("GET","/v1/setup_attempts",e,t,{methodType:"list"})}}});var Bn;var Ws=f(()=>{b();Bn=class Bn extends d{list(e,t){return this._makeRequest("GET","/v1/setup_intents",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/setup_intents",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/setup_intents/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/cancel`,t,n)}confirm(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/confirm`,t,n)}verifyMicrodeposits(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/verify_microdeposits`,t,n)}}});var Ln;var Qs=f(()=>{b();Ln=class Ln extends d{list(e,t){return this._makeRequest("GET","/v1/shipping_rates",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/shipping_rates",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/shipping_rates/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/shipping_rates/${encodeURIComponent(e)}`,t,n)}}});var Kn;var Js=f(()=>{b();Kn=class Kn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/sources/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/sources/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/sources",e,t)}verify(e,t,n){return this._makeRequest("POST",`/v1/sources/${encodeURIComponent(e)}/verify`,t,n)}listSourceTransactions(e,t,n){return this._makeRequest("GET",`/v1/sources/${encodeURIComponent(e)}/source_transactions`,t,n,{methodType:"list"})}}});var Hn;var Xs=f(()=>{b();Hn=class Hn extends d{cancel(e,t,n){return this._makeRequest("DELETE",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}deleteDiscount(e,t,n){return this._makeRequest("DELETE",`/v1/subscriptions/${encodeURIComponent(e)}/discount`,t,n)}list(e,t){return this._makeRequest("GET","/v1/subscriptions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/subscriptions",e,t,{requestSchema:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}search(e,t){return this._makeRequest("GET","/v1/subscriptions/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}})}migrate(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}/migrate`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}resume(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}/resume`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}}});var Vn;var Ys=f(()=>{b();Vn=class Vn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/subscription_items",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/subscription_items",e,t,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}}});var zn;var Zs=f(()=>{b();zn=class zn extends d{list(e,t){return this._makeRequest("GET","/v1/subscription_schedules",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/subscription_schedules",e,t,{requestSchema:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscription_schedules/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}}})}cancel(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}/cancel`,t,n)}release(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}/release`,t,n)}}});var Wn;var ea=f(()=>{b();Wn=class Wn extends d{list(e,t){return this._makeRequest("GET","/v1/tax_codes",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_codes/${encodeURIComponent(e)}`,t,n)}}});var Qn;var ta=f(()=>{b();Qn=class Qn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/tax_ids/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_ids/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/tax_ids",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/tax_ids",e,t)}}});var Jn;var na=f(()=>{b();Jn=class Jn extends d{list(e,t){return this._makeRequest("GET","/v1/tax_rates",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/tax_rates",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_rates/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/tax_rates/${encodeURIComponent(e)}`,t,n)}}});var Xn;var ia=f(()=>{b();Xn=class Xn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/tokens/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/tokens",e,t)}}});var Yn;var ra=f(()=>{b();Yn=class Yn extends d{list(e,t){return this._makeRequest("GET","/v1/topups",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/topups",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/topups/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/topups/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/topups/${encodeURIComponent(e)}/cancel`,t,n)}}});var Zn;var oa=f(()=>{b();Zn=class Zn extends d{list(e,t){return this._makeRequest("GET","/v1/transfers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/transfers",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}`,t,n)}listReversals(e,t,n){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}/reversals`,t,n,{methodType:"list"})}createReversal(e,t,n){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}/reversals`,t,n)}retrieveReversal(e,t,n,i){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}/reversals/${encodeURIComponent(t)}`,n,i)}updateReversal(e,t,n,i){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}/reversals/${encodeURIComponent(t)}`,n,i)}}});var ei;var sa=f(()=>{b();ei=class ei extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/webhook_endpoints",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/webhook_endpoints",e,t)}}});var ae={};Oi(ae,{Account:()=>oe,AccountLinks:()=>en,AccountSessions:()=>tn,Accounts:()=>oe,ApplePayDomains:()=>nn,ApplicationFees:()=>rn,Apps:()=>eu,Balance:()=>se,BalanceSettings:()=>on,BalanceTransactions:()=>sn,Balances:()=>se,Billing:()=>tu,BillingPortal:()=>nu,Charges:()=>an,Checkout:()=>iu,Climate:()=>ru,ConfirmationTokens:()=>ln,CountrySpecs:()=>cn,Coupons:()=>dn,CreditNotes:()=>un,CustomerSessions:()=>pn,Customers:()=>mn,Disputes:()=>fn,Entitlements:()=>ou,EphemeralKeys:()=>_n,Events:()=>kn,ExchangeRates:()=>bn,FileLinks:()=>hn,Files:()=>gn,FinancialConnections:()=>su,Forwarding:()=>au,Identity:()=>lu,InvoiceItems:()=>Rn,InvoicePayments:()=>Tn,InvoiceRenderingTemplates:()=>wn,Invoices:()=>yn,Issuing:()=>cu,Mandates:()=>vn,OAuthResource:()=>Sn,PaymentAttemptRecords:()=>xn,PaymentIntents:()=>Cn,PaymentLinks:()=>jn,PaymentMethodConfigurations:()=>En,PaymentMethodDomains:()=>qn,PaymentMethods:()=>Pn,PaymentRecords:()=>On,Payouts:()=>An,Plans:()=>In,Prices:()=>$n,Products:()=>Un,PromotionCodes:()=>Mn,Quotes:()=>Dn,Radar:()=>du,Refunds:()=>Fn,Reporting:()=>uu,Reviews:()=>Nn,SetupAttempts:()=>Gn,SetupIntents:()=>Bn,ShippingRates:()=>Ln,Sigma:()=>mu,Sources:()=>Kn,SubscriptionItems:()=>Vn,SubscriptionSchedules:()=>zn,Subscriptions:()=>Hn,Tax:()=>pu,TaxCodes:()=>Wn,TaxIds:()=>Qn,TaxRates:()=>Jn,Terminal:()=>fu,TestHelpers:()=>_u,Tokens:()=>Xn,Topups:()=>Yn,Transfers:()=>Zn,Treasury:()=>ku,V2:()=>bu,WebhookEndpoints:()=>ei});var eu,tu,nu,iu,ru,ou,su,au,lu,cu,du,uu,mu,pu,fu,_u,ku,bu;var aa=f(()=>{Or();Ar();Ir();Mr();Dr();Fr();Nr();Gr();Br();Lr();Kr();Hr();Vr();zr();Wr();Qr();Jr();Xr();Yr();Zr();eo();to();no();io();ro();oo();so();ao();lo();co();uo();mo();po();fo();_o();ko();bo();go();ho();yo();Ro();To();wo();vo();So();xo();Co();jo();Po();Eo();qo();Oo();Ao();Io();$o();Uo();Mo();Do();Fo();No();Go();Bo();Lo();Ko();Ho();Vo();zo();Wo();Qo();Jo();Xo();Yo();Zo();es();ts();ns();is();rs();os();ss();as();Ci();Ci();ls();cs();ds();us();ji();ji();ms();ps();fs();_s();ks();bs();gs();hs();ys();Rs();Ts();ws();vs();Ss();xs();Cs();js();Ps();Es();qs();$l();Os();As();Is();$s();Us();Ms();Ds();Fs();Ns();Gs();Bs();Ls();Ks();Hs();Vs();zs();Ws();Qs();Js();Xs();Ys();Zs();ea();ta();na();ia();ra();oa();sa();eu=S("apps",{Secrets:Ut}),tu=S("billing",{Alerts:Oe,CreditBalanceSummary:Ke,CreditBalanceTransactions:He,CreditGrants:Ve,MeterEventAdjustments:st,MeterEvents:dt,Meters:mt}),nu=S("billingPortal",{Configurations:Ne,Sessions:Mt}),iu=S("checkout",{Sessions:Dt}),ru=S("climate",{Orders:ft,Products:wt,Suppliers:Gt}),ou=S("entitlements",{ActiveEntitlements:qe,Features:et}),su=S("financialConnections",{Accounts:Pe,Sessions:Ft,Transactions:Ht}),au=S("forwarding",{Requests:It}),lu=S("identity",{VerificationReports:Yt,VerificationSessions:Zt}),cu=S("issuing",{Authorizations:Ie,Cardholders:Me,Cards:De,Disputes:Je,PersonalizationDesigns:yt,PhysicalBundles:Tt,Tokens:Lt,Transactions:Vt}),du=S("radar",{EarlyFraudWarnings:Xe,PaymentEvaluations:ht,ValueListItems:Jt,ValueLists:Xt}),uu=S("reporting",{ReportRuns:Ot,ReportTypes:At}),mu=S("sigma",{ScheduledQueryRuns:$t}),pu=S("tax",{Associations:Ae,Calculations:Ue,Registrations:qt,Settings:Nt,Transactions:zt}),fu=S("terminal",{Configurations:Ge,ConnectionTokens:Le,Locations:ot,OnboardingLinks:pt,Readers:vt}),_u=S("testHelpers",{ConfirmationTokens:Be,Customers:We,Refunds:Et,TestClocks:Bt,Issuing:S("issuing",{Authorizations:$e,Cards:Fe,PersonalizationDesigns:Rt,Transactions:Wt}),Terminal:S("terminal",{Readers:St}),Treasury:S("treasury",{InboundTransfers:it,OutboundPayments:_t,OutboundTransfers:bt,ReceivedCredits:xt,ReceivedDebits:jt})}),ku=S("treasury",{CreditReversals:ze,DebitReversals:Qe,FinancialAccounts:tt,InboundTransfers:rt,OutboundPayments:kt,OutboundTransfers:gt,ReceivedCredits:Ct,ReceivedDebits:Pt,TransactionEntries:Kt,Transactions:Qt}),bu=S("v2",{Billing:S("billing",{MeterEventAdjustments:at,MeterEventSession:lt,MeterEventStream:ct,MeterEvents:ut}),Commerce:S("commerce",{ProductCatalog:S("productCatalog",{Imports:nt})}),Core:S("core",{AccountLinks:Ce,AccountTokens:je,Accounts:Ee,EventDestinations:Ye,Events:Ze})})});var Ul=f(()=>{Ri()});class la{constructor(e){this.stripe=e,this.secrets=new Ut(e)}}var Ml=f(()=>{Ko()});class ca{constructor(e){this.stripe=e,this.alerts=new Oe(e),this.creditBalanceSummaries=new Ke(e),this.creditBalanceTransactions=new He(e),this.creditGrants=new Ve(e),this.meters=new mt(e),this.meterEvents=new dt(e),this.meterEventAdjustments=new st(e)}}var Dl=f(()=>{Fr();Xr();Yr();Zr();yo();go();fo()});class da{constructor(e){this.stripe=e,this.configurations=new Ne(e),this.sessions=new Mt(e)}}var Fl=f(()=>{zr();Ho()});class ua{constructor(e){this.stripe=e,this.sessions=new Dt(e)}}var Nl=f(()=>{Vo()});class ma{constructor(e){this.stripe=e,this.orders=new ft(e),this.products=new wt(e),this.suppliers=new Gt(e)}}var Gl=f(()=>{To();qo();Qo()});class pa{constructor(e){this.stripe=e,this.activeEntitlements=new qe(e),this.features=new et(e)}}var Bl=f(()=>{Dr();ao()});class fa{constructor(e){this.stripe=e,this.accounts=new Pe(e),this.sessions=new Ft(e),this.transactions=new Ht(e)}}var Ll=f(()=>{Ir();zo();Zo()});class _a{constructor(e){this.stripe=e,this.requests=new It(e)}}var Kl=f(()=>{Bo()});class ka{constructor(e){this.stripe=e,this.verificationReports=new Yt(e),this.verificationSessions=new Zt(e)}}var Hl=f(()=>{ss();as()});class ba{constructor(e){this.stripe=e,this.authorizations=new Ie(e),this.cards=new De(e),this.cardholders=new Me(e),this.disputes=new Je(e),this.personalizationDesigns=new yt(e),this.physicalBundles=new Tt(e),this.tokens=new Lt(e),this.transactions=new Vt(e)}}var Vl=f(()=>{Gr();Hr();Kr();io();jo();Eo();Xo();es()});class ga{constructor(e){this.stripe=e,this.earlyFraudWarnings=new Xe(e),this.paymentEvaluations=new ht(e),this.valueLists=new Xt(e),this.valueListItems=new Jt(e)}}var zl=f(()=>{ro();Co();os();rs()});class ha{constructor(e){this.stripe=e,this.reportRuns=new Ot(e),this.reportTypes=new At(e)}}var Wl=f(()=>{No();Go()});class ya{constructor(e){this.stripe=e,this.scheduledQueryRuns=new $t(e)}}var Ql=f(()=>{Lo()});class Ra{constructor(e){this.stripe=e,this.associations=new Ae(e),this.calculations=new Ue(e),this.registrations=new qt(e),this.settings=new Nt(e),this.transactions=new zt(e)}}var Jl=f(()=>{Nr();Lr();Fo();Wo();ts()});class Ta{constructor(e){this.stripe=e,this.configurations=new Ge(e),this.connectionTokens=new Le(e),this.locations=new ot(e),this.onboardingLinks=new pt(e),this.readers=new vt(e)}}var Xl=f(()=>{Wr();Jr();po();Ro();Oo()});class wa{constructor(e){this.stripe=e,this.authorizations=new $e(e),this.cards=new Fe(e),this.personalizationDesigns=new Rt(e),this.transactions=new Wt(e)}}var Yl=f(()=>{Br();Vr();Po();ns()});class va{constructor(e){this.stripe=e,this.readers=new St(e)}}var Zl=f(()=>{Ao()});class Sa{constructor(e){this.stripe=e,this.inboundTransfers=new it(e),this.outboundPayments=new _t(e),this.outboundTransfers=new bt(e),this.receivedCredits=new xt(e),this.receivedDebits=new jt(e)}}var ec=f(()=>{uo();wo();So();Io();Uo()});class xa{constructor(e){this.stripe=e,this.confirmationTokens=new Be(e),this.customers=new We(e),this.refunds=new Et(e),this.testClocks=new Bt(e),this.issuing=new wa(e),this.terminal=new va(e),this.treasury=new Sa(e)}}var tc=f(()=>{Qr();to();Do();Jo();Yl();Zl();ec()});class Ca{constructor(e){this.stripe=e,this.creditReversals=new ze(e),this.debitReversals=new Qe(e),this.financialAccounts=new tt(e),this.inboundTransfers=new rt(e),this.outboundPayments=new kt(e),this.outboundTransfers=new gt(e),this.receivedCredits=new Ct(e),this.receivedDebits=new Pt(e),this.transactions=new Qt(e),this.transactionEntries=new Kt(e)}}var nc=f(()=>{eo();no();lo();mo();vo();xo();$o();Mo();is();Yo()});class ja{constructor(e){this.stripe=e,this.meterEvents=new ut(e),this.meterEventAdjustments=new at(e),this.meterEventSession=new lt(e),this.meterEventStream=new ct(e)}}var ic=f(()=>{ho();_o();ko();bo()});class Pa{constructor(e){this.stripe=e,this.imports=new nt(e)}}var rc=f(()=>{co()});class Ea{constructor(e){this.stripe=e,this.productCatalog=new Pa(e)}}var oc=f(()=>{rc()});class qa{constructor(e){this.stripe=e,this.accounts=new Ee(e),this.accountLinks=new Ce(e),this.accountTokens=new je(e),this.events=new Ze(e),this.eventDestinations=new Ye(e)}}var sc=f(()=>{Mr();Or();Ar();so();oo()});class Oa{constructor(e){this.stripe=e,this.billing=new ja(e),this.commerce=new Ea(e),this.core=new qa(e)}}var ac=f(()=>{ic();oc();sc()});class w{static initialize(e,t=_c){w._platformFunctions=e,w._requestSenderFactory=t,w.webhooks=Pl(e),w.createNodeHttpClient=e.createNodeHttpClient,w.createFetchHttpClient=e.createFetchHttpClient,w.createNodeCryptoProvider=e.createNodeCryptoProvider,w.createSubtleCryptoProvider=e.createSubtleCryptoProvider;let n=e.getEnv(),i=e.getRuntimeVersion();w.aiAgent=n?pl(n):"",w.AI_AGENT=w.aiAgent,w.USER_AGENT={bindings_version:w.PACKAGE_VERSION,lang:"node",typescript:!1,...i?{lang_version:i}:{},...w.aiAgent?{ai_agent:w.aiAgent}:{}}}constructor(e,t={}){this._authenticator=null;let n=this._getPropsFromConfig(t);this._platformFunctions=w._platformFunctions,Object.defineProperty(this,"_emitter",{value:this._platformFunctions.createEmitter(),enumerable:!1,configurable:!1,writable:!1}),this.VERSION=w.PACKAGE_VERSION,this.on=this._emitter.on.bind(this._emitter),this.once=this._emitter.once.bind(this._emitter),this.off=this._emitter.removeListener.bind(this._emitter);let i=n.httpAgent||null;this._api={host:n.host||Aa,port:n.port||lc,protocol:n.protocol||"https",basePath:cc,version:n.apiVersion||dc,timeout:ki("timeout",n.timeout,uc),maxNetworkRetries:ki("maxNetworkRetries",n.maxNetworkRetries,2),agent:i,httpClient:n.httpClient||(i?this._platformFunctions.createNodeHttpClient(i):this._platformFunctions.createDefaultHttpClient()),dev:!1,stripeAccount:n.stripeAccount||null,stripeContext:n.stripeContext||null};let r=n.typescript||!1;if(r!==w.USER_AGENT.typescript)w.USER_AGENT.typescript=r;if(n.appInfo)this._setAppInfo(n.appInfo);this._setAuthenticator(e,n.authenticator||null),this.errors=Si,this.Decimal=M,this.webhooks=w.webhooks,this._prevRequestMetrics=[],this._enableTelemetry=n.telemetry!==!1,this._emitEventBodies=n.emitEventBodies===!0,this._requestSender=w._requestSenderFactory(this),this.accountLinks=new en(this),this.accountSessions=new tn(this),this.accounts=new oe(this),this.applePayDomains=new nn(this),this.applicationFees=new rn(this),this.balance=new se(this),this.balanceSettings=new on(this),this.balanceTransactions=new sn(this),this.charges=new an(this),this.confirmationTokens=new ln(this),this.countrySpecs=new cn(this),this.coupons=new dn(this),this.creditNotes=new un(this),this.customerSessions=new pn(this),this.customers=new mn(this),this.disputes=new fn(this),this.ephemeralKeys=new _n(this),this.events=new kn(this),this.exchangeRates=new bn(this),this.fileLinks=new hn(this),this.files=new gn(this),this.invoiceItems=new Rn(this),this.invoicePayments=new Tn(this),this.invoiceRenderingTemplates=new wn(this),this.invoices=new yn(this),this.mandates=new vn(this),this.paymentAttemptRecords=new xn(this),this.paymentIntents=new Cn(this),this.paymentLinks=new jn(this),this.paymentMethodConfigurations=new En(this),this.paymentMethodDomains=new qn(this),this.paymentMethods=new Pn(this),this.paymentRecords=new On(this),this.payouts=new An(this),this.plans=new In(this),this.prices=new $n(this),this.products=new Un(this),this.promotionCodes=new Mn(this),this.quotes=new Dn(this),this.refunds=new Fn(this),this.reviews=new Nn(this),this.setupAttempts=new Gn(this),this.setupIntents=new Bn(this),this.shippingRates=new Ln(this),this.sources=new Kn(this),this.subscriptionItems=new Vn(this),this.subscriptionSchedules=new zn(this),this.subscriptions=new Hn(this),this.taxCodes=new Wn(this),this.taxIds=new Qn(this),this.taxRates=new Jn(this),this.tokens=new Xn(this),this.topups=new Yn(this),this.transfers=new Zn(this),this.webhookEndpoints=new ei(this),this.apps=new la(this),this.billing=new ca(this),this.billingPortal=new da(this),this.checkout=new ua(this),this.climate=new ma(this),this.entitlements=new pa(this),this.financialConnections=new fa(this),this.forwarding=new _a(this),this.identity=new ka(this),this.issuing=new ba(this),this.radar=new ga(this),this.reporting=new ha(this),this.sigma=new ya(this),this.tax=new Ra(this),this.terminal=new Ta(this),this.testHelpers=new xa(this),this.treasury=new Ca(this),this.v2=new Oa(this),this.account=this.accounts,this.oauth=new Sn(this)}rawRequest(e,t,n,i){return this._requestSender._rawRequest(e,t,n,i)}_setAuthenticator(e,t){if(e&&t)throw Error("Can't specify both apiKey and authenticator");if(!e&&!t)throw Error("Neither apiKey nor config.authenticator provided");this._authenticator=e?lr(e):t}_setAppInfo(e){if(e&&typeof e!=="object")throw Error("AppInfo must be an object.");if(e&&!e.name)throw Error("AppInfo.name is required");e=e||{},this._appInfo=gu.reduce((t,n)=>{if(typeof e[n]=="string")t=t||{},t[n]=e[n];return t},{})}setClientId(e){this._clientId=e}getClientId(){return this._clientId}getConstant(e){switch(e){case"DEFAULT_HOST":return Aa;case"DEFAULT_PORT":return lc;case"DEFAULT_BASE_PATH":return cc;case"DEFAULT_API_VERSION":return dc;case"DEFAULT_TIMEOUT":return uc;case"MAX_NETWORK_RETRY_DELAY_SEC":return mc;case"INITIAL_NETWORK_RETRY_DELAY_SEC":return pc}return w[e]}resolveBaseAddress(e){let t=this.getApiField("host");if(t!==Aa)return t;return sr[e]}getMaxNetworkRetries(){return this.getApiField("maxNetworkRetries")}_setApiNumberField(e,t,n){let i=ki(e,t,n);this._setApiField(e,i)}getMaxNetworkRetryDelay(){return mc}getInitialNetworkRetryDelay(){return pc}getClientUserAgent(e){return this.getClientUserAgentSeeded(w.USER_AGENT,e)}getClientUserAgentSeeded(e,t){let n={};for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;n[o]=encodeURIComponent(e[o]??"null")}let i=this._platformFunctions.getPlatformInfo();if(i&&this.getTelemetryEnabled())n.platform=encodeURIComponent(i);else delete n.platform;let r=this.getApiField("httpClient");if(r)n.httplib=encodeURIComponent(r.getClientName());if(this._appInfo)n.application=this._appInfo;if(this.getTelemetryEnabled()){let o=this._platformFunctions.getTelemetryId();if(o)n.telemetry_id=o}t(JSON.stringify(n))}getAppInfoAsString(){if(!this._appInfo)return"";let e=this._appInfo.name;if(this._appInfo.version)e+=`/${this._appInfo.version}`;if(this._appInfo.url)e+=` (${this._appInfo.url})`;return e}getTelemetryEnabled(){return this._enableTelemetry}getEmitEventBodiesEnabled(){return this._emitEventBodies}_prepResources(){for(let e in ae){if(!Object.prototype.hasOwnProperty.call(ae,e))continue;this[ul(e.replace("Resource",""))]=new ae[e](this)}}_getPropsFromConfig(e){if(!e)return{};let t=typeof e==="string";if(!(e===Object(e)&&!Array.isArray(e))&&!t)throw Error("Config must either be an object or a string");if(t)return{apiVersion:e};if(Object.keys(e).filter((r)=>!fc.includes(r)).length>0)throw Error(`Config object may only contain the following: ${fc.join(", ")}`);return e}_setApiField(e,t){this._api[e]=t}getApiField(e){return this._api[e]}parseEventNotification(e,t,n,i,r,o){if(!this.webhooks.signature)throw Error("ERR: missing signature helper, unable to verify");this.webhooks.signature.verifyHeader(e,t,n,i||this.webhooks.DEFAULT_TOLERANCE,r||this._platformFunctions.createDefaultCryptoProvider(),o);let s=e instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(e)):JSON.parse(e);if(s&&s.object==="event")throw Error("You passed a webhook payload to stripe.parseEventNotification, which expects an event notification. Use stripe.webhooks.constructEvent instead.");if(s.context)s.context=K.parse(s.context);return s.fetchEvent=()=>this._requestSender._rawRequest("GET",`/v2/core/events/${s.id}`,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_event"]),s.fetchRelatedObject=()=>{if(!s.related_object)return Promise.resolve(null);return this._requestSender._rawRequest("GET",s.related_object.url,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_related_object"])},s}async parseEventNotificationAsync(e,t,n,i,r,o){if(!this.webhooks.signature)throw Error("ERR: missing signature helper, unable to verify");await this.webhooks.signature.verifyHeaderAsync(e,t,n,i||this.webhooks.DEFAULT_TOLERANCE,r||this._platformFunctions.createDefaultCryptoProvider(),o);let s=e instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(e)):JSON.parse(e);if(s&&s.object==="event")throw Error("You passed a webhook payload to stripe.parseEventNotificationAsync, which expects an event notification. Use stripe.webhooks.constructEventAsync instead.");if(s.context)s.context=K.parse(s.context);return s.fetchEvent=()=>this._requestSender._rawRequest("GET",`/v2/core/events/${s.id}`,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_event"]),s.fetchRelatedObject=()=>{if(!s.related_object)return Promise.resolve(null);return this._requestSender._rawRequest("GET",s.related_object.url,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_related_object"])},s}}var Aa="api.stripe.com",lc="443",cc="/v1/",dc,uc=80000,mc=5,pc=0.5,gu,fc,_c=(e)=>new re(e,d.MAX_BUFFERED_REQUEST_METRICS);var kc=f(()=>{xi();Tl();b();ar();El();yi();hi();aa();W();Ul();Ci();ls();cs();ds();us();ji();ms();ps();fs();_s();ks();bs();gs();hs();ys();Rs();Ts();vs();Ss();xs();Cs();js();Ps();Es();qs();Os();As();Is();$s();Us();Ms();Ds();Fs();Ns();Gs();Bs();Ls();Ks();Hs();Vs();zs();Ws();Qs();Js();Xs();Ys();Zs();ea();ta();na();ia();ra();oa();sa();Ml();Dl();Fl();Nl();Gl();Bl();Ll();Kl();Hl();Vl();zl();Wl();Ql();Jl();Xl();tc();nc();ac();ws();aa();dc=qr,gu=["name","version","url","partner_id"],fc=["authenticator","apiVersion","typescript","maxNetworkRetries","httpAgent","httpClient","timeout","host","port","protocol","telemetry","emitEventBodies","appInfo","stripeAccount","stripeContext"];w.PACKAGE_VERSION="22.3.2";w.API_VERSION=qr;w.aiAgent="";w.AI_AGENT="";w.USER_AGENT={bindings_version:w.PACKAGE_VERSION,lang:"node",typescript:!1};w.StripeResource=d;w.resources=ae;w.HttpClient=q;w.HttpClientResponse=he;w.CryptoProvider=Re;w.StripeContext=K;w.errors=Si;w.Decimal=M;w._requestSenderFactory=_c});var bc={};Oi(bc,{Decimal:()=>M,Stripe:()=>w,default:()=>hu});var hu;var gc=f(()=>{Rl();Ri();kc();w.initialize(new fr);hu=w});import"@stacksjs/validation";import{log as Ai}from"@stacksjs/cli";import{db as Na}from"@stacksjs/database";async function Xc(e,t={}){let{olderThanDays:n=30,column:i="created_at",query:r}=t;try{if(r){let l=Na.deleteFrom(e);l=r(l);let u=await l.execute(),m=Array.isArray(u)?u:[u],p=Number(m[0]?.numDeletedRows??m.length??0);return Ai.info(`Pruned ${p} records from ${e}`),p}let o=new Date;o.setDate(o.getDate()-n);let s=await Na.deleteFrom(e).where(i,"<",o.toISOString()).execute(),a=Array.isArray(s)?s:[s],c=Number(a[0]?.numDeletedRows??a.length??0);return Ai.info(`Pruned ${c} records from ${e} older than ${n} days`),c}catch(o){throw Ai.error(`Failed to prune ${e}:`,o),o}}async function wf(e,t={}){return Xc(e,t)}function vf(e){if(!e?.prunable)return null;if(typeof e.prunable==="boolean")return{olderThanDays:30,column:"created_at"};return e.prunable}import{createCipheriv as Yc,createDecipheriv as Zc,createHash as ed,randomBytes as td}from"crypto";import{log as ai}from"@stacksjs/logging";var Ga="enc:",Ba="aes-256-gcm",nd=12,si=null;async function La(){if(si)return si;let e=process.env.APP_KEY;if(!e)try{e=(await import("@stacksjs/config").catch(()=>null))?.config?.app?.key}catch{}if(!e)return null;return si=ed("sha256").update(e).digest(),si}function ue(e){return typeof e==="string"&&e.startsWith(Ga)}async function Ii(e){if(e==null)return e;if(ue(e))return e;if(typeof e!=="string")return e;let t=await La();if(!t)return ai.warn("[orm] encrypted attribute: APP_KEY not set - storing value in plaintext"),e;let n=td(nd),i=Yc(Ba,t,n),r=Buffer.concat([i.update(e,"utf8"),i.final()]),o=i.getAuthTag();return`${Ga}${n.toString("base64")}:${o.toString("base64")}:${r.toString("base64")}`}async function $i(e){if(e==null)return e;if(typeof e!=="string")return e;if(!ue(e))return e;try{let t=await La();if(!t)return ai.warn("[orm] encrypted attribute: APP_KEY not set - cannot decrypt"),null;let[,n,i,r]=e.split(":");if(!n||!i||!r)return ai.warn("[orm] encrypted attribute: malformed envelope, returning null"),null;let o=Buffer.from(n,"base64"),s=Buffer.from(i,"base64"),a=Buffer.from(r,"base64"),c=Zc(Ba,t,o);return c.setAuthTag(s),Buffer.concat([c.update(a),c.final()]).toString("utf8")}catch(t){return ai.warn("[orm] encrypted attribute: decrypt failed (key rotation? corrupted ciphertext?)",{error:t}),null}}function Ui(e){let t=e.attributes;if(!t||typeof t!=="object")return[];let n=[];for(let[i,r]of Object.entries(t))if(r&&typeof r==="object"&&r.encrypted===!0)n.push(i);return n}import{sqlDateTime as id}from"@stacksjs/database";import{log as pe}from"@stacksjs/logging";var rd=[/^password$/i,/^password_hash$/i,/^api_key$/i,/_token$/i,/_secret$/i,/^remember_token$/i],Ha="model_audits",Fi=null;function od(e){Fi=e}async function Mi(){if(Fi!=null)return Fi;try{let e=await import("@stacksjs/router").catch(()=>null);if(!e)return null;let t=e.getCurrentRequest;if(typeof t!=="function")return null;let n=t();if(!n)return null;return(n.user??n._user)?.id??null}catch{return null}}function li(e){if(!e||typeof e!=="object")return null;let t={};for(let[n,i]of Object.entries(e)){if(rd.some((r)=>r.test(n)))continue;t[n]=i}return t}function me(e){if(!e||typeof e!=="object")return null;let t=e;if(t._attributes&&typeof t._attributes==="object")return{...t._attributes};return{...e}}function sd(e,t){if(!e||!t)return{old:e,next:t};let n={},i={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of r)if(e[o]!==t[o])n[o]=e[o],i[o]=t[o];return{old:n,next:i}}async function Di(e,t=!1){try{let{db:n}=await import("@stacksjs/database");await n.insertInto(Ha).values({auditable_type:e.auditable_type,auditable_id:e.auditable_id,event:e.event,old_values:e.old_values?JSON.stringify(e.old_values):null,new_values:e.new_values?JSON.stringify(e.new_values):null,user_id:e.user_id,created_at:id()}).executeTakeFirst()}catch(n){if(pe.warn(`[orm] audit row write failed for ${e.auditable_type}#${String(e.auditable_id)} (${e.event})`,{error:n}),t)throw n}}function Va(e){return{async audits(t){try{let{db:n}=await import("@stacksjs/database");return(await n.selectFrom(Ha).selectAll().where("auditable_type","=",e).where("auditable_id","=",t).orderBy("created_at","desc").execute()??[]).map((r)=>({...r,old_values:typeof r.old_values==="string"?Ka(r.old_values):r.old_values,new_values:typeof r.new_values==="string"?Ka(r.new_values):r.new_values}))}catch(n){return pe.warn(`[orm] audits() lookup failed for ${e}#${String(t)}`,{error:n}),[]}}}}function Ka(e){try{return JSON.parse(e)}catch{return e}}function za(e){if(e&&typeof e==="object"&&"transactional"in e)return{transactional:e.transactional===!0};return{transactional:!1}}function Wa(e,t,n="id",i={}){let r=i.transactional===!0,o=e;if(typeof e.audits!=="function")e.audits=Va(t).audits;let s=async(u)=>{if(!r)return await u();let{db:m}=await import("@stacksjs/database");return await m.transaction(async()=>u())},a=e.create;if(typeof a==="function")e.create=async function(...u){return await s(async()=>{let m=await a.apply(this,u);try{let p=me(m),_=p?.[n];if(_!=null){let k=await Mi();await Di({auditable_type:t,auditable_id:_,event:"created",old_values:null,new_values:li(p),user_id:k},r)}}catch(p){if(pe.warn(`[orm] audit(create) failed for ${t}`,{error:p}),r)throw p}return m})};let c=e.update;if(typeof c==="function")e.update=async function(u,m){return await s(async()=>{let p=o.find,_=typeof p==="function"?me(await p.call(o,u)):null,k=await c.call(this,u,m);try{let g=me(k)??(typeof p==="function"?me(await p.call(o,u)):null),{old:y,next:R}=sd(_,g);if(R&&Object.keys(R).length>0){let v=await Mi();await Di({auditable_type:t,auditable_id:u,event:"updated",old_values:li(y),new_values:li(R),user_id:v},r)}}catch(g){if(pe.warn(`[orm] audit(update) failed for ${t}#${String(u)}`,{error:g}),r)throw g}return k})};let l=(u)=>{let m=e[u];if(typeof m!=="function")return;e[u]=async function(p){return await s(async()=>{let _=o.find,k=typeof _==="function"?me(await _.call(o,p)):null,g=await m.call(this,p);try{if(g!==!1&&k){let y=await Mi();await Di({auditable_type:t,auditable_id:p,event:"deleted",old_values:li(k),new_values:null,user_id:y},r)}}catch(y){if(pe.warn(`[orm] audit(${u}) failed for ${t}#${String(p)}`,{error:y}),r)throw y}return g})}};l("delete"),l("softDelete")}import{db as ad,sql as ld,sqlDateTime as Ni}from"@stacksjs/database";function G(e,t){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)throw Error(`[orm/commentable] ${t} requires a positive numeric id (received ${String(e)})`)}var fe="commentable_upvotes",_e="commentables";function cd(e){let t=e;return t.code==="SQLITE_CONSTRAINT_UNIQUE"||t.code==="SQLITE_CONSTRAINT"||t.code==="23505"||t.errno===1062||/unique|duplicate/i.test(t.message??"")}function Gi(e){let t=ad;return{async comments(n){return G(n,"comments"),await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).selectAll().execute()},async commentCount(n){let i=await t.selectFrom("commentables").select(ld`count(*) as count`).where("commentables_id","=",n).where("commentables_type","=",e).executeTakeFirst();return Number(i?.count)||0},async addComment(n,i){if(G(n,"addComment"),!i||typeof i.title!=="string"||i.title.trim().length===0)throw Error("[orm/commentable] addComment requires a non-empty comment.title");if(typeof i.body!=="string"||i.body.trim().length===0)throw Error("[orm/commentable] addComment requires a non-empty comment.body");let r=await t.insertInto("commentables").values({...i,commentables_id:n,commentables_type:e,status:"pending",created_at:Ni(),updated_at:Ni()}).returningAll().executeTakeFirst();if(r&&typeof r==="object"&&"id"in r)return r;let o=r?.lastInsertRowid;if(o==null)return r;return await t.selectFrom("commentables").where("id","=",Number(o)).selectAll().executeTakeFirst()},async approvedComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","approved").selectAll().execute()},async pendingComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","pending").selectAll().execute()},async rejectedComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","rejected").selectAll().execute()},async upvoteComment(n,i){G(n,"upvoteComment"),G(i,"upvoteComment");let r=()=>t.selectFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).selectAll().executeTakeFirst(),o=await r();if(o)return o;try{await t.insertInto(fe).values({upvoteable_id:n,upvoteable_type:_e,user_id:i,created_at:Ni()}).execute()}catch(s){if(!cd(s))throw s}return await r()},async removeCommentUpvote(n,i){G(n,"removeCommentUpvote"),G(i,"removeCommentUpvote"),await t.deleteFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).execute()},async commentUpvoteCount(n){G(n,"commentUpvoteCount");let i=await t.selectFrom(fe).select("count(*) as count").where("upvoteable_id","=",n).where("upvoteable_type","=",_e).executeTakeFirst();return Number(i?.count)||0},async hasUpvotedComment(n,i){return G(n,"hasUpvotedComment"),G(i,"hasUpvotedComment"),!!await t.selectFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).selectAll().executeTakeFirst()}}}import{db as dd,sql as ud,sqlDateTime as Qa}from"@stacksjs/database";function Bi(e,t){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)throw Error(`[orm/taggable] ${t} requires a positive numeric id (received ${String(e)})`)}function Li(e){let t=dd;return{async tags(n){return Bi(n,"tags"),await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).selectAll().execute()},async tagCount(n){Bi(n,"tagCount");let i=await t.selectFrom("taggables").select(ud`count(*) as count`).where("taggable_id","=",n).where("taggable_type","=",e).executeTakeFirst();return Number(i?.count)||0},async addTag(n,i){if(Bi(n,"addTag"),!i||typeof i.name!=="string"||i.name.trim().length===0)throw Error("[orm/taggable] addTag requires a non-empty tag.name");return await t.insertInto("taggables").values({...i,taggable_id:n,taggable_type:e,slug:i.name.toLowerCase().replace(/[^a-z0-9]+/g,"-"),is_active:!0,created_at:Qa(),updated_at:Qa()}).execute(),await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("name","=",i.name).selectAll().executeTakeFirst()},async activeTags(n){return await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("is_active","=",!0).selectAll().execute()},async inactiveTags(n){return await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("is_active","=",!1).selectAll().execute()},async removeTag(n,i){await t.deleteFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("id","=",i).execute()}}}import{db as md,sqlDateTime as ci}from"@stacksjs/database";function Ki(e){let t=md;async function n(i){return(await t.selectFrom("categorizable_models").where("categorizable_id","=",i).where("categorizable_type","=",e).selectAll().execute()).map((o)=>o.category_id)}return{async categories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).selectAll().execute()},async categoryCount(i){return(await n(i)).length},async addCategory(i,r){let o=()=>t.selectFrom("categorizables").where("name","=",r.name).where("categorizable_type","=",e).selectAll().executeTakeFirst(),s=await o();if(!s)await t.insertInto("categorizables").values({name:r.name,description:r.description,slug:r.name.toLowerCase().replace(/[^a-z0-9]+/g,"-"),categorizable_type:e,is_active:!0,created_at:ci(),updated_at:ci()}).execute(),s=await o();return await t.insertInto("categorizable_models").values({categorizable_id:i,categorizable_type:e,category_id:s.id,created_at:ci(),updated_at:ci()}).execute(),s},async activeCategories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).where("is_active","=",!0).selectAll().execute()},async inactiveCategories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).where("is_active","=",!1).selectAll().execute()},async removeCategory(i,r){await t.deleteFrom("categorizable_models").where("categorizable_id","=",i).where("categorizable_type","=",e).where("category_id","=",r).execute()}}}import{db as pd,sqlDateTime as fd}from"@stacksjs/database";function Hi(e,t){let n=pd,i=t?.table||`${e}_likes`,r=t?.foreignKey||`${e.replace(/s$/,"")}_id`;return{async likes(o){return await n.selectFrom(i).where(r,"=",o).selectAll().execute()},async likeCount(o){let s=await n.selectFrom(i).select("count(*) as count").where(r,"=",o).executeTakeFirst();return Number(s?.count)||0},async like(o,s){if(typeof o!=="number"||!Number.isFinite(o)||o<=0)throw Error(`[orm/likeable] like requires a positive numeric id (received ${String(o)})`);if(typeof s!=="number"||!Number.isFinite(s)||s<=0)throw Error(`[orm/likeable] like requires a positive numeric userId (received ${String(s)})`);let a=fd();try{return await n.insertInto(i).values({[r]:o,user_id:s,created_at:a,updated_at:a}).returningAll().executeTakeFirst()}catch(c){let l=c;if(!(l.code==="SQLITE_CONSTRAINT_UNIQUE"||l.code==="SQLITE_CONSTRAINT"||l.code==="23505"||l.errno===1062||/unique|duplicate/i.test(l.message??"")))throw c;let m=await n.selectFrom(i).where(r,"=",o).where("user_id","=",s).selectAll().executeTakeFirst();if(m)return m;throw c}},async unlike(o,s){await n.deleteFrom(i).where(r,"=",o).where("user_id","=",s).execute()},async isLiked(o,s){return!!await n.selectFrom(i).where(r,"=",o).where("user_id","=",s).selectAll().executeTakeFirst()},async likedBy(o){return(await n.selectFrom(i).select([r]).where("user_id","=",o).execute()).map((a)=>Number(a[r])).filter(Boolean)}}}function Xa(e){let t=e;return t?.code==="SQLITE_CONSTRAINT_UNIQUE"||t?.code==="SQLITE_CONSTRAINT"||t?.code==="23505"||t?.errno===1062||/unique|duplicate/i.test(t?.message??"")}function _d(e,t,n){let i=e;if(e instanceof Error&&typeof i.status==="number"&&Number.isInteger(i.status)&&i.status>=400&&i.status<600){let r={error:e.message};if(i.details!==void 0)r.details=i.details;return{status:i.status,body:r}}if(Xa(e))return{status:409,body:{error:`${t} already exists`}};return{status:500,body:{error:`Failed to ${n} ${t}`,detail:String(e)}}}function I(e){return e.replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toLowerCase()}function kd(e){let t={};for(let[n,i]of Object.entries(e))t[I(n)]=i;return t}function Nf(e,t){let n=String(t||"").replace(/^\/+|\/+$/g,""),i=String(e).replace(/^\/+/,"");return`/api/${n?`${n}/`:""}${i}`}function Gf(e){if(!e)return null;let t=e.attributes??{};if(Object.prototype.hasOwnProperty.call(t,"teamId")||Object.prototype.hasOwnProperty.call(t,"team_id"))return"team_id";return e.belongsTo?.some((n)=>n==="Team")?"team_id":null}function Bf(e,t,n){let i=Object.keys(e).find((o)=>I(o)===I(t));if(Array.isArray(n)){if(i===void 0)return{data:e,error:"Ownership value is required"};if(!n.some((o)=>String(o)===String(e[i])))return{data:e,error:"Ownership value is not available to this caller"};return{data:{...e,[t]:e[i]}}}if(n===null||n===void 0)return{data:e,error:"Caller has no ownership identity"};let r={...e};for(let o of Object.keys(r))if(I(o)===I(t))delete r[o];return r[t]=n,{data:r}}function bd(e){if(!e)return[];let t=Object.entries(e.attributes??{}).filter(([,n])=>n?.fillable===!0).map(([n])=>n);for(let n of e.belongsTo??[]){if(typeof n!=="string"||!n.trim())continue;let i=I(n.trim()).split("_").filter(Boolean);if(i.length===0)continue;let r=`${i[0]}${i.slice(1).map((o)=>`${o[0]?.toUpperCase()}${o.slice(1)}`).join("")}Id`;t.push(r)}return[...new Set(t)]}function gd(e,t){if(!e||t.length===0)return{};let n={};for(let i of t){if(i in e){n[i]=e[i];continue}let r=I(i);if(r!==i&&r in e)n[i]=e[r]}return n}function hd(e,t){if(e?.name!=="date"||t instanceof Date||typeof t!=="string")return t;let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!n)return t;let i=Number(n[1]),r=Number(n[2]),o=Number(n[3]),s=new Date(Date.UTC(i,r-1,o));if(s.getUTCFullYear()!==i||s.getUTCMonth()!==r-1||s.getUTCDate()!==o)return t;return s}function Lf(e,t){if(!t.length)return e;let n={...e};for(let i of t)delete n[i],delete n[I(i)];return n}function Kf(e,t){if(!e||t.length===0)return e;let n={...e};for(let i of t)delete n[i],delete n[I(i)];return n}var yd=["id","uuid","created_at","updated_at","deleted_at"];function Hf(e,t){let n=new Map;for(let i of[...Object.keys(e??{}),...yd]){let r=I(i);if(!/^\w+$/.test(r))continue;n.set(i,r),n.set(r,r)}for(let i of t)n.delete(i),n.delete(I(i));return n}function Vf(e,t,n){if(!t)return e;let i=String(t).split(",").map((o)=>o.trim()).filter(Boolean),r=e;for(let o of i){let s=o.startsWith("-"),a=s?o.slice(1):o;if(!/^\w+$/.test(a))continue;let c=n.get(a);if(!c)continue;r=r.orderBy(c,s?"desc":"asc")}return r}var Rd={string:{get:(e)=>e!=null?String(e):null,set:(e)=>e!=null?String(e):null},number:{get:(e)=>e!=null?Number(e):null,set:(e)=>e!=null?Number(e):null},integer:{get:(e)=>e!=null?Math.trunc(Number(e)):null,set:(e)=>e!=null?Math.trunc(Number(e)):null},float:{get:(e)=>e!=null?Number.parseFloat(String(e)):null,set:(e)=>e!=null?Number.parseFloat(String(e)):null},boolean:{get:(e)=>e===1||e==="1"||e===!0||e==="true",set:(e)=>e===!0||e===1||e==="1"||e==="true"?1:0},json:{get:(e)=>e==null?null:typeof e==="string"?Td(e):e,set:(e)=>e==null?null:typeof e==="string"?e:JSON.stringify(e)},datetime:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString():e},date:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString().split("T")[0]:e},array:{get:(e)=>e==null?[]:Array.isArray(e)?e:typeof e==="string"?wd(e):[],set:(e)=>e==null?null:Array.isArray(e)?JSON.stringify(e):e}};function Td(e){try{return JSON.parse(e)}catch{return e}}function wd(e){try{return JSON.parse(e)}catch{return[]}}function zf(e,t,n){if(!e||typeof e!=="object"||!t||Object.keys(t).length===0)return e;let i={...e};for(let[r,o]of Object.entries(t)){let s=typeof o==="string"?Rd[o]:o;if(!s||typeof s[n]!=="function")continue;if(Object.prototype.hasOwnProperty.call(i,r))i[r]=s[n](i[r]);let a=I(r);if(a!==r&&Object.prototype.hasOwnProperty.call(i,a))i[a]=s[n](i[a])}return i}function Ya(e,t,n){let i=t?.attributes??{},r={};for(let[o,s]of Object.entries(i)){let a=s?.validation?.rule;if(!a||typeof a.validate!=="function")continue;let c=Object.prototype.hasOwnProperty.call(e,o);if(!c&&n==="updating")continue;let l=s!==null&&typeof s==="object"&&Object.prototype.hasOwnProperty.call(s,"default"),u=c?e[o]:l?s.default:void 0,m=hd(a,u),p=a.validate(m);if(!p?.valid&&Array.isArray(p?.errors)&&p.errors.length>0)r[o]=p.errors.map((_)=>s?.validation?.message?.[_?.code]??_?.message??"invalid")}return Object.keys(r).length===0?{valid:!0}:{valid:!1,errors:r}}function Wf(e){return e.replace(/\{[^}]*\}/g,"{}").replace(/:[^/]+/g,"{}")}function Vi(e){if(Array.isArray(e))return e.filter((t)=>typeof t==="string"&&t.length>0);return typeof e==="string"&&e?[e]:[]}function Qf(e){let t=typeof e==="object"&&e!==null&&"middleware"in e,n=e?.middleware;if(!t)return{read:["auth"],write:["auth"],declared:!1};if(n&&typeof n==="object"&&!Array.isArray(n)){let r=n;return{read:"read"in r?Vi(r.read):["auth"],write:"write"in r?Vi(r.write):["auth"],declared:!0}}let i=Vi(n);return{read:i,write:i,declared:!0}}var Ja=15,vd=100;function Jf(e){let t=Number.parseInt(e.get("page")||String(1),10),n=Number.isFinite(t)?Math.max(1,t):1,i=Number.parseInt(e.get("per_page")||String(Ja),10),r=Math.min(Number.isFinite(i)?Math.max(1,i):Ja,vd);return{page:n,perPage:r,offset:(n-1)*r}}function di(e,t){let n=new URL(e.toString());return n.searchParams.set("page",String(t)),`${n.pathname}${n.search}`}function Sd(e,t,n,i,r,o){let s=(t-1)*n,a=i===0,c={page:t,per_page:n,from:a?null:s+1,to:a?null:s+i,has_more_pages:r,prev_page_url:t>1?di(e,t-1):null,next_page_url:r?di(e,t+1):null};if(o!==void 0&&!Number.isNaN(o)){let l=Math.max(1,Math.ceil(o/n));c.total=o,c.last_page=l,c.first_page_url=di(e,1),c.last_page_url=di(e,l)}return c}function Xf(e,t,n,i,r,o){let{page:s,...a}=Sd(e,t,n,i,r,o);return{current_page:s,...a}}import{cacheRequestQuery as xd}from"@stacksjs/router";var ui=new WeakMap;function e_(e,t){return xd(`batchLoad:${e.name??"model"}:${String(t)}`,async()=>new Promise((n,i)=>{let r=ui.get(e);if(!r)r={keys:[],resolvers:[],scheduled:!1},ui.set(e,r);if(r.keys.push(t),r.resolvers.push({key:t,resolve:n,reject:i}),r.scheduled)return;r.scheduled=!0,Promise.resolve().then(async()=>{let o=ui.get(e);if(!o)return;ui.delete(e);let s=Array.from(new Set(o.keys));try{let a=typeof e.findMany==="function"?await e.findMany(s):await Promise.all(s.map((l)=>e.find?.(l))),c=new Map;for(let l of a??[]){let u=l?.id;if(u!==void 0)c.set(u,l)}for(let l of o.resolvers)l.resolve(c.get(l.key))}catch(a){for(let c of o.resolvers)c.reject(a)}})}))}import{db as r_}from"@stacksjs/database";class Cd{conditions=[];where(e,...t){let[n,i]=t,r=i===void 0?"=":n,o=i===void 0?n:i;this.addCondition("and","where",e,r,o)}orWhere(e,...t){let[n,i]=t,r=i===void 0?"=":n,o=i===void 0?n:i;this.addCondition("or","where",e,r,o)}whereIn(e,t){this.conditions.push({type:"and",method:"whereIn",column:e,values:t})}whereNotIn(e,t){this.conditions.push({type:"and",method:"whereIn",column:e,values:t,operator:"not in"})}whereNull(e){this.conditions.push({type:"and",method:"whereNull",column:e})}whereNotNull(e){this.conditions.push({type:"and",method:"whereNotNull",column:e})}whereBetween(e,t){this.conditions.push({type:"and",method:"whereBetween",column:e,range:t})}whereExists(e){this.conditions.push({type:"and",method:"whereExists",column:"",callback:e})}addCondition(e,t,n,i,r){this.conditions.push({type:e,method:t,column:n,operator:i,value:r})}getConditions(){return this.conditions}}import{db as zi,runInTransactionScope as jd}from"@stacksjs/database";async function a_(e,t){return await jd(async()=>await zi.transaction(e,t))}async function l_(e){return await zi.savepoint(e)}function c_(e,t){return zi.transactional(e,t)}import{path as B}from"@stacksjs/path";import{fs as ne,globSync as Xi}from"@stacksjs/storage";import{plural as il,singular as Za,snakeCase as E}from"@stacksjs/strings";import{isString as mi}from"@stacksjs/validation";function rl(e){let t=e.belongsToMany;if(!t)return[];if(Array.isArray(t))return t.map((n)=>({relationName:typeof n==="string"?E(n):E(String(n.model)),relation:n}));return Object.entries(t).map(([n,i])=>{if(typeof i==="string")return{relationName:n,relation:i};return{relationName:n,relation:{model:i.model,pivotTable:i.table,firstForeignKey:i.foreignKey,secondForeignKey:i.relatedKey}}})}async function __(e){if(typeof e==="string")e=(await import(e)).default;return e.table??E(il(e?.name||""))}function ke(e,t){if(e.name)return e.name;return B.basename(t).replace(/\.ts$/,"")}function F(e,t){if(e.table)return e.table;return E(il(ke(e,t)))}function Pd(e,t){let n=[e,t];return n.sort(),n.join("_")}function k_(e,t){return t in e}async function Ed(e,t){let n=[];if(e.hasOne)for(let i of e.hasOne)n.push(await Wi(i,e,t,"hasOne"));if(e.hasMany)for(let i of e.hasMany)n.push(await Wi(i,e,t,"hasMany"));if(e.belongsTo)for(let i of e.belongsTo)n.push(await Wi(i,e,t,"belongsTo"));if(e.hasOneThrough)for(let i of e.hasOneThrough)n.push(await tl(i,e,t,"hasOneThrough"));if(e.hasManyThrough)for(let i of e.hasManyThrough)n.push(await tl(i,e,t,"hasManyThrough"));if(e.belongsToMany)for(let{relationName:i,relation:r}of rl(e))n.push(await Od(r,e,t,"belongsToMany",i));if(e.morphOne)n.push(await nl(e.morphOne,e,t,"morphOne"));if(e.morphMany){let i=Array.isArray(e.morphMany)?e.morphMany:[e.morphMany];for(let r of i)n.push(await nl(r,e,t,"morphMany"))}if(e.morphTo){let i=e.morphTo,r=Array.isArray(i)?i:typeof i==="object"&&i!==null?[i]:[];for(let o of r)n.push(qd(o,e,t))}if(e.morphToMany){let i=Array.isArray(e.morphToMany)?e.morphToMany:[e.morphToMany];for(let r of i)n.push(el(r,e,t,"morphToMany"))}if(e.morphedByMany){let i=Array.isArray(e.morphedByMany)?e.morphedByMany:[e.morphedByMany];for(let r of i)n.push(el(r,e,t,"morphedByMany"))}return n}function qd(e,t,n){let i=e&&typeof e==="object"&&e.name?String(e.name):`${E(n)}able`,r=e?.type||`${i}_type`;return{relationship:"morphTo",model:"",table:"",relationTable:"",foreignKey:e?.id||`${i}_id`,modelKey:r,relationName:i,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:"",pivotKey:"",pivotTable:""}}function el(e,t,n,i){let r=typeof e==="object"&&e!==null,o=r?String(e.model||""):String(e),s=r&&e.morphName?String(e.morphName):`${E(n)}able`,a=r&&e.pivotTable?String(e.pivotTable):s,c=r&&e.id||`${s}_id`,l=r&&e.type||`${s}_type`;return{relationship:i,model:o,table:"",relationTable:"",foreignKey:c,modelKey:l,relationName:s,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:c,pivotKey:l,pivotTable:a}}async function pi(e,t){let n=Ji(`${t}.ts`),i=Ji(`${e}.ts`),r=Qi(`${e}.ts`),o=Qi(`${t}.ts`);if(!n&&!o)throw Error(`Model not found: ${t}`);if(!i&&!r)throw Error(`Model not found: ${e}`);let s;try{if(ne.existsSync(n))s=(await import(n)).default;else s=(await import(o)).default}catch(c){throw Error(`Failed to load model: ${t}. Error: ${c?.message||"Unknown error"}`)}let a=ne.existsSync(i)?i:r;return{modelRelation:s,modelPath:a,modelRelationPath:ne.existsSync(n)?n:o}}async function tl(e,t,n,i){let r="",o="",s="",a="";if(mi(e))r=e;else r=e.model,o=e.relationName||"",s=e.through,a=e.throughForeignKey||"";let{modelRelation:c,modelPath:l,modelRelationPath:u}=await pi(n,r),m=F(c,u),p=F(t,l),_=E(ke(c,u)),k=E(n);return{relationship:i,model:r,table:m,relationTable:p,foreignKey:`${k}_id`,modelKey:`${_}_id`,relationName:o,relationModel:n,throughModel:s,throughForeignKey:a,pivotForeign:`${k}_id`,pivotKey:`${_}_id`,pivotTable:p}}async function Od(e,t,n,i,r){let o="",s="",a="",c=E(n);if(mi(e))o=e;else o=e.model,s=e.pivotTable||"",a=e.firstForeignKey||`${c}_id`;let{modelRelation:l,modelPath:u,modelRelationPath:m}=await pi(n,o),p=F(l,m),_=F(t,u),k=E(ke(l,m));return{relationship:i,model:o,table:p,relationTable:_,foreignKey:typeof e==="string"?`${c}_id`:e.firstForeignKey||`${c}_id`,modelKey:typeof e==="string"?`${k}_id`:e.secondForeignKey||`${k}_id`,relationName:r,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:a,pivotKey:`${k}_id`,pivotTable:s}}async function nl(e,t,n,i){let r="",o="",s="",a="";if(mi(e))r=e,o=`${E(n)}able`;else r=e.model,o=e.morphName||`${E(n)}able`,s=e.type||`${o}_type`,a=e.id||`${o}_id`;let{modelRelation:c,modelPath:l,modelRelationPath:u}=await pi(n,r),m=F(c,u),p=F(t,l);return{relationship:i,model:r,table:m,relationTable:p,foreignKey:a||`${o}_id`,modelKey:s||`${o}_type`,relationName:o,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:"",pivotKey:"",pivotTable:p}}async function Wi(e,t,n,i){let r="",o="";if(mi(e))r=e;else r=e.model,o=e.relationName||"";let{modelRelation:s,modelPath:a,modelRelationPath:c}=await pi(n,r),l=F(s,c),u=F(t,a),m=E(ke(s,c)),p=E(n),_={relationship:i,model:r,table:l,relationTable:u,foreignKey:typeof e==="string"?`${p}_id`:e.foreignKey||`${p}_id`,modelKey:`${m}_id`,relationName:o,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:`${p}_id`,pivotKey:`${m}_id`,pivotTable:u};if(i==="belongsTo")_.foreignKey="";return _}function b_(e){let t=/belongs/,n=/has/,i=/Through/,r=/morph/;if(i.test(e))return"throughType";if(t.test(e))return"belongsType";if(n.test(e))return"hasType";if(r.test(e))return"morphType";return""}function g_(e){let t=/One/;if(/Many/.test(e))return"many";if(t.test(e))return"one";return""}async function h_(e,t){let n=[];if("belongsToMany"in e){for(let{relation:i}of rl(e)){let r,o;if(typeof i==="string")o=i;else o=i.model;let s=Ji(`${o}.ts`),a=Qi(`${o}.ts`);if(ne.existsSync(s))r=(await import(s)).default;else r=(await import(a)).default;let c=F(r,s),l=F(e,t),u=typeof i==="object"&&"firstForeignKey"in i?i.firstForeignKey:`${Za(l)}_${e.primaryKey}`,m=typeof i==="object"&&"secondForeignKey"in i?i.secondForeignKey:`${Za(c)}_${e.primaryKey}`;n.push({table:(typeof i==="object"&&"pivotTable"in i?i.pivotTable:void 0)??Pd(l,c),firstForeignKey:u,secondForeignKey:m})}return n}return[]}async function y_(e){let t=Xi([B.userModelsPath("*.ts"),B.storagePath("framework/defaults/app/Models/**/*.ts")],{absolute:!0}),n=[];for(let i=0;i<t.length;i++){let r=t[i],o=await import(r);if(e===o.default.name)continue;let s=ke(o,r),a=await Ed(o.default,s);if(!a.length)continue;let c=a.find((l)=>l.model===e);if(c)n.push(c)}return n}function R_(e){if(e===void 0)return[];return Object.keys(e).filter((t)=>e[t]?.hidden===!0)}function T_(e){let t=e.attributes;if(t===void 0)return[];return Object.keys(t).filter((n)=>t[n]?.guarded===!0).map((n)=>E(n))}function w_(e,t){let n=e.attributes,i=[];if(n===void 0)return[];let r=typeof e.traits?.billable==="object"||typeof e.traits?.billable==="boolean",o=typeof e.traits?.useAuth==="object"?e.traits?.useAuth.usePasskey:!1,s=e.traits?.useUuid||!1;if(r)i.push("stripe_id");if(s)i.push("uuid");if(o)i.push(...["two_factor_secret","public_key"]);let a=t.map((c)=>c.foreignKey).filter((c)=>c);return[...Object.keys(n).filter((c)=>{if(n===void 0)return!1;return n[c]?.fillable===!0}).map((c)=>E(c)),...i,...a]}async function v_(e,t){let n=e.attributes;if(!n)n={};let i=Object.keys(n),r=[],o=Bun.file(t),s="";try{if(await o.exists())s=await o.text()}catch{s=""}let a=/rule:.*$/gm,c;c=a.exec(s);while(c!==null)r.push(c[0]),c=a.exec(s);return i.map((u,m)=>{let p=n[u],_=null,k=!1,g=!1,y=!1,R=!1;if(p)_=p||null,k=p.unique||!1,g=p.hidden||!1,y=p.fillable||!1;let v=r[m]??"";return R=(p.validation?.rule).isRequired??!1,{field:u,default:_,unique:k,hidden:g,fillable:y,required:R,fieldArray:Ad(v)}})}function Ad(e){let t=e.split("rule: schema.");if(t.length!==2)return null;if(!t[1])t[1]="";let n=t[1].replace(/,/g,"");if(!n)return null;let i=n.split("."),r=/\(([^)]+)\)/;return i.map((o)=>{let s=r.exec(o),a=s?s[1]:null;return{entity:o.replace(r,"").replace(/\(|\)/g,""),charValue:a}})[0]||null}function S_(e){let t=e.fieldArray?.entity;switch(t){case"enum":return"string | string[]";case"date":return"Date | string";case"timestamp":return"Date | string";case"datetime":return"Date | string";case"float":return"number";case"double":return"number";case"decimal":return"number";case"integer":return"number";case"bigint":return"number";default:return t}}function Qi(e){let t=B.join(B.storagePath("framework/defaults/app/Models"),"/"),n=B.join(t,e);if(ne.existsSync(n))return n;return Xi(`${t}**/${e}`,{absolute:!0})[0]??""}function Ji(e){let t=B.join(B.userModelsPath("/"),"/"),n=B.join(t,e);if(ne.existsSync(n))return n;return Xi(`${t}**/${e}`,{absolute:!0})[0]??""}function x_(e){let t=typeof e==="number"?new Date(e):typeof e==="string"?new Date(e):e;if(Number.isNaN(t.getTime()))throw Error(`Invalid date value: ${String(e)}`);return t.toISOString().replace("T"," ").split(".")[0]??""}function C_(e){return e.toISOString().split("T")[0]??""}function j_(e){return e.getTime()}import{createModel as vu,registerModel as Su}from"@stacksjs/query-builder";import{log as A}from"@stacksjs/logging";import{snakeCase as H}from"@stacksjs/strings";import{AsyncLocalStorage as Ec}from"async_hooks";function Id(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&typeof t.current_page==="number"&&typeof t.per_page==="number"&&typeof t.total==="number"&&typeof t.last_page==="number"}function $d(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&typeof t.current_page==="number"&&typeof t.per_page==="number"&&typeof t.has_more_pages==="boolean"&&!("total"in t)}function Ud(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&(typeof t.next_cursor==="string"||t.next_cursor===null)}function Yi(e){let{data:t}=e,{perPage:n,page:i,total:r,lastPage:o}=e.meta,s=t.length===0,a=s?null:(i-1)*n+1,c=s?null:a+t.length-1;return{data:t,current_page:i,per_page:n,total:r,last_page:o,from:a,to:c,has_more_pages:i<o}}function Zi(e){return{data:e.data,current_page:e.meta.page,per_page:e.meta.perPage,has_more_pages:e.meta.hasMore}}function er(e){return{data:e.data,per_page:e.meta.perPage,next_cursor:ol(e.meta.nextCursor),prev_cursor:ol(e.meta.prevCursor),has_more_pages:e.meta.nextCursor!==null&&e.meta.nextCursor!==void 0}}function ol(e){if(e===null||e===void 0)return null;if(typeof e==="string")return e;return JSON.stringify(e)}function nr(e,t){let n=or(),i=n?tr(n,"per_page"):void 0,r=n?tr(n,"page"):void 0,o=e!==void 0?Math.max(1,Math.floor(e)):Math.min(100,Math.max(1,i??15)),s=Math.max(1,Math.floor(t??r??1));return{perPage:o,page:s}}function ir(e,t){let n=or(),i=n?al(n,"cursor"):void 0,r=n?tr(n,"per_page"):void 0,o=e!==void 0?Math.max(1,Math.floor(e)):Math.min(100,Math.max(1,r??15)),a=sl(t!==void 0?t:i??null);return{perPage:o,cursor:a}}function sl(e){if(e===null||e===void 0)return null;if(Array.isArray(e))return e;if(typeof e==="string"&&e.startsWith("["))try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e}function rr(e){let t=or();if(!t)return e;let n=(()=>{try{return new URL(t.url)}catch{return null}})();if(!n)return e;let i=n.pathname;if(e.path=i,"next_cursor"in e)return e.next_page_url=e.next_cursor!==null?Y(n,{cursor:e.next_cursor}):null,e.prev_page_url=e.prev_cursor!==null?Y(n,{cursor:e.prev_cursor}):null,e;let r=e.current_page;if(e.prev_page_url=r>1?Y(n,{page:r-1}):null,"total"in e){let o=e.last_page;e.next_page_url=r<o?Y(n,{page:r+1}):null,e.first_page_url=Y(n,{page:1}),e.last_page_url=Y(n,{page:o})}else e.next_page_url=e.has_more_pages?Y(n,{page:r+1}):null;return e}function Y(e,t){let n=new URL(e.toString());for(let[i,r]of Object.entries(t))n.searchParams.set(i,String(r));return`${n.pathname}${n.search}`}var ie;function or(){if(ie===null)return;if(ie===void 0)try{let t=T("@stacksjs/router");if(typeof t.getCurrentRequest==="function")ie=t.getCurrentRequest;else{ie=null;return}}catch{ie=null;return}return ie()}function tr(e,t){let n=al(e,t);if(n===void 0)return;let i=Number(n);return Number.isFinite(i)?i:void 0}function al(e,t){let n=e.query?.[t];if(n===void 0)return;return Array.isArray(n)?n[0]:n}import{db as yu}from"@stacksjs/database";function hc(e){let t=yu;return{async createStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.createStripeCustomer(n,i)},async updateStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.updateStripeCustomer(n,i)},async deleteStripeUser(n){let{manageCustomer:i}=await import("@stacksjs/payments");return await i.deleteStripeUser(n)},async createOrGetStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.createOrGetStripeUser(n,i)},async retrieveStripeUser(n){let{manageCustomer:i}=await import("@stacksjs/payments");return await i.retrieveStripeUser(n)},async defaultPaymentMethod(n){let{managePaymentMethod:i}=await import("@stacksjs/payments");return await i.retrieveDefaultPaymentMethod(n)},async setDefaultPaymentMethod(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.setDefaultPaymentMethod(n,i)},async addPaymentMethod(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.addPaymentMethod(n,i)},async paymentMethods(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.listPaymentMethods(n,i)},async newSubscription(n,i,r,o={}){let{manageSubscription:s}=await import("@stacksjs/payments"),a=await s.create(n,i,r,o),l=a.latest_invoice?.payment_intent;return{subscription:a,paymentIntent:l}},async updateSubscription(n,i,r,o={}){let{manageSubscription:s}=await import("@stacksjs/payments"),a=await s.update(n,i,r,o),l=a.latest_invoice?.payment_intent;return{subscription:a,paymentIntent:l}},async cancelSubscription(n,i,r={}){let{manageSubscription:o}=await import("@stacksjs/payments");return{subscription:await o.cancel(i,r)}},async activeSubscription(n){let{manageSubscription:i}=await import("@stacksjs/payments"),r=await t.selectFrom("subscriptions").where("user_id","=",n.id).where("provider_status","=","active").selectAll().executeTakeFirst();if(r){let o=await i.retrieve(n,r.provider_id||"");return{subscription:r,providerSubscription:o}}return},async checkout(n,i,r={}){let{manageCheckout:o,manageCustomer:s}=await import("@stacksjs/payments"),a={};if(r.enableTax)a.automatic_tax={enabled:!0},delete r.enableTax;if(r.allowPromotions)a.allow_promotion_codes=!0,delete r.allowPromotions;let u={...{mode:"payment",customer:(await s.createOrGetStripeUser(n,{})).id,line_items:i.map((m)=>({price:m.priceId,quantity:m.quantity||1}))},...a,...r};return await o.create(n,u)},async createSetupIntent(n,i={}){let{manageSetupIntent:r}=await import("@stacksjs/payments");return await r.create(n,i)},async subscriptionHistory(n){let{manageInvoice:i}=await import("@stacksjs/payments");return await i.list(n)},async transactionHistory(n){let{manageTransaction:i}=await import("@stacksjs/payments");return await i.list(n)},async connectAccount(n,i={}){let r=i.accountColumn||"stripe_account_id",o=(n._attributes??n)[r];if(!o)return null;let s=await ti();try{return await s.accounts.retrieve(o)}catch{return null}},async createConnectAccount(n,i={}){let r=i.accountColumn||"stripe_account_id",o=n._attributes??n,s=o[r],a=await ti();if(!s){let{stacksIdempotencyKey:c}=await import("@stacksjs/payments"),l=i.modelTable||e,u=await a.accounts.create({type:i.type??"express",email:i.email??o.email,country:i.country??"US",capabilities:i.capabilities??{card_payments:{requested:!0},transfers:{requested:!0}}},{idempotencyKey:c("connect.account.create",l,o.id)});return s=u.id,await t.updateTable(l).set({[r]:s}).where("id","=",Number(o.id)).execute(),u}return await a.accounts.retrieve(s)},async connectOnboardLink(n,i){let r=i.accountColumn||"stripe_account_id",s=(n._attributes??n)[r];if(!s)throw Error("connectOnboardLink: model has no Stripe Connect account; call createConnectAccount first");return{url:(await(await ti()).accountLinks.create({account:s,refresh_url:i.refreshUrl,return_url:i.returnUrl,type:i.type??"account_onboarding"})).url,accountId:s}},async syncConnectStatus(n,i={}){let r=i.accountColumn||"stripe_account_id",o=i.chargesColumn||"charges_enabled",s=i.payoutsColumn||"payouts_enabled",a=n._attributes??n,c=a[r];if(!c)return{chargesEnabled:!1,payoutsEnabled:!1};let u=await(await ti()).accounts.retrieve(c),m=!!u.charges_enabled,p=!!u.payouts_enabled,_=i.modelTable||e;return await t.updateTable(_).set({[o]:m,[s]:p}).where("id","=",Number(a.id)).execute(),{chargesEnabled:m,payoutsEnabled:p}},async chargeWithSplit(n,i){let r=await ti(),o=i.accountColumn||"stripe_account_id",s=n._attributes??n,a=i.connectAccountId||s[o],c={amount:i.amountCents,currency:i.currency||"usd",automatic_payment_methods:{enabled:!0},metadata:i.metadata};if(a){if(c.transfer_data={destination:a},i.platformFeeCents)c.application_fee_amount=i.platformFeeCents}let{freshIdempotencyKey:l}=await import("@stacksjs/payments");return await r.paymentIntents.create(c,{idempotencyKey:l("payment_intent.create",s.id,i.amountCents)})}}}async function ti(){let e=globalThis.process?.env?.STRIPE_SECRET_KEY;if(!e)throw Error("Stripe Connect: STRIPE_SECRET_KEY not configured");return new(await Promise.resolve().then(() => (gc(),bc))).default(e,{apiVersion:"2026-06-24.dahlia"})}function yc(){return{async generateTwoFactorForModel(e){let{generateTwoFactorSecret:t}=await import("@stacksjs/auth"),n=t();await e.update({two_factor_secret:n})},async verifyTwoFactorCode(e,t){let n=e.get("two_factor_secret");if(typeof n!=="string")return!1;let{verifyTwoFactorCode:i,RateLimiter:r}=await import("@stacksjs/auth"),o=String(e.id??e.get?.("id")??e.get?.("email")??n),s=`2fa:${o}`;if(await r.isRateLimited(s)){let{HttpError:c}=await import("@stacksjs/error-handling");throw new c(429,"Too many verification attempts. Please try again later.")}if(!await i(t,n))return await r.recordFailedAttempt(s),!1;try{let{cache:c}=await import("@stacksjs/cache"),l=`2fa:used:${o}:${t}`;if(await c.has(l))return await r.recordFailedAttempt(s),!1;await c.set(l,"1",90)}catch{}return await r.resetAttempts(s),!0}}}import{sqlDateTime as Ru}from"@stacksjs/database";import{log as le}from"@stacksjs/logging";var Pi="deleted_at";function Rc(e,t="id"){return{async softDelete(n){let i=Ru(),r=e.where(t,n);if(typeof r?.update==="function")return await r.update({[Pi]:i}),!0;return!1},async restore(n){let i=e.where(t,n);if(typeof i?.update==="function")return await i.update({[Pi]:null}),!0;return!1},async forceDelete(n){let i=e.where(t,n);if(typeof i?.delete==="function")return await i.delete(),!0;return!1},withTrashed(){return typeof e.query==="function"?e.query():e},onlyTrashed(){let n=typeof e.query==="function"?e.query():e;if(typeof n?.whereNotNull==="function")return n.whereNotNull(Pi);return n?.where?.(Pi,"!=",null)??n}}}function Tc(e){if(e===!0||e==null)return{};if(typeof e==="object"&&!Array.isArray(e)){let t=e;if(Array.isArray(t.cascade)){let n=t.cascade.filter((i)=>typeof i==="string");return n.length?{cascade:n}:{}}return{}}return{}}function Tu(e,t){let n=e.hasMany??[],i=e.hasOne??[],r=n.some((u)=>Ia(u,t,!0)),o=i.some((u)=>Ia(u,t,!1));if(!r&&!o)return le.warn(`[orm] soft-delete cascade: '${t}' is not a declared hasMany/hasOne relation - skipping`),null;let a=(r?n:i).find((u)=>Ia(u,t,r))??null;if(!a)return null;let l=globalThis[a];if(!l)return le.warn(`[orm] soft-delete cascade: model '${a}' is not yet on globalThis - skipping cascade for '${t}'`),null;return{className:a,model:l}}function Ia(e,t,n){let i=e.toLowerCase();if(t===i)return!0;if(n&&t===`${i}s`)return!0;if(n&&i.endsWith("y")&&t===`${i.slice(0,-1)}ies`)return!0;return!1}async function wu(e,t,n,i,r){try{let o=n.where;if(typeof o!=="function"){le.warn(`[orm] cascade ${r}: child model has no .where()`);return}if(r==="softDelete"){let s=n.softDelete;if(typeof s==="function"){let c=o.call(n,i,t),l=typeof c?.get==="function"?await c.get():Array.isArray(c)?c:[],u=n.primaryKey||"id";for(let m of l){let p=m?.[u];if(p!=null)await s.call(n,p)}return}let a=o.call(n,i,t);if(typeof a?.delete==="function"){le.debug(`[orm] cascade soft-delete: child has no softDeletes trait, hard-deleting from ${String(n.table??"?")}`),await a.delete();return}}else{let s=n.restore;if(typeof s!=="function"){le.debug("[orm] cascade restore: child has no restore() - nothing to do");return}let a=n.withTrashed,l=(typeof a==="function"?a.call(n):n).where?.(i,t),u=typeof l?.get==="function"?await l.get():[],m=n.primaryKey||"id";for(let p of u){let _=p?.[m];if(_!=null)await s.call(n,_)}}}catch(o){if(le.warn(`[orm] soft-delete cascade ${r} on ${e}#${String(t)} failed`,{error:o}),process.env.STACKS_ORM_CASCADE_SWALLOW!=="true")throw o}}async function ni(e,t,n,i){let r=t.cascade;if(!r||r.length===0)return;let o=`${e.name.toLowerCase()}_id`;for(let s of r){let a=Tu(e,s);if(!a)continue;await wu(a.className,n,a.model,o,i)}}var qc=new Ec;function te(){return qc.getStore()?.suppressed===!0}function ee(e){return Promise.resolve(qc.run({suppressed:!0},e))}var Oc=new Ec;function xu(){return Oc.getStore()?.suppressed===!0}function Cu(e){return Promise.resolve(Oc.run({suppressed:!0},e))}var Fa=Symbol.for("stacks.orm.modelDefinition");class Ac extends Error{status=422;errors;constructor(e,t){let n=Object.keys(t).join(", ");super(`${e} validation failed: ${n}`);this.name="ModelValidationError",this.errors=t}}var wc=new Set;function ju(e,t){let n=typeof e==="string"?e.slice(0,80):String(e),i=`${typeof e}:${n}`;if(wc.has(i))return;wc.add(i);let r=t instanceof Error?t.message:String(t);console.error(`[orm] JSON cast failed to parse value (returning null): ${r} - value preview: ${JSON.stringify(n)}`)}var Pu={string:{get:(e)=>e!=null?String(e):null,set:(e)=>e!=null?String(e):null},number:{get:(e)=>e!=null?Number(e):null,set:(e)=>e!=null?Number(e):null},integer:{get:(e)=>e!=null?Math.trunc(Number(e)):null,set:(e)=>e!=null?Math.trunc(Number(e)):null},float:{get:(e)=>e!=null?Number.parseFloat(String(e)):null,set:(e)=>e!=null?Number.parseFloat(String(e)):null},boolean:{get:(e)=>e===1||e==="1"||e===!0||e==="true",set:(e)=>e===!0||e===1||e==="1"||e==="true"?1:0},json:{get:(e)=>{if(e==null)return null;if(typeof e==="string")try{return JSON.parse(e)}catch(t){return ju(e,t),null}return e},set:(e)=>{if(e==null)return null;return typeof e==="string"?e:JSON.stringify(e)}},datetime:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString():e},date:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString().split("T")[0]:e},array:{get:(e)=>{if(e==null)return[];if(Array.isArray(e))return e;if(typeof e==="string")try{return JSON.parse(e)}catch{return[]}return[]},set:(e)=>{if(e==null)return null;return Array.isArray(e)?JSON.stringify(e):e}}};function Ic(e){return typeof e==="string"?Pu[e]:e}function vc(e,t,n){if(!e||typeof e!=="object")return e;let i={...e};for(let[r,o]of Object.entries(t))if(r in i){let s=Ic(o);i[r]=s[n](i[r])}return i}var Ei=new Set(["_attributes","_original","_definition","_hasSaved","_relations"]),Sc=Symbol.for("stacks.modelInstanceProxy"),Eu={tags:{bag:"_taggable",mode:"id"},tagCount:{bag:"_taggable",mode:"id"},addTag:{bag:"_taggable",mode:"id"},activeTags:{bag:"_taggable",mode:"id"},inactiveTags:{bag:"_taggable",mode:"id"},removeTag:{bag:"_taggable",mode:"id"},categories:{bag:"_categorizable",mode:"id"},categoryCount:{bag:"_categorizable",mode:"id"},addCategory:{bag:"_categorizable",mode:"id"},activeCategories:{bag:"_categorizable",mode:"id"},inactiveCategories:{bag:"_categorizable",mode:"id"},removeCategory:{bag:"_categorizable",mode:"id"},comments:{bag:"_commentable",mode:"id"},commentCount:{bag:"_commentable",mode:"id"},addComment:{bag:"_commentable",mode:"id"},approvedComments:{bag:"_commentable",mode:"id"},pendingComments:{bag:"_commentable",mode:"id"},rejectedComments:{bag:"_commentable",mode:"id"},likes:{bag:"_likeable",mode:"id"},likeCount:{bag:"_likeable",mode:"id"},like:{bag:"_likeable",mode:"id"},unlike:{bag:"_likeable",mode:"id"},isLiked:{bag:"_likeable",mode:"id"},createStripeUser:{bag:"_billable",mode:"model"},updateStripeUser:{bag:"_billable",mode:"model"},deleteStripeUser:{bag:"_billable",mode:"model"},createOrGetStripeUser:{bag:"_billable",mode:"model"},retrieveStripeUser:{bag:"_billable",mode:"model"},defaultPaymentMethod:{bag:"_billable",mode:"model"},setDefaultPaymentMethod:{bag:"_billable",mode:"model"},addPaymentMethod:{bag:"_billable",mode:"model"},paymentMethods:{bag:"_billable",mode:"model"},newSubscription:{bag:"_billable",mode:"model"},updateSubscription:{bag:"_billable",mode:"model"},cancelSubscription:{bag:"_billable",mode:"model"},activeSubscription:{bag:"_billable",mode:"model"},checkout:{bag:"_billable",mode:"model"},createSetupIntent:{bag:"_billable",mode:"model"},subscriptionHistory:{bag:"_billable",mode:"model"},transactionHistory:{bag:"_billable",mode:"model"},connectAccount:{bag:"_billable",mode:"model"},createConnectAccount:{bag:"_billable",mode:"model"},connectOnboardLink:{bag:"_billable",mode:"model"},syncConnectStatus:{bag:"_billable",mode:"model"},chargeWithSplit:{bag:"_billable",mode:"model"},generateTwoFactorForModel:{bag:"_twoFactor",mode:"model"},verifyTwoFactorCode:{bag:"_twoFactor",mode:"model"}};function qu(e,t){if(!e||!t)return null;let n=t.split("."),i=e;for(let r of n){if(i==null||typeof i!=="object")return null;let o=i;if("_attributes"in o&&o._attributes&&typeof o._attributes==="object"){let s=o._attributes;if(r in s){i=s[r];continue}}if(r in o){i=o[r];continue}return null}return i??null}function D(e,t){if(!e||typeof e!=="object")return e;if(e[Sc])return e;let n=e._attributes;if(!n||typeof n!=="object")return e;if(t&&Object.keys(t).length>0){for(let[i,r]of Object.entries(t))if(Object.prototype.hasOwnProperty.call(n,i))n[i]=Ic(r).get(n[i])}return new Proxy(e,{get(i,r,o){if(r===Sc)return!0;if(r==="saveAsync")return async function(){let a=i._definition,c=a?.set;if(c&&typeof i.isDirty==="function"){for(let[u,m]of Object.entries(c)){if(typeof m!=="function")continue;if(!i.isDirty(u))continue;let p=m(i._attributes),_=p&&typeof p.then==="function"?await p:p;i._attributes[u]=_}let l=a.set;a.set={};try{return i.save()}finally{a.set=l}}return i.save()};if(r==="save")return function(){let a=i._definition,c=a?.set;if(c&&Object.keys(c).length>0&&typeof i.isDirty==="function"){for(let[u,m]of Object.entries(c)){if(typeof m!=="function")continue;if(!i.isDirty(u))continue;let p=m(i._attributes);if(p&&typeof p.then==="function")throw Error(`Setter for "${u}" returned a Promise - use \`saveAsync()\` instead of \`save()\` when a model has async setters.`);i._attributes[u]=p}let l=a.set;a.set={};try{return i.save()}finally{a.set=l}}return i.save()};if(r==="updateAsync")return async function(a){if(a&&typeof a==="object"&&!Array.isArray(a))for(let[c,l]of Object.entries(a))o[c]=l;return o.saveAsync()};if(r==="saveQuietly")return function(){return ee(()=>i.save())};if(r==="saveAsyncQuietly")return function(){return ee(()=>o.saveAsync())};if(r==="updateQuietly")return function(a){return ee(()=>i.update(a))};if(r==="updateAsyncQuietly")return function(a){return ee(()=>o.updateAsync(a))};if(r==="deleteQuietly")return function(){return ee(()=>i.delete())};if(r==="toSearchableObject")return function(){let l=i._definition?.traits?.useSearch;if(!l)return null;let u=i._attributes;if(!u)return null;if(l===!0){let g={...u};if(u.id!=null)g.id=String(u.id);return g}let m={},p=l.displayable?.length?l.displayable:[...l.searchable??[],...l.filterable??[],...l.sortable??[],"id"],_=l.denormalize??{},k=i._relations;for(let g of p){let y=H(g),R=u[y]??u[g];if(R!==void 0){m[y]=R;continue}let v=_[g]??_[y];if(v){m[y]=qu(k,v);continue}m[y]=void 0}if(u.id!=null)m.id=String(u.id);return m};if(typeof r==="string"&&!Ei.has(r)){let a=i._attributes;if(a&&Object.prototype.hasOwnProperty.call(a,r))return a[r];let c=i._relations;if(c&&Object.prototype.hasOwnProperty.call(c,r)){let u=c[r];if(Array.isArray(u))return u.map((m)=>D(m,t));return D(u,t)}let l=Eu[r];if(l){let p=i._definition?.__traitMethods?.[l.bag]?.[r];if(typeof p==="function")return l.mode==="model"?(..._)=>p(o,..._):(..._)=>p(i.id,..._)}if(a){let u=H(r);if(u!==r&&Object.prototype.hasOwnProperty.call(a,u))return a[u]}}let s=Reflect.get(i,r,i);return typeof s==="function"?s.bind(i):s},set(i,r,o,s){if(typeof r==="string"&&!Ei.has(r)){let{_attributes:a,set:c}=i;if(a&&Object.prototype.hasOwnProperty.call(a,r)){if(typeof c==="function")c.call(i,r,o);else a[r]=o;return!0}if(a){let l=H(r);if(l!==r&&Object.prototype.hasOwnProperty.call(a,l)){if(typeof c==="function")c.call(i,l,o);else a[l]=o;return!0}}if(a&&!(r in i)){if(typeof c==="function")c.call(i,r,o);else a[r]=o;return!0}}return Reflect.set(i,r,o,s)},has(i,r){if(typeof r==="string"&&!Ei.has(r)){let o=i._attributes;if(o&&Object.prototype.hasOwnProperty.call(o,r))return!0;let s=i._relations;if(s&&Object.prototype.hasOwnProperty.call(s,r))return!0;if(o){let a=H(r);if(a!==r&&Object.prototype.hasOwnProperty.call(o,a))return!0}}return Reflect.has(i,r)},deleteProperty(i,r){if(typeof r==="string"&&!Ei.has(r)){let o=i._attributes;if(o&&Object.prototype.hasOwnProperty.call(o,r))return delete o[r],!0}return Reflect.deleteProperty(i,r)},ownKeys(i){let r=i._attributes;return r?Object.keys(r):[]},getOwnPropertyDescriptor(i,r){if(typeof r==="string"){let o=i._attributes;if(o&&Object.prototype.hasOwnProperty.call(o,r))return{configurable:!0,enumerable:!0,value:o[r],writable:!0}}return Object.getOwnPropertyDescriptor(i,r)}})}var Ou=new Set(["get","first","last","firstOrFail","find","findOrFail","all","paginate","simplePaginate","cursorPaginate"]),Au={paginate:Yi,simplePaginate:Zi,cursorPaginate:er},xc=Symbol.for("stacks.queryBuilderProxy");function $c(e,t){if(!e||typeof e!=="object")return e;if(e[xc])return e;return new Proxy(e,{get(n,i,r){if(i===xc)return!0;let o=Reflect.get(n,i,r);if(typeof o!=="function")return o;return function(...s){let a=s,c=String(i);if(c==="paginate"||c==="simplePaginate"){let{perPage:m,page:p}=nr(s[0],s[1]);a=[m,p]}else if(c==="cursorPaginate"){let{perPage:m,cursor:p}=ir(s[0],s[1]);a=[m,p,s[2],s[3]]}let l=o.apply(n,a),u=(m)=>{if(Ou.has(c)){if(Array.isArray(m))return m.map((_)=>D(_,t));let p=Au[c];if(p&&m&&Array.isArray(m.data)){let _=m.data.map((g)=>D(g,t)),k=p({...m,data:_});return rr(k)}if(m&&Array.isArray(m.data))return{...m,data:m.data.map((_)=>D(_,t))};return D(m,t)}if(m&&typeof m==="object"&&typeof m.get==="function")return $c(m,t);return m};if(l&&typeof l.then==="function")return l.then(u);return u(l)}}})}function Iu(e,t){let n=["find","first","last","all","firstOrFail","findOrFail","findMany"];for(let o of n){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a),l=(u)=>Array.isArray(u)?u.map((m)=>D(m,t)):D(u,t);if(c&&typeof c.then==="function")return c.then(l);return l(c)}}let i=["create","firstOrCreate","updateOrCreate","make"];for(let o of i){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a),l=(u)=>Array.isArray(u)?u.map((m)=>D(m,t)):D(u,t);if(c&&typeof c.then==="function")return c.then(l);return l(c)}}let r=["query","where","orWhere","whereIn","whereNotIn","whereNull","whereNotNull","whereLike","whereBetween","whereNotBetween","orderBy","orderByDesc","select","with","limit","take","skip","latest","oldest"];for(let o of r){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a);return $c(c,t)}}}class Uc extends Error{model;id;constructor(e,t){super(t!=null?`[ORM] ${e} not found for id=${String(t)}`:`[ORM] No matching ${e} row`);this.name="ModelNotFoundError",this.model=e,this.id=t}}class Ua extends Error{model;attribute;reason;constructor(e,t,n){let i=n==="guarded"?`'${t}' is marked guarded`:`'${t}' is not in the fillable allowlist`;super(`[ORM] Mass assignment to ${e} forbidden: ${i}. Use ${e}.forceCreate(...) / .forceUpdate(...) to bypass.`);this.name="MassAssignmentException",this.model=e,this.attribute=t,this.reason=n}}var $u=new Set(["id","created_at","updated_at","deleted_at","uuid"]);function ii(e,t,n={}){if(n.force)return t;if(!t||typeof t!=="object"||Array.isArray(t))return t;let i=e.attributes;if(!i)return t;let r=new Set,o=new Set,s=new Set;for(let[c,l]of Object.entries(i)){let u=H(c);if(r.add(u),l?.fillable===!0)o.add(u);if(l?.guarded===!0)s.add(u)}let a=o.size>0?o:r;for(let c of Object.keys(t)){let l=H(c);if($u.has(l))continue;if(s.has(l))throw new Ua(e.name,c,"guarded");if(l.endsWith("_id"))continue;if(!a.has(l))throw new Ua(e.name,c,"not-fillable")}return t}async function Ma(e,t){let n=e.set;if(!n||typeof n!=="object")return t;let i={...t};for(let[r,o]of Object.entries(n)){if(typeof o!=="function"||!(r in i))continue;try{i[r]=await o(i)}catch(s){A.error(`[orm] ${e.name}.set.${r} threw - skipping setter`,s)}}return i}function Uu(e,t){let n=t.primaryKey||"id",i=e.create;function r(l){let u=e.where;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} needs a working where(): the underlying query builder did not expose one`);return u}function o(l){let u=e.find;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} needs a working find(): the underlying query builder did not expose one`);return u}function s(l){let u=e.create;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} cannot create: the underlying query builder did not expose create()`);return u}if(typeof e.update!=="function")e.update=async function(l,u){if(l==null)throw Error(`[ORM] ${t.name}.update requires an id as the first argument`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.update requires a data object as the second argument`);if(Object.keys(u).length===0){A.debug(`[orm] ${t.name}.update called with empty data - short-circuiting and returning current row`);let _=e.find;return typeof _==="function"?await _.call(e,l):null}ii(t,u);let m=await Ma(t,u);await r("update").call(e,n,l).update(m);let p=e.find;return typeof p==="function"?await p.call(e,l):null};if(typeof e.forceUpdate!=="function")e.forceUpdate=async function(l,u){if(l==null)throw Error(`[ORM] ${t.name}.forceUpdate requires an id as the first argument`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.forceUpdate requires a data object as the second argument`);let m=await Ma(t,u);await r("forceUpdate").call(e,n,l).update(m);let p=e.find;return typeof p==="function"?await p.call(e,l):null};if(typeof e.forceCreate!=="function")e.forceCreate=async function(l){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.forceCreate requires a data object`);let u=e.make;if(typeof u==="function"){let m=await u.call(e);if(m&&typeof m.forceFill==="function"&&typeof m.save==="function")return m.forceFill(l),await m.save()??m}if(typeof i!=="function")throw Error(`[ORM] ${t.name}.forceCreate cannot create: the underlying query builder did not expose create()`);return await i.call(e,l)};if(typeof e.delete!=="function")e.delete=async function(l){if(l==null)throw Error(`[ORM] ${t.name}.delete requires an id as the first argument`);if(!await o("delete").call(e,l))return!1;return await r("delete").call(e,n,l).delete(),!0};if(typeof e.findOrFail!=="function")e.findOrFail=async function(l){let u=await o("findOrFail").call(e,l);if(u==null)throw new Uc(t.name,l);return u};if(typeof e.exists!=="function")e.exists=async function(l){if(l==null)return!1;let u=r("exists").call(e,n,l);if(typeof u.count==="function"){let p=await u.count();return Number(p)>0}let m=e.find;return typeof m==="function"?await m.call(e,l)!=null:!1};if(typeof e.firstOrCreate!=="function")e.firstOrCreate=async function(l,u={}){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.firstOrCreate requires a where-attrs object`);let m=r("firstOrCreate").call(e,l),p=typeof m.first==="function"?await m.first():await m;if(p)return p;let _={...l,...u};return ii(t,_),await s("firstOrCreate").call(e,_)};if(typeof e.updateOrCreate!=="function")e.updateOrCreate=async function(l,u){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.updateOrCreate requires a where-attrs object`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.updateOrCreate requires a values object`);let m=r("updateOrCreate").call(e,l),p=typeof m.first==="function"?await m.first():await m;if(p){ii(t,u);let k=p[n];await r("updateOrCreate").call(e,n,k).update(u);let g=e.find;return typeof g==="function"?await g.call(e,k):{...p,...u}}let _={...l,...u};return ii(t,_),await s("updateOrCreate").call(e,_)};if(typeof e.count!=="function")e.count=async function(){let l=e;if(typeof l.query==="function"){let p=l.query();if(typeof p?.count==="function"){let _=await p.count();return Number(_)||0}}let{all:u,get:m}=e;if(typeof u==="function")return(await u.call(e)||[]).length;if(typeof m==="function")return(await m.call(e)||[]).length;return 0};if(typeof e.pluck!=="function")e.pluck=async function(l){if(!l||typeof l!=="string")throw Error(`[ORM] ${t.name}.pluck requires a column name`);let u=e.all;return((typeof u==="function"?await u.call(e):[])||[]).map((p)=>p?.[l])};if(typeof e.whereIn!=="function")e.whereIn=async function(l,u){if(!l||typeof l!=="string")throw Error(`[ORM] ${t.name}.whereIn requires a column name`);if(!Array.isArray(u))throw Error(`[ORM] ${t.name}.whereIn requires an array of values`);if(u.length===0)return[];let m=e.where;if(typeof m!=="function")return[];let p=m.call(e,l,"in",u);if(p&&typeof p.get==="function")return await p.get();return await p};let a=[["latest","desc"],["oldest","asc"]];for(let[l,u]of a)if(typeof e[l]!=="function")e[l]=async function(m="created_at"){let p=e,_=typeof p.query==="function"?p.query():p;if(typeof _?.orderBy==="function"){let R=_.orderBy(m,u);if(typeof R.first==="function")return await R.first();if(typeof R.get==="function")return(await R.get())?.[0]??null}let k=e.all;if(typeof k!=="function")return null;return[...await k.call(e)||[]].sort((R,v)=>{let x=R?.[m],P=v?.[m];if(x===P)return 0;return(x>P?1:-1)*(u==="desc"?-1:1)})[0]??null};let c=Fc(t.traits?.useSearch,t);if(c){let l=c.index??t.table??H(`${t.name}s`);if(typeof e.search!=="function")e.search=function(u,m){return Nu(e,l,u,m,c.searchable)};if(typeof e.makeAllSearchable!=="function")e.makeAllSearchable=async function(u=500){let m=e.all;if(typeof m!=="function")throw Error(`[ORM] ${t.name}.makeAllSearchable cannot run: the underlying query builder did not expose all()`);let{useSearchEngine:p}=await import("@stacksjs/search-engine"),_=p(),k=0,g=e.query;if(typeof g==="function")try{let v=g.call(e);if(v&&typeof v.chunk==="function")return await v.chunk(u,async(x)=>{let P=await Da(x,c);if(P.length>0)await _.addDocuments(l,P);k+=P.length}),k}catch{}let y=await m.call(e)||[],R=await Da(y,c);if(R.length>0)await _.addDocuments(l,R);return R.length};if(typeof e.removeAllFromSearch!=="function")e.removeAllFromSearch=async function(){let{useSearchEngine:u}=await import("@stacksjs/search-engine"),m=u();if(typeof m.deleteAllDocuments==="function"){await m.deleteAllDocuments(l);return}let p=e.all,_=typeof p==="function"?await p.call(e)||[]:[],k=u();for(let g of _){let y=g?.id??g?._attributes?.id;if(y!=null)await k.deleteDocument(l,Number(y))}}}}async function Da(e,t){if(e.length===0)return[];if(typeof t.shapeMany==="function"){let i=await t.shapeMany(e);if(!Array.isArray(i)||i.length!==e.length)throw TypeError(`[orm/search] shapeMany returned ${Array.isArray(i)?i.length:typeof i} documents for ${e.length} rows. It must return one document per row, in order, or documents are indexed under the wrong ids.`);return i.filter(Boolean)}return(await Promise.all(e.map((i)=>Fu(i,t)))).filter(Boolean)}function Mu(e){let t=new Set,n=e.attributes??{};for(let[i,r]of Object.entries(n))if(r?.hidden)t.add(i);return t}function Du(e,t){if(!e||t.size===0)return e;let n={};for(let[i,r]of Object.entries(e))if(!t.has(i))n[i]=r;return n}async function Fu(e,t){if(typeof t.shape==="function")try{return await t.shape(e)}catch{return}let n=e?.toSearchableObject?.();if(n!==void 0)return n;return Du(e?._attributes??(typeof e?.toJSON==="function"?e.toJSON():null),t.hidden??new Set)}function Nu(e,t,n,i,r){let o=r&&r.length>0?{query_by:[...r].join(",")}:{},s={q:n,...o,...i??{}},a={with(c){return s={...s,...c},a},where(c){return s={...s,filter:c},a},async get(){let{useSearchEngine:c}=await import("@stacksjs/search-engine");return(await c().search(t,s))?.hits??[]},async paginate(c,l=1){let{useSearchEngine:u}=await import("@stacksjs/search-engine"),p=await u().search(t,{...s,limit:c,offset:(l-1)*c});return{hits:p.hits??[],total:Number(p.estimatedTotalHits??p.nbHits??p.total??0),page:l,perPage:c}},async raw(){let{useSearchEngine:c}=await import("@stacksjs/search-engine");return await c().search(t,s)}};return a}function Mc(e){let t=H(e);return t===e?[e]:[e,t]}async function $a(e,t){if(!e||typeof e!=="object")return;let n=e._attributes??e;for(let i of t)for(let r of Mc(i)){if(!(r in n))continue;let o=n[r];if(!ue(o))continue;n[r]=await $i(o)}}function Gu(e,t){if(t.length===0)return;let n=async(a)=>{if(Array.isArray(a)){for(let c of a)await $a(c,t);return a}if(a&&typeof a==="object"&&Array.isArray(a.data)){for(let c of a.data)await $a(c,t);return a}if(a)await $a(a,t);return a},i=["find","first","last","all","firstOrFail","findOrFail","findMany"];for(let a of i){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(...l){let u=await c.apply(this,l);return await n(u)}}let r=["create","firstOrCreate","updateOrCreate","make"];for(let a of r){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(...l){let u=await c.apply(this,l);return await n(u)}}for(let a of["update","forceUpdate"]){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(l,u){let m=await c.call(this,l,u);return await n(m)}}let o=["first","firstOrFail","get","all","find","findOrFail","last","paginate","simplePaginate"],s=(a)=>{if(!a||typeof a!=="object")return a;let c=a;if(c.__stacksEncryptedReads)return a;for(let l of o){let u=c[l];if(typeof u!=="function")continue;c[l]=async function(...m){return await n(await u.apply(this,m))}}for(let l of["where","whereIn","whereNull","whereNotNull","orWhere","orderBy","orderByDesc","limit","offset","with"]){let u=c[l];if(typeof u!=="function")continue;c[l]=function(...m){return s(u.apply(this,m))}}return Object.defineProperty(c,"__stacksEncryptedReads",{value:!0,enumerable:!1}),a};for(let a of["where","whereIn","whereNull","whereNotNull","orderBy","orderByDesc","limit","query"]){let c=e[a];if(typeof c!=="function")continue;e[a]=function(...l){return s(c.apply(this,l))}}}function Bu(e,t){if(t.length===0)return;let n=async(r)=>{if(!r||typeof r!=="object"||Array.isArray(r))return r;let o={...r};for(let s of t)for(let a of Mc(s))if(a in o)o[a]=await Ii(o[a]);return o},i=["create","firstOrCreate","updateOrCreate","forceCreate"];for(let r of i){let o=e[r];if(typeof o!=="function")continue;e[r]=async function(...s){if(s[0]=await n(s[0]),s[1])s[1]=await n(s[1]);return await o.apply(this,s)}}for(let r of["update","forceUpdate"]){let o=e[r];if(typeof o!=="function")continue;e[r]=async function(s,a){let c=await n(a);return await o.call(this,s,c)}}}function Lu(e,t){let n=e.create;if(typeof n==="function")e.create=async function(i,...r){ii(t,i);let o=await Ma(t,i);return await n.call(this,o,...r)};for(let i of["firstOrCreate","updateOrCreate"]){let r=e[i];if(typeof r!=="function")continue}}function Ku(e,t){let n=String(t?.name??e.name??"Model"),i=(s,a)=>{if(xu())return;if(!s||typeof s!=="object"||Array.isArray(s))return;let c=Ya(s,t,a);if(!c.valid)throw new Ac(n,c.errors)},r=e.create;if(typeof r==="function")e.create=async function(s,...a){return i(s,"creating"),await r.call(this,s,...a)};let o=e.update;if(typeof o==="function")e.update=async function(s,a,...c){return i(a,"updating"),await o.call(this,s,a,...c)}}function Hu(e,t){let n=["create","firstOrCreate","updateOrCreate"];for(let r of n){let o=e[r];if(typeof o==="function")e[r]=async function(...s){if(A.debug(`[orm] ${r.charAt(0).toUpperCase()+r.slice(1)} ${String(e.name||"unknown")}`,s[0]),s[0]&&typeof s[0]==="object"&&!Array.isArray(s[0]))s[0]=vc(s[0],t,"set");return await o.apply(this,s)}}let i=e.update;if(typeof i==="function")e.update=async function(r,o){let s=o&&typeof o==="object"&&!Array.isArray(o)?vc(o,t,"set"):o;return await i.call(this,r,s)}}function Dc(e){A.debug(`[orm] Defining model: ${e.name} (table: ${e.table})`);let t=Vu(e),n=Wu(e),i=zu(t,n),r=Qu(e);e.__traitMethods=r;let o=i?{...e,hooks:{...e.hooks,...i}}:e,a=vu(o);if(Iu(a,e.casts),Uu(a,o),Lu(a,o),e.casts&&Object.keys(e.casts).length>0)Hu(a,e.casts);let c=Ui(e);if(c.length>0)Bu(a,c),Gu(a,c);let l=e.traits?.useSoftDeletes;if(l)Ju(a,o,l);let u=e.traits?.useAudit;if(u){let p=za(u);Wa(a,e.name,e.primaryKey||"id",p)}Ku(a,o),a.withoutValidation=function(p){return Cu(p)},a.withoutEvents=function(p){return ee(p)};for(let p of["create","update","firstOrCreate","updateOrCreate","forceCreate","forceUpdate","delete","forceDelete","softDelete","restore"]){let _=a[p];if(typeof _!=="function")continue;let k=`${p}Quietly`;if(typeof a[k]==="function")continue;a[k]=function(...g){return ee(()=>_.apply(a,g))}}let m=Object.assign(a,r,{...e,getDefinition:()=>e,_isStacksModel:!0});return Su(e.name,m),Object.defineProperty(m,Fa,{value:e,enumerable:!1,configurable:!0}),m}function Vu(e){let t=e.traits?.observe;if(!t)return;let n=e.name.toLowerCase(),i=(p)=>{let _=p?.attributes;if(!_||typeof _!=="object")return p;let k=e.primaryKey||"id",g={..._};if(g[k]===void 0&&p[k]!==void 0)g[k]=p[k];return g},r=async(p,_)=>{if(te())return;try{let{dispatch:k}=await import("@stacksjs/events");await k(p,_)}catch(k){if(k&&typeof k==="object"&&"code"in k&&k.code==="MODULE_NOT_FOUND")return;if(console.error(`[ORM] Event '${p}' handler error:`,k),process.env.STACKS_ORM_EVENT_ERRORS!=="swallow")throw k}},o=e.traits?.broadcastOn,s=e.traits?.broadcastWith,a=typeof o==="function"&&typeof s==="function",c=async(p,_)=>{if(!a)return;if(te())return;try{let k=o(_),g=Array.isArray(k)?k:[k],y=s(_),v=(await import("@stacksjs/realtime").catch(()=>null))?.broadcast;if(typeof v!=="function")return;for(let x of g){if(typeof x!=="string"||x.length===0)continue;await v(x,p,y)}}catch(k){if(k&&typeof k==="object"&&"code"in k&&k.code==="MODULE_NOT_FOUND")return;if(console.error(`[ORM] Broadcast '${p}' handler error:`,k),process.env.STACKS_ORM_BROADCAST_ERRORS==="throw")throw k}},l=async(p,_)=>{if(te())return!0;try{let{dispatchAsync:k}=await import("@stacksjs/events"),g=await k(p,_);if(Array.isArray(g)&&g.some((y)=>y===!1))return!1}catch(k){if(k&&typeof k==="object"&&"code"in k&&k.code==="MODULE_NOT_FOUND")return!0;if(console.error(`[ORM] Before-event '${p}' handler error:`,k),process.env.STACKS_ORM_EVENT_ERRORS!=="swallow")throw k}return!0},u=t===!0?["create","update","delete"]:Array.isArray(t)?t:[],m={};if(u.includes("create"))m.beforeCreate=async(p)=>{if(A.debug(`[orm] Create ${n}`,p),!await l(`${n}:saving`,p))throw Error(`[ORM] ${n}:saving event cancelled the operation`);if(!await l(`${n}:creating`,p))throw Error(`[ORM] ${n}:creating event cancelled the operation`)},m.afterCreate=async(p)=>{let _=i(p);await r(`${n}:created`,_),await r(`${n}:saved`,_),await c(`${n}:created`,p)};if(u.includes("update"))m.beforeUpdate=async(p)=>{if(A.debug(`[orm] Update ${n}#${p?.id??"unknown"}`,p),!await l(`${n}:saving`,p))throw Error(`[ORM] ${n}:saving event cancelled the operation`);if(!await l(`${n}:updating`,p))throw Error(`[ORM] ${n}:updating event cancelled the operation`)},m.afterUpdate=async(p)=>{let _=i(p);await r(`${n}:updated`,_),await r(`${n}:saved`,_),await c(`${n}:updated`,p)};if(u.includes("delete"))m.beforeDelete=async(p)=>{if(A.debug(`[orm] Delete ${n}#${p?.id??"unknown"}`),!await l(`${n}:deleting`,p))throw Error(`[ORM] ${n}:deleting event cancelled the operation`)},m.afterDelete=async(p)=>{await r(`${n}:deleted`,i(p)),await c(`${n}:deleted`,p)};return m}function zu(...e){let t={},n=new Set;for(let i of e){if(!i)continue;for(let r of Object.keys(i))n.add(r)}for(let i of n){let r=e.map((o)=>o?.[i]).filter((o)=>typeof o==="function");if(!r.length)continue;t[i]=async(...o)=>{for(let s of r)await s(...o)}}return Object.keys(t).length?t:void 0}function Fc(e,t){if(!e)return null;let n=e===!0?{}:typeof e==="object"?{...e}:null;if(!n)return null;if(t)n.hidden=Mu(t);return n}function Wu(e){let t=Fc(e.traits?.useSearch,e);if(!t)return;let n=t,i=n.index??e.table??H(`${e.name}s`);async function r(a){if(typeof n.shapeMany==="function")try{let[u]=await Da([a],n);return u}catch(u){A.warn(`[orm/search] shapeMany() threw for ${e.name}: ${u.message}`);return}if(typeof n.shape==="function")try{return await n.shape(a)}catch(u){A.warn(`[orm/search] shape() threw for ${e.name}: ${u.message}`);return}let l=D(a).toSearchableObject?.();if(l!==void 0)return l;return a?._attributes??(typeof a?.toJSON==="function"?a.toJSON():null)}let o=async(a)=>{if(te())return;let c=await r(a);if(!c)return;if(t.queueable){try{let{Jobs:l}=await import("@stacksjs/queue");await l.dispatch("SyncSearchIndex",{index:i,op:"upsert",doc:c})}catch(l){A.warn(`[orm/search] queue dispatch failed for ${e.name}; falling back to inline: ${l.message}`),await jc(i,c,e.name)}return}await jc(i,c,e.name)};return{afterCreate:o,afterUpdate:o,afterDelete:async(a)=>{if(te())return;let c=a?.id??a?._attributes?.id;if(c==null)return;if(t.queueable){try{let{Jobs:l}=await import("@stacksjs/queue");await l.dispatch("SyncSearchIndex",{index:i,op:"delete",id:Number(c)})}catch(l){A.warn(`[orm/search] queue dispatch failed for ${e.name}#${c}; falling back to inline: ${l.message}`),await Pc(i,Number(c),e.name)}return}await Pc(i,Number(c),e.name)}}}var Cc=new Map;function Nc(e,t){let n=Cc.get(e)??0;if(Cc.set(e,n+1),n===0)A.warn(`[orm/search] ${t}`);else if(n===9)A.warn(`[orm/search] ${e} is still failing; further identical warnings suppressed for this process.`)}async function jc(e,t,n){try{let{useSearchEngine:i}=await import("@stacksjs/search-engine");await i().addDocument(e,t)}catch(i){Nc(`index:${n}`,`Failed to index ${n}: ${i.message}`)}}async function Pc(e,t,n){try{let{useSearchEngine:i}=await import("@stacksjs/search-engine");await i().deleteDocument(e,t)}catch(i){Nc(`remove:${n}`,`Failed to remove ${n}#${t}: ${i.message}`)}}function Qu(e){let t={},n=e.table,i=e.traits;if(!i)return t;if(i.taggable)t._taggable=Li(n);if(i.categorizable)t._categorizable=Ki(n);if(i.commentable)t._commentable=Gi(n);if(i.billable)t._billable=hc(n);if(i.likeable){let o=typeof i.likeable==="object"?i.likeable:void 0;t._likeable=Hi(n,o)}let r=i.useAuth||i.authenticatable;if(typeof r==="object"&&r&&"useTwoFactor"in r&&r.useTwoFactor)t._twoFactor=yc();return t}function Ju(e,t,n){let i=Rc(e,t.primaryKey||"id"),r=Tc(n),o=t,s=t.name.toLowerCase(),a=t.traits?.observe!=null&&t.traits?.observe!==!1,c=async(_)=>{if(!a||te())return!0;try{let{dispatchAsync:k}=await import("@stacksjs/events"),g=await k(`${s}:restoring`,{id:_});if(Array.isArray(g)&&g.some((y)=>y===!1))return!1}catch(k){if(k?.code!=="MODULE_NOT_FOUND")console.error(`[ORM] Before-event '${s}:restoring' handler error:`,k)}return!0},l=async(_)=>{if(!a||te())return;try{let{dispatch:k}=await import("@stacksjs/events");await k(`${s}:restored`,{id:_})}catch(k){if(k?.code!=="MODULE_NOT_FOUND")console.error(`[ORM] Event '${s}:restored' handler error:`,k)}},u=process.env.STACKS_ORM_CASCADE_SWALLOW!=="true",m=async(_)=>{if(!r.cascade?.length||!u){let g=await i.softDelete(_);if(g&&r.cascade?.length)await ni(o,r,_,"softDelete");return g}let{db:k}=await import("@stacksjs/database");return await k.transaction(async()=>{let g=await i.softDelete(_);if(g)await ni(o,r,_,"softDelete");return g})},p=async(_)=>{if(!await c(_))return!1;if(!r.cascade?.length||!u){let R=await i.restore(_);if(R){if(r.cascade?.length)await ni(o,r,_,"restore");await l(_)}return R}let{db:g}=await import("@stacksjs/database"),y=await g.transaction(async()=>{let R=await i.restore(_);if(R)await ni(o,r,_,"restore");return R});if(y)await l(_);return y};e.softDelete=m,e.restore=p,e.forceDelete=i.forceDelete,e.withTrashed=i.withTrashed,e.onlyTrashed=i.onlyTrashed,e.delete=m}function Xu(e){if(e==null)return e;if(Array.isArray(e))return e.map(Xu);if(typeof e!=="object")return e;if(typeof e.toJSON==="function")return e.toJSON();if(e._attributes&&typeof e._attributes==="object")return e._attributes;return e}var Yu=["belongsTo","hasOne","hasMany","belongsToMany","morphMany","morphOne"],Zu=["traits","dashboard"];function em(e){let t=e?.[Fa];if(t&&typeof t==="object")return t;if(e&&typeof e==="object"&&"name"in e&&"attributes"in e)return e;throw TypeError("extendModel() expects a model created by defineModel(), or a model definition. Import the framework model itself rather than its table name.")}function tm(e,t){let n=Array.isArray(e)?e:[],i=Array.isArray(t)?t:[];if(!n.length&&!i.length)return;return[...new Set([...n,...i])]}function nm(e){if(!e)return 0;return Object.values(e).reduce((t,n)=>{let i=Number(n?.order);return Number.isFinite(i)&&i>t?i:t},0)}function im(e,t){let n={...e,...t},i=e.attributes??{},r=t.attributes??{};if(t.attributes){let o=nm(i),s=Object.fromEntries(Object.entries(r).map(([a,c])=>{let l=!(a in i),u=Number.isFinite(Number(c?.order));if(l&&!u)return[a,{...c,order:++o}];return[a,c]}));n.attributes={...i,...s}}for(let o of Yu){let s=tm(e[o],t[o]);if(s)n[o]=s}for(let o of Zu){let s=e[o],a=t[o];if(s&&a&&typeof s==="object"&&typeof a==="object")n[o]={...s,...a}}return n}function yj(e,t){return Dc(im(em(e),t))}import{log as rm}from"@stacksjs/logging";import{path as V}from"@stacksjs/path";import{fs as ri}from"@stacksjs/storage";function Q(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()}function om(e){let t=e.default;if(typeof t==="boolean")return"boolean";if(typeof t==="number")return"number";if(typeof t==="string")return"string";return"unknown"}function sm(e){let t=e.validation;if(!t||typeof t!=="object")return null;let n=t.rule;return n&&typeof n==="object"?n:null}function am(e){if(!e||String(e.name??"")!=="enum")return null;let n=(Array.isArray(e.allowedValues)?e.allowedValues:[]).filter((i)=>typeof i==="string"||typeof i==="number").map((i)=>typeof i==="number"?String(i):JSON.stringify(i));return n.length>0?n.join(" | "):null}function lm(e){let t=sm(e),n=am(t);if(n!==null)return e.nullable===!0?`${n} | null`:n;let i=typeof e.type==="string"?e.type.toLowerCase():String(t?.name??"").toLowerCase(),r=(()=>{switch(i){case"string":case"text":case"longtext":case"mediumtext":case"tinytext":case"char":case"varchar":case"enum":case"uuid":case"date":case"datetime":case"timestamp":case"timestamptz":case"password":case"time":case"year":return"string";case"number":case"integer":case"int":case"tinyint":case"smallint":case"mediumint":case"float":case"double":case"decimal":case"numeric":return"number";case"bigint":return"number | bigint";case"boolean":case"bool":return"boolean";case"json":case"jsonb":return"unknown";case"binary":case"blob":case"bytea":return"Uint8Array";case"unix":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return om(e)}})();return e.nullable===!0?`${r} | null`:r}function cm(e){let t={},n=e.belongsTo;if(!n)return t;let i=Array.isArray(n)?n:Object.values(n);for(let r of i){if(typeof r==="string"){t[`${Q(r)}_id`]="number";continue}if(r&&typeof r==="object"){let o=r;if(typeof o.foreignKey==="string"){t[o.foreignKey]="number";continue}if(typeof o.model==="string")t[`${Q(o.model)}_id`]="number"}}return t}function dm(e,t){let[n,i]=[Q(e),Q(t)].sort();return`${n}_${i}`}function um(e){let t=e.default,n=typeof t==="string"?"string":typeof t==="number"?"number":typeof t==="boolean"?"boolean":t instanceof Date?"string":"unknown";return e.nullable?`${n} | null`:n}function mm(e,t){let n=t.belongsToMany;if(!n)return[];let i=[],r=Array.isArray(n)?n:Object.values(n);for(let o of r){let s,a,c,l,u={},m=!0;if(typeof o==="string")s=o;else if(o&&typeof o==="object"&&"model"in o){let y=o;if(s=y.model,"pivotTable"in y||"firstForeignKey"in y||"secondForeignKey"in y)a=y.pivotTable,c=y.firstForeignKey,l=y.secondForeignKey;else{let R=o;a=R.table,c=R.foreignKey,l=R.relatedKey,u=R.pivot?.columns??{},m=Boolean(R.pivot?.timestamps)}}else continue;let p=a??dm(e,s),_=c??`${Q(e)}_id`,k=l??`${Q(s)}_id`,g={id:"number",[_]:"number",[k]:"number"};for(let[y,R]of Object.entries(u))g[y]=um(R);if(m)g.created_at="string",g.updated_at="string | null";i.push({table:p,columns:g})}return i}var pm={email_verified_at:"string | null",password_changed_at:"string | null",two_factor_secret:"string | null",two_factor_enabled:"boolean | null",two_factor_last_used_step:"number | null",stripe_id:"string | null"};function fm(e){let t={id:"number"},n=e.traits??{};if(n.useUuid)t.uuid="string";if((n.useTimestamps??n.timestampable)!==!1)t.created_at="string",t.updated_at="string | null";if(n.useSoftDeletes??n.softDeletable)t.deleted_at="string | null";if((e.table??"")==="users"||e.name==="User")Object.assign(t,pm);return t}function _m(e){let t={},n=e.attributes??{};for(let[i,r]of Object.entries(n))t[Q(i)]=lm(r);return t}function km(e){return e.replace(/_([a-z0-9])/g,(t,n)=>n.toUpperCase())}function bm(e){let t={...e};for(let[n,i]of Object.entries(e)){let r=km(n);if(r!==n&&!(r in t))t[r]=i}return t}function Gc(e,t,n=2){let i=" ".repeat(n),r=" ".repeat(n+1),o=Object.entries(t).map(([a,c])=>`${r}${a}: ${c}`).join(`
|
|
15
|
+
`);function a(u){let m=o,p=u instanceof Uint8Array?u:new Uint8Array(r.encode(u));o=new Uint8Array(m.length+p.length+2),o.set(m),o.set(p,m.length),o.set(s,o.length-2)}function c(u){return`"${u.replace(/"|"/g,"%22").replace(/\r\n|\r|\n/g," ")}"`}let l=ml(t);for(let u in l){if(!Object.prototype.hasOwnProperty.call(l,u))continue;let m=l[u];if(a(`--${i}`),Object.prototype.hasOwnProperty.call(m,"data")){let p=m;a(`Content-Disposition: form-data; name=${c(u)}; filename=${c(p.name||"blob")}`),a(`Content-Type: ${p.type||"application/octet-stream"}`),a(""),a(p.data)}else a(`Content-Disposition: form-data; name=${c(u)}`),a(""),a(m)}return a(`--${i}--`),o};var Il=f(()=>{W()});var gn;var Ss=f(()=>{Il();b();gn=class gn extends d{constructor(){super(...arguments);this.requestDataProcessor=Al}list(e,t){return this._makeRequest("GET","/v1/files",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/files",e,t,{headers:{"Content-Type":"multipart/form-data"},apiBase:"files"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/files/${encodeURIComponent(e)}`,t,n)}}});var hn;var xs=f(()=>{b();hn=class hn extends d{list(e,t){return this._makeRequest("GET","/v1/file_links",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/file_links",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/file_links/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/file_links/${encodeURIComponent(e)}`,t,n)}}});var yn;var Cs=f(()=>{b();yn=class yn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/invoices/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/invoices",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/invoices",e,t,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}search(e,t){return this._makeRequest("GET","/v1/invoices/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}addLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/add_lines`,t,n,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}attachPayment(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/attach_payment`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}finalizeInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/finalize`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}markUncollectible(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/mark_uncollectible`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}pay(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/pay`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}removeLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/remove_lines`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}sendInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/send`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}updateLines(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/update_lines`,t,n,{requestSchema:{kind:"object",fields:{lines:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}voidInvoice(e,t,n){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/void`,t,n,{responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}createPreview(e,t){return this._makeRequest("POST","/v1/invoices/create_preview",e,t,{requestSchema:{kind:"object",fields:{invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},schedule_details:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}},subscription_details:{kind:"object",fields:{items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}},responseSchema:{kind:"object",fields:{lines:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/invoices/${encodeURIComponent(e)}/lines`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}updateLineItem(e,t,n,i){return this._makeRequest("POST",`/v1/invoices/${encodeURIComponent(e)}/lines/${encodeURIComponent(t)}`,n,i,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}}});var Rn;var js=f(()=>{b();Rn=class Rn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/invoiceitems/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}list(e,t){return this._makeRequest("GET","/v1/invoiceitems",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/invoiceitems",e,t,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}},quantity_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{pricing:{kind:"nullable",inner:{kind:"object",fields:{unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},quantity_decimal:{kind:"decimal_string"}}}})}}});var Tn;var Ps=f(()=>{b();Tn=class Tn extends d{list(e,t){return this._makeRequest("GET","/v1/invoice_payments",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoice_payments/${encodeURIComponent(e)}`,t,n)}}});var wn;var Es=f(()=>{b();wn=class wn extends d{list(e,t){return this._makeRequest("GET","/v1/invoice_rendering_templates",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}`,t,n)}archive(e,t,n){return this._makeRequest("POST",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}/archive`,t,n)}unarchive(e,t,n){return this._makeRequest("POST",`/v1/invoice_rendering_templates/${encodeURIComponent(e)}/unarchive`,t,n)}}});var vn;var qs=f(()=>{b();vn=class vn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/mandates/${encodeURIComponent(e)}`,t,n)}}});var Sn;var $l=f(()=>{b();W();Sn=class Sn extends d{constructor(){super(...arguments);this.basePath=be("/")}authorizeUrl(e,t){e=e||{},t=t||{};let n="oauth/authorize";if(t.express)n=`express/${n}`;if(!e.response_type)e.response_type="code";if(!e.client_id)e.client_id=this._stripe.getClientId();if(!e.scope)e.scope="read_write";return`https://${this._stripe.resolveBaseAddress("connect")}/${n}?${z(e)}`}token(e,t){return this._makeRequest("POST","/oauth/token",e,t,{apiBase:"connect"})}deauthorize(e,t){if(!e.client_id)e.client_id=this._stripe.getClientId();return this._makeRequest("POST","/oauth/deauthorize",e,t,{apiBase:"connect"})}}});var xn;var Os=f(()=>{b();xn=class xn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_attempt_records",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_attempt_records/${encodeURIComponent(e)}`,t,n)}}});var Cn;var As=f(()=>{b();Cn=class Cn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_intents",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_intents",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_intents/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}`,t,n)}search(e,t){return this._makeRequest("GET","/v1/payment_intents/search",e,t,{methodType:"search"})}applyCustomerBalance(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/apply_customer_balance`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/cancel`,t,n)}capture(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/capture`,t,n)}confirm(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/confirm`,t,n)}incrementAuthorization(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/increment_authorization`,t,n)}verifyMicrodeposits(e,t,n){return this._makeRequest("POST",`/v1/payment_intents/${encodeURIComponent(e)}/verify_microdeposits`,t,n)}listAmountDetailsLineItems(e,t,n){return this._makeRequest("GET",`/v1/payment_intents/${encodeURIComponent(e)}/amount_details_line_items`,t,n,{methodType:"list"})}}});var jn;var Is=f(()=>{b();jn=class jn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_links",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/payment_links",e,t,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_links/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/payment_links/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/payment_links/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}}});var Pn;var $s=f(()=>{b();Pn=class Pn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_methods",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_methods",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_methods/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}`,t,n)}attach(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}/attach`,t,n)}detach(e,t,n){return this._makeRequest("POST",`/v1/payment_methods/${encodeURIComponent(e)}/detach`,t,n)}}});var En;var Us=f(()=>{b();En=class En extends d{list(e,t){return this._makeRequest("GET","/v1/payment_method_configurations",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_method_configurations",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_method_configurations/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_method_configurations/${encodeURIComponent(e)}`,t,n)}}});var qn;var Ms=f(()=>{b();qn=class qn extends d{list(e,t){return this._makeRequest("GET","/v1/payment_method_domains",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payment_method_domains",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_method_domains/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payment_method_domains/${encodeURIComponent(e)}`,t,n)}validate(e,t,n){return this._makeRequest("POST",`/v1/payment_method_domains/${encodeURIComponent(e)}/validate`,t,n)}}});var On;var Ds=f(()=>{b();On=class On extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/payment_records/${encodeURIComponent(e)}`,t,n)}reportPaymentAttempt(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt`,t,n)}reportPaymentAttemptCanceled(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_canceled`,t,n)}reportPaymentAttemptFailed(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_failed`,t,n)}reportPaymentAttemptGuaranteed(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_guaranteed`,t,n)}reportPaymentAttemptInformational(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_payment_attempt_informational`,t,n)}reportRefund(e,t,n){return this._makeRequest("POST",`/v1/payment_records/${encodeURIComponent(e)}/report_refund`,t,n)}reportPayment(e,t){return this._makeRequest("POST","/v1/payment_records/report_payment",e,t)}}});var An;var Fs=f(()=>{b();An=class An extends d{list(e,t){return this._makeRequest("GET","/v1/payouts",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/payouts",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/payouts/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}/cancel`,t,n)}reverse(e,t,n){return this._makeRequest("POST",`/v1/payouts/${encodeURIComponent(e)}/reverse`,t,n)}}});var In;var Ns=f(()=>{b();In=class In extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/plans/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/plans/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/plans/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/plans",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/plans",e,t,{requestSchema:{kind:"object",fields:{amount_decimal:{kind:"decimal_string"},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}}}},responseSchema:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}}});var $n;var Gs=f(()=>{b();$n=class $n extends d{list(e,t){return this._makeRequest("GET","/v1/prices",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/prices",e,t,{requestSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}},responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/prices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/prices/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}})}search(e,t){return this._makeRequest("GET","/v1/prices/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}})}}});var Un;var Bs=f(()=>{b();Un=class Un extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/products/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/products/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/products",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/products",e,t,{requestSchema:{kind:"object",fields:{default_price_data:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"decimal_string"},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}},unit_amount_decimal:{kind:"decimal_string"}}}}}})}search(e,t){return this._makeRequest("GET","/v1/products/search",e,t,{methodType:"search"})}deleteFeature(e,t,n,i){return this._makeRequest("DELETE",`/v1/products/${encodeURIComponent(e)}/features/${encodeURIComponent(t)}`,n,i)}retrieveFeature(e,t,n,i){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}/features/${encodeURIComponent(t)}`,n,i)}listFeatures(e,t,n){return this._makeRequest("GET",`/v1/products/${encodeURIComponent(e)}/features`,t,n,{methodType:"list"})}createFeature(e,t,n){return this._makeRequest("POST",`/v1/products/${encodeURIComponent(e)}/features`,t,n)}}});var Mn;var Ls=f(()=>{b();Mn=class Mn extends d{list(e,t){return this._makeRequest("GET","/v1/promotion_codes",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/promotion_codes",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/promotion_codes/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/promotion_codes/${encodeURIComponent(e)}`,t,n)}}});var Dn;var Ks=f(()=>{b();Dn=class Dn extends d{list(e,t){return this._makeRequest("GET","/v1/quotes",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/quotes",e,t,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{line_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}accept(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/accept`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}cancel(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/cancel`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}finalizeQuote(e,t,n){return this._makeRequest("POST",`/v1/quotes/${encodeURIComponent(e)}/finalize`,t,n,{responseSchema:{kind:"object",fields:{computed:{kind:"object",fields:{upfront:{kind:"object",fields:{line_items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}}}})}pdf(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/pdf`,t,n,{apiBase:"files",streaming:!0})}listComputedUpfrontLineItems(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/computed_upfront_line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}listLineItems(e,t,n){return this._makeRequest("GET",`/v1/quotes/${encodeURIComponent(e)}/line_items`,t,n,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{price:{kind:"nullable",inner:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}})}}});var Fn;var Hs=f(()=>{b();Fn=class Fn extends d{list(e,t){return this._makeRequest("GET","/v1/refunds",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/refunds",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/refunds/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/refunds/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/refunds/${encodeURIComponent(e)}/cancel`,t,n)}}});var Nn;var Vs=f(()=>{b();Nn=class Nn extends d{list(e,t){return this._makeRequest("GET","/v1/reviews",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/reviews/${encodeURIComponent(e)}`,t,n)}approve(e,t,n){return this._makeRequest("POST",`/v1/reviews/${encodeURIComponent(e)}/approve`,t,n)}}});var Gn;var zs=f(()=>{b();Gn=class Gn extends d{list(e,t){return this._makeRequest("GET","/v1/setup_attempts",e,t,{methodType:"list"})}}});var Bn;var Ws=f(()=>{b();Bn=class Bn extends d{list(e,t){return this._makeRequest("GET","/v1/setup_intents",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/setup_intents",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/setup_intents/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/cancel`,t,n)}confirm(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/confirm`,t,n)}verifyMicrodeposits(e,t,n){return this._makeRequest("POST",`/v1/setup_intents/${encodeURIComponent(e)}/verify_microdeposits`,t,n)}}});var Ln;var Qs=f(()=>{b();Ln=class Ln extends d{list(e,t){return this._makeRequest("GET","/v1/shipping_rates",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/shipping_rates",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/shipping_rates/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/shipping_rates/${encodeURIComponent(e)}`,t,n)}}});var Kn;var Js=f(()=>{b();Kn=class Kn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/sources/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/sources/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/sources",e,t)}verify(e,t,n){return this._makeRequest("POST",`/v1/sources/${encodeURIComponent(e)}/verify`,t,n)}listSourceTransactions(e,t,n){return this._makeRequest("GET",`/v1/sources/${encodeURIComponent(e)}/source_transactions`,t,n,{methodType:"list"})}}});var Hn;var Xs=f(()=>{b();Hn=class Hn extends d{cancel(e,t,n){return this._makeRequest("DELETE",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}deleteDiscount(e,t,n){return this._makeRequest("DELETE",`/v1/subscriptions/${encodeURIComponent(e)}/discount`,t,n)}list(e,t){return this._makeRequest("GET","/v1/subscriptions",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/subscriptions",e,t,{requestSchema:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}},responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}search(e,t){return this._makeRequest("GET","/v1/subscriptions/search",e,t,{methodType:"search",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}}}}})}migrate(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}/migrate`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}resume(e,t,n){return this._makeRequest("POST",`/v1/subscriptions/${encodeURIComponent(e)}/resume`,t,n,{responseSchema:{kind:"object",fields:{items:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}}}})}}});var Vn;var Ys=f(()=>{b();Vn=class Vn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n,{responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}update(e,t,n){return this._makeRequest("POST",`/v1/subscription_items/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}list(e,t){return this._makeRequest("GET","/v1/subscription_items",e,t,{methodType:"list",responseSchema:{kind:"object",fields:{data:{kind:"array",element:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}}}}})}create(e,t){return this._makeRequest("POST","/v1/subscription_items",e,t,{requestSchema:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}},responseSchema:{kind:"object",fields:{plan:{kind:"object",fields:{amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}},price:{kind:"object",fields:{currency_options:{kind:"array",element:{kind:"object",fields:{tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},tiers:{kind:"array",element:{kind:"object",fields:{flat_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}},unit_amount_decimal:{kind:"nullable",inner:{kind:"decimal_string"}}}}}}})}}});var zn;var Zs=f(()=>{b();zn=class zn extends d{list(e,t){return this._makeRequest("GET","/v1/subscription_schedules",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/subscription_schedules",e,t,{requestSchema:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}}})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/subscription_schedules/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}`,t,n,{requestSchema:{kind:"object",fields:{phases:{kind:"array",element:{kind:"object",fields:{add_invoice_items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}},items:{kind:"array",element:{kind:"object",fields:{price_data:{kind:"object",fields:{unit_amount_decimal:{kind:"decimal_string"}}}}}}}}}}}})}cancel(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}/cancel`,t,n)}release(e,t,n){return this._makeRequest("POST",`/v1/subscription_schedules/${encodeURIComponent(e)}/release`,t,n)}}});var Wn;var ea=f(()=>{b();Wn=class Wn extends d{list(e,t){return this._makeRequest("GET","/v1/tax_codes",e,t,{methodType:"list"})}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_codes/${encodeURIComponent(e)}`,t,n)}}});var Qn;var ta=f(()=>{b();Qn=class Qn extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/tax_ids/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_ids/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/tax_ids",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/tax_ids",e,t)}}});var Jn;var na=f(()=>{b();Jn=class Jn extends d{list(e,t){return this._makeRequest("GET","/v1/tax_rates",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/tax_rates",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/tax_rates/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/tax_rates/${encodeURIComponent(e)}`,t,n)}}});var Xn;var ia=f(()=>{b();Xn=class Xn extends d{retrieve(e,t,n){return this._makeRequest("GET",`/v1/tokens/${encodeURIComponent(e)}`,t,n)}create(e,t){return this._makeRequest("POST","/v1/tokens",e,t)}}});var Yn;var ra=f(()=>{b();Yn=class Yn extends d{list(e,t){return this._makeRequest("GET","/v1/topups",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/topups",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/topups/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/topups/${encodeURIComponent(e)}`,t,n)}cancel(e,t,n){return this._makeRequest("POST",`/v1/topups/${encodeURIComponent(e)}/cancel`,t,n)}}});var Zn;var oa=f(()=>{b();Zn=class Zn extends d{list(e,t){return this._makeRequest("GET","/v1/transfers",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/transfers",e,t)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}`,t,n)}listReversals(e,t,n){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}/reversals`,t,n,{methodType:"list"})}createReversal(e,t,n){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}/reversals`,t,n)}retrieveReversal(e,t,n,i){return this._makeRequest("GET",`/v1/transfers/${encodeURIComponent(e)}/reversals/${encodeURIComponent(t)}`,n,i)}updateReversal(e,t,n,i){return this._makeRequest("POST",`/v1/transfers/${encodeURIComponent(e)}/reversals/${encodeURIComponent(t)}`,n,i)}}});var ei;var sa=f(()=>{b();ei=class ei extends d{del(e,t,n){return this._makeRequest("DELETE",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}retrieve(e,t,n){return this._makeRequest("GET",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}update(e,t,n){return this._makeRequest("POST",`/v1/webhook_endpoints/${encodeURIComponent(e)}`,t,n)}list(e,t){return this._makeRequest("GET","/v1/webhook_endpoints",e,t,{methodType:"list"})}create(e,t){return this._makeRequest("POST","/v1/webhook_endpoints",e,t)}}});var ae={};Oi(ae,{Account:()=>oe,AccountLinks:()=>en,AccountSessions:()=>tn,Accounts:()=>oe,ApplePayDomains:()=>nn,ApplicationFees:()=>rn,Apps:()=>eu,Balance:()=>se,BalanceSettings:()=>on,BalanceTransactions:()=>sn,Balances:()=>se,Billing:()=>tu,BillingPortal:()=>nu,Charges:()=>an,Checkout:()=>iu,Climate:()=>ru,ConfirmationTokens:()=>ln,CountrySpecs:()=>cn,Coupons:()=>dn,CreditNotes:()=>un,CustomerSessions:()=>pn,Customers:()=>mn,Disputes:()=>fn,Entitlements:()=>ou,EphemeralKeys:()=>_n,Events:()=>kn,ExchangeRates:()=>bn,FileLinks:()=>hn,Files:()=>gn,FinancialConnections:()=>su,Forwarding:()=>au,Identity:()=>lu,InvoiceItems:()=>Rn,InvoicePayments:()=>Tn,InvoiceRenderingTemplates:()=>wn,Invoices:()=>yn,Issuing:()=>cu,Mandates:()=>vn,OAuthResource:()=>Sn,PaymentAttemptRecords:()=>xn,PaymentIntents:()=>Cn,PaymentLinks:()=>jn,PaymentMethodConfigurations:()=>En,PaymentMethodDomains:()=>qn,PaymentMethods:()=>Pn,PaymentRecords:()=>On,Payouts:()=>An,Plans:()=>In,Prices:()=>$n,Products:()=>Un,PromotionCodes:()=>Mn,Quotes:()=>Dn,Radar:()=>du,Refunds:()=>Fn,Reporting:()=>uu,Reviews:()=>Nn,SetupAttempts:()=>Gn,SetupIntents:()=>Bn,ShippingRates:()=>Ln,Sigma:()=>mu,Sources:()=>Kn,SubscriptionItems:()=>Vn,SubscriptionSchedules:()=>zn,Subscriptions:()=>Hn,Tax:()=>pu,TaxCodes:()=>Wn,TaxIds:()=>Qn,TaxRates:()=>Jn,Terminal:()=>fu,TestHelpers:()=>_u,Tokens:()=>Xn,Topups:()=>Yn,Transfers:()=>Zn,Treasury:()=>ku,V2:()=>bu,WebhookEndpoints:()=>ei});var eu,tu,nu,iu,ru,ou,su,au,lu,cu,du,uu,mu,pu,fu,_u,ku,bu;var aa=f(()=>{Or();Ar();Ir();Mr();Dr();Fr();Nr();Gr();Br();Lr();Kr();Hr();Vr();zr();Wr();Qr();Jr();Xr();Yr();Zr();eo();to();no();io();ro();oo();so();ao();lo();co();uo();mo();po();fo();_o();ko();bo();go();ho();yo();Ro();To();wo();vo();So();xo();Co();jo();Po();Eo();qo();Oo();Ao();Io();$o();Uo();Mo();Do();Fo();No();Go();Bo();Lo();Ko();Ho();Vo();zo();Wo();Qo();Jo();Xo();Yo();Zo();es();ts();ns();is();rs();os();ss();as();Ci();Ci();ls();cs();ds();us();ji();ji();ms();ps();fs();_s();ks();bs();gs();hs();ys();Rs();Ts();ws();vs();Ss();xs();Cs();js();Ps();Es();qs();$l();Os();As();Is();$s();Us();Ms();Ds();Fs();Ns();Gs();Bs();Ls();Ks();Hs();Vs();zs();Ws();Qs();Js();Xs();Ys();Zs();ea();ta();na();ia();ra();oa();sa();eu=S("apps",{Secrets:Ut}),tu=S("billing",{Alerts:Oe,CreditBalanceSummary:Ke,CreditBalanceTransactions:He,CreditGrants:Ve,MeterEventAdjustments:st,MeterEvents:dt,Meters:mt}),nu=S("billingPortal",{Configurations:Ne,Sessions:Mt}),iu=S("checkout",{Sessions:Dt}),ru=S("climate",{Orders:ft,Products:wt,Suppliers:Gt}),ou=S("entitlements",{ActiveEntitlements:qe,Features:et}),su=S("financialConnections",{Accounts:Pe,Sessions:Ft,Transactions:Ht}),au=S("forwarding",{Requests:It}),lu=S("identity",{VerificationReports:Yt,VerificationSessions:Zt}),cu=S("issuing",{Authorizations:Ie,Cardholders:Me,Cards:De,Disputes:Je,PersonalizationDesigns:yt,PhysicalBundles:Tt,Tokens:Lt,Transactions:Vt}),du=S("radar",{EarlyFraudWarnings:Xe,PaymentEvaluations:ht,ValueListItems:Jt,ValueLists:Xt}),uu=S("reporting",{ReportRuns:Ot,ReportTypes:At}),mu=S("sigma",{ScheduledQueryRuns:$t}),pu=S("tax",{Associations:Ae,Calculations:Ue,Registrations:qt,Settings:Nt,Transactions:zt}),fu=S("terminal",{Configurations:Ge,ConnectionTokens:Le,Locations:ot,OnboardingLinks:pt,Readers:vt}),_u=S("testHelpers",{ConfirmationTokens:Be,Customers:We,Refunds:Et,TestClocks:Bt,Issuing:S("issuing",{Authorizations:$e,Cards:Fe,PersonalizationDesigns:Rt,Transactions:Wt}),Terminal:S("terminal",{Readers:St}),Treasury:S("treasury",{InboundTransfers:it,OutboundPayments:_t,OutboundTransfers:bt,ReceivedCredits:xt,ReceivedDebits:jt})}),ku=S("treasury",{CreditReversals:ze,DebitReversals:Qe,FinancialAccounts:tt,InboundTransfers:rt,OutboundPayments:kt,OutboundTransfers:gt,ReceivedCredits:Ct,ReceivedDebits:Pt,TransactionEntries:Kt,Transactions:Qt}),bu=S("v2",{Billing:S("billing",{MeterEventAdjustments:at,MeterEventSession:lt,MeterEventStream:ct,MeterEvents:ut}),Commerce:S("commerce",{ProductCatalog:S("productCatalog",{Imports:nt})}),Core:S("core",{AccountLinks:Ce,AccountTokens:je,Accounts:Ee,EventDestinations:Ye,Events:Ze})})});var Ul=f(()=>{Ri()});class la{constructor(e){this.stripe=e,this.secrets=new Ut(e)}}var Ml=f(()=>{Ko()});class ca{constructor(e){this.stripe=e,this.alerts=new Oe(e),this.creditBalanceSummaries=new Ke(e),this.creditBalanceTransactions=new He(e),this.creditGrants=new Ve(e),this.meters=new mt(e),this.meterEvents=new dt(e),this.meterEventAdjustments=new st(e)}}var Dl=f(()=>{Fr();Xr();Yr();Zr();yo();go();fo()});class da{constructor(e){this.stripe=e,this.configurations=new Ne(e),this.sessions=new Mt(e)}}var Fl=f(()=>{zr();Ho()});class ua{constructor(e){this.stripe=e,this.sessions=new Dt(e)}}var Nl=f(()=>{Vo()});class ma{constructor(e){this.stripe=e,this.orders=new ft(e),this.products=new wt(e),this.suppliers=new Gt(e)}}var Gl=f(()=>{To();qo();Qo()});class pa{constructor(e){this.stripe=e,this.activeEntitlements=new qe(e),this.features=new et(e)}}var Bl=f(()=>{Dr();ao()});class fa{constructor(e){this.stripe=e,this.accounts=new Pe(e),this.sessions=new Ft(e),this.transactions=new Ht(e)}}var Ll=f(()=>{Ir();zo();Zo()});class _a{constructor(e){this.stripe=e,this.requests=new It(e)}}var Kl=f(()=>{Bo()});class ka{constructor(e){this.stripe=e,this.verificationReports=new Yt(e),this.verificationSessions=new Zt(e)}}var Hl=f(()=>{ss();as()});class ba{constructor(e){this.stripe=e,this.authorizations=new Ie(e),this.cards=new De(e),this.cardholders=new Me(e),this.disputes=new Je(e),this.personalizationDesigns=new yt(e),this.physicalBundles=new Tt(e),this.tokens=new Lt(e),this.transactions=new Vt(e)}}var Vl=f(()=>{Gr();Hr();Kr();io();jo();Eo();Xo();es()});class ga{constructor(e){this.stripe=e,this.earlyFraudWarnings=new Xe(e),this.paymentEvaluations=new ht(e),this.valueLists=new Xt(e),this.valueListItems=new Jt(e)}}var zl=f(()=>{ro();Co();os();rs()});class ha{constructor(e){this.stripe=e,this.reportRuns=new Ot(e),this.reportTypes=new At(e)}}var Wl=f(()=>{No();Go()});class ya{constructor(e){this.stripe=e,this.scheduledQueryRuns=new $t(e)}}var Ql=f(()=>{Lo()});class Ra{constructor(e){this.stripe=e,this.associations=new Ae(e),this.calculations=new Ue(e),this.registrations=new qt(e),this.settings=new Nt(e),this.transactions=new zt(e)}}var Jl=f(()=>{Nr();Lr();Fo();Wo();ts()});class Ta{constructor(e){this.stripe=e,this.configurations=new Ge(e),this.connectionTokens=new Le(e),this.locations=new ot(e),this.onboardingLinks=new pt(e),this.readers=new vt(e)}}var Xl=f(()=>{Wr();Jr();po();Ro();Oo()});class wa{constructor(e){this.stripe=e,this.authorizations=new $e(e),this.cards=new Fe(e),this.personalizationDesigns=new Rt(e),this.transactions=new Wt(e)}}var Yl=f(()=>{Br();Vr();Po();ns()});class va{constructor(e){this.stripe=e,this.readers=new St(e)}}var Zl=f(()=>{Ao()});class Sa{constructor(e){this.stripe=e,this.inboundTransfers=new it(e),this.outboundPayments=new _t(e),this.outboundTransfers=new bt(e),this.receivedCredits=new xt(e),this.receivedDebits=new jt(e)}}var ec=f(()=>{uo();wo();So();Io();Uo()});class xa{constructor(e){this.stripe=e,this.confirmationTokens=new Be(e),this.customers=new We(e),this.refunds=new Et(e),this.testClocks=new Bt(e),this.issuing=new wa(e),this.terminal=new va(e),this.treasury=new Sa(e)}}var tc=f(()=>{Qr();to();Do();Jo();Yl();Zl();ec()});class Ca{constructor(e){this.stripe=e,this.creditReversals=new ze(e),this.debitReversals=new Qe(e),this.financialAccounts=new tt(e),this.inboundTransfers=new rt(e),this.outboundPayments=new kt(e),this.outboundTransfers=new gt(e),this.receivedCredits=new Ct(e),this.receivedDebits=new Pt(e),this.transactions=new Qt(e),this.transactionEntries=new Kt(e)}}var nc=f(()=>{eo();no();lo();mo();vo();xo();$o();Mo();is();Yo()});class ja{constructor(e){this.stripe=e,this.meterEvents=new ut(e),this.meterEventAdjustments=new at(e),this.meterEventSession=new lt(e),this.meterEventStream=new ct(e)}}var ic=f(()=>{ho();_o();ko();bo()});class Pa{constructor(e){this.stripe=e,this.imports=new nt(e)}}var rc=f(()=>{co()});class Ea{constructor(e){this.stripe=e,this.productCatalog=new Pa(e)}}var oc=f(()=>{rc()});class qa{constructor(e){this.stripe=e,this.accounts=new Ee(e),this.accountLinks=new Ce(e),this.accountTokens=new je(e),this.events=new Ze(e),this.eventDestinations=new Ye(e)}}var sc=f(()=>{Mr();Or();Ar();so();oo()});class Oa{constructor(e){this.stripe=e,this.billing=new ja(e),this.commerce=new Ea(e),this.core=new qa(e)}}var ac=f(()=>{ic();oc();sc()});class w{static initialize(e,t=_c){w._platformFunctions=e,w._requestSenderFactory=t,w.webhooks=Pl(e),w.createNodeHttpClient=e.createNodeHttpClient,w.createFetchHttpClient=e.createFetchHttpClient,w.createNodeCryptoProvider=e.createNodeCryptoProvider,w.createSubtleCryptoProvider=e.createSubtleCryptoProvider;let n=e.getEnv(),i=e.getRuntimeVersion();w.aiAgent=n?pl(n):"",w.AI_AGENT=w.aiAgent,w.USER_AGENT={bindings_version:w.PACKAGE_VERSION,lang:"node",typescript:!1,...i?{lang_version:i}:{},...w.aiAgent?{ai_agent:w.aiAgent}:{}}}constructor(e,t={}){this._authenticator=null;let n=this._getPropsFromConfig(t);this._platformFunctions=w._platformFunctions,Object.defineProperty(this,"_emitter",{value:this._platformFunctions.createEmitter(),enumerable:!1,configurable:!1,writable:!1}),this.VERSION=w.PACKAGE_VERSION,this.on=this._emitter.on.bind(this._emitter),this.once=this._emitter.once.bind(this._emitter),this.off=this._emitter.removeListener.bind(this._emitter);let i=n.httpAgent||null;this._api={host:n.host||Aa,port:n.port||lc,protocol:n.protocol||"https",basePath:cc,version:n.apiVersion||dc,timeout:ki("timeout",n.timeout,uc),maxNetworkRetries:ki("maxNetworkRetries",n.maxNetworkRetries,2),agent:i,httpClient:n.httpClient||(i?this._platformFunctions.createNodeHttpClient(i):this._platformFunctions.createDefaultHttpClient()),dev:!1,stripeAccount:n.stripeAccount||null,stripeContext:n.stripeContext||null};let r=n.typescript||!1;if(r!==w.USER_AGENT.typescript)w.USER_AGENT.typescript=r;if(n.appInfo)this._setAppInfo(n.appInfo);this._setAuthenticator(e,n.authenticator||null),this.errors=Si,this.Decimal=M,this.webhooks=w.webhooks,this._prevRequestMetrics=[],this._enableTelemetry=n.telemetry!==!1,this._emitEventBodies=n.emitEventBodies===!0,this._requestSender=w._requestSenderFactory(this),this.accountLinks=new en(this),this.accountSessions=new tn(this),this.accounts=new oe(this),this.applePayDomains=new nn(this),this.applicationFees=new rn(this),this.balance=new se(this),this.balanceSettings=new on(this),this.balanceTransactions=new sn(this),this.charges=new an(this),this.confirmationTokens=new ln(this),this.countrySpecs=new cn(this),this.coupons=new dn(this),this.creditNotes=new un(this),this.customerSessions=new pn(this),this.customers=new mn(this),this.disputes=new fn(this),this.ephemeralKeys=new _n(this),this.events=new kn(this),this.exchangeRates=new bn(this),this.fileLinks=new hn(this),this.files=new gn(this),this.invoiceItems=new Rn(this),this.invoicePayments=new Tn(this),this.invoiceRenderingTemplates=new wn(this),this.invoices=new yn(this),this.mandates=new vn(this),this.paymentAttemptRecords=new xn(this),this.paymentIntents=new Cn(this),this.paymentLinks=new jn(this),this.paymentMethodConfigurations=new En(this),this.paymentMethodDomains=new qn(this),this.paymentMethods=new Pn(this),this.paymentRecords=new On(this),this.payouts=new An(this),this.plans=new In(this),this.prices=new $n(this),this.products=new Un(this),this.promotionCodes=new Mn(this),this.quotes=new Dn(this),this.refunds=new Fn(this),this.reviews=new Nn(this),this.setupAttempts=new Gn(this),this.setupIntents=new Bn(this),this.shippingRates=new Ln(this),this.sources=new Kn(this),this.subscriptionItems=new Vn(this),this.subscriptionSchedules=new zn(this),this.subscriptions=new Hn(this),this.taxCodes=new Wn(this),this.taxIds=new Qn(this),this.taxRates=new Jn(this),this.tokens=new Xn(this),this.topups=new Yn(this),this.transfers=new Zn(this),this.webhookEndpoints=new ei(this),this.apps=new la(this),this.billing=new ca(this),this.billingPortal=new da(this),this.checkout=new ua(this),this.climate=new ma(this),this.entitlements=new pa(this),this.financialConnections=new fa(this),this.forwarding=new _a(this),this.identity=new ka(this),this.issuing=new ba(this),this.radar=new ga(this),this.reporting=new ha(this),this.sigma=new ya(this),this.tax=new Ra(this),this.terminal=new Ta(this),this.testHelpers=new xa(this),this.treasury=new Ca(this),this.v2=new Oa(this),this.account=this.accounts,this.oauth=new Sn(this)}rawRequest(e,t,n,i){return this._requestSender._rawRequest(e,t,n,i)}_setAuthenticator(e,t){if(e&&t)throw Error("Can't specify both apiKey and authenticator");if(!e&&!t)throw Error("Neither apiKey nor config.authenticator provided");this._authenticator=e?lr(e):t}_setAppInfo(e){if(e&&typeof e!=="object")throw Error("AppInfo must be an object.");if(e&&!e.name)throw Error("AppInfo.name is required");e=e||{},this._appInfo=gu.reduce((t,n)=>{if(typeof e[n]=="string")t=t||{},t[n]=e[n];return t},{})}setClientId(e){this._clientId=e}getClientId(){return this._clientId}getConstant(e){switch(e){case"DEFAULT_HOST":return Aa;case"DEFAULT_PORT":return lc;case"DEFAULT_BASE_PATH":return cc;case"DEFAULT_API_VERSION":return dc;case"DEFAULT_TIMEOUT":return uc;case"MAX_NETWORK_RETRY_DELAY_SEC":return mc;case"INITIAL_NETWORK_RETRY_DELAY_SEC":return pc}return w[e]}resolveBaseAddress(e){let t=this.getApiField("host");if(t!==Aa)return t;return sr[e]}getMaxNetworkRetries(){return this.getApiField("maxNetworkRetries")}_setApiNumberField(e,t,n){let i=ki(e,t,n);this._setApiField(e,i)}getMaxNetworkRetryDelay(){return mc}getInitialNetworkRetryDelay(){return pc}getClientUserAgent(e){return this.getClientUserAgentSeeded(w.USER_AGENT,e)}getClientUserAgentSeeded(e,t){let n={};for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;n[o]=encodeURIComponent(e[o]??"null")}let i=this._platformFunctions.getPlatformInfo();if(i&&this.getTelemetryEnabled())n.platform=encodeURIComponent(i);else delete n.platform;let r=this.getApiField("httpClient");if(r)n.httplib=encodeURIComponent(r.getClientName());if(this._appInfo)n.application=this._appInfo;if(this.getTelemetryEnabled()){let o=this._platformFunctions.getTelemetryId();if(o)n.telemetry_id=o}t(JSON.stringify(n))}getAppInfoAsString(){if(!this._appInfo)return"";let e=this._appInfo.name;if(this._appInfo.version)e+=`/${this._appInfo.version}`;if(this._appInfo.url)e+=` (${this._appInfo.url})`;return e}getTelemetryEnabled(){return this._enableTelemetry}getEmitEventBodiesEnabled(){return this._emitEventBodies}_prepResources(){for(let e in ae){if(!Object.prototype.hasOwnProperty.call(ae,e))continue;this[ul(e.replace("Resource",""))]=new ae[e](this)}}_getPropsFromConfig(e){if(!e)return{};let t=typeof e==="string";if(!(e===Object(e)&&!Array.isArray(e))&&!t)throw Error("Config must either be an object or a string");if(t)return{apiVersion:e};if(Object.keys(e).filter((r)=>!fc.includes(r)).length>0)throw Error(`Config object may only contain the following: ${fc.join(", ")}`);return e}_setApiField(e,t){this._api[e]=t}getApiField(e){return this._api[e]}parseEventNotification(e,t,n,i,r,o){if(!this.webhooks.signature)throw Error("ERR: missing signature helper, unable to verify");this.webhooks.signature.verifyHeader(e,t,n,i||this.webhooks.DEFAULT_TOLERANCE,r||this._platformFunctions.createDefaultCryptoProvider(),o);let s=e instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(e)):JSON.parse(e);if(s&&s.object==="event")throw Error("You passed a webhook payload to stripe.parseEventNotification, which expects an event notification. Use stripe.webhooks.constructEvent instead.");if(s.context)s.context=K.parse(s.context);return s.fetchEvent=()=>this._requestSender._rawRequest("GET",`/v2/core/events/${s.id}`,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_event"]),s.fetchRelatedObject=()=>{if(!s.related_object)return Promise.resolve(null);return this._requestSender._rawRequest("GET",s.related_object.url,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_related_object"])},s}async parseEventNotificationAsync(e,t,n,i,r,o){if(!this.webhooks.signature)throw Error("ERR: missing signature helper, unable to verify");await this.webhooks.signature.verifyHeaderAsync(e,t,n,i||this.webhooks.DEFAULT_TOLERANCE,r||this._platformFunctions.createDefaultCryptoProvider(),o);let s=e instanceof Uint8Array?JSON.parse(new TextDecoder("utf8").decode(e)):JSON.parse(e);if(s&&s.object==="event")throw Error("You passed a webhook payload to stripe.parseEventNotificationAsync, which expects an event notification. Use stripe.webhooks.constructEventAsync instead.");if(s.context)s.context=K.parse(s.context);return s.fetchEvent=()=>this._requestSender._rawRequest("GET",`/v2/core/events/${s.id}`,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_event"]),s.fetchRelatedObject=()=>{if(!s.related_object)return Promise.resolve(null);return this._requestSender._rawRequest("GET",s.related_object.url,void 0,{stripeContext:s.context,headers:{"Stripe-Request-Trigger":`event=${s.id}`}},["fetch_related_object"])},s}}var Aa="api.stripe.com",lc="443",cc="/v1/",dc,uc=80000,mc=5,pc=0.5,gu,fc,_c=(e)=>new re(e,d.MAX_BUFFERED_REQUEST_METRICS);var kc=f(()=>{xi();Tl();b();ar();El();yi();hi();aa();W();Ul();Ci();ls();cs();ds();us();ji();ms();ps();fs();_s();ks();bs();gs();hs();ys();Rs();Ts();vs();Ss();xs();Cs();js();Ps();Es();qs();Os();As();Is();$s();Us();Ms();Ds();Fs();Ns();Gs();Bs();Ls();Ks();Hs();Vs();zs();Ws();Qs();Js();Xs();Ys();Zs();ea();ta();na();ia();ra();oa();sa();Ml();Dl();Fl();Nl();Gl();Bl();Ll();Kl();Hl();Vl();zl();Wl();Ql();Jl();Xl();tc();nc();ac();ws();aa();dc=qr,gu=["name","version","url","partner_id"],fc=["authenticator","apiVersion","typescript","maxNetworkRetries","httpAgent","httpClient","timeout","host","port","protocol","telemetry","emitEventBodies","appInfo","stripeAccount","stripeContext"];w.PACKAGE_VERSION="22.3.2";w.API_VERSION=qr;w.aiAgent="";w.AI_AGENT="";w.USER_AGENT={bindings_version:w.PACKAGE_VERSION,lang:"node",typescript:!1};w.StripeResource=d;w.resources=ae;w.HttpClient=q;w.HttpClientResponse=he;w.CryptoProvider=Re;w.StripeContext=K;w.errors=Si;w.Decimal=M;w._requestSenderFactory=_c});var bc={};Oi(bc,{Decimal:()=>M,Stripe:()=>w,default:()=>hu});var hu;var gc=f(()=>{Rl();Ri();kc();w.initialize(new fr);hu=w});import"@stacksjs/validation";import{log as Ai}from"@stacksjs/cli";import{db as Na}from"@stacksjs/database";async function Xc(e,t={}){let{olderThanDays:n=30,column:i="created_at",query:r}=t;try{if(r){let l=Na.deleteFrom(e);l=r(l);let u=await l.execute(),m=Array.isArray(u)?u:[u],p=Number(m[0]?.numDeletedRows??m.length??0);return Ai.info(`Pruned ${p} records from ${e}`),p}let o=new Date;o.setDate(o.getDate()-n);let s=await Na.deleteFrom(e).where(i,"<",o.toISOString()).execute(),a=Array.isArray(s)?s:[s],c=Number(a[0]?.numDeletedRows??a.length??0);return Ai.info(`Pruned ${c} records from ${e} older than ${n} days`),c}catch(o){throw Ai.error(`Failed to prune ${e}:`,o),o}}async function wf(e,t={}){return Xc(e,t)}function vf(e){if(!e?.prunable)return null;if(typeof e.prunable==="boolean")return{olderThanDays:30,column:"created_at"};return e.prunable}import{createCipheriv as Yc,createDecipheriv as Zc,createHash as ed,randomBytes as td}from"crypto";import{log as ai}from"@stacksjs/logging";var Ga="enc:",Ba="aes-256-gcm",nd=12,si=null;async function La(){if(si)return si;let e=process.env.APP_KEY;if(!e)try{e=(await import("@stacksjs/config").catch(()=>null))?.config?.app?.key}catch{}if(!e)return null;return si=ed("sha256").update(e).digest(),si}function ue(e){return typeof e==="string"&&e.startsWith(Ga)}async function Ii(e){if(e==null)return e;if(ue(e))return e;if(typeof e!=="string")return e;let t=await La();if(!t)return ai.warn("[orm] encrypted attribute: APP_KEY not set - storing value in plaintext"),e;let n=td(nd),i=Yc(Ba,t,n),r=Buffer.concat([i.update(e,"utf8"),i.final()]),o=i.getAuthTag();return`${Ga}${n.toString("base64")}:${o.toString("base64")}:${r.toString("base64")}`}async function $i(e){if(e==null)return e;if(typeof e!=="string")return e;if(!ue(e))return e;try{let t=await La();if(!t)return ai.warn("[orm] encrypted attribute: APP_KEY not set - cannot decrypt"),null;let[,n,i,r]=e.split(":");if(!n||!i||!r)return ai.warn("[orm] encrypted attribute: malformed envelope, returning null"),null;let o=Buffer.from(n,"base64"),s=Buffer.from(i,"base64"),a=Buffer.from(r,"base64"),c=Zc(Ba,t,o);return c.setAuthTag(s),Buffer.concat([c.update(a),c.final()]).toString("utf8")}catch(t){return ai.warn("[orm] encrypted attribute: decrypt failed (key rotation? corrupted ciphertext?)",{error:t}),null}}function Ui(e){let t=e.attributes;if(!t||typeof t!=="object")return[];let n=[];for(let[i,r]of Object.entries(t))if(r&&typeof r==="object"&&r.encrypted===!0)n.push(i);return n}import{sqlDateTime as id}from"@stacksjs/database";import{log as pe}from"@stacksjs/logging";var rd=[/^password$/i,/^password_hash$/i,/^api_key$/i,/_token$/i,/_secret$/i,/^remember_token$/i],Ha="model_audits",Fi=null;function od(e){Fi=e}async function Mi(){if(Fi!=null)return Fi;try{let e=await import("@stacksjs/router").catch(()=>null);if(!e)return null;let t=e.getCurrentRequest;if(typeof t!=="function")return null;let n=t();if(!n)return null;return(n.user??n._user)?.id??null}catch{return null}}function li(e){if(!e||typeof e!=="object")return null;let t={};for(let[n,i]of Object.entries(e)){if(rd.some((r)=>r.test(n)))continue;t[n]=i}return t}function me(e){if(!e||typeof e!=="object")return null;let t=e;if(t._attributes&&typeof t._attributes==="object")return{...t._attributes};return{...e}}function sd(e,t){if(!e||!t)return{old:e,next:t};let n={},i={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of r)if(e[o]!==t[o])n[o]=e[o],i[o]=t[o];return{old:n,next:i}}async function Di(e,t=!1){try{let{db:n}=await import("@stacksjs/database");await n.insertInto(Ha).values({auditable_type:e.auditable_type,auditable_id:e.auditable_id,event:e.event,old_values:e.old_values?JSON.stringify(e.old_values):null,new_values:e.new_values?JSON.stringify(e.new_values):null,user_id:e.user_id,created_at:id()}).executeTakeFirst()}catch(n){if(pe.warn(`[orm] audit row write failed for ${e.auditable_type}#${String(e.auditable_id)} (${e.event})`,{error:n}),t)throw n}}function Va(e){return{async audits(t){try{let{db:n}=await import("@stacksjs/database");return(await n.selectFrom(Ha).selectAll().where("auditable_type","=",e).where("auditable_id","=",t).orderBy("created_at","desc").execute()??[]).map((r)=>({...r,old_values:typeof r.old_values==="string"?Ka(r.old_values):r.old_values,new_values:typeof r.new_values==="string"?Ka(r.new_values):r.new_values}))}catch(n){return pe.warn(`[orm] audits() lookup failed for ${e}#${String(t)}`,{error:n}),[]}}}}function Ka(e){try{return JSON.parse(e)}catch{return e}}function za(e){if(e&&typeof e==="object"&&"transactional"in e)return{transactional:e.transactional===!0};return{transactional:!1}}function Wa(e,t,n="id",i={}){let r=i.transactional===!0,o=e;if(typeof e.audits!=="function")e.audits=Va(t).audits;let s=async(u)=>{if(!r)return await u();let{db:m}=await import("@stacksjs/database");return await m.transaction(async()=>u())},a=e.create;if(typeof a==="function")e.create=async function(...u){return await s(async()=>{let m=await a.apply(this,u);try{let p=me(m),_=p?.[n];if(_!=null){let k=await Mi();await Di({auditable_type:t,auditable_id:_,event:"created",old_values:null,new_values:li(p),user_id:k},r)}}catch(p){if(pe.warn(`[orm] audit(create) failed for ${t}`,{error:p}),r)throw p}return m})};let c=e.update;if(typeof c==="function")e.update=async function(u,m){return await s(async()=>{let p=o.find,_=typeof p==="function"?me(await p.call(o,u)):null,k=await c.call(this,u,m);try{let g=me(k)??(typeof p==="function"?me(await p.call(o,u)):null),{old:y,next:R}=sd(_,g);if(R&&Object.keys(R).length>0){let v=await Mi();await Di({auditable_type:t,auditable_id:u,event:"updated",old_values:li(y),new_values:li(R),user_id:v},r)}}catch(g){if(pe.warn(`[orm] audit(update) failed for ${t}#${String(u)}`,{error:g}),r)throw g}return k})};let l=(u)=>{let m=e[u];if(typeof m!=="function")return;e[u]=async function(p){return await s(async()=>{let _=o.find,k=typeof _==="function"?me(await _.call(o,p)):null,g=await m.call(this,p);try{if(g!==!1&&k){let y=await Mi();await Di({auditable_type:t,auditable_id:p,event:"deleted",old_values:li(k),new_values:null,user_id:y},r)}}catch(y){if(pe.warn(`[orm] audit(${u}) failed for ${t}#${String(p)}`,{error:y}),r)throw y}return g})}};l("delete"),l("softDelete")}import{db as ad,sql as ld,sqlDateTime as Ni}from"@stacksjs/database";function G(e,t){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)throw Error(`[orm/commentable] ${t} requires a positive numeric id (received ${String(e)})`)}var fe="commentable_upvotes",_e="commentables";function cd(e){let t=e;return t.code==="SQLITE_CONSTRAINT_UNIQUE"||t.code==="SQLITE_CONSTRAINT"||t.code==="23505"||t.errno===1062||/unique|duplicate/i.test(t.message??"")}function Gi(e){let t=ad;return{async comments(n){return G(n,"comments"),await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).selectAll().execute()},async commentCount(n){let i=await t.selectFrom("commentables").select(ld`count(*) as count`).where("commentables_id","=",n).where("commentables_type","=",e).executeTakeFirst();return Number(i?.count)||0},async addComment(n,i){if(G(n,"addComment"),!i||typeof i.title!=="string"||i.title.trim().length===0)throw Error("[orm/commentable] addComment requires a non-empty comment.title");if(typeof i.body!=="string"||i.body.trim().length===0)throw Error("[orm/commentable] addComment requires a non-empty comment.body");let r=await t.insertInto("commentables").values({...i,commentables_id:n,commentables_type:e,status:"pending",created_at:Ni(),updated_at:Ni()}).returningAll().executeTakeFirst();if(r&&typeof r==="object"&&"id"in r)return r;let o=r?.lastInsertRowid;if(o==null)return r;return await t.selectFrom("commentables").where("id","=",Number(o)).selectAll().executeTakeFirst()},async approvedComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","approved").selectAll().execute()},async pendingComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","pending").selectAll().execute()},async rejectedComments(n){return await t.selectFrom("commentables").where("commentables_id","=",n).where("commentables_type","=",e).where("status","=","rejected").selectAll().execute()},async upvoteComment(n,i){G(n,"upvoteComment"),G(i,"upvoteComment");let r=()=>t.selectFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).selectAll().executeTakeFirst(),o=await r();if(o)return o;try{await t.insertInto(fe).values({upvoteable_id:n,upvoteable_type:_e,user_id:i,created_at:Ni()}).execute()}catch(s){if(!cd(s))throw s}return await r()},async removeCommentUpvote(n,i){G(n,"removeCommentUpvote"),G(i,"removeCommentUpvote"),await t.deleteFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).execute()},async commentUpvoteCount(n){G(n,"commentUpvoteCount");let i=await t.selectFrom(fe).select("count(*) as count").where("upvoteable_id","=",n).where("upvoteable_type","=",_e).executeTakeFirst();return Number(i?.count)||0},async hasUpvotedComment(n,i){return G(n,"hasUpvotedComment"),G(i,"hasUpvotedComment"),!!await t.selectFrom(fe).where("upvoteable_id","=",n).where("upvoteable_type","=",_e).where("user_id","=",i).selectAll().executeTakeFirst()}}}import{db as dd,sql as ud,sqlDateTime as Qa}from"@stacksjs/database";function Bi(e,t){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)throw Error(`[orm/taggable] ${t} requires a positive numeric id (received ${String(e)})`)}function Li(e){let t=dd;return{async tags(n){return Bi(n,"tags"),await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).selectAll().execute()},async tagCount(n){Bi(n,"tagCount");let i=await t.selectFrom("taggables").select(ud`count(*) as count`).where("taggable_id","=",n).where("taggable_type","=",e).executeTakeFirst();return Number(i?.count)||0},async addTag(n,i){if(Bi(n,"addTag"),!i||typeof i.name!=="string"||i.name.trim().length===0)throw Error("[orm/taggable] addTag requires a non-empty tag.name");return await t.insertInto("taggables").values({...i,taggable_id:n,taggable_type:e,slug:i.name.toLowerCase().replace(/[^a-z0-9]+/g,"-"),is_active:!0,created_at:Qa(),updated_at:Qa()}).execute(),await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("name","=",i.name).selectAll().executeTakeFirst()},async activeTags(n){return await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("is_active","=",!0).selectAll().execute()},async inactiveTags(n){return await t.selectFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("is_active","=",!1).selectAll().execute()},async removeTag(n,i){await t.deleteFrom("taggables").where("taggable_id","=",n).where("taggable_type","=",e).where("id","=",i).execute()}}}import{db as md,sqlDateTime as ci}from"@stacksjs/database";function Ki(e){let t=md;async function n(i){return(await t.selectFrom("categorizable_models").where("categorizable_id","=",i).where("categorizable_type","=",e).selectAll().execute()).map((o)=>o.category_id)}return{async categories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).selectAll().execute()},async categoryCount(i){return(await n(i)).length},async addCategory(i,r){let o=()=>t.selectFrom("categorizables").where("name","=",r.name).where("categorizable_type","=",e).selectAll().executeTakeFirst(),s=await o();if(!s)await t.insertInto("categorizables").values({name:r.name,description:r.description,slug:r.name.toLowerCase().replace(/[^a-z0-9]+/g,"-"),categorizable_type:e,is_active:!0,created_at:ci(),updated_at:ci()}).execute(),s=await o();return await t.insertInto("categorizable_models").values({categorizable_id:i,categorizable_type:e,category_id:s.id,created_at:ci(),updated_at:ci()}).execute(),s},async activeCategories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).where("is_active","=",!0).selectAll().execute()},async inactiveCategories(i){let r=await n(i);if(r.length===0)return[];return await t.selectFrom("categorizables").where("id","in",r).where("is_active","=",!1).selectAll().execute()},async removeCategory(i,r){await t.deleteFrom("categorizable_models").where("categorizable_id","=",i).where("categorizable_type","=",e).where("category_id","=",r).execute()}}}import{db as pd,sqlDateTime as fd}from"@stacksjs/database";function Hi(e,t){let n=pd,i=t?.table||`${e}_likes`,r=t?.foreignKey||`${e.replace(/s$/,"")}_id`;return{async likes(o){return await n.selectFrom(i).where(r,"=",o).selectAll().execute()},async likeCount(o){let s=await n.selectFrom(i).select("count(*) as count").where(r,"=",o).executeTakeFirst();return Number(s?.count)||0},async like(o,s){if(typeof o!=="number"||!Number.isFinite(o)||o<=0)throw Error(`[orm/likeable] like requires a positive numeric id (received ${String(o)})`);if(typeof s!=="number"||!Number.isFinite(s)||s<=0)throw Error(`[orm/likeable] like requires a positive numeric userId (received ${String(s)})`);let a=fd();try{return await n.insertInto(i).values({[r]:o,user_id:s,created_at:a,updated_at:a}).returningAll().executeTakeFirst()}catch(c){let l=c;if(!(l.code==="SQLITE_CONSTRAINT_UNIQUE"||l.code==="SQLITE_CONSTRAINT"||l.code==="23505"||l.errno===1062||/unique|duplicate/i.test(l.message??"")))throw c;let m=await n.selectFrom(i).where(r,"=",o).where("user_id","=",s).selectAll().executeTakeFirst();if(m)return m;throw c}},async unlike(o,s){await n.deleteFrom(i).where(r,"=",o).where("user_id","=",s).execute()},async isLiked(o,s){return!!await n.selectFrom(i).where(r,"=",o).where("user_id","=",s).selectAll().executeTakeFirst()},async likedBy(o){return(await n.selectFrom(i).select([r]).where("user_id","=",o).execute()).map((a)=>Number(a[r])).filter(Boolean)}}}function Xa(e){let t=e;return t?.code==="SQLITE_CONSTRAINT_UNIQUE"||t?.code==="SQLITE_CONSTRAINT"||t?.code==="23505"||t?.errno===1062||/unique|duplicate/i.test(t?.message??"")}function _d(e,t,n){let i=e;if(e instanceof Error&&typeof i.status==="number"&&Number.isInteger(i.status)&&i.status>=400&&i.status<600){let r={error:e.message};if(i.details!==void 0)r.details=i.details;return{status:i.status,body:r}}if(Xa(e))return{status:409,body:{error:`${t} already exists`}};return{status:500,body:{error:`Failed to ${n} ${t}`,detail:String(e)}}}function I(e){return e.replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toLowerCase()}function kd(e){let t={};for(let[n,i]of Object.entries(e))t[I(n)]=i;return t}function Nf(e,t){let n=String(t||"").replace(/^\/+|\/+$/g,""),i=String(e).replace(/^\/+/,"");return`/api/${n?`${n}/`:""}${i}`}function Gf(e){if(!e)return null;let t=e.attributes??{};if(Object.prototype.hasOwnProperty.call(t,"teamId")||Object.prototype.hasOwnProperty.call(t,"team_id"))return"team_id";return e.belongsTo?.some((n)=>n==="Team")?"team_id":null}function Bf(e,t,n){let i=Object.keys(e).find((o)=>I(o)===I(t));if(Array.isArray(n)){if(i===void 0)return{data:e,error:"Ownership value is required"};if(!n.some((o)=>String(o)===String(e[i])))return{data:e,error:"Ownership value is not available to this caller"};return{data:{...e,[t]:e[i]}}}if(n===null||n===void 0)return{data:e,error:"Caller has no ownership identity"};let r={...e};for(let o of Object.keys(r))if(I(o)===I(t))delete r[o];return r[t]=n,{data:r}}function bd(e){if(!e)return[];let t=Object.entries(e.attributes??{}).filter(([,n])=>n?.fillable===!0).map(([n])=>n);for(let n of e.belongsTo??[]){if(typeof n!=="string"||!n.trim())continue;let i=I(n.trim()).split("_").filter(Boolean);if(i.length===0)continue;let r=`${i[0]}${i.slice(1).map((o)=>`${o[0]?.toUpperCase()}${o.slice(1)}`).join("")}Id`;t.push(r)}return[...new Set(t)]}function gd(e,t){if(!e||t.length===0)return{};let n={};for(let i of t){if(i in e){n[i]=e[i];continue}let r=I(i);if(r!==i&&r in e)n[i]=e[r]}return n}function hd(e,t){if(e?.name!=="date"||t instanceof Date||typeof t!=="string")return t;let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!n)return t;let i=Number(n[1]),r=Number(n[2]),o=Number(n[3]),s=new Date(Date.UTC(i,r-1,o));if(s.getUTCFullYear()!==i||s.getUTCMonth()!==r-1||s.getUTCDate()!==o)return t;return s}function Lf(e,t){if(!t.length)return e;let n={...e};for(let i of t)delete n[i],delete n[I(i)];return n}function Kf(e,t){if(!e||t.length===0)return e;let n={...e};for(let i of t)delete n[i],delete n[I(i)];return n}var yd=["id","uuid","created_at","updated_at","deleted_at"];function Hf(e,t){let n=new Map;for(let i of[...Object.keys(e??{}),...yd]){let r=I(i);if(!/^\w+$/.test(r))continue;n.set(i,r),n.set(r,r)}for(let i of t)n.delete(i),n.delete(I(i));return n}function Vf(e,t,n){if(!t)return e;let i=String(t).split(",").map((o)=>o.trim()).filter(Boolean),r=e;for(let o of i){let s=o.startsWith("-"),a=s?o.slice(1):o;if(!/^\w+$/.test(a))continue;let c=n.get(a);if(!c)continue;r=r.orderBy(c,s?"desc":"asc")}return r}var Rd={string:{get:(e)=>e!=null?String(e):null,set:(e)=>e!=null?String(e):null},number:{get:(e)=>e!=null?Number(e):null,set:(e)=>e!=null?Number(e):null},integer:{get:(e)=>e!=null?Math.trunc(Number(e)):null,set:(e)=>e!=null?Math.trunc(Number(e)):null},float:{get:(e)=>e!=null?Number.parseFloat(String(e)):null,set:(e)=>e!=null?Number.parseFloat(String(e)):null},boolean:{get:(e)=>e===1||e==="1"||e===!0||e==="true",set:(e)=>e===!0||e===1||e==="1"||e==="true"?1:0},json:{get:(e)=>e==null?null:typeof e==="string"?Td(e):e,set:(e)=>e==null?null:typeof e==="string"?e:JSON.stringify(e)},datetime:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString():e},date:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString().split("T")[0]:e},array:{get:(e)=>e==null?[]:Array.isArray(e)?e:typeof e==="string"?wd(e):[],set:(e)=>e==null?null:Array.isArray(e)?JSON.stringify(e):e}};function Td(e){try{return JSON.parse(e)}catch{return e}}function wd(e){try{return JSON.parse(e)}catch{return[]}}function zf(e,t,n){if(!e||typeof e!=="object"||!t||Object.keys(t).length===0)return e;let i={...e};for(let[r,o]of Object.entries(t)){let s=typeof o==="string"?Rd[o]:o;if(!s||typeof s[n]!=="function")continue;if(Object.prototype.hasOwnProperty.call(i,r))i[r]=s[n](i[r]);let a=I(r);if(a!==r&&Object.prototype.hasOwnProperty.call(i,a))i[a]=s[n](i[a])}return i}function Ya(e,t,n){let i=t?.attributes??{},r={};for(let[o,s]of Object.entries(i)){let a=s?.validation?.rule;if(!a||typeof a.validate!=="function")continue;let c=Object.prototype.hasOwnProperty.call(e,o);if(!c&&n==="updating")continue;let l=s!==null&&typeof s==="object"&&Object.prototype.hasOwnProperty.call(s,"default"),u=c?e[o]:l?s.default:void 0,m=hd(a,u),p=a.validate(m);if(!p?.valid&&Array.isArray(p?.errors)&&p.errors.length>0)r[o]=p.errors.map((_)=>s?.validation?.message?.[_?.code]??_?.message??"invalid")}return Object.keys(r).length===0?{valid:!0}:{valid:!1,errors:r}}function Wf(e){return e.replace(/\{[^}]*\}/g,"{}").replace(/:[^/]+/g,"{}")}function Vi(e){if(Array.isArray(e))return e.filter((t)=>typeof t==="string"&&t.length>0);return typeof e==="string"&&e?[e]:[]}function Qf(e){let t=typeof e==="object"&&e!==null&&"middleware"in e,n=e?.middleware;if(!t)return{read:["auth"],write:["auth"],declared:!1};if(n&&typeof n==="object"&&!Array.isArray(n)){let r=n;return{read:"read"in r?Vi(r.read):["auth"],write:"write"in r?Vi(r.write):["auth"],declared:!0}}let i=Vi(n);return{read:i,write:i,declared:!0}}var Ja=15,vd=100;function Jf(e){let t=Number.parseInt(e.get("page")||String(1),10),n=Number.isFinite(t)?Math.max(1,t):1,i=Number.parseInt(e.get("per_page")||String(Ja),10),r=Math.min(Number.isFinite(i)?Math.max(1,i):Ja,vd);return{page:n,perPage:r,offset:(n-1)*r}}function di(e,t){let n=new URL(e.toString());return n.searchParams.set("page",String(t)),`${n.pathname}${n.search}`}function Sd(e,t,n,i,r,o){let s=(t-1)*n,a=i===0,c={page:t,per_page:n,from:a?null:s+1,to:a?null:s+i,has_more_pages:r,prev_page_url:t>1?di(e,t-1):null,next_page_url:r?di(e,t+1):null};if(o!==void 0&&!Number.isNaN(o)){let l=Math.max(1,Math.ceil(o/n));c.total=o,c.last_page=l,c.first_page_url=di(e,1),c.last_page_url=di(e,l)}return c}function Xf(e,t,n,i,r,o){let{page:s,...a}=Sd(e,t,n,i,r,o);return{current_page:s,...a}}import{cacheRequestQuery as xd}from"@stacksjs/router";var ui=new WeakMap;function e_(e,t){return xd(`batchLoad:${e.name??"model"}:${String(t)}`,async()=>new Promise((n,i)=>{let r=ui.get(e);if(!r)r={keys:[],resolvers:[],scheduled:!1},ui.set(e,r);if(r.keys.push(t),r.resolvers.push({key:t,resolve:n,reject:i}),r.scheduled)return;r.scheduled=!0,Promise.resolve().then(async()=>{let o=ui.get(e);if(!o)return;ui.delete(e);let s=Array.from(new Set(o.keys));try{let a=typeof e.findMany==="function"?await e.findMany(s):await Promise.all(s.map((l)=>e.find?.(l))),c=new Map;for(let l of a??[]){let u=l?.id;if(u!==void 0)c.set(u,l)}for(let l of o.resolvers)l.resolve(c.get(l.key))}catch(a){for(let c of o.resolvers)c.reject(a)}})}))}import{db as r_}from"@stacksjs/database";class Cd{conditions=[];where(e,...t){let[n,i]=t,r=i===void 0?"=":n,o=i===void 0?n:i;this.addCondition("and","where",e,r,o)}orWhere(e,...t){let[n,i]=t,r=i===void 0?"=":n,o=i===void 0?n:i;this.addCondition("or","where",e,r,o)}whereIn(e,t){this.conditions.push({type:"and",method:"whereIn",column:e,values:t})}whereNotIn(e,t){this.conditions.push({type:"and",method:"whereIn",column:e,values:t,operator:"not in"})}whereNull(e){this.conditions.push({type:"and",method:"whereNull",column:e})}whereNotNull(e){this.conditions.push({type:"and",method:"whereNotNull",column:e})}whereBetween(e,t){this.conditions.push({type:"and",method:"whereBetween",column:e,range:t})}whereExists(e){this.conditions.push({type:"and",method:"whereExists",column:"",callback:e})}addCondition(e,t,n,i,r){this.conditions.push({type:e,method:t,column:n,operator:i,value:r})}getConditions(){return this.conditions}}import{db as zi,runInTransactionScope as jd}from"@stacksjs/database";async function a_(e,t){return await jd(async()=>await zi.transaction(e,t))}async function l_(e){return await zi.savepoint(e)}function c_(e,t){return zi.transactional(e,t)}import{path as B}from"@stacksjs/path";import{fs as ne,globSync as Xi}from"@stacksjs/storage";import{plural as il,singular as Za,snakeCase as E}from"@stacksjs/strings";import{isString as mi}from"@stacksjs/validation";function rl(e){let t=e.belongsToMany;if(!t)return[];if(Array.isArray(t))return t.map((n)=>({relationName:typeof n==="string"?E(n):E(String(n.model)),relation:n}));return Object.entries(t).map(([n,i])=>{if(typeof i==="string")return{relationName:n,relation:i};return{relationName:n,relation:{model:i.model,pivotTable:i.table,firstForeignKey:i.foreignKey,secondForeignKey:i.relatedKey}}})}async function __(e){if(typeof e==="string")e=(await import(e)).default;return e.table??E(il(e?.name||""))}function ke(e,t){if(e.name)return e.name;return B.basename(t).replace(/\.ts$/,"")}function F(e,t){if(e.table)return e.table;return E(il(ke(e,t)))}function Pd(e,t){let n=[e,t];return n.sort(),n.join("_")}function k_(e,t){return t in e}async function Ed(e,t){let n=[];if(e.hasOne)for(let i of e.hasOne)n.push(await Wi(i,e,t,"hasOne"));if(e.hasMany)for(let i of e.hasMany)n.push(await Wi(i,e,t,"hasMany"));if(e.belongsTo)for(let i of e.belongsTo)n.push(await Wi(i,e,t,"belongsTo"));if(e.hasOneThrough)for(let i of e.hasOneThrough)n.push(await tl(i,e,t,"hasOneThrough"));if(e.hasManyThrough)for(let i of e.hasManyThrough)n.push(await tl(i,e,t,"hasManyThrough"));if(e.belongsToMany)for(let{relationName:i,relation:r}of rl(e))n.push(await Od(r,e,t,"belongsToMany",i));if(e.morphOne)n.push(await nl(e.morphOne,e,t,"morphOne"));if(e.morphMany){let i=Array.isArray(e.morphMany)?e.morphMany:[e.morphMany];for(let r of i)n.push(await nl(r,e,t,"morphMany"))}if(e.morphTo){let i=e.morphTo,r=Array.isArray(i)?i:typeof i==="object"&&i!==null?[i]:[];for(let o of r)n.push(qd(o,e,t))}if(e.morphToMany){let i=Array.isArray(e.morphToMany)?e.morphToMany:[e.morphToMany];for(let r of i)n.push(el(r,e,t,"morphToMany"))}if(e.morphedByMany){let i=Array.isArray(e.morphedByMany)?e.morphedByMany:[e.morphedByMany];for(let r of i)n.push(el(r,e,t,"morphedByMany"))}return n}function qd(e,t,n){let i=e&&typeof e==="object"&&e.name?String(e.name):`${E(n)}able`,r=e?.type||`${i}_type`;return{relationship:"morphTo",model:"",table:"",relationTable:"",foreignKey:e?.id||`${i}_id`,modelKey:r,relationName:i,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:"",pivotKey:"",pivotTable:""}}function el(e,t,n,i){let r=typeof e==="object"&&e!==null,o=r?String(e.model||""):String(e),s=r&&e.morphName?String(e.morphName):`${E(n)}able`,a=r&&e.pivotTable?String(e.pivotTable):s,c=r&&e.id||`${s}_id`,l=r&&e.type||`${s}_type`;return{relationship:i,model:o,table:"",relationTable:"",foreignKey:c,modelKey:l,relationName:s,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:c,pivotKey:l,pivotTable:a}}async function pi(e,t){let n=Ji(`${t}.ts`),i=Ji(`${e}.ts`),r=Qi(`${e}.ts`),o=Qi(`${t}.ts`);if(!n&&!o)throw Error(`Model not found: ${t}`);if(!i&&!r)throw Error(`Model not found: ${e}`);let s;try{if(ne.existsSync(n))s=(await import(n)).default;else s=(await import(o)).default}catch(c){throw Error(`Failed to load model: ${t}. Error: ${c?.message||"Unknown error"}`)}let a=ne.existsSync(i)?i:r;return{modelRelation:s,modelPath:a,modelRelationPath:ne.existsSync(n)?n:o}}async function tl(e,t,n,i){let r="",o="",s="",a="";if(mi(e))r=e;else r=e.model,o=e.relationName||"",s=e.through,a=e.throughForeignKey||"";let{modelRelation:c,modelPath:l,modelRelationPath:u}=await pi(n,r),m=F(c,u),p=F(t,l),_=E(ke(c,u)),k=E(n);return{relationship:i,model:r,table:m,relationTable:p,foreignKey:`${k}_id`,modelKey:`${_}_id`,relationName:o,relationModel:n,throughModel:s,throughForeignKey:a,pivotForeign:`${k}_id`,pivotKey:`${_}_id`,pivotTable:p}}async function Od(e,t,n,i,r){let o="",s="",a="",c=E(n);if(mi(e))o=e;else o=e.model,s=e.pivotTable||"",a=e.firstForeignKey||`${c}_id`;let{modelRelation:l,modelPath:u,modelRelationPath:m}=await pi(n,o),p=F(l,m),_=F(t,u),k=E(ke(l,m));return{relationship:i,model:o,table:p,relationTable:_,foreignKey:typeof e==="string"?`${c}_id`:e.firstForeignKey||`${c}_id`,modelKey:typeof e==="string"?`${k}_id`:e.secondForeignKey||`${k}_id`,relationName:r,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:a,pivotKey:`${k}_id`,pivotTable:s}}async function nl(e,t,n,i){let r="",o="",s="",a="";if(mi(e))r=e,o=`${E(n)}able`;else r=e.model,o=e.morphName||`${E(n)}able`,s=e.type||`${o}_type`,a=e.id||`${o}_id`;let{modelRelation:c,modelPath:l,modelRelationPath:u}=await pi(n,r),m=F(c,u),p=F(t,l);return{relationship:i,model:r,table:m,relationTable:p,foreignKey:a||`${o}_id`,modelKey:s||`${o}_type`,relationName:o,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:"",pivotKey:"",pivotTable:p}}async function Wi(e,t,n,i){let r="",o="";if(mi(e))r=e;else r=e.model,o=e.relationName||"";let{modelRelation:s,modelPath:a,modelRelationPath:c}=await pi(n,r),l=F(s,c),u=F(t,a),m=E(ke(s,c)),p=E(n),_=typeof e==="string"?"":e.foreignKey||"",k={relationship:i,model:r,table:l,relationTable:u,foreignKey:_||`${p}_id`,modelKey:`${m}_id`,relationName:o,relationModel:n,throughModel:"",throughForeignKey:"",pivotForeign:`${p}_id`,pivotKey:`${m}_id`,pivotTable:u};if(i==="belongsTo"){if(k.foreignKey="",_)k.modelKey=_}return k}function b_(e){let t=/belongs/,n=/has/,i=/Through/,r=/morph/;if(i.test(e))return"throughType";if(t.test(e))return"belongsType";if(n.test(e))return"hasType";if(r.test(e))return"morphType";return""}function g_(e){let t=/One/;if(/Many/.test(e))return"many";if(t.test(e))return"one";return""}async function h_(e,t){let n=[];if("belongsToMany"in e){for(let{relation:i}of rl(e)){let r,o;if(typeof i==="string")o=i;else o=i.model;let s=Ji(`${o}.ts`),a=Qi(`${o}.ts`);if(ne.existsSync(s))r=(await import(s)).default;else r=(await import(a)).default;let c=F(r,s),l=F(e,t),u=typeof i==="object"&&"firstForeignKey"in i?i.firstForeignKey:`${Za(l)}_${e.primaryKey}`,m=typeof i==="object"&&"secondForeignKey"in i?i.secondForeignKey:`${Za(c)}_${e.primaryKey}`;n.push({table:(typeof i==="object"&&"pivotTable"in i?i.pivotTable:void 0)??Pd(l,c),firstForeignKey:u,secondForeignKey:m})}return n}return[]}async function y_(e){let t=Xi([B.userModelsPath("*.ts"),B.storagePath("framework/defaults/app/Models/**/*.ts")],{absolute:!0}),n=[];for(let i=0;i<t.length;i++){let r=t[i],o=await import(r);if(e===o.default.name)continue;let s=ke(o,r),a=await Ed(o.default,s);if(!a.length)continue;let c=a.find((l)=>l.model===e);if(c)n.push(c)}return n}function R_(e){if(e===void 0)return[];return Object.keys(e).filter((t)=>e[t]?.hidden===!0)}function T_(e){let t=e.attributes;if(t===void 0)return[];return Object.keys(t).filter((n)=>t[n]?.guarded===!0).map((n)=>E(n))}function w_(e,t){let n=e.attributes,i=[];if(n===void 0)return[];let r=typeof e.traits?.billable==="object"||typeof e.traits?.billable==="boolean",o=typeof e.traits?.useAuth==="object"?e.traits?.useAuth.usePasskey:!1,s=e.traits?.useUuid||!1;if(r)i.push("stripe_id");if(s)i.push("uuid");if(o)i.push(...["two_factor_secret","public_key"]);let a=t.map((c)=>c.foreignKey).filter((c)=>c);return[...Object.keys(n).filter((c)=>{if(n===void 0)return!1;return n[c]?.fillable===!0}).map((c)=>E(c)),...i,...a]}async function v_(e,t){let n=e.attributes;if(!n)n={};let i=Object.keys(n),r=[],o=Bun.file(t),s="";try{if(await o.exists())s=await o.text()}catch{s=""}let a=/rule:.*$/gm,c;c=a.exec(s);while(c!==null)r.push(c[0]),c=a.exec(s);return i.map((u,m)=>{let p=n[u],_=null,k=!1,g=!1,y=!1,R=!1;if(p)_=p||null,k=p.unique||!1,g=p.hidden||!1,y=p.fillable||!1;let v=r[m]??"";return R=(p.validation?.rule).isRequired??!1,{field:u,default:_,unique:k,hidden:g,fillable:y,required:R,fieldArray:Ad(v)}})}function Ad(e){let t=e.split("rule: schema.");if(t.length!==2)return null;if(!t[1])t[1]="";let n=t[1].replace(/,/g,"");if(!n)return null;let i=n.split("."),r=/\(([^)]+)\)/;return i.map((o)=>{let s=r.exec(o),a=s?s[1]:null;return{entity:o.replace(r,"").replace(/\(|\)/g,""),charValue:a}})[0]||null}function S_(e){let t=e.fieldArray?.entity;switch(t){case"enum":return"string | string[]";case"date":return"Date | string";case"timestamp":return"Date | string";case"datetime":return"Date | string";case"float":return"number";case"double":return"number";case"decimal":return"number";case"integer":return"number";case"bigint":return"number";default:return t}}function Qi(e){let t=B.join(B.storagePath("framework/defaults/app/Models"),"/"),n=B.join(t,e);if(ne.existsSync(n))return n;return Xi(`${t}**/${e}`,{absolute:!0})[0]??""}function Ji(e){let t=B.join(B.userModelsPath("/"),"/"),n=B.join(t,e);if(ne.existsSync(n))return n;return Xi(`${t}**/${e}`,{absolute:!0})[0]??""}function x_(e){let t=typeof e==="number"?new Date(e):typeof e==="string"?new Date(e):e;if(Number.isNaN(t.getTime()))throw Error(`Invalid date value: ${String(e)}`);return t.toISOString().replace("T"," ").split(".")[0]??""}function C_(e){return e.toISOString().split("T")[0]??""}function j_(e){return e.getTime()}import{createModel as vu,registerModel as Su}from"@stacksjs/query-builder";import{log as A}from"@stacksjs/logging";import{snakeCase as H}from"@stacksjs/strings";import{AsyncLocalStorage as Ec}from"async_hooks";function Id(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&typeof t.current_page==="number"&&typeof t.per_page==="number"&&typeof t.total==="number"&&typeof t.last_page==="number"}function $d(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&typeof t.current_page==="number"&&typeof t.per_page==="number"&&typeof t.has_more_pages==="boolean"&&!("total"in t)}function Ud(e){if(e===null||typeof e!=="object")return!1;let t=e;return Array.isArray(t.data)&&(typeof t.next_cursor==="string"||t.next_cursor===null)}function Yi(e){let{data:t}=e,{perPage:n,page:i,total:r,lastPage:o}=e.meta,s=t.length===0,a=s?null:(i-1)*n+1,c=s?null:a+t.length-1;return{data:t,current_page:i,per_page:n,total:r,last_page:o,from:a,to:c,has_more_pages:i<o}}function Zi(e){return{data:e.data,current_page:e.meta.page,per_page:e.meta.perPage,has_more_pages:e.meta.hasMore}}function er(e){return{data:e.data,per_page:e.meta.perPage,next_cursor:ol(e.meta.nextCursor),prev_cursor:ol(e.meta.prevCursor),has_more_pages:e.meta.nextCursor!==null&&e.meta.nextCursor!==void 0}}function ol(e){if(e===null||e===void 0)return null;if(typeof e==="string")return e;return JSON.stringify(e)}function nr(e,t){let n=or(),i=n?tr(n,"per_page"):void 0,r=n?tr(n,"page"):void 0,o=e!==void 0?Math.max(1,Math.floor(e)):Math.min(100,Math.max(1,i??15)),s=Math.max(1,Math.floor(t??r??1));return{perPage:o,page:s}}function ir(e,t){let n=or(),i=n?al(n,"cursor"):void 0,r=n?tr(n,"per_page"):void 0,o=e!==void 0?Math.max(1,Math.floor(e)):Math.min(100,Math.max(1,r??15)),a=sl(t!==void 0?t:i??null);return{perPage:o,cursor:a}}function sl(e){if(e===null||e===void 0)return null;if(Array.isArray(e))return e;if(typeof e==="string"&&e.startsWith("["))try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e}function rr(e){let t=or();if(!t)return e;let n=(()=>{try{return new URL(t.url)}catch{return null}})();if(!n)return e;let i=n.pathname;if(e.path=i,"next_cursor"in e)return e.next_page_url=e.next_cursor!==null?Y(n,{cursor:e.next_cursor}):null,e.prev_page_url=e.prev_cursor!==null?Y(n,{cursor:e.prev_cursor}):null,e;let r=e.current_page;if(e.prev_page_url=r>1?Y(n,{page:r-1}):null,"total"in e){let o=e.last_page;e.next_page_url=r<o?Y(n,{page:r+1}):null,e.first_page_url=Y(n,{page:1}),e.last_page_url=Y(n,{page:o})}else e.next_page_url=e.has_more_pages?Y(n,{page:r+1}):null;return e}function Y(e,t){let n=new URL(e.toString());for(let[i,r]of Object.entries(t))n.searchParams.set(i,String(r));return`${n.pathname}${n.search}`}var ie;function or(){if(ie===null)return;if(ie===void 0)try{let t=T("@stacksjs/router");if(typeof t.getCurrentRequest==="function")ie=t.getCurrentRequest;else{ie=null;return}}catch{ie=null;return}return ie()}function tr(e,t){let n=al(e,t);if(n===void 0)return;let i=Number(n);return Number.isFinite(i)?i:void 0}function al(e,t){let n=e.query?.[t];if(n===void 0)return;return Array.isArray(n)?n[0]:n}import{db as yu}from"@stacksjs/database";function hc(e){let t=yu;return{async createStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.createStripeCustomer(n,i)},async updateStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.updateStripeCustomer(n,i)},async deleteStripeUser(n){let{manageCustomer:i}=await import("@stacksjs/payments");return await i.deleteStripeUser(n)},async createOrGetStripeUser(n,i){let{manageCustomer:r}=await import("@stacksjs/payments");return await r.createOrGetStripeUser(n,i)},async retrieveStripeUser(n){let{manageCustomer:i}=await import("@stacksjs/payments");return await i.retrieveStripeUser(n)},async defaultPaymentMethod(n){let{managePaymentMethod:i}=await import("@stacksjs/payments");return await i.retrieveDefaultPaymentMethod(n)},async setDefaultPaymentMethod(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.setDefaultPaymentMethod(n,i)},async addPaymentMethod(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.addPaymentMethod(n,i)},async paymentMethods(n,i){let{managePaymentMethod:r}=await import("@stacksjs/payments");return await r.listPaymentMethods(n,i)},async newSubscription(n,i,r,o={}){let{manageSubscription:s}=await import("@stacksjs/payments"),a=await s.create(n,i,r,o),l=a.latest_invoice?.payment_intent;return{subscription:a,paymentIntent:l}},async updateSubscription(n,i,r,o={}){let{manageSubscription:s}=await import("@stacksjs/payments"),a=await s.update(n,i,r,o),l=a.latest_invoice?.payment_intent;return{subscription:a,paymentIntent:l}},async cancelSubscription(n,i,r={}){let{manageSubscription:o}=await import("@stacksjs/payments");return{subscription:await o.cancel(i,r)}},async activeSubscription(n){let{manageSubscription:i}=await import("@stacksjs/payments"),r=await t.selectFrom("subscriptions").where("user_id","=",n.id).where("provider_status","=","active").selectAll().executeTakeFirst();if(r){let o=await i.retrieve(n,r.provider_id||"");return{subscription:r,providerSubscription:o}}return},async checkout(n,i,r={}){let{manageCheckout:o,manageCustomer:s}=await import("@stacksjs/payments"),a={};if(r.enableTax)a.automatic_tax={enabled:!0},delete r.enableTax;if(r.allowPromotions)a.allow_promotion_codes=!0,delete r.allowPromotions;let u={...{mode:"payment",customer:(await s.createOrGetStripeUser(n,{})).id,line_items:i.map((m)=>({price:m.priceId,quantity:m.quantity||1}))},...a,...r};return await o.create(n,u)},async createSetupIntent(n,i={}){let{manageSetupIntent:r}=await import("@stacksjs/payments");return await r.create(n,i)},async subscriptionHistory(n){let{manageInvoice:i}=await import("@stacksjs/payments");return await i.list(n)},async transactionHistory(n){let{manageTransaction:i}=await import("@stacksjs/payments");return await i.list(n)},async connectAccount(n,i={}){let r=i.accountColumn||"stripe_account_id",o=(n._attributes??n)[r];if(!o)return null;let s=await ti();try{return await s.accounts.retrieve(o)}catch{return null}},async createConnectAccount(n,i={}){let r=i.accountColumn||"stripe_account_id",o=n._attributes??n,s=o[r],a=await ti();if(!s){let{stacksIdempotencyKey:c}=await import("@stacksjs/payments"),l=i.modelTable||e,u=await a.accounts.create({type:i.type??"express",email:i.email??o.email,country:i.country??"US",capabilities:i.capabilities??{card_payments:{requested:!0},transfers:{requested:!0}}},{idempotencyKey:c("connect.account.create",l,o.id)});return s=u.id,await t.updateTable(l).set({[r]:s}).where("id","=",Number(o.id)).execute(),u}return await a.accounts.retrieve(s)},async connectOnboardLink(n,i){let r=i.accountColumn||"stripe_account_id",s=(n._attributes??n)[r];if(!s)throw Error("connectOnboardLink: model has no Stripe Connect account; call createConnectAccount first");return{url:(await(await ti()).accountLinks.create({account:s,refresh_url:i.refreshUrl,return_url:i.returnUrl,type:i.type??"account_onboarding"})).url,accountId:s}},async syncConnectStatus(n,i={}){let r=i.accountColumn||"stripe_account_id",o=i.chargesColumn||"charges_enabled",s=i.payoutsColumn||"payouts_enabled",a=n._attributes??n,c=a[r];if(!c)return{chargesEnabled:!1,payoutsEnabled:!1};let u=await(await ti()).accounts.retrieve(c),m=!!u.charges_enabled,p=!!u.payouts_enabled,_=i.modelTable||e;return await t.updateTable(_).set({[o]:m,[s]:p}).where("id","=",Number(a.id)).execute(),{chargesEnabled:m,payoutsEnabled:p}},async chargeWithSplit(n,i){let r=await ti(),o=i.accountColumn||"stripe_account_id",s=n._attributes??n,a=i.connectAccountId||s[o],c={amount:i.amountCents,currency:i.currency||"usd",automatic_payment_methods:{enabled:!0},metadata:i.metadata};if(a){if(c.transfer_data={destination:a},i.platformFeeCents)c.application_fee_amount=i.platformFeeCents}let{freshIdempotencyKey:l}=await import("@stacksjs/payments");return await r.paymentIntents.create(c,{idempotencyKey:l("payment_intent.create",s.id,i.amountCents)})}}}async function ti(){let e=globalThis.process?.env?.STRIPE_SECRET_KEY;if(!e)throw Error("Stripe Connect: STRIPE_SECRET_KEY not configured");return new(await Promise.resolve().then(() => (gc(),bc))).default(e,{apiVersion:"2026-06-24.dahlia"})}function yc(){return{async generateTwoFactorForModel(e){let{generateTwoFactorSecret:t}=await import("@stacksjs/auth"),n=t();await e.update({two_factor_secret:n})},async verifyTwoFactorCode(e,t){let n=e.get("two_factor_secret");if(typeof n!=="string")return!1;let{verifyTwoFactorCode:i,RateLimiter:r}=await import("@stacksjs/auth"),o=String(e.id??e.get?.("id")??e.get?.("email")??n),s=`2fa:${o}`;if(await r.isRateLimited(s)){let{HttpError:c}=await import("@stacksjs/error-handling");throw new c(429,"Too many verification attempts. Please try again later.")}if(!await i(t,n))return await r.recordFailedAttempt(s),!1;try{let{cache:c}=await import("@stacksjs/cache"),l=`2fa:used:${o}:${t}`;if(await c.has(l))return await r.recordFailedAttempt(s),!1;await c.set(l,"1",90)}catch{}return await r.resetAttempts(s),!0}}}import{sqlDateTime as Ru}from"@stacksjs/database";import{log as le}from"@stacksjs/logging";var Pi="deleted_at";function Rc(e,t="id"){return{async softDelete(n){let i=Ru(),r=e.where(t,n);if(typeof r?.update==="function")return await r.update({[Pi]:i}),!0;return!1},async restore(n){let i=e.where(t,n);if(typeof i?.update==="function")return await i.update({[Pi]:null}),!0;return!1},async forceDelete(n){let i=e.where(t,n);if(typeof i?.delete==="function")return await i.delete(),!0;return!1},withTrashed(){return typeof e.query==="function"?e.query():e},onlyTrashed(){let n=typeof e.query==="function"?e.query():e;if(typeof n?.whereNotNull==="function")return n.whereNotNull(Pi);return n?.where?.(Pi,"!=",null)??n}}}function Tc(e){if(e===!0||e==null)return{};if(typeof e==="object"&&!Array.isArray(e)){let t=e;if(Array.isArray(t.cascade)){let n=t.cascade.filter((i)=>typeof i==="string");return n.length?{cascade:n}:{}}return{}}return{}}function Tu(e,t){let n=e.hasMany??[],i=e.hasOne??[],r=n.some((u)=>Ia(u,t,!0)),o=i.some((u)=>Ia(u,t,!1));if(!r&&!o)return le.warn(`[orm] soft-delete cascade: '${t}' is not a declared hasMany/hasOne relation - skipping`),null;let a=(r?n:i).find((u)=>Ia(u,t,r))??null;if(!a)return null;let l=globalThis[a];if(!l)return le.warn(`[orm] soft-delete cascade: model '${a}' is not yet on globalThis - skipping cascade for '${t}'`),null;return{className:a,model:l}}function Ia(e,t,n){let i=e.toLowerCase();if(t===i)return!0;if(n&&t===`${i}s`)return!0;if(n&&i.endsWith("y")&&t===`${i.slice(0,-1)}ies`)return!0;return!1}async function wu(e,t,n,i,r){try{let o=n.where;if(typeof o!=="function"){le.warn(`[orm] cascade ${r}: child model has no .where()`);return}if(r==="softDelete"){let s=n.softDelete;if(typeof s==="function"){let c=o.call(n,i,t),l=typeof c?.get==="function"?await c.get():Array.isArray(c)?c:[],u=n.primaryKey||"id";for(let m of l){let p=m?.[u];if(p!=null)await s.call(n,p)}return}let a=o.call(n,i,t);if(typeof a?.delete==="function"){le.debug(`[orm] cascade soft-delete: child has no softDeletes trait, hard-deleting from ${String(n.table??"?")}`),await a.delete();return}}else{let s=n.restore;if(typeof s!=="function"){le.debug("[orm] cascade restore: child has no restore() - nothing to do");return}let a=n.withTrashed,l=(typeof a==="function"?a.call(n):n).where?.(i,t),u=typeof l?.get==="function"?await l.get():[],m=n.primaryKey||"id";for(let p of u){let _=p?.[m];if(_!=null)await s.call(n,_)}}}catch(o){if(le.warn(`[orm] soft-delete cascade ${r} on ${e}#${String(t)} failed`,{error:o}),process.env.STACKS_ORM_CASCADE_SWALLOW!=="true")throw o}}async function ni(e,t,n,i){let r=t.cascade;if(!r||r.length===0)return;let o=`${e.name.toLowerCase()}_id`;for(let s of r){let a=Tu(e,s);if(!a)continue;await wu(a.className,n,a.model,o,i)}}var qc=new Ec;function te(){return qc.getStore()?.suppressed===!0}function ee(e){return Promise.resolve(qc.run({suppressed:!0},e))}var Oc=new Ec;function xu(){return Oc.getStore()?.suppressed===!0}function Cu(e){return Promise.resolve(Oc.run({suppressed:!0},e))}var Fa=Symbol.for("stacks.orm.modelDefinition");class Ac extends Error{status=422;errors;constructor(e,t){let n=Object.keys(t).join(", ");super(`${e} validation failed: ${n}`);this.name="ModelValidationError",this.errors=t}}var wc=new Set;function ju(e,t){let n=typeof e==="string"?e.slice(0,80):String(e),i=`${typeof e}:${n}`;if(wc.has(i))return;wc.add(i);let r=t instanceof Error?t.message:String(t);console.error(`[orm] JSON cast failed to parse value (returning null): ${r} - value preview: ${JSON.stringify(n)}`)}var Pu={string:{get:(e)=>e!=null?String(e):null,set:(e)=>e!=null?String(e):null},number:{get:(e)=>e!=null?Number(e):null,set:(e)=>e!=null?Number(e):null},integer:{get:(e)=>e!=null?Math.trunc(Number(e)):null,set:(e)=>e!=null?Math.trunc(Number(e)):null},float:{get:(e)=>e!=null?Number.parseFloat(String(e)):null,set:(e)=>e!=null?Number.parseFloat(String(e)):null},boolean:{get:(e)=>e===1||e==="1"||e===!0||e==="true",set:(e)=>e===!0||e===1||e==="1"||e==="true"?1:0},json:{get:(e)=>{if(e==null)return null;if(typeof e==="string")try{return JSON.parse(e)}catch(t){return ju(e,t),null}return e},set:(e)=>{if(e==null)return null;return typeof e==="string"?e:JSON.stringify(e)}},datetime:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString():e},date:{get:(e)=>e?new Date(e):null,set:(e)=>e instanceof Date?e.toISOString().split("T")[0]:e},array:{get:(e)=>{if(e==null)return[];if(Array.isArray(e))return e;if(typeof e==="string")try{return JSON.parse(e)}catch{return[]}return[]},set:(e)=>{if(e==null)return null;return Array.isArray(e)?JSON.stringify(e):e}}};function Ic(e){return typeof e==="string"?Pu[e]:e}function vc(e,t,n){if(!e||typeof e!=="object")return e;let i={...e};for(let[r,o]of Object.entries(t))if(r in i){let s=Ic(o);i[r]=s[n](i[r])}return i}var Ei=new Set(["_attributes","_original","_definition","_hasSaved","_relations"]),Sc=Symbol.for("stacks.modelInstanceProxy"),Eu={tags:{bag:"_taggable",mode:"id"},tagCount:{bag:"_taggable",mode:"id"},addTag:{bag:"_taggable",mode:"id"},activeTags:{bag:"_taggable",mode:"id"},inactiveTags:{bag:"_taggable",mode:"id"},removeTag:{bag:"_taggable",mode:"id"},categories:{bag:"_categorizable",mode:"id"},categoryCount:{bag:"_categorizable",mode:"id"},addCategory:{bag:"_categorizable",mode:"id"},activeCategories:{bag:"_categorizable",mode:"id"},inactiveCategories:{bag:"_categorizable",mode:"id"},removeCategory:{bag:"_categorizable",mode:"id"},comments:{bag:"_commentable",mode:"id"},commentCount:{bag:"_commentable",mode:"id"},addComment:{bag:"_commentable",mode:"id"},approvedComments:{bag:"_commentable",mode:"id"},pendingComments:{bag:"_commentable",mode:"id"},rejectedComments:{bag:"_commentable",mode:"id"},likes:{bag:"_likeable",mode:"id"},likeCount:{bag:"_likeable",mode:"id"},like:{bag:"_likeable",mode:"id"},unlike:{bag:"_likeable",mode:"id"},isLiked:{bag:"_likeable",mode:"id"},createStripeUser:{bag:"_billable",mode:"model"},updateStripeUser:{bag:"_billable",mode:"model"},deleteStripeUser:{bag:"_billable",mode:"model"},createOrGetStripeUser:{bag:"_billable",mode:"model"},retrieveStripeUser:{bag:"_billable",mode:"model"},defaultPaymentMethod:{bag:"_billable",mode:"model"},setDefaultPaymentMethod:{bag:"_billable",mode:"model"},addPaymentMethod:{bag:"_billable",mode:"model"},paymentMethods:{bag:"_billable",mode:"model"},newSubscription:{bag:"_billable",mode:"model"},updateSubscription:{bag:"_billable",mode:"model"},cancelSubscription:{bag:"_billable",mode:"model"},activeSubscription:{bag:"_billable",mode:"model"},checkout:{bag:"_billable",mode:"model"},createSetupIntent:{bag:"_billable",mode:"model"},subscriptionHistory:{bag:"_billable",mode:"model"},transactionHistory:{bag:"_billable",mode:"model"},connectAccount:{bag:"_billable",mode:"model"},createConnectAccount:{bag:"_billable",mode:"model"},connectOnboardLink:{bag:"_billable",mode:"model"},syncConnectStatus:{bag:"_billable",mode:"model"},chargeWithSplit:{bag:"_billable",mode:"model"},generateTwoFactorForModel:{bag:"_twoFactor",mode:"model"},verifyTwoFactorCode:{bag:"_twoFactor",mode:"model"}};function qu(e,t){if(!e||!t)return null;let n=t.split("."),i=e;for(let r of n){if(i==null||typeof i!=="object")return null;let o=i;if("_attributes"in o&&o._attributes&&typeof o._attributes==="object"){let s=o._attributes;if(r in s){i=s[r];continue}}if(r in o){i=o[r];continue}return null}return i??null}function D(e,t){if(!e||typeof e!=="object")return e;if(e[Sc])return e;let n=e._attributes;if(!n||typeof n!=="object")return e;if(t&&Object.keys(t).length>0){for(let[i,r]of Object.entries(t))if(Object.prototype.hasOwnProperty.call(n,i))n[i]=Ic(r).get(n[i])}return new Proxy(e,{get(i,r,o){if(r===Sc)return!0;if(r==="saveAsync")return async function(){let a=i._definition,c=a?.set;if(c&&typeof i.isDirty==="function"){for(let[u,m]of Object.entries(c)){if(typeof m!=="function")continue;if(!i.isDirty(u))continue;let p=m(i._attributes),_=p&&typeof p.then==="function"?await p:p;i._attributes[u]=_}let l=a.set;a.set={};try{return i.save()}finally{a.set=l}}return i.save()};if(r==="save")return function(){let a=i._definition,c=a?.set;if(c&&Object.keys(c).length>0&&typeof i.isDirty==="function"){for(let[u,m]of Object.entries(c)){if(typeof m!=="function")continue;if(!i.isDirty(u))continue;let p=m(i._attributes);if(p&&typeof p.then==="function")throw Error(`Setter for "${u}" returned a Promise - use \`saveAsync()\` instead of \`save()\` when a model has async setters.`);i._attributes[u]=p}let l=a.set;a.set={};try{return i.save()}finally{a.set=l}}return i.save()};if(r==="updateAsync")return async function(a){if(a&&typeof a==="object"&&!Array.isArray(a))for(let[c,l]of Object.entries(a))o[c]=l;return o.saveAsync()};if(r==="saveQuietly")return function(){return ee(()=>i.save())};if(r==="saveAsyncQuietly")return function(){return ee(()=>o.saveAsync())};if(r==="updateQuietly")return function(a){return ee(()=>i.update(a))};if(r==="updateAsyncQuietly")return function(a){return ee(()=>o.updateAsync(a))};if(r==="deleteQuietly")return function(){return ee(()=>i.delete())};if(r==="toSearchableObject")return function(){let l=i._definition?.traits?.useSearch;if(!l)return null;let u=i._attributes;if(!u)return null;if(l===!0){let g={...u};if(u.id!=null)g.id=String(u.id);return g}let m={},p=l.displayable?.length?l.displayable:[...l.searchable??[],...l.filterable??[],...l.sortable??[],"id"],_=l.denormalize??{},k=i._relations;for(let g of p){let y=H(g),R=u[y]??u[g];if(R!==void 0){m[y]=R;continue}let v=_[g]??_[y];if(v){m[y]=qu(k,v);continue}m[y]=void 0}if(u.id!=null)m.id=String(u.id);return m};if(typeof r==="string"&&!Ei.has(r)){let a=i._attributes;if(a&&Object.prototype.hasOwnProperty.call(a,r))return a[r];let c=i._relations;if(c&&Object.prototype.hasOwnProperty.call(c,r)){let u=c[r];if(Array.isArray(u))return u.map((m)=>D(m,t));return D(u,t)}let l=Eu[r];if(l){let p=i._definition?.__traitMethods?.[l.bag]?.[r];if(typeof p==="function")return l.mode==="model"?(..._)=>p(o,..._):(..._)=>p(i.id,..._)}if(a){let u=H(r);if(u!==r&&Object.prototype.hasOwnProperty.call(a,u))return a[u]}}let s=Reflect.get(i,r,i);return typeof s==="function"?s.bind(i):s},set(i,r,o,s){if(typeof r==="string"&&!Ei.has(r)){let{_attributes:a,set:c}=i;if(a&&Object.prototype.hasOwnProperty.call(a,r)){if(typeof c==="function")c.call(i,r,o);else a[r]=o;return!0}if(a){let l=H(r);if(l!==r&&Object.prototype.hasOwnProperty.call(a,l)){if(typeof c==="function")c.call(i,l,o);else a[l]=o;return!0}}if(a&&!(r in i)){if(typeof c==="function")c.call(i,r,o);else a[r]=o;return!0}}return Reflect.set(i,r,o,s)},has(i,r){if(typeof r==="string"&&!Ei.has(r)){let o=i._attributes;if(o&&Object.prototype.hasOwnProperty.call(o,r))return!0;let s=i._relations;if(s&&Object.prototype.hasOwnProperty.call(s,r))return!0;if(o){let a=H(r);if(a!==r&&Object.prototype.hasOwnProperty.call(o,a))return!0}}return Reflect.has(i,r)},deleteProperty(i,r){if(typeof r==="string"&&!Ei.has(r)){let o=i._attributes;if(o&&Object.prototype.hasOwnProperty.call(o,r))return delete o[r],!0}return Reflect.deleteProperty(i,r)},ownKeys(i){let r=i._attributes;return r?Object.keys(r):[]},getOwnPropertyDescriptor(i,r){if(typeof r==="string"){let o=i._attributes;if(o&&Object.prototype.hasOwnProperty.call(o,r))return{configurable:!0,enumerable:!0,value:o[r],writable:!0}}return Object.getOwnPropertyDescriptor(i,r)}})}var Ou=new Set(["get","first","last","firstOrFail","find","findOrFail","all","paginate","simplePaginate","cursorPaginate"]),Au={paginate:Yi,simplePaginate:Zi,cursorPaginate:er},xc=Symbol.for("stacks.queryBuilderProxy");function $c(e,t){if(!e||typeof e!=="object")return e;if(e[xc])return e;return new Proxy(e,{get(n,i,r){if(i===xc)return!0;let o=Reflect.get(n,i,r);if(typeof o!=="function")return o;return function(...s){let a=s,c=String(i);if(c==="paginate"||c==="simplePaginate"){let{perPage:m,page:p}=nr(s[0],s[1]);a=[m,p]}else if(c==="cursorPaginate"){let{perPage:m,cursor:p}=ir(s[0],s[1]);a=[m,p,s[2],s[3]]}let l=o.apply(n,a),u=(m)=>{if(Ou.has(c)){if(Array.isArray(m))return m.map((_)=>D(_,t));let p=Au[c];if(p&&m&&Array.isArray(m.data)){let _=m.data.map((g)=>D(g,t)),k=p({...m,data:_});return rr(k)}if(m&&Array.isArray(m.data))return{...m,data:m.data.map((_)=>D(_,t))};return D(m,t)}if(m&&typeof m==="object"&&typeof m.get==="function")return $c(m,t);return m};if(l&&typeof l.then==="function")return l.then(u);return u(l)}}})}function Iu(e,t){let n=["find","first","last","all","firstOrFail","findOrFail","findMany"];for(let o of n){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a),l=(u)=>Array.isArray(u)?u.map((m)=>D(m,t)):D(u,t);if(c&&typeof c.then==="function")return c.then(l);return l(c)}}let i=["create","firstOrCreate","updateOrCreate","make"];for(let o of i){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a),l=(u)=>Array.isArray(u)?u.map((m)=>D(m,t)):D(u,t);if(c&&typeof c.then==="function")return c.then(l);return l(c)}}let r=["query","where","orWhere","whereIn","whereNotIn","whereNull","whereNotNull","whereLike","whereBetween","whereNotBetween","orderBy","orderByDesc","select","with","limit","take","skip","latest","oldest"];for(let o of r){let s=e[o];if(typeof s!=="function")continue;e[o]=function(...a){let c=s.apply(this,a);return $c(c,t)}}}class Uc extends Error{model;id;constructor(e,t){super(t!=null?`[ORM] ${e} not found for id=${String(t)}`:`[ORM] No matching ${e} row`);this.name="ModelNotFoundError",this.model=e,this.id=t}}class Ua extends Error{model;attribute;reason;constructor(e,t,n){let i=n==="guarded"?`'${t}' is marked guarded`:`'${t}' is not in the fillable allowlist`;super(`[ORM] Mass assignment to ${e} forbidden: ${i}. Use ${e}.forceCreate(...) / .forceUpdate(...) to bypass.`);this.name="MassAssignmentException",this.model=e,this.attribute=t,this.reason=n}}var $u=new Set(["id","created_at","updated_at","deleted_at","uuid"]);function ii(e,t,n={}){if(n.force)return t;if(!t||typeof t!=="object"||Array.isArray(t))return t;let i=e.attributes;if(!i)return t;let r=new Set,o=new Set,s=new Set;for(let[c,l]of Object.entries(i)){let u=H(c);if(r.add(u),l?.fillable===!0)o.add(u);if(l?.guarded===!0)s.add(u)}let a=o.size>0?o:r;for(let c of Object.keys(t)){let l=H(c);if($u.has(l))continue;if(s.has(l))throw new Ua(e.name,c,"guarded");if(l.endsWith("_id"))continue;if(!a.has(l))throw new Ua(e.name,c,"not-fillable")}return t}async function Ma(e,t){let n=e.set;if(!n||typeof n!=="object")return t;let i={...t};for(let[r,o]of Object.entries(n)){if(typeof o!=="function"||!(r in i))continue;try{i[r]=await o(i)}catch(s){A.error(`[orm] ${e.name}.set.${r} threw - skipping setter`,s)}}return i}function Uu(e,t){let n=t.primaryKey||"id",i=e.create;function r(l){let u=e.where;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} needs a working where(): the underlying query builder did not expose one`);return u}function o(l){let u=e.find;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} needs a working find(): the underlying query builder did not expose one`);return u}function s(l){let u=e.create;if(typeof u!=="function")throw Error(`[ORM] ${t.name}.${l} cannot create: the underlying query builder did not expose create()`);return u}if(typeof e.update!=="function")e.update=async function(l,u){if(l==null)throw Error(`[ORM] ${t.name}.update requires an id as the first argument`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.update requires a data object as the second argument`);if(Object.keys(u).length===0){A.debug(`[orm] ${t.name}.update called with empty data - short-circuiting and returning current row`);let _=e.find;return typeof _==="function"?await _.call(e,l):null}ii(t,u);let m=await Ma(t,u);await r("update").call(e,n,l).update(m);let p=e.find;return typeof p==="function"?await p.call(e,l):null};if(typeof e.forceUpdate!=="function")e.forceUpdate=async function(l,u){if(l==null)throw Error(`[ORM] ${t.name}.forceUpdate requires an id as the first argument`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.forceUpdate requires a data object as the second argument`);let m=await Ma(t,u);await r("forceUpdate").call(e,n,l).update(m);let p=e.find;return typeof p==="function"?await p.call(e,l):null};if(typeof e.forceCreate!=="function")e.forceCreate=async function(l){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.forceCreate requires a data object`);let u=e.make;if(typeof u==="function"){let m=await u.call(e);if(m&&typeof m.forceFill==="function"&&typeof m.save==="function")return m.forceFill(l),await m.save()??m}if(typeof i!=="function")throw Error(`[ORM] ${t.name}.forceCreate cannot create: the underlying query builder did not expose create()`);return await i.call(e,l)};if(typeof e.delete!=="function")e.delete=async function(l){if(l==null)throw Error(`[ORM] ${t.name}.delete requires an id as the first argument`);if(!await o("delete").call(e,l))return!1;return await r("delete").call(e,n,l).delete(),!0};if(typeof e.findOrFail!=="function")e.findOrFail=async function(l){let u=await o("findOrFail").call(e,l);if(u==null)throw new Uc(t.name,l);return u};if(typeof e.exists!=="function")e.exists=async function(l){if(l==null)return!1;let u=r("exists").call(e,n,l);if(typeof u.count==="function"){let p=await u.count();return Number(p)>0}let m=e.find;return typeof m==="function"?await m.call(e,l)!=null:!1};if(typeof e.firstOrCreate!=="function")e.firstOrCreate=async function(l,u={}){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.firstOrCreate requires a where-attrs object`);let m=r("firstOrCreate").call(e,l),p=typeof m.first==="function"?await m.first():await m;if(p)return p;let _={...l,...u};return ii(t,_),await s("firstOrCreate").call(e,_)};if(typeof e.updateOrCreate!=="function")e.updateOrCreate=async function(l,u){if(!l||typeof l!=="object"||Array.isArray(l))throw Error(`[ORM] ${t.name}.updateOrCreate requires a where-attrs object`);if(!u||typeof u!=="object"||Array.isArray(u))throw Error(`[ORM] ${t.name}.updateOrCreate requires a values object`);let m=r("updateOrCreate").call(e,l),p=typeof m.first==="function"?await m.first():await m;if(p){ii(t,u);let k=p[n];await r("updateOrCreate").call(e,n,k).update(u);let g=e.find;return typeof g==="function"?await g.call(e,k):{...p,...u}}let _={...l,...u};return ii(t,_),await s("updateOrCreate").call(e,_)};if(typeof e.count!=="function")e.count=async function(){let l=e;if(typeof l.query==="function"){let p=l.query();if(typeof p?.count==="function"){let _=await p.count();return Number(_)||0}}let{all:u,get:m}=e;if(typeof u==="function")return(await u.call(e)||[]).length;if(typeof m==="function")return(await m.call(e)||[]).length;return 0};if(typeof e.pluck!=="function")e.pluck=async function(l){if(!l||typeof l!=="string")throw Error(`[ORM] ${t.name}.pluck requires a column name`);let u=e.all;return((typeof u==="function"?await u.call(e):[])||[]).map((p)=>p?.[l])};if(typeof e.whereIn!=="function")e.whereIn=async function(l,u){if(!l||typeof l!=="string")throw Error(`[ORM] ${t.name}.whereIn requires a column name`);if(!Array.isArray(u))throw Error(`[ORM] ${t.name}.whereIn requires an array of values`);if(u.length===0)return[];let m=e.where;if(typeof m!=="function")return[];let p=m.call(e,l,"in",u);if(p&&typeof p.get==="function")return await p.get();return await p};let a=[["latest","desc"],["oldest","asc"]];for(let[l,u]of a)if(typeof e[l]!=="function")e[l]=async function(m="created_at"){let p=e,_=typeof p.query==="function"?p.query():p;if(typeof _?.orderBy==="function"){let R=_.orderBy(m,u);if(typeof R.first==="function")return await R.first();if(typeof R.get==="function")return(await R.get())?.[0]??null}let k=e.all;if(typeof k!=="function")return null;return[...await k.call(e)||[]].sort((R,v)=>{let x=R?.[m],P=v?.[m];if(x===P)return 0;return(x>P?1:-1)*(u==="desc"?-1:1)})[0]??null};let c=Fc(t.traits?.useSearch,t);if(c){let l=c.index??t.table??H(`${t.name}s`);if(typeof e.search!=="function")e.search=function(u,m){return Nu(e,l,u,m,c.searchable)};if(typeof e.makeAllSearchable!=="function")e.makeAllSearchable=async function(u=500){let m=e.all;if(typeof m!=="function")throw Error(`[ORM] ${t.name}.makeAllSearchable cannot run: the underlying query builder did not expose all()`);let{useSearchEngine:p}=await import("@stacksjs/search-engine"),_=p(),k=0,g=e.query;if(typeof g==="function")try{let v=g.call(e);if(v&&typeof v.chunk==="function")return await v.chunk(u,async(x)=>{let P=await Da(x,c);if(P.length>0)await _.addDocuments(l,P);k+=P.length}),k}catch{}let y=await m.call(e)||[],R=await Da(y,c);if(R.length>0)await _.addDocuments(l,R);return R.length};if(typeof e.removeAllFromSearch!=="function")e.removeAllFromSearch=async function(){let{useSearchEngine:u}=await import("@stacksjs/search-engine"),m=u();if(typeof m.deleteAllDocuments==="function"){await m.deleteAllDocuments(l);return}let p=e.all,_=typeof p==="function"?await p.call(e)||[]:[],k=u();for(let g of _){let y=g?.id??g?._attributes?.id;if(y!=null)await k.deleteDocument(l,Number(y))}}}}async function Da(e,t){if(e.length===0)return[];if(typeof t.shapeMany==="function"){let i=await t.shapeMany(e);if(!Array.isArray(i)||i.length!==e.length)throw TypeError(`[orm/search] shapeMany returned ${Array.isArray(i)?i.length:typeof i} documents for ${e.length} rows. It must return one document per row, in order, or documents are indexed under the wrong ids.`);return i.filter(Boolean)}return(await Promise.all(e.map((i)=>Fu(i,t)))).filter(Boolean)}function Mu(e){let t=new Set,n=e.attributes??{};for(let[i,r]of Object.entries(n))if(r?.hidden)t.add(i);return t}function Du(e,t){if(!e||t.size===0)return e;let n={};for(let[i,r]of Object.entries(e))if(!t.has(i))n[i]=r;return n}async function Fu(e,t){if(typeof t.shape==="function")try{return await t.shape(e)}catch{return}let n=e?.toSearchableObject?.();if(n!==void 0)return n;return Du(e?._attributes??(typeof e?.toJSON==="function"?e.toJSON():null),t.hidden??new Set)}function Nu(e,t,n,i,r){let o=r&&r.length>0?{query_by:[...r].join(",")}:{},s={q:n,...o,...i??{}},a={with(c){return s={...s,...c},a},where(c){return s={...s,filter:c},a},async get(){let{useSearchEngine:c}=await import("@stacksjs/search-engine");return(await c().search(t,s))?.hits??[]},async paginate(c,l=1){let{useSearchEngine:u}=await import("@stacksjs/search-engine"),p=await u().search(t,{...s,limit:c,offset:(l-1)*c});return{hits:p.hits??[],total:Number(p.estimatedTotalHits??p.nbHits??p.total??0),page:l,perPage:c}},async raw(){let{useSearchEngine:c}=await import("@stacksjs/search-engine");return await c().search(t,s)}};return a}function Mc(e){let t=H(e);return t===e?[e]:[e,t]}async function $a(e,t){if(!e||typeof e!=="object")return;let n=e._attributes??e;for(let i of t)for(let r of Mc(i)){if(!(r in n))continue;let o=n[r];if(!ue(o))continue;n[r]=await $i(o)}}function Gu(e,t){if(t.length===0)return;let n=async(a)=>{if(Array.isArray(a)){for(let c of a)await $a(c,t);return a}if(a&&typeof a==="object"&&Array.isArray(a.data)){for(let c of a.data)await $a(c,t);return a}if(a)await $a(a,t);return a},i=["find","first","last","all","firstOrFail","findOrFail","findMany"];for(let a of i){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(...l){let u=await c.apply(this,l);return await n(u)}}let r=["create","firstOrCreate","updateOrCreate","make"];for(let a of r){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(...l){let u=await c.apply(this,l);return await n(u)}}for(let a of["update","forceUpdate"]){let c=e[a];if(typeof c!=="function")continue;e[a]=async function(l,u){let m=await c.call(this,l,u);return await n(m)}}let o=["first","firstOrFail","get","all","find","findOrFail","last","paginate","simplePaginate"],s=(a)=>{if(!a||typeof a!=="object")return a;let c=a;if(c.__stacksEncryptedReads)return a;for(let l of o){let u=c[l];if(typeof u!=="function")continue;c[l]=async function(...m){return await n(await u.apply(this,m))}}for(let l of["where","whereIn","whereNull","whereNotNull","orWhere","orderBy","orderByDesc","limit","offset","with"]){let u=c[l];if(typeof u!=="function")continue;c[l]=function(...m){return s(u.apply(this,m))}}return Object.defineProperty(c,"__stacksEncryptedReads",{value:!0,enumerable:!1}),a};for(let a of["where","whereIn","whereNull","whereNotNull","orderBy","orderByDesc","limit","query"]){let c=e[a];if(typeof c!=="function")continue;e[a]=function(...l){return s(c.apply(this,l))}}}function Bu(e,t){if(t.length===0)return;let n=async(r)=>{if(!r||typeof r!=="object"||Array.isArray(r))return r;let o={...r};for(let s of t)for(let a of Mc(s))if(a in o)o[a]=await Ii(o[a]);return o},i=["create","firstOrCreate","updateOrCreate","forceCreate"];for(let r of i){let o=e[r];if(typeof o!=="function")continue;e[r]=async function(...s){if(s[0]=await n(s[0]),s[1])s[1]=await n(s[1]);return await o.apply(this,s)}}for(let r of["update","forceUpdate"]){let o=e[r];if(typeof o!=="function")continue;e[r]=async function(s,a){let c=await n(a);return await o.call(this,s,c)}}}function Lu(e,t){let n=e.create;if(typeof n==="function")e.create=async function(i,...r){ii(t,i);let o=await Ma(t,i);return await n.call(this,o,...r)};for(let i of["firstOrCreate","updateOrCreate"]){let r=e[i];if(typeof r!=="function")continue}}function Ku(e,t){let n=String(t?.name??e.name??"Model"),i=(s,a)=>{if(xu())return;if(!s||typeof s!=="object"||Array.isArray(s))return;let c=Ya(s,t,a);if(!c.valid)throw new Ac(n,c.errors)},r=e.create;if(typeof r==="function")e.create=async function(s,...a){return i(s,"creating"),await r.call(this,s,...a)};let o=e.update;if(typeof o==="function")e.update=async function(s,a,...c){return i(a,"updating"),await o.call(this,s,a,...c)}}function Hu(e,t){let n=["create","firstOrCreate","updateOrCreate"];for(let r of n){let o=e[r];if(typeof o==="function")e[r]=async function(...s){if(A.debug(`[orm] ${r.charAt(0).toUpperCase()+r.slice(1)} ${String(e.name||"unknown")}`,s[0]),s[0]&&typeof s[0]==="object"&&!Array.isArray(s[0]))s[0]=vc(s[0],t,"set");return await o.apply(this,s)}}let i=e.update;if(typeof i==="function")e.update=async function(r,o){let s=o&&typeof o==="object"&&!Array.isArray(o)?vc(o,t,"set"):o;return await i.call(this,r,s)}}function Dc(e){A.debug(`[orm] Defining model: ${e.name} (table: ${e.table})`);let t=Vu(e),n=Wu(e),i=zu(t,n),r=Qu(e);e.__traitMethods=r;let o=i?{...e,hooks:{...e.hooks,...i}}:e,a=vu(o);if(Iu(a,e.casts),Uu(a,o),Lu(a,o),e.casts&&Object.keys(e.casts).length>0)Hu(a,e.casts);let c=Ui(e);if(c.length>0)Bu(a,c),Gu(a,c);let l=e.traits?.useSoftDeletes;if(l)Ju(a,o,l);let u=e.traits?.useAudit;if(u){let p=za(u);Wa(a,e.name,e.primaryKey||"id",p)}Ku(a,o),a.withoutValidation=function(p){return Cu(p)},a.withoutEvents=function(p){return ee(p)};for(let p of["create","update","firstOrCreate","updateOrCreate","forceCreate","forceUpdate","delete","forceDelete","softDelete","restore"]){let _=a[p];if(typeof _!=="function")continue;let k=`${p}Quietly`;if(typeof a[k]==="function")continue;a[k]=function(...g){return ee(()=>_.apply(a,g))}}let m=Object.assign(a,r,{...e,getDefinition:()=>e,_isStacksModel:!0});return Su(e.name,m),Object.defineProperty(m,Fa,{value:e,enumerable:!1,configurable:!0}),m}function Vu(e){let t=e.traits?.observe;if(!t)return;let n=e.name.toLowerCase(),i=(p)=>{let _=p?.attributes;if(!_||typeof _!=="object")return p;let k=e.primaryKey||"id",g={..._};if(g[k]===void 0&&p[k]!==void 0)g[k]=p[k];return g},r=async(p,_)=>{if(te())return;try{let{dispatch:k}=await import("@stacksjs/events");await k(p,_)}catch(k){if(k&&typeof k==="object"&&"code"in k&&k.code==="MODULE_NOT_FOUND")return;if(console.error(`[ORM] Event '${p}' handler error:`,k),process.env.STACKS_ORM_EVENT_ERRORS!=="swallow")throw k}},o=e.traits?.broadcastOn,s=e.traits?.broadcastWith,a=typeof o==="function"&&typeof s==="function",c=async(p,_)=>{if(!a)return;if(te())return;try{let k=o(_),g=Array.isArray(k)?k:[k],y=s(_),v=(await import("@stacksjs/realtime").catch(()=>null))?.broadcast;if(typeof v!=="function")return;for(let x of g){if(typeof x!=="string"||x.length===0)continue;await v(x,p,y)}}catch(k){if(k&&typeof k==="object"&&"code"in k&&k.code==="MODULE_NOT_FOUND")return;if(console.error(`[ORM] Broadcast '${p}' handler error:`,k),process.env.STACKS_ORM_BROADCAST_ERRORS==="throw")throw k}},l=async(p,_)=>{if(te())return!0;try{let{dispatchAsync:k}=await import("@stacksjs/events"),g=await k(p,_);if(Array.isArray(g)&&g.some((y)=>y===!1))return!1}catch(k){if(k&&typeof k==="object"&&"code"in k&&k.code==="MODULE_NOT_FOUND")return!0;if(console.error(`[ORM] Before-event '${p}' handler error:`,k),process.env.STACKS_ORM_EVENT_ERRORS!=="swallow")throw k}return!0},u=t===!0?["create","update","delete"]:Array.isArray(t)?t:[],m={};if(u.includes("create"))m.beforeCreate=async(p)=>{if(A.debug(`[orm] Create ${n}`,p),!await l(`${n}:saving`,p))throw Error(`[ORM] ${n}:saving event cancelled the operation`);if(!await l(`${n}:creating`,p))throw Error(`[ORM] ${n}:creating event cancelled the operation`)},m.afterCreate=async(p)=>{let _=i(p);await r(`${n}:created`,_),await r(`${n}:saved`,_),await c(`${n}:created`,p)};if(u.includes("update"))m.beforeUpdate=async(p)=>{if(A.debug(`[orm] Update ${n}#${p?.id??"unknown"}`,p),!await l(`${n}:saving`,p))throw Error(`[ORM] ${n}:saving event cancelled the operation`);if(!await l(`${n}:updating`,p))throw Error(`[ORM] ${n}:updating event cancelled the operation`)},m.afterUpdate=async(p)=>{let _=i(p);await r(`${n}:updated`,_),await r(`${n}:saved`,_),await c(`${n}:updated`,p)};if(u.includes("delete"))m.beforeDelete=async(p)=>{if(A.debug(`[orm] Delete ${n}#${p?.id??"unknown"}`),!await l(`${n}:deleting`,p))throw Error(`[ORM] ${n}:deleting event cancelled the operation`)},m.afterDelete=async(p)=>{await r(`${n}:deleted`,i(p)),await c(`${n}:deleted`,p)};return m}function zu(...e){let t={},n=new Set;for(let i of e){if(!i)continue;for(let r of Object.keys(i))n.add(r)}for(let i of n){let r=e.map((o)=>o?.[i]).filter((o)=>typeof o==="function");if(!r.length)continue;t[i]=async(...o)=>{for(let s of r)await s(...o)}}return Object.keys(t).length?t:void 0}function Fc(e,t){if(!e)return null;let n=e===!0?{}:typeof e==="object"?{...e}:null;if(!n)return null;if(t)n.hidden=Mu(t);return n}function Wu(e){let t=Fc(e.traits?.useSearch,e);if(!t)return;let n=t,i=n.index??e.table??H(`${e.name}s`);async function r(a){if(typeof n.shapeMany==="function")try{let[u]=await Da([a],n);return u}catch(u){A.warn(`[orm/search] shapeMany() threw for ${e.name}: ${u.message}`);return}if(typeof n.shape==="function")try{return await n.shape(a)}catch(u){A.warn(`[orm/search] shape() threw for ${e.name}: ${u.message}`);return}let l=D(a).toSearchableObject?.();if(l!==void 0)return l;return a?._attributes??(typeof a?.toJSON==="function"?a.toJSON():null)}let o=async(a)=>{if(te())return;let c=await r(a);if(!c)return;if(t.queueable){try{let{Jobs:l}=await import("@stacksjs/queue");await l.dispatch("SyncSearchIndex",{index:i,op:"upsert",doc:c})}catch(l){A.warn(`[orm/search] queue dispatch failed for ${e.name}; falling back to inline: ${l.message}`),await jc(i,c,e.name)}return}await jc(i,c,e.name)};return{afterCreate:o,afterUpdate:o,afterDelete:async(a)=>{if(te())return;let c=a?.id??a?._attributes?.id;if(c==null)return;if(t.queueable){try{let{Jobs:l}=await import("@stacksjs/queue");await l.dispatch("SyncSearchIndex",{index:i,op:"delete",id:Number(c)})}catch(l){A.warn(`[orm/search] queue dispatch failed for ${e.name}#${c}; falling back to inline: ${l.message}`),await Pc(i,Number(c),e.name)}return}await Pc(i,Number(c),e.name)}}}var Cc=new Map;function Nc(e,t){let n=Cc.get(e)??0;if(Cc.set(e,n+1),n===0)A.warn(`[orm/search] ${t}`);else if(n===9)A.warn(`[orm/search] ${e} is still failing; further identical warnings suppressed for this process.`)}async function jc(e,t,n){try{let{useSearchEngine:i}=await import("@stacksjs/search-engine");await i().addDocument(e,t)}catch(i){Nc(`index:${n}`,`Failed to index ${n}: ${i.message}`)}}async function Pc(e,t,n){try{let{useSearchEngine:i}=await import("@stacksjs/search-engine");await i().deleteDocument(e,t)}catch(i){Nc(`remove:${n}`,`Failed to remove ${n}#${t}: ${i.message}`)}}function Qu(e){let t={},n=e.table,i=e.traits;if(!i)return t;if(i.taggable)t._taggable=Li(n);if(i.categorizable)t._categorizable=Ki(n);if(i.commentable)t._commentable=Gi(n);if(i.billable)t._billable=hc(n);if(i.likeable){let o=typeof i.likeable==="object"?i.likeable:void 0;t._likeable=Hi(n,o)}let r=i.useAuth||i.authenticatable;if(typeof r==="object"&&r&&"useTwoFactor"in r&&r.useTwoFactor)t._twoFactor=yc();return t}function Ju(e,t,n){let i=Rc(e,t.primaryKey||"id"),r=Tc(n),o=t,s=t.name.toLowerCase(),a=t.traits?.observe!=null&&t.traits?.observe!==!1,c=async(_)=>{if(!a||te())return!0;try{let{dispatchAsync:k}=await import("@stacksjs/events"),g=await k(`${s}:restoring`,{id:_});if(Array.isArray(g)&&g.some((y)=>y===!1))return!1}catch(k){if(k?.code!=="MODULE_NOT_FOUND")console.error(`[ORM] Before-event '${s}:restoring' handler error:`,k)}return!0},l=async(_)=>{if(!a||te())return;try{let{dispatch:k}=await import("@stacksjs/events");await k(`${s}:restored`,{id:_})}catch(k){if(k?.code!=="MODULE_NOT_FOUND")console.error(`[ORM] Event '${s}:restored' handler error:`,k)}},u=process.env.STACKS_ORM_CASCADE_SWALLOW!=="true",m=async(_)=>{if(!r.cascade?.length||!u){let g=await i.softDelete(_);if(g&&r.cascade?.length)await ni(o,r,_,"softDelete");return g}let{db:k}=await import("@stacksjs/database");return await k.transaction(async()=>{let g=await i.softDelete(_);if(g)await ni(o,r,_,"softDelete");return g})},p=async(_)=>{if(!await c(_))return!1;if(!r.cascade?.length||!u){let R=await i.restore(_);if(R){if(r.cascade?.length)await ni(o,r,_,"restore");await l(_)}return R}let{db:g}=await import("@stacksjs/database"),y=await g.transaction(async()=>{let R=await i.restore(_);if(R)await ni(o,r,_,"restore");return R});if(y)await l(_);return y};e.softDelete=m,e.restore=p,e.forceDelete=i.forceDelete,e.withTrashed=i.withTrashed,e.onlyTrashed=i.onlyTrashed,e.delete=m}function Xu(e){if(e==null)return e;if(Array.isArray(e))return e.map(Xu);if(typeof e!=="object")return e;if(typeof e.toJSON==="function")return e.toJSON();if(e._attributes&&typeof e._attributes==="object")return e._attributes;return e}var Yu=["belongsTo","hasOne","hasMany","belongsToMany","morphMany","morphOne"],Zu=["traits","dashboard"];function em(e){let t=e?.[Fa];if(t&&typeof t==="object")return t;if(e&&typeof e==="object"&&"name"in e&&"attributes"in e)return e;throw TypeError("extendModel() expects a model created by defineModel(), or a model definition. Import the framework model itself rather than its table name.")}function tm(e,t){let n=Array.isArray(e)?e:[],i=Array.isArray(t)?t:[];if(!n.length&&!i.length)return;return[...new Set([...n,...i])]}function nm(e){if(!e)return 0;return Object.values(e).reduce((t,n)=>{let i=Number(n?.order);return Number.isFinite(i)&&i>t?i:t},0)}function im(e,t){let n={...e,...t},i=e.attributes??{},r=t.attributes??{};if(t.attributes){let o=nm(i),s=Object.fromEntries(Object.entries(r).map(([a,c])=>{let l=!(a in i),u=Number.isFinite(Number(c?.order));if(l&&!u)return[a,{...c,order:++o}];return[a,c]}));n.attributes={...i,...s}}for(let o of Yu){let s=tm(e[o],t[o]);if(s)n[o]=s}for(let o of Zu){let s=e[o],a=t[o];if(s&&a&&typeof s==="object"&&typeof a==="object")n[o]={...s,...a}}return n}function yj(e,t){return Dc(im(em(e),t))}import{log as rm}from"@stacksjs/logging";import{path as V}from"@stacksjs/path";import{fs as ri}from"@stacksjs/storage";function Q(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()}function om(e){let t=e.default;if(typeof t==="boolean")return"boolean";if(typeof t==="number")return"number";if(typeof t==="string")return"string";return"unknown"}function sm(e){let t=e.validation;if(!t||typeof t!=="object")return null;let n=t.rule;return n&&typeof n==="object"?n:null}function am(e){if(!e||String(e.name??"")!=="enum")return null;let n=(Array.isArray(e.allowedValues)?e.allowedValues:[]).filter((i)=>typeof i==="string"||typeof i==="number").map((i)=>typeof i==="number"?String(i):JSON.stringify(i));return n.length>0?n.join(" | "):null}function lm(e){let t=sm(e),n=am(t);if(n!==null)return e.nullable===!0?`${n} | null`:n;let i=typeof e.type==="string"?e.type.toLowerCase():String(t?.name??"").toLowerCase(),r=(()=>{switch(i){case"string":case"text":case"longtext":case"mediumtext":case"tinytext":case"char":case"varchar":case"enum":case"uuid":case"date":case"datetime":case"timestamp":case"timestamptz":case"password":case"time":case"year":return"string";case"number":case"integer":case"int":case"tinyint":case"smallint":case"mediumint":case"float":case"double":case"decimal":case"numeric":return"number";case"bigint":return"number | bigint";case"boolean":case"bool":return"boolean";case"json":case"jsonb":return"unknown";case"binary":case"blob":case"bytea":return"Uint8Array";case"unix":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return om(e)}})();return e.nullable===!0?`${r} | null`:r}function cm(e){let t={},n=e.belongsTo;if(!n)return t;let i=Array.isArray(n)?n:Object.values(n);for(let r of i){if(typeof r==="string"){t[`${Q(r)}_id`]="number";continue}if(r&&typeof r==="object"){let o=r;if(typeof o.foreignKey==="string"){t[o.foreignKey]="number";continue}if(typeof o.model==="string")t[`${Q(o.model)}_id`]="number"}}return t}function dm(e,t){let[n,i]=[Q(e),Q(t)].sort();return`${n}_${i}`}function um(e){let t=e.default,n=typeof t==="string"?"string":typeof t==="number"?"number":typeof t==="boolean"?"boolean":t instanceof Date?"string":"unknown";return e.nullable?`${n} | null`:n}function mm(e,t){let n=t.belongsToMany;if(!n)return[];let i=[],r=Array.isArray(n)?n:Object.values(n);for(let o of r){let s,a,c,l,u={},m=!0;if(typeof o==="string")s=o;else if(o&&typeof o==="object"&&"model"in o){let y=o;if(s=y.model,"pivotTable"in y||"firstForeignKey"in y||"secondForeignKey"in y)a=y.pivotTable,c=y.firstForeignKey,l=y.secondForeignKey;else{let R=o;a=R.table,c=R.foreignKey,l=R.relatedKey,u=R.pivot?.columns??{},m=Boolean(R.pivot?.timestamps)}}else continue;let p=a??dm(e,s),_=c??`${Q(e)}_id`,k=l??`${Q(s)}_id`,g={id:"number",[_]:"number",[k]:"number"};for(let[y,R]of Object.entries(u))g[y]=um(R);if(m)g.created_at="string",g.updated_at="string | null";i.push({table:p,columns:g})}return i}var pm={email_verified_at:"string | null",password_changed_at:"string | null",two_factor_secret:"string | null",two_factor_enabled:"boolean | null",two_factor_last_used_step:"number | null",stripe_id:"string | null"};function fm(e){let t={id:"number"},n=e.traits??{};if(n.useUuid)t.uuid="string";if((n.useTimestamps??n.timestampable)!==!1)t.created_at="string",t.updated_at="string | null";if(n.useSoftDeletes??n.softDeletable)t.deleted_at="string | null";if((e.table??"")==="users"||e.name==="User")Object.assign(t,pm);return t}function _m(e){let t={},n=e.attributes??{};for(let[i,r]of Object.entries(n))t[Q(i)]=lm(r);return t}function km(e){return e.replace(/_([a-z0-9])/g,(t,n)=>n.toUpperCase())}function bm(e){let t={...e};for(let[n,i]of Object.entries(e)){let r=km(n);if(r!==n&&!(r in t))t[r]=i}return t}function Gc(e,t,n=2){let i=" ".repeat(n),r=" ".repeat(n+1),o=Object.entries(t).map(([a,c])=>`${r}${a}: ${c}`).join(`
|
|
16
16
|
`),s=/^[A-Z_a-z]\w*$/.test(e)?e:`'${e}'`;return`${i}${s}: {
|
|
17
17
|
${r}// columns
|
|
18
18
|
${o}
|