@salla.sa/twilight-components 2.14.298 → 2.14.300

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 (150) hide show
  1. package/dist/cjs/{Helper-C9UmWIYn.js → Helper-B5NunIdR.js} +1 -0
  2. package/dist/cjs/{filepond-Dn-jnnWy.js → filepond-BScg3EjA.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-poster-4K4RC5sx.js → filepond-plugin-file-poster-C0equ1tk.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-size-B85pytvJ.js → filepond-plugin-file-validate-size-DbSDO39t.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-file-validate-type-vWh-hrFq.js → filepond-plugin-file-validate-type-oNrCSQ4M.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-edit-B3-_-hIs.js → filepond-plugin-image-edit-CEs1Wvna.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-exif-orientation-Cbkb7_k1.js → filepond-plugin-image-exif-orientation-CR0z9rwJ.js} +1 -1
  8. package/dist/cjs/{filepond-plugin-image-preview-CqcNMHtt.js → filepond-plugin-image-preview-QCP0yf11.js} +1 -1
  9. package/dist/cjs/{index-Z2nWod3c.js → index-bUFB5h9D.js} +1 -1
  10. package/dist/cjs/{index-DENUwtYT.js → index-tXQykYB9.js} +2 -2
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/salla-accordion_62.cjs.entry.js +29 -30
  13. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-filters-widget.cjs.entry.js +2 -2
  21. package/dist/cjs/salla-filters.cjs.entry.js +2 -2
  22. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-notifications.cjs.entry.js +2 -2
  28. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-orders.cjs.entry.js +2 -2
  35. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-reviews-page.cjs.entry.js +2 -2
  39. package/dist/cjs/salla-reviews.cjs.entry.js +2 -2
  40. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  46. package/dist/cjs/twilight.cjs.js +1 -1
  47. package/dist/collection/Helpers/Helper.js +1 -0
  48. package/dist/collection/components/salla-products-list/salla-products-list.js +3 -3
  49. package/dist/collection/components/salla-user-menu/salla-user-menu.js +18 -19
  50. package/dist/components/Helper.js +1 -0
  51. package/dist/components/index.js +2 -2
  52. package/dist/components/salla-products-list2.js +1 -1
  53. package/dist/components/salla-user-menu.js +18 -19
  54. package/dist/esm/{Helper-B51hb0bi.js → Helper-Bt5Zv9cl.js} +1 -0
  55. package/dist/esm/{filepond-q8kfR-qI.js → filepond-DZgILbOT.js} +1 -1
  56. package/dist/esm/{filepond-plugin-file-poster-CAkqJrqM.js → filepond-plugin-file-poster-DMXXHQ1L.js} +1 -1
  57. package/dist/esm/{filepond-plugin-file-validate-size-lHUJVKW0.js → filepond-plugin-file-validate-size-uKHV0jNp.js} +1 -1
  58. package/dist/esm/{filepond-plugin-file-validate-type-FHDAVW2X.js → filepond-plugin-file-validate-type-D8hhJ9EB.js} +1 -1
  59. package/dist/esm/{filepond-plugin-image-edit-drdbdxxE.js → filepond-plugin-image-edit-0X2RSyN6.js} +1 -1
  60. package/dist/esm/{filepond-plugin-image-exif-orientation-Kqs0PJBo.js → filepond-plugin-image-exif-orientation-0v28bqEm.js} +1 -1
  61. package/dist/esm/{filepond-plugin-image-preview-BZGs88rC.js → filepond-plugin-image-preview-rwaj1mis.js} +1 -1
  62. package/dist/esm/{index-CPlWMNOm.js → index-DA5HnTzR.js} +1 -1
  63. package/dist/esm/{index-Bh2SK07N.js → index-Vf9-v4wr.js} +2 -2
  64. package/dist/esm/loader.js +2 -2
  65. package/dist/esm/salla-accordion_62.entry.js +29 -30
  66. package/dist/esm/salla-advertisement.entry.js +1 -1
  67. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  68. package/dist/esm/salla-apps-icons.entry.js +1 -1
  69. package/dist/esm/salla-cart-item-offers.entry.js +1 -1
  70. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  71. package/dist/esm/salla-contacts.entry.js +1 -1
  72. package/dist/esm/salla-custom-fields.entry.js +1 -1
  73. package/dist/esm/salla-filters-widget.entry.js +2 -2
  74. package/dist/esm/salla-filters.entry.js +2 -2
  75. package/dist/esm/salla-installment.entry.js +1 -1
  76. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  77. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  78. package/dist/esm/salla-metadata.entry.js +1 -1
  79. package/dist/esm/salla-notification-item.entry.js +1 -1
  80. package/dist/esm/salla-notifications.entry.js +2 -2
  81. package/dist/esm/salla-offer.entry.js +1 -1
  82. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  83. package/dist/esm/salla-order-details-options.entry.js +1 -1
  84. package/dist/esm/salla-order-details.entry.js +1 -1
  85. package/dist/esm/salla-order-summary.entry.js +1 -1
  86. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  87. package/dist/esm/salla-orders.entry.js +2 -2
  88. package/dist/esm/salla-payments.entry.js +1 -1
  89. package/dist/esm/salla-price-range.entry.js +1 -1
  90. package/dist/esm/salla-review-card.entry.js +1 -1
  91. package/dist/esm/salla-reviews-page.entry.js +2 -2
  92. package/dist/esm/salla-reviews.entry.js +2 -2
  93. package/dist/esm/salla-social.entry.js +1 -1
  94. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  95. package/dist/esm/salla-tooltip.entry.js +1 -1
  96. package/dist/esm/salla-trust-badges.entry.js +1 -1
  97. package/dist/esm/salla-verify.entry.js +1 -1
  98. package/dist/esm/salla-wallet.entry.js +1 -1
  99. package/dist/esm/twilight.js +2 -2
  100. package/dist/twilight/{p-BLPRGu3L.js → p--XHnNbTg.js} +1 -1
  101. package/dist/twilight/{p-62fd72e0.entry.js → p-060b76fc.entry.js} +1 -1
  102. package/dist/twilight/{p-d6c99665.entry.js → p-10627275.entry.js} +1 -1
  103. package/dist/twilight/{p-c31e0731.entry.js → p-11258ae1.entry.js} +1 -1
  104. package/dist/twilight/{p-5460b611.entry.js → p-11734c15.entry.js} +2 -2
  105. package/dist/twilight/{p-dbce8093.entry.js → p-11e3381f.entry.js} +1 -1
  106. package/dist/twilight/{p-c69d87e4.entry.js → p-151c103f.entry.js} +1 -1
  107. package/dist/twilight/{p-8d246fcd.entry.js → p-20c4c8af.entry.js} +1 -1
  108. package/dist/twilight/{p-6891ae55.entry.js → p-3d92ba5c.entry.js} +1 -1
  109. package/dist/twilight/{p-5789243f.entry.js → p-446bd291.entry.js} +1 -1
  110. package/dist/twilight/{p-de903389.entry.js → p-4ba71acf.entry.js} +1 -1
  111. package/dist/twilight/{p-4c74e526.entry.js → p-4d3071a5.entry.js} +1 -1
  112. package/dist/twilight/{p-842debd3.entry.js → p-53ad8f04.entry.js} +1 -1
  113. package/dist/twilight/{p-4df42ff8.entry.js → p-5426fed3.entry.js} +1 -1
  114. package/dist/twilight/{p-1863db37.entry.js → p-65103ff7.entry.js} +1 -1
  115. package/dist/twilight/{p-85d168c9.entry.js → p-6d112428.entry.js} +1 -1
  116. package/dist/twilight/{p-7d3b2c8d.entry.js → p-70750924.entry.js} +1 -1
  117. package/dist/twilight/{p-11d325ba.entry.js → p-7a980667.entry.js} +1 -1
  118. package/dist/twilight/{p-af92eed9.entry.js → p-81f65a33.entry.js} +1 -1
  119. package/dist/twilight/{p-b4127acc.entry.js → p-83a0e642.entry.js} +1 -1
  120. package/dist/twilight/{p-b2ab5fcc.entry.js → p-8f3f3530.entry.js} +1 -1
  121. package/dist/twilight/{p-ccfd9c1e.entry.js → p-91b68094.entry.js} +1 -1
  122. package/dist/twilight/{p-5981c13b.entry.js → p-9795c6d0.entry.js} +1 -1
  123. package/dist/twilight/{p-5f46651c.entry.js → p-97e6602f.entry.js} +1 -1
  124. package/dist/twilight/{p-CtJEHiDh.js → p-B7BW4Mdj.js} +1 -1
  125. package/dist/twilight/{p-BcA-Dpxf.js → p-BmD3prgX.js} +1 -1
  126. package/dist/twilight/{p-HMoEZhqa.js → p-CPQv1htQ.js} +1 -1
  127. package/dist/twilight/p-DQd7LCNI.js +9 -0
  128. package/dist/twilight/{p-sK70mswA.js → p-DUIBkQ0L.js} +1 -1
  129. package/dist/twilight/p-Dljb4XCt.js +4 -0
  130. package/dist/twilight/{p-DykGR1vx.js → p-EFshmXnQ.js} +1 -1
  131. package/dist/twilight/{p-Bh2SK07N.js → p-Vf9-v4wr.js} +1 -1
  132. package/dist/twilight/{p-ecddf6ff.entry.js → p-a9adb89e.entry.js} +1 -1
  133. package/dist/twilight/{p-e584c46f.entry.js → p-afeeefb3.entry.js} +1 -1
  134. package/dist/twilight/{p-cef92263.entry.js → p-b7ca90d8.entry.js} +1 -1
  135. package/dist/twilight/{p-3f62e05b.entry.js → p-bb3a0dbc.entry.js} +1 -1
  136. package/dist/twilight/{p-0d04ca56.entry.js → p-c77da76a.entry.js} +1 -1
  137. package/dist/twilight/{p-9d46ba91.entry.js → p-d062aafc.entry.js} +1 -1
  138. package/dist/twilight/{p-b2548a59.entry.js → p-ddd3cb10.entry.js} +1 -1
  139. package/dist/twilight/{p-8f481f80.entry.js → p-dfb1f2bb.entry.js} +1 -1
  140. package/dist/twilight/{p-5f815dc4.entry.js → p-f155cb58.entry.js} +1 -1
  141. package/dist/twilight/{p-99b49b76.entry.js → p-f54b0939.entry.js} +1 -1
  142. package/dist/twilight/{p-e23f38dc.entry.js → p-fadae641.entry.js} +1 -1
  143. package/dist/twilight/{p-B0jU8m7y.js → p-ozyDVWVs.js} +1 -1
  144. package/dist/twilight/twilight.esm.js +1 -1
  145. package/dist/types/components/salla-products-list/salla-products-list.d.ts +1 -1
  146. package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +2 -2
  147. package/dist/types/components.d.ts +2 -2
  148. package/package.json +5 -5
  149. package/dist/twilight/p-DFYs0E0K.js +0 -9
  150. package/dist/twilight/p-X-ZUrwUQ.js +0 -4
