@foxy.io/elements 1.34.0 → 1.35.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/dist/cdn/foxy-access-recovery-form.js +1 -1
  2. package/dist/cdn/foxy-address-card.js +1 -1
  3. package/dist/cdn/foxy-address-form.js +1 -1
  4. package/dist/cdn/foxy-admin-subscription-card.js +1 -1
  5. package/dist/cdn/foxy-admin-subscription-form.js +1 -1
  6. package/dist/cdn/foxy-api-browser.js +1 -1
  7. package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
  8. package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
  9. package/dist/cdn/foxy-applied-tax-card.js +1 -1
  10. package/dist/cdn/foxy-attribute-card.js +1 -1
  11. package/dist/cdn/foxy-attribute-form.js +1 -1
  12. package/dist/cdn/foxy-billing-address-card.js +1 -1
  13. package/dist/cdn/foxy-cancellation-form.js +1 -1
  14. package/dist/cdn/foxy-cart-card.js +1 -1
  15. package/dist/cdn/foxy-cart-form.js +1 -1
  16. package/dist/cdn/foxy-client-card.js +1 -1
  17. package/dist/cdn/foxy-client-form.js +1 -1
  18. package/dist/cdn/foxy-collection-page.js +1 -1
  19. package/dist/cdn/foxy-collection-pages.js +1 -1
  20. package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
  21. package/dist/cdn/foxy-coupon-card.js +1 -1
  22. package/dist/cdn/foxy-coupon-code-card.js +1 -1
  23. package/dist/cdn/foxy-coupon-code-form.js +1 -1
  24. package/dist/cdn/foxy-coupon-codes-form.js +1 -1
  25. package/dist/cdn/foxy-coupon-detail-card.js +1 -1
  26. package/dist/cdn/foxy-coupon-form.js +1 -1
  27. package/dist/cdn/foxy-custom-field-card.js +1 -1
  28. package/dist/cdn/foxy-custom-field-form.js +1 -1
  29. package/dist/cdn/foxy-customer-card.js +1 -1
  30. package/dist/cdn/foxy-customer-form.js +1 -1
  31. package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
  32. package/dist/cdn/foxy-customer-portal-settings.js +1 -1
  33. package/dist/cdn/foxy-customer-portal.js +2 -2
  34. package/dist/cdn/foxy-customer.js +1 -1
  35. package/dist/cdn/foxy-customers-table.js +1 -1
  36. package/dist/cdn/foxy-discount-builder.js +1 -1
  37. package/dist/cdn/foxy-discount-card.js +1 -1
  38. package/dist/cdn/foxy-discount-detail-card.js +1 -1
  39. package/dist/cdn/foxy-donation.js +1 -1
  40. package/dist/cdn/foxy-downloadable-card.js +1 -1
  41. package/dist/cdn/foxy-downloadable-form.js +1 -1
  42. package/dist/cdn/foxy-email-template-card.js +1 -1
  43. package/dist/cdn/foxy-email-template-form.js +1 -1
  44. package/dist/cdn/foxy-error-entry-card.js +1 -1
  45. package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -0
  46. package/dist/cdn/foxy-filter-attribute-card.js +1 -1
  47. package/dist/cdn/foxy-filter-attribute-form.js +1 -1
  48. package/dist/cdn/foxy-form-dialog.js +1 -1
  49. package/dist/cdn/foxy-generate-codes-form.js +1 -1
  50. package/dist/cdn/foxy-gift-card-card.js +1 -1
  51. package/dist/cdn/foxy-gift-card-code-card.js +1 -1
  52. package/dist/cdn/foxy-gift-card-code-form.js +1 -1
  53. package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
  54. package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
  55. package/dist/cdn/foxy-gift-card-form.js +1 -1
  56. package/dist/cdn/foxy-i18n-editor.js +1 -1
  57. package/dist/cdn/foxy-i18n.js +1 -1
  58. package/dist/cdn/foxy-integration-card.js +1 -1
  59. package/dist/cdn/foxy-integration-form.js +1 -1
  60. package/dist/cdn/foxy-item-card.js +1 -1
  61. package/dist/cdn/foxy-item-category-card.js +1 -1
  62. package/dist/cdn/foxy-item-category-form.js +1 -1
  63. package/dist/cdn/foxy-item-form.js +1 -1
  64. package/dist/cdn/foxy-item-option-card.js +1 -1
  65. package/dist/cdn/foxy-item-option-form.js +1 -1
  66. package/dist/cdn/foxy-items-form.js +1 -1
  67. package/dist/cdn/foxy-native-integration-card.js +1 -1
  68. package/dist/cdn/foxy-native-integration-form.js +1 -1
  69. package/dist/cdn/foxy-nucleon-element.js +1 -1
  70. package/dist/cdn/foxy-pagination.js +1 -1
  71. package/dist/cdn/foxy-passkey-card.js +1 -1
  72. package/dist/cdn/foxy-passkey-form.js +1 -1
  73. package/dist/cdn/foxy-payment-card-embed.js +1 -1
  74. package/dist/cdn/foxy-payment-card.js +1 -1
  75. package/dist/cdn/foxy-payment-method-card.js +1 -1
  76. package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
  77. package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
  78. package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
  79. package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
  80. package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
  81. package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
  82. package/dist/cdn/foxy-payments-api.js +1 -1
  83. package/dist/cdn/foxy-query-builder.js +1 -1
  84. package/dist/cdn/foxy-report-form.js +1 -1
  85. package/dist/cdn/foxy-reports-table.js +1 -1
  86. package/dist/cdn/foxy-shipment-card.js +1 -1
  87. package/dist/cdn/foxy-shipping-container-card.js +1 -1
  88. package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
  89. package/dist/cdn/foxy-shipping-method-card.js +1 -1
  90. package/dist/cdn/foxy-shipping-service-card.js +1 -1
  91. package/dist/cdn/foxy-sign-in-form.js +1 -1
  92. package/dist/cdn/foxy-spinner.js +2 -2
  93. package/dist/cdn/foxy-store-card.js +1 -1
  94. package/dist/cdn/foxy-store-form.js +1 -1
  95. package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
  96. package/dist/cdn/foxy-subscription-card.js +1 -1
  97. package/dist/cdn/foxy-subscription-form.js +1 -1
  98. package/dist/cdn/foxy-subscription-settings-form.js +1 -1
  99. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  100. package/dist/cdn/foxy-table.js +1 -1
  101. package/dist/cdn/foxy-tax-card.js +1 -1
  102. package/dist/cdn/foxy-tax-form.js +1 -1
  103. package/dist/cdn/foxy-template-config-form.js +1 -1
  104. package/dist/cdn/foxy-template-form.js +1 -1
  105. package/dist/cdn/foxy-template-set-card.js +1 -1
  106. package/dist/cdn/foxy-template-set-form.js +1 -1
  107. package/dist/cdn/foxy-transaction-card.js +1 -1
  108. package/dist/cdn/foxy-transaction.js +1 -1
  109. package/dist/cdn/foxy-transactions-table.js +7 -7
  110. package/dist/cdn/foxy-update-payment-method-form.js +1 -1
  111. package/dist/cdn/foxy-user-card.js +1 -1
  112. package/dist/cdn/foxy-user-form.js +1 -1
  113. package/dist/cdn/foxy-user-invitation-card.js +1 -1
  114. package/dist/cdn/foxy-user-invitation-form.js +1 -1
  115. package/dist/cdn/foxy-users-table.js +1 -1
  116. package/dist/cdn/foxy-webhook-card.js +1 -1
  117. package/dist/cdn/foxy-webhook-form.js +1 -1
  118. package/dist/cdn/foxy-webhook-log-card.js +1 -1
  119. package/dist/cdn/foxy-webhook-status-card.js +1 -1
  120. package/dist/cdn/{shared-126cb82b.js → shared-018166d0.js} +1 -1
  121. package/dist/cdn/{shared-8e73014c.js → shared-01f85a69.js} +1 -1
  122. package/dist/cdn/{shared-e9e2fd3f.js → shared-066fb69f.js} +1 -1
  123. package/dist/cdn/{shared-1b5f155f.js → shared-0ae33cf9.js} +1 -1
  124. package/dist/cdn/{shared-d735fc99.js → shared-0e2a0b21.js} +1 -1
  125. package/dist/cdn/{shared-4f216dc1.js → shared-112e521b.js} +1 -1
  126. package/dist/cdn/{shared-6cf39826.js → shared-1c4ddc9b.js} +1 -1
  127. package/dist/cdn/{shared-f8252d03.js → shared-238d397f.js} +1 -1
  128. package/dist/cdn/{shared-370be17b.js → shared-257389e5.js} +4 -4
  129. package/dist/cdn/{shared-a86480c5.js → shared-27e2e59a.js} +1 -1
  130. package/dist/cdn/{shared-527eb17e.js → shared-28b0e29a.js} +1 -1
  131. package/dist/cdn/{shared-869ed25d.js → shared-297e8531.js} +1 -1
  132. package/dist/cdn/{shared-e8df4368.js → shared-2cb3cb3a.js} +1 -1
  133. package/dist/cdn/{shared-851b96ae.js → shared-2f02918d.js} +1 -1
  134. package/dist/cdn/{shared-fceaef95.js → shared-31d8e958.js} +1 -1
  135. package/dist/cdn/{shared-bbd2a4e6.js → shared-32440b17.js} +1 -1
  136. package/dist/cdn/{shared-5245b330.js → shared-363dce45.js} +1 -1
  137. package/dist/cdn/{shared-b62fb09f.js → shared-3713f047.js} +1 -1
  138. package/dist/cdn/shared-44118acb.js +1 -0
  139. package/dist/cdn/shared-44fd89ce.js +1 -0
  140. package/dist/cdn/{shared-e0b00e0f.js → shared-4c4b87c2.js} +1 -1
  141. package/dist/cdn/{shared-3efc6649.js → shared-504f3c65.js} +1 -1
  142. package/dist/cdn/{shared-a34983ea.js → shared-51fd39fa.js} +1 -1
  143. package/dist/cdn/{shared-f57e1679.js → shared-525c1936.js} +1 -1
  144. package/dist/cdn/{shared-16766722.js → shared-53caa399.js} +1 -1
  145. package/dist/cdn/{shared-e6379bd1.js → shared-573d6e21.js} +1 -1
  146. package/dist/cdn/{shared-ae68261f.js → shared-57a98543.js} +1 -1
  147. package/dist/cdn/{shared-3e25035f.js → shared-5d308dd7.js} +1 -1
  148. package/dist/cdn/{shared-e766f6e0.js → shared-5e0b71a2.js} +1 -1
  149. package/dist/cdn/shared-67898669.js +1 -0
  150. package/dist/cdn/{shared-1838736d.js → shared-68fdcf24.js} +1 -1
  151. package/dist/cdn/{shared-f378fe25.js → shared-6de0e9f3.js} +1 -1
  152. package/dist/cdn/{shared-d806ec21.js → shared-70487b4c.js} +1 -1
  153. package/dist/cdn/{shared-7cfd461d.js → shared-7889f2f2.js} +1 -1
  154. package/dist/cdn/{shared-a83e33cd.js → shared-80688cd4.js} +1 -1
  155. package/dist/cdn/{shared-9e9bec09.js → shared-80a7903f.js} +1 -1
  156. package/dist/cdn/{shared-74d9b3d4.js → shared-84761b5b.js} +1 -1
  157. package/dist/cdn/{shared-0db6454a.js → shared-8af5a4f2.js} +1 -1
  158. package/dist/cdn/{shared-1df36027.js → shared-8b838d83.js} +1 -1
  159. package/dist/cdn/{shared-6c4a5133.js → shared-95a7dab8.js} +1 -1
  160. package/dist/cdn/{shared-c176c4fa.js → shared-96886940.js} +1 -1
  161. package/dist/cdn/{shared-6a63a308.js → shared-9f97643d.js} +1 -1
  162. package/dist/cdn/{shared-9421c0d7.js → shared-9fcd36e5.js} +1 -1
  163. package/dist/cdn/{shared-6cf0c762.js → shared-a585bfd3.js} +1 -1
  164. package/dist/cdn/shared-a7617e76.js +1 -0
  165. package/dist/cdn/{shared-0d0fe9c0.js → shared-ab26c69f.js} +1 -1
  166. package/dist/cdn/{shared-46de2ed2.js → shared-b04e9753.js} +1 -1
  167. package/dist/cdn/{shared-a4953186.js → shared-b0d76785.js} +1 -1
  168. package/dist/cdn/{shared-a24264e6.js → shared-b16829cd.js} +1 -1
  169. package/dist/cdn/{shared-7e1768cf.js → shared-b1fa0b61.js} +1 -1
  170. package/dist/cdn/{shared-85803aca.js → shared-b77e1a8a.js} +1 -1
  171. package/dist/cdn/{shared-e8b8c8d0.js → shared-bb3c9e23.js} +1 -1
  172. package/dist/cdn/{shared-7d234de2.js → shared-c5326ab8.js} +1 -1
  173. package/dist/cdn/{shared-921e3f1e.js → shared-c532d615.js} +1 -1
  174. package/dist/cdn/{shared-c1f4a6ef.js → shared-c5cb7e8a.js} +1 -1
  175. package/dist/cdn/{shared-2b6b735d.js → shared-c7740aa2.js} +1 -1
  176. package/dist/cdn/{shared-e7069b0f.js → shared-ce055dce.js} +1 -1
  177. package/dist/cdn/{shared-dbc9aff0.js → shared-cf0ca582.js} +1 -1
  178. package/dist/cdn/{shared-bec65d6d.js → shared-d3a5cb85.js} +2 -2
  179. package/dist/cdn/{shared-23aa2506.js → shared-d973155b.js} +1 -1
  180. package/dist/cdn/{shared-4e6c65e6.js → shared-da393323.js} +1 -1
  181. package/dist/cdn/{shared-0293eba8.js → shared-e77d8d01.js} +1 -1
  182. package/dist/cdn/{shared-2fd6e530.js → shared-eadddff6.js} +1 -1
  183. package/dist/cdn/{shared-51fd3fc6.js → shared-eb7bf7ba.js} +1 -1
  184. package/dist/cdn/{shared-7040eef3.js → shared-ebc72d69.js} +1 -1
  185. package/dist/cdn/{shared-9c479921.js → shared-ec5b614e.js} +1 -1
  186. package/dist/cdn/{shared-a7524277.js → shared-fc6bcfc5.js} +1 -1
  187. package/dist/cdn/{shared-2ddb119e.js → shared-ffc84c84.js} +1 -1
  188. package/dist/cdn/translations/experimental-add-to-cart-builder/en.json +558 -0
  189. package/dist/elements/internal/InternalEditableControl/InternalEditableControl.js +21 -6
  190. package/dist/elements/internal/InternalEditableControl/InternalEditableControl.js.map +1 -1
  191. package/dist/elements/internal/InternalSummaryControl/InternalSummaryControl.d.ts +5 -2
  192. package/dist/elements/internal/InternalSummaryControl/InternalSummaryControl.js +61 -1
  193. package/dist/elements/internal/InternalSummaryControl/InternalSummaryControl.js.map +1 -1
  194. package/dist/elements/public/CustomerPortal/InternalCustomerPortalLoggedOutView.js +1 -0
  195. package/dist/elements/public/CustomerPortal/InternalCustomerPortalLoggedOutView.js.map +1 -1
  196. package/dist/elements/public/ExperimentalAddToCartBuilder/ExperimentalAddToCartBuilder.d.ts +52 -0
  197. package/dist/elements/public/ExperimentalAddToCartBuilder/ExperimentalAddToCartBuilder.js +887 -0
  198. package/dist/elements/public/ExperimentalAddToCartBuilder/ExperimentalAddToCartBuilder.js.map +1 -0
  199. package/dist/elements/public/ExperimentalAddToCartBuilder/index.d.ts +16 -0
  200. package/dist/elements/public/ExperimentalAddToCartBuilder/index.js +18 -0
  201. package/dist/elements/public/ExperimentalAddToCartBuilder/index.js.map +1 -0
  202. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/InternalExperimentalAddToCartBuilderCustomOptionCard.d.ts +6 -0
  203. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/InternalExperimentalAddToCartBuilderCustomOptionCard.js +14 -0
  204. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/InternalExperimentalAddToCartBuilderCustomOptionCard.js.map +1 -0
  205. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/index.d.ts +3 -0
  206. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/index.js +5 -0
  207. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/index.js.map +1 -0
  208. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/types.d.ts +11 -0
  209. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/types.js +2 -0
  210. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionCard/types.js.map +1 -0
  211. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/InternalExperimentalAddToCartBuilderCustomOptionForm.d.ts +21 -0
  212. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/InternalExperimentalAddToCartBuilderCustomOptionForm.js +123 -0
  213. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/InternalExperimentalAddToCartBuilderCustomOptionForm.js.map +1 -0
  214. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/index.d.ts +9 -0
  215. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/index.js +11 -0
  216. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/index.js.map +1 -0
  217. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/types.d.ts +11 -0
  218. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/types.js +2 -0
  219. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderCustomOptionForm/types.js.map +1 -0
  220. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderItemControl/InternalExperimentalAddToCartBuilderItemControl.d.ts +15 -0
  221. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderItemControl/InternalExperimentalAddToCartBuilderItemControl.js +397 -0
  222. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderItemControl/InternalExperimentalAddToCartBuilderItemControl.js.map +1 -0
  223. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderItemControl/index.d.ts +19 -0
  224. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderItemControl/index.js +21 -0
  225. package/dist/elements/public/ExperimentalAddToCartBuilder/internal/InternalExperimentalAddToCartBuilderItemControl/index.js.map +1 -0
  226. package/dist/elements/public/ExperimentalAddToCartBuilder/preview.css.d.ts +2 -0
  227. package/dist/elements/public/ExperimentalAddToCartBuilder/preview.css.js +153 -0
  228. package/dist/elements/public/ExperimentalAddToCartBuilder/preview.css.js.map +1 -0
  229. package/dist/elements/public/ExperimentalAddToCartBuilder/types.d.ts +59 -0
  230. package/dist/elements/public/ExperimentalAddToCartBuilder/types.js +2 -0
  231. package/dist/elements/public/ExperimentalAddToCartBuilder/types.js.map +1 -0
  232. package/dist/elements/public/NucleonElement/API.js +3 -1
  233. package/dist/elements/public/NucleonElement/API.js.map +1 -1
  234. package/dist/elements/public/index.d.ts +1 -0
  235. package/dist/elements/public/index.defined.d.ts +1 -0
  236. package/dist/elements/public/index.defined.js +1 -0
  237. package/dist/elements/public/index.defined.js.map +1 -1
  238. package/dist/elements/public/index.js +1 -0
  239. package/dist/elements/public/index.js.map +1 -1
  240. package/dist/mixins/themeable.js +32 -0
  241. package/dist/mixins/themeable.js.map +1 -1
  242. package/package.json +3 -2
  243. package/dist/cdn/shared-0fe1dd67.js +0 -1
  244. package/dist/cdn/shared-41072bad.js +0 -1
  245. package/dist/cdn/shared-88bfb7f5.js +0 -1
  246. package/dist/cdn/shared-c518ece2.js +0 -1
