b23-lib 3.0.7 → 3.0.9

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 (103) hide show
  1. package/dist/Auth/index.js +1 -1
  2. package/dist/Auth/index.js.map +1 -1
  3. package/dist/Auth/index.mjs +1 -1
  4. package/dist/Auth/index.mjs.map +1 -1
  5. package/dist/Classes/Address.js +1 -1
  6. package/dist/Classes/Address.js.map +1 -1
  7. package/dist/Classes/Address.mjs +1 -1
  8. package/dist/Classes/Base.js +1 -1
  9. package/dist/Classes/Base.js.map +1 -1
  10. package/dist/Classes/Base.mjs +1 -1
  11. package/dist/Classes/Cart.js +1 -1
  12. package/dist/Classes/Cart.js.map +1 -1
  13. package/dist/Classes/Cart.mjs +1 -1
  14. package/dist/Classes/Cart.mjs.map +1 -1
  15. package/dist/Classes/Charge.d.mts +53 -2
  16. package/dist/Classes/Charge.d.ts +53 -2
  17. package/dist/Classes/Charge.js +1 -1
  18. package/dist/Classes/Charge.js.map +1 -1
  19. package/dist/Classes/Charge.mjs +1 -1
  20. package/dist/Classes/Coupon.js +1 -1
  21. package/dist/Classes/Coupon.js.map +1 -1
  22. package/dist/Classes/Coupon.mjs +1 -1
  23. package/dist/Classes/Customer.js +1 -1
  24. package/dist/Classes/Customer.js.map +1 -1
  25. package/dist/Classes/Customer.mjs +1 -1
  26. package/dist/Classes/Customer.mjs.map +1 -1
  27. package/dist/Classes/CustomerAddress.js +1 -1
  28. package/dist/Classes/CustomerAddress.js.map +1 -1
  29. package/dist/Classes/CustomerAddress.mjs +1 -1
  30. package/dist/Classes/CustomerAddress.mjs.map +1 -1
  31. package/dist/Classes/Enum.d.mts +9 -1
  32. package/dist/Classes/Enum.d.ts +9 -1
  33. package/dist/Classes/Enum.js +1 -1
  34. package/dist/Classes/Enum.js.map +1 -1
  35. package/dist/Classes/Enum.mjs +1 -1
  36. package/dist/Classes/Inventory.js +1 -1
  37. package/dist/Classes/Inventory.js.map +1 -1
  38. package/dist/Classes/Inventory.mjs +1 -1
  39. package/dist/Classes/Inventory.mjs.map +1 -1
  40. package/dist/Classes/LineItem.js +1 -1
  41. package/dist/Classes/LineItem.js.map +1 -1
  42. package/dist/Classes/LineItem.mjs +1 -1
  43. package/dist/Classes/Order.js +1 -1
  44. package/dist/Classes/Order.js.map +1 -1
  45. package/dist/Classes/Order.mjs +1 -1
  46. package/dist/Classes/Order.mjs.map +1 -1
  47. package/dist/Classes/Payment.js +1 -1
  48. package/dist/Classes/Payment.js.map +1 -1
  49. package/dist/Classes/Payment.mjs +1 -1
  50. package/dist/Classes/Payment.mjs.map +1 -1
  51. package/dist/Classes/Price.js +1 -1
  52. package/dist/Classes/Price.js.map +1 -1
  53. package/dist/Classes/Price.mjs +1 -1
  54. package/dist/Classes/Product.js +1 -1
  55. package/dist/Classes/Product.js.map +1 -1
  56. package/dist/Classes/Product.mjs +1 -1
  57. package/dist/Classes/ShoppingContainer.d.mts +4 -0
  58. package/dist/Classes/ShoppingContainer.d.ts +4 -0
  59. package/dist/Classes/ShoppingContainer.js +1 -1
  60. package/dist/Classes/ShoppingContainer.js.map +1 -1
  61. package/dist/Classes/ShoppingContainer.mjs +1 -1
  62. package/dist/Classes/TaxRule.js.map +1 -1
  63. package/dist/Classes/TaxRule.mjs +1 -1
  64. package/dist/Classes/TieredPrice.js +1 -1
  65. package/dist/Classes/TieredPrice.js.map +1 -1
  66. package/dist/Classes/TieredPrice.mjs +1 -1
  67. package/dist/chunk-2QHUEAZR.mjs +2 -0
  68. package/dist/chunk-2QHUEAZR.mjs.map +1 -0
  69. package/dist/{chunk-XHGUVYQO.mjs → chunk-3HKY6ZOF.mjs} +2 -2
  70. package/dist/{chunk-XHGUVYQO.mjs.map → chunk-3HKY6ZOF.mjs.map} +1 -1
  71. package/dist/chunk-4ZFZXWD7.mjs +2 -0
  72. package/dist/chunk-4ZFZXWD7.mjs.map +1 -0
  73. package/dist/chunk-GFMGTV5E.mjs +2 -0
  74. package/dist/chunk-GFMGTV5E.mjs.map +1 -0
  75. package/dist/{chunk-R3ZADSUJ.mjs → chunk-HX32EJ3F.mjs} +2 -2
  76. package/dist/{chunk-R3ZADSUJ.mjs.map → chunk-HX32EJ3F.mjs.map} +1 -1
  77. package/dist/{chunk-L3CNGDFJ.mjs → chunk-JCUHTCOC.mjs} +2 -2
  78. package/dist/{chunk-L3CNGDFJ.mjs.map → chunk-JCUHTCOC.mjs.map} +1 -1
  79. package/dist/chunk-OAE2FJFJ.mjs +2 -0
  80. package/dist/chunk-OAE2FJFJ.mjs.map +1 -0
  81. package/dist/{chunk-XBFSNBKL.mjs → chunk-QLYPJDDV.mjs} +2 -2
  82. package/dist/{chunk-XBFSNBKL.mjs.map → chunk-QLYPJDDV.mjs.map} +1 -1
  83. package/dist/chunk-UXZBULDS.mjs +2 -0
  84. package/dist/chunk-UXZBULDS.mjs.map +1 -0
  85. package/dist/chunk-Z3CF4K5C.mjs +2 -0
  86. package/dist/{chunk-IQNK7EEI.mjs.map → chunk-Z3CF4K5C.mjs.map} +1 -1
  87. package/dist/chunk-ZZ3B7OGM.mjs +2 -0
  88. package/dist/{chunk-RHSKHT5F.mjs.map → chunk-ZZ3B7OGM.mjs.map} +1 -1
  89. package/dist/index.js +2 -2
  90. package/dist/index.js.map +1 -1
  91. package/dist/index.mjs +1 -1
  92. package/dist/index.mjs.map +1 -1
  93. package/package.json +1 -1
  94. package/dist/chunk-FC4P26U3.mjs +0 -2
  95. package/dist/chunk-FC4P26U3.mjs.map +0 -1
  96. package/dist/chunk-GJ2DSRIP.mjs +0 -2
  97. package/dist/chunk-GJ2DSRIP.mjs.map +0 -1
  98. package/dist/chunk-HKXV6QWV.mjs +0 -2
  99. package/dist/chunk-HKXV6QWV.mjs.map +0 -1
  100. package/dist/chunk-IQNK7EEI.mjs +0 -2
  101. package/dist/chunk-RHSKHT5F.mjs +0 -2
  102. package/dist/chunk-URFRPQCT.mjs +0 -2
  103. package/dist/chunk-URFRPQCT.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export{d as Fetch,b as Logger,c as ResponseUtility}from'./chunk-AMIRIUMH.mjs';import {d}from'./chunk-HKXV6QWV.mjs';export{a as Utils}from'./chunk-HKXV6QWV.mjs';import'./chunk-XBFSNBKL.mjs';import'./chunk-XHGUVYQO.mjs';import {j,a,b,c as c$1,d as d$1}from'./chunk-FC4P26U3.mjs';import'./chunk-RSTZJZSQ.mjs';import'./chunk-XPKK6DFA.mjs';var p={$id:"standards",definitions:{lowercaseText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]*$"},lowercaseText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,10}$"},lowercaseText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,16}$"},lowercaseText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,30}$"},lowercaseText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,50}$"},lowercaseText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,256}$"},text:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).*$"},text10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,10}$"},text16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,16}$"},text30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,30}$"},text50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,50}$"},text256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,256}$"},requiredText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).+$"},requiredText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,10}$"},requiredText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,16}$"},requiredText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,30}$"},requiredText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,50}$"},requiredText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,256}$"},url:{type:"string",pattern:"^https://[^\\s/$.?#].[^\\s]*$",maxLength:2048},uuid:{type:"string",minLength:1,pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"},productKey:{type:"string",pattern:d.productKeyRegex.source},productSku:{type:"string",pattern:d.productSKURegex.source},genderCategory:{type:"string",enum:Object.values(j)},price:{type:"object",properties:{amount:{type:"number",minimum:0},currency:{$ref:"#/definitions/currency"}},additionalProperties:!1,required:["amount","currency"]},color:{type:"object",properties:{name:{type:"string"},hex:{type:"string"}},additionalProperties:!1,required:["name"]},attributeValue:{oneOf:[{type:"string"},{$ref:"#/definitions/color"}]},selectionAttributes:{type:"object",properties:{color:{$ref:"#/definitions/color"}},required:["color"],additionalProperties:{$ref:"#/definitions/attributeValue"}},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},company:{$ref:"#/definitions/text50"},phone:{type:"string",pattern:"^[0-9]{10}$"},email:{type:"string",pattern:"^[^\\s]+@[^\\s]+\\.[^\\s]+$"},addressLine1:{$ref:"#/definitions/requiredText50"},addressLine2:{$ref:"#/definitions/text50"},city:{$ref:"#/definitions/requiredText30"},postalCode:{$ref:"#/definitions/requiredText16"},state:{type:"string",enum:["AP","AR","AS","BR","CT","GA","GJ","HR","HP","JH","KA","KL","MP","MH","MN","ML","MZ","NL","OR","PB","RJ","SK","TN","TG","TR","UP","UT","WB","AN","CH","DH","LD","DL","PY","LA","JK"]},country:{type:"string",enum:Object.values(a)},currency:{type:"string",enum:Object.values(b)},locale:{type:"string",enum:Object.values(c$1)},language:{type:"string",enum:Object.values(d$1)},localeOrLanguage:{type:"string",enum:[...Object.values(c$1),...Object.values(d$1)]},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},company:{$ref:"standards#/definitions/company"},phone:{$ref:"standards#/definitions/phone"},email:{$ref:"standards#/definitions/email"},addressLine1:{$ref:"standards#/definitions/addressLine1"},addressLine2:{$ref:"standards#/definitions/addressLine2"},city:{$ref:"standards#/definitions/city"},postalCode:{$ref:"standards#/definitions/postalCode"},state:{$ref:"standards#/definitions/state"},country:{$ref:"standards#/definitions/country"}},required:["firstName","lastName","phone","email","addressLine1","postalCode","state","country"]}}};var $={getStandardSchemaDefinition(){return p}},c=$;
1
+ export{d as Fetch,b as Logger,c as ResponseUtility}from'./chunk-AMIRIUMH.mjs';import {b}from'./chunk-OAE2FJFJ.mjs';export{a as Utils}from'./chunk-OAE2FJFJ.mjs';import'./chunk-QLYPJDDV.mjs';import'./chunk-3HKY6ZOF.mjs';import {j,a,b as b$1,c as c$1,d}from'./chunk-GFMGTV5E.mjs';import'./chunk-RSTZJZSQ.mjs';import'./chunk-XPKK6DFA.mjs';import'./chunk-UXZBULDS.mjs';var p={$id:"standards",definitions:{lowercaseText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]*$"},lowercaseText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,10}$"},lowercaseText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,16}$"},lowercaseText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,30}$"},lowercaseText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,50}$"},lowercaseText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,256}$"},text:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).*$"},text10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,10}$"},text16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,16}$"},text30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,30}$"},text50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,50}$"},text256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,256}$"},requiredText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).+$"},requiredText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,10}$"},requiredText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,16}$"},requiredText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,30}$"},requiredText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,50}$"},requiredText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,256}$"},url:{type:"string",pattern:"^https://[^\\s/$.?#].[^\\s]*$",maxLength:2048},uuid:{type:"string",minLength:1,pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"},productKey:{type:"string",pattern:b.productKeyRegex.source},productSku:{type:"string",pattern:b.productSKURegex.source},genderCategory:{type:"string",enum:Object.values(j)},price:{type:"object",properties:{amount:{type:"number",minimum:0},currency:{$ref:"#/definitions/currency"}},additionalProperties:!1,required:["amount","currency"]},color:{type:"object",properties:{name:{type:"string"},hex:{type:"string"}},additionalProperties:!1,required:["name"]},attributeValue:{oneOf:[{type:"string"},{$ref:"#/definitions/color"}]},selectionAttributes:{type:"object",properties:{color:{$ref:"#/definitions/color"}},required:["color"],additionalProperties:{$ref:"#/definitions/attributeValue"}},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},company:{$ref:"#/definitions/text50"},phone:{type:"string",pattern:"^[0-9]{10}$"},email:{type:"string",pattern:"^[^\\s]+@[^\\s]+\\.[^\\s]+$"},addressLine1:{$ref:"#/definitions/requiredText50"},addressLine2:{$ref:"#/definitions/text50"},city:{$ref:"#/definitions/requiredText30"},postalCode:{$ref:"#/definitions/requiredText16"},state:{type:"string",enum:["AP","AR","AS","BR","CT","GA","GJ","HR","HP","JH","KA","KL","MP","MH","MN","ML","MZ","NL","OR","PB","RJ","SK","TN","TG","TR","UP","UT","WB","AN","CH","DH","LD","DL","PY","LA","JK"]},country:{type:"string",enum:Object.values(a)},currency:{type:"string",enum:Object.values(b$1)},locale:{type:"string",enum:Object.values(c$1)},language:{type:"string",enum:Object.values(d)},localeOrLanguage:{type:"string",enum:[...Object.values(c$1),...Object.values(d)]},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},company:{$ref:"standards#/definitions/company"},phone:{$ref:"standards#/definitions/phone"},email:{$ref:"standards#/definitions/email"},addressLine1:{$ref:"standards#/definitions/addressLine1"},addressLine2:{$ref:"standards#/definitions/addressLine2"},city:{$ref:"standards#/definitions/city"},postalCode:{$ref:"standards#/definitions/postalCode"},state:{$ref:"standards#/definitions/state"},country:{$ref:"standards#/definitions/country"}},required:["firstName","lastName","phone","email","addressLine1","postalCode","state","country"]}}};var $={getStandardSchemaDefinition(){return p}},c=$;
2
2
  export{c as Schema};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Schema/definition.ts","../src/Schema/index.ts"],"names":["definition_default","ProductModel","GenderCategory","OperationalCountry","OperationalCountryCurrency","OperationalLocale","OperationalLanguage","Schema","Schema_default"],"mappings":"+UAGA,IAAOA,CAAQ,CAAA,CACb,GAAO,CAAA,WAAA,CACP,WAAe,CAAA,CACX,aAAiB,CAAA,CACb,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,2BACf,CACA,CAAA,eAAA,CAAmB,CACf,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,gCACf,CAAA,CACA,eAAmB,CAAA,CACf,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,gCACf,CACA,CAAA,eAAA,CAAmB,CACf,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,gCACf,CAAA,CACA,eAAmB,CAAA,CACf,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA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,CAAoB,CAChB,IAAA,CAAQ,QACP,CAAA,IAAA,CAAQ,CAAC,GAAG,MAAO,CAAA,MAAA,CAAOD,GAAiB,CAAA,CAAG,GAAG,MAAA,CAAO,MAAOC,CAAAA,GAAmB,CAAC,CACxF,CACA,CAAA,WAAA,CAAe,CACX,IAAA,CAAQ,QACR,CAAA,IAAA,CAAQ,CAAC,UAAA,CAAY,SAAW,CAAA,kBAAkB,CACtD,CAAA,CACA,OAAW,CAAA,CACP,IAAQ,CAAA,QAAA,CACR,UAAc,CAAA,CACV,SAAa,CAAA,CAAC,IAAQ,CAAA,kCAAkC,CACxD,CAAA,QAAA,CAAY,CAAE,IAAA,CAAQ,iCAAkC,CAAA,CACxD,OAAW,CAAA,CAAE,IAAQ,CAAA,gCAAiC,CACtD,CAAA,KAAA,CAAS,CAAE,IAAA,CAAQ,8BAA+B,CAAA,CAClD,KAAS,CAAA,CAAE,IAAQ,CAAA,8BAA+B,CAClD,CAAA,YAAA,CAAgB,CAAE,IAAA,CAAQ,qCAAsC,CAAA,CAChE,YAAgB,CAAA,CAAE,IAAQ,CAAA,qCAAsC,CAChE,CAAA,IAAA,CAAQ,CAAE,IAAA,CAAQ,6BAA8B,CAAA,CAChD,UAAc,CAAA,CAAE,IAAQ,CAAA,mCAAoC,CAC5D,CAAA,KAAA,CAAS,CAAE,IAAA,CAAQ,8BAA+B,CAAA,CAClD,OAAW,CAAA,CAAE,IAAQ,CAAA,gCAAiC,CAC1D,CAAA,CACA,QAAY,CAAA,CAAC,WAAa,CAAA,UAAA,CAAY,OAAS,CAAA,OAAA,CAAS,cAAgB,CAAA,YAAA,CAAc,OAAS,CAAA,SAAS,CAC5G,CACJ,CACF,CAAA,CCzMMC,IAAAA,CAAAA,CAAS,CACb,2BAAA,EAA8B,CAC5B,OAAOP,CACT,CACF,EAEOQ,CAAQD,CAAAA","file":"index.mjs","sourcesContent":["import { GenderCategory, OperationalCountry, OperationalCountryCurrency, OperationalLanguage, OperationalLocale } from \"../Classes/Enum\";\r\nimport ProductModel from \"../Classes/Product\";\r\n\r\nexport default {\r\n \"$id\": \"standards\",\r\n \"definitions\": {\r\n \"lowercaseText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]*$\"\r\n },\r\n \"lowercaseText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,10}$\"\r\n },\r\n \"lowercaseText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,16}$\"\r\n },\r\n \"lowercaseText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,30}$\"\r\n },\r\n \"lowercaseText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,50}$\"\r\n },\r\n \"lowercaseText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,256}$\"\r\n },\r\n \"text\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).*$\"\r\n },\r\n \"text10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,10}$\"\r\n },\r\n \"text16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,16}$\"\r\n },\r\n \"text30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,30}$\"\r\n },\r\n \"text50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,50}$\"\r\n },\r\n \"text256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,256}$\"\r\n },\r\n \"requiredText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).+$\"\r\n },\r\n \"requiredText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,10}$\"\r\n },\r\n \"requiredText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,16}$\"\r\n },\r\n \"requiredText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,30}$\"\r\n },\r\n \"requiredText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,50}$\"\r\n },\r\n \"requiredText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,256}$\"\r\n },\r\n \"url\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^https://[^\\\\s/$.?#].[^\\\\s]*$\",\r\n \"maxLength\": 2048\r\n },\r\n \"uuid\": {\r\n \"type\": \"string\",\r\n \"minLength\": 1,\r\n \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"\r\n },\r\n \"productKey\": {\r\n \"type\": \"string\",\r\n \"pattern\": ProductModel.productKeyRegex.source\r\n },\r\n \"productSku\": {\r\n \"type\": \"string\",\r\n \"pattern\": ProductModel.productSKURegex.source\r\n },\r\n \"genderCategory\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(GenderCategory)\r\n },\r\n \"price\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"amount\": { \"type\": \"number\", \"minimum\": 0 },\r\n \"currency\": { \"$ref\": \"#/definitions/currency\" }\r\n },\r\n \"additionalProperties\": false,\r\n \"required\": [\"amount\", \"currency\"]\r\n },\r\n \"color\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"name\": {\r\n \"type\": \"string\"\r\n },\r\n \"hex\": {\r\n \"type\": \"string\"\r\n }\r\n },\r\n \"additionalProperties\": false,\r\n \"required\": [\r\n \"name\"\r\n ]\r\n },\r\n \"attributeValue\": {\r\n \"oneOf\": [\r\n { \"type\": \"string\" },\r\n {\r\n \"$ref\": \"#/definitions/color\"\r\n }\r\n ]\r\n },\r\n \"selectionAttributes\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"color\": { \"$ref\": \"#/definitions/color\" }\r\n },\r\n \"required\": [\"color\"],\r\n \"additionalProperties\": {\r\n \"$ref\": \"#/definitions/attributeValue\"\r\n }\r\n },\r\n \"firstName\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"lastName\": { \"$ref\": \"#/definitions/text30\" },\r\n \"company\": { \"$ref\": \"#/definitions/text50\" },\r\n \"phone\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[0-9]{10}$\"\r\n },\r\n \"email\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[^\\\\s]+@[^\\\\s]+\\\\.[^\\\\s]+$\"\r\n },\r\n \"addressLine1\": { \"$ref\": \"#/definitions/requiredText50\" },\r\n \"addressLine2\": { \"$ref\": \"#/definitions/text50\" },\r\n \"city\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"postalCode\": { \"$ref\": \"#/definitions/requiredText16\" },\r\n \"state\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"AP\", \"AR\", \"AS\", \"BR\", \"CT\", \"GA\", \"GJ\", \"HR\", \"HP\", \"JH\", \"KA\", \"KL\", \"MP\", \"MH\", \"MN\", \"ML\", \"MZ\", \"NL\", \"OR\", \"PB\", \"RJ\", \"SK\", \"TN\", \"TG\", \"TR\", \"UP\", \"UT\", \"WB\", \"AN\", \"CH\", \"DH\", \"LD\", \"DL\", \"PY\", \"LA\", \"JK\"]\r\n },\r\n \"country\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalCountry)\r\n },\r\n \"currency\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalCountryCurrency)\r\n },\r\n \"locale\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalLocale)\r\n },\r\n \"language\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalLanguage)\r\n },\r\n \"localeOrLanguage\": {\r\n \"type\": \"string\",\r\n \"enum\": [...Object.values(OperationalLocale), ...Object.values(OperationalLanguage)]\r\n },\r\n \"addressType\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"shipping\", \"billing\", \"billing&shipping\"]\r\n },\r\n \"address\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"firstName\": {\"$ref\": \"standards#/definitions/firstName\"},\r\n \"lastName\": { \"$ref\": \"standards#/definitions/lastName\" },\r\n \"company\": { \"$ref\": \"standards#/definitions/company\" },\r\n \"phone\": { \"$ref\": \"standards#/definitions/phone\" },\r\n \"email\": { \"$ref\": \"standards#/definitions/email\" },\r\n \"addressLine1\": { \"$ref\": \"standards#/definitions/addressLine1\" },\r\n \"addressLine2\": { \"$ref\": \"standards#/definitions/addressLine2\" },\r\n \"city\": { \"$ref\": \"standards#/definitions/city\" },\r\n \"postalCode\": { \"$ref\": \"standards#/definitions/postalCode\" },\r\n \"state\": { \"$ref\": \"standards#/definitions/state\" },\r\n \"country\": { \"$ref\": \"standards#/definitions/country\" }\r\n },\r\n \"required\": [\"firstName\", \"lastName\", \"phone\", \"email\", \"addressLine1\", \"postalCode\", \"state\", \"country\"]\r\n }\r\n }\r\n}","import SchemaDefinitions from './definition';\r\n\r\nconst Schema = {\r\n getStandardSchemaDefinition() {\r\n return SchemaDefinitions;\r\n }\r\n}\r\n\r\nexport default Schema;\r\n"]}
