b23-lib 3.4.0 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/Classes/Address.d.mts +1 -1
  2. package/dist/Classes/Address.d.ts +1 -1
  3. package/dist/Classes/Base.d.mts +1 -1
  4. package/dist/Classes/Base.d.ts +1 -1
  5. package/dist/Classes/Cart.d.mts +1 -1
  6. package/dist/Classes/Cart.d.ts +1 -1
  7. package/dist/Classes/Cart.js +1 -1
  8. package/dist/Classes/Cart.js.map +1 -1
  9. package/dist/Classes/Cart.mjs +1 -1
  10. package/dist/Classes/Charge.d.mts +1 -1
  11. package/dist/Classes/Charge.d.ts +1 -1
  12. package/dist/Classes/Common.d.mts +1 -1
  13. package/dist/Classes/Common.d.ts +1 -1
  14. package/dist/Classes/Coupon.d.mts +1 -1
  15. package/dist/Classes/Coupon.d.ts +1 -1
  16. package/dist/Classes/Customer.d.mts +1 -1
  17. package/dist/Classes/Customer.d.ts +1 -1
  18. package/dist/Classes/CustomerAddress.d.mts +1 -1
  19. package/dist/Classes/CustomerAddress.d.ts +1 -1
  20. package/dist/Classes/Inventory.d.mts +1 -1
  21. package/dist/Classes/Inventory.d.ts +1 -1
  22. package/dist/Classes/Invoice.d.mts +1 -1
  23. package/dist/Classes/Invoice.d.ts +1 -1
  24. package/dist/Classes/LineItem.d.mts +1 -1
  25. package/dist/Classes/LineItem.d.ts +1 -1
  26. package/dist/Classes/Order.d.mts +1 -1
  27. package/dist/Classes/Order.d.ts +1 -1
  28. package/dist/Classes/Order.js +1 -1
  29. package/dist/Classes/Order.js.map +1 -1
  30. package/dist/Classes/Order.mjs +1 -1
  31. package/dist/Classes/Payment.d.mts +3 -2
  32. package/dist/Classes/Payment.d.ts +3 -2
  33. package/dist/Classes/Payment.js +1 -1
  34. package/dist/Classes/Payment.js.map +1 -1
  35. package/dist/Classes/Payment.mjs +1 -1
  36. package/dist/Classes/Payment.mjs.map +1 -1
  37. package/dist/Classes/Price.d.mts +1 -1
  38. package/dist/Classes/Price.d.ts +1 -1
  39. package/dist/Classes/Product.d.mts +1 -1
  40. package/dist/Classes/Product.d.ts +1 -1
  41. package/dist/Classes/ShoppingContainer.d.mts +2 -2
  42. package/dist/Classes/ShoppingContainer.d.ts +2 -2
  43. package/dist/Classes/ShoppingContainer.js +1 -1
  44. package/dist/Classes/ShoppingContainer.js.map +1 -1
  45. package/dist/Classes/ShoppingContainer.mjs +1 -1
  46. package/dist/Classes/TaxRule.d.mts +1 -1
  47. package/dist/Classes/TaxRule.d.ts +1 -1
  48. package/dist/Classes/TieredPrice.d.mts +1 -1
  49. package/dist/Classes/TieredPrice.d.ts +1 -1
  50. package/dist/{Common-BPgGKaZC.d.ts → Common-BsfeCt6G.d.ts} +1 -0
  51. package/dist/{Common-DY253_Gs.d.mts → Common-Du2s_43h.d.mts} +1 -0
  52. package/dist/chunk-2POPOJGE.mjs +2 -0
  53. package/dist/chunk-2POPOJGE.mjs.map +1 -0
  54. package/dist/index.d.mts +1 -1
  55. package/dist/index.d.ts +1 -1
  56. package/package.json +1 -1
  57. package/dist/chunk-DBB6UTQH.mjs +0 -2
  58. package/dist/chunk-DBB6UTQH.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import {a as a$1}from'../chunk-DBB6UTQH.mjs';import'../chunk-B2VFJRLS.mjs';import {b}from'../chunk-HX32EJ3F.mjs';import'../chunk-G6LH7V5B.mjs';import'../chunk-SOZHGHMY.mjs';import'../chunk-RQ2FFWUW.mjs';import'../chunk-MHLRJ4IJ.mjs';import'../chunk-FCRJAAPY.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-LI5JQ6UC.mjs';import'../chunk-QK4XJ3GB.mjs';import {a as a$2}from'../chunk-R5DM7WCD.mjs';import'../chunk-UXZBULDS.mjs';var a=(s=>(s.PLACED="PLACED",s.PENDING_PAYMENT="PENDING_PAYMENT",s.PROCESSING="PROCESSING",s.CANCELLED="CANCELLED",s.COMPLETED="COMPLETED",s))(a||{}),i=class extends a$1{orderNumber;cartId;paymentStatus;holdReason;state;shippingAddress;billingAddress;constructor(t,e=new Date){super(t,e,{checkCouponExpiry:!1}),this.orderNumber=t.orderNumber,this.cartId=t.cartId,this.paymentStatus=t.paymentStatus,this.holdReason=t.holdReason||"",this.state=t.state,this.shippingAddress=new b(t.shippingAddress,e),this.billingAddress=new b(t.billingAddress,e);}getCustomerId(){return this.customerId}getCustomerEmail(){return this.customerEmail}getShippingAddress(){return this.shippingAddress}getBillingAddress(){return this.billingAddress}getOrderNumber(){return this.orderNumber}getCartId(){return this.cartId}getPaymentStatus(){return this.paymentStatus}getHoldReason(){return this.holdReason}getState(){return this.state}getLineItemState(t){let e=this.getLineItems().find(d=>d.getId()===t);if(!e)throw new a$2(t);return e.getState()}getDetails(){return {...super.getDetails(),orderNumber:this.getOrderNumber(),customerId:this.getCustomerId(),customerEmail:this.getCustomerEmail(),shippingAddress:this.getShippingAddress().getDetails(),billingAddress:this.getBillingAddress().getDetails(),cartId:this.getCartId(),paymentStatus:this.getPaymentStatus(),holdReason:this.getHoldReason(),state:this.getState()}}};export{a as OrderState,i as default};//# sourceMappingURL=Order.mjs.map
1
+ import {a as a$1}from'../chunk-2POPOJGE.mjs';import'../chunk-B2VFJRLS.mjs';import {b}from'../chunk-HX32EJ3F.mjs';import'../chunk-G6LH7V5B.mjs';import'../chunk-SOZHGHMY.mjs';import'../chunk-RQ2FFWUW.mjs';import'../chunk-MHLRJ4IJ.mjs';import'../chunk-FCRJAAPY.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-LI5JQ6UC.mjs';import'../chunk-QK4XJ3GB.mjs';import {a as a$2}from'../chunk-R5DM7WCD.mjs';import'../chunk-UXZBULDS.mjs';var a=(s=>(s.PLACED="PLACED",s.PENDING_PAYMENT="PENDING_PAYMENT",s.PROCESSING="PROCESSING",s.CANCELLED="CANCELLED",s.COMPLETED="COMPLETED",s))(a||{}),i=class extends a$1{orderNumber;cartId;paymentStatus;holdReason;state;shippingAddress;billingAddress;constructor(t,e=new Date){super(t,e,{checkCouponExpiry:!1}),this.orderNumber=t.orderNumber,this.cartId=t.cartId,this.paymentStatus=t.paymentStatus,this.holdReason=t.holdReason||"",this.state=t.state,this.shippingAddress=new b(t.shippingAddress,e),this.billingAddress=new b(t.billingAddress,e);}getCustomerId(){return this.customerId}getCustomerEmail(){return this.customerEmail}getShippingAddress(){return this.shippingAddress}getBillingAddress(){return this.billingAddress}getOrderNumber(){return this.orderNumber}getCartId(){return this.cartId}getPaymentStatus(){return this.paymentStatus}getHoldReason(){return this.holdReason}getState(){return this.state}getLineItemState(t){let e=this.getLineItems().find(d=>d.getId()===t);if(!e)throw new a$2(t);return e.getState()}getDetails(){return {...super.getDetails(),orderNumber:this.getOrderNumber(),customerId:this.getCustomerId(),customerEmail:this.getCustomerEmail(),shippingAddress:this.getShippingAddress().getDetails(),billingAddress:this.getBillingAddress().getDetails(),cartId:this.getCartId(),paymentStatus:this.getPaymentStatus(),holdReason:this.getHoldReason(),state:this.getState()}}};export{a as OrderState,i as default};//# sourceMappingURL=Order.mjs.map
2
2
  //# sourceMappingURL=Order.mjs.map
@@ -1,5 +1,5 @@
1
1
  import BaseModel, { BaseAttributes, BaseData } from './Base.mjs';
2
- import { c as CurrencyCode, I as ISODateTimeUTC } from '../Common-DY253_Gs.mjs';
2
+ import { c as CurrencyCode, I as ISODateTimeUTC } from '../Common-Du2s_43h.mjs';
3
3
  import '../Auth/index.mjs';
4
4
  import './Enum.mjs';
5
5
 
@@ -9,7 +9,8 @@ declare enum PaymentStatus {
9
9
  CAPTURED = "CAPTURED",
10
10
  FAILED = "FAILED",
11
11
  REFUNDED = "REFUNDED",
12
- PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED"
12
+ PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED",
13
+ CANCELLED = "CANCELLED"
13
14
  }