@@ -0,0 +1,887 @@
1
+ import { TranslatableMixin } from "../../../mixins/translatable.js";
2
+ import { ResponsiveMixin } from "../../../mixins/responsive.js";
3
+ import { BooleanSelector } from '@foxy.io/sdk/core';
4
+ import { decode, encode } from 'html-entities';
5
+ import { InternalForm } from "../../internal/InternalForm/InternalForm.js";
6
+ import { previewCSS } from './preview.css';
7
+ import { html, svg } from 'lit-element';
8
+ import { ifDefined } from 'lit-html/directives/if-defined';
9
+ import { classMap } from "../../../utils/class-map.js";
10
+ import debounce from 'lodash-es/debounce';
11
+ const NS = 'experimental-add-to-cart-builder';
12
+ const Base = ResponsiveMixin(TranslatableMixin(InternalForm, NS));
13
+ /**
14
+ * WARNING: this element is marked as experimental and is subject to change in future releases.
15
+ * We will not be maintaining backwards compatibility for elements in the experimental namespace.
16
+ * If you are using this element, please make sure to use a fixed version of the package in your `package.json`.
17
+ *
18
+ * This element allows you to create an add-to-cart form and link for your store.
19
+ *
20
+ * @element foxy-experimental-add-to-cart-builder
21
+ */
22
+ export class ExperimentalAddToCartBuilder extends Base {
23
+ constructor() {
24
+ super(...arguments);
25
+ /** Default host domain for stores that don't use a custom domain name, e.g. `foxycart.com`. */
26
+ this.defaultDomain = null;
27
+ /** URL of the HMAC encoder endpoint. */
28
+ this.encodeHelper = null;
29
+ /** URL of the `fx:locale_codes` property helper. This will be used to determine the currency code. */
30
+ this.localeCodes = null;
31
+ /** URL of the store this add-to-cart code is created for. */
32
+ this.store = null;
33
+ this.__signingSeparator = `--${Date.now()}${(Math.random() * 100000).toFixed(0)}--`;
34
+ this.__emptyOptions = [
35
+ { label: 'option_false', value: 'false' },
36
+ { label: 'option_true', value: 'true' },
37
+ { label: 'option_reset', value: 'reset' },
38
+ ];
39
+ this.__cartOptions = [
40
+ { label: 'option_add', value: 'add' },
41
+ { label: 'option_checkout', value: 'checkout' },
42
+ { label: 'option_redirect', value: 'redirect' },
43
+ ];
44
+ this.__signAsync = debounce(async (html, encodeHelper) => {
45
+ if (html === this.__previousUnsignedCode && this.__previousSignedCode)
46
+ return;
47
+ const isCancelled = () => html !== this.__previousUnsignedCode;
48
+ this.__signingState = 'busy';
49
+ try {
50
+ const res = await new ExperimentalAddToCartBuilder.API(this).fetch(encodeHelper, {
51
+ headers: { 'Content-Type': 'text/plain' },
52
+ method: 'POST',
53
+ body: html,
54
+ });
55
+ if (!isCancelled()) {
56
+ if (res.ok) {
57
+ const result = (await res.json()).result;
58
+ if (!isCancelled()) {
59
+ this.__signingState = 'idle';
60
+ this.__previousSignedCode = result.replace(/value="--OPEN--" data-replace/gi, 'value');
61
+ }
62
+ }
63
+ else {
64
+ this.__signingState = 'fail';
65
+ }
66
+ }
67
+ }
68
+ catch (_a) {
69
+ if (!isCancelled())
70
+ this.__signingState = 'fail';
71
+ }
72
+ }, 500);
73
+ this.__previousUnsignedCode = '';
74
+ this.__previousSignedCode = '';
75
+ this.__signingState = 'idle';
76
+ this.__openState = [];
77
+ }
78
+ static get properties() {
79
+ return {
80
+ ...super.properties,
81
+ defaultDomain: { attribute: 'default-domain' },
82
+ encodeHelper: { attribute: 'encode-helper' },
83
+ localeCodes: { attribute: 'locale-codes' },
84
+ store: {},
85
+ __previousUnsignedCode: { attribute: false },
86
+ __previousSignedCode: { attribute: false },
87
+ __signingState: { attribute: false },
88
+ __openState: { attribute: false },
89
+ };
90
+ }
91
+ get hiddenSelector() {
92
+ const alwaysMatch = [super.hiddenSelector.toString()];
93
+ alwaysMatch.unshift('header:copy-id', 'header:copy-json', 'undo');
94
+ return new BooleanSelector(alwaysMatch.join(' ').trim());
95
+ }
96
+ renderBody() {
97
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
98
+ const addToCartCode = this.__getAddToCartCode();
99
+ const storeUrl = (_c = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a._links['fx:store'].href) !== null && _b !== void 0 ? _b : this.store) !== null && _c !== void 0 ? _c : void 0;
100
+ const store = (_d = this.__storeLoader) === null || _d === void 0 ? void 0 : _d.data;
101
+ return html `
102
+ <div class="grid gap-m items-start sm-grid-cols-2 md-grid-cols-3 h-full overflow-auto">
103
+ <foxy-internal-summary-control layout="section" class="space-y-s" infer="items">
104
+ ${(_e = this.form.items) === null || _e === void 0 ? void 0 : _e.map((product, index) => {
105
+ var _a;
106
+ return html `
107
+ <foxy-internal-summary-control
108
+ layout="details"
109
+ label=${ifDefined(product.name.trim() || void 0)}
110
+ infer="item-group"
111
+ ?open=${ifDefined(this.__openState[index])}
112
+ @toggle=${(evt) => {
113
+ const details = evt.currentTarget;
114
+ this.__openState[index] = details.open;
115
+ this.__openState = [...this.__openState];
116
+ }}
117
+ >
118
+ <foxy-internal-experimental-add-to-cart-builder-item-control
119
+ item-categories=${ifDefined(store === null || store === void 0 ? void 0 : store._links['fx:item_categories'].href)}
120
+ currency-code=${ifDefined((_a = this.__resolvedCurrencyCode) !== null && _a !== void 0 ? _a : void 0)}
121
+ store=${ifDefined(storeUrl)}
122
+ index=${index}
123
+ infer="item"
124
+ .defaultItemCategory=${this.__defaultItemCategory}
125
+ @remove=${() => {
126
+ var _a;
127
+ const newProducts = (_a = this.form.items) === null || _a === void 0 ? void 0 : _a.filter((_, i) => i !== index);
128
+ this.edit({ items: newProducts });
129
+ this.__openState = this.__openState.filter((_, i) => i !== index);
130
+ }}
131
+ >
132
+ </foxy-internal-experimental-add-to-cart-builder-item-control>
133
+ </foxy-internal-summary-control>
134
+ `;
135
+ })}
136
+
137
+ <vaadin-button
138
+ class="w-full"
139
+ theme="success"
140
+ ?disabled=${this.disabled}
141
+ @click=${() => {
142
+ var _a;
143
+ const newItem = { name: '', price: 0, custom_options: [], sub_frequency: '1m' };
144
+ const existingItems = (_a = this.form.items) !== null && _a !== void 0 ? _a : [];
145
+ this.edit({ items: [...existingItems, newItem] });
146
+ this.__openState = [...new Array(existingItems.length).fill(false), true];
147
+ }}
148
+ >
149
+ <foxy-i18n infer="add-product" key="caption"></foxy-i18n>
150
+ </vaadin-button>
151
+ </foxy-internal-summary-control>
152
+
153
+ <div class="space-y-m md-col-span-2 sticky top-0">
154
+ ${addToCartCode
155
+ ? html `
156
+ <foxy-internal-summary-control infer="preview">
157
+ <div class="flex">
158
+ <iframe
159
+ srcdoc="${previewCSS}${addToCartCode.formHTML}"
160
+ style="margin: calc(-1 * (0.625em + (var(--lumo-border-radius) / 4) - 1px))"
161
+ class=${classMap({
162
+ 'flex-1 transition-all filter': true,
163
+ 'blur-sm': this.__signingState !== 'idle',
164
+ })}
165
+ @load=${(evt) => {
166
+ var _a;
167
+ const iframe = evt.currentTarget;
168
+ const root = (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document.documentElement;
169
+ if (root)
170
+ iframe.style.height = root.scrollHeight + 'px';
171
+ }}
172
+ >
173
+ </iframe>
174
+ </div>
175
+
176
+ <div
177
+ class="flex leading-s text-s min-w-0 relative"
178
+ style="gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
179
+ >
180
+ <div
181
+ style="font-family: monospace; max-height: calc(8 * (1em * var(--lumo-line-height-s)))"
182
+ class=${classMap({
183
+ 'break-all overflow-auto flex-1 min-w-0 transition-all filter': true,
184
+ 'blur-sm': this.__signingState !== 'idle',
185
+ })}
186
+ >
187
+ <code class="whitespace-pre">${addToCartCode.formHTML}</code>
188
+ </div>
189
+
190
+ <div
191
+ style="top: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px); right: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
192
+ class=${classMap({
193
+ 'absolute right-0 bg-base rounded-s transition-opacity': true,
194
+ 'opacity-0 pointer-events-none': this.__signingState !== 'busy',
195
+ })}
196
+ >
197
+ <div class="bg-contrast-10 rounded-s">
198
+ <foxy-spinner infer="spinner" class="-mx-xs" style="transform: scale(0.8)">
199
+ </foxy-spinner>
200
+ </div>
201
+ </div>
202
+
203
+ <foxy-copy-to-clipboard
204
+ infer="copy-to-clipboard"
205
+ text=${addToCartCode.formHTML}
206
+ class=${classMap({
207
+ 'flex-shrink-0 text-m transition-opacity': true,
208
+ 'opacity-0 pointer-events-none': this.__signingState === 'busy',
209
+ })}
210
+ >
211
+ </foxy-copy-to-clipboard>
212
+ </div>
213
+
214
+ <div
215
+ class="flex items-start text-xs leading-xs text-secondary"
216
+ style="gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
217
+ >
218
+ ${svg `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-contrast-70" style="width: 1.25em"><path fill-rule="evenodd" d="M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0ZM9 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM6.75 8a.75.75 0 0 0 0 1.5h.75v1.75a.75.75 0 0 0 1.5 0v-2.5A.75.75 0 0 0 8.25 8h-1.5Z" clip-rule="evenodd" /></svg>`}
219
+ <p>
220
+ <foxy-i18n infer="" key="edits_tip"></foxy-i18n>
221
+ <a
222
+ target="_blank"
223
+ class="rounded font-medium underline transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50"
224
+ href="https://wiki.foxycart.com/v/2.0/products"
225
+ >
226
+ <foxy-i18n infer="" key="edits_docs"></foxy-i18n>
227
+ </a>
228
+ </p>
229
+ </div>
230
+ </foxy-internal-summary-control>
231
+
232
+ <foxy-internal-summary-control infer="link">
233
+ ${addToCartCode.linkHref
234
+ ? html `
235
+ <div
236
+ class="flex items-center leading-s min-w-0 relative"
237
+ style="gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
238
+ >
239
+ <foxy-i18n infer="" key="direct_link"></foxy-i18n>
240
+ <a
241
+ target="_blank"
242
+ style="max-width: 30rem"
243
+ href=${addToCartCode.linkHref}
244
+ class=${classMap({
245
+ 'font-medium truncate ml-auto min-w-0 rounded-s': true,
246
+ 'transition-all filter': true,
247
+ 'hover-underline': true,
248
+ 'focus-outline-none focus-ring-2 focus-ring-primary-50': true,
249
+ 'blur-sm': this.__signingState !== 'idle',
250
+ })}
251
+ >
252
+ ${addToCartCode.linkHref}
253
+ </a>
254
+ <div
255
+ style="top: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px); right: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
256
+ class=${classMap({
257
+ 'absolute right-0 bg-base rounded-s transition-opacity': true,
258
+ 'opacity-0 pointer-events-none': this.__signingState !== 'busy',
259
+ })}
260
+ >
261
+ <div class="bg-contrast-10 rounded-s">
262
+ <foxy-spinner
263
+ infer="spinner"
264
+ state=${this.__signingState === 'fail' ? 'error' : 'busy'}
265
+ class="-mx-xs"
266
+ style="transform: scale(0.8)"
267
+ >
268
+ </foxy-spinner>
269
+ </div>
270
+ </div>
271
+ <foxy-copy-to-clipboard
272
+ infer="copy-to-clipboard"
273
+ text=${addToCartCode.linkHref}
274
+ class=${classMap({
275
+ 'flex-shrink-0 text-m transition-opacity': true,
276
+ 'opacity-0 pointer-events-none': this.__signingState === 'busy',
277
+ })}
278
+ >
279
+ </foxy-copy-to-clipboard>
280
+ </div>
281
+ `
282
+ : html `
283
+ <p class="text-disabled">
284
+ <foxy-i18n infer="" key="unavailable"></foxy-i18n>
285
+ </p>
286
+ `}
287
+ </foxy-internal-summary-control>
288
+ `
289
+ : html `
290
+ <foxy-internal-summary-control infer="preview">
291
+ <div class="flex items-center justify-center p-xl">
292
+ <foxy-spinner infer="unavailable"></foxy-spinner>
293
+ </div>
294
+ </foxy-internal-summary-control>
295
+ `}
296
+
297
+ <foxy-internal-summary-control infer="cart-settings">
298
+ <foxy-internal-resource-picker-control
299
+ layout="summary-item"
300
+ first=${ifDefined((_g = (_f = this.__storeLoader) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g._links['fx:template_sets'].href)}
301
+ infer="template-set-uri"
302
+ item="foxy-template-set-card"
303
+ >
304
+ </foxy-internal-resource-picker-control>
305
+
306
+ <foxy-internal-select-control
307
+ layout="summary-item"
308
+ infer="empty"
309
+ .options=${this.__emptyOptions}
310
+ >
311
+ </foxy-internal-select-control>
312
+
313
+ <foxy-internal-select-control
314
+ layout="summary-item"
315
+ infer="cart"
316
+ .options=${this.__cartOptions}
317
+ >
318
+ </foxy-internal-select-control>
319
+
320
+ ${this.form.cart === 'redirect'
321
+ ? html `
322
+ <foxy-internal-text-control layout="summary-item" infer="redirect">
323
+ </foxy-internal-text-control>
324
+ `
325
+ : ''}
326
+
327
+ <foxy-internal-text-control layout="summary-item" infer="coupon">
328
+ </foxy-internal-text-control>
329
+ </foxy-internal-summary-control>
330
+ </div>
331
+ </div>
332
+
333
+ <foxy-nucleon
334
+ class="hidden"
335
+ infer=""
336
+ href=${ifDefined(this.__defaultTemplateSetHref)}
337
+ id="defaultTemplateSetLoader"
338
+ @update=${() => this.requestUpdate()}
339
+ >
340
+ </foxy-nucleon>
341
+
342
+ <foxy-nucleon
343
+ class="hidden"
344
+ infer=""
345
+ href=${ifDefined(this.__defaultItemCategoryHref)}
346
+ id="defaultItemCategoryLoader"
347
+ @update=${() => this.requestUpdate()}
348
+ >
349
+ </foxy-nucleon>
350
+
351
+ <foxy-nucleon
352
+ class="hidden"
353
+ infer=""
354
+ href=${ifDefined((_h = this.localeCodes) !== null && _h !== void 0 ? _h : void 0)}
355
+ id="localeCodesHelperLoader"
356
+ @update=${() => this.requestUpdate()}
357
+ >
358
+ </foxy-nucleon>
359
+
360
+ <foxy-nucleon
361
+ class="hidden"
362
+ infer=""
363
+ href=${ifDefined((_j = this.form.template_set_uri) !== null && _j !== void 0 ? _j : void 0)}
364
+ id="templateSetLoader"
365
+ @update=${() => this.requestUpdate()}
366
+ >
367
+ </foxy-nucleon>
368
+
369
+ <foxy-nucleon
370
+ class="hidden"
371
+ infer=""
372
+ href=${ifDefined((_m = (_l = (_k = this.data) === null || _k === void 0 ? void 0 : _k._links['fx:store'].href) !== null && _l !== void 0 ? _l : this.store) !== null && _m !== void 0 ? _m : void 0)}
373
+ id="storeLoaderId"
374
+ @update=${() => this.requestUpdate()}
375
+ >
376
+ </foxy-nucleon>
377
+
378
+ ${(_o = this.form.items) === null || _o === void 0 ? void 0 : _o.map((product, index) => {
379
+ var _a;
380
+ return html `
381
+ <foxy-nucleon
382
+ class="hidden"
383
+ infer=""
384
+ href=${ifDefined((_a = product.item_category_uri) !== null && _a !== void 0 ? _a : void 0)}
385
+ id="itemCategoryLoaderProduct${index}"
386
+ @update=${() => this.requestUpdate()}
387
+ >
388
+ </foxy-nucleon>
389
+
390
+ ${product.custom_options.map((option, i) => {
391
+ var _a;
392
+ return html `
393
+ <foxy-nucleon
394
+ class="hidden"
395
+ infer=""
396
+ href=${ifDefined((_a = option.item_category_uri) !== null && _a !== void 0 ? _a : void 0)}
397
+ id="itemCategoryLoaderProduct${index}Option${i}"
398
+ @update=${() => this.requestUpdate()}
399
+ >
400
+ </foxy-nucleon>
401
+ `;
402
+ })}
403
+ `;
404
+ })}
405
+ `;
406
+ }
407
+ updated(changes) {
408
+ var _a, _b;
409
+ super.updated(changes);
410
+ if (this.in('idle') && !((_a = this.form.items) === null || _a === void 0 ? void 0 : _a.length)) {
411
+ this.edit({ items: [{ name: '', price: 0, sub_frequency: '1m', custom_options: [] }] });
412
+ this.__openState = [true];
413
+ }
414
+ if (((_b = this.form.items) === null || _b === void 0 ? void 0 : _b.length) && !this.__openState.length) {
415
+ this.__openState = [true, ...new Array(this.form.items.length - 1).fill(false)];
416
+ }
417
+ }
418
+ submit() {
419
+ // Do nothing – this form is not meant to be submitted.
420
+ }
421
+ get __defaultTemplateSetHref() {
422
+ var _a, _b, _c;
423
+ try {
424
+ const url = new URL((_c = (_b = (_a = this.__storeLoader) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b._links['fx:template_sets'].href) !== null && _c !== void 0 ? _c : '');
425
+ url.searchParams.set('code', 'DEFAULT');
426
+ return url.toString();
427
+ }
428
+ catch (_d) {
429
+ return undefined;
430
+ }
431
+ }
432
+ get __defaultItemCategoryHref() {
433
+ var _a, _b, _c;
434
+ try {
435
+ const url = new URL((_c = (_b = (_a = this.__storeLoader) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b._links['fx:item_categories'].href) !== null && _c !== void 0 ? _c : '');
436
+ url.searchParams.set('code', 'DEFAULT');
437
+ return url.toString();
438
+ }
439
+ catch (_d) {
440
+ return undefined;
441
+ }
442
+ }
443
+ get __resolvedCurrencyCode() {
444
+ var _a, _b, _c, _d;
445
+ const localeCodesLoader = this.renderRoot.querySelector('#localeCodesHelperLoader');
446
+ const currentLocale = (_a = this.__resolvedTemplateSet) === null || _a === void 0 ? void 0 : _a.locale_code;
447
+ const allLocales = (_b = localeCodesLoader === null || localeCodesLoader === void 0 ? void 0 : localeCodesLoader.data) === null || _b === void 0 ? void 0 : _b.values;
448
+ const localeInfo = currentLocale ? allLocales === null || allLocales === void 0 ? void 0 : allLocales[currentLocale] : void 0;
449
+ return localeInfo ? (_d = (_c = /Currency: ([A-Z]{3})/g.exec(localeInfo)) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.toUpperCase() : void 0;
450
+ }
451
+ get __resolvedTemplateSet() {
452
+ var _a, _b, _c, _d;
453
+ const $ = (s) => this.renderRoot.querySelector(s);
454
+ return ((_b = (_a = $('#templateSetLoader')) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : (_d = (_c = $('#defaultTemplateSetLoader')) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d._embedded['fx:template_sets'][0]);
455
+ }
456
+ get __defaultItemCategory() {
457
+ var _a, _b;
458
+ return (_b = (_a = this.renderRoot.querySelector('#defaultItemCategoryLoader')) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b._embedded['fx:item_categories'][0];
459
+ }
460
+ get __resolvedCartUrl() {
461
+ var _a;
462
+ const store = (_a = this.__storeLoader) === null || _a === void 0 ? void 0 : _a.data;
463
+ if (store) {
464
+ if (store.use_remote_domain) {
465
+ return `https://${store.store_domain}/cart`;
466
+ }
467
+ else if (this.defaultDomain !== null) {
468
+ return `https://${store.store_domain}.${this.defaultDomain}/cart`;
469
+ }
470
+ }
471
+ return null;
472
+ }
473
+ get __storeLoader() {
474
+ return this.renderRoot.querySelector('#storeLoaderId');
475
+ }
476
+ __getItemCategoryLoader(productIndex, optionIndex) {
477
+ const prefix = `#itemCategoryLoaderProduct${productIndex}`;
478
+ const selector = typeof optionIndex === 'number' ? `${prefix}Option${optionIndex}` : prefix;
479
+ return this.renderRoot.querySelector(selector);
480
+ }
481
+ __getAddToCartFormHTML() {
482
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
483
+ const currencyCode = this.__resolvedCurrencyCode;
484
+ const templateSet = this.__resolvedTemplateSet;
485
+ const cartUrl = this.__resolvedCartUrl;
486
+ const store = (_a = this.__storeLoader) === null || _a === void 0 ? void 0 : _a.data;
487
+ if (!this.defaultDomain || !templateSet || !store || !currencyCode || !cartUrl)
488
+ return '';
489
+ let hasAtLeastOneFieldset = false;
490
+ let output = `<form action="${encode(cartUrl)}" method="post" target="_blank">`;
491
+ let level = 1;
492
+ const newline = () => `\n${' '.repeat(level * 2)}`;
493
+ const addHiddenInput = (name, value) => {
494
+ const encodedValue = encode(value);
495
+ const encodedName = encode(name);
496
+ output += `${newline()}<input type="hidden" name="${encodedName}" value="${encodedValue}">`;
497
+ };
498
+ if (templateSet.code !== 'DEFAULT')
499
+ addHiddenInput('template_set', templateSet.code);
500
+ if (this.form.empty && this.form.empty !== 'false')
501
+ addHiddenInput('empty', this.form.empty);
502
+ if (this.form.cart === 'checkout')
503
+ addHiddenInput('cart', 'checkout');
504
+ if (this.form.redirect)
505
+ addHiddenInput('redirect', this.form.redirect);
506
+ if (this.form.coupon)
507
+ addHiddenInput('coupon', this.form.coupon);
508
+ const items = (_b = this.form.items) !== null && _b !== void 0 ? _b : [];
509
+ const hasMoreThanOneProduct = items.length > 1;
510
+ for (let productIndex = 0; productIndex < items.length; ++productIndex) {
511
+ const itemCategoryLoader = this.__getItemCategoryLoader(productIndex);
512
+ const itemCategory = itemCategoryLoader === null || itemCategoryLoader === void 0 ? void 0 : itemCategoryLoader.data;
513
+ const product = items[productIndex];
514
+ if (product.item_category_uri && !itemCategory)
515
+ return '';
516
+ const resolvedMinQty = Math.max(1, (_c = product.quantity_min) !== null && _c !== void 0 ? _c : 1);
517
+ const resolvedMaxQty = Math.max(resolvedMinQty, (_d = product.quantity_max) !== null && _d !== void 0 ? _d : Infinity);
518
+ const varyQty = resolvedMinQty !== resolvedMaxQty &&
519
+ product.expires_format !== 'minutes' &&
520
+ !product.hide_quantity;
521
+ const varyPrice = product.price_configurable;
522
+ const varyptions = product.custom_options.some((v, i, a) => v.value_configurable || a.findIndex(vv => vv.name === v.name) !== i);
523
+ const resolvedName = product.name.trim() || this.t('items.item-group.item.basics-group.name.placeholder');
524
+ const needsFieldset = hasAtLeastOneFieldset || (hasMoreThanOneProduct && (varyPrice || varyQty || varyptions));
525
+ if (needsFieldset) {
526
+ hasAtLeastOneFieldset = true;
527
+ output += `${newline()}<fieldset>`;
528
+ level++;
529
+ output += `${newline()}<legend>${encode(resolvedName)}</legend>`;
530
+ }
531
+ const prefix = productIndex === 0 ? '' : `${productIndex + 1}:`;
532
+ addHiddenInput(`${prefix}name`, resolvedName);
533
+ const price = `${product.price}${currencyCode}`;
534
+ if (product.price_configurable) {
535
+ const encodedNoCurrencyPrice = encode(product.price.toFixed(2));
536
+ output += `${newline()}<label>`;
537
+ level++;
538
+ output += `${newline()}<span>${encode(this.t('preview.price_label'))}</span>`;
539
+ if (store.use_cart_validation) {
540
+ output += `${newline()}<input required name="${prefix}price" value="--OPEN--" data-replace="${encodedNoCurrencyPrice}">`;
541
+ }
542
+ else {
543
+ output += `${newline()}<input required name="${prefix}price" value="${encodedNoCurrencyPrice}">`;
544
+ }
545
+ level--;
546
+ output += `${newline()}</label>`;
547
+ }
548
+ else {
549
+ addHiddenInput(`${prefix}price`, price);
550
+ }
551
+ if (itemCategory && itemCategory.code !== 'DEFAULT') {
552
+ addHiddenInput(`${prefix}category`, itemCategory.code);
553
+ }
554
+ if (product.code)
555
+ addHiddenInput(`${prefix}code`, product.code);
556
+ if (product.parent_code)
557
+ addHiddenInput(`${prefix}parent_code`, product.parent_code);
558
+ if (product.image) {
559
+ addHiddenInput(`${prefix}image`, product.image);
560
+ if (product.url)
561
+ addHiddenInput(`${prefix}url`, product.url);
562
+ }
563
+ if (product.sub_enabled) {
564
+ if (product.sub_frequency) {
565
+ addHiddenInput(`${prefix}sub_frequency`, product.sub_frequency);
566
+ if (product.sub_startdate) {
567
+ if (product.sub_startdate_format === 'yyyymmdd') {
568
+ const date = new Date(product.sub_startdate);
569
+ const year = date.getFullYear();
570
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
571
+ const day = date.getDate().toString().padStart(2, '0');
572
+ addHiddenInput(`${prefix}sub_startdate`, `${year}${month}${day}`);
573
+ }
574
+ else {
575
+ addHiddenInput(`${prefix}sub_startdate`, String(product.sub_startdate));
576
+ }
577
+ }
578
+ if (product.sub_enddate) {
579
+ if (product.sub_enddate_format === 'yyyymmdd') {
580
+ const date = new Date(product.sub_enddate);
581
+ const year = date.getFullYear();
582
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
583
+ const day = date.getDate().toString().padStart(2, '0');
584
+ addHiddenInput(`${prefix}sub_enddate`, `${year}${month}${day}`);
585
+ }
586
+ else {
587
+ addHiddenInput(`${prefix}sub_enddate`, String(product.sub_enddate));
588
+ }
589
+ }
590
+ }
591
+ }
592
+ if (product.discount_name && product.discount_type && product.discount_details) {
593
+ addHiddenInput(`${prefix}discount_${product.discount_type}`, `${product.discount_name}{${product.discount_details}}`);
594
+ }
595
+ if (product.expires_value) {
596
+ if (product.expires_format === 'timestamp') {
597
+ addHiddenInput(`${prefix}expires`, product.expires_value.toFixed(0));
598
+ }
599
+ else {
600
+ addHiddenInput(`${prefix}expires`, product.expires_value.toFixed(0));
601
+ }
602
+ }
603
+ if (varyQty) {
604
+ output += `${newline()}<label>`;
605
+ level++;
606
+ output += `${newline()}<span>${encode(this.t('preview.quantity_label'))}</span>`;
607
+ output += `${newline()}<input type="number" name="${encode(`${prefix}quantity`)}"`;
608
+ output += ` min="${encode(String(resolvedMinQty))}"`;
609
+ if (resolvedMaxQty !== Infinity)
610
+ output += ` max="${encode(String(resolvedMaxQty))}"`;
611
+ if (store.use_cart_validation) {
612
+ output += ` value="--OPEN--" data-replace="${encode(String((_e = product.quantity) !== null && _e !== void 0 ? _e : 1))}">`;
613
+ }
614
+ else {
615
+ output += ` value="${encode(String((_f = product.quantity) !== null && _f !== void 0 ? _f : 1))}">`;
616
+ }
617
+ level--;
618
+ output += `${newline()}</label>`;
619
+ }
620
+ else if (((_g = product.quantity) !== null && _g !== void 0 ? _g : 1) > 1) {
621
+ addHiddenInput(`${prefix}quantity`, ((_h = product.quantity) !== null && _h !== void 0 ? _h : 1).toString());
622
+ }
623
+ if (product.expires_format !== 'minutes') {
624
+ if (resolvedMinQty !== 1) {
625
+ addHiddenInput(`${prefix}quantity_min`, resolvedMinQty.toFixed(0));
626
+ }
627
+ if (resolvedMaxQty !== Infinity) {
628
+ addHiddenInput(`${prefix}quantity_max`, resolvedMaxQty.toFixed(0));
629
+ }
630
+ }
631
+ if (product.length)
632
+ addHiddenInput(`${prefix}length`, product.length.toFixed(3));
633
+ if (product.width)
634
+ addHiddenInput(`${prefix}width`, product.width.toFixed(3));
635
+ if (product.height)
636
+ addHiddenInput(`${prefix}height`, product.height.toFixed(3));
637
+ if (product.weight)
638
+ addHiddenInput(`${prefix}weight`, product.weight.toFixed(3));
639
+ if (store.features_multiship) {
640
+ output += `${newline()}<label>`;
641
+ level++;
642
+ output += `${newline()}<span>${encode(this.t('preview.shipto_label'))}</span>`;
643
+ if (store.use_cart_validation) {
644
+ output += `${newline()}<input name="${prefix}shipto" value="--OPEN--" data-replace="">`;
645
+ }
646
+ else {
647
+ output += `${newline()}<input name="${prefix}shipto" value="">`;
648
+ }
649
+ level--;
650
+ output += `${newline()}</label>`;
651
+ }
652
+ const groupedCustomOptions = product.custom_options.reduce((acc, option) => {
653
+ if (!acc[option.name])
654
+ acc[option.name] = [];
655
+ acc[option.name].push(option);
656
+ return acc;
657
+ }, {});
658
+ for (const optionName in groupedCustomOptions) {
659
+ const group = groupedCustomOptions[optionName];
660
+ if (group.length === 1) {
661
+ const optionIndex = product.custom_options.indexOf(group[0]);
662
+ const itemCategory = (_j = this.__getItemCategoryLoader(productIndex, optionIndex)) === null || _j === void 0 ? void 0 : _j.data;
663
+ const modifiers = this.__getOptionModifiers(group[0], itemCategory !== null && itemCategory !== void 0 ? itemCategory : null, currencyCode);
664
+ const value = `${group[0].value}${modifiers}`;
665
+ const name = `${prefix}${optionName}`;
666
+ if (group[0].value_configurable) {
667
+ output += `${newline()}<label>`;
668
+ level++;
669
+ output += `${newline()}<span>${encode(optionName)}:</span>`;
670
+ output += `${newline()}<input name="${encode(name)}" `;
671
+ if (store.use_cart_validation) {
672
+ output += `value="--OPEN--" data-replace="${encode(value)}">`;
673
+ }
674
+ else {
675
+ output += `value="${encode(value)}">`;
676
+ }
677
+ level--;
678
+ output += `${newline()}</label>`;
679
+ }
680
+ else {
681
+ addHiddenInput(name, value);
682
+ }
683
+ }
684
+ else {
685
+ output += `${newline()}<label>`;
686
+ level++;
687
+ output += `${newline()}<span>${encode(optionName)}:</span>`;
688
+ output += `${newline()}<select name="${prefix}${optionName}">`;
689
+ level++;
690
+ group.forEach(option => {
691
+ var _a;
692
+ const optionIndex = product.custom_options.indexOf(option);
693
+ const itemCategory = (_a = this.__getItemCategoryLoader(productIndex, optionIndex)) === null || _a === void 0 ? void 0 : _a.data;
694
+ const modifiers = this.__getOptionModifiers(option, itemCategory !== null && itemCategory !== void 0 ? itemCategory : null, currencyCode);
695
+ const encodedValue = encode(`${option.value}${modifiers}`);
696
+ const encodedCaption = encode(option.value);
697
+ output += `${newline()}<option value="${encodedValue}">${encodedCaption}</option>`;
698
+ });
699
+ level--;
700
+ output += `${newline()}</select>`;
701
+ level--;
702
+ output += `${newline()}</label>`;
703
+ }
704
+ }
705
+ if (needsFieldset) {
706
+ level--;
707
+ output += `${newline()}</fieldset>`;
708
+ }
709
+ }
710
+ const encodedSubmitCaption = encode(this.t('preview.submit_caption'));
711
+ output += `${newline()}<button type="submit">${encodedSubmitCaption}</button>`;
712
+ level--;
713
+ output += `${newline()}</form>`;
714
+ return output;
715
+ }
716
+ __getAddToCartLinkHref() {
717
+ var _a, _b, _c, _d, _e, _f, _g, _h;
718
+ const currencyCode = this.__resolvedCurrencyCode;
719
+ const templateSet = this.__resolvedTemplateSet;
720
+ const cartUrl = this.__resolvedCartUrl;
721
+ const store = (_a = this.__storeLoader) === null || _a === void 0 ? void 0 : _a.data;
722
+ if (!this.defaultDomain || !templateSet || !store || !currencyCode || !cartUrl)
723
+ return '';
724
+ const url = new URL(cartUrl);
725
+ if (templateSet.code !== 'DEFAULT')
726
+ url.searchParams.set('template_set', templateSet.code);
727
+ if (this.form.cart === 'checkout')
728
+ url.searchParams.set('cart', 'checkout');
729
+ if (this.form.redirect)
730
+ url.searchParams.set('redirect', this.form.redirect);
731
+ if (this.form.coupon)
732
+ url.searchParams.set('coupon', this.form.coupon);
733
+ if (this.form.empty && this.form.empty !== 'false') {
734
+ url.searchParams.set('empty', this.form.empty);
735
+ }
736
+ for (let index = 0; index < ((_c = (_b = this.form.items) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0); ++index) {
737
+ const product = this.form.items[index];
738
+ const prefix = index === 0 ? '' : `${index + 1}:`;
739
+ const itemCategory = (_d = this.__getItemCategoryLoader(index)) === null || _d === void 0 ? void 0 : _d.data;
740
+ if (product.item_category_uri && !itemCategory)
741
+ return '';
742
+ if (product.price_configurable)
743
+ return '';
744
+ if (new Set(product.custom_options.map(v => v.name)).size < product.custom_options.length) {
745
+ return '';
746
+ }
747
+ if (itemCategory && itemCategory.code !== 'DEFAULT') {
748
+ url.searchParams.set(`${prefix}category`, itemCategory.code);
749
+ }
750
+ url.searchParams.set(`${prefix}name`, product.name);
751
+ url.searchParams.set(`${prefix}price`, `${product.price}${currencyCode}`);
752
+ if (product.code)
753
+ url.searchParams.set(`${prefix}code`, product.code);
754
+ if (product.parent_code)
755
+ url.searchParams.set(`${prefix}parent_code`, product.parent_code);
756
+ if (product.image) {
757
+ url.searchParams.set(`${prefix}image`, product.image);
758
+ if (product.url)
759
+ url.searchParams.set(`${prefix}url`, product.url);
760
+ }
761
+ if (product.sub_enabled) {
762
+ if (product.sub_frequency) {
763
+ url.searchParams.set(`${prefix}sub_frequency`, product.sub_frequency);
764
+ if (product.sub_startdate) {
765
+ if (product.sub_startdate_format === 'yyyymmdd') {
766
+ const date = new Date(product.sub_startdate);
767
+ const year = date.getFullYear();
768
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
769
+ const day = date.getDate().toString().padStart(2, '0');
770
+ url.searchParams.set(`${prefix}sub_startdate`, `${year}${month}${day}`);
771
+ }
772
+ else {
773
+ url.searchParams.set(`${prefix}sub_startdate`, String(product.sub_startdate));
774
+ }
775
+ }
776
+ if (product.sub_enddate) {
777
+ if (product.sub_enddate_format === 'yyyymmdd') {
778
+ const date = new Date(product.sub_enddate);
779
+ const year = date.getFullYear();
780
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
781
+ const day = date.getDate().toString().padStart(2, '0');
782
+ url.searchParams.set(`${prefix}sub_enddate`, `${year}${month}${day}`);
783
+ }
784
+ else {
785
+ url.searchParams.set(`${prefix}sub_enddate`, String(product.sub_enddate));
786
+ }
787
+ }
788
+ }
789
+ }
790
+ if (product.discount_name && product.discount_type && product.discount_details) {
791
+ url.searchParams.set(`${prefix}discount_${product.discount_type}`, `${product.discount_name}{${product.discount_details}}`);
792
+ }
793
+ if (product.expires_value) {
794
+ if (product.expires_format === 'timestamp') {
795
+ url.searchParams.set(`${prefix}expires`, product.expires_value.toFixed(0));
796
+ }
797
+ else {
798
+ url.searchParams.set(`${prefix}expires`, product.expires_value.toFixed(0));
799
+ }
800
+ }
801
+ if (((_e = product.quantity) !== null && _e !== void 0 ? _e : 1) > 1) {
802
+ url.searchParams.set(`${prefix}quantity`, ((_f = product.quantity) !== null && _f !== void 0 ? _f : 1).toFixed(0));
803
+ }
804
+ if (product.expires_format !== 'minutes') {
805
+ if (product.quantity_min) {
806
+ url.searchParams.set(`${prefix}quantity_min`, product.quantity_min.toString());
807
+ }
808
+ if (product.quantity_max) {
809
+ url.searchParams.set(`${prefix}quantity_max`, product.quantity_max.toString());
810
+ }
811
+ }
812
+ if (product.weight)
813
+ url.searchParams.set(`${prefix}weight`, product.weight.toFixed(3));
814
+ if (product.length)
815
+ url.searchParams.set(`${prefix}length`, product.length.toFixed(3));
816
+ if (product.width)
817
+ url.searchParams.set(`${prefix}width`, product.width.toFixed(3));
818
+ if (product.height)
819
+ url.searchParams.set(`${prefix}height`, product.height.toFixed(3));
820
+ for (let optionIndex = 0; optionIndex < product.custom_options.length; ++optionIndex) {
821
+ const option = product.custom_options[optionIndex];
822
+ if (option.value_configurable)
823
+ return '';
824
+ const itemCategory = (_g = this.__getItemCategoryLoader(index, optionIndex)) === null || _g === void 0 ? void 0 : _g.data;
825
+ const modifiers = this.__getOptionModifiers(option, itemCategory !== null && itemCategory !== void 0 ? itemCategory : null, currencyCode);
826
+ url.searchParams.set(`${prefix}${option.name}`, `${(_h = option.value) !== null && _h !== void 0 ? _h : ''}${modifiers}`);
827
+ }
828
+ }
829
+ return url.toString();
830
+ }
831
+ __getAddToCartCode() {
832
+ var _a;
833
+ const store = (_a = this.__storeLoader) === null || _a === void 0 ? void 0 : _a.data;
834
+ if (!this.encodeHelper || !store)
835
+ return null;
836
+ const formHTML = this.__getAddToCartFormHTML();
837
+ const linkHref = this.__getAddToCartLinkHref();
838
+ if (!formHTML && !linkHref)
839
+ return null;
840
+ let unsignedCode;
841
+ if (linkHref) {
842
+ const linkHTML = `<a href="${encode(linkHref)}">Add to cart</a>`;
843
+ unsignedCode = `${formHTML}${this.__signingSeparator}${linkHTML}`;
844
+ }
845
+ else {
846
+ unsignedCode = formHTML;
847
+ }
848
+ if (unsignedCode === this.__previousUnsignedCode && this.__previousSignedCode) {
849
+ const [formHTML, linkHTML] = this.__previousSignedCode.split(this.__signingSeparator);
850
+ return {
851
+ linkHref: linkHTML ? decode(linkHTML.substring(9, linkHTML.length - 17)) : '',
852
+ formHTML,
853
+ };
854
+ }
855
+ this.__previousUnsignedCode = unsignedCode;
856
+ this.__previousSignedCode = '';
857
+ if (store.use_cart_validation)
858
+ this.__signAsync(unsignedCode, this.encodeHelper);
859
+ return { formHTML, linkHref };
860
+ }
861
+ __getOptionModifiers(option, optionItemCategory, currencyCode) {
862
+ if (option.value_configurable)
863
+ return '';
864
+ const modifiers = [];
865
+ if (option.price) {
866
+ const operator = option.replace_price ? ':' : Math.sign(option.price) === -1 ? '-' : '+';
867
+ if (option.replace_price || option.price !== 0)
868
+ modifiers.push(`p${operator}${Math.abs(option.price)}${currencyCode}`);
869
+ }
870
+ if (option.weight) {
871
+ const operator = option.replace_weight ? ':' : Math.sign(option.weight) === -1 ? '-' : '+';
872
+ if (option.replace_weight || option.weight !== 0)
873
+ modifiers.push(`w${operator}${Math.abs(option.weight)}`);
874
+ }
875
+ if (option.item_category_uri && !optionItemCategory)
876
+ return '';
877
+ if (optionItemCategory)
878
+ modifiers.push(`y:${optionItemCategory.code}`);
879
+ if (option.code) {
880
+ const operator = option.replace_code ? ':' : '+';
881
+ if (option.replace_code || option.code !== '')
882
+ modifiers.push(`c${operator}${option.code}`);
883
+ }
884
+ return modifiers.length ? `{${modifiers.join('|')}}` : '';
885
+ }
886
+ }
887
+ //# sourceMappingURL=ExperimentalAddToCartBuilder.js.map