1
+ {"version":3,"sources":["../src/Schema/definition.ts","../src/Schema/index.ts"],"names":["definition_default","ProductModel","GenderCategory","OperationalCountry","OperationalCountryCurrency","OperationalLocale","OperationalLanguage","Schema","Schema_default"],"mappings":"4WAGA,IAAOA,CAAQ,CAAA,CACb,GAAO,CAAA,WAAA,CACP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,IAAQ,CAAA,gCAAiC,CAC1D,CAAA,CACA,QAAY,CAAA,CAAC,WAAa,CAAA,UAAA,CAAY,OAAS,CAAA,OAAA,CAAS,cAAgB,CAAA,YAAA,CAAc,OAAS,CAAA,SAAS,CAC5G,CACJ,CACF,CAAA,CCzMMC,IAAAA,CAAAA,CAAS,CACb,2BAAA,EAA8B,CAC5B,OAAOP,CACT,CACF,EAEOQ,CAAQD,CAAAA","file":"index.mjs","sourcesContent":["import { GenderCategory, OperationalCountry, OperationalCountryCurrency, OperationalLanguage, OperationalLocale } from \"../Classes/Enum\";\r\nimport ProductModel from \"../Classes/Product\";\r\n\r\nexport default {\r\n \"$id\": \"standards\",\r\n \"definitions\": {\r\n \"lowercaseText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]*$\"\r\n },\r\n \"lowercaseText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,10}$\"\r\n },\r\n \"lowercaseText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,16}$\"\r\n },\r\n \"lowercaseText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,30}$\"\r\n },\r\n \"lowercaseText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,50}$\"\r\n },\r\n \"lowercaseText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,256}$\"\r\n },\r\n \"text\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).*$\"\r\n },\r\n \"text10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,10}$\"\r\n },\r\n \"text16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,16}$\"\r\n },\r\n \"text30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,30}$\"\r\n },\r\n \"text50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,50}$\"\r\n },\r\n \"text256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,256}$\"\r\n },\r\n \"requiredText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).+$\"\r\n },\r\n \"requiredText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,10}$\"\r\n },\r\n \"requiredText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,16}$\"\r\n },\r\n \"requiredText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,30}$\"\r\n },\r\n \"requiredText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,50}$\"\r\n },\r\n \"requiredText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,256}$\"\r\n },\r\n \"url\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^https://[^\\\\s/$.?#].[^\\\\s]*$\",\r\n \"maxLength\": 2048\r\n },\r\n \"uuid\": {\r\n \"type\": \"string\",\r\n \"minLength\": 1,\r\n \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"\r\n },\r\n \"productKey\": {\r\n \"type\": \"string\",\r\n \"pattern\": ProductModel.productKeyRegex.source\r\n },\r\n \"productSku\": {\r\n \"type\": \"string\",\r\n \"pattern\": ProductModel.productSKURegex.source\r\n },\r\n \"genderCategory\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(GenderCategory)\r\n },\r\n \"price\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"amount\": { \"type\": \"number\", \"minimum\": 0 },\r\n \"currency\": { \"$ref\": \"#/definitions/currency\" }\r\n },\r\n \"additionalProperties\": false,\r\n \"required\": [\"amount\", \"currency\"]\r\n },\r\n \"color\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"name\": {\r\n \"type\": \"string\"\r\n },\r\n \"hex\": {\r\n \"type\": \"string\"\r\n }\r\n },\r\n \"additionalProperties\": false,\r\n \"required\": [\r\n \"name\"\r\n ]\r\n },\r\n \"attributeValue\": {\r\n \"oneOf\": [\r\n { \"type\": \"string\" },\r\n {\r\n \"$ref\": \"#/definitions/color\"\r\n }\r\n ]\r\n },\r\n \"selectionAttributes\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"color\": { \"$ref\": \"#/definitions/color\" }\r\n },\r\n \"required\": [\"color\"],\r\n \"additionalProperties\": {\r\n \"$ref\": \"#/definitions/attributeValue\"\r\n }\r\n },\r\n \"firstName\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"lastName\": { \"$ref\": \"#/definitions/text30\" },\r\n \"company\": { \"$ref\": \"#/definitions/text50\" },\r\n \"phone\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[0-9]{10}$\"\r\n },\r\n \"email\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[^\\\\s]+@[^\\\\s]+\\\\.[^\\\\s]+$\"\r\n },\r\n \"addressLine1\": { \"$ref\": \"#/definitions/requiredText50\" },\r\n \"addressLine2\": { \"$ref\": \"#/definitions/text50\" },\r\n \"city\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"postalCode\": { \"$ref\": \"#/definitions/requiredText16\" },\r\n \"state\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"AP\", \"AR\", \"AS\", \"BR\", \"CT\", \"GA\", \"GJ\", \"HR\", \"HP\", \"JH\", \"KA\", \"KL\", \"MP\", \"MH\", \"MN\", \"ML\", \"MZ\", \"NL\", \"OR\", \"PB\", \"RJ\", \"SK\", \"TN\", \"TG\", \"TR\", \"UP\", \"UT\", \"WB\", \"AN\", \"CH\", \"DH\", \"LD\", \"DL\", \"PY\", \"LA\", \"JK\"]\r\n },\r\n \"country\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalCountry)\r\n },\r\n \"currency\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalCountryCurrency)\r\n },\r\n \"locale\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalLocale)\r\n },\r\n \"language\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalLanguage)\r\n },\r\n \"localeOrLanguage\": {\r\n \"type\": \"string\",\r\n \"enum\": [...Object.values(OperationalLocale), ...Object.values(OperationalLanguage)]\r\n },\r\n \"addressType\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"shipping\", \"billing\", \"billing&shipping\"]\r\n },\r\n \"address\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"firstName\": {\"$ref\": \"standards#/definitions/firstName\"},\r\n \"lastName\": { \"$ref\": \"standards#/definitions/lastName\" },\r\n \"company\": { \"$ref\": \"standards#/definitions/company\" },\r\n \"phone\": { \"$ref\": \"standards#/definitions/phone\" },\r\n \"email\": { \"$ref\": \"standards#/definitions/email\" },\r\n \"addressLine1\": { \"$ref\": \"standards#/definitions/addressLine1\" },\r\n \"addressLine2\": { \"$ref\": \"standards#/definitions/addressLine2\" },\r\n \"city\": { \"$ref\": \"standards#/definitions/city\" },\r\n \"postalCode\": { \"$ref\": \"standards#/definitions/postalCode\" },\r\n \"state\": { \"$ref\": \"standards#/definitions/state\" },\r\n \"country\": { \"$ref\": \"standards#/definitions/country\" }\r\n },\r\n \"required\": [\"firstName\", \"lastName\", \"phone\", \"email\", \"addressLine1\", \"postalCode\", \"state\", \"country\"]\r\n }\r\n }\r\n}","import SchemaDefinitions from './definition';\r\n\r\nconst Schema = {\r\n getStandardSchemaDefinition() {\r\n return SchemaDefinitions;\r\n }\r\n}\r\n\r\nexport default Schema;\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b23-lib",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
4
4
  "description": "This repo hold common classes, type and util functiona",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,2 +0,0 @@
1
- var R=(n=>(n.IN="IN",n))(R||{}),p=(n=>(n.INR="INR",n))(p||{}),r=(I=>(I["en-IN"]="en-IN",I["kn-IN"]="kn-IN",I))(r||{}),D=(N=>(N.en="en",N.kn="kn",N))(D||{}),T={"en-IN":"en","kn-IN":"kn"},x={"en-IN":"IN","kn-IN":"IN"},U={IN:"INR"},M={INR:"\u20B9"},P={INR:"en-IN"},l=(o=>(o.MALE="Male",o.FEMALE="Female",o.UNISEX="Unisex",o.KIDS="Kids",o.BOY="Boy",o.GIRL="Girl",o.GENERAL="General",o))(l||{}),u=(N=>(N.PRIMARY="PRIMARY",N.GALLERY="GALLERY",N))(u||{}),c=(N=>(N.SHIPPING="SHIPPING",N.ADJUSTMENT="ADJUSTMENT",N))(c||{}),a=(n=>(n.GST="GST",n))(a||{}),L=(E=>(E.INITIAL="INITIAL",E.PROCESSING="PROCESSING",E.SHIPPED="SHIPPED",E.DELIVERED="DELIVERED",E.CANCELLED="CANCELLED",E.RETURN_REQUESTED="RETURN_REQUESTED",E.RETURNED="RETURNED",E.REFUND_INITIATED="REFUND_INITIATED",E.REFUNDED="REFUNDED",E.ON_HOLD="ON_HOLD",E))(L||{});export{R as a,p as b,r as c,D as d,T as e,x as f,U as g,M as h,P as i,l as j,u as k,c as l,a as m,L as n};//# sourceMappingURL=chunk-FC4P26U3.mjs.map
2
- //# sourceMappingURL=chunk-FC4P26U3.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/Classes/Enum.ts"],"names":["OperationalCountry","OperationalCountryCurrency","OperationalLocale","OperationalLanguage","LocaleLanguageMap","LocaleCountryMap","CountryCurrencyMap","CurrencySymbolMap","CurrencyLocaleMap","GenderCategory","ImageCategory","ChargeType","TaxSystem","LineItemState"],"mappings":"AAGO,IAAKA,CACGA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,EAAK,CAAA,IAAA,CADRA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAIAC,CACGA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,GAAM,CAAA,KAAA,CADTA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAIAC,OACGA,CAAA,CAAA,OAAA,CAAA,CAAU,OACCA,CAAAA,CAAAA,CAAA,OAAU,CAAA,CAAA,OAAA,CAFxBA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,OACVA,CAAA,CAAA,EAAA,CAAK,IACLA,CAAAA,CAAAA,CAAA,EAAK,CAAA,IAAA,CAFKA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKCC,EAAoE,CAC9E,OAAA,CAA6B,IAC7B,CAAA,OAAA,CAA6B,IAChC,CAAA,CAEaC,CAAkE,CAAA,CAC5E,QAA6B,IAC7B,CAAA,OAAA,CAA6B,IAChC,CAAA,CAKaC,CAAqB,CAAA,CACnB,EAAwB,CAAA,KACvC,EAEaC,CAAoB,CAAA,CAC9B,GAAiC,CAAA,QACpC,CAEaC,CAAAA,CAAAA,CAAoB,CAC9B,GAAA,CAAiC,OACpC,CAKYC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAA,CAAA,IAAA,CAAO,MACPA,CAAAA,CAAAA,CAAA,MAAS,CAAA,QAAA,CACTA,EAAA,MAAS,CAAA,QAAA,CACTA,CAAA,CAAA,IAAA,CAAO,MACPA,CAAAA,CAAAA,CAAA,GAAM,CAAA,KAAA,CACNA,CAAA,CAAA,IAAA,CAAO,MACPA,CAAAA,CAAAA,CAAA,OAAU,CAAA,SAAA,CAPAA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAUAC,OACVA,CAAA,CAAA,OAAA,CAAU,SACVA,CAAAA,CAAAA,CAAA,OAAU,CAAA,SAAA,CAFAA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,OACVA,CAAA,CAAA,QAAA,CAAW,UACXA,CAAAA,CAAAA,CAAA,UAAa,CAAA,YAAA,CAFHA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,OACVA,CAAA,CAAA,GAAA,CAAM,KADIA,CAAAA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAkBAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAA,CAAA,OAAA,CAAU,UACVA,CAAA,CAAA,UAAA,CAAa,YACbA,CAAAA,CAAAA,CAAA,OAAU,CAAA,SAAA,CACVA,CAAA,CAAA,SAAA,CAAY,YACZA,CAAA,CAAA,SAAA,CAAY,WACZA,CAAAA,CAAAA,CAAA,gBAAmB,CAAA,kBAAA,CACnBA,CAAA,CAAA,QAAA,CAAW,WACXA,CAAA,CAAA,gBAAA,CAAmB,kBACnBA,CAAAA,CAAAA,CAAA,QAAW,CAAA,UAAA,CACXA,CAAA,CAAA,OAAA,CAAU,UAVAA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA","file":"chunk-FC4P26U3.mjs","sourcesContent":["/**\r\n * Represents the countries where the application operates or products are available.\r\n */\r\nexport enum OperationalCountry {\r\n /** India */ IN = 'IN',\r\n}\r\n\r\nexport enum OperationalCountryCurrency {\r\n /** India */ INR = 'INR',\r\n}\r\n\r\nexport enum OperationalLocale {\r\n /** India */ 'en-IN' = 'en-IN',\r\n /** India ( Kannada) */ 'kn-IN' = 'kn-IN'\r\n}\r\n\r\nexport enum OperationalLanguage {\r\n en = 'en',\r\n kn = 'kn'\r\n}\r\n\r\nexport const LocaleLanguageMap: Record<OperationalLocale, OperationalLanguage> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalLanguage.en,\r\n [OperationalLocale[\"kn-IN\"]]: OperationalLanguage.kn,\r\n}\r\n\r\nexport const LocaleCountryMap: Record<OperationalLocale, OperationalCountry> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalCountry.IN,\r\n [OperationalLocale[\"kn-IN\"]]: OperationalCountry.IN,\r\n}\r\n\r\n/**\r\n * Defines the supported ISO 4217 currency codes as an enumeration.\r\n */\r\nexport const CountryCurrencyMap = {\r\n /** India */[OperationalCountry.IN]: OperationalCountryCurrency.INR,\r\n};\r\n\r\nexport const CurrencySymbolMap = {\r\n [OperationalCountryCurrency.INR]: '₹',\r\n}\r\n\r\nexport const CurrencyLocaleMap = {\r\n [OperationalCountryCurrency.INR]: OperationalLocale[\"en-IN\"],\r\n}\r\n\r\n/**\r\n * Defines standard gender categories for product targeting.\r\n */\r\nexport enum GenderCategory {\r\n MALE = 'Male',\r\n FEMALE = 'Female',\r\n UNISEX = 'Unisex',\r\n KIDS = 'Kids',\r\n BOY = 'Boy',\r\n GIRL = 'Girl',\r\n GENERAL = 'General',\r\n}\r\n\r\nexport enum ImageCategory {\r\n PRIMARY = 'PRIMARY',\r\n GALLERY = 'GALLERY'\r\n}\r\n\r\nexport enum ChargeType {\r\n SHIPPING = 'SHIPPING',\r\n ADJUSTMENT = 'ADJUSTMENT'\r\n}\r\n\r\nexport enum TaxSystem {\r\n GST = 'GST',\r\n}\r\n\r\n/**\r\n * LineItemState\r\n * \r\n * INITIAL: Item added to order, not yet processed.\r\n * PROCESSING: Item is being prepared for shipment.\r\n * SHIPPED: Item dispatched to customer.\r\n * DELIVERED: Item delivered to customer.\r\n * CANCELLED: Item cancelled before shipment or delivery.\r\n * RETURN_REQUESTED: Customer requests to return item.\r\n * RETURNED: Item received back from customer.\r\n * REFUND_INITIATED: Refund initiated for item.\r\n * REFUNDED: Refund processed for item.\r\n * ON_HOLD: Item is paused due to payment, inventory, or other issues.\r\n */\r\nexport enum LineItemState {\r\n INITIAL = \"INITIAL\",\r\n PROCESSING = \"PROCESSING\",\r\n SHIPPED = \"SHIPPED\",\r\n DELIVERED = \"DELIVERED\",\r\n CANCELLED = \"CANCELLED\",\r\n RETURN_REQUESTED = \"RETURN_REQUESTED\",\r\n RETURNED = \"RETURNED\",\r\n REFUND_INITIATED = \"REFUND_INITIATED\",\r\n REFUNDED = \"REFUNDED\",\r\n ON_HOLD = \"ON_HOLD\",\r\n}"]}
@@ -1,2 +0,0 @@
1
- import {c}from'./chunk-L3CNGDFJ.mjs';import {b,a as a$1}from'./chunk-HKXV6QWV.mjs';import {a}from'./chunk-XHGUVYQO.mjs';import {e}from'./chunk-FC4P26U3.mjs';import {j}from'./chunk-XPKK6DFA.mjs';var m=class extends b{id;name;category;lineItemId;chargeType;pricing;total;constructor(t){super(t),this.id=t.id,this.name=t.name,this.category=t.category,this.lineItemId=t.lineItemId,this.chargeType=t.chargeType,this.pricing={price:new a(t.pricing.price),taxCategory:t.pricing.taxCategory,applicableTaxRule:t.pricing.applicableTaxRule.map(e=>new c(e))},this.total={price:new a(t.total.price),discounts:Object.fromEntries(Object.entries(t.total.discounts).map(([e,a$1])=>[e,new a(a$1)])),totalDiscount:new a(t.total.totalDiscount),netPrice:new a(t.total.netPrice),taxBreakdown:Object.fromEntries(Object.entries(t.total.taxBreakdown).map(([e,a$1])=>[e,{rate:a$1.rate,taxablePrice:new a(a$1.taxablePrice),amount:new a(a$1.amount),system:a$1.system,subSystem:a$1.subSystem}])),taxTotal:new a(t.total.taxTotal),grandTotal:new a(t.total.grandTotal)};}getId(){return this.id}getName(t){return t?a$1.deepClone(this.name[t]??this.name[e[t]]??this.name.en):a$1.deepClone(this.name)}getCategory(){return this.category}getChargeType(){return this.chargeType}getLineItemId(){return this.lineItemId}getPricing(){return {price:this.pricing.price,taxCategory:this.pricing.taxCategory,applicableTaxRule:[...this.pricing.applicableTaxRule]}}getTotal(){return {price:this.total.price,discounts:{...this.total.discounts},netPrice:this.total.netPrice,totalDiscount:this.total.totalDiscount,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{rate:e.rate,taxablePrice:e.taxablePrice,amount:e.amount,system:e.system,subSystem:e.subSystem}])),taxTotal:this.total.taxTotal,grandTotal:this.total.grandTotal}}getApplicableTaxRules(){return [...this.pricing.applicableTaxRule]}updateTax(t){t.forEach(e=>{if(!e.appliesTo(this.pricing.taxCategory,e.getTaxCountry()))throw new j}),this.pricing.applicableTaxRule=t,this.calculateTotals();}updateDiscounts(t){let e={};t.forEach(a=>{e[a.coupon.getCode()]=a.amount;}),this.total.discounts=e,this.calculateTotals();}calculateTotals(){let t=this.pricing.price.zero(),e=this.pricing.price,a=Object.values(this.total.discounts).reduce((i,o)=>i.add(o),t),p=e.subtract(a),g={},s=this.pricing.applicableTaxRule.reduce((i,o)=>i+o.getApplicableTaxRate(),0),l=p.divide(1+s).round(),u=s>0?p.subtract(l):t,d=t,c=this.pricing.applicableTaxRule.reduce((i,o)=>o.getApplicableTaxRate()>i.getApplicableTaxRate()?o:i),x=c.getTaxRuleId();this.pricing.applicableTaxRule.forEach(i=>{if(i.getTaxRuleId()===x)return;let o=i.getApplicableTaxRate(),h=s>0?u.multiply(o).divide(s).round():t;g[i.getTaxRuleId()]={rate:o,taxablePrice:l,amount:h,system:i.getTaxSystem(),subSystem:i.getTaxSubSystem()},d=d.add(h);});let P=u.subtract(d);g[x]={rate:c.getApplicableTaxRate(),taxablePrice:l,amount:P,system:c.getTaxSystem(),subSystem:c.getTaxSubSystem()};let D=l,R=p;this.total={price:e,discounts:this.total.discounts,netPrice:D,totalDiscount:a,taxBreakdown:g,taxTotal:u,grandTotal:R};}getDetails(){return {id:this.id,name:a$1.deepClone(this.name),category:this.category,lineItemId:this.lineItemId,chargeType:this.chargeType,pricing:{price:this.pricing.price.getDetails(),taxCategory:this.pricing.taxCategory,applicableTaxRule:this.pricing.applicableTaxRule.map(e=>e.getDetails())},total:{price:this.total.price.getDetails(),discounts:Object.fromEntries(Object.entries(this.total.discounts).map(([e,a])=>[e,a.getDetails()])),totalDiscount:this.total.totalDiscount.getDetails(),netPrice:this.total.netPrice.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([e,a])=>[e,{rate:a.rate,taxablePrice:a.taxablePrice.getDetails(),amount:a.amount.getDetails(),system:a.system,subSystem:a.subSystem}])),taxTotal:this.total.taxTotal.getDetails(),grandTotal:this.total.grandTotal.getDetails()},customFields:this.getAllCustomFields()}}};export{m as a};//# sourceMappingURL=chunk-GJ2DSRIP.mjs.map
2
- //# sourceMappingURL=chunk-GJ2DSRIP.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/Classes/Charge.ts"],"names":["ChargeModel","CustomFieldModel","data","PriceModel","r","FixedTaxRuleModel","discountId","discount","taxRuleId","taxBreakdown","locale","Utils_default","LocaleLanguageMap","key","value","taxRules","taxRule","InvalidTaxRuleError","appliedDiscounts","chargeDiscounts","zero","price","totalDiscount","sum","s","grossAmount","totalRate","taxableBase","totalTaxAmount","distributedTax","maxRateRule","prev","current","maxRateRuleId","rate","taxAmount","maxRateTaxAmount","netPrice","grandTotal","k","v"],"mappings":"kMAqEA,IAAqBA,EAArB,cAAyCC,CAAiB,CAC5C,EACA,CAAA,IAAA,CACA,SACA,UACA,CAAA,UAAA,CACA,OAKA,CAAA,KAAA,CAEV,YAAYC,CAAwB,CAAA,CAChC,MAAMA,CAAI,CAAA,CACV,KAAK,EAAKA,CAAAA,CAAAA,CAAK,EACf,CAAA,IAAA,CAAK,KAAOA,CAAK,CAAA,IAAA,CACjB,KAAK,QAAWA,CAAAA,CAAAA,CAAK,SACrB,IAAK,CAAA,UAAA,CAAaA,EAAK,UACvB,CAAA,IAAA,CAAK,WAAaA,CAAK,CAAA,UAAA,CACvB,KAAK,OAAU,CAAA,CACX,MAA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A,MAAA,CAAO,YACjB,CAAA,MAAA,CAAQA,EAAE,MACV,CAAA,SAAA,CAAWA,EAAE,SACjB,CAAC,CAAC,CAAC,EACH,QAAU,CAAA,IAAA,CAAK,MAAM,QAAS,CAAA,UAAA,GAC9B,UAAY,CAAA,IAAA,CAAK,MAAM,UAAW,CAAA,UAAA,EACtC,CACA,CAAA,YAAA,CAAc,KAAK,kBAAmB,EAC1C,CAEJ,CACJ","file":"chunk-GJ2DSRIP.mjs","sourcesContent":["import BaseModel, { BaseAttributes, BaseData, CustomFieldAttributes, CustomFieldModel } from \"./Base\";\r\nimport Utils from \"../Utils\";\r\nimport { LocaleCode, LocalizedString } from \"./Common\";\r\nimport { ChargeType, LocaleLanguageMap, TaxSystem } from \"./Enum\";\r\nimport { InvalidTaxRuleError } from \"./Error\";\r\nimport PriceModel, { PriceData } from \"./Price\";\r\nimport { FixedTaxRuleData, FixedTaxRuleModel, TaxRuleData, TaxRuleModel } from \"./TaxRule\";\r\nimport CouponModel from \"./Coupon\";\r\n\r\nexport type ChargePricing = {\r\n price: PriceData;\r\n taxCategory: string;\r\n applicableTaxRule: FixedTaxRuleData[];\r\n};\r\n\r\nexport type ChargeTaxBreakdown = {\r\n rate: number;\r\n taxablePrice: PriceData;\r\n amount: PriceData;\r\n system: TaxSystem;\r\n subSystem: string;\r\n};\r\n\r\nexport type ChargeTaxBreakdownModel = {\r\n rate: number;\r\n taxablePrice: PriceModel;\r\n amount: PriceModel;\r\n system: TaxSystem;\r\n subSystem: string;\r\n};\r\n\r\nexport type ChargeTotals = {\r\n price: PriceData;\r\n discounts: Record<string, PriceData>;\r\n totalDiscount: PriceData;\r\n netPrice: PriceData;\r\n taxBreakdown: Record<string, ChargeTaxBreakdown>;\r\n taxTotal: PriceData;\r\n grandTotal: PriceData;\r\n};\r\n\r\nexport type ChargeTotalsModel = {\r\n price: PriceModel;\r\n discounts: Record<string, PriceModel>;\r\n totalDiscount: PriceModel;\r\n netPrice: PriceModel;\r\n taxBreakdown: Record<string, ChargeTaxBreakdownModel>;\r\n taxTotal: PriceModel;\r\n grandTotal: PriceModel;\r\n};\r\n\r\nexport type ChargeAttributes = CustomFieldAttributes & {\r\n id: string;\r\n name: LocalizedString;\r\n category: string;\r\n lineItemId?: string;\r\n chargeType: ChargeType;\r\n pricing: ChargePricing;\r\n total: ChargeTotals;\r\n};\r\n\r\nexport type ChargeData = Omit<Required<ChargeAttributes>, 'lineItemId'> & {\r\n lineItemId?: string;\r\n};\r\n\r\n/**\r\n * Represents an additional charge (or discount if amount is negative) in a shopping container.\r\n * Supports its own tax rules.\r\n */\r\nexport default class ChargeModel extends CustomFieldModel {\r\n protected id: string;\r\n protected name: LocalizedString;\r\n protected category: string;\r\n protected lineItemId?: string;\r\n protected chargeType: ChargeType;\r\n protected pricing: {\r\n price: PriceModel;\r\n taxCategory: string;\r\n applicableTaxRule: FixedTaxRuleModel[];\r\n };\r\n protected total: ChargeTotalsModel;\r\n\r\n constructor(data: ChargeAttributes) {\r\n super(data);\r\n this.id = data.id;\r\n this.name = data.name;\r\n this.category = data.category;\r\n this.lineItemId = data.lineItemId;\r\n this.chargeType = data.chargeType;\r\n this.pricing = {\r\n price: new PriceModel(data.pricing.price),\r\n taxCategory: data.pricing.taxCategory,\r\n applicableTaxRule: data.pricing.applicableTaxRule.map(r => new FixedTaxRuleModel(r))\r\n };\r\n\r\n this.total = {\r\n price: new PriceModel(data.total.price),\r\n discounts: Object.fromEntries(\r\n Object.entries(data.total.discounts).map(([discountId, discount]) => [\r\n discountId,\r\n new PriceModel(discount)\r\n ])\r\n ),\r\n totalDiscount: new PriceModel(data.total.totalDiscount),\r\n netPrice: new PriceModel(data.total.netPrice),\r\n taxBreakdown: Object.fromEntries(\r\n Object.entries(data.total.taxBreakdown).map(([taxRuleId, taxBreakdown]) => [\r\n taxRuleId,\r\n {\r\n rate: taxBreakdown.rate,\r\n taxablePrice: new PriceModel(taxBreakdown.taxablePrice),\r\n amount: new PriceModel(taxBreakdown.amount),\r\n system: taxBreakdown.system,\r\n subSystem: taxBreakdown.subSystem\r\n }\r\n ])\r\n ),\r\n taxTotal: new PriceModel(data.total.taxTotal),\r\n grandTotal: new PriceModel(data.total.grandTotal),\r\n };\r\n }\r\n\r\n public getId(): string { return this.id; }\r\n\r\n\r\n /**\r\n * Gets the full localized product name object.\r\n * @returns A copy of the LocalizedString object for the name.\r\n */\r\n getName(): LocalizedString\r\n /**\r\n * Gets the product name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return Utils.deepClone(this.name[locale] ?? this.name[LocaleLanguageMap[locale]] ?? this.name.en);\r\n } else {\r\n return Utils.deepClone(this.name);\r\n }\r\n }\r\n public getCategory(): string { return this.category; }\r\n public getChargeType(): ChargeType { return this.chargeType; }\r\n public getLineItemId(): string | undefined { return this.lineItemId; }\r\n public getPricing() {\n return {\n price: this.pricing.price,\n taxCategory: this.pricing.taxCategory,\n applicableTaxRule: [...this.pricing.applicableTaxRule]\n };\n }\n \r\n public getTotal(): ChargeTotalsModel {\n return {\n price: this.total.price,\n discounts: { ...this.total.discounts },\n netPrice: this.total.netPrice,\n totalDiscount: this.total.totalDiscount,\n taxBreakdown: Object.fromEntries(\n Object.entries(this.total.taxBreakdown).map(([key, value]) => [\n key,\n {\n rate: value.rate,\n taxablePrice: value.taxablePrice,\n amount: value.amount,\n system: value.system,\n subSystem: value.subSystem\n }\n ])\n ),\n taxTotal: this.total.taxTotal,\n grandTotal: this.total.grandTotal,\n };\n }\n\r\n public getApplicableTaxRules(): FixedTaxRuleModel[] {\n return [...this.pricing.applicableTaxRule];\n }\n\r\n /**\r\n * Updates the tax rule for this line item and recalculates totals.\r\n * @param taxRule - The new tax rule to apply.\r\n * @throws {Error} If the tax rule category does not match the item's tax category.\r\n */\r\n public updateTax(taxRules: FixedTaxRuleModel[]): void {\r\n taxRules.forEach(taxRule => {\r\n if (!taxRule.appliesTo(this.pricing.taxCategory, taxRule.getTaxCountry())) {\r\n throw new InvalidTaxRuleError();\r\n }\r\n });\r\n\r\n // Remove the old taxableUnitPrice calculation - no longer needed\r\n this.pricing.applicableTaxRule = taxRules;\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Updates the discounts applied to this line item and recalculates totals.\r\n * @param appliedDiscounts - List of coupons and their allocated discount amounts.\r\n */\r\n public updateDiscounts(appliedDiscounts: { coupon: CouponModel, amount: PriceModel }[]): void {\r\n let chargeDiscounts = {} as Record<string, PriceModel>;\r\n appliedDiscounts.forEach(discount => {\r\n chargeDiscounts[discount.coupon.getCode()] = discount.amount;\r\n });\r\n\r\n this.total.discounts = chargeDiscounts;\r\n this.calculateTotals();\r\n }\r\n\r\n public calculateTotals(): void {\r\n const zero = this.pricing.price.zero();\r\n const price = this.pricing.price;\r\n\r\n const totalDiscount = Object.values(this.total.discounts).reduce((sum, s) => sum.add(s), zero);\r\n const grossAmount = price.subtract(totalDiscount);\r\n\r\n const taxBreakdown: Record<string, ChargeTaxBreakdownModel> = {};\r\n\r\n // 1. Calculate total rate for inclusive back-calculation\r\n const totalRate = this.pricing.applicableTaxRule.reduce((sum, r) => sum + r.getApplicableTaxRate(), 0);\r\n\r\n // 2. Calculate BASE and TOTAL TAX using balancing logic\r\n // We round the base first, then define tax as the residual (Gross - Base)\r\n // This guarantees Base + Tax === GrandTotal (inclusive price)\r\n const taxableBase = grossAmount.divide(1 + totalRate).round();\r\n const totalTaxAmount = totalRate > 0 ? grossAmount.subtract(taxableBase) : zero;\r\n\r\n // 3. Distribute total tax among rules\r\n // We find the rule with the largest rate to absorb the rounding residual\r\n let distributedTax = zero;\r\n const maxRateRule = this.pricing.applicableTaxRule.reduce((prev, current) =>\r\n (current.getApplicableTaxRate() > prev.getApplicableTaxRate()) ? current : prev\r\n );\r\n const maxRateRuleId = maxRateRule.getTaxRuleId();\r\n\r\n // Calculate all other rules first\r\n this.pricing.applicableTaxRule.forEach((taxRule) => {\r\n if (taxRule.getTaxRuleId() === maxRateRuleId) return;\r\n\r\n const rate = taxRule.getApplicableTaxRate();\r\n const taxAmount = totalRate > 0 ? totalTaxAmount.multiply(rate).divide(totalRate).round() : zero;\r\n\r\n taxBreakdown[taxRule.getTaxRuleId()] = {\r\n rate: rate,\r\n taxablePrice: taxableBase,\r\n amount: taxAmount,\r\n system: taxRule.getTaxSystem(),\r\n subSystem: taxRule.getTaxSubSystem()\r\n };\r\n distributedTax = distributedTax.add(taxAmount);\r\n });\r\n\r\n // Assign residual to the largest rate rule\r\n const maxRateTaxAmount = totalTaxAmount.subtract(distributedTax);\r\n taxBreakdown[maxRateRuleId] = {\r\n rate: maxRateRule.getApplicableTaxRate(),\r\n taxablePrice: taxableBase,\r\n amount: maxRateTaxAmount,\r\n system: maxRateRule.getTaxSystem(),\r\n subSystem: maxRateRule.getTaxSubSystem()\r\n };\r\n\r\n const netPrice = taxableBase;\r\n const grandTotal = grossAmount;\r\n\r\n this.total = {\r\n price: price,\r\n discounts: this.total.discounts,\r\n netPrice: netPrice,\r\n totalDiscount: totalDiscount,\r\n taxBreakdown: taxBreakdown,\r\n taxTotal: totalTaxAmount,\r\n grandTotal: grandTotal\r\n };\r\n }\r\n\r\n public getDetails(): ChargeData {\r\n const details: ChargeData = {\r\n id: this.id,\r\n name: Utils.deepClone(this.name),\r\n category: this.category,\r\n lineItemId: this.lineItemId,\r\n chargeType: this.chargeType,\r\n pricing: {\r\n price: this.pricing.price.getDetails(),\r\n taxCategory: this.pricing.taxCategory,\r\n applicableTaxRule: this.pricing.applicableTaxRule.map(r => r.getDetails())\r\n },\r\n total: {\r\n price: this.total.price.getDetails(),\r\n discounts: Object.fromEntries(Object.entries(this.total.discounts).map(([k, v]) => [k, v.getDetails()])),\r\n totalDiscount: this.total.totalDiscount.getDetails(),\r\n netPrice: this.total.netPrice.getDetails(),\r\n taxBreakdown: Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([k, v]) => [k, {\r\n rate: v.rate,\r\n taxablePrice: v.taxablePrice.getDetails(),\r\n amount: v.amount.getDetails(),\r\n system: v.system,\r\n subSystem: v.subSystem\r\n }])),\r\n taxTotal: this.total.taxTotal.getDetails(),\r\n grandTotal: this.total.grandTotal.getDetails()\r\n },\r\n customFields: this.getAllCustomFields()\r\n };\r\n return details;\r\n }\r\n}\r\n"]}
@@ -1,2 +0,0 @@
1
- import {a as a$1}from'./chunk-XBFSNBKL.mjs';import {e}from'./chunk-FC4P26U3.mjs';import {b as b$1}from'./chunk-RSTZJZSQ.mjs';import {g,d}from'./chunk-XPKK6DFA.mjs';import F from'crypto';var A=new Uint8Array(256),h=A.length;function x(){return h>A.length-16&&(F.randomFillSync(A),h=0),A.slice(h,h+=16)}var U=/^(?:[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 K(t){return typeof t=="string"&&U.test(t)}var z=K;var a=[];for(let t=0;t<256;++t)a.push((t+256).toString(16).slice(1));function b(t,e=0){return a[t[e+0]]+a[t[e+1]]+a[t[e+2]]+a[t[e+3]]+"-"+a[t[e+4]]+a[t[e+5]]+"-"+a[t[e+6]]+a[t[e+7]]+"-"+a[t[e+8]]+a[t[e+9]]+"-"+a[t[e+10]]+a[t[e+11]]+a[t[e+12]]+a[t[e+13]]+a[t[e+14]]+a[t[e+15]]}function V(t){if(!z(t))throw TypeError("Invalid UUID");let e,i=new Uint8Array(16);return i[0]=(e=parseInt(t.slice(0,8),16))>>>24,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=e&255,i[4]=(e=parseInt(t.slice(9,13),16))>>>8,i[5]=e&255,i[6]=(e=parseInt(t.slice(14,18),16))>>>8,i[7]=e&255,i[8]=(e=parseInt(t.slice(19,23),16))>>>8,i[9]=e&255,i[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,i[11]=e/4294967296&255,i[12]=e>>>24&255,i[13]=e>>>16&255,i[14]=e>>>8&255,i[15]=e&255,i}var B=V;function k(t){t=unescape(encodeURIComponent(t));let e=[];for(let i=0;i<t.length;++i)e.push(t.charCodeAt(i));return e}var $="6ba7b810-9dad-11d1-80b4-00c04fd430c8",G="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function D(t,e,i){function r(s,o,g,S){var C;if(typeof s=="string"&&(s=k(s)),typeof o=="string"&&(o=B(o)),((C=o)===null||C===void 0?void 0:C.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let d=new Uint8Array(16+s.length);if(d.set(o),d.set(s,o.length),d=i(d),d[6]=d[6]&15|e,d[8]=d[8]&63|128,g){S=S||0;for(let y=0;y<16;++y)g[S+y]=d[y];return g}return b(d)}try{r.name=t;}catch{}return r.DNS=$,r.URL=G,r}var T={randomUUID:F.randomUUID};function O(t,e,i){if(T.randomUUID&&!e&&!t)return T.randomUUID();t=t||{};let r=t.random||(t.rng||x)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){i=i||0;for(let s=0;s<16;++s)e[i+s]=r[s];return e}return b(r)}var L=O;function j(t){return Array.isArray(t)?t=Buffer.from(t):typeof t=="string"&&(t=Buffer.from(t,"utf8")),F.createHash("sha1").update(t).digest()}var R=j;var q=D("v5",80,R),v=q;var m=class t extends f{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(e){if(typeof e!="object")throw new g("Selection attributes must be an object");return Object.keys(e).filter(r=>e[r]!==void 0&&r.toLowerCase()!=="size").sort().map(r=>e[r].name?`${r}:c+${e[r].name}`:`${r}:${e[r]}`).join("|").toLowerCase()}static parseSelectionAttributesKey(e){try{let i={},r=e.split("|");for(let s of r){let[o,g]=s.split(":");g.startsWith("c+")?i[o]={name:g.slice(2)}:i[o]=g;}return i}catch(i){throw new g(i?.message)}}constructor(e,i=new Date){super(e,i),this.id=e.id,this.key=e.key,this.name={...e.name},this.description={...e.description},this.slug={...e.slug},this.brand=e.brand,this.pricing=Object.keys(e.pricing).reduce((s,o)=>(e.pricing[o]&&(s[o]=new a$1(e.pricing[o])),s),{}),this.targetGender=e.targetGender,this.attributes=n.deepClone(e.attributes),this.specifications=n.deepClone(e.specifications),this.categories=n.deepClone(e.categories);let r=new Set;this.variants=(e.variants||[]).map(s=>{if(!s.selectionAttributes||typeof s.selectionAttributes!="object")throw new g("Selection attributes are required");this.checkSelectionAttributes(s.selectionAttributes);let o=t.generateSelectionAttributesKey(s.selectionAttributes);if(r.has(o))throw new d(o);return r.add(o),{sku:s.sku,selectionAttributes:s.selectionAttributes,images:{primary:new b$1(s.images.primary),gallery:(s.images.gallery||[]).map(g=>new b$1(g))}}}),this.isActive=e.isActive,this.searchTags=e.searchTags?n.deepClone(e.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getName(e$1){return e$1?this.name[e$1]??this.name[e[e$1]]??this.name.en:n.deepClone(this.name)}getDescription(e$1){return e$1?this.description[e$1]??this.description[e[e$1]]??this.description.en:n.deepClone(this.description)}getSlug(e$1){return e$1?this.slug[e$1]??this.slug[e[e$1]]??this.slug.en:n.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(e){return e?this.pricing[e]??null:{...this.pricing}}getAttributes(){return n.deepClone(this.attributes)}getVariants(){return this.variants.map(e=>({sku:e.sku,selectionAttributes:n.deepClone(e.selectionAttributes),images:{primary:e.images.primary,gallery:[...e.images.gallery]}}))}getImagesBySelectionAttributes(e){let i=t.generateSelectionAttributesKey(e),r=this.variants.find(s=>t.generateSelectionAttributesKey(s.selectionAttributes)===i);return r?{primary:r.images.primary,gallery:[...r.images.gallery]}:null}getImages(e,i){switch(i){case"PRIMARY":return this.getImagesBySelectionAttributes(e)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(e)?.gallery??[];default:return this.getImagesBySelectionAttributes(e)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return n.deepClone(this.categories)}getSpecifications(e$1){return e$1?n.deepClone(this.specifications[e$1]??this.specifications[e[e$1]]??this.specifications.en):n.deepClone(this.specifications)}getSearchTags(e$1){return e$1?n.deepClone(this.searchTags[e$1]??this.searchTags[e[e$1]]??this.searchTags.en):n.deepClone(this.searchTags)}getDetails(){let e=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((i,r)=>(this.pricing[r]&&(i[r]=this.pricing[r]?.getDetails()),i),{}),attributes:this.getAttributes(),variants:this.variants.map(i=>({sku:i.sku,selectionAttributes:n.deepClone(i.selectionAttributes),images:{primary:i.images.primary.getDetails(),gallery:i.images.gallery.map(r=>r.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...e}}checkSelectionAttributes(e){if(!e||typeof e!="object")throw new g("Selection attributes are required");Object.keys(this.attributes).forEach(i=>{if(i.toLowerCase()==="size")return;let r=this.attributes[i],s=e[i];if(s===void 0)throw new g(`Selection attribute '${i}' is missing`);if(typeof r=="string"){if(typeof s!="string"||r!==s)throw new g(`Selection attribute '${i}' is invalid`)}else if(Array.isArray(r)){if(r.length>0&&typeof r[0]=="string"){if(typeof s!="string"||!r.includes(s))throw new g(`Selection attribute '${i}' is invalid`)}else if(typeof s!="object"||!("name"in s)||r.findIndex(o=>o.name===s.name)<0)throw new g(`Selection attribute '${i}' is invalid`)}});}validateSelectionAttribute(e){let i=t.generateSelectionAttributesKey(e);return this.variants.some(r=>t.generateSelectionAttributesKey(r.selectionAttributes)===i)}validateSize(e){return this.attributes.size.includes(e)}};var Z={isUUID:t=>/^[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(t),isEmail:t=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t),isURL:t=>/^(http|https):\/\/[^ "]+$/.test(t),generateUUID:(t,e)=>e&&t?v(t,e):L(),generateSearchId:(t,e)=>`${t}#${m.generateSelectionAttributesKey(e)}`,getKeyfromSearchId:t=>{let[e,i]=t.split("#");return {key:e,selectionAttributes:m.parseSelectionAttributesKey(i)}},deepClone(t){return structuredClone(t)}},n=Z;var w=class{customFields;constructor(e,i=new Date){this.customFields={...e.customFields};}getCustomField(e){let i=this.customFields[e];return i==null?i:n.deepClone(i)}setCustomField(e,i){this.customFields[e]=i;}getAllCustomFields(){return n.deepClone(this.customFields)}},f=class extends w{version;createdAt;modifiedAt;modifiedBy;constructor(e,i=new Date){super(e),this.version=e.version??1,this.createdAt=e.createdAt&&!isNaN(Date.parse(e.createdAt))?new Date(e.createdAt).toISOString():i.toISOString(),this.modifiedAt=e.modifiedAt&&!isNaN(Date.parse(e.modifiedAt))?new Date(e.modifiedAt).toISOString():i.toISOString(),this.modifiedBy={...e.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(e,i,r,s){this.modifiedBy={id:e,authType:i,requestId:r,lambdaName:s};}};export{n as a,w as b,f as c,m as d};//# sourceMappingURL=chunk-HKXV6QWV.mjs.map
2
- //# sourceMappingURL=chunk-HKXV6QWV.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../node_modules/uuid/dist/esm-node/rng.js","../node_modules/uuid/dist/esm-node/regex.js","../node_modules/uuid/dist/esm-node/validate.js","../node_modules/uuid/dist/esm-node/stringify.js","../node_modules/uuid/dist/esm-node/parse.js","../node_modules/uuid/dist/esm-node/v35.js","../node_modules/uuid/dist/esm-node/native.js","../node_modules/uuid/dist/esm-node/v4.js","../node_modules/uuid/dist/esm-node/sha1.js","../node_modules/uuid/dist/esm-node/v5.js","../src/Classes/Product.ts","../src/Utils/index.ts","../src/Classes/Base.ts"],"names":["rnds8Pool","poolPtr","rng","crypto","regex_default","validate","uuid","validate_default","byteToHex","i","unsafeStringify","arr","offset","parse","v","parse_default","stringToBytes","str","bytes","DNS","URL","v35","name","version","hashfunc","generateUUID","value","namespace","buf","_namespace","native_default","v4","options","rnds","v4_default","sha1","sha1_default","v5","v5_default","ProductModel","_ProductModel","BaseModel","selectionAttributes","SelectionAttributeParseError","key","attributes","parts","part","error","data","date","acc","country","TieredPriceModel","Utils_default","uniqueSelectionAttributes","variant","DuplicateSelectionAttributeError","ImageInfoModel","image","locale","LocaleLanguageMap","searchKey","match","category","baseDetails","img","allowedAttributeValues","providedValue","c","size","Utils","searchId","selectionAttributesKey","obj","CustomFieldModel","fieldName","id","authType","requestId","lambdaName"],"mappings":"0LACA,IAAMA,CAAY,CAAA,IAAI,WAAW,GAAG,CAAA,CAEhCC,CAAUD,CAAAA,CAAAA,CAAU,MACT,CAAA,SAARE,GAAuB,CAC5B,OAAID,CAAUD,CAAAA,CAAAA,CAAU,MAAS,CAAA,EAAA,GAC/BG,CAAO,CAAA,cAAA,CAAeH,CAAS,CAAA,CAC/BC,CAAU,CAAA,CAAA,CAAA,CAGLD,CAAU,CAAA,KAAA,CAAMC,EAASA,CAAW,EAAA,EAAE,CAC/C,CCXA,IAAOG,CAAAA,CAAQ,sHCEf,SAASC,CAAAA,CAASC,CAAM,CAAA,CACtB,OAAO,OAAOA,GAAS,QAAYF,EAAAA,CAAAA,CAAM,IAAKE,CAAAA,CAAI,CACpD,CAEA,IAAOC,CAAAA,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,OAAO,IAAA,CAAK,UACd,CAMA,iBAA4B,EAAA,CAC1B,OAAO,IAAI,IAAK,CAAA,IAAA,CAAK,UAAU,CAAA,CAAE,OAAQ,EAC3C,CAMA,aAA4B,EAAA,CAC1B,OAAO,CAAE,GAAG,IAAA,CAAK,UAAW,CAC9B,CAMA,aAAA,CAAc4B,CAAaC,CAAAA,CAAAA,CAAqBC,CAAoBC,CAAAA,CAAAA,CAA2B,CAC7F,IAAK,CAAA,UAAA,CAAa,CAChB,EAAA,CAAAH,CACA,CAAA,QAAA,CAAAC,CACA,CAAA,SAAA,CAAAC,CACA,CAAA,UAAA,CAAAC,CACF,EACF,CACF","file":"chunk-HKXV6QWV.mjs","sourcesContent":["import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[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;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","import { unsafeStringify } from './stringify.js';\nimport parse from './parse.js';\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nexport const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexport const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexport default function v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = parse(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","import crypto from 'crypto';\nexport default {\n randomUUID: crypto.randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import crypto from 'crypto';\n\nfunction sha1(bytes) {\n if (Array.isArray(bytes)) {\n bytes = Buffer.from(bytes);\n } else if (typeof bytes === 'string') {\n bytes = Buffer.from(bytes, 'utf8');\n }\n\n return crypto.createHash('sha1').update(bytes).digest();\n}\n\nexport default sha1;","import v35 from './v35.js';\nimport sha1 from './sha1.js';\nconst v5 = v35('v5', 0x50, sha1);\nexport default v5;","import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { Color, LocalizedString, CountryCode, LocaleCode, LocalizedValue, Prettify } from './Common';\r\nimport { GenderCategory, ImageCategory, LocaleLanguageMap } from \"./Enum\";\r\nimport { DuplicateSelectionAttributeError, DuplicateSizeError, SelectionAttributeParseError } from \"./Error\";\r\nimport ImageInfoModel, { ImageInfoData } from \"./ImageInfo\";\r\nimport { TieredPriceModel, TieredPriceAttributes, TieredPriceData } from \"./TieredPrice\";\r\n\r\nexport type ProductSelectionAttributes = Prettify<{\r\n color: Color[];\r\n size: string[];\r\n} & {\r\n [key: string]: string | string[] | Color[];\r\n}>;\r\n\r\nexport type SelectionAttributes = {\r\n color: Color;\r\n [key: string]: string | Color;\r\n};\r\n\r\nexport type VariantData = {\r\n sku: string;\r\n selectionAttributes: SelectionAttributes;\r\n images: {\r\n primary: ImageInfoData;\r\n gallery: ImageInfoData[];\r\n };\r\n};\r\n\r\nexport type VariantModel = {\r\n sku: string;\r\n selectionAttributes: SelectionAttributes;\r\n images: {\r\n primary: ImageInfoModel;\r\n gallery: ImageInfoModel[];\r\n };\r\n};\r\n\r\n\r\nexport type ProductSpecification = { [key: string]: string | string[] };\r\n\r\nexport type ProductAttributes = BaseAttributes & {\r\n id: string;\r\n key: string;\r\n\r\n name: LocalizedString;\r\n description: LocalizedString;\r\n slug: LocalizedString;\r\n brand: string;\r\n\r\n pricing: {\r\n [country in CountryCode]?: TieredPriceAttributes;\r\n };\r\n\r\n targetGender: GenderCategory;\r\n attributes: ProductSelectionAttributes;\r\n specifications: LocalizedValue<ProductSpecification>;\r\n categories: string[];\r\n\r\n variants: VariantData[];\r\n\r\n // Metadata\r\n isActive: boolean;\r\n searchTags?: LocalizedValue<string[]>;\r\n};\r\n\r\nexport type ProductData = Required<ProductAttributes>\r\n\r\nexport default class ProductModel extends BaseModel {\r\n protected id: string;\r\n protected key: string;\r\n\r\n protected name: LocalizedString;\r\n protected description: LocalizedString;\r\n protected slug: LocalizedString;\r\n protected brand: string;\r\n\r\n protected pricing: {\r\n [country in CountryCode]?: TieredPriceModel;\r\n };\r\n\r\n protected variants: VariantModel[];\r\n\r\n protected targetGender: GenderCategory;\r\n protected attributes: ProductSelectionAttributes;\r\n protected specifications: LocalizedValue<ProductSpecification>;\r\n protected categories: string[];\r\n\r\n // Metadata\r\n protected isActive: boolean;\r\n\r\n protected searchTags: LocalizedValue<string[]>;\r\n\r\n static productKeyRegex = /^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$/;\r\n static productSKURegex = /^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$/;\r\n\r\n /**\r\n * Generates a unique key for checking uniqueness for a given selection attributes.\r\n * Excludes 'size' from the key generation.\r\n * @param selectionAttributes - The selection attributes.\r\n * @returns A string key representing the unique attribute combination.\r\n */\r\n static generateSelectionAttributesKey(selectionAttributes: SelectionAttributes): string {\r\n if (typeof selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes must be an object');\r\n }\r\n\r\n const sortedKeys = Object.keys(selectionAttributes)\r\n .filter(key => selectionAttributes[key] !== undefined && key.toLowerCase() !== 'size')\r\n .sort()\r\n\r\n return sortedKeys.map(key => {\r\n if ((selectionAttributes[key] as Color).name) {\r\n return `${key}:c+${(selectionAttributes[key] as Color).name}`;\r\n }\r\n return `${key}:${selectionAttributes[key]}`;\r\n }).join('|').toLowerCase();\r\n }\r\n\r\n /**\r\n * Parses a selection attributes key into an object.\r\n * @param key - The selection attributes key to parse.\r\n * @returns An object containing the parsed selection attributes.\r\n */\r\n static parseSelectionAttributesKey(key: string): SelectionAttributes {\r\n try {\r\n const attributes: SelectionAttributes = {} as unknown as SelectionAttributes;\r\n const parts = key.split('|');\r\n for (const part of parts) {\r\n const [key, value] = part.split(':');\r\n if (value.startsWith('c+')) {\r\n attributes[key] = { name: value.slice(2) } as Color;\r\n } else {\r\n attributes[key] = value;\r\n }\r\n }\r\n return attributes;\r\n } catch (error: any) {\r\n throw new SelectionAttributeParseError(error?.message);\r\n }\r\n }\r\n\r\n /**\r\n * Creates an instance of ProductModel.\r\n * Initializes properties based on the provided data, creating copies where necessary.\r\n * @param data - The initial product attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: ProductAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n\r\n this.id = data.id;\r\n this.key = data.key;\r\n\r\n this.name = { ...data.name };\r\n this.description = { ...data.description };\r\n this.slug = { ...data.slug };\r\n this.brand = data.brand;\r\n\r\n this.pricing = (Object.keys(data.pricing) as CountryCode[]).reduce((acc, country) => {\r\n if (data.pricing[country]) {\r\n acc[country] = new TieredPriceModel(data.pricing[country]);\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]?: TieredPriceModel });\r\n\r\n this.targetGender = data.targetGender;\r\n this.attributes = Utils.deepClone(data.attributes);\r\n this.specifications = Utils.deepClone(data.specifications);\r\n this.categories = Utils.deepClone(data.categories);\r\n\r\n const uniqueSelectionAttributes = new Set<string>();\r\n this.variants = (data.variants || []).map(variant => {\r\n if (!variant.selectionAttributes || typeof variant.selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes are required');\r\n }\r\n\r\n this.checkSelectionAttributes(variant.selectionAttributes);\r\n const key = ProductModel.generateSelectionAttributesKey(variant.selectionAttributes);\r\n if (uniqueSelectionAttributes.has(key)) {\r\n throw new DuplicateSelectionAttributeError(key);\r\n }\r\n uniqueSelectionAttributes.add(key);\r\n return {\r\n sku: variant.sku,\r\n selectionAttributes: variant.selectionAttributes,\r\n images: {\r\n primary: new ImageInfoModel(variant.images.primary),\r\n gallery: (variant.images.gallery || []).map(image => new ImageInfoModel(image))\r\n }\r\n };\r\n });\r\n\r\n this.isActive = data.isActive;\r\n this.searchTags = data.searchTags ? Utils.deepClone(data.searchTags) : { en: [] };\r\n }\r\n\r\n /**\r\n * Gets the base Product ID.\r\n * @returns Product ID.\r\n */\r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the user-friendly product key.\r\n * @returns Product Key.\r\n */\r\n getKey(): string {\r\n return this.key;\r\n }\r\n\r\n /**\r\n * Gets the full localized product name object.\r\n * @returns A copy of the LocalizedString object for the name.\r\n */\r\n getName(): LocalizedString\r\n /**\r\n * Gets the product name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.name[locale] ?? this.name[LocaleLanguageMap[locale]] ?? this.name.en;\r\n } else {\r\n return Utils.deepClone(this.name);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized product description object.\r\n * @returns A copy of the LocalizedString object for the description.\r\n */\r\n getDescription(): LocalizedString\r\n /**\r\n * Gets the product description for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The description string for the specified locale.\r\n */\r\n getDescription(locale: LocaleCode): string\r\n getDescription(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.description[locale] ?? this.description[LocaleLanguageMap[locale]] ?? this.description.en;\r\n } else {\r\n return Utils.deepClone(this.description);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized product slug object.\r\n * @returns A copy of the LocalizedString object for the slug.\r\n */\r\n getSlug(): LocalizedString\r\n /**\r\n * Gets the product slug for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The slug string for the specified locale.\r\n */\r\n getSlug(locale: LocaleCode): string\r\n getSlug(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.slug[locale] ?? this.slug[LocaleLanguageMap[locale]] ?? this.slug.en;\r\n } else {\r\n return Utils.deepClone(this.slug);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the brand associated with the product.\r\n * @returns The brand name string.\r\n */\r\n getBrand(): string {\r\n return this.brand;\r\n }\r\n\r\n /**\r\n * Gets the tiered price details for the product.\r\n * @returns Pricing details mapped by country.\r\n */\r\n getPriceDetails(): { [country in CountryCode]?: TieredPriceModel }\r\n /**\r\n * Gets the tiered price details for a specific country.\r\n * @param country - The country code.\r\n * @returns The tiered price model for the country, or null if not found.\r\n */\r\n getPriceDetails(country: CountryCode): TieredPriceModel | null\r\n getPriceDetails(country?: CountryCode): { [country in CountryCode]?: TieredPriceModel } | TieredPriceModel | null {\r\n if (country) {\r\n return this.pricing[country] ?? null;\r\n }\r\n return { ...this.pricing };\r\n }\r\n\r\n /**\r\n * Gets the variant-specific attributes (color, sizes). Returns copies.\r\n * @returns Product Attributes.\r\n */\r\n getAttributes(): ProductSelectionAttributes {\r\n return Utils.deepClone(this.attributes);\r\n }\r\n\r\n\r\n /**\r\n * Gets the variant-specific attributes (color, sizes). Returns copies.\r\n * @returns Product Attributes.\r\n */\r\n getVariants(): VariantModel[] {\r\n return this.variants.map(variant => ({\r\n sku: variant.sku,\r\n selectionAttributes: Utils.deepClone(variant.selectionAttributes),\r\n images: {\r\n primary: variant.images.primary,\r\n gallery: [...variant.images.gallery]\r\n }\r\n }));\r\n }\r\n\r\n /**\r\n * Gets the images for a specific selection attribute combination.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The matching image set or null if not found.\r\n */\r\n private getImagesBySelectionAttributes(selectionAttributes: SelectionAttributes): { primary: ImageInfoModel; gallery: ImageInfoModel[] } | null {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n\r\n const match = this.variants.find(variant =>\r\n ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey\r\n );\r\n\r\n return match ? {\r\n primary: match.images.primary,\r\n gallery: [...match.images.gallery]\r\n } : null;\r\n }\r\n\r\n /**\r\n * Gets the images for a specific selection attribute combination.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The matching image set or null if not found.\r\n */\r\n getImages(selectionAttributes: SelectionAttributes): { primary: ImageInfoModel; gallery: ImageInfoModel[] }\r\n getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.PRIMARY): ImageInfoModel\r\n getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.GALLERY): ImageInfoModel[]\r\n getImages(selectionAttributes: SelectionAttributes, category?: ImageCategory): { primary: ImageInfoModel; gallery: ImageInfoModel[] } | ImageInfoModel | ImageInfoModel[] {\r\n switch (category) {\r\n case ImageCategory.PRIMARY:\r\n return this.getImagesBySelectionAttributes(selectionAttributes)?.primary ?? this.variants[0]?.images?.primary;\r\n case ImageCategory.GALLERY:\r\n return this.getImagesBySelectionAttributes(selectionAttributes)?.gallery ?? [];\r\n default:\r\n return this.getImagesBySelectionAttributes(selectionAttributes) ?? { primary: this.variants[0]?.images?.primary, gallery: [] };\r\n }\r\n }\r\n\r\n\r\n /**\r\n * Checks if the product is active.\r\n * @returns True if the product is active, false otherwise.\r\n */\r\n getIsActive(): boolean {\r\n return this.isActive;\r\n }\r\n\r\n /**\r\n * Gets the target gender category for the product.\r\n * @returns The GenderCategory enum value.\r\n */\r\n getTargetGender(): GenderCategory {\r\n return this.targetGender;\r\n }\r\n\r\n /**\r\n * Gets the list of categories the product belongs to. Returns a copy.\r\n * @returns An array of category.\r\n */\r\n getCategories(): string[] {\r\n return Utils.deepClone(this.categories);\r\n }\r\n\r\n /**\r\n * Gets the full localized product specifications object.\r\n * @returns Product Specifications\r\n */\r\n getSpecifications(): LocalizedValue<ProductSpecification>\r\n /**\r\n * Gets the product specifications for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The ProductSpecification object for the specified locale, or undefined if not found.\r\n */\r\n getSpecifications(locale: LocaleCode): ProductSpecification\r\n getSpecifications(locale?: LocaleCode): LocalizedValue<ProductSpecification> | ProductSpecification {\r\n if (locale) {\r\n return Utils.deepClone(this.specifications[locale] ?? this.specifications[LocaleLanguageMap[locale]] ?? this.specifications.en);\r\n } else {\r\n return Utils.deepClone(this.specifications);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the localized list of search tags. Returns a copy.\r\n * @returns Localized array of search tags.\r\n */\r\n getSearchTags(): LocalizedValue<string[]>\r\n /**\r\n * Gets the search tags for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The array of search tags for the specified locale, or undefined if not found.\r\n */\r\n getSearchTags(locale: LocaleCode): string[]\r\n getSearchTags(locale?: LocaleCode): LocalizedValue<string[]> | string[] {\r\n if (locale) {\r\n return Utils.deepClone(this.searchTags[locale] ?? this.searchTags[LocaleLanguageMap[locale]] ?? this.searchTags.en);\r\n } else {\r\n return Utils.deepClone(this.searchTags);\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @returns ProductData\r\n */\r\n getDetails(): ProductData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n id: this.getId(),\r\n key: this.getKey(),\r\n name: this.getName(),\r\n description: this.getDescription(),\r\n slug: this.getSlug(),\r\n brand: this.getBrand(),\r\n pricing: (Object.keys(this.pricing) as CountryCode[]).reduce((acc, country) => {\r\n if (this.pricing[country]) {\r\n acc[country] = this.pricing[country]?.getDetails();\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]: TieredPriceData }),\r\n attributes: this.getAttributes(),\r\n variants: this.variants.map(v => ({\r\n sku: v.sku,\r\n selectionAttributes: Utils.deepClone(v.selectionAttributes),\r\n images: {\r\n primary: v.images.primary.getDetails(),\r\n gallery: v.images.gallery.map(img => img.getDetails())\r\n }\r\n })),\r\n isActive: this.getIsActive(),\r\n targetGender: this.getTargetGender(),\r\n categories: this.getCategories(),\r\n specifications: this.getSpecifications(),\r\n searchTags: this.getSearchTags(),\r\n ...baseDetails\r\n };\r\n }\r\n\r\n /**\r\n * Checks if the provided selection attributes are valid for the product.\r\n * @param selectionAttributes The selection attributes to validate.\r\n * @throws {SelectionAttributeParseError} If the selection attributes are invalid.\r\n */\r\n checkSelectionAttributes(selectionAttributes: SelectionAttributes): void {\r\n if (!selectionAttributes || typeof selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes are required');\r\n }\r\n\r\n Object.keys(this.attributes).forEach(key => {\r\n if(key.toLowerCase() === 'size') return;\r\n \r\n const allowedAttributeValues = this.attributes[key];\r\n const providedValue = selectionAttributes[key];\r\n\r\n if (providedValue === undefined) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is missing`);\r\n }\r\n\r\n if (typeof allowedAttributeValues === 'string') {\r\n if (typeof providedValue !== 'string' || allowedAttributeValues !== providedValue) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n } else if (Array.isArray(allowedAttributeValues)) {\r\n if (allowedAttributeValues.length > 0 && typeof allowedAttributeValues[0] === 'string') {\r\n if (typeof providedValue !== 'string' || !(allowedAttributeValues as string[]).includes(providedValue)) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n } else {\r\n // Color validation\r\n if (\r\n typeof providedValue !== 'object' ||\r\n !('name' in providedValue) ||\r\n (allowedAttributeValues as Color[]).findIndex(c => c.name === (providedValue as Color).name) < 0\r\n ) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Validates if the provided selection attributes exist for this product.\r\n * @param selectionAttributes - The attributes to validate.\r\n * @returns True if a valid selection attribute exists, false otherwise.\r\n */\r\n validateSelectionAttribute(selectionAttributes: SelectionAttributes): boolean {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n\r\n return this.variants.some(variant => ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey);\r\n }\r\n\r\n /**\r\n * Validates if a specific size is available for this product.\r\n * @param size - The size to check.\r\n * @returns True if the size exists in the product's attributes, false otherwise.\r\n */\r\n validateSize(size: string): boolean {\r\n return this.attributes.size.includes(size);\r\n }\r\n}\r\n","import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\r\nimport ProductModel, { SelectionAttributes } from '../Classes/Product';\r\n\r\nconst Utils = {\r\n isUUID: (value: string): boolean => {\r\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return uuidRegex.test(value);\r\n },\r\n\r\n isEmail: (value: string): boolean => {\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n return emailRegex.test(value);\r\n },\r\n\r\n isURL: (value: string): boolean => {\r\n const urlRegex = /^(http|https):\\/\\/[^ \"]+$/;\r\n return urlRegex.test(value);\r\n },\r\n \r\n generateUUID: (value?: string, namespace?: string) => {\r\n if(namespace && value){\r\n return uuidv5(value, namespace);\r\n }\r\n return uuidv4();\r\n },\r\n\r\n generateSearchId: (key: string, selectionAttributes: SelectionAttributes) => {\r\n return `${key}#${ProductModel.generateSelectionAttributesKey(selectionAttributes)}`;\r\n },\r\n\r\n getKeyfromSearchId: (searchId: string) => {\r\n const [key, selectionAttributesKey] = searchId.split('#');\r\n return {\r\n key,\r\n selectionAttributes: ProductModel.parseSelectionAttributesKey(selectionAttributesKey)\r\n }\r\n },\r\n\r\n /**\r\n * Deep clones an object using `structuredClone`. Don't use this on a class instance.\r\n * @param obj - The object to clone.\r\n * @returns A deep clone of the object.\r\n */\r\n deepClone<T>(obj: T): T {\r\n return structuredClone(obj);\r\n }\r\n}\r\n\r\nexport default Utils;\r\n","import { AuthType } from \"../Auth\";\r\nimport { ISODateTimeUTC, Prettify } from \"./Common\";\r\nimport Utils from \"../Utils\";\r\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 {\r\n const value = this.customFields[fieldName];\r\n if (value === undefined || value === null) return value;\r\n return Utils.deepClone(value);\r\n }\r\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 {\r\n return Utils.deepClone(this.customFields);\r\n }\r\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"]}
@@ -1,2 +0,0 @@
1
- import {c,a}from'./chunk-HKXV6QWV.mjs';import {a as a$1}from'./chunk-XHGUVYQO.mjs';import {e}from'./chunk-FC4P26U3.mjs';import {t}from'./chunk-XPKK6DFA.mjs';var y=(t=>(t.COUPON="coupon",t.AUTOMATIC="automatic",t))(y||{}),M=(t=>(t.FLAT="flat",t.PERCENTAGE="percentage",t))(M||{}),b=(t=>(t.SHIPPING="SHIPPING",t.CUSTOMER="CUSTOMER",t))(b||{}),P=(t=>(t.ALL="all",t.FTB="ftb",t))(P||{}),p=class extends c{couponCode;name;description;type;customerId;validFrom;validTo;minCartValue;maxCartDiscount;discountMethod;percentageValue;applicableTo;category;constructor(e,t$1=new Date){if(super(e,t$1),this.couponCode=e.couponCode,this.name=a.deepClone(e.name),this.description=a.deepClone(e.description),this.type=e.type,this.customerId=e.customerId,this.validFrom=e.validFrom&&Date.parse(e.validFrom)?new Date(e.validFrom).toISOString():t$1.toISOString(),this.validTo=e.validTo&&Date.parse(e.validTo)?new Date(e.validTo).toISOString():t$1.toISOString(),this.minCartValue=Object.keys(e.minCartValue).reduce((o,i)=>{let r=e.minCartValue[i];return r&&(o[i]=new a$1(r)),o},{}),this.maxCartDiscount=Object.keys(e.maxCartDiscount).reduce((o,i)=>{let r=e.maxCartDiscount[i];return r&&(o[i]=new a$1(r)),o},{}),this.discountMethod=e.discountMethod,this.percentageValue=e.percentageValue??0,this.percentageValue>100)throw new t("Percentage value cannot be greater than 100");this.applicableTo=e.applicableTo,this.category=e.category;}getCode(){return this.couponCode}getName(e$1){return e$1?this.name[e$1]??this.name[e[e$1]]??this.name.en:{...this.name}}getDescription(e$1){return e$1?this.description[e$1]??this.description[e[e$1]]??this.description.en:{...this.description}}getType(){return this.type}getCustomerId(){return this.customerId??""}getValidFrom(){return this.validFrom}getValidTo(){return this.validTo}getMinCartValue(e){return e?this.minCartValue[e]:{...this.minCartValue}}getMaxCartDiscount(e){return e?this.maxCartDiscount[e]:{...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((e,t)=>{let o=this.getMinCartValue(t);return o&&(e[t]=o.getDetails()),e},{}),maxCartDiscount:Object.keys(this.getMaxCartDiscount()).reduce((e,t)=>{let o=this.getMaxCartDiscount(t);return o&&(e[t]=o.getDetails()),e},{}),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(e){return this.applicableTo==="all"||this.applicableTo==="ftb"&&e}calculateApplicableCouponDiscount(e,t,o,i,r=!0){let n=new a$1({amount:0,currency:i}),s;if(r&&!this.isActive())return n;let C=this.getMinCartValue(o),c=this.getMaxCartDiscount(o);if(!C||C.compareTo(e)>0||!c)return n;let h=this.getCategory(),D=this.getDiscountMethod(),u=h==="SHIPPING"?t:e;if(u.getAmount()<=0)return n;switch(D){case"flat":let T=c;s=u.min(T);break;case"percentage":s=u.multiply(this.getPercentageValue()/100).round();break;default:return n}return s.min(c)}};export{y as a,M as b,b as c,P as d,p as e};//# sourceMappingURL=chunk-IQNK7EEI.mjs.map
2
- //# sourceMappingURL=chunk-IQNK7EEI.mjs.map
@@ -1,2 +0,0 @@
1
- import {b as b$3}from'./chunk-L3CNGDFJ.mjs';import {b as b$1,a}from'./chunk-HKXV6QWV.mjs';import {a as a$2}from'./chunk-XBFSNBKL.mjs';import {a as a$1}from'./chunk-XHGUVYQO.mjs';import {e,n}from'./chunk-FC4P26U3.mjs';import {b as b$2}from'./chunk-RSTZJZSQ.mjs';import {c,e as e$1,f,h,i,j,b as b$4}from'./chunk-XPKK6DFA.mjs';var b=class extends b$1{id;productKey;selectionAttributes;name;specifications;primaryImage;subItems;pricing;state;total;constructor(t){super(t),this.id=t.id,this.productKey=t.productKey,this.selectionAttributes=a.deepClone(t.selectionAttributes),this.name=a.deepClone(t.name),this.specifications=a.deepClone(t.specifications),this.primaryImage=new b$2(t.primaryImage),this.subItems=a.deepClone(t.subItems);let e=new Set;this.subItems.forEach(i=>{if(e.has(i.size))throw new c(i.size);e.add(i.size);}),this.pricing={unitPrice:new a$1(t.pricing.unitPrice),tierPricing:new a$2(t.pricing.tierPricing),taxCategory:t.pricing.taxCategory,applicableTaxRule:t.pricing.applicableTaxRule.map(i=>new b$3(i))},this.state=t.state??"INITIAL",this.total={quantity:t.total.quantity,unitPrice:new a$1(t.total.unitPrice),subtotal:new a$1(t.total.subtotal),discounts:Object.fromEntries(Object.entries(t.total.discounts).map(([i,a])=>[i,new a$1(a)])),totalDiscount:new a$1(t.total.totalDiscount),netUnitPrice:new a$1(t.total.netUnitPrice),netSubtotal:new a$1(t.total.netSubtotal),taxBreakdown:Object.fromEntries(Object.entries(t.total.taxBreakdown).map(([i,a])=>[i,{rate:a.rate,taxableUnitPrice:new a$1(a.taxableUnitPrice),taxPerUnit:new a$1(a.taxPerUnit),amount:new a$1(a.amount),system:a.system,subSystem:a.subSystem}])),taxTotal:new a$1(t.total.taxTotal),grandTotal:new a$1(t.total.grandTotal)};}getId(){return this.id}getProductKey(){return this.productKey}getSelectionAttributes(){return a.deepClone(this.selectionAttributes)}getName(t){return t?a.deepClone(this.name[t]??this.name[e[t]]??this.name.en):a.deepClone(this.name)}getSpecifications(t){return t?a.deepClone(this.specifications[t]??this.specifications[e[t]]??this.specifications.en):a.deepClone(this.specifications)}getImage(){return this.primaryImage}getSubItems(){return a.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,discounts:Object.fromEntries(Object.entries(this.total.discounts).map(([t,e])=>[t,e])),totalDiscount:this.total.totalDiscount,netUnitPrice:this.total.netUnitPrice,netSubtotal:this.total.netSubtotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{rate:e.rate,taxableUnitPrice:e.taxableUnitPrice,taxPerUnit:e.taxPerUnit,amount:e.amount,system:e.system,subSystem:e.subSystem}])),taxTotal:this.total.taxTotal,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(),discounts:Object.fromEntries(Object.entries(e.discounts).map(([i,a])=>[i,a.getDetails()])),totalDiscount:e.totalDiscount.getDetails(),netUnitPrice:e.netUnitPrice.getDetails(),netSubtotal:e.netSubtotal.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(e.taxBreakdown).map(([i,a])=>[i,{rate:a.rate,taxableUnitPrice:a.taxableUnitPrice.getDetails(),taxPerUnit:a.taxPerUnit.getDetails(),amount:a.amount.getDetails(),system:a.system,subSystem:a.subSystem}])),taxTotal:e.taxTotal.getDetails(),grandTotal:e.grandTotal.getDetails()},customFields:this.getAllCustomFields()}}addSubItems(t,e){t.forEach(i=>{let a=this.subItems.find(c=>c.size===i.size);a?a.quantity=e?a.quantity+i.quantity:i.quantity:this.subItems.push(i);}),this.subItems=this.subItems.filter(i=>i.quantity>0),this.calculateTotals();}updateProductData(t,e,i$1){if(this.productKey!==t.getKey()||!t.validateSelectionAttribute(this.selectionAttributes))throw new e$1;if(!t.getIsActive())throw new f;this.subItems.forEach(s=>{if(!t.validateSize(s.size))throw new h});let a=t.getPriceDetails(e);if(!a||a.getBaseUnitPrice().getCurrency()!==i$1)throw new i;this.name=t.getName(),this.specifications=t.getSpecifications(),this.primaryImage=t.getImages(this.selectionAttributes).primary;let c=this.subItems.reduce((s,g)=>s+g.quantity,0),{unitPrice:l}=a.getApplicableTier(c);this.pricing={unitPrice:l,tierPricing:a,taxCategory:a.getTaxCategory(),applicableTaxRule:this.pricing.applicableTaxRule},this.calculateTotals();}updateDiscounts(t){let e={};t.forEach(i=>{e[i.coupon.getCode()]=i.amount;}),this.total.discounts=e,this.calculateTotals();}updateTax(t){t.forEach(e=>{if(!e.appliesTo(this.pricing.taxCategory,e.getTaxCountry()))throw new j}),this.pricing.applicableTaxRule=t,this.calculateTotals();}calculateTotals(){let t=this.pricing.unitPrice.zero(),e=this.subItems.reduce((n,u)=>n+u.quantity,0);if(this.state==="CANCELLED"){this.total={quantity:0,unitPrice:t,subtotal:t,discounts:{},totalDiscount:t,netUnitPrice:t,netSubtotal:t,taxBreakdown:{},taxTotal:t,grandTotal:t};return}let{unitPrice:i}=this.pricing.tierPricing.getApplicableTier(e),a=i.multiply(e),c=Object.values(this.total.discounts).reduce((n,u)=>n.add(u),t),l=a.subtract(c),s=e>0?l.divide(e):t,g={},m=t;this.pricing.applicableTaxRule.forEach(n=>{let u=n.getApplicableTaxRate(s),P=n.calculateTax(s),h=P.multiply(e).round();g[n.getTaxRuleId()]={rate:u,taxableUnitPrice:s,taxPerUnit:P,amount:h,system:n.getTaxSystem(),subSystem:n.getTaxSubSystem()},m=m.add(h);});let w=l.add(m);this.total={quantity:e,unitPrice:i,subtotal:a,discounts:this.total.discounts,totalDiscount:c,netUnitPrice:s,netSubtotal:l,taxBreakdown:g,taxTotal:m,grandTotal:w};}updateState(t){if(this.state in n)this.state!==t&&(this.state=t);else throw new b$4(t)}clearLineItem(){let t=this.pricing.unitPrice.zero();this.id="",this.productKey="",this.selectionAttributes={color:{name:""}},this.name={en:""},this.primaryImage=new b$2({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,discounts:{},totalDiscount:t,netUnitPrice:t,netSubtotal:t,taxBreakdown:{},taxTotal:t,grandTotal:t};}};export{b as a};//# sourceMappingURL=chunk-RHSKHT5F.mjs.map
2
- //# sourceMappingURL=chunk-RHSKHT5F.mjs.map
@@ -1,2 +0,0 @@
1
- import {a}from'./chunk-RHSKHT5F.mjs';import {b}from'./chunk-R3ZADSUJ.mjs';import {a as a$1}from'./chunk-GJ2DSRIP.mjs';import {e}from'./chunk-IQNK7EEI.mjs';import {c,a as a$2}from'./chunk-HKXV6QWV.mjs';import {a as a$3}from'./chunk-XHGUVYQO.mjs';var A=class extends c{id;customerId;customerEmail;anonymousId;lineItems;charges;shippingDetails;shippingAddress;billingAddress;coupons;total;country;currency;locale;constructor(t,e$1=new Date){super(t,e$1),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(o=>new a(o)),this.charges=(t.charges??[]).map(o=>new a$1(o)),this.billingAddress=t.billingAddress?new b(t.billingAddress,e$1):null,this.shippingAddress=t.shippingAddress?new b(t.shippingAddress,e$1):null,this.coupons=(t.coupons??[]).map(o=>new e(o)),this.shippingDetails=t.shippingDetails?a$2.deepClone(t.shippingDetails):null,this.total={subtotal:new a$3(t.total.subtotal),netSubtotal:new a$3(t.total.netSubtotal),lineItemTaxTotal:new a$3(t.total.lineItemTaxTotal||{amount:0,currency:t.currency}),lineItemTaxBreakdown:this.mapTaxBreakdown(t.total.lineItemTaxBreakdown||{}),chargesTotal:new a$3(t.total.chargesTotal||{amount:0,currency:t.currency}),shippingCharge:new a$3(t.total.shippingCharge),netShippingCharge:new a$3(t.total.netShippingCharge),chargeTaxTotal:new a$3(t.total.chargeTaxTotal||{amount:0,currency:t.currency}),chargeTaxBreakdown:this.mapTaxBreakdown(t.total.chargeTaxBreakdown||{}),taxTotal:new a$3(t.total.taxTotal),taxBreakdown:this.mapTaxBreakdown(t.total.taxBreakdown),discounts:Object.fromEntries(Object.entries(t.total.discounts).map(([o,s])=>[o,new a$3(s)])),totalDiscount:new a$3(t.total.totalDiscount),grandTotal:new a$3(t.total.grandTotal)};}mapTaxBreakdown(t){return Object.fromEntries(Object.entries(t||{}).map(([e,o])=>[e,{system:o.system,totalAmount:new a$3(o.totalAmount),subSystems:Object.fromEntries(Object.entries(o.subSystems).map(([s,n])=>[s,new a$3(n)]))}]))}serializeTaxBreakdown(t){return Object.fromEntries(Object.entries(t||{}).map(([e,o])=>[e,{system:o.system,totalAmount:o.totalAmount.getDetails(),subSystems:Object.fromEntries(Object.entries(o.subSystems).map(([s,n])=>[s,n.getDetails()]))}]))}getId(){return this.id}getCustomerId(){return this.customerId}getCustomerEmail(){return this.customerEmail}getAnonymousId(){return this.anonymousId}getLineItems(){return this.lineItems.map(t=>new a(t.getDetails()))}getLineItemsCount(){return this.lineItems.length}getCharges(){return this.charges.map(t=>new a$1(t.getDetails()))}addCharge(t){this.charges.push(t),this.calculateTotals();}clearCharges(){this.charges=[],this.calculateTotals();}getShippingDetails(){return this.shippingDetails?a$2.deepClone(this.shippingDetails):null}getShippingAddress(){return this.shippingAddress?new b(this.shippingAddress.getDetails()):null}hasShippingAddress(){return !!this.shippingAddress}hasBillingAddress(){return !!this.billingAddress}getBillingAddress(){return this.billingAddress?new b(this.billingAddress.getDetails()):null}getCoupons(){return [...this.coupons]}getCountry(){return this.country}getCurrency(){return this.currency}getLocale(){return this.locale}getTotal(){return {subtotal:this.total.subtotal,netSubtotal:this.total.netSubtotal,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}}])),chargesTotal:this.total.chargesTotal,shippingCharge:this.total.shippingCharge,netShippingCharge:this.total.netShippingCharge,chargeTaxTotal:this.total.chargeTaxTotal,chargeTaxBreakdown:Object.fromEntries(Object.entries(this.total.chargeTaxBreakdown).map(([t,e])=>[t,{system:e.system,totalAmount:e.totalAmount,subSystems:{...e.subSystems}}])),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}}])),discounts:{...this.total.discounts},totalDiscount:this.total.totalDiscount,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:{subtotal:t.subtotal.getDetails(),netSubtotal:t.netSubtotal.getDetails(),lineItemTaxTotal:t.lineItemTaxTotal.getDetails(),lineItemTaxBreakdown:this.serializeTaxBreakdown(t.lineItemTaxBreakdown),chargesTotal:t.chargesTotal.getDetails(),shippingCharge:t.shippingCharge.getDetails(),netShippingCharge:t.netShippingCharge.getDetails(),chargeTaxTotal:t.chargeTaxTotal.getDetails(),chargeTaxBreakdown:this.serializeTaxBreakdown(t.chargeTaxBreakdown),taxTotal:t.taxTotal.getDetails(),taxBreakdown:this.serializeTaxBreakdown(t.taxBreakdown),discounts:Object.fromEntries(Object.entries(t.discounts).map(([e,o])=>[e,o.getDetails()])),totalDiscount:t.totalDiscount.getDetails(),grandTotal:t.grandTotal.getDetails()},country:this.getCountry(),currency:this.getCurrency(),locale:this.getLocale()}}calculateTotals(){let t=new a$3({amount:0,currency:this.currency}),e=this.lineItems.filter(i=>i.getState()!=="CANCELLED"),o=e.reduce((i,a)=>i.add(a.getTotal().subtotal),t),s=e.reduce((i,a)=>i.add(a.getTotal().netSubtotal),t),n=this.charges.filter(i=>i.getChargeType()==="SHIPPING").reduce((i,a)=>i.add(a.getTotal().price),t),u=t,g={},h={};this.coupons.forEach(i=>{let a=i.calculateApplicableCouponDiscount(o,n,this.country,this.currency);u=u.add(a),g[i.getCode()]=a,i.getCategory()!=="SHIPPING"&&(h[i.getCode()]=a);}),this.applyDiscountsInLineItem(h);let l=this.coupons.find(i=>i.getCategory()==="SHIPPING");l?this.applyDiscuountsInShippingCharges({[l.getCode()]:g[l.getCode()]||t}):this.applyDiscuountsInShippingCharges({});let p=this.charges.reduce((i,a)=>i.add(a.getTotal().grandTotal),t),m=this.charges.filter(i=>i.getChargeType()==="SHIPPING").reduce((i,a)=>i.add(a.getTotal().grandTotal),t),y=t,b=t,S=t,d={},B={},M={},D=(i,a)=>{Object.entries(i).forEach(([O,T])=>{let r=T.system,C=T.subSystem;a[r]||(a[r]={system:r,totalAmount:t,subSystems:{}}),a[r].subSystems[C]?a[r].subSystems[C]=a[r].subSystems[C].add(T.amount):a[r].subSystems[C]=T.amount,a[r].totalAmount=a[r].totalAmount.add(T.amount),d[r]||(d[r]={system:r,totalAmount:t,subSystems:{}}),d[r].subSystems[C]?d[r].subSystems[C]=d[r].subSystems[C].add(T.amount):d[r].subSystems[C]=T.amount,d[r].totalAmount=d[r].totalAmount.add(T.amount);});};e.forEach(i=>{let a=i.getTotal().taxBreakdown;a&&(D(a,B),D(a,d),b=b.add(i.getTotal().taxTotal));}),this.charges.forEach(i=>{let a=i.getTotal().taxBreakdown;a&&(D(a,M),D(a,d),S=S.add(i.getTotal().taxTotal));}),y=b.add(S);let E=s.add(b).add(p);this.total={subtotal:o,netSubtotal:s,lineItemTaxTotal:b,lineItemTaxBreakdown:B,chargesTotal:p,shippingCharge:n,netShippingCharge:m,chargeTaxTotal:S,chargeTaxBreakdown:M,taxTotal:y,taxBreakdown:d,discounts:g,totalDiscount:u,grandTotal:E};}updateShippingDetails(t){this.shippingDetails=t,this.calculateTotals();}applyCoupons(t){let e=t.filter(s=>s.getCategory()==="SHIPPING"),o=t.filter(s=>s.getCategory()!=="SHIPPING");this.coupons=[],this.total.totalDiscount=this.total.subtotal.zero(),this.total.discounts={},o.length&&this.applyNonShippingCoupons(o),this.applyDiscountsInLineItem(this.total.discounts),e.length&&this.applyShippingCoupons(e),this.calculateTotals();}applyDiscountsInLineItem(t){let e=Array.from(Object.entries(t)).filter(s=>!s[1].isZero()),o=new Map;this.lineItems.forEach(s=>o.set(s.getId(),[])),e.forEach(([s,n])=>{let u=this.coupons.find(l=>l.getCode()===s);if(!u||n.isZero())return;let g=this.lineItems.filter(l=>l.getState()!=="CANCELLED"&&!l.getTotal().subtotal.isZero()).sort((l,p)=>l.getTotal().subtotal.compareTo(p.getTotal().subtotal)),h=new a$3({amount:0,currency:this.currency});g.forEach((l,p)=>{let m;p===g.length-1?m=n.subtract(h):m=n.multiply(l.getTotal().subtotal).divide(this.total.subtotal).round(),h=h.add(m),o.get(l.getId())?.push({coupon:u,amount:m});});}),this.lineItems.forEach(s=>{s.getState()==="CANCELLED"||this.total.subtotal.isZero()?s.updateDiscounts([]):s.updateDiscounts(o.get(s.getId())||[]);});}applyDiscuountsInShippingCharges(t){let e=Array.from(Object.entries(t)).filter(n=>!n[1].isZero()),o=this.charges.filter(n=>n.getChargeType()==="SHIPPING"),s=new Map;o.forEach(n=>s.set(n.getId(),[])),e.forEach(([n,u])=>{let g=this.coupons.find(p=>p.getCode()===n);if(!g||u.isZero())return;let h=o.sort((p,m)=>p.getTotal().grandTotal.compareTo(m.getTotal().grandTotal)),l=new a$3({amount:0,currency:this.currency});h.forEach((p,m)=>{let y;m===h.length-1?y=u.subtract(l):y=u.multiply(p.getTotal().grandTotal).divide(this.total.subtotal).round(),l=l.add(y),s.get(p.getId())?.push({coupon:g,amount:y});});}),o.forEach(n=>{n.updateDiscounts(s.get(n.getId())||[]);});}applyNonShippingCoupons(t){let e=t.filter(o=>o.getType()==="coupon");if(e.length===1){let o=e[0].calculateApplicableCouponDiscount(this.total.subtotal,this.total.shippingCharge,this.country,this.currency);o.getAmount()>0&&(this.coupons.push(e[0]),this.total.discounts[e[0].getCode()]=o,this.total.totalDiscount=o);}}applyShippingCoupons(t){if(this.total.shippingCharge.getAmount()>0&&t.length>0){let e=this.total.subtotal.subtract(this.total.totalDiscount),o=t.reduce((n,u)=>{if(!n)return u;let g=u.calculateApplicableCouponDiscount(e,this.total.shippingCharge,this.country,this.currency).min(this.total.shippingCharge),h=n.calculateApplicableCouponDiscount(e,this.total.shippingCharge,this.country,this.currency).min(this.total.shippingCharge);return g===h?u.getType()==="coupon"?u:n:g.compareTo(h)>0?u:n}),s=o.calculateApplicableCouponDiscount(e,this.total.shippingCharge,this.country,this.currency).min(this.total.shippingCharge);s.getAmount()>0&&(this.coupons.push(o),this.total.discounts[o.getCode()]=s,this.total.totalDiscount=this.total.totalDiscount.add(s),this.total.netShippingCharge=this.total.shippingCharge.subtract(s));}}};export{A as a};//# sourceMappingURL=chunk-URFRPQCT.mjs.map
2
- //# sourceMappingURL=chunk-URFRPQCT.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/Classes/ShoppingContainer.ts"],"names":["BaseShoppingContainerModel","BaseModel","data","date","item","LineItemModel","charge","ChargeModel","AddressModel","coupon","CouponModel","Utils_default","PriceModel","key","value","breakdown","systemKey","systemValue","subKey","subValue","totals","zero","filteredLineItems","lineitem","subTotal","total","lineItem","netSubtotal","shippingCharge","totalDiscount","discounts","nonShippingCouponTotal","couponValue","shippingCoupon","chargesTotal","netShippingCharge","taxTotal","lineItemTaxTotal","chargeTaxTotal","taxBreakdown","lineItemTaxBreakdown","chargeTaxBreakdown","mergeTax","sourceBreakdown","targetBreakdown","ruleId","system","subsystem","lineItemTaxes","chargeTaxes","grandTotal","shippingDetails","applicableCoupons","shippingCoupons","otherCoupons","couponTotal","couponDiscounts","couponDiscount","itemDiscounts","li","code","c","validItems","a","b","distributed","index","amount","shippingCharges","chargeDiscounts","validCharges","coupons","subTotalWithCouponDiscount","maxValuedCoupon","maxCoupon","currentCoupon","currentCouponValue","maxCouponValue"],"mappings":"qPAyH8BA,IAAAA,CAAAA,CAA9B,cAAiEC,CAAU,CAC/D,EAAA,CACA,UACA,CAAA,aAAA,CACA,WACA,CAAA,SAAA,CACA,OACA,CAAA,eAAA,CACA,eACA,CAAA,cAAA,CAGA,OAGA,CAAA,KAAA,CAEA,OACA,CAAA,QAAA,CACA,MAQV,CAAA,WAAA,CAAYC,CAAuCC,CAAAA,GAAAA,CAAa,IAAI,IAAA,CAAQ,CAC1E,KAAA,CAAMD,CAAMC,CAAAA,GAAI,CAChB,CAAA,IAAA,CAAK,GAAKD,CAAK,CAAA,EAAA,CACf,IAAK,CAAA,UAAA,CAAaA,CAAK,CAAA,UAAA,CACvB,IAAK,CAAA,aAAA,CAAgBA,CAAK,CAAA,aAAA,CAC1B,IAAK,CAAA,WAAA,CAAcA,CAAK,CAAA,WAAA,CACxB,IAAK,CAAA,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T.mjs","sourcesContent":["import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport AddressModel, { AddressData } from \"./Address\";\r\nimport LineItemModel, { LineItemData, LineItemTaxBreakdown, LineItemTaxBreakdownModel } from \"./LineItem\";\r\nimport { CountryCode, CurrencyCode, LocaleCode, ShippingDetails } from \"./Common\";\r\nimport PriceModel, { PriceData } from \"./Price\";\r\nimport CouponModel, { CouponCategory, CouponData, CouponType } from \"./Coupon\";\r\nimport Utils from \"../Utils\";\r\nimport { ChargeType, LineItemState, TaxSystem } from \"./Enum\";\r\nimport { FixedTaxRuleModel, TaxRuleModel } from \"./TaxRule\";\r\nimport ChargeModel, { ChargeData, ChargeTaxBreakdownModel } from \"./Charge\";\r\n\r\n/**\r\n * Breakdown of a specific tax system (e.g., GST, VAT) for the entire container.\r\n * Groups taxes by system and then by specific rule/subsystem.\r\n */\r\nexport type TaxSystemBreakdown = {\r\n /** Name of the tax system (e.g., GST) */\r\n system: TaxSystem;\r\n /** Total tax amount collected for this system across all line items and charges */\r\n totalAmount: PriceData;\r\n /** Detailed breakdown by rule/subsystem to total tax amount (e.g., CGST, SGST) */\r\n subSystems: Record<string, PriceData>;\r\n};\r\n\r\n/**\r\n * Internal model for tax system breakdown using PriceModel instances.\r\n */\r\nexport type TaxSystemBreakdownModel = {\r\n system: TaxSystem;\r\n totalAmount: PriceModel;\r\n subSystems: Record<string, PriceModel>;\r\n};\r\n\r\nexport type ShoppingContainerTaxBreakdownModel = Record<string, TaxSystemBreakdownModel>;\r\n\r\n/**\r\n * Comprehensive totals for a shopping container, logically grouped by source.\r\n */\r\nexport type ShoppingContainerTotal = {\r\n // --- Item Totals ---\r\n /** Sum of all line item prices before any discounts or taxes */\r\n subtotal: PriceData;\r\n /** Total item subtotal after item-level discounts have been applied (taxable base for items) */\r\n netSubtotal: PriceData;\r\n /** Total tax collected specifically from line items */\r\n lineItemTaxTotal: PriceData;\r\n /** Granular tax breakdown for all line items */\r\n lineItemTaxBreakdown: Record<string, TaxSystemBreakdown>;\r\n\r\n // --- Charge Totals ---\r\n /** Sum of all extra charges (shipping, processing, etc.) before tax */\r\n chargesTotal: PriceData;\r\n /** Specifically the shipping portion of charges */\r\n shippingCharge: PriceData;\r\n /** Shipping cost after any shipping-specific discounts */\r\n netShippingCharge: PriceData;\r\n /** Total tax collected specifically from charges */\r\n chargeTaxTotal: PriceData;\r\n /** Granular tax breakdown for all charges */\r\n chargeTaxBreakdown: Record<string, TaxSystemBreakdown>;\r\n\r\n // --- Aggregate Totals ---\r\n /** Combined total tax (lineItemTaxTotal + chargeTaxTotal) */\r\n taxTotal: PriceData;\r\n /** Combined granular tax breakdown for the entire container */\r\n taxBreakdown: Record<string, TaxSystemBreakdown>;\r\n /** Map of applied coupon codes to their calculated discount amounts */\r\n discounts: Record<string, PriceData>;\r\n /** Sum of all coupon discounts applied to the container */\r\n totalDiscount: PriceData;\r\n /** Final total amount to be paid (NetSubtotal + ChargesTotal + TaxTotal - (any remaining discounts)) */\r\n grandTotal: PriceData;\r\n};\r\n\r\n/**\r\n * Internal model version of ShoppingContainerTotal using PriceModel instances.\r\n */\r\nexport type ShoppingContainerTotalModel = {\r\n subtotal: PriceModel;\r\n netSubtotal: PriceModel;\r\n lineItemTaxTotal: PriceModel;\r\n lineItemTaxBreakdown: Record<string, TaxSystemBreakdownModel>;\r\n\r\n chargesTotal: PriceModel;\r\n shippingCharge: PriceModel;\r\n netShippingCharge: PriceModel;\r\n chargeTaxTotal: PriceModel;\r\n chargeTaxBreakdown: Record<string, TaxSystemBreakdownModel>;\r\n\r\n taxTotal: PriceModel;\r\n taxBreakdown: Record<string, TaxSystemBreakdownModel>;\r\n discounts: Record<string, PriceModel>;\r\n totalDiscount: PriceModel;\r\n grandTotal: PriceModel;\r\n};\r\n\r\n\r\nexport type BaseShoppingContainerAttributes = BaseAttributes & {\r\n id: string;\r\n customerId?: string;\r\n customerEmail?: string;\r\n anonymousId?: string;\r\n lineItems: LineItemData[];\r\n charges: ChargeData[];\r\n shippingDetails: ShippingDetails | null;\r\n shippingAddress?: AddressData | null;\r\n billingAddress?: AddressData | null;\r\n coupons: CouponData[];\r\n total: ShoppingContainerTotal;\r\n country: CountryCode;\r\n currency: CurrencyCode;\r\n locale: LocaleCode;\r\n};\r\n\r\nexport type BaseShoppingContainerData = BaseShoppingContainerAttributes & BaseData\r\n\r\n\r\n/**\r\n * Abstract base class for shopping-related containers like carts and orders.\r\n * Manages common elements such as line items, addresses, coupons, and totals.\r\n */\r\nexport default abstract class BaseShoppingContainerModel extends BaseModel {\r\n protected id: string;\r\n protected customerId?: string;\r\n protected customerEmail?: string;\r\n protected anonymousId?: string;\r\n protected lineItems: LineItemModel[];\r\n protected charges: ChargeModel[];\r\n protected shippingDetails: ShippingDetails | null;\r\n protected shippingAddress: AddressModel | null;\r\n protected billingAddress: AddressModel | null;\r\n\r\n // CouponsCodes\r\n protected coupons: CouponModel[];\r\n\r\n // Cart Totals\r\n protected total: ShoppingContainerTotalModel;\r\n\r\n protected country: CountryCode;\r\n protected currency: CurrencyCode;\r\n protected locale: LocaleCode;\r\n\r\n /**\r\n * Creates an instance of BaseShoppingContainerModel.\r\n * Initializes common properties and calculates initial base totals.\r\n * @param data - The initial attributes for the shopping container.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: BaseShoppingContainerAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.id = data.id;\r\n this.customerId = data.customerId;\r\n this.customerEmail = data.customerEmail;\r\n this.anonymousId = data.anonymousId;\r\n this.country = data.country;\r\n this.currency = data.currency;\r\n this.locale = data.locale;\r\n this.lineItems = (data.lineItems ?? []).map(item => new LineItemModel(item));\r\n this.charges = (data.charges ?? []).map(charge => new ChargeModel(charge));\r\n this.billingAddress = data.billingAddress ? new AddressModel(data.billingAddress, date) : null;\r\n this.shippingAddress = data.shippingAddress ? new AddressModel(data.shippingAddress, date) : null;\r\n this.coupons = (data.coupons ?? []).map(coupon => new CouponModel(coupon));\r\n\r\n this.shippingDetails = data.shippingDetails ? Utils.deepClone(data.shippingDetails) : null;\r\n\r\n this.total = {\r\n subtotal: new PriceModel(data.total.subtotal),\r\n netSubtotal: new PriceModel(data.total.netSubtotal),\r\n lineItemTaxTotal: new PriceModel(data.total.lineItemTaxTotal || { amount: 0, currency: data.currency }),\r\n lineItemTaxBreakdown: this.mapTaxBreakdown(data.total.lineItemTaxBreakdown || {}),\r\n\r\n chargesTotal: new PriceModel(data.total.chargesTotal || { amount: 0, currency: data.currency }),\r\n shippingCharge: new PriceModel(data.total.shippingCharge),\r\n netShippingCharge: new PriceModel(data.total.netShippingCharge),\r\n chargeTaxTotal: new PriceModel(data.total.chargeTaxTotal || { amount: 0, currency: data.currency }),\r\n chargeTaxBreakdown: this.mapTaxBreakdown(data.total.chargeTaxBreakdown || {}),\r\n\r\n taxTotal: new PriceModel(data.total.taxTotal),\r\n taxBreakdown: this.mapTaxBreakdown(data.total.taxBreakdown),\r\n discounts: Object.fromEntries(\r\n Object.entries(data.total.discounts).map(([key, value]) => [key, new PriceModel(value)])\r\n ),\r\n totalDiscount: new PriceModel(data.total.totalDiscount),\r\n grandTotal: new PriceModel(data.total.grandTotal),\r\n };\r\n }\r\n\r\n private mapTaxBreakdown(breakdown: Record<string, TaxSystemBreakdown>): Record<string, TaxSystemBreakdownModel> {\r\n return Object.fromEntries(\r\n Object.entries(breakdown || {}).map(([systemKey, systemValue]) => [\r\n systemKey,\r\n {\r\n system: systemValue.system,\r\n totalAmount: new PriceModel(systemValue.totalAmount),\r\n subSystems: Object.fromEntries(\r\n Object.entries(systemValue.subSystems).map(([subKey, subValue]) => [\r\n subKey,\r\n new PriceModel(subValue)\r\n ])\r\n )\r\n }\r\n ])\r\n );\r\n }\r\n\r\n private serializeTaxBreakdown(breakdown: Record<string, TaxSystemBreakdownModel>): Record<string, TaxSystemBreakdown> {\r\n return Object.fromEntries(\r\n Object.entries(breakdown || {}).map(([systemKey, systemValue]) => [\r\n systemKey,\r\n {\r\n system: systemValue.system,\r\n totalAmount: systemValue.totalAmount.getDetails(),\r\n subSystems: Object.fromEntries(\r\n Object.entries(systemValue.subSystems).map(([subKey, subValue]) => [\r\n subKey,\r\n subValue.getDetails()\r\n ])\r\n )\r\n }\r\n ])\r\n );\r\n }\r\n\r\n /**\r\n * Gets the unique identifier for this shopping container (cart ID or order ID).\r\n * @returns The ID string.\r\n */\r\n public getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the customer ID associated with this container, if available.\r\n * @returns The customer ID string, or undefined.\r\n */\r\n public getCustomerId(): string | undefined {\r\n return this.customerId;\r\n }\r\n\r\n /**\r\n * Gets the customer email associated with this container, if available.\r\n * @returns The customer email string, or undefined.\r\n */\r\n public getCustomerEmail(): string | undefined {\r\n return this.customerEmail;\r\n }\r\n\r\n /**\r\n * Gets the anonymous user ID associated with this container, if available.\r\n * @returns The anonymous ID string, or undefined.\r\n */\r\n public getAnonymousId(): string | undefined {\r\n return this.anonymousId;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the line items in the container.\r\n * Each item is a new LineItemModel instance created from the original's details.\r\n * @returns An array of LineItemModel instances.\r\n */\r\n public getLineItems(): LineItemModel[] {\r\n // Return new instances to prevent modification of internal state\r\n return this.lineItems.map(item => new LineItemModel(item.getDetails()));\r\n }\r\n\r\n /**\r\n * Gets current number of line items in the container.\r\n * @returns The count of line items.\r\n */\r\n public getLineItemsCount(): number {\r\n return this.lineItems.length;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the charges in the container.\r\n * @returns An array of ChargeModel instances.\r\n */\r\n public getCharges(): ChargeModel[] {\r\n return this.charges.map(charge => new ChargeModel(charge.getDetails()));\r\n }\r\n\r\n /**\r\n * Adds a new charge to the container and recalculates totals.\r\n * @param charge - The charge to add.\r\n */\r\n public addCharge(charge: ChargeModel): void {\r\n this.charges.push(charge);\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Clears all charges from the container and recalculates totals.\r\n */\r\n public clearCharges(): void {\r\n this.charges = [];\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Gets a copy of the shipping details associated with the container.\r\n * @returns A ShippingDetails object, or null if none are set.\r\n */\r\n public getShippingDetails(): ShippingDetails | null {\n return this.shippingDetails ? Utils.deepClone(this.shippingDetails) : null;\n }\n\r\n /**\r\n * Gets a defensive copy of the shipping address associated with the container.\r\n * Returns a new AddressModel instance created from the original's details.\r\n * @returns An AddressModel instance, or null if no shipping address is set.\r\n */\r\n public getShippingAddress(): AddressModel | null {\r\n return this.shippingAddress ? new AddressModel(this.shippingAddress.getDetails()) : null;\r\n }\r\n\r\n /**\r\n * Checks if a shipping address is associated with this container.\r\n * @returns True if a shipping address is set, false otherwise.\r\n */\r\n public hasShippingAddress(): boolean {\r\n return !!this.shippingAddress;\r\n }\r\n\r\n /**\r\n * Checks if a billing address is associated with this container.\r\n * @returns True if a billing address is set, false otherwise.\r\n */\r\n public hasBillingAddress(): boolean {\r\n return !!this.billingAddress;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the billing address associated with the container.\r\n * Returns a new AddressModel instance created from the original's details.\r\n * @returns An AddressModel instance, or null if no billing address is set.\r\n */\r\n public getBillingAddress(): AddressModel | null {\r\n return this.billingAddress ? new AddressModel(this.billingAddress.getDetails()) : null;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the coupons applied to the container.\r\n * Each item is a new CouponModel instance created from the original's details.\r\n * @returns An array of CouponModel instances.\r\n */\r\n public getCoupons(): CouponModel[] {\n return [...this.coupons];\n }\n\r\n /**\r\n * Gets the country code associated with this container.\r\n * @returns The CountryCode enum value.\r\n */\r\n public getCountry(): CountryCode {\r\n return this.country;\r\n }\r\n\r\n /**\r\n * Gets the currency code associated with this container.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode {\r\n return this.currency;\r\n }\r\n\r\n /**\r\n * Gets the locale code associated with this container.\r\n * @returns The LocaleCode enum value.\r\n */\r\n public getLocale(): LocaleCode {\r\n return this.locale;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the calculated totals for the container.\r\n * @returns An object containing shipping, subtotal, coupon, and grand totals.\r\n */\r\n public getTotal() {\n return {\n subtotal: this.total.subtotal,\n netSubtotal: this.total.netSubtotal,\n lineItemTaxTotal: this.total.lineItemTaxTotal,\n lineItemTaxBreakdown: Object.fromEntries(\n Object.entries(this.total.lineItemTaxBreakdown).map(([systemKey, systemValue]) => [\n systemKey,\n {\n system: systemValue.system,\n totalAmount: systemValue.totalAmount,\n subSystems: { ...systemValue.subSystems }\n }\n ])\n ),\n chargesTotal: this.total.chargesTotal,\n shippingCharge: this.total.shippingCharge,\n netShippingCharge: this.total.netShippingCharge,\n chargeTaxTotal: this.total.chargeTaxTotal,\n chargeTaxBreakdown: Object.fromEntries(\n Object.entries(this.total.chargeTaxBreakdown).map(([systemKey, systemValue]) => [\n systemKey,\n {\n system: systemValue.system,\n totalAmount: systemValue.totalAmount,\n subSystems: { ...systemValue.subSystems }\n }\n ])\n ),\n taxTotal: this.total.taxTotal,\n taxBreakdown: Object.fromEntries(\n Object.entries(this.total.taxBreakdown).map(([systemKey, systemValue]) => [\n systemKey,\n {\n system: systemValue.system,\n totalAmount: systemValue.totalAmount,\n subSystems: { ...systemValue.subSystems }\n }\n ])\n ),\n discounts: { ...this.total.discounts },\n totalDiscount: this.total.totalDiscount,\n grandTotal: this.total.grandTotal,\n };\n }\n\r\n /**\r\n * Gets a plain data object representing the shopping container's current state.\r\n * Includes details from the base model and specific container properties.\r\n * @returns BaseShoppingContainerData object suitable for serialization or API responses.\r\n */\r\n getDetails(): BaseShoppingContainerData {\r\n const totals = this.getTotal();\r\n return {\r\n ...super.getDetails(),\r\n id: this.getId(),\r\n customerId: this.getCustomerId(),\r\n customerEmail: this.getCustomerEmail(),\r\n anonymousId: this.getAnonymousId(),\r\n lineItems: this.getLineItems().map(item => item.getDetails()),\r\n charges: this.getCharges().map(charge => charge.getDetails()),\r\n shippingDetails: this.getShippingDetails(),\r\n shippingAddress: this.getShippingAddress()?.getDetails() || null,\r\n billingAddress: this.getBillingAddress()?.getDetails() || null,\r\n coupons: this.getCoupons().map(coupon => coupon.getDetails()),\r\n total: {\r\n // Item Totals\r\n subtotal: totals.subtotal.getDetails(),\r\n netSubtotal: totals.netSubtotal.getDetails(),\r\n lineItemTaxTotal: totals.lineItemTaxTotal.getDetails(),\r\n lineItemTaxBreakdown: this.serializeTaxBreakdown(totals.lineItemTaxBreakdown),\r\n\r\n // Charge Totals\r\n chargesTotal: totals.chargesTotal.getDetails(),\r\n shippingCharge: totals.shippingCharge.getDetails(),\r\n netShippingCharge: totals.netShippingCharge.getDetails(),\r\n chargeTaxTotal: totals.chargeTaxTotal.getDetails(),\r\n chargeTaxBreakdown: this.serializeTaxBreakdown(totals.chargeTaxBreakdown),\r\n\r\n // Aggregate Totals\r\n taxTotal: totals.taxTotal.getDetails(),\r\n taxBreakdown: this.serializeTaxBreakdown(totals.taxBreakdown),\r\n discounts: Object.fromEntries(\r\n Object.entries(totals.discounts).map(([key, value]) => [key, value.getDetails()])\r\n ),\r\n totalDiscount: totals.totalDiscount.getDetails(),\r\n grandTotal: totals.grandTotal.getDetails(),\r\n },\r\n country: this.getCountry(),\r\n currency: this.getCurrency(),\r\n locale: this.getLocale(),\r\n };\r\n }\r\n\r\n /**\r\n * Recalculates the total costs for the shopping container.\r\n * This includes summing line items, calculating shipping, applying coupons, and computing taxes.\r\n */\r\n public calculateTotals(): void {\r\n const zero = new PriceModel({ amount: 0, currency: this.currency });\r\n \r\n // 1. Calculate LineItem subtotals\r\n const filteredLineItems = this.lineItems.filter(lineitem => lineitem.getState() !== LineItemState.CANCELLED);\r\n const subTotal = filteredLineItems.reduce((total, lineItem) => total.add(lineItem.getTotal().subtotal), zero);\r\n const netSubtotal = filteredLineItems.reduce((total, lineItem) => total.add(lineItem.getTotal().netSubtotal), zero);\r\n\r\n // 2. Calculate Shipping Cost\r\n const shippingCharge = this.charges\r\n .filter(charge => charge.getChargeType() === ChargeType.SHIPPING)\r\n .reduce((total, charge) => total.add(charge.getTotal().price), zero);\r\n\r\n // 3. Calculate coupon values based on gross subtotal & shipping\r\n let totalDiscount = zero;\r\n let discounts: Record<string, PriceModel> = {};\r\n let nonShippingCouponTotal: Record<string, PriceModel> = {};\r\n this.coupons.forEach(coupon => {\r\n const couponValue = coupon.calculateApplicableCouponDiscount(subTotal, shippingCharge, this.country, this.currency);\r\n totalDiscount = totalDiscount.add(couponValue);\r\n discounts[coupon.getCode()] = couponValue;\r\n if (coupon.getCategory() !== CouponCategory.SHIPPING) {\r\n nonShippingCouponTotal[coupon.getCode()] = couponValue;\r\n }\r\n })\r\n\r\n // 4. Apply discounts at lineitem and shipping charges\r\n this.applyDiscountsInLineItem(nonShippingCouponTotal);\r\n\r\n const shippingCoupon = this.coupons.find(coupon => coupon.getCategory() === CouponCategory.SHIPPING);\r\n if(shippingCoupon) {\r\n this.applyDiscuountsInShippingCharges({[shippingCoupon.getCode()] : discounts[shippingCoupon.getCode()] || zero});\r\n } else {\r\n // If no shipping coupon, ensure any previous discounts on shipping charges are cleared\r\n this.applyDiscuountsInShippingCharges({});\r\n }\r\n\r\n // 5. Calculate charges and net shipping after discount\r\n const chargesTotal = this.charges.reduce((total, charge) => total.add(charge.getTotal().grandTotal), zero);\r\n const netShippingCharge = this.charges\r\n .filter(charge => charge.getChargeType() === ChargeType.SHIPPING)\r\n .reduce((total, charge) => total.add(charge.getTotal().grandTotal), zero);\r\n\r\n // 6. Aggregate Taxes & Grand Total from all items and charges\r\n let taxTotal = zero;\r\n let lineItemTaxTotal = zero;\r\n let chargeTaxTotal = zero;\r\n\r\n const taxBreakdown: ShoppingContainerTaxBreakdownModel = {};\r\n const lineItemTaxBreakdown: ShoppingContainerTaxBreakdownModel = {};\r\n const chargeTaxBreakdown: ShoppingContainerTaxBreakdownModel = {};\r\n\r\n // Helper to merge tax breakdowns into hierarchical structure\r\n const mergeTax = (\r\n sourceBreakdown: Record<string, LineItemTaxBreakdownModel | ChargeTaxBreakdownModel>,\r\n targetBreakdown: ShoppingContainerTaxBreakdownModel\r\n ) => {\r\n Object.entries(sourceBreakdown).forEach(([ruleId, breakdown]) => {\r\n const system = breakdown.system;\r\n const subsystem = breakdown.subSystem;\r\n\r\n // Populate Target Breakdown\r\n if (!targetBreakdown[system]) {\r\n targetBreakdown[system] = { system, totalAmount: zero, subSystems: {} };\r\n }\r\n if (!targetBreakdown[system].subSystems[subsystem]) {\r\n targetBreakdown[system].subSystems[subsystem] = breakdown.amount;\r\n } else {\r\n targetBreakdown[system].subSystems[subsystem] = targetBreakdown[system].subSystems[subsystem].add(breakdown.amount);\r\n }\r\n targetBreakdown[system].totalAmount = targetBreakdown[system].totalAmount.add(breakdown.amount);\r\n\r\n // Populate Combined taxBreakdown\r\n if (!taxBreakdown[system]) {\r\n taxBreakdown[system] = { system, totalAmount: zero, subSystems: {} };\r\n }\r\n if (!taxBreakdown[system].subSystems[subsystem]) {\r\n taxBreakdown[system].subSystems[subsystem] = breakdown.amount;\r\n } else {\r\n taxBreakdown[system].subSystems[subsystem] = taxBreakdown[system].subSystems[subsystem].add(breakdown.amount);\r\n }\r\n taxBreakdown[system].totalAmount = taxBreakdown[system].totalAmount.add(breakdown.amount);\r\n });\r\n };\r\n\r\n // 6.1 Merge line item taxes\r\n filteredLineItems.forEach(lineItem => {\r\n const lineItemTaxes = lineItem.getTotal().taxBreakdown;\r\n if (lineItemTaxes) {\r\n mergeTax(lineItemTaxes, lineItemTaxBreakdown);\r\n mergeTax(lineItemTaxes, taxBreakdown);\r\n lineItemTaxTotal = lineItemTaxTotal.add(lineItem.getTotal().taxTotal);\r\n }\r\n });\r\n\r\n // 6.2 Merge charge taxes\r\n this.charges.forEach(charge => {\r\n const chargeTaxes = charge.getTotal().taxBreakdown;\r\n if (chargeTaxes) {\r\n mergeTax(chargeTaxes, chargeTaxBreakdown);\r\n mergeTax(chargeTaxes, taxBreakdown);\r\n chargeTaxTotal = chargeTaxTotal.add(charge.getTotal().taxTotal);\r\n }\r\n });\r\n\r\n // 6.3 Calculate total tax\r\n taxTotal = lineItemTaxTotal.add(chargeTaxTotal);\r\n\r\n // 7. Final Grand Total: netSubtotal + netShippingCharge + taxTotal\r\n const grandTotal = netSubtotal.add(lineItemTaxTotal).add(chargesTotal);\r\n\r\n this.total = {\r\n subtotal: subTotal,\r\n netSubtotal: netSubtotal,\r\n lineItemTaxTotal: lineItemTaxTotal,\r\n lineItemTaxBreakdown: lineItemTaxBreakdown,\r\n\r\n chargesTotal: chargesTotal,\r\n shippingCharge: shippingCharge,\r\n netShippingCharge: netShippingCharge,\r\n chargeTaxTotal: chargeTaxTotal,\r\n chargeTaxBreakdown: chargeTaxBreakdown,\r\n\r\n taxTotal: taxTotal,\r\n taxBreakdown: taxBreakdown,\r\n discounts: discounts,\r\n totalDiscount: totalDiscount,\r\n grandTotal: grandTotal,\r\n };\r\n }\r\n\r\n /**\r\n * Updates the shipping details and recalculates the totals.\r\n * @param shippingDetails - The new shipping details to apply.\r\n */\r\n public updateShippingDetails(shippingDetails: ShippingDetails): void {\r\n this.shippingDetails = shippingDetails;\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Applies a list of coupons to the shopping container.\r\n * Filters out invalid coupons, separates shipping and non-shipping coupons,\r\n * and distributes discounts to line items.\r\n * @param applicableCoupons - The list of coupons to attempt to apply.\r\n */\r\n public applyCoupons(applicableCoupons: CouponModel[]): void {\r\n //Apply coupons\r\n const shippingCoupons = applicableCoupons.filter(coupon => coupon.getCategory() === CouponCategory.SHIPPING);\r\n const otherCoupons = applicableCoupons.filter(coupon => coupon.getCategory() !== CouponCategory.SHIPPING);\r\n\r\n this.coupons = [];\r\n this.total.totalDiscount = this.total.subtotal.zero();\r\n this.total.discounts = {};\r\n // Apply non shipping coupons\r\n otherCoupons.length && this.applyNonShippingCoupons(otherCoupons);\r\n this.applyDiscountsInLineItem(this.total.discounts);\r\n\r\n // Apply shipping coupons\r\n shippingCoupons.length && this.applyShippingCoupons(shippingCoupons);\r\n\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Distributes the total discount amount among the line items.\r\n * @param couponTotal - A record of coupon codes and their calculated discount amounts.\r\n */\r\n private applyDiscountsInLineItem(couponTotal: Record<string, PriceModel>) {\r\n const couponDiscounts: [string, PriceModel][] = Array.from(Object.entries(couponTotal))\r\n .filter(couponDiscount => !couponDiscount[1].isZero());\r\n\r\n const itemDiscounts = new Map<string, { coupon: CouponModel, amount: PriceModel }[]>();\r\n this.lineItems.forEach(li => itemDiscounts.set(li.getId(), []));\r\n\r\n couponDiscounts.forEach(([code, totalDiscount]) => {\r\n const coupon = this.coupons.find(c => c.getCode() === code);\r\n if (!coupon || totalDiscount.isZero()) return;\r\n\r\n const validItems = this.lineItems\r\n .filter(li => li.getState() !== LineItemState.CANCELLED && !li.getTotal().subtotal.isZero())\r\n .sort((a, b) => a.getTotal().subtotal.compareTo(b.getTotal().subtotal));\r\n\r\n let distributed = new PriceModel({ amount: 0, currency: this.currency });\r\n\r\n validItems.forEach((item, index) => {\r\n let amount: PriceModel;\r\n if (index === validItems.length - 1) {\r\n amount = totalDiscount.subtract(distributed);\r\n } else {\r\n amount = totalDiscount.multiply(item.getTotal().subtotal).divide(this.total.subtotal).round();\r\n }\r\n distributed = distributed.add(amount);\r\n itemDiscounts.get(item.getId())?.push({ coupon, amount });\r\n });\r\n });\r\n\r\n this.lineItems.forEach(lineItem => {\r\n if (lineItem.getState() === LineItemState.CANCELLED || this.total.subtotal.isZero()) {\r\n lineItem.updateDiscounts([]);\r\n } else {\r\n lineItem.updateDiscounts(itemDiscounts.get(lineItem.getId()) || []);\r\n }\r\n });\r\n }\r\n\r\n private applyDiscuountsInShippingCharges(couponTotal: Record<string, PriceModel>) {\r\n const couponDiscounts: [string, PriceModel][] = Array.from(Object.entries(couponTotal))\r\n .filter(couponDiscount => !couponDiscount[1].isZero());\r\n const shippingCharges = this.charges.filter(charge => charge.getChargeType() === ChargeType.SHIPPING);\r\n\r\n const chargeDiscounts = new Map<string, { coupon: CouponModel, amount: PriceModel }[]>();\r\n shippingCharges.forEach(li => chargeDiscounts.set(li.getId(), []));\r\n\r\n couponDiscounts.forEach(([code, totalDiscount]) => {\r\n const coupon = this.coupons.find(c => c.getCode() === code);\r\n if (!coupon || totalDiscount.isZero()) return;\r\n\r\n const validCharges = shippingCharges\r\n .sort((a, b) => a.getTotal().grandTotal.compareTo(b.getTotal().grandTotal));\r\n\r\n let distributed = new PriceModel({ amount: 0, currency: this.currency });\r\n\r\n validCharges.forEach((charge, index) => {\r\n let amount: PriceModel;\r\n if (index === validCharges.length - 1) {\r\n amount = totalDiscount.subtract(distributed);\r\n } else {\r\n amount = totalDiscount.multiply(charge.getTotal().grandTotal).divide(this.total.subtotal).round();\r\n }\r\n distributed = distributed.add(amount);\r\n chargeDiscounts.get(charge.getId())?.push({ coupon, amount });\r\n });\r\n });\r\n\r\n shippingCharges.forEach(charge => {\r\n charge.updateDiscounts(chargeDiscounts.get(charge.getId()) || []);\r\n });\r\n }\r\n\r\n /**\r\n * Selects and applies the best applicable non-shipping coupon.\r\n * Currently supports applying only a single coupon of type COUPON.\r\n * @param applicableCoupons - List of available non-shipping coupons.\r\n */\r\n private applyNonShippingCoupons(applicableCoupons: CouponModel[]) {\r\n const coupons = applicableCoupons.filter(coupon => coupon.getType() === CouponType.COUPON);\r\n if (coupons.length === 1) {\r\n const couponValue = coupons[0].calculateApplicableCouponDiscount(this.total.subtotal, this.total.shippingCharge, this.country, this.currency);\r\n if (couponValue.getAmount() > 0) {\r\n this.coupons.push(coupons[0]);\r\n this.total.discounts[coupons[0].getCode()] = couponValue;\r\n this.total.totalDiscount = couponValue;\r\n }\r\n }\r\n // Todo: Add support to other type in future like promotion\r\n }\r\n\r\n /**\r\n * Selects and applies the best applicable shipping coupon.\r\n * @param applicableCoupons - List of available shipping coupons.\r\n */\r\n private applyShippingCoupons(applicableCoupons: CouponModel[]) {\r\n if (this.total.shippingCharge.getAmount() > 0 && applicableCoupons.length > 0) {\r\n const subTotalWithCouponDiscount = this.total.subtotal.subtract(this.total.totalDiscount);\r\n\r\n const maxValuedCoupon = applicableCoupons.reduce((maxCoupon, currentCoupon) => {\r\n if (!maxCoupon) return currentCoupon;\r\n\r\n const currentCouponValue = currentCoupon.calculateApplicableCouponDiscount(subTotalWithCouponDiscount, this.total.shippingCharge, this.country, this.currency).min(this.total.shippingCharge);\r\n const maxCouponValue = maxCoupon.calculateApplicableCouponDiscount(subTotalWithCouponDiscount, this.total.shippingCharge, this.country, this.currency).min(this.total.shippingCharge);\r\n\r\n if (currentCouponValue === maxCouponValue) {\r\n return currentCoupon.getType() === 'coupon' ? currentCoupon : maxCoupon;\r\n }\r\n return currentCouponValue.compareTo(maxCouponValue) > 0 ? currentCoupon : maxCoupon;\r\n });\r\n\r\n const couponValue = maxValuedCoupon.calculateApplicableCouponDiscount(subTotalWithCouponDiscount, this.total.shippingCharge, this.country, this.currency).min(this.total.shippingCharge);\r\n if (couponValue.getAmount() > 0) {\r\n this.coupons.push(maxValuedCoupon);\r\n this.total.discounts[maxValuedCoupon.getCode()] = couponValue;\r\n this.total.totalDiscount = this.total.totalDiscount.add(couponValue);\r\n this.total.netShippingCharge = this.total.shippingCharge.subtract(couponValue);\r\n }\r\n }\r\n }\r\n}\r\n\r\n\r\n"]}