14
15
  declare enum PaymentMode {
15
16
  PAY_LATER = "PAY_LATER",
@@ -1,5 +1,5 @@
1
1
  import BaseModel, { BaseAttributes, BaseData } from './Base.js';
2
- import { c as CurrencyCode, I as ISODateTimeUTC } from '../Common-BPgGKaZC.js';
2
+ import { c as CurrencyCode, I as ISODateTimeUTC } from '../Common-BsfeCt6G.js';
3
3
  import '../Auth/index.js';
4
4
  import './Enum.js';
5
5
 
@@ -9,7 +9,8 @@ declare enum PaymentStatus {
9
9
  CAPTURED = "CAPTURED",
10
10
  FAILED = "FAILED",
11
11
  REFUNDED = "REFUNDED",
12
- PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED"
12
+ PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED",
13
+ CANCELLED = "CANCELLED"
13
14
  }
14
15
  declare enum PaymentMode {
15
16
  PAY_LATER = "PAY_LATER",
@@ -1,2 +1,2 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var u=n=>structuredClone(n),d=class{customFields;constructor(t,e=new Date){this.customFields={...t.customFields};}getCustomField(t){let e=this.customFields[t];return e==null?e:u(e)}setCustomField(t,e){this.customFields[t]=e;}getAllCustomFields(){return u(this.customFields)}},i=class extends d{version;createdAt;modifiedAt;modifiedBy;constructor(t,e=new Date){super(t),this.version=t.version??1,this.createdAt=t.createdAt&&!isNaN(Date.parse(t.createdAt))?new Date(t.createdAt).toISOString():e.toISOString(),this.modifiedAt=t.modifiedAt&&!isNaN(Date.parse(t.modifiedAt))?new Date(t.modifiedAt).toISOString():e.toISOString(),this.modifiedBy={...t.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(t,e,a,g){this.modifiedBy={id:t,authType:e,requestId:a,lambdaName:g};}};var m=(s=>(s.PENDING="PENDING",s.AUTHORIZED="AUTHORIZED",s.CAPTURED="CAPTURED",s.FAILED="FAILED",s.REFUNDED="REFUNDED",s.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",s))(m||{}),p=(r=>(r.PAY_LATER="PAY_LATER",r.CARD="CARD",r.CASH="CASH",r.NET_BANKING="NET_BANKING",r.WALLET="WALLET",r.COD="COD",r.UNKNOWN="UNKNOWN",r))(p||{}),o=class extends i{txnId;externalId;orderNumber;customerId;status;subStatus;amount;currency;paymentMode;gatewayResponse;gatewayErrorCode;gatewayErrorMessage;amountRefunded;cardLast4;cardBrand;transactionAt;constructor(t,e=new Date){super(t,e),this.txnId=t.txnId,this.externalId=t.externalId,this.orderNumber=t.orderNumber,this.customerId=t.customerId,this.status=t.status,this.subStatus=t.subStatus,this.amount=t.amount,this.currency=t.currency,this.paymentMode=t.paymentMode,this.gatewayResponse=t.gatewayResponse,this.gatewayErrorCode=t.gatewayErrorCode,this.gatewayErrorMessage=t.gatewayErrorMessage,this.amountRefunded=t.amountRefunded||0,this.cardLast4=t.cardLast4,this.cardBrand=t.cardBrand,this.transactionAt=t.transactionAt;}getTxnId(){return this.txnId}getExternalId(){return this.externalId}getOrderNumber(){return this.orderNumber}getCustomerId(){return this.customerId}getStatus(){return this.status}getSubStatus(){return this.subStatus}getAmount(){return this.amount}getCurrency(){return this.currency}getPaymentMode(){return this.paymentMode}getGatewayResponse(){return this.gatewayResponse}getGatewayErrorCode(){return this.gatewayErrorCode}getGatewayErrorMessage(){return this.gatewayErrorMessage}getAmountRefunded(){return this.amountRefunded}getCardLast4(){return this.cardLast4}getCardBrand(){return this.cardBrand}getTransactionAt(){return this.transactionAt}getDetails(){return {...super.getDetails(),txnId:this.getTxnId(),externalId:this.getExternalId(),orderNumber:this.getOrderNumber(),customerId:this.getCustomerId(),status:this.getStatus(),subStatus:this.getSubStatus(),amount:this.getAmount(),currency:this.getCurrency(),paymentMode:this.getPaymentMode(),gatewayErrorCode:this.getGatewayErrorCode(),amountRefunded:this.getAmountRefunded(),cardLast4:this.getCardLast4(),cardBrand:this.getCardBrand(),transactionAt:this.getTransactionAt()}}};exports.PaymentMode=p;exports.PaymentStatus=m;exports.default=o;//# sourceMappingURL=Payment.js.map
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var o=i=>structuredClone(i),n=class{customFields;constructor(t,r=new Date){this.customFields={...t.customFields};}getCustomField(t){let r=this.customFields[t];return r==null?r:o(r)}setCustomField(t,r){this.customFields[t]=r;}getAllCustomFields(){return o(this.customFields)}},s=class extends n{version;createdAt;modifiedAt;modifiedBy;constructor(t,r=new Date){super(t),this.version=t.version??1,this.createdAt=t.createdAt&&!isNaN(Date.parse(t.createdAt))?new Date(t.createdAt).toISOString():r.toISOString(),this.modifiedAt=t.modifiedAt&&!isNaN(Date.parse(t.modifiedAt))?new Date(t.modifiedAt).toISOString():r.toISOString(),this.modifiedBy={...t.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(t,r,u,a){this.modifiedBy={id:t,authType:r,requestId:u,lambdaName:a};}};var c=(e=>(e.PENDING="PENDING",e.AUTHORIZED="AUTHORIZED",e.CAPTURED="CAPTURED",e.FAILED="FAILED",e.REFUNDED="REFUNDED",e.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",e.CANCELLED="CANCELLED",e))(c||{}),m=(e=>(e.PAY_LATER="PAY_LATER",e.CARD="CARD",e.CASH="CASH",e.NET_BANKING="NET_BANKING",e.WALLET="WALLET",e.COD="COD",e.UNKNOWN="UNKNOWN",e))(m||{}),d=class extends s{txnId;externalId;orderNumber;customerId;status;subStatus;amount;currency;paymentMode;gatewayResponse;gatewayErrorCode;gatewayErrorMessage;amountRefunded;cardLast4;cardBrand;transactionAt;constructor(t,r=new Date){super(t,r),this.txnId=t.txnId,this.externalId=t.externalId,this.orderNumber=t.orderNumber,this.customerId=t.customerId,this.status=t.status,this.subStatus=t.subStatus,this.amount=t.amount,this.currency=t.currency,this.paymentMode=t.paymentMode,this.gatewayResponse=t.gatewayResponse,this.gatewayErrorCode=t.gatewayErrorCode,this.gatewayErrorMessage=t.gatewayErrorMessage,this.amountRefunded=t.amountRefunded||0,this.cardLast4=t.cardLast4,this.cardBrand=t.cardBrand,this.transactionAt=t.transactionAt;}getTxnId(){return this.txnId}getExternalId(){return this.externalId}getOrderNumber(){return this.orderNumber}getCustomerId(){return this.customerId}getStatus(){return this.status}getSubStatus(){return this.subStatus}getAmount(){return this.amount}getCurrency(){return this.currency}getPaymentMode(){return this.paymentMode}getGatewayResponse(){return this.gatewayResponse}getGatewayErrorCode(){return this.gatewayErrorCode}getGatewayErrorMessage(){return this.gatewayErrorMessage}getAmountRefunded(){return this.amountRefunded}getCardLast4(){return this.cardLast4}getCardBrand(){return this.cardBrand}getTransactionAt(){return this.transactionAt}getDetails(){return {...super.getDetails(),txnId:this.getTxnId(),externalId:this.getExternalId(),orderNumber:this.getOrderNumber(),customerId:this.getCustomerId(),status:this.getStatus(),subStatus:this.getSubStatus(),amount:this.getAmount(),currency:this.getCurrency(),paymentMode:this.getPaymentMode(),gatewayErrorCode:this.getGatewayErrorCode(),amountRefunded:this.getAmountRefunded(),cardLast4:this.getCardLast4(),cardBrand:this.getCardBrand(),transactionAt:this.getTransactionAt()}}};exports.PaymentMode=m;exports.PaymentStatus=c;exports.default=d;//# sourceMappingURL=Payment.js.map
2
2
  //# sourceMappingURL=Payment.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Classes/Base.ts","../../src/Classes/Payment.ts"],"names":["deepClone","obj","CustomFieldModel","data","date","fieldName","value","Base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GAFkB,KAAA,CAAM,UAAW,EAAA,CAGnC,KAAO,CAAA,IAAA,CAAK,QAAS,EAAA,CACrB,UAAY,CAAA,IAAA,CAAK,aAAc,EAAA,CAC/B,WAAa,CAAA,IAAA,CAAK,cAAe,EAAA,CACjC,UAAY,CAAA,IAAA,CAAK,aAAc,EAAA,CAC/B,MAAQ,CAAA,IAAA,CAAK,SAAU,EAAA,CACvB,SAAW,CAAA,IAAA,CAAK,cAChB,CAAA,MAAA,CAAQ,IAAK,CAAA,SAAA,EACb,CAAA,QAAA,CAAU,IAAK,CAAA,WAAA,EACf,CAAA,WAAA,CAAa,IAAK,CAAA,cAAA,EAClB,CAAA,gBAAA,CAAkB,IAAK,CAAA,mBAAA,GACvB,cAAgB,CAAA,IAAA,CAAK,iBAAkB,EAAA,CACvC,SAAW,CAAA,IAAA,CAAK,YAAa,EAAA,CAC7B,SAAW,CAAA,IAAA,CAAK,YAAa,EAAA,CAC7B,aAAe,CAAA,IAAA,CAAK,gBAAiB,EACvC,CACF,CACF","file":"Payment.js","sourcesContent":["import { AuthType } from \"../Auth\";\nimport { ISODateTimeUTC, Prettify } from \"./Common\";\n\nconst deepClone = <T>(obj: T): T => structuredClone(obj);\n\r\nexport interface CustomFields {\r\n [key: string]: any;\r\n}\r\n\r\nexport type CustomFieldAttributes = {\r\n customFields?: CustomFields;\r\n}\r\n\r\nexport class CustomFieldModel {\r\n protected customFields: CustomFields;\r\n constructor(data: CustomFieldAttributes, date: Date = new Date()) {\r\n this.customFields = { ...data.customFields };\r\n }\r\n\r\n /**\r\n * Retrieves the value of a specific custom field.\r\n * @param fieldName - The name (key) of the custom field to retrieve.\r\n * @returns The value of the custom field, or null if the field does not exist.\r\n */\r\n getCustomField(fieldName: string): any {\n const value = this.customFields[fieldName];\n if (value === undefined || value === null) return value;\n return deepClone(value);\n }\n\r\n /**\r\n * Sets the value of a specific custom field.\r\n * Also updates the modification timestamp and increments the version.\r\n * @param fieldName - The name (key) of the custom field to set.\r\n * @param value - The value to assign to the custom field.\r\n */\r\n setCustomField(fieldName: string, value: any): void {\r\n this.customFields[fieldName] = value;\r\n }\r\n\r\n /**\r\n * Retrieves a shallow copy of all custom fields associated with the instance.\r\n * @returns An object containing all custom fields.\r\n */\r\n getAllCustomFields(): CustomFields {\n return deepClone(this.customFields);\n }\n}\r\n\r\nexport type ModifiedBy = {\r\n id?: string;\r\n authType?: string;\r\n requestId?: string;\r\n lambdaName?: string;\r\n}\r\n\r\nexport type BaseAttributes = Prettify<CustomFieldAttributes & {\r\n version?: number;\r\n createdAt?: ISODateTimeUTC;\r\n modifiedAt?: ISODateTimeUTC;\r\n modifiedBy?: ModifiedBy;\r\n}>;\r\n\r\nexport type BaseData = Required<BaseAttributes>;\r\n\r\n/**\r\n * Provides common foundational properties and methods for other data models.\r\n * Handles tracking of custom fields, versioning, and timestamps.\r\n */\r\nexport default class BaseModel extends CustomFieldModel {\r\n protected version: number;\r\n protected createdAt: ISODateTimeUTC;\r\n protected modifiedAt: ISODateTimeUTC;\r\n protected modifiedBy: ModifiedBy;\r\n\r\n /**\r\n * Creates an instance of BaseModel.\r\n * Initializes common properties like timestamps, version, and custom fields.\r\n * @param data - Optional initial attributes for the base model.\r\n * @param date - Optional date object to use for default timestamps (defaults to current time).\r\n */\r\n constructor(data: BaseAttributes, date: Date = new Date()) {\r\n super(data);\r\n this.version = data.version ?? 1;\r\n this.createdAt = data.createdAt && !isNaN(Date.parse(data.createdAt))\r\n ?\r\n new Date(data.createdAt).toISOString()\r\n :\r\n date.toISOString();\r\n this.modifiedAt = data.modifiedAt && !isNaN(Date.parse(data.modifiedAt))\r\n ? new Date(data.modifiedAt).toISOString()\r\n : date.toISOString();\r\n\r\n this.modifiedBy = { ...data.modifiedBy };\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the base model's current state.\r\n * @returns BaseData object containing common properties.\r\n */\r\n getDetails(): BaseData {\r\n return {\r\n customFields: this.getAllCustomFields(), // Use getter to return a copy\r\n version: this.getVersion(),\r\n createdAt: this.getCreatedAt(),\r\n modifiedAt: this.getModifiedAt(),\r\n modifiedBy: this.getModifiedBy(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current version number of the model instance.\r\n * @returns The version number.\r\n */\r\n getVersion(): number {\r\n return this.version;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as an ISO 8601 string.\r\n * @returns The creation timestamp string.\r\n */\r\n getCreatedAt(): string {\r\n return this.createdAt;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as a Unix epoch time (milliseconds).\r\n * @returns The creation time in milliseconds since the epoch.\r\n */\r\n getCreatedAtTime(): number {\r\n return new Date(this.createdAt).getTime();\r\n }\r\n\r\n\r\n /**\r\n * Gets the last modification timestamp as an ISO 8601 string.\r\n * @returns The last modification timestamp string.\r\n */\r\n getModifiedAt(): string {\r\n return this.modifiedAt;\r\n }\r\n\r\n /**\r\n * Gets the last modification timestamp as a Unix epoch time (milliseconds).\r\n * @returns The last modification time in milliseconds since the epoch.\r\n */\r\n getModifiedAtTime(): number {\r\n return new Date(this.modifiedAt).getTime();\r\n }\r\n\r\n /**\r\n * Gets the identifier of the user or process that last modified the instance.\r\n * @returns\r\n */\r\n getModifiedBy(): ModifiedBy {\r\n return { ...this.modifiedBy };\r\n }\r\n\r\n /**\r\n * Sets the identifier of the user or process that last modified the instance.\r\n * @param modifiedBy - The identifier string.\r\n */\r\n setModifiedBy(id?: string, authType?: AuthType, requestId?: string, lambdaName?: string): void {\r\n this.modifiedBy = {\r\n id,\r\n authType,\r\n requestId,\r\n lambdaName,\r\n };\r\n }\r\n}\r\n","import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CurrencyCode, ISODateTimeUTC } from \"./Common\";\r\n\r\nexport enum PaymentStatus {\r\n PENDING = \"PENDING\",\r\n AUTHORIZED = \"AUTHORIZED\",\r\n CAPTURED = \"CAPTURED\",\r\n FAILED = \"FAILED\",\r\n REFUNDED = \"REFUNDED\",\r\n PARTIALLY_REFUNDED = \"PARTIALLY_REFUNDED\",\r\n}\r\n\r\nexport enum PaymentMode {\r\n PAY_LATER = \"PAY_LATER\",\r\n CARD = \"CARD\",\r\n CASH = \"CASH\",\r\n NET_BANKING = \"NET_BANKING\",\r\n WALLET = \"WALLET\",\r\n COD = \"COD\",\r\n UNKNOWN = \"UNKNOWN\",\r\n}\r\n\r\n/**\r\n * Input attributes for creating or updating a PaymentModel.\r\n */\r\nexport type PaymentAttributes = BaseAttributes & {\r\n txnId: string;\r\n externalId?: string;\r\n orderNumber: string;\r\n customerId: string;\r\n status: PaymentStatus;\r\n subStatus?: string;\r\n amount: number;\r\n currency: CurrencyCode;\r\n paymentMode: PaymentMode;\r\n gatewayResponse?: string;\r\n gatewayErrorCode?: string;\r\n gatewayErrorMessage?: string;\r\n amountRefunded?: number;\r\n cardLast4?: string;\r\n cardBrand?: string;\r\n transactionAt: ISODateTimeUTC;\r\n};\r\n\r\n/**\r\n * Output data structure for a PaymentModel.\r\n * Excludes potentially large or sensitive fields by default.\r\n */\r\nexport type PaymentData = Omit<PaymentAttributes, 'gatewayResponse' | 'gatewayErrorMessage'> & BaseData\r\n\r\n/**\r\n * Represents a payment transaction, attempt, or record associated with an order.\r\n */\r\nexport default class PaymentModel extends BaseModel {\r\n protected txnId: string;\r\n protected externalId?: string;\r\n protected orderNumber: string;\r\n protected customerId: string;\r\n protected status: PaymentStatus;\r\n protected subStatus?: string;\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n protected paymentMode: PaymentMode;\r\n protected gatewayResponse?: string;\r\n protected gatewayErrorCode?: string;\r\n protected gatewayErrorMessage?: string;\r\n protected amountRefunded: number;\r\n protected cardLast4?: string;\r\n protected cardBrand?: string;\r\n protected transactionAt: ISODateTimeUTC;\r\n\r\n /**\r\n * Creates an instance of PaymentModel.\r\n * @param data - The initial payment attributes.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: PaymentAttributes, date: Date = new Date()) {\r\n super(data, date); // Pass BaseAttributes to parent\r\n\r\n // Assign properties\r\n this.txnId = data.txnId;\r\n this.externalId = data.externalId;\r\n this.orderNumber = data.orderNumber;\r\n this.customerId = data.customerId;\r\n this.status = data.status;\r\n this.subStatus = data.subStatus;\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n this.paymentMode = data.paymentMode;\r\n this.gatewayResponse = data.gatewayResponse;\r\n this.gatewayErrorCode = data.gatewayErrorCode;\r\n this.gatewayErrorMessage = data.gatewayErrorMessage;\r\n this.amountRefunded = data.amountRefunded || 0; // Default to 0 if undefined\r\n this.cardLast4 = data.cardLast4;\r\n this.cardBrand = data.cardBrand;\r\n this.transactionAt = data.transactionAt;\r\n }\r\n\r\n /**\r\n * Gets the primary transaction identifier.\r\n * @returns The transaction ID string.\r\n */\r\n public getTxnId(): string { return this.txnId; }\r\n\r\n /**\r\n * Gets the external identifier, often from a payment gateway.\r\n * @returns The external ID string, or undefined if not set.\r\n */\r\n public getExternalId(): string | undefined { return this.externalId; }\r\n\r\n /**\r\n * Gets the order number associated with this payment.\r\n * @returns The order number string.\r\n */\r\n public getOrderNumber(): string { return this.orderNumber; }\r\n\r\n /**\r\n * Gets the customer ID associated with this payment.\r\n * @returns The customer ID string.\r\n */\r\n public getCustomerId(): string { return this.customerId; }\r\n\r\n /**\r\n * Gets the current status of the payment (e.g., PENDING, CAPTURED).\r\n * @returns The PaymentStatus enum value.\r\n */\r\n public getStatus(): PaymentStatus { return this.status; }\r\n\r\n /**\r\n * Gets the detailed sub-status, often provided by the payment gateway.\r\n * @returns The sub-status string, or undefined if not set.\r\n */\r\n public getSubStatus(): string | undefined { return this.subStatus; }\r\n\r\n /**\r\n * Gets the amount of the payment transaction.\r\n * @returns The payment amount number.\r\n */\r\n public getAmount(): number { return this.amount; }\r\n\r\n /**\r\n * Gets the currency code for the payment amount.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode { return this.currency; }\r\n\r\n /**\r\n * Gets the mode or method used for the payment (e.g., CARD, COD).\r\n * @returns The PaymentMode enum value.\r\n */\r\n public getPaymentMode(): PaymentMode { return this.paymentMode; }\r\n\r\n /**\r\n * Gets the raw response data from the payment gateway (potentially large).\r\n * @returns The gateway response string, or undefined if not set.\r\n */\r\n public getGatewayResponse(): string | undefined { return this.gatewayResponse; }\r\n\r\n /**\r\n * Gets the error code returned by the payment gateway, if any.\r\n * @returns The gateway error code string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorCode(): string | undefined { return this.gatewayErrorCode; }\r\n\r\n /**\r\n * Gets the error message returned by the payment gateway, if any.\r\n * @returns The gateway error message string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorMessage(): string | undefined { return this.gatewayErrorMessage; }\r\n\r\n /**\r\n * Gets the total amount that has been refunded for this transaction.\r\n * @returns The refunded amount number (defaults to 0).\r\n */\r\n public getAmountRefunded(): number { return this.amountRefunded; }\r\n\r\n /**\r\n * Gets the last 4 digits of the card used, if applicable.\r\n * @returns The card's last 4 digits string, or undefined.\r\n */\r\n public getCardLast4(): string | undefined { return this.cardLast4; }\r\n\r\n /**\r\n * Gets the brand of the card used (e.g., Visa, Mastercard), if applicable.\r\n * @returns The card brand string, or undefined.\r\n */\r\n public getCardBrand(): string | undefined { return this.cardBrand; }\r\n\r\n /**\r\n * Gets the timestamp when the transaction occurred or was recorded.\r\n * @returns The transaction timestamp as an ISO 8601 string.\r\n */\r\n public getTransactionAt(): ISODateTimeUTC { return this.transactionAt; }\r\n\r\n\r\n /**\r\n * Gets a plain data object representing the payment's current state.\r\n * @returns PaymentData object suitable for serialization or API responses.\r\n */\r\n getDetails(): PaymentData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n ...baseDetails,\r\n txnId: this.getTxnId(),\r\n externalId: this.getExternalId(),\r\n orderNumber: this.getOrderNumber(),\r\n customerId: this.getCustomerId(),\r\n status: this.getStatus(),\r\n subStatus: this.getSubStatus(),\r\n amount: this.getAmount(),\r\n currency: this.getCurrency(),\r\n paymentMode: this.getPaymentMode(),\r\n gatewayErrorCode: this.getGatewayErrorCode(),\r\n amountRefunded: this.getAmountRefunded(),\r\n cardLast4: this.getCardLast4(),\r\n cardBrand: this.getCardBrand(),\r\n transactionAt: this.getTransactionAt(),\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../src/Classes/Base.ts","../../src/Classes/Payment.ts"],"names":["deepClone","obj","CustomFieldModel","data","date","fieldName","value","BaseModel","id","authType","requestId","lambdaName","PaymentStatus","PaymentMode","PaymentModel"],"mappings":"sEAGA,IAAMA,CAAgBC,CAAAA,CAAAA,EAAc,eAAgBA,CAAAA,CAAG,CAU1CC,CAAAA,CAAAA,CAAN,KAAuB,CAClB,YACV,CAAA,WAAA,CAAYC,CAA6BC,CAAAA,CAAAA,CAAa,IAAI,IAAA,CAAQ,CAChE,IAAA,CAAK,YAAe,CAAA,CAAE,GAAGD,CAAAA,CAAK,YAAa,EAC7C,CAOA,cAAA,CAAeE,CAAwB,CAAA,CACrC,IAAMC,CAAAA,CAAQ,KAAK,YAAaD,CAAAA,CAAS,CACzC,CAAA,OAA2BC,CAAU,EAAA,IAAA,CAAaA,CAC3CN,CAAAA,CAAAA,CAAUM,CAAK,CACxB,CAQA,cAAA,CAAeD,CAAmBC,CAAAA,CAAAA,CAAkB,CAClD,IAAA,CAAK,aAAaD,CAAS,CAAA,CAAIC,EACjC,CAMA,kBAAmC,EAAA,CACjC,OAAON,CAAAA,CAAU,IAAK,CAAA,YAAY,CACpC,CACF,CAsBqBO,CAAAA,CAAAA,CAArB,cAAuCL,CAAiB,CAC5C,OACA,CAAA,SAAA,CACA,UACA,CAAA,UAAA,CAQV,WAAYC,CAAAA,CAAAA,CAAsBC,CAAa,CAAA,IAAI,IAAQ,CAAA,CACzD,KAAMD,CAAAA,CAAI,CACV,CAAA,IAAA,CAAK,OAAUA,CAAAA,CAAAA,CAAK,OAAW,EAAA,CAAA,CAC/B,IAAK,CAAA,SAAA,CAAYA,CAAK,CAAA,SAA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E,OAAO,IAAK,CAAA,gBAAkB,CAM1E,sBAAA,EAA6C,CAAE,OAAO,IAAK,CAAA,mBAAqB,CAMhF,iBAAA,EAA4B,CAAE,OAAO,KAAK,cAAgB,CAM1D,YAAmC,EAAA,CAAE,OAAO,IAAA,CAAK,SAAW,CAM5D,YAAmC,EAAA,CAAE,OAAO,IAAA,CAAK,SAAW,CAM5D,gBAAmC,EAAA,CAAE,OAAO,IAAK,CAAA,aAAe,CAOvE,UAAA,EAA0B,CAExB,OAAO,CACL,GAFkB,KAAM,CAAA,UAAA,EAGxB,CAAA,KAAA,CAAO,IAAK,CAAA,QAAA,EACZ,CAAA,UAAA,CAAY,KAAK,aAAc,EAAA,CAC/B,WAAa,CAAA,IAAA,CAAK,cAAe,EAAA,CACjC,UAAY,CAAA,IAAA,CAAK,aAAc,EAAA,CAC/B,MAAQ,CAAA,IAAA,CAAK,SAAU,EAAA,CACvB,SAAW,CAAA,IAAA,CAAK,cAChB,CAAA,MAAA,CAAQ,IAAK,CAAA,SAAA,EACb,CAAA,QAAA,CAAU,IAAK,CAAA,WAAA,EACf,CAAA,WAAA,CAAa,IAAK,CAAA,cAAA,EAClB,CAAA,gBAAA,CAAkB,IAAK,CAAA,mBAAA,GACvB,cAAgB,CAAA,IAAA,CAAK,iBAAkB,EAAA,CACvC,SAAW,CAAA,IAAA,CAAK,YAAa,EAAA,CAC7B,SAAW,CAAA,IAAA,CAAK,YAAa,EAAA,CAC7B,aAAe,CAAA,IAAA,CAAK,gBAAiB,EACvC,CACF,CACF","file":"Payment.js","sourcesContent":["import { AuthType } from \"../Auth\";\nimport { ISODateTimeUTC, Prettify } from \"./Common\";\n\nconst deepClone = <T>(obj: T): T => structuredClone(obj);\n\r\nexport interface CustomFields {\r\n [key: string]: any;\r\n}\r\n\r\nexport type CustomFieldAttributes = {\r\n customFields?: CustomFields;\r\n}\r\n\r\nexport class CustomFieldModel {\r\n protected customFields: CustomFields;\r\n constructor(data: CustomFieldAttributes, date: Date = new Date()) {\r\n this.customFields = { ...data.customFields };\r\n }\r\n\r\n /**\r\n * Retrieves the value of a specific custom field.\r\n * @param fieldName - The name (key) of the custom field to retrieve.\r\n * @returns The value of the custom field, or null if the field does not exist.\r\n */\r\n getCustomField(fieldName: string): any {\n const value = this.customFields[fieldName];\n if (value === undefined || value === null) return value;\n return deepClone(value);\n }\n\r\n /**\r\n * Sets the value of a specific custom field.\r\n * Also updates the modification timestamp and increments the version.\r\n * @param fieldName - The name (key) of the custom field to set.\r\n * @param value - The value to assign to the custom field.\r\n */\r\n setCustomField(fieldName: string, value: any): void {\r\n this.customFields[fieldName] = value;\r\n }\r\n\r\n /**\r\n * Retrieves a shallow copy of all custom fields associated with the instance.\r\n * @returns An object containing all custom fields.\r\n */\r\n getAllCustomFields(): CustomFields {\n return deepClone(this.customFields);\n }\n}\r\n\r\nexport type ModifiedBy = {\r\n id?: string;\r\n authType?: string;\r\n requestId?: string;\r\n lambdaName?: string;\r\n}\r\n\r\nexport type BaseAttributes = Prettify<CustomFieldAttributes & {\r\n version?: number;\r\n createdAt?: ISODateTimeUTC;\r\n modifiedAt?: ISODateTimeUTC;\r\n modifiedBy?: ModifiedBy;\r\n}>;\r\n\r\nexport type BaseData = Required<BaseAttributes>;\r\n\r\n/**\r\n * Provides common foundational properties and methods for other data models.\r\n * Handles tracking of custom fields, versioning, and timestamps.\r\n */\r\nexport default class BaseModel extends CustomFieldModel {\r\n protected version: number;\r\n protected createdAt: ISODateTimeUTC;\r\n protected modifiedAt: ISODateTimeUTC;\r\n protected modifiedBy: ModifiedBy;\r\n\r\n /**\r\n * Creates an instance of BaseModel.\r\n * Initializes common properties like timestamps, version, and custom fields.\r\n * @param data - Optional initial attributes for the base model.\r\n * @param date - Optional date object to use for default timestamps (defaults to current time).\r\n */\r\n constructor(data: BaseAttributes, date: Date = new Date()) {\r\n super(data);\r\n this.version = data.version ?? 1;\r\n this.createdAt = data.createdAt && !isNaN(Date.parse(data.createdAt))\r\n ?\r\n new Date(data.createdAt).toISOString()\r\n :\r\n date.toISOString();\r\n this.modifiedAt = data.modifiedAt && !isNaN(Date.parse(data.modifiedAt))\r\n ? new Date(data.modifiedAt).toISOString()\r\n : date.toISOString();\r\n\r\n this.modifiedBy = { ...data.modifiedBy };\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the base model's current state.\r\n * @returns BaseData object containing common properties.\r\n */\r\n getDetails(): BaseData {\r\n return {\r\n customFields: this.getAllCustomFields(), // Use getter to return a copy\r\n version: this.getVersion(),\r\n createdAt: this.getCreatedAt(),\r\n modifiedAt: this.getModifiedAt(),\r\n modifiedBy: this.getModifiedBy(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current version number of the model instance.\r\n * @returns The version number.\r\n */\r\n getVersion(): number {\r\n return this.version;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as an ISO 8601 string.\r\n * @returns The creation timestamp string.\r\n */\r\n getCreatedAt(): string {\r\n return this.createdAt;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as a Unix epoch time (milliseconds).\r\n * @returns The creation time in milliseconds since the epoch.\r\n */\r\n getCreatedAtTime(): number {\r\n return new Date(this.createdAt).getTime();\r\n }\r\n\r\n\r\n /**\r\n * Gets the last modification timestamp as an ISO 8601 string.\r\n * @returns The last modification timestamp string.\r\n */\r\n getModifiedAt(): string {\r\n return this.modifiedAt;\r\n }\r\n\r\n /**\r\n * Gets the last modification timestamp as a Unix epoch time (milliseconds).\r\n * @returns The last modification time in milliseconds since the epoch.\r\n */\r\n getModifiedAtTime(): number {\r\n return new Date(this.modifiedAt).getTime();\r\n }\r\n\r\n /**\r\n * Gets the identifier of the user or process that last modified the instance.\r\n * @returns\r\n */\r\n getModifiedBy(): ModifiedBy {\r\n return { ...this.modifiedBy };\r\n }\r\n\r\n /**\r\n * Sets the identifier of the user or process that last modified the instance.\r\n * @param modifiedBy - The identifier string.\r\n */\r\n setModifiedBy(id?: string, authType?: AuthType, requestId?: string, lambdaName?: string): void {\r\n this.modifiedBy = {\r\n id,\r\n authType,\r\n requestId,\r\n lambdaName,\r\n };\r\n }\r\n}\r\n","import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CurrencyCode, ISODateTimeUTC } from \"./Common\";\r\n\r\nexport enum PaymentStatus {\r\n PENDING = \"PENDING\",\r\n AUTHORIZED = \"AUTHORIZED\",\r\n CAPTURED = \"CAPTURED\",\r\n FAILED = \"FAILED\",\r\n REFUNDED = \"REFUNDED\",\r\n PARTIALLY_REFUNDED = \"PARTIALLY_REFUNDED\",\r\n CANCELLED = \"CANCELLED\"\r\n}\r\n\r\nexport enum PaymentMode {\r\n PAY_LATER = \"PAY_LATER\",\r\n CARD = \"CARD\",\r\n CASH = \"CASH\",\r\n NET_BANKING = \"NET_BANKING\",\r\n WALLET = \"WALLET\",\r\n COD = \"COD\",\r\n UNKNOWN = \"UNKNOWN\",\r\n}\r\n\r\n/**\r\n * Input attributes for creating or updating a PaymentModel.\r\n */\r\nexport type PaymentAttributes = BaseAttributes & {\r\n txnId: string;\r\n externalId?: string;\r\n orderNumber: string;\r\n customerId: string;\r\n status: PaymentStatus;\r\n subStatus?: string;\r\n amount: number;\r\n currency: CurrencyCode;\r\n paymentMode: PaymentMode;\r\n gatewayResponse?: string;\r\n gatewayErrorCode?: string;\r\n gatewayErrorMessage?: string;\r\n amountRefunded?: number;\r\n cardLast4?: string;\r\n cardBrand?: string;\r\n transactionAt: ISODateTimeUTC;\r\n};\r\n\r\n/**\r\n * Output data structure for a PaymentModel.\r\n * Excludes potentially large or sensitive fields by default.\r\n */\r\nexport type PaymentData = Omit<PaymentAttributes, 'gatewayResponse' | 'gatewayErrorMessage'> & BaseData\r\n\r\n/**\r\n * Represents a payment transaction, attempt, or record associated with an order.\r\n */\r\nexport default class PaymentModel extends BaseModel {\r\n protected txnId: string;\r\n protected externalId?: string;\r\n protected orderNumber: string;\r\n protected customerId: string;\r\n protected status: PaymentStatus;\r\n protected subStatus?: string;\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n protected paymentMode: PaymentMode;\r\n protected gatewayResponse?: string;\r\n protected gatewayErrorCode?: string;\r\n protected gatewayErrorMessage?: string;\r\n protected amountRefunded: number;\r\n protected cardLast4?: string;\r\n protected cardBrand?: string;\r\n protected transactionAt: ISODateTimeUTC;\r\n\r\n /**\r\n * Creates an instance of PaymentModel.\r\n * @param data - The initial payment attributes.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: PaymentAttributes, date: Date = new Date()) {\r\n super(data, date); // Pass BaseAttributes to parent\r\n\r\n // Assign properties\r\n this.txnId = data.txnId;\r\n this.externalId = data.externalId;\r\n this.orderNumber = data.orderNumber;\r\n this.customerId = data.customerId;\r\n this.status = data.status;\r\n this.subStatus = data.subStatus;\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n this.paymentMode = data.paymentMode;\r\n this.gatewayResponse = data.gatewayResponse;\r\n this.gatewayErrorCode = data.gatewayErrorCode;\r\n this.gatewayErrorMessage = data.gatewayErrorMessage;\r\n this.amountRefunded = data.amountRefunded || 0; // Default to 0 if undefined\r\n this.cardLast4 = data.cardLast4;\r\n this.cardBrand = data.cardBrand;\r\n this.transactionAt = data.transactionAt;\r\n }\r\n\r\n /**\r\n * Gets the primary transaction identifier.\r\n * @returns The transaction ID string.\r\n */\r\n public getTxnId(): string { return this.txnId; }\r\n\r\n /**\r\n * Gets the external identifier, often from a payment gateway.\r\n * @returns The external ID string, or undefined if not set.\r\n */\r\n public getExternalId(): string | undefined { return this.externalId; }\r\n\r\n /**\r\n * Gets the order number associated with this payment.\r\n * @returns The order number string.\r\n */\r\n public getOrderNumber(): string { return this.orderNumber; }\r\n\r\n /**\r\n * Gets the customer ID associated with this payment.\r\n * @returns The customer ID string.\r\n */\r\n public getCustomerId(): string { return this.customerId; }\r\n\r\n /**\r\n * Gets the current status of the payment (e.g., PENDING, CAPTURED).\r\n * @returns The PaymentStatus enum value.\r\n */\r\n public getStatus(): PaymentStatus { return this.status; }\r\n\r\n /**\r\n * Gets the detailed sub-status, often provided by the payment gateway.\r\n * @returns The sub-status string, or undefined if not set.\r\n */\r\n public getSubStatus(): string | undefined { return this.subStatus; }\r\n\r\n /**\r\n * Gets the amount of the payment transaction.\r\n * @returns The payment amount number.\r\n */\r\n public getAmount(): number { return this.amount; }\r\n\r\n /**\r\n * Gets the currency code for the payment amount.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode { return this.currency; }\r\n\r\n /**\r\n * Gets the mode or method used for the payment (e.g., CARD, COD).\r\n * @returns The PaymentMode enum value.\r\n */\r\n public getPaymentMode(): PaymentMode { return this.paymentMode; }\r\n\r\n /**\r\n * Gets the raw response data from the payment gateway (potentially large).\r\n * @returns The gateway response string, or undefined if not set.\r\n */\r\n public getGatewayResponse(): string | undefined { return this.gatewayResponse; }\r\n\r\n /**\r\n * Gets the error code returned by the payment gateway, if any.\r\n * @returns The gateway error code string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorCode(): string | undefined { return this.gatewayErrorCode; }\r\n\r\n /**\r\n * Gets the error message returned by the payment gateway, if any.\r\n * @returns The gateway error message string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorMessage(): string | undefined { return this.gatewayErrorMessage; }\r\n\r\n /**\r\n * Gets the total amount that has been refunded for this transaction.\r\n * @returns The refunded amount number (defaults to 0).\r\n */\r\n public getAmountRefunded(): number { return this.amountRefunded; }\r\n\r\n /**\r\n * Gets the last 4 digits of the card used, if applicable.\r\n * @returns The card's last 4 digits string, or undefined.\r\n */\r\n public getCardLast4(): string | undefined { return this.cardLast4; }\r\n\r\n /**\r\n * Gets the brand of the card used (e.g., Visa, Mastercard), if applicable.\r\n * @returns The card brand string, or undefined.\r\n */\r\n public getCardBrand(): string | undefined { return this.cardBrand; }\r\n\r\n /**\r\n * Gets the timestamp when the transaction occurred or was recorded.\r\n * @returns The transaction timestamp as an ISO 8601 string.\r\n */\r\n public getTransactionAt(): ISODateTimeUTC { return this.transactionAt; }\r\n\r\n\r\n /**\r\n * Gets a plain data object representing the payment's current state.\r\n * @returns PaymentData object suitable for serialization or API responses.\r\n */\r\n getDetails(): PaymentData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n ...baseDetails,\r\n txnId: this.getTxnId(),\r\n externalId: this.getExternalId(),\r\n orderNumber: this.getOrderNumber(),\r\n customerId: this.getCustomerId(),\r\n status: this.getStatus(),\r\n subStatus: this.getSubStatus(),\r\n amount: this.getAmount(),\r\n currency: this.getCurrency(),\r\n paymentMode: this.getPaymentMode(),\r\n gatewayErrorCode: this.getGatewayErrorCode(),\r\n amountRefunded: this.getAmountRefunded(),\r\n cardLast4: this.getCardLast4(),\r\n cardBrand: this.getCardBrand(),\r\n transactionAt: this.getTransactionAt(),\r\n };\r\n }\r\n}\r\n"]}
@@ -1,2 +1,2 @@
1
- import {b}from'../chunk-UXZBULDS.mjs';var u=(r=>(r.PENDING="PENDING",r.AUTHORIZED="AUTHORIZED",r.CAPTURED="CAPTURED",r.FAILED="FAILED",r.REFUNDED="REFUNDED",r.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",r))(u||{}),i=(e=>(e.PAY_LATER="PAY_LATER",e.CARD="CARD",e.CASH="CASH",e.NET_BANKING="NET_BANKING",e.WALLET="WALLET",e.COD="COD",e.UNKNOWN="UNKNOWN",e))(i||{}),s=class extends b{txnId;externalId;orderNumber;customerId;status;subStatus;amount;currency;paymentMode;gatewayResponse;gatewayErrorCode;gatewayErrorMessage;amountRefunded;cardLast4;cardBrand;transactionAt;constructor(t,a=new Date){super(t,a),this.txnId=t.txnId,this.externalId=t.externalId,this.orderNumber=t.orderNumber,this.customerId=t.customerId,this.status=t.status,this.subStatus=t.subStatus,this.amount=t.amount,this.currency=t.currency,this.paymentMode=t.paymentMode,this.gatewayResponse=t.gatewayResponse,this.gatewayErrorCode=t.gatewayErrorCode,this.gatewayErrorMessage=t.gatewayErrorMessage,this.amountRefunded=t.amountRefunded||0,this.cardLast4=t.cardLast4,this.cardBrand=t.cardBrand,this.transactionAt=t.transactionAt;}getTxnId(){return this.txnId}getExternalId(){return this.externalId}getOrderNumber(){return this.orderNumber}getCustomerId(){return this.customerId}getStatus(){return this.status}getSubStatus(){return this.subStatus}getAmount(){return this.amount}getCurrency(){return this.currency}getPaymentMode(){return this.paymentMode}getGatewayResponse(){return this.gatewayResponse}getGatewayErrorCode(){return this.gatewayErrorCode}getGatewayErrorMessage(){return this.gatewayErrorMessage}getAmountRefunded(){return this.amountRefunded}getCardLast4(){return this.cardLast4}getCardBrand(){return this.cardBrand}getTransactionAt(){return this.transactionAt}getDetails(){return {...super.getDetails(),txnId:this.getTxnId(),externalId:this.getExternalId(),orderNumber:this.getOrderNumber(),customerId:this.getCustomerId(),status:this.getStatus(),subStatus:this.getSubStatus(),amount:this.getAmount(),currency:this.getCurrency(),paymentMode:this.getPaymentMode(),gatewayErrorCode:this.getGatewayErrorCode(),amountRefunded:this.getAmountRefunded(),cardLast4:this.getCardLast4(),cardBrand:this.getCardBrand(),transactionAt:this.getTransactionAt()}}};export{i as PaymentMode,u as PaymentStatus,s as default};//# sourceMappingURL=Payment.mjs.map
1
+ import {b}from'../chunk-UXZBULDS.mjs';var a=(e=>(e.PENDING="PENDING",e.AUTHORIZED="AUTHORIZED",e.CAPTURED="CAPTURED",e.FAILED="FAILED",e.REFUNDED="REFUNDED",e.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",e.CANCELLED="CANCELLED",e))(a||{}),u=(e=>(e.PAY_LATER="PAY_LATER",e.CARD="CARD",e.CASH="CASH",e.NET_BANKING="NET_BANKING",e.WALLET="WALLET",e.COD="COD",e.UNKNOWN="UNKNOWN",e))(u||{}),r=class extends b{txnId;externalId;orderNumber;customerId;status;subStatus;amount;currency;paymentMode;gatewayResponse;gatewayErrorCode;gatewayErrorMessage;amountRefunded;cardLast4;cardBrand;transactionAt;constructor(t,n=new Date){super(t,n),this.txnId=t.txnId,this.externalId=t.externalId,this.orderNumber=t.orderNumber,this.customerId=t.customerId,this.status=t.status,this.subStatus=t.subStatus,this.amount=t.amount,this.currency=t.currency,this.paymentMode=t.paymentMode,this.gatewayResponse=t.gatewayResponse,this.gatewayErrorCode=t.gatewayErrorCode,this.gatewayErrorMessage=t.gatewayErrorMessage,this.amountRefunded=t.amountRefunded||0,this.cardLast4=t.cardLast4,this.cardBrand=t.cardBrand,this.transactionAt=t.transactionAt;}getTxnId(){return this.txnId}getExternalId(){return this.externalId}getOrderNumber(){return this.orderNumber}getCustomerId(){return this.customerId}getStatus(){return this.status}getSubStatus(){return this.subStatus}getAmount(){return this.amount}getCurrency(){return this.currency}getPaymentMode(){return this.paymentMode}getGatewayResponse(){return this.gatewayResponse}getGatewayErrorCode(){return this.gatewayErrorCode}getGatewayErrorMessage(){return this.gatewayErrorMessage}getAmountRefunded(){return this.amountRefunded}getCardLast4(){return this.cardLast4}getCardBrand(){return this.cardBrand}getTransactionAt(){return this.transactionAt}getDetails(){return {...super.getDetails(),txnId:this.getTxnId(),externalId:this.getExternalId(),orderNumber:this.getOrderNumber(),customerId:this.getCustomerId(),status:this.getStatus(),subStatus:this.getSubStatus(),amount:this.getAmount(),currency:this.getCurrency(),paymentMode:this.getPaymentMode(),gatewayErrorCode:this.getGatewayErrorCode(),amountRefunded:this.getAmountRefunded(),cardLast4:this.getCardLast4(),cardBrand:this.getCardBrand(),transactionAt:this.getTransactionAt()}}};export{u as PaymentMode,a as PaymentStatus,r as default};//# sourceMappingURL=Payment.mjs.map
2
2
  //# sourceMappingURL=Payment.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Classes/Payment.ts"],"names":["PaymentStatus","PaymentMode","PaymentModel","BaseModel","data","date"],"mappings":"sCAGO,IAAKA,CACVA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,OAAU,CAAA,SAAA,CACVA,EAAA,UAAa,CAAA,YAAA,CACbA,CAAA,CAAA,QAAA,CAAW,WACXA,CAAA,CAAA,MAAA,CA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,WAAa,CAAA,IAAA,CAAK,cAAe,EAAA,CACjC,WAAY,IAAK,CAAA,aAAA,EACjB,CAAA,MAAA,CAAQ,KAAK,SAAU,EAAA,CACvB,SAAW,CAAA,IAAA,CAAK,YAAa,EAAA,CAC7B,MAAQ,CAAA,IAAA,CAAK,WACb,CAAA,QAAA,CAAU,IAAK,CAAA,WAAA,GACf,WAAa,CAAA,IAAA,CAAK,cAAe,EAAA,CACjC,iBAAkB,IAAK,CAAA,mBAAA,EACvB,CAAA,cAAA,CAAgB,KAAK,iBAAkB,EAAA,CACvC,SAAW,CAAA,IAAA,CAAK,cAChB,CAAA,SAAA,CAAW,IAAK,CAAA,YAAA,GAChB,aAAe,CAAA,IAAA,CAAK,gBAAiB,EACvC,CACF,CACF","file":"Payment.mjs","sourcesContent":["import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CurrencyCode, ISODateTimeUTC } from \"./Common\";\r\n\r\nexport enum PaymentStatus {\r\n PENDING = \"PENDING\",\r\n AUTHORIZED = \"AUTHORIZED\",\r\n CAPTURED = \"CAPTURED\",\r\n FAILED = \"FAILED\",\r\n REFUNDED = \"REFUNDED\",\r\n PARTIALLY_REFUNDED = \"PARTIALLY_REFUNDED\",\r\n}\r\n\r\nexport enum PaymentMode {\r\n PAY_LATER = \"PAY_LATER\",\r\n CARD = \"CARD\",\r\n CASH = \"CASH\",\r\n NET_BANKING = \"NET_BANKING\",\r\n WALLET = \"WALLET\",\r\n COD = \"COD\",\r\n UNKNOWN = \"UNKNOWN\",\r\n}\r\n\r\n/**\r\n * Input attributes for creating or updating a PaymentModel.\r\n */\r\nexport type PaymentAttributes = BaseAttributes & {\r\n txnId: string;\r\n externalId?: string;\r\n orderNumber: string;\r\n customerId: string;\r\n status: PaymentStatus;\r\n subStatus?: string;\r\n amount: number;\r\n currency: CurrencyCode;\r\n paymentMode: PaymentMode;\r\n gatewayResponse?: string;\r\n gatewayErrorCode?: string;\r\n gatewayErrorMessage?: string;\r\n amountRefunded?: number;\r\n cardLast4?: string;\r\n cardBrand?: string;\r\n transactionAt: ISODateTimeUTC;\r\n};\r\n\r\n/**\r\n * Output data structure for a PaymentModel.\r\n * Excludes potentially large or sensitive fields by default.\r\n */\r\nexport type PaymentData = Omit<PaymentAttributes, 'gatewayResponse' | 'gatewayErrorMessage'> & BaseData\r\n\r\n/**\r\n * Represents a payment transaction, attempt, or record associated with an order.\r\n */\r\nexport default class PaymentModel extends BaseModel {\r\n protected txnId: string;\r\n protected externalId?: string;\r\n protected orderNumber: string;\r\n protected customerId: string;\r\n protected status: PaymentStatus;\r\n protected subStatus?: string;\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n protected paymentMode: PaymentMode;\r\n protected gatewayResponse?: string;\r\n protected gatewayErrorCode?: string;\r\n protected gatewayErrorMessage?: string;\r\n protected amountRefunded: number;\r\n protected cardLast4?: string;\r\n protected cardBrand?: string;\r\n protected transactionAt: ISODateTimeUTC;\r\n\r\n /**\r\n * Creates an instance of PaymentModel.\r\n * @param data - The initial payment attributes.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: PaymentAttributes, date: Date = new Date()) {\r\n super(data, date); // Pass BaseAttributes to parent\r\n\r\n // Assign properties\r\n this.txnId = data.txnId;\r\n this.externalId = data.externalId;\r\n this.orderNumber = data.orderNumber;\r\n this.customerId = data.customerId;\r\n this.status = data.status;\r\n this.subStatus = data.subStatus;\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n this.paymentMode = data.paymentMode;\r\n this.gatewayResponse = data.gatewayResponse;\r\n this.gatewayErrorCode = data.gatewayErrorCode;\r\n this.gatewayErrorMessage = data.gatewayErrorMessage;\r\n this.amountRefunded = data.amountRefunded || 0; // Default to 0 if undefined\r\n this.cardLast4 = data.cardLast4;\r\n this.cardBrand = data.cardBrand;\r\n this.transactionAt = data.transactionAt;\r\n }\r\n\r\n /**\r\n * Gets the primary transaction identifier.\r\n * @returns The transaction ID string.\r\n */\r\n public getTxnId(): string { return this.txnId; }\r\n\r\n /**\r\n * Gets the external identifier, often from a payment gateway.\r\n * @returns The external ID string, or undefined if not set.\r\n */\r\n public getExternalId(): string | undefined { return this.externalId; }\r\n\r\n /**\r\n * Gets the order number associated with this payment.\r\n * @returns The order number string.\r\n */\r\n public getOrderNumber(): string { return this.orderNumber; }\r\n\r\n /**\r\n * Gets the customer ID associated with this payment.\r\n * @returns The customer ID string.\r\n */\r\n public getCustomerId(): string { return this.customerId; }\r\n\r\n /**\r\n * Gets the current status of the payment (e.g., PENDING, CAPTURED).\r\n * @returns The PaymentStatus enum value.\r\n */\r\n public getStatus(): PaymentStatus { return this.status; }\r\n\r\n /**\r\n * Gets the detailed sub-status, often provided by the payment gateway.\r\n * @returns The sub-status string, or undefined if not set.\r\n */\r\n public getSubStatus(): string | undefined { return this.subStatus; }\r\n\r\n /**\r\n * Gets the amount of the payment transaction.\r\n * @returns The payment amount number.\r\n */\r\n public getAmount(): number { return this.amount; }\r\n\r\n /**\r\n * Gets the currency code for the payment amount.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode { return this.currency; }\r\n\r\n /**\r\n * Gets the mode or method used for the payment (e.g., CARD, COD).\r\n * @returns The PaymentMode enum value.\r\n */\r\n public getPaymentMode(): PaymentMode { return this.paymentMode; }\r\n\r\n /**\r\n * Gets the raw response data from the payment gateway (potentially large).\r\n * @returns The gateway response string, or undefined if not set.\r\n */\r\n public getGatewayResponse(): string | undefined { return this.gatewayResponse; }\r\n\r\n /**\r\n * Gets the error code returned by the payment gateway, if any.\r\n * @returns The gateway error code string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorCode(): string | undefined { return this.gatewayErrorCode; }\r\n\r\n /**\r\n * Gets the error message returned by the payment gateway, if any.\r\n * @returns The gateway error message string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorMessage(): string | undefined { return this.gatewayErrorMessage; }\r\n\r\n /**\r\n * Gets the total amount that has been refunded for this transaction.\r\n * @returns The refunded amount number (defaults to 0).\r\n */\r\n public getAmountRefunded(): number { return this.amountRefunded; }\r\n\r\n /**\r\n * Gets the last 4 digits of the card used, if applicable.\r\n * @returns The card's last 4 digits string, or undefined.\r\n */\r\n public getCardLast4(): string | undefined { return this.cardLast4; }\r\n\r\n /**\r\n * Gets the brand of the card used (e.g., Visa, Mastercard), if applicable.\r\n * @returns The card brand string, or undefined.\r\n */\r\n public getCardBrand(): string | undefined { return this.cardBrand; }\r\n\r\n /**\r\n * Gets the timestamp when the transaction occurred or was recorded.\r\n * @returns The transaction timestamp as an ISO 8601 string.\r\n */\r\n public getTransactionAt(): ISODateTimeUTC { return this.transactionAt; }\r\n\r\n\r\n /**\r\n * Gets a plain data object representing the payment's current state.\r\n * @returns PaymentData object suitable for serialization or API responses.\r\n */\r\n getDetails(): PaymentData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n ...baseDetails,\r\n txnId: this.getTxnId(),\r\n externalId: this.getExternalId(),\r\n orderNumber: this.getOrderNumber(),\r\n customerId: this.getCustomerId(),\r\n status: this.getStatus(),\r\n subStatus: this.getSubStatus(),\r\n amount: this.getAmount(),\r\n currency: this.getCurrency(),\r\n paymentMode: this.getPaymentMode(),\r\n gatewayErrorCode: this.getGatewayErrorCode(),\r\n amountRefunded: this.getAmountRefunded(),\r\n cardLast4: this.getCardLast4(),\r\n cardBrand: this.getCardBrand(),\r\n transactionAt: this.getTransactionAt(),\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../src/Classes/Payment.ts"],"names":["PaymentStatus","PaymentMode","PaymentModel","BaseModel","data","date"],"mappings":"sCAGO,IAAKA,CACVA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,OAAU,CAAA,SAAA,CACVA,EAAA,UAAa,CAAA,YAAA,CACbA,CAAA,CAAA,QAAA,CAAW,WACXA,CAAA,CAAA,MAAA,CAAS,QACTA,CAAAA,CAAAA,CAAA,SAAW,UACXA,CAAAA,C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CACjC,WAAY,IAAK,CAAA,aAAA,EACjB,CAAA,MAAA,CAAQ,KAAK,SAAU,EAAA,CACvB,SAAW,CAAA,IAAA,CAAK,YAAa,EAAA,CAC7B,MAAQ,CAAA,IAAA,CAAK,WACb,CAAA,QAAA,CAAU,IAAK,CAAA,WAAA,GACf,WAAa,CAAA,IAAA,CAAK,cAAe,EAAA,CACjC,iBAAkB,IAAK,CAAA,mBAAA,EACvB,CAAA,cAAA,CAAgB,KAAK,iBAAkB,EAAA,CACvC,SAAW,CAAA,IAAA,CAAK,cAChB,CAAA,SAAA,CAAW,IAAK,CAAA,YAAA,GAChB,aAAe,CAAA,IAAA,CAAK,gBAAiB,EACvC,CACF,CACF","file":"Payment.mjs","sourcesContent":["import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CurrencyCode, ISODateTimeUTC } from \"./Common\";\r\n\r\nexport enum PaymentStatus {\r\n PENDING = \"PENDING\",\r\n AUTHORIZED = \"AUTHORIZED\",\r\n CAPTURED = \"CAPTURED\",\r\n FAILED = \"FAILED\",\r\n REFUNDED = \"REFUNDED\",\r\n PARTIALLY_REFUNDED = \"PARTIALLY_REFUNDED\",\r\n CANCELLED = \"CANCELLED\"\r\n}\r\n\r\nexport enum PaymentMode {\r\n PAY_LATER = \"PAY_LATER\",\r\n CARD = \"CARD\",\r\n CASH = \"CASH\",\r\n NET_BANKING = \"NET_BANKING\",\r\n WALLET = \"WALLET\",\r\n COD = \"COD\",\r\n UNKNOWN = \"UNKNOWN\",\r\n}\r\n\r\n/**\r\n * Input attributes for creating or updating a PaymentModel.\r\n */\r\nexport type PaymentAttributes = BaseAttributes & {\r\n txnId: string;\r\n externalId?: string;\r\n orderNumber: string;\r\n customerId: string;\r\n status: PaymentStatus;\r\n subStatus?: string;\r\n amount: number;\r\n currency: CurrencyCode;\r\n paymentMode: PaymentMode;\r\n gatewayResponse?: string;\r\n gatewayErrorCode?: string;\r\n gatewayErrorMessage?: string;\r\n amountRefunded?: number;\r\n cardLast4?: string;\r\n cardBrand?: string;\r\n transactionAt: ISODateTimeUTC;\r\n};\r\n\r\n/**\r\n * Output data structure for a PaymentModel.\r\n * Excludes potentially large or sensitive fields by default.\r\n */\r\nexport type PaymentData = Omit<PaymentAttributes, 'gatewayResponse' | 'gatewayErrorMessage'> & BaseData\r\n\r\n/**\r\n * Represents a payment transaction, attempt, or record associated with an order.\r\n */\r\nexport default class PaymentModel extends BaseModel {\r\n protected txnId: string;\r\n protected externalId?: string;\r\n protected orderNumber: string;\r\n protected customerId: string;\r\n protected status: PaymentStatus;\r\n protected subStatus?: string;\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n protected paymentMode: PaymentMode;\r\n protected gatewayResponse?: string;\r\n protected gatewayErrorCode?: string;\r\n protected gatewayErrorMessage?: string;\r\n protected amountRefunded: number;\r\n protected cardLast4?: string;\r\n protected cardBrand?: string;\r\n protected transactionAt: ISODateTimeUTC;\r\n\r\n /**\r\n * Creates an instance of PaymentModel.\r\n * @param data - The initial payment attributes.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: PaymentAttributes, date: Date = new Date()) {\r\n super(data, date); // Pass BaseAttributes to parent\r\n\r\n // Assign properties\r\n this.txnId = data.txnId;\r\n this.externalId = data.externalId;\r\n this.orderNumber = data.orderNumber;\r\n this.customerId = data.customerId;\r\n this.status = data.status;\r\n this.subStatus = data.subStatus;\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n this.paymentMode = data.paymentMode;\r\n this.gatewayResponse = data.gatewayResponse;\r\n this.gatewayErrorCode = data.gatewayErrorCode;\r\n this.gatewayErrorMessage = data.gatewayErrorMessage;\r\n this.amountRefunded = data.amountRefunded || 0; // Default to 0 if undefined\r\n this.cardLast4 = data.cardLast4;\r\n this.cardBrand = data.cardBrand;\r\n this.transactionAt = data.transactionAt;\r\n }\r\n\r\n /**\r\n * Gets the primary transaction identifier.\r\n * @returns The transaction ID string.\r\n */\r\n public getTxnId(): string { return this.txnId; }\r\n\r\n /**\r\n * Gets the external identifier, often from a payment gateway.\r\n * @returns The external ID string, or undefined if not set.\r\n */\r\n public getExternalId(): string | undefined { return this.externalId; }\r\n\r\n /**\r\n * Gets the order number associated with this payment.\r\n * @returns The order number string.\r\n */\r\n public getOrderNumber(): string { return this.orderNumber; }\r\n\r\n /**\r\n * Gets the customer ID associated with this payment.\r\n * @returns The customer ID string.\r\n */\r\n public getCustomerId(): string { return this.customerId; }\r\n\r\n /**\r\n * Gets the current status of the payment (e.g., PENDING, CAPTURED).\r\n * @returns The PaymentStatus enum value.\r\n */\r\n public getStatus(): PaymentStatus { return this.status; }\r\n\r\n /**\r\n * Gets the detailed sub-status, often provided by the payment gateway.\r\n * @returns The sub-status string, or undefined if not set.\r\n */\r\n public getSubStatus(): string | undefined { return this.subStatus; }\r\n\r\n /**\r\n * Gets the amount of the payment transaction.\r\n * @returns The payment amount number.\r\n */\r\n public getAmount(): number { return this.amount; }\r\n\r\n /**\r\n * Gets the currency code for the payment amount.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode { return this.currency; }\r\n\r\n /**\r\n * Gets the mode or method used for the payment (e.g., CARD, COD).\r\n * @returns The PaymentMode enum value.\r\n */\r\n public getPaymentMode(): PaymentMode { return this.paymentMode; }\r\n\r\n /**\r\n * Gets the raw response data from the payment gateway (potentially large).\r\n * @returns The gateway response string, or undefined if not set.\r\n */\r\n public getGatewayResponse(): string | undefined { return this.gatewayResponse; }\r\n\r\n /**\r\n * Gets the error code returned by the payment gateway, if any.\r\n * @returns The gateway error code string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorCode(): string | undefined { return this.gatewayErrorCode; }\r\n\r\n /**\r\n * Gets the error message returned by the payment gateway, if any.\r\n * @returns The gateway error message string, or undefined if no error occurred or wasn't recorded.\r\n */\r\n public getGatewayErrorMessage(): string | undefined { return this.gatewayErrorMessage; }\r\n\r\n /**\r\n * Gets the total amount that has been refunded for this transaction.\r\n * @returns The refunded amount number (defaults to 0).\r\n */\r\n public getAmountRefunded(): number { return this.amountRefunded; }\r\n\r\n /**\r\n * Gets the last 4 digits of the card used, if applicable.\r\n * @returns The card's last 4 digits string, or undefined.\r\n */\r\n public getCardLast4(): string | undefined { return this.cardLast4; }\r\n\r\n /**\r\n * Gets the brand of the card used (e.g., Visa, Mastercard), if applicable.\r\n * @returns The card brand string, or undefined.\r\n */\r\n public getCardBrand(): string | undefined { return this.cardBrand; }\r\n\r\n /**\r\n * Gets the timestamp when the transaction occurred or was recorded.\r\n * @returns The transaction timestamp as an ISO 8601 string.\r\n */\r\n public getTransactionAt(): ISODateTimeUTC { return this.transactionAt; }\r\n\r\n\r\n /**\r\n * Gets a plain data object representing the payment's current state.\r\n * @returns PaymentData object suitable for serialization or API responses.\r\n */\r\n getDetails(): PaymentData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n ...baseDetails,\r\n txnId: this.getTxnId(),\r\n externalId: this.getExternalId(),\r\n orderNumber: this.getOrderNumber(),\r\n customerId: this.getCustomerId(),\r\n status: this.getStatus(),\r\n subStatus: this.getSubStatus(),\r\n amount: this.getAmount(),\r\n currency: this.getCurrency(),\r\n paymentMode: this.getPaymentMode(),\r\n gatewayErrorCode: this.getGatewayErrorCode(),\r\n amountRefunded: this.getAmountRefunded(),\r\n cardLast4: this.getCardLast4(),\r\n cardBrand: this.getCardBrand(),\r\n transactionAt: this.getTransactionAt(),\r\n };\r\n }\r\n}\r\n"]}
@@ -1,2 +1,2 @@
1
- export { g as PriceAttributes, P as PriceData, a as default } from '../Common-DY253_Gs.mjs';
1
+ export { g as PriceAttributes, P as PriceData, a as default } from '../Common-Du2s_43h.mjs';
2
2
  import './Enum.mjs';
@@ -1,2 +1,2 @@
1
- export { g as PriceAttributes, P as PriceData, a as default } from '../Common-BPgGKaZC.js';
1
+ export { g as PriceAttributes, P as PriceData, a as default } from '../Common-BsfeCt6G.js';
2
2
  import './Enum.js';
@@ -1,5 +1,5 @@
1
1
  import BaseModel, { BaseAttributes } from './Base.mjs';
2
- import { b as Prettify, f as Color, d as LocalizedString, C as CountryCode, e as LocalizedValue, L as LocaleCode } from '../Common-DY253_Gs.mjs';
2
+ import { b as Prettify, f as Color, d as LocalizedString, C as CountryCode, e as LocalizedValue, L as LocaleCode } from '../Common-Du2s_43h.mjs';
3
3
  import { GenderCategory, ImageCategory } from './Enum.mjs';
4
4
  import ImageInfoModel, { ImageInfoData } from './ImageInfo.mjs';
5
5
  import { TieredPriceAttributes, TieredPriceModel } from './TieredPrice.mjs';
@@ -1,5 +1,5 @@
1
1
  import BaseModel, { BaseAttributes } from './Base.js';
2
- import { b as Prettify, f as Color, d as LocalizedString, C as CountryCode, e as LocalizedValue, L as LocaleCode } from '../Common-BPgGKaZC.js';
2
+ import { b as Prettify, f as Color, d as LocalizedString, C as CountryCode, e as LocalizedValue, L as LocaleCode } from '../Common-BsfeCt6G.js';
3
3
  import { GenderCategory, ImageCategory } from './Enum.js';
4
4
  import ImageInfoModel, { ImageInfoData } from './ImageInfo.js';
5
5
  import { TieredPriceAttributes, TieredPriceModel } from './TieredPrice.js';
@@ -1,7 +1,7 @@
1
1
  import BaseModel, { BaseAttributes, BaseData } from './Base.mjs';
2
2
  import AddressModel, { AddressData } from './Address.mjs';
3
3
  import LineItemModel, { LineItemData } from './LineItem.mjs';
4
- import { P as PriceData, a as PriceModel, S as ShippingDetails, C as CountryCode, c as CurrencyCode, L as LocaleCode } from '../Common-DY253_Gs.mjs';
4
+ import { P as PriceData, a as PriceModel, S as ShippingDetails, C as CountryCode, c as CurrencyCode, L as LocaleCode } from '../Common-Du2s_43h.mjs';
5
5
  import CouponModel, { CouponData } from './Coupon.mjs';
6
6
  import { TaxSystem } from './Enum.mjs';
7
7
  import ChargeModel, { ChargeData } from './Charge.mjs';
@@ -115,6 +115,7 @@ type BaseShoppingContainerData = BaseShoppingContainerAttributes & BaseData;
115
115
  * Manages common elements such as line items, addresses, coupons, and totals.
116
116
  */
117
117
  declare abstract class BaseShoppingContainerModel extends BaseModel {
118
+ #private;
118
119
  protected id: string;
119
120
  protected customerId?: string;
120
121
  protected customerEmail?: string;
@@ -129,7 +130,6 @@ declare abstract class BaseShoppingContainerModel extends BaseModel {
129
130
  protected country: CountryCode;
130
131
  protected currency: CurrencyCode;
131
132
  protected locale: LocaleCode;
132
- private metaData;
133
133
  /**
134
134
  * Creates an instance of BaseShoppingContainerModel.
135
135
  * Initializes common properties and calculates initial base totals.
@@ -1,7 +1,7 @@
1
1
  import BaseModel, { BaseAttributes, BaseData } from './Base.js';
2
2
  import AddressModel, { AddressData } from './Address.js';
3
3
  import LineItemModel, { LineItemData } from './LineItem.js';
4
- import { P as PriceData, a as PriceModel, S as ShippingDetails, C as CountryCode, c as CurrencyCode, L as LocaleCode } from '../Common-BPgGKaZC.js';
4
+ import { P as PriceData, a as PriceModel, S as ShippingDetails, C as CountryCode, c as CurrencyCode, L as LocaleCode } from '../Common-BsfeCt6G.js';
5
5
  import CouponModel, { CouponData } from './Coupon.js';
6
6
  import { TaxSystem } from './Enum.js';
7
7
  import ChargeModel, { ChargeData } from './Charge.js';
@@ -115,6 +115,7 @@ type BaseShoppingContainerData = BaseShoppingContainerAttributes & BaseData;
115
115
  * Manages common elements such as line items, addresses, coupons, and totals.
116
116
  */
117
117
  declare abstract class BaseShoppingContainerModel extends BaseModel {
118
+ #private;
118
119
  protected id: string;
119
120
  protected customerId?: string;
120
121
  protected customerEmail?: string;
@@ -129,7 +130,6 @@ declare abstract class BaseShoppingContainerModel extends BaseModel {
129
130
  protected country: CountryCode;
130
131
  protected currency: CurrencyCode;
131
132
  protected locale: LocaleCode;
132
- private metaData;
133
133
  /**
134
134
  * Creates an instance of BaseShoppingContainerModel.
135
135
  * Initializes common properties and calculates initial base totals.
@@ -1,2 +1,2 @@
1
- 'use strict';var Mt=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Mt__default=/*#__PURE__*/_interopDefault(Mt);var Tt=n=>structuredClone(n),B=class{customFields;constructor(t,e=new Date){this.customFields={...t.customFields};}getCustomField(t){let e=this.customFields[t];return e==null?e:Tt(e)}setCustomField(t,e){this.customFields[t]=e;}getAllCustomFields(){return Tt(this.customFields)}},w=class extends B{version;createdAt;modifiedAt;modifiedBy;constructor(t,e=new Date){super(t),this.version=t.version??1,this.createdAt=t.createdAt&&!isNaN(Date.parse(t.createdAt))?new Date(t.createdAt).toISOString():e.toISOString(),this.modifiedAt=t.modifiedAt&&!isNaN(Date.parse(t.modifiedAt))?new Date(t.modifiedAt).toISOString():e.toISOString(),this.modifiedBy={...t.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(t,e,i,r){this.modifiedBy={id:t,authType:e,requestId:i,lambdaName:r};}};var U=class extends w{id;firstName;lastName;company;phone;email;addressLine1;addressLine2;city;postalCode;state;country;isBillingAddress;isShippingAddress;constructor(t,e=new Date){super(t,e),this.id=t.id,this.firstName=t.firstName,this.lastName=t.lastName||"",this.company=t.company||"",this.phone=t.phone,this.email=t.email,this.addressLine1=t.addressLine1,this.addressLine2=t.addressLine2||"",this.city=t.city,this.postalCode=t.postalCode,this.state=t.state,this.country=t.country,this.isBillingAddress=t.isBillingAddress,this.isShippingAddress=t.isShippingAddress;}getDetails(){return {...super.getDetails(),id:this.getId(),firstName:this.getFirstName(),lastName:this.getLastName(),company:this.getCompany(),phone:this.getPhone(),email:this.getEmail(),addressLine1:this.getAddressLine1(),addressLine2:this.getAddressLine2(),city:this.getCity(),postalCode:this.getPostalCode(),state:this.getState(),country:this.getCountry(),isBillingAddress:this.getIsBillingAddress(),isShippingAddress:this.getIsShippingAddress()}}getId(){return this.id}getFirstName(){return this.firstName}getLastName(){return this.lastName}getCompany(){return this.company}getPhone(){return this.phone}getEmail(){return this.email}getAddressLine1(){return this.addressLine1}getAddressLine2(){return this.addressLine2}getCity(){return this.city}getPostalCode(){return this.postalCode}getState(){return this.state}getCountry(){return this.country}getIsBillingAddress(){return this.isBillingAddress}getIsShippingAddress(){return this.isShippingAddress}getAddressType(){return this.isBillingAddress&&this.isShippingAddress?"billing&shipping":this.isBillingAddress?"billing":this.isShippingAddress?"shipping":"none"}static checkIfShippingAddress(t){return t==="shipping"||t==="billing&shipping"}static checkIfBillingAddress(t){return t==="billing"||t==="billing&shipping"}};var X=new Uint8Array(256),J=X.length;function mt(){return J>X.length-16&&(Mt__default.default.randomFillSync(X),J=0),X.slice(J,J+=16)}var ft=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function wt(n){return typeof n=="string"&&ft.test(n)}var It=wt;var I=[];for(let n=0;n<256;++n)I.push((n+256).toString(16).slice(1));function W(n,t=0){return I[n[t+0]]+I[n[t+1]]+I[n[t+2]]+I[n[t+3]]+"-"+I[n[t+4]]+I[n[t+5]]+"-"+I[n[t+6]]+I[n[t+7]]+"-"+I[n[t+8]]+I[n[t+9]]+"-"+I[n[t+10]]+I[n[t+11]]+I[n[t+12]]+I[n[t+13]]+I[n[t+14]]+I[n[t+15]]}function Lt(n){if(!It(n))throw TypeError("Invalid UUID");let t,e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}var At=Lt;function vt(n){n=unescape(encodeURIComponent(n));let t=[];for(let e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var Et="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Bt="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ht(n,t,e){function i(r,o,a,g){var d;if(typeof r=="string"&&(r=vt(r)),typeof o=="string"&&(o=At(o)),((d=o)===null||d===void 0?void 0:d.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+r.length);if(c.set(o),c.set(r,o.length),c=e(c),c[6]=c[6]&15|t,c[8]=c[8]&63|128,a){g=g||0;for(let u=0;u<16;++u)a[g+u]=c[u];return a}return W(c)}try{i.name=n;}catch{}return i.DNS=Et,i.URL=Bt,i}var yt={randomUUID:Mt__default.default.randomUUID};function kt(n,t,e){if(yt.randomUUID&&!t&&!n)return yt.randomUUID();n=n||{};let i=n.random||(n.rng||mt)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let r=0;r<16;++r)t[e+r]=i[r];return t}return W(i)}var bt=kt;function Ut(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),Mt__default.default.createHash("sha1").update(n).digest()}var St=Ut;var Ot=ht("v5",80,St),Ct=Ot;var P={"en-IN":"en","kn-IN":"kn"};var Pt={INR:"\u20B9"},Dt={INR:"en-IN"};var _=(u=>(u.INITIAL="INITIAL",u.PROCESSING="PROCESSING",u.SHIPPED="SHIPPED",u.DELIVERED="DELIVERED",u.CANCELLED="CANCELLED",u.RETURN_REQUESTED="RETURN_REQUESTED",u.RETURNED="RETURNED",u.REFUND_INITIATED="REFUND_INITIATED",u.REFUNDED="REFUNDED",u.ON_HOLD="ON_HOLD",u))(_||{});var tt=class extends Error{constructor(t){super(`Invalid line item state: ${t}`),this.name="InvalidLineItemStateError";}},et=class extends Error{constructor(t){super(`InvalidLineItemTaxRule: ${t}`),this.name="InvalidLineItemTaxRuleError";}},it=class extends Error{constructor(t){super(`Duplicate size found: ${t}`),this.name="DuplicateSizeError";}},rt=class extends Error{constructor(t){super(`Duplicate selection attribute found: ${t}`),this.name="DuplicateSelectionAttributeError";}},nt=class extends Error{constructor(t="Product and selection attributes do not match."){super(`ProductMismatch: ${t}`),this.name="ProductMismatchError";}},ot=class extends Error{constructor(t="Product is not active."){super(`ProductInactive: ${t}`),this.name="ProductInactiveError";}},L=class extends Error{constructor(t="Failed to parse selection attributes key."){super(`SelectionAttributeParseError: ${t}`),this.name="SelectionAttributeParseError";}},st=class extends Error{constructor(t="Size does not match."){super(`SizeMismatch: ${t}`),this.name="SizeMismatchError";}},at=class extends Error{constructor(t="Pricing details not available for the product"){super(`NotFound: ${t}`),this.name="PricingNotFoundError";}},F=class extends Error{constructor(t="Tax rule category mismatch."){super(`InvalidTaxRule: ${t}`),this.name="InvalidTaxRuleError";}},ct=class extends Error{constructor(t="Tax category is not valid."){super(`InvalidTaxCategory: ${t}`),this.name="InvalidTaxCategoryError";}},lt=class extends Error{constructor(t="Minimum quantity must be greater than zero."){super(`InvalidMinQuantity: ${t}`),this.name="InvalidMinQuantityError";}},ut=class extends Error{constructor(t){super(`InvalidTieredPrice: ${t}`),this.name="InvalidTieredPriceError";}},dt=class extends Error{constructor(t="Quantity must be greater than zero."){super(`InvalidQuantity: ${t}`),this.name="InvalidQuantityError";}},gt=class extends Error{constructor(t){super(`NoApplicableTier: Quantity ${t} does not meet the minimum purchase requirement.`),this.name="NoApplicableTierError";}};var Q=class extends Error{constructor(t="Amount cannot be negative."){super(`InvalidAmount: ${t}`),this.name="InvalidPriceAmountError";}},z=class extends Error{constructor(t="Currency code is required."){super(`InvalidCurrency: ${t}`),this.name="InvalidCurrencyCodeError";}},v=class extends Error{constructor(t="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${t}`),this.name="CurrencyMismatchError";}},D=class extends Error{constructor(t){super(`InvalidArgument: ${t}`),this.name="InvalidArgumentError";}},H=class extends Error{constructor(t="Invalid image source configuration."){super(`InvalidImageSource: ${t}`),this.name="InvalidImageSourceError";}},Z=class extends Error{constructor(t="Invalid charge data."){super(`InvalidCharge: ${t}`),this.name="InvalidChargeError";}},j=class extends Error{constructor(t="Invalid charge tax rule."){super(`InvalidChargeTaxRule: ${t}`),this.name="InvalidChargeTaxRuleError";}};var R=class{sources;alt;order;label;constructor(t){if(this.sources={...t.sources},this.alt=t.alt,this.order=t.order,this.label=t.label,!this.sources.original)throw new H("ImageInfoModel cannot be created without an 'original' source URL.")}getSources(){return {...this.sources}}getSource(t){return this.sources[t]||this.sources.original}getAlt(){return this.alt}getOrder(){return this.order}getLabel(){return this.label}setAlt(t){this.alt=t;}setOrder(t){this.order=t;}setLabel(t){this.label=t;}setSource(t,e){if(e===void 0){if(t==="original")throw new H("Cannot remove the 'original' image source.");delete this.sources[t];}else this.sources[t]=e;}getDetails(){return {sources:this.getSources(),alt:this.getAlt(),order:this.getOrder(),label:this.getLabel()}}};var s=class n{#t;amount;currency;constructor(t){if(this.#t="PriceModel",t.amount<0)throw new Q("Amount cannot be negative.");if(!t.currency)throw new z("Currency code is required.");this.currency=t.currency,this.amount=parseFloat(t.amount.toFixed(n.getPrecisionPlaces(this.currency)));}get kind(){return this.#t}static isPriceModel(t){return typeof t=="object"&&t!==null&&t.kind==="PriceModel"}getCurrency(){return this.currency}getAmount(){return this.amount}getDetails(){return {amount:this.amount,currency:this.currency}}getPreciseAmount(t){return parseFloat(t.toFixed(n.getPrecisionPlaces(this.currency)))}compareTo(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot compare prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return this.getPreciseAmount(this.amount-t.getAmount())}add(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot add prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return new n({amount:this.getPreciseAmount(this.amount+t.getAmount()),currency:this.currency})}subtract(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot subtract prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return new n({amount:this.getPreciseAmount(this.amount-t.getAmount()),currency:this.currency})}multiply(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot multiply prices in different currencies.");return new n({amount:this.getPreciseAmount(this.amount*t.getAmount()),currency:this.currency})}else if(typeof t=="number"&&t>=0)return new n({amount:this.getPreciseAmount(this.amount*t),currency:this.currency});throw new D("Must be a non-negative number.")}divide(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot divide prices in different currencies.");return new n({amount:this.getPreciseAmount(this.amount/t.getAmount()),currency:this.currency})}else if(typeof t=="number"&&t>0)return new n({amount:this.getPreciseAmount(this.amount/t),currency:this.currency});throw new D("Must be a positive number.")}min(...t){if(t.length===0)throw new D("Must provide at least one PriceModel.");return t.reduce((e,i)=>{if(n.isPriceModel(i)){if(e.getCurrency()!==i.getCurrency())throw new v("Cannot compare prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return e.compareTo(i)<0?e:i},this)}max(...t){if(t.length===0)throw new D("Must provide at least one PriceModel.");return t.reduce((e,i)=>{if(n.isPriceModel(i)){if(e.getCurrency()!==i.getCurrency())throw new v("Cannot compare prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return e.compareTo(i)>0?e:i},this)}zero(){return new n({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new n({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return n.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return n.getFormattedString(this.amount,this.currency)}toString(){return this.getFormattedString()}static getFormattedString(t,e,i={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let r=Dt[e];if(!e||!r)throw new z("Invalid currency code for formatting.");let o=t,a=i.displayAsInteger?0:n.getDecimalPlaces(e),g={style:i.style??"currency",currency:e,signDisplay:"never",currencyDisplay:i.currencyDisplay,minimumFractionDigits:a,maximumFractionDigits:a};i.displayAsInteger&&(o=Math.ceil(o));try{return new Intl.NumberFormat(r,g).format(o)}catch(d){return console.error(`Error formatting price for currency "${e}" and locale "${r}":`,d),`${Pt[e]??e} ${n.addThousandSeparators(o.toFixed(a))}`}}static getDecimalPlaces(t){switch(t){case"INR":default:return 2}}static getPrecisionPlaces(t){switch(t){case"INR":default:return 6}}static addThousandSeparators(t){let e=t.split("."),i=e[0],r=e.length>1?"."+e[1]:"";return i.replace(/\B(?=(\d{3})+(?!\d))/g,",")+r}static getRoundedAmount(t,e){if(t<0)throw new Q("Amount cannot be negative for rounding.");if(e===void 0)throw new z("Invalid currency code for rounding.");let i=n.getDecimalPlaces(e),r=Math.pow(10,i);return Math.round(t*r)/r}};var $=class{baseUnitPrice;taxCategory;tiers;constructor(t){let e=new s(t.baseUnitPrice);if(!t.taxCategory)throw new ct;let i=(t.tiers??[]).map(d=>({minQuantity:d.minQuantity,unitPrice:new s(d.unitPrice)})).sort((d,c)=>d.minQuantity-c.minQuantity);if(i.some(d=>d.minQuantity<=0))throw new lt;let o=i.some(d=>d.unitPrice.getCurrency()!==e.getCurrency()),a=i.some((d,c)=>c>0&&d.unitPrice.compareTo(i[c-1].unitPrice)>0),g=i[0]?.unitPrice.compareTo(e)>0;if(o||a||g)throw new ut("Tiers must share the same currency and must not increase in unit price.");this.baseUnitPrice=e,this.taxCategory=t.taxCategory,this.tiers=i;}getBaseUnitPrice(){return this.baseUnitPrice}getTaxCategory(){return this.taxCategory}getTiers(){return this.tiers.map(t=>({minQuantity:t.minQuantity,unitPrice:t.unitPrice}))}getDetails(){return {baseUnitPrice:this.baseUnitPrice.getDetails(),taxCategory:this.taxCategory,tiers:this.tiers.map(t=>({minQuantity:t.minQuantity,unitPrice:t.unitPrice.getDetails()}))}}getApplicableTier(t){if(t<=0)throw new dt;for(let e=this.tiers.length-1;e>=0;e--)if(t>=this.tiers[e].minQuantity){let i=this.tiers[e];return {minQuantity:i.minQuantity,unitPrice:i.unitPrice}}throw new gt(t)}getMinQuantity(){return this.tiers[0]?.minQuantity??1}getMaxDiscountPercent(){if(!this.tiers.length)return 0;let t=this.tiers[this.tiers.length-1].unitPrice.getAmount(),e=this.baseUnitPrice.getAmount();return (e-t)/e*100}};var V=class n extends w{id;key;name;description;slug;brand;pricing;variants;targetGender;attributes;specifications;categories;isActive;searchTags;static productKeyRegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static productSKURegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static generateSelectionAttributesKey(t){if(typeof t!="object")throw new L("Selection attributes must be an object");return Object.keys(t).filter(i=>t[i]!==void 0&&i.toLowerCase()!=="size").sort().map(i=>t[i].name?`${i}:c+${t[i].name}`:`${i}:${t[i]}`).join("|").toLowerCase()}static parseSelectionAttributesKey(t){try{let e={},i=t.split("|");for(let r of i){let[o,a]=r.split(":");a.startsWith("c+")?e[o]={name:a.slice(2)}:e[o]=a;}return e}catch(e){throw new L(e?.message)}}constructor(t,e=new Date){super(t,e),this.id=t.id,this.key=t.key,this.name={...t.name},this.description={...t.description},this.slug={...t.slug},this.brand=t.brand,this.pricing=Object.keys(t.pricing).reduce((r,o)=>(t.pricing[o]&&(r[o]=new $(t.pricing[o])),r),{}),this.targetGender=t.targetGender,this.attributes=m.deepClone(t.attributes),this.specifications=m.deepClone(t.specifications),this.categories=m.deepClone(t.categories);let i=new Set;this.variants=(t.variants||[]).map(r=>{if(!r.selectionAttributes||typeof r.selectionAttributes!="object")throw new L("Selection attributes are required");this.checkSelectionAttributes(r.selectionAttributes);let o=n.generateSelectionAttributesKey(r.selectionAttributes);if(i.has(o))throw new rt(o);return i.add(o),{sku:r.sku,selectionAttributes:r.selectionAttributes,images:{primary:new R(r.images.primary),gallery:(r.images.gallery||[]).map(a=>new R(a))}}}),this.isActive=t.isActive,this.searchTags=t.searchTags?m.deepClone(t.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getName(t){return t?this.name[t]??this.name[P[t]]??this.name.en:m.deepClone(this.name)}getDescription(t){return t?this.description[t]??this.description[P[t]]??this.description.en:m.deepClone(this.description)}getSlug(t){return t?this.slug[t]??this.slug[P[t]]??this.slug.en:m.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(t){return t?this.pricing[t]??null:{...this.pricing}}getAttributes(){return m.deepClone(this.attributes)}getVariants(){return this.variants.map(t=>({sku:t.sku,selectionAttributes:m.deepClone(t.selectionAttributes),images:{primary:t.images.primary,gallery:[...t.images.gallery]}}))}getImagesBySelectionAttributes(t){let e=n.generateSelectionAttributesKey(t),i=this.variants.find(r=>n.generateSelectionAttributesKey(r.selectionAttributes)===e);return i?{primary:i.images.primary,gallery:[...i.images.gallery]}:null}getImages(t,e){switch(e){case"PRIMARY":return this.getImagesBySelectionAttributes(t)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(t)?.gallery??[];default:return this.getImagesBySelectionAttributes(t)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return m.deepClone(this.categories)}getSpecifications(t){return t?m.deepClone(this.specifications[t]??this.specifications[P[t]]??this.specifications.en):m.deepClone(this.specifications)}getSearchTags(t){return t?m.deepClone(this.searchTags[t]??this.searchTags[P[t]]??this.searchTags.en):m.deepClone(this.searchTags)}getDetails(){let t=super.getDetails();return {id:this.getId(),key:this.getKey(),name:this.getName(),description:this.getDescription(),slug:this.getSlug(),brand:this.getBrand(),pricing:Object.keys(this.pricing).reduce((e,i)=>(this.pricing[i]&&(e[i]=this.pricing[i]?.getDetails()),e),{}),attributes:this.getAttributes(),variants:this.variants.map(e=>({sku:e.sku,selectionAttributes:m.deepClone(e.selectionAttributes),images:{primary:e.images.primary.getDetails(),gallery:e.images.gallery.map(i=>i.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...t}}checkSelectionAttributes(t){if(!t||typeof t!="object")throw new L("Selection attributes are required");Object.keys(this.attributes).forEach(e=>{if(e.toLowerCase()==="size")return;let i=this.attributes[e],r=t[e];if(r===void 0)throw new L(`Selection attribute '${e}' is missing`);if(typeof i=="string"){if(typeof r!="string"||i!==r)throw new L(`Selection attribute '${e}' is invalid`)}else if(Array.isArray(i)){if(i.length>0&&typeof i[0]=="string"){if(typeof r!="string"||!i.includes(r))throw new L(`Selection attribute '${e}' is invalid`)}else if(typeof r!="object"||!("name"in r)||i.findIndex(o=>o.name===r.name)<0)throw new L(`Selection attribute '${e}' is invalid`)}});}validateSelectionAttribute(t){let e=n.generateSelectionAttributesKey(t);return this.variants.some(i=>n.generateSelectionAttributesKey(i.selectionAttributes)===e)}validateSize(t){return this.attributes.size.includes(t)}};var Ft={isUUID:n=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(n),isEmail:n=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(n),isURL:n=>/^(http|https):\/\/[^ "]+$/.test(n),generateUUID:(n,t)=>t&&n?Ct(n,t):bt(),generateSearchId:(n,t)=>`${n}#${V.generateSelectionAttributesKey(t)}`,getKeyfromSearchId:n=>{let[t,e]=n.split("#");return {key:t,selectionAttributes:V.parseSelectionAttributesKey(e)}},deepClone(n){return structuredClone(n)}},m=Ft;var G=class extends B{taxRuleId;taxCategory;taxSystem;taxSubSystem;country;rate;minPrice;maxPrice;excludeMin;excludeMax;effectiveFrom;effectiveTo;constructor(t){super(t),this.taxRuleId=t.taxRuleId,this.taxSystem=t.taxSystem,this.taxSubSystem=t.taxSubSystem,this.taxCategory=t.taxCategory,this.country=t.country,this.rate=t.rate,this.minPrice=new s(t.minPrice),this.maxPrice=t.maxPrice?new s(t.maxPrice):void 0,this.excludeMin=t.excludeMin??!1,this.excludeMax=t.excludeMax??!1,this.effectiveFrom=new Date(t.effectiveFrom).toISOString(),this.effectiveTo=t.effectiveTo?new Date(t.effectiveTo).toISOString():void 0;}getTaxRuleId(){return this.taxRuleId}getTaxSystem(){return this.taxSystem}getTaxSubSystem(){return this.taxSubSystem}getTaxCategory(){return this.taxCategory}getCountry(){return this.country}getRate(){return this.rate}getMinPrice(){return this.minPrice}getMaxPrice(){return this.maxPrice}getExcludeMin(){return this.excludeMin}getExcludeMax(){return this.excludeMax}getEffectiveFrom(){return this.effectiveFrom}getEffectiveTo(){return this.effectiveTo}getDetails(){return {taxRuleId:this.getTaxRuleId(),taxSystem:this.getTaxSystem(),taxSubSystem:this.getTaxSubSystem(),taxCategory:this.getTaxCategory(),country:this.getCountry(),rate:this.getRate(),minPrice:this.getMinPrice().getDetails(),maxPrice:this.getMaxPrice()?.getDetails(),excludeMin:this.getExcludeMin(),excludeMax:this.getExcludeMax(),effectiveFrom:this.effectiveFrom,effectiveTo:this.effectiveTo?this.effectiveTo:void 0,customFields:this.getAllCustomFields()}}appliesTo(t,e,i,r=new Date){let o=!i||(this.excludeMin?this.minPrice.compareTo(i)<0:this.minPrice.compareTo(i)<=0)&&(this.maxPrice?this.excludeMax?this.maxPrice.compareTo(i)>0:this.maxPrice.compareTo(i)>=0:!0);return this.taxCategory===t&&this.country===e&&o&&Date.parse(this.effectiveFrom)<=r.getTime()&&(this.effectiveTo?Date.parse(this.effectiveTo)>=r.getTime():!0)}getApplicableTaxRate(t){return this.appliesTo(this.taxCategory,this.country,t)?this.rate:0}calculateTax(t){return this.appliesTo(this.taxCategory,this.country,t)?t.multiply(this.rate):t.zero()}static getTaxRateDisplayString(t,e,i){let r=e*100,o=r%1===0?r.toString():r.toFixed(2).replace(/\.?0+$/,"");return i?.percentageOnly?`${o}%`:t.getTaxSystem()==="GST"?`${t.getTaxSubSystem()} ${o}%`:`${t.getTaxSystem()} ${o}%`}};var q=class extends B{id;productKey;selectionAttributes;name;specifications;primaryImage;subItems;pricing;state;total;constructor(t){super(t),this.id=t.id,this.productKey=t.productKey,this.selectionAttributes=m.deepClone(t.selectionAttributes),this.name=m.deepClone(t.name),this.specifications=m.deepClone(t.specifications),this.primaryImage=new R(t.primaryImage),this.subItems=m.deepClone(t.subItems);let e=new Set;this.subItems.forEach(i=>{if(e.has(i.size))throw new it(i.size);e.add(i.size);}),this.pricing={unitPrice:new s(t.pricing.unitPrice),tierPricing:new $(t.pricing.tierPricing),taxCategory:t.pricing.taxCategory,applicableTaxRule:t.pricing.applicableTaxRule.map(i=>new G(i))},this.validateTaxRules(this.pricing.applicableTaxRule),this.state=t.state??"INITIAL",this.total={quantity:t.total.quantity,unitPrice:new s(t.total.unitPrice),subtotal:new s(t.total.subtotal),discountTotal:new s(t.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(t.total.discountBreakdown).map(([i,r])=>[i,new s(r)])),netUnitPrice:new s(t.total.netUnitPrice),netSubtotal:new s(t.total.netSubtotal),taxTotal:new s(t.total.taxTotal),taxBreakdown:Object.fromEntries(Object.entries(t.total.taxBreakdown).map(([i,r])=>[i,{rate:r.rate,taxableUnitPrice:new s(r.taxableUnitPrice),taxPerUnit:new s(r.taxPerUnit),taxAmount:new s(r.taxAmount),system:r.system,subSystem:r.subSystem}])),grandTotal:new s(t.total.grandTotal)};}getId(){return this.id}getProductKey(){return this.productKey}getSelectionAttributes(){return m.deepClone(this.selectionAttributes)}getName(t){return t?m.deepClone(this.name[t]??this.name[P[t]]??this.name.en):m.deepClone(this.name)}getSpecifications(t){return t?m.deepClone(this.specifications[t]??this.specifications[P[t]]??this.specifications.en):m.deepClone(this.specifications)}getImage(){return this.primaryImage}getSubItems(){return m.deepClone(this.subItems)}getTotalQuantity(){return this.total.quantity}getPricing(){return {unitPrice:this.pricing.unitPrice,tierPricing:this.pricing.tierPricing,taxCategory:this.pricing.taxCategory,applicableTaxRule:[...this.pricing.applicableTaxRule]}}getState(){return this.state}getTotal(){return {quantity:this.total.quantity,unitPrice:this.total.unitPrice,subtotal:this.total.subtotal,discountTotal:this.total.discountTotal,discountBreakdown:Object.fromEntries(Object.entries(this.total.discountBreakdown).map(([t,e])=>[t,e])),netUnitPrice:this.total.netUnitPrice,netSubtotal:this.total.netSubtotal,taxTotal:this.total.taxTotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{rate:e.rate,taxableUnitPrice:e.taxableUnitPrice,taxPerUnit:e.taxPerUnit,taxAmount:e.taxAmount,system:e.system,subSystem:e.subSystem}])),grandTotal:this.total.grandTotal}}getDetails(){let t=this.getPricing(),e=this.getTotal();return {id:this.getId(),productKey:this.getProductKey(),selectionAttributes:this.getSelectionAttributes(),name:this.getName(),specifications:this.getSpecifications(),primaryImage:this.getImage().getDetails(),subItems:this.getSubItems(),pricing:{unitPrice:t.unitPrice.getDetails(),tierPricing:t.tierPricing.getDetails(),taxCategory:t.taxCategory,applicableTaxRule:t.applicableTaxRule.map(i=>i.getDetails())},state:this.getState(),total:{quantity:e.quantity,unitPrice:e.unitPrice.getDetails(),subtotal:e.subtotal.getDetails(),discountTotal:e.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(e.discountBreakdown).map(([i,r])=>[i,r.getDetails()])),netUnitPrice:e.netUnitPrice.getDetails(),netSubtotal:e.netSubtotal.getDetails(),taxTotal:e.taxTotal.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(e.taxBreakdown).map(([i,r])=>[i,{rate:r.rate,taxableUnitPrice:r.taxableUnitPrice.getDetails(),taxPerUnit:r.taxPerUnit.getDetails(),taxAmount:r.taxAmount.getDetails(),system:r.system,subSystem:r.subSystem}])),grandTotal:e.grandTotal.getDetails()},customFields:this.getAllCustomFields()}}validateTaxRules(t){let e=new Set;for(let i=0;i<t.length;i++){let r=t[i].getTaxRuleId();if(e.has(r))throw new et("Duplicate tax rule ID found: "+r);e.add(r);}}addSubItems(t,e){t.forEach(i=>{let r=this.subItems.find(o=>o.size===i.size);r?r.quantity=e?r.quantity+i.quantity:i.quantity:this.subItems.push(i);}),this.subItems=this.subItems.filter(i=>i.quantity>0),this.calculateTotals();}updateProductData(t,e,i){if(this.productKey!==t.getKey()||!t.validateSelectionAttribute(this.selectionAttributes))throw new nt;if(!t.getIsActive())throw new ot;this.subItems.forEach(g=>{if(!t.validateSize(g.size))throw new st});let r=t.getPriceDetails(e);if(!r||r.getBaseUnitPrice().getCurrency()!==i)throw new at;this.name=t.getName(),this.specifications=t.getSpecifications(),this.primaryImage=t.getImages(this.selectionAttributes).primary;let o=this.subItems.reduce((g,d)=>g+d.quantity,0),{unitPrice:a}=r.getApplicableTier(o);this.pricing={unitPrice:a,tierPricing:r,taxCategory:r.getTaxCategory(),applicableTaxRule:this.pricing.applicableTaxRule},this.calculateTotals();}updateDiscounts(t){let e={};t.forEach(i=>{e[i.coupon.getCode()]=i.amount;}),this.total.discountBreakdown=e,this.calculateTotals();}updateTax(t){t.forEach(e=>{if(!e.appliesTo(this.pricing.taxCategory,e.getCountry()))throw new F}),this.validateTaxRules(t),this.pricing.applicableTaxRule=t,this.calculateTotals();}calculateTotals(){let t=this.pricing.unitPrice.zero(),e=this.subItems.reduce((h,b)=>h+b.quantity,0);if(this.state==="CANCELLED"){this.total={quantity:0,unitPrice:t,subtotal:t,discountTotal:t,discountBreakdown:{},netUnitPrice:t,netSubtotal:t,taxTotal:t,taxBreakdown:{},grandTotal:t};return}let{unitPrice:i}=this.pricing.tierPricing.getApplicableTier(e),r=i.multiply(e),o=Object.values(this.total.discountBreakdown).reduce((h,b)=>h.add(b),t),a=r.subtract(o),g=e>0?a.divide(e):t,d={},c=t;this.pricing.applicableTaxRule.forEach(h=>{let b=h.getApplicableTaxRate(g),T=h.calculateTax(g),A=T.multiply(e).round();d[h.getTaxRuleId()]={rate:b,taxableUnitPrice:g,taxPerUnit:T,taxAmount:A,system:h.getTaxSystem(),subSystem:h.getTaxSubSystem()},c=c.add(A);});let u=a.add(c);this.total={quantity:e,unitPrice:i,subtotal:r,discountTotal:o,discountBreakdown:this.total.discountBreakdown,netUnitPrice:g,netSubtotal:a,taxTotal:c,taxBreakdown:d,grandTotal:u};}updateState(t){if(this.state in _)this.state!==t&&(this.state=t);else throw new tt(t)}clearLineItem(){let t=this.pricing.unitPrice.zero();this.id="",this.productKey="",this.selectionAttributes={color:{name:""}},this.name={en:""},this.primaryImage=new R({sources:{original:""}}),this.subItems=[],this.pricing={unitPrice:t,tierPricing:this.pricing.tierPricing,taxCategory:this.pricing.taxCategory,applicableTaxRule:[]},this.total={quantity:0,unitPrice:t,subtotal:t,discountTotal:t,discountBreakdown:{},netUnitPrice:t,netSubtotal:t,taxTotal:t,taxBreakdown:{},grandTotal:t};}};var Y=class extends w{couponCode;name;description;type;customerId;validFrom;validTo;minCartValue;maxCartDiscount;discountMethod;percentageValue;applicableTo;category;constructor(t,e=new Date){if(super(t,e),this.couponCode=t.couponCode,this.name=m.deepClone(t.name),this.description=m.deepClone(t.description),this.type=t.type,this.customerId=t.customerId,this.validFrom=t.validFrom&&Date.parse(t.validFrom)?new Date(t.validFrom).toISOString():e.toISOString(),this.validTo=t.validTo&&Date.parse(t.validTo)?new Date(t.validTo).toISOString():e.toISOString(),this.minCartValue=Object.keys(t.minCartValue).reduce((i,r)=>{let o=t.minCartValue[r];return o&&(i[r]=new s(o)),i},{}),this.maxCartDiscount=Object.keys(t.maxCartDiscount).reduce((i,r)=>{let o=t.maxCartDiscount[r];return o&&(i[r]=new s(o)),i},{}),this.discountMethod=t.discountMethod,this.percentageValue=t.percentageValue??0,this.percentageValue>100)throw new D("Percentage value cannot be greater than 100");this.applicableTo=t.applicableTo,this.category=t.category;}getCode(){return this.couponCode}getName(t){return t?this.name[t]??this.name[P[t]]??this.name.en:{...this.name}}getDescription(t){return t?this.description[t]??this.description[P[t]]??this.description.en:{...this.description}}getType(){return this.type}getCustomerId(){return this.customerId??""}getValidFrom(){return this.validFrom}getValidTo(){return this.validTo}getMinCartValue(t){return t?this.minCartValue[t]:{...this.minCartValue}}getMaxCartDiscount(t){return t?this.maxCartDiscount[t]:{...this.maxCartDiscount}}getDiscountMethod(){return this.discountMethod}getPercentageValue(){return this.percentageValue}getApplicableTo(){return this.applicableTo}getCategory(){return this.category}getDetails(){return {...super.getDetails(),couponCode:this.getCode(),name:this.getName(),description:this.getDescription(),type:this.getType(),customerId:this.getCustomerId(),validFrom:this.getValidFrom(),validTo:this.getValidTo(),minCartValue:Object.keys(this.getMinCartValue()).reduce((t,e)=>{let i=this.getMinCartValue(e);return i&&(t[e]=i.getDetails()),t},{}),maxCartDiscount:Object.keys(this.getMaxCartDiscount()).reduce((t,e)=>{let i=this.getMaxCartDiscount(e);return i&&(t[e]=i.getDetails()),t},{}),discountMethod:this.getDiscountMethod(),percentageValue:this.getPercentageValue(),applicableTo:this.getApplicableTo(),category:this.getCategory()}}isActive(){return new Date(this.validFrom)<=new Date&&new Date(this.validTo)>=new Date}isApplicableTo(t){return this.applicableTo==="all"||this.applicableTo==="ftb"&&t}calculateApplicableCouponDiscount(t,e,i,r,o=!0){let a=new s({amount:0,currency:r}),g;if(o&&!this.isActive())return a;let d=this.getMinCartValue(i),c=this.getMaxCartDiscount(i);if(!d||d.compareTo(t)>0||!c)return a;let u=this.getCategory(),h=this.getDiscountMethod(),b=u==="SHIPPING"?e:t;if(b.getAmount()<=0)return a;switch(h){case"flat":let A=c;g=b.min(A);break;case"percentage":g=b.multiply(this.getPercentageValue()/100).round();break;default:return a}return g.min(c)}};var K=class extends B{id;name;type;category;impact;pricing;lineItemId;total;constructor(t){if(super(t),this.id=t.id,this.name=t.name,this.type=t.type,this.category=t.category,this.impact=t.impact,this.lineItemId=t.lineItemId,this.pricing={baseChargeAmount:new s(t.pricing.baseChargeAmount),taxCategory:t.pricing.taxCategory,applicableTaxRule:t.pricing.applicableTaxRule.map(e=>new G(e))},this.validateTaxRules(this.pricing.applicableTaxRule),this.impact==="SUBTRACT"&&this.type!=="ADJUSTMENT")throw new Z("SUBTRACT impact is only allowed for ADJUSTMENT charge");this.total={chargeAmount:new s(t.total.chargeAmount),discountTotal:new s(t.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(t.total.discountBreakdown).map(([e,i])=>[e,new s(i)])),netChargeAmount:new s(t.total.netChargeAmount),taxBreakdown:Object.fromEntries(Object.entries(t.total.taxBreakdown).map(([e,i])=>[e,{rate:i.rate,taxableAmount:new s(i.taxableAmount),taxAmount:new s(i.taxAmount),system:i.system,subSystem:i.subSystem}])),taxTotal:new s(t.total.taxTotal),grandTotal:new s(t.total.grandTotal)};}getId(){return this.id}getName(t){return t?m.deepClone(this.name[t]??this.name[P[t]]??this.name.en):m.deepClone(this.name)}getCategory(){return this.category}getType(){return this.type}getImpact(){return this.impact}getLineItemId(){return this.lineItemId}getPricing(){return {baseChargeAmount:this.pricing.baseChargeAmount,taxCategory:this.pricing.taxCategory,applicableTaxRule:[...this.pricing.applicableTaxRule]}}getTotal(){return {chargeAmount:this.total.chargeAmount,discountTotal:this.total.discountTotal,discountBreakdown:{...this.total.discountBreakdown},netChargeAmount:this.total.netChargeAmount,taxTotal:this.total.taxTotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{rate:e.rate,taxableAmount:e.taxableAmount,taxAmount:e.taxAmount,system:e.system,subSystem:e.subSystem}])),grandTotal:this.total.grandTotal}}getApplicableTaxRules(){return [...this.pricing.applicableTaxRule]}updateTax(t){if(this.type==="ADJUSTMENT"&&t.length>0)throw new Z("Adjustment charges cannot apply tax rules.");t.forEach(e=>{if(!e.appliesTo(this.pricing.taxCategory,e.getCountry()))throw new F}),this.validateTaxRules(t),this.pricing.applicableTaxRule=t,this.calculateTotals();}validateTaxRules(t){if(this.impact==="SUBTRACT"&&t.some(i=>i.getRate()>0))throw new j("Subtractive charges cannot have positive tax rates.");let e=new Set;for(let i=0;i<t.length;i++){let r=t[i].getTaxRuleId();if(e.has(r))throw new j("Duplicate tax rule ID found: "+r);e.add(r);for(let o=i+1;o<t.length;o++){let a=t[i],g=t[o],d=a.getMinPrice(),c=a.getMaxPrice(),u=a.getExcludeMin(),h=a.getExcludeMax(),b=g.getMinPrice(),T=g.getMaxPrice(),A=g.getExcludeMin(),M=g.getExcludeMax(),x=(()=>{if(!c)return !1;let S=c.compareTo(b);return S<0||S===0&&(h||A)})(),y=(()=>{if(!T)return !1;let S=T.compareTo(d);return S<0||S===0&&(M||u)})();if(!(x||y)&&!(d.compareTo(b)===0&&u===A&&h===M&&(!c&&!T||c&&T&&c.compareTo(T)===0)))throw new j(`Overlapping rules found: [${a.getTaxRuleId()}: ${u?"(":"["}${d.getAmount()}-${c?.getAmount()??"Infinity"}${h?")":"]"}] and [${g.getTaxRuleId()}: ${A?"(":"["}${b.getAmount()}-${T?.getAmount()??"Infinity"}${M?")":"]"}]`)}}}updateDiscounts(t){let e={};t.forEach(i=>{e[i.coupon.getCode()]=i.amount;}),this.total.discountBreakdown=e,this.calculateTotals();}calculateTotals(){let t=this.pricing.baseChargeAmount.zero(),e=this.pricing.baseChargeAmount,i=Object.values(this.total.discountBreakdown).reduce((x,y)=>x.add(y),t),r=e.subtract(i),o={},a=this.pricing.applicableTaxRule.reduce((x,y)=>x+y.getApplicableTaxRate(r),0);if(a<=0){this.total={chargeAmount:e,discountTotal:i,discountBreakdown:this.total.discountBreakdown,netChargeAmount:r,taxTotal:t,taxBreakdown:{},grandTotal:r};return}let g=r.getCurrency(),d=r.getAmount(),c=1e3,u=s.getRoundedAmount(d/(1+a),g),h=u,b=Number.POSITIVE_INFINITY;for(let x=0;x<c;x++){let y=new s({amount:u,currency:g}),S=this.pricing.applicableTaxRule.sort((l,p)=>p.getApplicableTaxRate(y)-l.getApplicableTaxRate(y)).map(l=>s.getRoundedAmount(u*l.getApplicableTaxRate(y),g)).reduce((l,p)=>l+p,0),E=u+S-d,pt=this.pricing.applicableTaxRule.reduce((l,p)=>l+p.getApplicableTaxRate(y),0);if(Math.abs(E)<Math.abs(b)&&(b=E,h=u),E===0||(u=u-E/(1+pt),u<0||u>d))break}let T=new s({amount:h,currency:g}),A=t;this.pricing.applicableTaxRule.sort((x,y)=>y.getApplicableTaxRate(T)-x.getApplicableTaxRate(T)).forEach(x=>{let y=x.getApplicableTaxRate(T),O=s.getRoundedAmount(h*y,g),S=new s({amount:O,currency:g});o[x.getTaxRuleId()]={rate:y,taxableAmount:T,taxAmount:S,system:x.getTaxSystem(),subSystem:x.getTaxSubSystem()},A=A.add(S);});let M=r;this.total={chargeAmount:e,discountTotal:i,discountBreakdown:this.total.discountBreakdown,netChargeAmount:r,taxBreakdown:o,taxTotal:A,grandTotal:M};}getDetails(){return {id:this.id,name:m.deepClone(this.name),type:this.type,category:this.category,pricing:{baseChargeAmount:this.pricing.baseChargeAmount.getDetails(),taxCategory:this.pricing.taxCategory,applicableTaxRule:this.pricing.applicableTaxRule.map(e=>e.getDetails())},impact:this.impact,lineItemId:this.lineItemId,total:{chargeAmount:this.total.chargeAmount.getDetails(),discountTotal:this.total.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(this.total.discountBreakdown).map(([e,i])=>[e,i.getDetails()])),netChargeAmount:this.total.netChargeAmount.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([e,i])=>[e,{rate:i.rate,taxableAmount:i.taxableAmount.getDetails(),taxAmount:i.taxAmount.getDetails(),system:i.system,subSystem:i.subSystem}])),taxTotal:this.total.taxTotal.getDetails(),grandTotal:this.total.grandTotal.getDetails()},customFields:this.getAllCustomFields()}}};var xt=class extends w{id;customerId;customerEmail;anonymousId;lineItems;charges;shippingDetails;shippingAddress;billingAddress;coupons;total;country;currency;locale;metaData;constructor(t,e=new Date,i={checkCouponExpiry:!0}){super(t,e),this.id=t.id,this.customerId=t.customerId,this.customerEmail=t.customerEmail,this.anonymousId=t.anonymousId,this.country=t.country,this.currency=t.currency,this.locale=t.locale,this.lineItems=(t.lineItems??[]).map(r=>new q(r)),this.charges=(t.charges??[]).map(r=>new K(r)),this.billingAddress=t.billingAddress?new U(t.billingAddress,e):null,this.shippingAddress=t.shippingAddress?new U(t.shippingAddress,e):null,this.coupons=(t.coupons??[]).map(r=>new Y(r)),this.shippingDetails=t.shippingDetails?m.deepClone(t.shippingDetails):null,this.total={lineItemSubtotal:new s(t.total.lineItemSubtotal),netLineItemSubtotal:new s(t.total.netLineItemSubtotal),lineItemTaxTotal:new s(t.total.lineItemTaxTotal),lineItemTaxBreakdown:this.mapTaxBreakdown(t.total.lineItemTaxBreakdown),additiveCharges:new s(t.total.additiveCharges),netAdditiveCharges:new s(t.total.netAdditiveCharges),additiveChargesTaxTotal:new s(t.total.additiveChargesTaxTotal),additiveChargesTaxBreakdown:this.mapTaxBreakdown(t.total.additiveChargesTaxBreakdown),adjustmentCharges:new s(t.total.adjustmentCharges),shippingCharges:new s(t.total.shippingCharges),netShippingCharges:new s(t.total.netShippingCharges),discountTotal:new s(t.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(t.total.discountBreakdown).map(([r,o])=>[r,new s(o)])),taxTotal:new s(t.total.taxTotal),taxBreakdown:this.mapTaxBreakdown(t.total.taxBreakdown),grandTotal:new s(t.total.grandTotal)},this.metaData={checkCouponExpiry:i.checkCouponExpiry};}mapTaxBreakdown(t){return Object.fromEntries(Object.entries(t||{}).map(([e,i])=>[e,{system:i.system,totalAmount:new s(i.totalAmount),subSystems:Object.fromEntries(Object.entries(i.subSystems).map(([r,o])=>[r,new s(o)]))}]))}serializeTaxBreakdown(t){return Object.fromEntries(Object.entries(t||{}).map(([e,i])=>[e,{system:i.system,totalAmount:i.totalAmount.getDetails(),subSystems:Object.fromEntries(Object.entries(i.subSystems).map(([r,o])=>[r,o.getDetails()]))}]))}getId(){return this.id}getCustomerId(){return this.customerId}getCustomerEmail(){return this.customerEmail}getAnonymousId(){return this.anonymousId}getLineItems(){return this.lineItems.map(t=>new q(t.getDetails()))}getLineItemsCount(){return this.lineItems.length}getCharges(){return this.charges.map(t=>new K(t.getDetails()))}addCharge(t){this.charges.push(t),this.calculateTotals();}clearCharges(){this.charges=[],this.calculateTotals();}getShippingDetails(){return this.shippingDetails?m.deepClone(this.shippingDetails):null}getShippingAddress(){return this.shippingAddress?new U(this.shippingAddress.getDetails()):null}hasShippingAddress(){return !!this.shippingAddress}hasBillingAddress(){return !!this.billingAddress}getBillingAddress(){return this.billingAddress?new U(this.billingAddress.getDetails()):null}getCoupons(){return [...this.coupons]}getCountry(){return this.country}getCurrency(){return this.currency}getLocale(){return this.locale}getTotal(){return {lineItemSubtotal:this.total.lineItemSubtotal,netLineItemSubtotal:this.total.netLineItemSubtotal,lineItemTaxTotal:this.total.lineItemTaxTotal,lineItemTaxBreakdown:Object.fromEntries(Object.entries(this.total.lineItemTaxBreakdown).map(([t,e])=>[t,{system:e.system,totalAmount:e.totalAmount,subSystems:{...e.subSystems}}])),additiveCharges:this.total.additiveCharges,netAdditiveCharges:this.total.netAdditiveCharges,additiveChargesTaxTotal:this.total.additiveChargesTaxTotal,additiveChargesTaxBreakdown:Object.fromEntries(Object.entries(this.total.additiveChargesTaxBreakdown).map(([t,e])=>[t,{system:e.system,totalAmount:e.totalAmount,subSystems:{...e.subSystems}}])),adjustmentCharges:this.total.adjustmentCharges,shippingCharges:this.total.shippingCharges,netShippingCharges:this.total.netShippingCharges,discountBreakdown:{...this.total.discountBreakdown},discountTotal:this.total.discountTotal,taxTotal:this.total.taxTotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{system:e.system,totalAmount:e.totalAmount,subSystems:{...e.subSystems}}])),grandTotal:this.total.grandTotal}}getDetails(){let t=this.getTotal();return {...super.getDetails(),id:this.getId(),customerId:this.getCustomerId(),customerEmail:this.getCustomerEmail(),anonymousId:this.getAnonymousId(),lineItems:this.getLineItems().map(e=>e.getDetails()),charges:this.getCharges().map(e=>e.getDetails()),shippingDetails:this.getShippingDetails(),shippingAddress:this.getShippingAddress()?.getDetails()||null,billingAddress:this.getBillingAddress()?.getDetails()||null,coupons:this.getCoupons().map(e=>e.getDetails()),total:{lineItemSubtotal:t.lineItemSubtotal.getDetails(),netLineItemSubtotal:t.netLineItemSubtotal.getDetails(),lineItemTaxTotal:t.lineItemTaxTotal.getDetails(),lineItemTaxBreakdown:this.serializeTaxBreakdown(t.lineItemTaxBreakdown),additiveCharges:t.additiveCharges.getDetails(),netAdditiveCharges:t.netAdditiveCharges.getDetails(),additiveChargesTaxTotal:t.additiveChargesTaxTotal.getDetails(),additiveChargesTaxBreakdown:this.serializeTaxBreakdown(t.additiveChargesTaxBreakdown),adjustmentCharges:t.adjustmentCharges.getDetails(),shippingCharges:t.shippingCharges.getDetails(),netShippingCharges:t.netShippingCharges.getDetails(),discountTotal:t.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(t.discountBreakdown).map(([e,i])=>[e,i.getDetails()])),taxTotal:t.taxTotal.getDetails(),taxBreakdown:this.serializeTaxBreakdown(t.taxBreakdown),grandTotal:t.grandTotal.getDetails()},country:this.getCountry(),currency:this.getCurrency(),locale:this.getLocale()}}calculateTotals(){let t=new s({amount:0,currency:this.currency}),e=this.lineItems.filter(l=>l.getState()!=="CANCELLED"),i=e.reduce((l,p)=>l.add(p.getTotal().subtotal),t),r=this.charges.filter(l=>l.getType()==="SHIPPING").reduce((l,p)=>l.add(p.getTotal().chargeAmount),t);this.total.lineItemSubtotal=i,this.total.shippingCharges=r;let o=t,a={},g={};this.coupons.forEach(l=>{let p=l.calculateApplicableCouponDiscount(i,r,this.country,this.currency,this.metaData.checkCouponExpiry);o=o.add(p),a[l.getCode()]=p,l.getCategory()!=="SHIPPING"&&(g[l.getCode()]=p);}),this.total.discountTotal=o,this.total.discountBreakdown=a,this.applyDiscountsInLineItem(g);let d=this.coupons.find(l=>l.getCategory()==="SHIPPING");d?this.applyDiscountsInShippingCharges({[d.getCode()]:a[d.getCode()]||t}):this.applyDiscountsInShippingCharges({});let c=this.lineItems.reduce((l,p)=>l.add(p.getTotal().netSubtotal),t),u=this.charges.filter(l=>l.getType()==="SHIPPING").reduce((l,p)=>l.add(p.getTotal().grandTotal),t);this.total.netLineItemSubtotal=c,this.total.netShippingCharges=u;let h=this.charges.filter(l=>l.getImpact()==="ADD").reduce((l,p)=>l.add(p.getTotal().chargeAmount),t),b=this.charges.filter(l=>l.getImpact()==="ADD").reduce((l,p)=>l.add(p.getTotal().grandTotal),t),T=this.charges.filter(l=>l.getImpact()==="SUBTRACT").reduce((l,p)=>l.add(p.getTotal().grandTotal),t),A=t,M=t,x=t,y={},O={},S={},E=(l,p)=>{Object.entries(l).forEach(([$t,k])=>{let f=k.system,N=k.subSystem;p[f]||(p[f]={system:f,totalAmount:t,subSystems:{}}),p[f].subSystems[N]?p[f].subSystems[N]=p[f].subSystems[N].add(k.taxAmount):p[f].subSystems[N]=k.taxAmount,p[f].totalAmount=p[f].totalAmount.add(k.taxAmount),y[f]||(y[f]={system:f,totalAmount:t,subSystems:{}}),y[f].subSystems[N]?y[f].subSystems[N]=y[f].subSystems[N].add(k.taxAmount):y[f].subSystems[N]=k.taxAmount,y[f].totalAmount=y[f].totalAmount.add(k.taxAmount);});};e.forEach(l=>{let p=l.getTotal().taxBreakdown;p&&(E(p,O),E(p,y),M=M.add(l.getTotal().taxTotal));}),this.charges.forEach(l=>{let p=l.getTotal().taxBreakdown;p&&(E(p,S),E(p,y),x=x.add(l.getTotal().taxTotal));}),A=M.add(x);let pt=c.add(M).add(b).subtract(T);this.total={lineItemSubtotal:i,netLineItemSubtotal:c,lineItemTaxTotal:M,lineItemTaxBreakdown:O,additiveCharges:h,netAdditiveCharges:b,additiveChargesTaxTotal:x,additiveChargesTaxBreakdown:S,adjustmentCharges:T,shippingCharges:r,netShippingCharges:u,discountTotal:o,discountBreakdown:a,taxTotal:A,taxBreakdown:y,grandTotal:pt};}updateShippingDetails(t){this.shippingDetails=t;}applyCoupons(t){let e=t.filter(r=>r.getCategory()==="SHIPPING"),i=t.filter(r=>r.getCategory()!=="SHIPPING");this.coupons=[],this.total.discountTotal=this.total.lineItemSubtotal.zero(),this.total.discountBreakdown={},i.length&&this.applyNonShippingCoupons(i),this.applyDiscountsInLineItem(this.total.discountBreakdown),e.length&&this.applyShippingCoupons(e),this.calculateTotals();}applyDiscountsInLineItem(t){let e=Array.from(Object.entries(t)).filter(r=>!r[1].isZero()),i=new Map;this.lineItems.forEach(r=>i.set(r.getId(),[])),e.forEach(([r,o])=>{let a=this.coupons.find(c=>c.getCode()===r);if(!a||o.isZero())return;let g=this.lineItems.filter(c=>c.getState()!=="CANCELLED"&&!c.getTotal().subtotal.isZero()).sort((c,u)=>c.getTotal().subtotal.compareTo(u.getTotal().subtotal)),d=new s({amount:0,currency:this.currency});g.forEach((c,u)=>{let h;u===g.length-1?h=o.subtract(d):h=o.multiply(c.getTotal().subtotal).divide(this.total.lineItemSubtotal).round(),d=d.add(h),i.get(c.getId())?.push({coupon:a,amount:h});});}),this.lineItems.forEach(r=>{r.getState()==="CANCELLED"||this.total.lineItemSubtotal.isZero()?r.updateDiscounts([]):r.updateDiscounts(i.get(r.getId())||[]);});}applyDiscountsInShippingCharges(t){let e=Array.from(Object.entries(t)).filter(o=>!o[1].isZero()),i=this.charges.filter(o=>o.getType()==="SHIPPING"),r=new Map;i.forEach(o=>r.set(o.getId(),[])),e.forEach(([o,a])=>{let g=this.coupons.find(u=>u.getCode()===o);if(!g||a.isZero())return;let d=i.sort((u,h)=>u.getTotal().grandTotal.compareTo(h.getTotal().grandTotal)),c=new s({amount:0,currency:this.currency});d.forEach((u,h)=>{let b;h===d.length-1?b=a.subtract(c):b=a.multiply(u.getTotal().chargeAmount).divide(this.total.shippingCharges).round(),c=c.add(b),r.get(u.getId())?.push({coupon:g,amount:b});});}),i.forEach(o=>{o.updateDiscounts(r.get(o.getId())||[]);});}applyNonShippingCoupons(t){let e=t.filter(i=>i.getType()==="coupon");if(e.length===1){let i=e[0].calculateApplicableCouponDiscount(this.total.lineItemSubtotal,this.total.shippingCharges,this.country,this.currency,this.metaData.checkCouponExpiry);i.getAmount()>0&&(this.coupons.push(e[0]),this.total.discountTotal=i,this.total.discountBreakdown[e[0].getCode()]=i);}}applyShippingCoupons(t){if(this.total.shippingCharges.getAmount()>0&&t.length>0){let e=this.total.lineItemSubtotal.subtract(this.total.discountTotal),i=t.reduce((o,a)=>{if(!o)return a;let g=a.calculateApplicableCouponDiscount(e,this.total.shippingCharges,this.country,this.currency,this.metaData.checkCouponExpiry).min(this.total.shippingCharges),d=o.calculateApplicableCouponDiscount(e,this.total.shippingCharges,this.country,this.currency,this.metaData.checkCouponExpiry).min(this.total.shippingCharges);return g.compareTo(d)===0?a.getType()==="coupon"?a:o:g.compareTo(d)>0?a:o}),r=i.calculateApplicableCouponDiscount(e,this.total.shippingCharges,this.country,this.currency,this.metaData.checkCouponExpiry).min(this.total.shippingCharges);r.getAmount()>0&&(this.coupons.push(i),this.total.discountTotal=this.total.discountTotal.add(r),this.total.discountBreakdown[i.getCode()]=r);}}};module.exports=xt;//# sourceMappingURL=ShoppingContainer.js.map
1
+ 'use strict';var Mt=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Mt__default=/*#__PURE__*/_interopDefault(Mt);var Tt=n=>structuredClone(n),B=class{customFields;constructor(t,e=new Date){this.customFields={...t.customFields};}getCustomField(t){let e=this.customFields[t];return e==null?e:Tt(e)}setCustomField(t,e){this.customFields[t]=e;}getAllCustomFields(){return Tt(this.customFields)}},w=class extends B{version;createdAt;modifiedAt;modifiedBy;constructor(t,e=new Date){super(t),this.version=t.version??1,this.createdAt=t.createdAt&&!isNaN(Date.parse(t.createdAt))?new Date(t.createdAt).toISOString():e.toISOString(),this.modifiedAt=t.modifiedAt&&!isNaN(Date.parse(t.modifiedAt))?new Date(t.modifiedAt).toISOString():e.toISOString(),this.modifiedBy={...t.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(t,e,i,r){this.modifiedBy={id:t,authType:e,requestId:i,lambdaName:r};}};var U=class extends w{id;firstName;lastName;company;phone;email;addressLine1;addressLine2;city;postalCode;state;country;isBillingAddress;isShippingAddress;constructor(t,e=new Date){super(t,e),this.id=t.id,this.firstName=t.firstName,this.lastName=t.lastName||"",this.company=t.company||"",this.phone=t.phone,this.email=t.email,this.addressLine1=t.addressLine1,this.addressLine2=t.addressLine2||"",this.city=t.city,this.postalCode=t.postalCode,this.state=t.state,this.country=t.country,this.isBillingAddress=t.isBillingAddress,this.isShippingAddress=t.isShippingAddress;}getDetails(){return {...super.getDetails(),id:this.getId(),firstName:this.getFirstName(),lastName:this.getLastName(),company:this.getCompany(),phone:this.getPhone(),email:this.getEmail(),addressLine1:this.getAddressLine1(),addressLine2:this.getAddressLine2(),city:this.getCity(),postalCode:this.getPostalCode(),state:this.getState(),country:this.getCountry(),isBillingAddress:this.getIsBillingAddress(),isShippingAddress:this.getIsShippingAddress()}}getId(){return this.id}getFirstName(){return this.firstName}getLastName(){return this.lastName}getCompany(){return this.company}getPhone(){return this.phone}getEmail(){return this.email}getAddressLine1(){return this.addressLine1}getAddressLine2(){return this.addressLine2}getCity(){return this.city}getPostalCode(){return this.postalCode}getState(){return this.state}getCountry(){return this.country}getIsBillingAddress(){return this.isBillingAddress}getIsShippingAddress(){return this.isShippingAddress}getAddressType(){return this.isBillingAddress&&this.isShippingAddress?"billing&shipping":this.isBillingAddress?"billing":this.isShippingAddress?"shipping":"none"}static checkIfShippingAddress(t){return t==="shipping"||t==="billing&shipping"}static checkIfBillingAddress(t){return t==="billing"||t==="billing&shipping"}};var X=new Uint8Array(256),J=X.length;function mt(){return J>X.length-16&&(Mt__default.default.randomFillSync(X),J=0),X.slice(J,J+=16)}var ft=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function wt(n){return typeof n=="string"&&ft.test(n)}var It=wt;var I=[];for(let n=0;n<256;++n)I.push((n+256).toString(16).slice(1));function W(n,t=0){return I[n[t+0]]+I[n[t+1]]+I[n[t+2]]+I[n[t+3]]+"-"+I[n[t+4]]+I[n[t+5]]+"-"+I[n[t+6]]+I[n[t+7]]+"-"+I[n[t+8]]+I[n[t+9]]+"-"+I[n[t+10]]+I[n[t+11]]+I[n[t+12]]+I[n[t+13]]+I[n[t+14]]+I[n[t+15]]}function Lt(n){if(!It(n))throw TypeError("Invalid UUID");let t,e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}var At=Lt;function vt(n){n=unescape(encodeURIComponent(n));let t=[];for(let e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var Et="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Bt="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ht(n,t,e){function i(r,o,a,g){var d;if(typeof r=="string"&&(r=vt(r)),typeof o=="string"&&(o=At(o)),((d=o)===null||d===void 0?void 0:d.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+r.length);if(c.set(o),c.set(r,o.length),c=e(c),c[6]=c[6]&15|t,c[8]=c[8]&63|128,a){g=g||0;for(let u=0;u<16;++u)a[g+u]=c[u];return a}return W(c)}try{i.name=n;}catch{}return i.DNS=Et,i.URL=Bt,i}var yt={randomUUID:Mt__default.default.randomUUID};function kt(n,t,e){if(yt.randomUUID&&!t&&!n)return yt.randomUUID();n=n||{};let i=n.random||(n.rng||mt)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let r=0;r<16;++r)t[e+r]=i[r];return t}return W(i)}var bt=kt;function Ut(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),Mt__default.default.createHash("sha1").update(n).digest()}var St=Ut;var Ot=ht("v5",80,St),Ct=Ot;var P={"en-IN":"en","kn-IN":"kn"};var Pt={INR:"\u20B9"},Dt={INR:"en-IN"};var _=(u=>(u.INITIAL="INITIAL",u.PROCESSING="PROCESSING",u.SHIPPED="SHIPPED",u.DELIVERED="DELIVERED",u.CANCELLED="CANCELLED",u.RETURN_REQUESTED="RETURN_REQUESTED",u.RETURNED="RETURNED",u.REFUND_INITIATED="REFUND_INITIATED",u.REFUNDED="REFUNDED",u.ON_HOLD="ON_HOLD",u))(_||{});var tt=class extends Error{constructor(t){super(`Invalid line item state: ${t}`),this.name="InvalidLineItemStateError";}},et=class extends Error{constructor(t){super(`InvalidLineItemTaxRule: ${t}`),this.name="InvalidLineItemTaxRuleError";}},it=class extends Error{constructor(t){super(`Duplicate size found: ${t}`),this.name="DuplicateSizeError";}},rt=class extends Error{constructor(t){super(`Duplicate selection attribute found: ${t}`),this.name="DuplicateSelectionAttributeError";}},nt=class extends Error{constructor(t="Product and selection attributes do not match."){super(`ProductMismatch: ${t}`),this.name="ProductMismatchError";}},ot=class extends Error{constructor(t="Product is not active."){super(`ProductInactive: ${t}`),this.name="ProductInactiveError";}},L=class extends Error{constructor(t="Failed to parse selection attributes key."){super(`SelectionAttributeParseError: ${t}`),this.name="SelectionAttributeParseError";}},st=class extends Error{constructor(t="Size does not match."){super(`SizeMismatch: ${t}`),this.name="SizeMismatchError";}},at=class extends Error{constructor(t="Pricing details not available for the product"){super(`NotFound: ${t}`),this.name="PricingNotFoundError";}},F=class extends Error{constructor(t="Tax rule category mismatch."){super(`InvalidTaxRule: ${t}`),this.name="InvalidTaxRuleError";}},ct=class extends Error{constructor(t="Tax category is not valid."){super(`InvalidTaxCategory: ${t}`),this.name="InvalidTaxCategoryError";}},lt=class extends Error{constructor(t="Minimum quantity must be greater than zero."){super(`InvalidMinQuantity: ${t}`),this.name="InvalidMinQuantityError";}},ut=class extends Error{constructor(t){super(`InvalidTieredPrice: ${t}`),this.name="InvalidTieredPriceError";}},dt=class extends Error{constructor(t="Quantity must be greater than zero."){super(`InvalidQuantity: ${t}`),this.name="InvalidQuantityError";}},gt=class extends Error{constructor(t){super(`NoApplicableTier: Quantity ${t} does not meet the minimum purchase requirement.`),this.name="NoApplicableTierError";}};var Q=class extends Error{constructor(t="Amount cannot be negative."){super(`InvalidAmount: ${t}`),this.name="InvalidPriceAmountError";}},z=class extends Error{constructor(t="Currency code is required."){super(`InvalidCurrency: ${t}`),this.name="InvalidCurrencyCodeError";}},v=class extends Error{constructor(t="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${t}`),this.name="CurrencyMismatchError";}},D=class extends Error{constructor(t){super(`InvalidArgument: ${t}`),this.name="InvalidArgumentError";}},H=class extends Error{constructor(t="Invalid image source configuration."){super(`InvalidImageSource: ${t}`),this.name="InvalidImageSourceError";}},Z=class extends Error{constructor(t="Invalid charge data."){super(`InvalidCharge: ${t}`),this.name="InvalidChargeError";}},j=class extends Error{constructor(t="Invalid charge tax rule."){super(`InvalidChargeTaxRule: ${t}`),this.name="InvalidChargeTaxRuleError";}};var R=class{sources;alt;order;label;constructor(t){if(this.sources={...t.sources},this.alt=t.alt,this.order=t.order,this.label=t.label,!this.sources.original)throw new H("ImageInfoModel cannot be created without an 'original' source URL.")}getSources(){return {...this.sources}}getSource(t){return this.sources[t]||this.sources.original}getAlt(){return this.alt}getOrder(){return this.order}getLabel(){return this.label}setAlt(t){this.alt=t;}setOrder(t){this.order=t;}setLabel(t){this.label=t;}setSource(t,e){if(e===void 0){if(t==="original")throw new H("Cannot remove the 'original' image source.");delete this.sources[t];}else this.sources[t]=e;}getDetails(){return {sources:this.getSources(),alt:this.getAlt(),order:this.getOrder(),label:this.getLabel()}}};var s=class n{#t;amount;currency;constructor(t){if(this.#t="PriceModel",t.amount<0)throw new Q("Amount cannot be negative.");if(!t.currency)throw new z("Currency code is required.");this.currency=t.currency,this.amount=parseFloat(t.amount.toFixed(n.getPrecisionPlaces(this.currency)));}get kind(){return this.#t}static isPriceModel(t){return typeof t=="object"&&t!==null&&t.kind==="PriceModel"}getCurrency(){return this.currency}getAmount(){return this.amount}getDetails(){return {amount:this.amount,currency:this.currency}}getPreciseAmount(t){return parseFloat(t.toFixed(n.getPrecisionPlaces(this.currency)))}compareTo(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot compare prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return this.getPreciseAmount(this.amount-t.getAmount())}add(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot add prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return new n({amount:this.getPreciseAmount(this.amount+t.getAmount()),currency:this.currency})}subtract(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot subtract prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return new n({amount:this.getPreciseAmount(this.amount-t.getAmount()),currency:this.currency})}multiply(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot multiply prices in different currencies.");return new n({amount:this.getPreciseAmount(this.amount*t.getAmount()),currency:this.currency})}else if(typeof t=="number"&&t>=0)return new n({amount:this.getPreciseAmount(this.amount*t),currency:this.currency});throw new D("Must be a non-negative number.")}divide(t){if(n.isPriceModel(t)){if(this.currency!==t.getCurrency())throw new v("Cannot divide prices in different currencies.");return new n({amount:this.getPreciseAmount(this.amount/t.getAmount()),currency:this.currency})}else if(typeof t=="number"&&t>0)return new n({amount:this.getPreciseAmount(this.amount/t),currency:this.currency});throw new D("Must be a positive number.")}min(...t){if(t.length===0)throw new D("Must provide at least one PriceModel.");return t.reduce((e,i)=>{if(n.isPriceModel(i)){if(e.getCurrency()!==i.getCurrency())throw new v("Cannot compare prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return e.compareTo(i)<0?e:i},this)}max(...t){if(t.length===0)throw new D("Must provide at least one PriceModel.");return t.reduce((e,i)=>{if(n.isPriceModel(i)){if(e.getCurrency()!==i.getCurrency())throw new v("Cannot compare prices in different currencies.")}else throw new D("Must be a PriceModel instance.");return e.compareTo(i)>0?e:i},this)}zero(){return new n({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new n({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return n.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return n.getFormattedString(this.amount,this.currency)}toString(){return this.getFormattedString()}static getFormattedString(t,e,i={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let r=Dt[e];if(!e||!r)throw new z("Invalid currency code for formatting.");let o=t,a=i.displayAsInteger?0:n.getDecimalPlaces(e),g={style:i.style??"currency",currency:e,signDisplay:"never",currencyDisplay:i.currencyDisplay,minimumFractionDigits:a,maximumFractionDigits:a};i.displayAsInteger&&(o=Math.ceil(o));try{return new Intl.NumberFormat(r,g).format(o)}catch(d){return console.error(`Error formatting price for currency "${e}" and locale "${r}":`,d),`${Pt[e]??e} ${n.addThousandSeparators(o.toFixed(a))}`}}static getDecimalPlaces(t){switch(t){case"INR":default:return 2}}static getPrecisionPlaces(t){switch(t){case"INR":default:return 6}}static addThousandSeparators(t){let e=t.split("."),i=e[0],r=e.length>1?"."+e[1]:"";return i.replace(/\B(?=(\d{3})+(?!\d))/g,",")+r}static getRoundedAmount(t,e){if(t<0)throw new Q("Amount cannot be negative for rounding.");if(e===void 0)throw new z("Invalid currency code for rounding.");let i=n.getDecimalPlaces(e),r=Math.pow(10,i);return Math.round(t*r)/r}};var $=class{baseUnitPrice;taxCategory;tiers;constructor(t){let e=new s(t.baseUnitPrice);if(!t.taxCategory)throw new ct;let i=(t.tiers??[]).map(d=>({minQuantity:d.minQuantity,unitPrice:new s(d.unitPrice)})).sort((d,c)=>d.minQuantity-c.minQuantity);if(i.some(d=>d.minQuantity<=0))throw new lt;let o=i.some(d=>d.unitPrice.getCurrency()!==e.getCurrency()),a=i.some((d,c)=>c>0&&d.unitPrice.compareTo(i[c-1].unitPrice)>0),g=i[0]?.unitPrice.compareTo(e)>0;if(o||a||g)throw new ut("Tiers must share the same currency and must not increase in unit price.");this.baseUnitPrice=e,this.taxCategory=t.taxCategory,this.tiers=i;}getBaseUnitPrice(){return this.baseUnitPrice}getTaxCategory(){return this.taxCategory}getTiers(){return this.tiers.map(t=>({minQuantity:t.minQuantity,unitPrice:t.unitPrice}))}getDetails(){return {baseUnitPrice:this.baseUnitPrice.getDetails(),taxCategory:this.taxCategory,tiers:this.tiers.map(t=>({minQuantity:t.minQuantity,unitPrice:t.unitPrice.getDetails()}))}}getApplicableTier(t){if(t<=0)throw new dt;for(let e=this.tiers.length-1;e>=0;e--)if(t>=this.tiers[e].minQuantity){let i=this.tiers[e];return {minQuantity:i.minQuantity,unitPrice:i.unitPrice}}throw new gt(t)}getMinQuantity(){return this.tiers[0]?.minQuantity??1}getMaxDiscountPercent(){if(!this.tiers.length)return 0;let t=this.tiers[this.tiers.length-1].unitPrice.getAmount(),e=this.baseUnitPrice.getAmount();return (e-t)/e*100}};var V=class n extends w{id;key;name;description;slug;brand;pricing;variants;targetGender;attributes;specifications;categories;isActive;searchTags;static productKeyRegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static productSKURegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static generateSelectionAttributesKey(t){if(typeof t!="object")throw new L("Selection attributes must be an object");return Object.keys(t).filter(i=>t[i]!==void 0&&i.toLowerCase()!=="size").sort().map(i=>t[i].name?`${i}:c+${t[i].name}`:`${i}:${t[i]}`).join("|").toLowerCase()}static parseSelectionAttributesKey(t){try{let e={},i=t.split("|");for(let r of i){let[o,a]=r.split(":");a.startsWith("c+")?e[o]={name:a.slice(2)}:e[o]=a;}return e}catch(e){throw new L(e?.message)}}constructor(t,e=new Date){super(t,e),this.id=t.id,this.key=t.key,this.name={...t.name},this.description={...t.description},this.slug={...t.slug},this.brand=t.brand,this.pricing=Object.keys(t.pricing).reduce((r,o)=>(t.pricing[o]&&(r[o]=new $(t.pricing[o])),r),{}),this.targetGender=t.targetGender,this.attributes=m.deepClone(t.attributes),this.specifications=m.deepClone(t.specifications),this.categories=m.deepClone(t.categories);let i=new Set;this.variants=(t.variants||[]).map(r=>{if(!r.selectionAttributes||typeof r.selectionAttributes!="object")throw new L("Selection attributes are required");this.checkSelectionAttributes(r.selectionAttributes);let o=n.generateSelectionAttributesKey(r.selectionAttributes);if(i.has(o))throw new rt(o);return i.add(o),{sku:r.sku,selectionAttributes:r.selectionAttributes,images:{primary:new R(r.images.primary),gallery:(r.images.gallery||[]).map(a=>new R(a))}}}),this.isActive=t.isActive,this.searchTags=t.searchTags?m.deepClone(t.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getName(t){return t?this.name[t]??this.name[P[t]]??this.name.en:m.deepClone(this.name)}getDescription(t){return t?this.description[t]??this.description[P[t]]??this.description.en:m.deepClone(this.description)}getSlug(t){return t?this.slug[t]??this.slug[P[t]]??this.slug.en:m.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(t){return t?this.pricing[t]??null:{...this.pricing}}getAttributes(){return m.deepClone(this.attributes)}getVariants(){return this.variants.map(t=>({sku:t.sku,selectionAttributes:m.deepClone(t.selectionAttributes),images:{primary:t.images.primary,gallery:[...t.images.gallery]}}))}getImagesBySelectionAttributes(t){let e=n.generateSelectionAttributesKey(t),i=this.variants.find(r=>n.generateSelectionAttributesKey(r.selectionAttributes)===e);return i?{primary:i.images.primary,gallery:[...i.images.gallery]}:null}getImages(t,e){switch(e){case"PRIMARY":return this.getImagesBySelectionAttributes(t)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(t)?.gallery??[];default:return this.getImagesBySelectionAttributes(t)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return m.deepClone(this.categories)}getSpecifications(t){return t?m.deepClone(this.specifications[t]??this.specifications[P[t]]??this.specifications.en):m.deepClone(this.specifications)}getSearchTags(t){return t?m.deepClone(this.searchTags[t]??this.searchTags[P[t]]??this.searchTags.en):m.deepClone(this.searchTags)}getDetails(){let t=super.getDetails();return {id:this.getId(),key:this.getKey(),name:this.getName(),description:this.getDescription(),slug:this.getSlug(),brand:this.getBrand(),pricing:Object.keys(this.pricing).reduce((e,i)=>(this.pricing[i]&&(e[i]=this.pricing[i]?.getDetails()),e),{}),attributes:this.getAttributes(),variants:this.variants.map(e=>({sku:e.sku,selectionAttributes:m.deepClone(e.selectionAttributes),images:{primary:e.images.primary.getDetails(),gallery:e.images.gallery.map(i=>i.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...t}}checkSelectionAttributes(t){if(!t||typeof t!="object")throw new L("Selection attributes are required");Object.keys(this.attributes).forEach(e=>{if(e.toLowerCase()==="size")return;let i=this.attributes[e],r=t[e];if(r===void 0)throw new L(`Selection attribute '${e}' is missing`);if(typeof i=="string"){if(typeof r!="string"||i!==r)throw new L(`Selection attribute '${e}' is invalid`)}else if(Array.isArray(i)){if(i.length>0&&typeof i[0]=="string"){if(typeof r!="string"||!i.includes(r))throw new L(`Selection attribute '${e}' is invalid`)}else if(typeof r!="object"||!("name"in r)||i.findIndex(o=>o.name===r.name)<0)throw new L(`Selection attribute '${e}' is invalid`)}});}validateSelectionAttribute(t){let e=n.generateSelectionAttributesKey(t);return this.variants.some(i=>n.generateSelectionAttributesKey(i.selectionAttributes)===e)}validateSize(t){return this.attributes.size.includes(t)}};var Ft={isUUID:n=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(n),isEmail:n=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(n),isURL:n=>/^(http|https):\/\/[^ "]+$/.test(n),generateUUID:(n,t)=>t&&n?Ct(n,t):bt(),generateSearchId:(n,t)=>`${n}#${V.generateSelectionAttributesKey(t)}`,getKeyfromSearchId:n=>{let[t,e]=n.split("#");return {key:t,selectionAttributes:V.parseSelectionAttributesKey(e)}},deepClone(n){return structuredClone(n)}},m=Ft;var G=class extends B{taxRuleId;taxCategory;taxSystem;taxSubSystem;country;rate;minPrice;maxPrice;excludeMin;excludeMax;effectiveFrom;effectiveTo;constructor(t){super(t),this.taxRuleId=t.taxRuleId,this.taxSystem=t.taxSystem,this.taxSubSystem=t.taxSubSystem,this.taxCategory=t.taxCategory,this.country=t.country,this.rate=t.rate,this.minPrice=new s(t.minPrice),this.maxPrice=t.maxPrice?new s(t.maxPrice):void 0,this.excludeMin=t.excludeMin??!1,this.excludeMax=t.excludeMax??!1,this.effectiveFrom=new Date(t.effectiveFrom).toISOString(),this.effectiveTo=t.effectiveTo?new Date(t.effectiveTo).toISOString():void 0;}getTaxRuleId(){return this.taxRuleId}getTaxSystem(){return this.taxSystem}getTaxSubSystem(){return this.taxSubSystem}getTaxCategory(){return this.taxCategory}getCountry(){return this.country}getRate(){return this.rate}getMinPrice(){return this.minPrice}getMaxPrice(){return this.maxPrice}getExcludeMin(){return this.excludeMin}getExcludeMax(){return this.excludeMax}getEffectiveFrom(){return this.effectiveFrom}getEffectiveTo(){return this.effectiveTo}getDetails(){return {taxRuleId:this.getTaxRuleId(),taxSystem:this.getTaxSystem(),taxSubSystem:this.getTaxSubSystem(),taxCategory:this.getTaxCategory(),country:this.getCountry(),rate:this.getRate(),minPrice:this.getMinPrice().getDetails(),maxPrice:this.getMaxPrice()?.getDetails(),excludeMin:this.getExcludeMin(),excludeMax:this.getExcludeMax(),effectiveFrom:this.effectiveFrom,effectiveTo:this.effectiveTo?this.effectiveTo:void 0,customFields:this.getAllCustomFields()}}appliesTo(t,e,i,r=new Date){let o=!i||(this.excludeMin?this.minPrice.compareTo(i)<0:this.minPrice.compareTo(i)<=0)&&(this.maxPrice?this.excludeMax?this.maxPrice.compareTo(i)>0:this.maxPrice.compareTo(i)>=0:!0);return this.taxCategory===t&&this.country===e&&o&&Date.parse(this.effectiveFrom)<=r.getTime()&&(this.effectiveTo?Date.parse(this.effectiveTo)>=r.getTime():!0)}getApplicableTaxRate(t){return this.appliesTo(this.taxCategory,this.country,t)?this.rate:0}calculateTax(t){return this.appliesTo(this.taxCategory,this.country,t)?t.multiply(this.rate):t.zero()}static getTaxRateDisplayString(t,e,i){let r=e*100,o=r%1===0?r.toString():r.toFixed(2).replace(/\.?0+$/,"");return i?.percentageOnly?`${o}%`:t.getTaxSystem()==="GST"?`${t.getTaxSubSystem()} ${o}%`:`${t.getTaxSystem()} ${o}%`}};var q=class extends B{id;productKey;selectionAttributes;name;specifications;primaryImage;subItems;pricing;state;total;constructor(t){super(t),this.id=t.id,this.productKey=t.productKey,this.selectionAttributes=m.deepClone(t.selectionAttributes),this.name=m.deepClone(t.name),this.specifications=m.deepClone(t.specifications),this.primaryImage=new R(t.primaryImage),this.subItems=m.deepClone(t.subItems);let e=new Set;this.subItems.forEach(i=>{if(e.has(i.size))throw new it(i.size);e.add(i.size);}),this.pricing={unitPrice:new s(t.pricing.unitPrice),tierPricing:new $(t.pricing.tierPricing),taxCategory:t.pricing.taxCategory,applicableTaxRule:t.pricing.applicableTaxRule.map(i=>new G(i))},this.validateTaxRules(this.pricing.applicableTaxRule),this.state=t.state??"INITIAL",this.total={quantity:t.total.quantity,unitPrice:new s(t.total.unitPrice),subtotal:new s(t.total.subtotal),discountTotal:new s(t.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(t.total.discountBreakdown).map(([i,r])=>[i,new s(r)])),netUnitPrice:new s(t.total.netUnitPrice),netSubtotal:new s(t.total.netSubtotal),taxTotal:new s(t.total.taxTotal),taxBreakdown:Object.fromEntries(Object.entries(t.total.taxBreakdown).map(([i,r])=>[i,{rate:r.rate,taxableUnitPrice:new s(r.taxableUnitPrice),taxPerUnit:new s(r.taxPerUnit),taxAmount:new s(r.taxAmount),system:r.system,subSystem:r.subSystem}])),grandTotal:new s(t.total.grandTotal)};}getId(){return this.id}getProductKey(){return this.productKey}getSelectionAttributes(){return m.deepClone(this.selectionAttributes)}getName(t){return t?m.deepClone(this.name[t]??this.name[P[t]]??this.name.en):m.deepClone(this.name)}getSpecifications(t){return t?m.deepClone(this.specifications[t]??this.specifications[P[t]]??this.specifications.en):m.deepClone(this.specifications)}getImage(){return this.primaryImage}getSubItems(){return m.deepClone(this.subItems)}getTotalQuantity(){return this.total.quantity}getPricing(){return {unitPrice:this.pricing.unitPrice,tierPricing:this.pricing.tierPricing,taxCategory:this.pricing.taxCategory,applicableTaxRule:[...this.pricing.applicableTaxRule]}}getState(){return this.state}getTotal(){return {quantity:this.total.quantity,unitPrice:this.total.unitPrice,subtotal:this.total.subtotal,discountTotal:this.total.discountTotal,discountBreakdown:Object.fromEntries(Object.entries(this.total.discountBreakdown).map(([t,e])=>[t,e])),netUnitPrice:this.total.netUnitPrice,netSubtotal:this.total.netSubtotal,taxTotal:this.total.taxTotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{rate:e.rate,taxableUnitPrice:e.taxableUnitPrice,taxPerUnit:e.taxPerUnit,taxAmount:e.taxAmount,system:e.system,subSystem:e.subSystem}])),grandTotal:this.total.grandTotal}}getDetails(){let t=this.getPricing(),e=this.getTotal();return {id:this.getId(),productKey:this.getProductKey(),selectionAttributes:this.getSelectionAttributes(),name:this.getName(),specifications:this.getSpecifications(),primaryImage:this.getImage().getDetails(),subItems:this.getSubItems(),pricing:{unitPrice:t.unitPrice.getDetails(),tierPricing:t.tierPricing.getDetails(),taxCategory:t.taxCategory,applicableTaxRule:t.applicableTaxRule.map(i=>i.getDetails())},state:this.getState(),total:{quantity:e.quantity,unitPrice:e.unitPrice.getDetails(),subtotal:e.subtotal.getDetails(),discountTotal:e.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(e.discountBreakdown).map(([i,r])=>[i,r.getDetails()])),netUnitPrice:e.netUnitPrice.getDetails(),netSubtotal:e.netSubtotal.getDetails(),taxTotal:e.taxTotal.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(e.taxBreakdown).map(([i,r])=>[i,{rate:r.rate,taxableUnitPrice:r.taxableUnitPrice.getDetails(),taxPerUnit:r.taxPerUnit.getDetails(),taxAmount:r.taxAmount.getDetails(),system:r.system,subSystem:r.subSystem}])),grandTotal:e.grandTotal.getDetails()},customFields:this.getAllCustomFields()}}validateTaxRules(t){let e=new Set;for(let i=0;i<t.length;i++){let r=t[i].getTaxRuleId();if(e.has(r))throw new et("Duplicate tax rule ID found: "+r);e.add(r);}}addSubItems(t,e){t.forEach(i=>{let r=this.subItems.find(o=>o.size===i.size);r?r.quantity=e?r.quantity+i.quantity:i.quantity:this.subItems.push(i);}),this.subItems=this.subItems.filter(i=>i.quantity>0),this.calculateTotals();}updateProductData(t,e,i){if(this.productKey!==t.getKey()||!t.validateSelectionAttribute(this.selectionAttributes))throw new nt;if(!t.getIsActive())throw new ot;this.subItems.forEach(g=>{if(!t.validateSize(g.size))throw new st});let r=t.getPriceDetails(e);if(!r||r.getBaseUnitPrice().getCurrency()!==i)throw new at;this.name=t.getName(),this.specifications=t.getSpecifications(),this.primaryImage=t.getImages(this.selectionAttributes).primary;let o=this.subItems.reduce((g,d)=>g+d.quantity,0),{unitPrice:a}=r.getApplicableTier(o);this.pricing={unitPrice:a,tierPricing:r,taxCategory:r.getTaxCategory(),applicableTaxRule:this.pricing.applicableTaxRule},this.calculateTotals();}updateDiscounts(t){let e={};t.forEach(i=>{e[i.coupon.getCode()]=i.amount;}),this.total.discountBreakdown=e,this.calculateTotals();}updateTax(t){t.forEach(e=>{if(!e.appliesTo(this.pricing.taxCategory,e.getCountry()))throw new F}),this.validateTaxRules(t),this.pricing.applicableTaxRule=t,this.calculateTotals();}calculateTotals(){let t=this.pricing.unitPrice.zero(),e=this.subItems.reduce((h,b)=>h+b.quantity,0);if(this.state==="CANCELLED"){this.total={quantity:0,unitPrice:t,subtotal:t,discountTotal:t,discountBreakdown:{},netUnitPrice:t,netSubtotal:t,taxTotal:t,taxBreakdown:{},grandTotal:t};return}let{unitPrice:i}=this.pricing.tierPricing.getApplicableTier(e),r=i.multiply(e),o=Object.values(this.total.discountBreakdown).reduce((h,b)=>h.add(b),t),a=r.subtract(o),g=e>0?a.divide(e):t,d={},c=t;this.pricing.applicableTaxRule.forEach(h=>{let b=h.getApplicableTaxRate(g),T=h.calculateTax(g),A=T.multiply(e).round();d[h.getTaxRuleId()]={rate:b,taxableUnitPrice:g,taxPerUnit:T,taxAmount:A,system:h.getTaxSystem(),subSystem:h.getTaxSubSystem()},c=c.add(A);});let u=a.add(c);this.total={quantity:e,unitPrice:i,subtotal:r,discountTotal:o,discountBreakdown:this.total.discountBreakdown,netUnitPrice:g,netSubtotal:a,taxTotal:c,taxBreakdown:d,grandTotal:u};}updateState(t){if(this.state in _)this.state!==t&&(this.state=t);else throw new tt(t)}clearLineItem(){let t=this.pricing.unitPrice.zero();this.id="",this.productKey="",this.selectionAttributes={color:{name:""}},this.name={en:""},this.primaryImage=new R({sources:{original:""}}),this.subItems=[],this.pricing={unitPrice:t,tierPricing:this.pricing.tierPricing,taxCategory:this.pricing.taxCategory,applicableTaxRule:[]},this.total={quantity:0,unitPrice:t,subtotal:t,discountTotal:t,discountBreakdown:{},netUnitPrice:t,netSubtotal:t,taxTotal:t,taxBreakdown:{},grandTotal:t};}};var Y=class extends w{couponCode;name;description;type;customerId;validFrom;validTo;minCartValue;maxCartDiscount;discountMethod;percentageValue;applicableTo;category;constructor(t,e=new Date){if(super(t,e),this.couponCode=t.couponCode,this.name=m.deepClone(t.name),this.description=m.deepClone(t.description),this.type=t.type,this.customerId=t.customerId,this.validFrom=t.validFrom&&Date.parse(t.validFrom)?new Date(t.validFrom).toISOString():e.toISOString(),this.validTo=t.validTo&&Date.parse(t.validTo)?new Date(t.validTo).toISOString():e.toISOString(),this.minCartValue=Object.keys(t.minCartValue).reduce((i,r)=>{let o=t.minCartValue[r];return o&&(i[r]=new s(o)),i},{}),this.maxCartDiscount=Object.keys(t.maxCartDiscount).reduce((i,r)=>{let o=t.maxCartDiscount[r];return o&&(i[r]=new s(o)),i},{}),this.discountMethod=t.discountMethod,this.percentageValue=t.percentageValue??0,this.percentageValue>100)throw new D("Percentage value cannot be greater than 100");this.applicableTo=t.applicableTo,this.category=t.category;}getCode(){return this.couponCode}getName(t){return t?this.name[t]??this.name[P[t]]??this.name.en:{...this.name}}getDescription(t){return t?this.description[t]??this.description[P[t]]??this.description.en:{...this.description}}getType(){return this.type}getCustomerId(){return this.customerId??""}getValidFrom(){return this.validFrom}getValidTo(){return this.validTo}getMinCartValue(t){return t?this.minCartValue[t]:{...this.minCartValue}}getMaxCartDiscount(t){return t?this.maxCartDiscount[t]:{...this.maxCartDiscount}}getDiscountMethod(){return this.discountMethod}getPercentageValue(){return this.percentageValue}getApplicableTo(){return this.applicableTo}getCategory(){return this.category}getDetails(){return {...super.getDetails(),couponCode:this.getCode(),name:this.getName(),description:this.getDescription(),type:this.getType(),customerId:this.getCustomerId(),validFrom:this.getValidFrom(),validTo:this.getValidTo(),minCartValue:Object.keys(this.getMinCartValue()).reduce((t,e)=>{let i=this.getMinCartValue(e);return i&&(t[e]=i.getDetails()),t},{}),maxCartDiscount:Object.keys(this.getMaxCartDiscount()).reduce((t,e)=>{let i=this.getMaxCartDiscount(e);return i&&(t[e]=i.getDetails()),t},{}),discountMethod:this.getDiscountMethod(),percentageValue:this.getPercentageValue(),applicableTo:this.getApplicableTo(),category:this.getCategory()}}isActive(){return new Date(this.validFrom)<=new Date&&new Date(this.validTo)>=new Date}isApplicableTo(t){return this.applicableTo==="all"||this.applicableTo==="ftb"&&t}calculateApplicableCouponDiscount(t,e,i,r,o=!0){let a=new s({amount:0,currency:r}),g;if(o&&!this.isActive())return a;let d=this.getMinCartValue(i),c=this.getMaxCartDiscount(i);if(!d||d.compareTo(t)>0||!c)return a;let u=this.getCategory(),h=this.getDiscountMethod(),b=u==="SHIPPING"?e:t;if(b.getAmount()<=0)return a;switch(h){case"flat":let A=c;g=b.min(A);break;case"percentage":g=b.multiply(this.getPercentageValue()/100).round();break;default:return a}return g.min(c)}};var K=class extends B{id;name;type;category;impact;pricing;lineItemId;total;constructor(t){if(super(t),this.id=t.id,this.name=t.name,this.type=t.type,this.category=t.category,this.impact=t.impact,this.lineItemId=t.lineItemId,this.pricing={baseChargeAmount:new s(t.pricing.baseChargeAmount),taxCategory:t.pricing.taxCategory,applicableTaxRule:t.pricing.applicableTaxRule.map(e=>new G(e))},this.validateTaxRules(this.pricing.applicableTaxRule),this.impact==="SUBTRACT"&&this.type!=="ADJUSTMENT")throw new Z("SUBTRACT impact is only allowed for ADJUSTMENT charge");this.total={chargeAmount:new s(t.total.chargeAmount),discountTotal:new s(t.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(t.total.discountBreakdown).map(([e,i])=>[e,new s(i)])),netChargeAmount:new s(t.total.netChargeAmount),taxBreakdown:Object.fromEntries(Object.entries(t.total.taxBreakdown).map(([e,i])=>[e,{rate:i.rate,taxableAmount:new s(i.taxableAmount),taxAmount:new s(i.taxAmount),system:i.system,subSystem:i.subSystem}])),taxTotal:new s(t.total.taxTotal),grandTotal:new s(t.total.grandTotal)};}getId(){return this.id}getName(t){return t?m.deepClone(this.name[t]??this.name[P[t]]??this.name.en):m.deepClone(this.name)}getCategory(){return this.category}getType(){return this.type}getImpact(){return this.impact}getLineItemId(){return this.lineItemId}getPricing(){return {baseChargeAmount:this.pricing.baseChargeAmount,taxCategory:this.pricing.taxCategory,applicableTaxRule:[...this.pricing.applicableTaxRule]}}getTotal(){return {chargeAmount:this.total.chargeAmount,discountTotal:this.total.discountTotal,discountBreakdown:{...this.total.discountBreakdown},netChargeAmount:this.total.netChargeAmount,taxTotal:this.total.taxTotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{rate:e.rate,taxableAmount:e.taxableAmount,taxAmount:e.taxAmount,system:e.system,subSystem:e.subSystem}])),grandTotal:this.total.grandTotal}}getApplicableTaxRules(){return [...this.pricing.applicableTaxRule]}updateTax(t){if(this.type==="ADJUSTMENT"&&t.length>0)throw new Z("Adjustment charges cannot apply tax rules.");t.forEach(e=>{if(!e.appliesTo(this.pricing.taxCategory,e.getCountry()))throw new F}),this.validateTaxRules(t),this.pricing.applicableTaxRule=t,this.calculateTotals();}validateTaxRules(t){if(this.impact==="SUBTRACT"&&t.some(i=>i.getRate()>0))throw new j("Subtractive charges cannot have positive tax rates.");let e=new Set;for(let i=0;i<t.length;i++){let r=t[i].getTaxRuleId();if(e.has(r))throw new j("Duplicate tax rule ID found: "+r);e.add(r);for(let o=i+1;o<t.length;o++){let a=t[i],g=t[o],d=a.getMinPrice(),c=a.getMaxPrice(),u=a.getExcludeMin(),h=a.getExcludeMax(),b=g.getMinPrice(),T=g.getMaxPrice(),A=g.getExcludeMin(),M=g.getExcludeMax(),x=(()=>{if(!c)return !1;let S=c.compareTo(b);return S<0||S===0&&(h||A)})(),y=(()=>{if(!T)return !1;let S=T.compareTo(d);return S<0||S===0&&(M||u)})();if(!(x||y)&&!(d.compareTo(b)===0&&u===A&&h===M&&(!c&&!T||c&&T&&c.compareTo(T)===0)))throw new j(`Overlapping rules found: [${a.getTaxRuleId()}: ${u?"(":"["}${d.getAmount()}-${c?.getAmount()??"Infinity"}${h?")":"]"}] and [${g.getTaxRuleId()}: ${A?"(":"["}${b.getAmount()}-${T?.getAmount()??"Infinity"}${M?")":"]"}]`)}}}updateDiscounts(t){let e={};t.forEach(i=>{e[i.coupon.getCode()]=i.amount;}),this.total.discountBreakdown=e,this.calculateTotals();}calculateTotals(){let t=this.pricing.baseChargeAmount.zero(),e=this.pricing.baseChargeAmount,i=Object.values(this.total.discountBreakdown).reduce((x,y)=>x.add(y),t),r=e.subtract(i),o={},a=this.pricing.applicableTaxRule.reduce((x,y)=>x+y.getApplicableTaxRate(r),0);if(a<=0){this.total={chargeAmount:e,discountTotal:i,discountBreakdown:this.total.discountBreakdown,netChargeAmount:r,taxTotal:t,taxBreakdown:{},grandTotal:r};return}let g=r.getCurrency(),d=r.getAmount(),c=1e3,u=s.getRoundedAmount(d/(1+a),g),h=u,b=Number.POSITIVE_INFINITY;for(let x=0;x<c;x++){let y=new s({amount:u,currency:g}),S=this.pricing.applicableTaxRule.sort((l,p)=>p.getApplicableTaxRate(y)-l.getApplicableTaxRate(y)).map(l=>s.getRoundedAmount(u*l.getApplicableTaxRate(y),g)).reduce((l,p)=>l+p,0),E=u+S-d,pt=this.pricing.applicableTaxRule.reduce((l,p)=>l+p.getApplicableTaxRate(y),0);if(Math.abs(E)<Math.abs(b)&&(b=E,h=u),E===0||(u=u-E/(1+pt),u<0||u>d))break}let T=new s({amount:h,currency:g}),A=t;this.pricing.applicableTaxRule.sort((x,y)=>y.getApplicableTaxRate(T)-x.getApplicableTaxRate(T)).forEach(x=>{let y=x.getApplicableTaxRate(T),O=s.getRoundedAmount(h*y,g),S=new s({amount:O,currency:g});o[x.getTaxRuleId()]={rate:y,taxableAmount:T,taxAmount:S,system:x.getTaxSystem(),subSystem:x.getTaxSubSystem()},A=A.add(S);});let M=r;this.total={chargeAmount:e,discountTotal:i,discountBreakdown:this.total.discountBreakdown,netChargeAmount:r,taxBreakdown:o,taxTotal:A,grandTotal:M};}getDetails(){return {id:this.id,name:m.deepClone(this.name),type:this.type,category:this.category,pricing:{baseChargeAmount:this.pricing.baseChargeAmount.getDetails(),taxCategory:this.pricing.taxCategory,applicableTaxRule:this.pricing.applicableTaxRule.map(e=>e.getDetails())},impact:this.impact,lineItemId:this.lineItemId,total:{chargeAmount:this.total.chargeAmount.getDetails(),discountTotal:this.total.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(this.total.discountBreakdown).map(([e,i])=>[e,i.getDetails()])),netChargeAmount:this.total.netChargeAmount.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([e,i])=>[e,{rate:i.rate,taxableAmount:i.taxableAmount.getDetails(),taxAmount:i.taxAmount.getDetails(),system:i.system,subSystem:i.subSystem}])),taxTotal:this.total.taxTotal.getDetails(),grandTotal:this.total.grandTotal.getDetails()},customFields:this.getAllCustomFields()}}};var xt=class extends w{id;customerId;customerEmail;anonymousId;lineItems;charges;shippingDetails;shippingAddress;billingAddress;coupons;total;country;currency;locale;#t;constructor(t,e=new Date,i={checkCouponExpiry:!0}){super(t,e),this.id=t.id,this.customerId=t.customerId,this.customerEmail=t.customerEmail,this.anonymousId=t.anonymousId,this.country=t.country,this.currency=t.currency,this.locale=t.locale,this.lineItems=(t.lineItems??[]).map(r=>new q(r)),this.charges=(t.charges??[]).map(r=>new K(r)),this.billingAddress=t.billingAddress?new U(t.billingAddress,e):null,this.shippingAddress=t.shippingAddress?new U(t.shippingAddress,e):null,this.coupons=(t.coupons??[]).map(r=>new Y(r)),this.shippingDetails=t.shippingDetails?m.deepClone(t.shippingDetails):null,this.total={lineItemSubtotal:new s(t.total.lineItemSubtotal),netLineItemSubtotal:new s(t.total.netLineItemSubtotal),lineItemTaxTotal:new s(t.total.lineItemTaxTotal),lineItemTaxBreakdown:this.mapTaxBreakdown(t.total.lineItemTaxBreakdown),additiveCharges:new s(t.total.additiveCharges),netAdditiveCharges:new s(t.total.netAdditiveCharges),additiveChargesTaxTotal:new s(t.total.additiveChargesTaxTotal),additiveChargesTaxBreakdown:this.mapTaxBreakdown(t.total.additiveChargesTaxBreakdown),adjustmentCharges:new s(t.total.adjustmentCharges),shippingCharges:new s(t.total.shippingCharges),netShippingCharges:new s(t.total.netShippingCharges),discountTotal:new s(t.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(t.total.discountBreakdown).map(([r,o])=>[r,new s(o)])),taxTotal:new s(t.total.taxTotal),taxBreakdown:this.mapTaxBreakdown(t.total.taxBreakdown),grandTotal:new s(t.total.grandTotal)},this.#t={checkCouponExpiry:i.checkCouponExpiry};}mapTaxBreakdown(t){return Object.fromEntries(Object.entries(t||{}).map(([e,i])=>[e,{system:i.system,totalAmount:new s(i.totalAmount),subSystems:Object.fromEntries(Object.entries(i.subSystems).map(([r,o])=>[r,new s(o)]))}]))}serializeTaxBreakdown(t){return Object.fromEntries(Object.entries(t||{}).map(([e,i])=>[e,{system:i.system,totalAmount:i.totalAmount.getDetails(),subSystems:Object.fromEntries(Object.entries(i.subSystems).map(([r,o])=>[r,o.getDetails()]))}]))}getId(){return this.id}getCustomerId(){return this.customerId}getCustomerEmail(){return this.customerEmail}getAnonymousId(){return this.anonymousId}getLineItems(){return this.lineItems.map(t=>new q(t.getDetails()))}getLineItemsCount(){return this.lineItems.length}getCharges(){return this.charges.map(t=>new K(t.getDetails()))}addCharge(t){this.charges.push(t),this.calculateTotals();}clearCharges(){this.charges=[],this.calculateTotals();}getShippingDetails(){return this.shippingDetails?m.deepClone(this.shippingDetails):null}getShippingAddress(){return this.shippingAddress?new U(this.shippingAddress.getDetails()):null}hasShippingAddress(){return !!this.shippingAddress}hasBillingAddress(){return !!this.billingAddress}getBillingAddress(){return this.billingAddress?new U(this.billingAddress.getDetails()):null}getCoupons(){return [...this.coupons]}getCountry(){return this.country}getCurrency(){return this.currency}getLocale(){return this.locale}getTotal(){return {lineItemSubtotal:this.total.lineItemSubtotal,netLineItemSubtotal:this.total.netLineItemSubtotal,lineItemTaxTotal:this.total.lineItemTaxTotal,lineItemTaxBreakdown:Object.fromEntries(Object.entries(this.total.lineItemTaxBreakdown).map(([t,e])=>[t,{system:e.system,totalAmount:e.totalAmount,subSystems:{...e.subSystems}}])),additiveCharges:this.total.additiveCharges,netAdditiveCharges:this.total.netAdditiveCharges,additiveChargesTaxTotal:this.total.additiveChargesTaxTotal,additiveChargesTaxBreakdown:Object.fromEntries(Object.entries(this.total.additiveChargesTaxBreakdown).map(([t,e])=>[t,{system:e.system,totalAmount:e.totalAmount,subSystems:{...e.subSystems}}])),adjustmentCharges:this.total.adjustmentCharges,shippingCharges:this.total.shippingCharges,netShippingCharges:this.total.netShippingCharges,discountBreakdown:{...this.total.discountBreakdown},discountTotal:this.total.discountTotal,taxTotal:this.total.taxTotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{system:e.system,totalAmount:e.totalAmount,subSystems:{...e.subSystems}}])),grandTotal:this.total.grandTotal}}getDetails(){let t=this.getTotal();return {...super.getDetails(),id:this.getId(),customerId:this.getCustomerId(),customerEmail:this.getCustomerEmail(),anonymousId:this.getAnonymousId(),lineItems:this.getLineItems().map(e=>e.getDetails()),charges:this.getCharges().map(e=>e.getDetails()),shippingDetails:this.getShippingDetails(),shippingAddress:this.getShippingAddress()?.getDetails()||null,billingAddress:this.getBillingAddress()?.getDetails()||null,coupons:this.getCoupons().map(e=>e.getDetails()),total:{lineItemSubtotal:t.lineItemSubtotal.getDetails(),netLineItemSubtotal:t.netLineItemSubtotal.getDetails(),lineItemTaxTotal:t.lineItemTaxTotal.getDetails(),lineItemTaxBreakdown:this.serializeTaxBreakdown(t.lineItemTaxBreakdown),additiveCharges:t.additiveCharges.getDetails(),netAdditiveCharges:t.netAdditiveCharges.getDetails(),additiveChargesTaxTotal:t.additiveChargesTaxTotal.getDetails(),additiveChargesTaxBreakdown:this.serializeTaxBreakdown(t.additiveChargesTaxBreakdown),adjustmentCharges:t.adjustmentCharges.getDetails(),shippingCharges:t.shippingCharges.getDetails(),netShippingCharges:t.netShippingCharges.getDetails(),discountTotal:t.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(t.discountBreakdown).map(([e,i])=>[e,i.getDetails()])),taxTotal:t.taxTotal.getDetails(),taxBreakdown:this.serializeTaxBreakdown(t.taxBreakdown),grandTotal:t.grandTotal.getDetails()},country:this.getCountry(),currency:this.getCurrency(),locale:this.getLocale()}}calculateTotals(){let t=new s({amount:0,currency:this.currency}),e=this.lineItems.filter(l=>l.getState()!=="CANCELLED"),i=e.reduce((l,p)=>l.add(p.getTotal().subtotal),t),r=this.charges.filter(l=>l.getType()==="SHIPPING").reduce((l,p)=>l.add(p.getTotal().chargeAmount),t);this.total.lineItemSubtotal=i,this.total.shippingCharges=r;let o=t,a={},g={};this.coupons.forEach(l=>{let p=l.calculateApplicableCouponDiscount(i,r,this.country,this.currency,this.#t.checkCouponExpiry);o=o.add(p),a[l.getCode()]=p,l.getCategory()!=="SHIPPING"&&(g[l.getCode()]=p);}),this.total.discountTotal=o,this.total.discountBreakdown=a,this.applyDiscountsInLineItem(g);let d=this.coupons.find(l=>l.getCategory()==="SHIPPING");d?this.applyDiscountsInShippingCharges({[d.getCode()]:a[d.getCode()]||t}):this.applyDiscountsInShippingCharges({});let c=this.lineItems.reduce((l,p)=>l.add(p.getTotal().netSubtotal),t),u=this.charges.filter(l=>l.getType()==="SHIPPING").reduce((l,p)=>l.add(p.getTotal().grandTotal),t);this.total.netLineItemSubtotal=c,this.total.netShippingCharges=u;let h=this.charges.filter(l=>l.getImpact()==="ADD").reduce((l,p)=>l.add(p.getTotal().chargeAmount),t),b=this.charges.filter(l=>l.getImpact()==="ADD").reduce((l,p)=>l.add(p.getTotal().grandTotal),t),T=this.charges.filter(l=>l.getImpact()==="SUBTRACT").reduce((l,p)=>l.add(p.getTotal().grandTotal),t),A=t,M=t,x=t,y={},O={},S={},E=(l,p)=>{Object.entries(l).forEach(([$t,k])=>{let f=k.system,N=k.subSystem;p[f]||(p[f]={system:f,totalAmount:t,subSystems:{}}),p[f].subSystems[N]?p[f].subSystems[N]=p[f].subSystems[N].add(k.taxAmount):p[f].subSystems[N]=k.taxAmount,p[f].totalAmount=p[f].totalAmount.add(k.taxAmount),y[f]||(y[f]={system:f,totalAmount:t,subSystems:{}}),y[f].subSystems[N]?y[f].subSystems[N]=y[f].subSystems[N].add(k.taxAmount):y[f].subSystems[N]=k.taxAmount,y[f].totalAmount=y[f].totalAmount.add(k.taxAmount);});};e.forEach(l=>{let p=l.getTotal().taxBreakdown;p&&(E(p,O),E(p,y),M=M.add(l.getTotal().taxTotal));}),this.charges.forEach(l=>{let p=l.getTotal().taxBreakdown;p&&(E(p,S),E(p,y),x=x.add(l.getTotal().taxTotal));}),A=M.add(x);let pt=c.add(M).add(b).subtract(T);this.total={lineItemSubtotal:i,netLineItemSubtotal:c,lineItemTaxTotal:M,lineItemTaxBreakdown:O,additiveCharges:h,netAdditiveCharges:b,additiveChargesTaxTotal:x,additiveChargesTaxBreakdown:S,adjustmentCharges:T,shippingCharges:r,netShippingCharges:u,discountTotal:o,discountBreakdown:a,taxTotal:A,taxBreakdown:y,grandTotal:pt};}updateShippingDetails(t){this.shippingDetails=t;}applyCoupons(t){let e=t.filter(r=>r.getCategory()==="SHIPPING"),i=t.filter(r=>r.getCategory()!=="SHIPPING");this.coupons=[],this.total.discountTotal=this.total.lineItemSubtotal.zero(),this.total.discountBreakdown={},i.length&&this.applyNonShippingCoupons(i),this.applyDiscountsInLineItem(this.total.discountBreakdown),e.length&&this.applyShippingCoupons(e),this.calculateTotals();}applyDiscountsInLineItem(t){let e=Array.from(Object.entries(t)).filter(r=>!r[1].isZero()),i=new Map;this.lineItems.forEach(r=>i.set(r.getId(),[])),e.forEach(([r,o])=>{let a=this.coupons.find(c=>c.getCode()===r);if(!a||o.isZero())return;let g=this.lineItems.filter(c=>c.getState()!=="CANCELLED"&&!c.getTotal().subtotal.isZero()).sort((c,u)=>c.getTotal().subtotal.compareTo(u.getTotal().subtotal)),d=new s({amount:0,currency:this.currency});g.forEach((c,u)=>{let h;u===g.length-1?h=o.subtract(d):h=o.multiply(c.getTotal().subtotal).divide(this.total.lineItemSubtotal).round(),d=d.add(h),i.get(c.getId())?.push({coupon:a,amount:h});});}),this.lineItems.forEach(r=>{r.getState()==="CANCELLED"||this.total.lineItemSubtotal.isZero()?r.updateDiscounts([]):r.updateDiscounts(i.get(r.getId())||[]);});}applyDiscountsInShippingCharges(t){let e=Array.from(Object.entries(t)).filter(o=>!o[1].isZero()),i=this.charges.filter(o=>o.getType()==="SHIPPING"),r=new Map;i.forEach(o=>r.set(o.getId(),[])),e.forEach(([o,a])=>{let g=this.coupons.find(u=>u.getCode()===o);if(!g||a.isZero())return;let d=i.sort((u,h)=>u.getTotal().grandTotal.compareTo(h.getTotal().grandTotal)),c=new s({amount:0,currency:this.currency});d.forEach((u,h)=>{let b;h===d.length-1?b=a.subtract(c):b=a.multiply(u.getTotal().chargeAmount).divide(this.total.shippingCharges).round(),c=c.add(b),r.get(u.getId())?.push({coupon:g,amount:b});});}),i.forEach(o=>{o.updateDiscounts(r.get(o.getId())||[]);});}applyNonShippingCoupons(t){let e=t.filter(i=>i.getType()==="coupon");if(e.length===1){let i=e[0].calculateApplicableCouponDiscount(this.total.lineItemSubtotal,this.total.shippingCharges,this.country,this.currency,this.#t.checkCouponExpiry);i.getAmount()>0&&(this.coupons.push(e[0]),this.total.discountTotal=i,this.total.discountBreakdown[e[0].getCode()]=i);}}applyShippingCoupons(t){if(this.total.shippingCharges.getAmount()>0&&t.length>0){let e=this.total.lineItemSubtotal.subtract(this.total.discountTotal),i=t.reduce((o,a)=>{if(!o)return a;let g=a.calculateApplicableCouponDiscount(e,this.total.shippingCharges,this.country,this.currency,this.#t.checkCouponExpiry).min(this.total.shippingCharges),d=o.calculateApplicableCouponDiscount(e,this.total.shippingCharges,this.country,this.currency,this.#t.checkCouponExpiry).min(this.total.shippingCharges);return g.compareTo(d)===0?a.getType()==="coupon"?a:o:g.compareTo(d)>0?a:o}),r=i.calculateApplicableCouponDiscount(e,this.total.shippingCharges,this.country,this.currency,this.#t.checkCouponExpiry).min(this.total.shippingCharges);r.getAmount()>0&&(this.coupons.push(i),this.total.discountTotal=this.total.discountTotal.add(r),this.total.discountBreakdown[i.getCode()]=r);}}};module.exports=xt;//# sourceMappingURL=ShoppingContainer.js.map
2
2
  //# sourceMappingURL=ShoppingContainer.js.map