@@ -1965,7 +1965,7 @@ export namespace Components {
1965
1965
  * The source of the products list
1966
1966
  * @type {string}
1967
1967
  */
1968
- "source": 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales' | 'wishlist' | 'top-rated';
1968
+ "source": 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales' | 'wishlist' | 'top-rated' | 'reorder';
1969
1969
  /**
1970
1970
  * The source value, cloud be different values as following: - array of ids when `source` in ['categories', 'brands', 'tags', 'selected'] - keyword when `source` = 'search' - products payload when `source` = 'json' - product_id when `source` = 'related'
1971
1971
  * @type {string}
@@ -5751,7 +5751,7 @@ declare namespace LocalJSX {
5751
5751
  * The source of the products list
5752
5752
  * @type {string}
5753
5753
  */
5754
- "source"?: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales' | 'wishlist' | 'top-rated';
5754
+ "source"?: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales' | 'wishlist' | 'top-rated' | 'reorder';
5755
5755
  /**
5756
5756
  * The source value, cloud be different values as following: - array of ids when `source` in ['categories', 'brands', 'tags', 'selected'] - keyword when `source` = 'search' - products payload when `source` = 'json' - product_id when `source` = 'related'
5757
5757
  * @type {string}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight-components",
3
- "version": "2.14.298",
3
+ "version": "2.14.300",
4
4
  "license": "GPL-3.0",
5
5
  "author": "Salla Team <support@salla.dev> (https://salla.dev)",
6
6
  "bugs": {
@@ -80,9 +80,9 @@
80
80
  "typescript": "^5.4.5"
81
81
  },
82
82
  "dependencies": {
83
- "@salla.sa/applepay": "2.14.298",
84
- "@salla.sa/twilight": "2.14.298",
85
- "@salla.sa/twilight-tailwind-theme": "2.14.298",
83
+ "@salla.sa/applepay": "2.14.300",
84
+ "@salla.sa/twilight": "2.14.300",
85
+ "@salla.sa/twilight-tailwind-theme": "2.14.300",
86
86
  "@types/node": "^20.4.8",
87
87
  "animejs": "^3.2.2",
88
88
  "filepond": "^4.30.6",
@@ -100,5 +100,5 @@
100
100
  "vanilla-lazyload": "^17.8.5",
101
101
  "vanilla-picker": "^2.12.2"
102
102
  },
103
- "gitHead": "fd9b3ed9979eee23a614757140850d445e408fd6"
103
+ "gitHead": "efcdb4998beb96ff1c5eb28905f100eb6dd0b939"
104
104
  }
@@ -1,9 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{d as A}from"./p-Bh2SK07N.js";function n(A,n){return n.forEach((function(n){n&&"string"!=typeof n&&!Array.isArray(n)&&Object.keys(n).forEach((function(e){if("default"!==e&&!(e in A)){var r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(A,e,r.get?r:{enumerable:!0,get:function(){return n[e]}})}}))})),Object.freeze(A)}var e,r={exports:{}},i=(e||(e=1,r.exports=function(){var A=65496,n=65505,e=1165519206,r=18761,i=274,t=65280,o=function(A,n){return A.getUint16(n,arguments.length>2&&void 0!==arguments[2]&&arguments[2])},a=function(A,n){return A.getUint32(n,arguments.length>2&&void 0!==arguments[2]&&arguments[2])},u="undefined"!=typeof window&&void 0!==window.document,f=void 0,d=u?new Image:{};d.onload=function(){return f=d.naturalWidth>d.naturalHeight},d.src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=";var c=function(u){var d=u.utils,c=d.Type,v=d.isFile;return(0,u.addFilter)("DID_LOAD_ITEM",(function(u,d){var c=d.query;return new Promise((function(d){var w=u.file;if(!(v(w)&&function(A){return/^image\/jpeg/.test(A.type)}(w)&&c("GET_ALLOW_IMAGE_EXIF_ORIENTATION")&&f))return d(u);(function(u){return new Promise((function(f){var d=new FileReader;d.onload=function(u){var d=new DataView(u.target.result);if(o(d,0)===A){for(var c=d.byteLength,v=2;v<c;){var w=o(d,v);if(v+=2,w===n){if(a(d,v+=2)!==e)break;var g=o(d,v+=6)===r;v+=a(d,v+4,g);var l=o(d,v,g);v+=2;for(var p=0;p<l;p++)if(o(d,v+12*p,g)===i)return void f(o(d,v+12*p+8,g))}else{if((w&t)!==t)break;v+=o(d,v)}}f(-1)}else f(-1)},d.readAsArrayBuffer(u.slice(0,65536))}))})(w).then((function(A){u.setMetadata("exif",{orientation:A}),d(u)}))}))})),{options:{allowImageExifOrientation:[!0,c.BOOLEAN]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:c})),c}()),r.exports),t=n({__proto__:null,default:A(i)},[i]);
5
- /*!
6
- * FilePondPluginImageExifOrientation 1.0.11
7
- * Licensed under MIT, https://opensource.org/licenses/MIT/
8
- * Please visit https://pqina.nl/filepond/ for details.
9
- */export{t as f}
@@ -1,4 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{a as e}from"./p-CgtvEd63.js";salla.event.setMaxListeners(100);var t=new class{setIncludes(e){return this.includes=e,this}toggleElementClassIf(e,t,a,r){t=Array.isArray(t)?t:t.split(" "),a=Array.isArray(a)?a:a.split(" ");let n=r(e);return e?.classList.remove(...n?a:t),e?.classList.add(...n?t:a),this}toggleClassIf(e,t,a,r){return document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,a,r))),this}isValidEmail(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}filterEmojies(e){return e.replace(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g,"")}debounce(e,...t){return this.debounce_||(this.debounce_=salla.helpers.debounce(((e,...t)=>e(...t)),500)),this.debounce_(e,...t)}getProductsSource(e){return{"brands.single":"brands","product.index":"categories","product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","customer.wishlist":"wishlist","landing-page":"landing-page","product.index.tag":"tags","product.index.sales":"sales","components.most_sales_products":"sales"}[e||salla.config.get("page.slug")]||e||"latest"}getPageTitleForSource(e){return(e={brands:"common.titles.brands",latest:"blocks.home.latest_products",offers:"common.titles.discounts",sales:"common.titles.most_sales"}[e])?salla.lang.get(e):""}getProductsSourceValue(e,t){const a=this.getProductsSource(e);let r=null;if(t)try{r="string"==typeof t?JSON.parse(t):t}catch(e){console.error("Failed to parse JSON string in sourceValue:",e)}if(!["search","json","offers","latest","sales","related"].includes(a)){if(Array.isArray(r)&&r.length)return r;if(Array.isArray(r)&&!r.length)return"";if("number"==typeof r)return[r];if(!t&&["categories","tags","brands"].includes(e))return[salla.config.get("page.id")]}return r||t?r||t:"search"===a?new URLSearchParams(window.location.search).get("q")||"":salla.config.get("page.id")}extractFiltersFromUrl(e){let t={};return e.forEach(((e,a)=>{const r=a.match(/^filters\[(.*?)\](\[(.*?)\])?$/u);if(r){const a=r[1],n=r[3];n?(t[a]=t[a]||{},t[a][n]=e):t[a]=e}else{const r=a.match(/^(.*?)$/u);r&&(t[r[1]]=e)}})),t}async injectExtraFieldsToResponse(e){if(!e||!this.includes)return e;const t=e.data.map((e=>e.id));try{const{data:a}=await this.fetchImagesAndOptions(t);if(this.injectOptionsAndImages(e.data,a),!this.includes.includes("metadata"))return e;const r=await salla.api.metadata.fetchValues("product",t);return e.data.forEach((e=>{e.metadata=r.data.find((t=>parseInt(t.entity_id)===parseInt(e.id)))})),e}catch(e){throw console.error("Error in injectExtraFieldsToResponse:",e),e}}fetchImagesAndOptions(e){return this.productsIncludes().length?salla.api.product.fetchOptions(e,{with:this.productsIncludes()}):Promise.resolve({data:[]})}injectOptionsAndImages(e,t){return t.length?e.map((e=>(this.includes.filter((e=>"metadata"!==e)).forEach((a=>{const r=t.find((t=>parseInt(t.id)===parseInt(e.id)));e[a]=r?r[a]:null})),e))):null}productsIncludes(){return this.includes?.filter((e=>"metadata"!=e))}parseJson(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(e){salla.logger.error("Failed to parse includes as JSON:",e)}return null}getProductSchemaMarkupScript(e){const t=document.createElement("script");return t.type="application/ld+json",t.text=JSON.stringify({"@context":"http://schema.org","@type":"Product",name:e?.name,image:e?.image?.url||e?.thumbnail,description:e?.description,brand:{"@type":"Brand",logo:e?.brand?.logo},offers:{"@type":"Offer",price:e?.price}}),t}createProductSchema(e,t){let a={productID:`${e.id}`,"@type":"Product",name:e.name,url:e.url,image:e.image.url||e.image,description:e.description||e.subtitle||e.name,...e.sku&&e.sku.length>0&&{sku:e.sku},offers:{"@type":"Offer",url:e.url,priceCurrency:e.currency,price:e.price,itemCondition:"NewCondition",availability:e.is_available?"InStock":"OutOfStock",priceValidUntil:e.discount_ends||new Date((new Date).setDate((new Date).getDate()+7)).toISOString().split("T")[0],priceSpecification:{"@type":"PriceSpecification",price:e.regular_price,priceCurrency:e.currency,valueAddedTaxIncluded:e.is_taxable},seller:{"@type":"Organization",name:salla.config.get("store.name")},shippingDetails:{"@type":"OfferShippingDetails",shippingRate:{"@type":"MonetaryAmount",value:"0",currency:e.currency||"SAR"},deliveryTime:{"@type":"ShippingDeliveryTime",businessDays:{"@type":"OpeningHoursSpecification",dayOfWeek:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]},cutoffTime:"14:00"}},hasMerchantReturnPolicy:{"@type":"MerchantReturnPolicy",returnPolicyCategory:"https://schema.org/MerchantReturnFiniteReturnWindow",merchantReturnDays:30,returnMethod:"https://schema.org/ReturnByMail",returnFees:"https://schema.org/FreeReturn"}}};return e.rating?.stars&&(a.aggregateRating={"@type":"AggregateRating",ratingValue:e.rating.stars,reviewCount:e.rating.count}),{"@type":"ListItem",position:t,item:a}}generateProductSchema(e){const t="salla-product-schema-script";if(document.getElementById(t))return void salla.logger.warn(`already added schema-script with id (${t})!`);const a=document.createElement("script");a.type="application/ld+json",a.id=t;const r={"@context":"https://schema.org","@type":"ItemList",name:salla.config.get("page.title"),itemListElement:e.map(((e,t)=>this.createProductSchema(e,t+1)))};a.textContent=JSON.stringify(r),document.head.appendChild(a)}formatDateFromString(e,t,a="en"){const r={en:"Invalid Date",ar:"تاريخ غير صالح"};if(!e||"string"!=typeof e||""===e.trim())return r[a];let n;if(/^\d+$/.test(e)){const t=parseInt(e);n=new Date(t>1e12?t:1e3*t)}else n=new Date(e);return isNaN(n.getTime())?r[a]:`${{en:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ar:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت"]}[a][n.getDay()]} ${t(n.getDate(),"en"===a)} ${{en:["January","February","March","April","May","June","July","August","September","October","November","December"],ar:["يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"]}[a][n.getMonth()]} ${t(n.getFullYear(),"en"===a)}`}copyToClipboard(e){var t=e.target.innerText;navigator.clipboard.writeText(t).then((()=>{console.log("Text copied to clipboard: "+t)})).catch((e=>{console.error("Unable to copy text to clipboard",e)}))}animateItems(t){t&&e({targets:t,opacity:[0,1],duration:1200,translateY:[20,0],delay:function(e,t){return 100*t},easing:"easeOutExpo",complete:function(){t.forEach((e=>{e.classList.add("animated")}))}})}createReviewObject(e){return{"@type":"Review",author:{"@type":"Person",name:e.name},reviewBody:e.content,reviewRating:{"@type":"Rating",bestRating:"5",ratingValue:e.stars,worstRating:"1"}}}generateReviewSchema(e){const t=document.createElement("script");t.type="application/ld+json";const a={"@context":"http://schema.org/","@type":"Store",name:salla.config.get("store.name"),url:salla.config.get("store.url"),address:"الرياض",review:e.map((e=>this.createReviewObject(e))),aggregateRating:{"@type":"AggregateRating",ratingValue:e.reduce(((e,t)=>e+t.stars),0)/e.length,reviewCount:e.length}};t.textContent=JSON.stringify(a),document.head.appendChild(t)}};export{t as H}