@salla.sa/twilight-components 2.14.306 → 2.14.307

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 (145) hide show
  1. package/dist/cjs/{filepond-T68FpD2x.js → filepond-Btud-9cx.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-D2qWU0E8.js → filepond-plugin-file-poster--Gwmscgl.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-BBlP06s2.js → filepond-plugin-file-validate-size-BOJQxGjN.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-DsoFa7eA.js → filepond-plugin-file-validate-type-C77Hrmz7.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-Db2ao8Iq.js → filepond-plugin-image-edit-DI9lM8fO.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-BR30PCYO.js → filepond-plugin-image-exif-orientation-DLoZc-P9.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-CRbzO01p.js → filepond-plugin-image-preview-DHeIf3Qv.js} +1 -1
  8. package/dist/cjs/{index-_C7Hhk-4.js → index-BW35Qz0q.js} +1 -1
  9. package/dist/cjs/{index-B-Pk8e4E.js → index-C_8SUOhh.js} +2 -2
  10. package/dist/cjs/loader.cjs.js +2 -2
  11. package/dist/cjs/salla-accordion_62.cjs.entry.js +95 -67
  12. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-reviews-page.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  45. package/dist/cjs/twilight.cjs.js +2 -2
  46. package/dist/collection/components/salla-file-upload/salla-file-upload.js +23 -14
  47. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +72 -61
  48. package/dist/components/index.js +2 -2
  49. package/dist/components/salla-file-upload2.js +22 -13
  50. package/dist/components/salla-rating-modal.js +64 -61
  51. package/dist/esm/{filepond-CEA-Ut0D.js → filepond-BDCqb9n1.js} +1 -1
  52. package/dist/esm/{filepond-plugin-file-poster-CrHfyiKb.js → filepond-plugin-file-poster-Csff9zr1.js} +1 -1
  53. package/dist/esm/{filepond-plugin-file-validate-size-BAjMQFxV.js → filepond-plugin-file-validate-size-uT0vdpSK.js} +1 -1
  54. package/dist/esm/{filepond-plugin-file-validate-type-3WttM4LY.js → filepond-plugin-file-validate-type-C71qG90l.js} +1 -1
  55. package/dist/esm/{filepond-plugin-image-edit-gXv8D0gp.js → filepond-plugin-image-edit-AV3f4iVU.js} +1 -1
  56. package/dist/esm/{filepond-plugin-image-exif-orientation-Cqa1508w.js → filepond-plugin-image-exif-orientation-BrahCgFe.js} +1 -1
  57. package/dist/esm/{filepond-plugin-image-preview-k7khQXHq.js → filepond-plugin-image-preview-B73Halt8.js} +1 -1
  58. package/dist/esm/{index-DzTVR6sF.js → index-CkTB8LrG.js} +2 -2
  59. package/dist/esm/{index-hJWVffcN.js → index-DAIvUtTl.js} +1 -1
  60. package/dist/esm/loader.js +3 -3
  61. package/dist/esm/salla-accordion_62.entry.js +95 -67
  62. package/dist/esm/salla-advertisement.entry.js +1 -1
  63. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  64. package/dist/esm/salla-apps-icons.entry.js +1 -1
  65. package/dist/esm/salla-cart-item-offers.entry.js +1 -1
  66. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  67. package/dist/esm/salla-contacts.entry.js +1 -1
  68. package/dist/esm/salla-custom-fields.entry.js +1 -1
  69. package/dist/esm/salla-filters-widget.entry.js +1 -1
  70. package/dist/esm/salla-filters.entry.js +1 -1
  71. package/dist/esm/salla-installment.entry.js +1 -1
  72. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  73. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  74. package/dist/esm/salla-metadata.entry.js +1 -1
  75. package/dist/esm/salla-notification-item.entry.js +1 -1
  76. package/dist/esm/salla-notifications.entry.js +1 -1
  77. package/dist/esm/salla-offer.entry.js +1 -1
  78. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  79. package/dist/esm/salla-order-details-options.entry.js +1 -1
  80. package/dist/esm/salla-order-details.entry.js +1 -1
  81. package/dist/esm/salla-order-summary.entry.js +1 -1
  82. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  83. package/dist/esm/salla-orders.entry.js +1 -1
  84. package/dist/esm/salla-payments.entry.js +1 -1
  85. package/dist/esm/salla-price-range.entry.js +1 -1
  86. package/dist/esm/salla-review-card.entry.js +1 -1
  87. package/dist/esm/salla-reviews-page.entry.js +1 -1
  88. package/dist/esm/salla-reviews.entry.js +1 -1
  89. package/dist/esm/salla-social.entry.js +1 -1
  90. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  91. package/dist/esm/salla-tooltip.entry.js +1 -1
  92. package/dist/esm/salla-trust-badges.entry.js +1 -1
  93. package/dist/esm/salla-verify.entry.js +1 -1
  94. package/dist/esm/salla-wallet.entry.js +1 -1
  95. package/dist/esm/twilight.js +3 -3
  96. package/dist/twilight/{p-eff7b7fd.entry.js → p-07e3af79.entry.js} +1 -1
  97. package/dist/twilight/{p-dc88b0d4.entry.js → p-152cca87.entry.js} +1 -1
  98. package/dist/twilight/{p-e2a7ad27.entry.js → p-1ac688b1.entry.js} +1 -1
  99. package/dist/twilight/{p-a6793957.entry.js → p-2bc66d76.entry.js} +1 -1
  100. package/dist/twilight/{p-8f7c61ae.entry.js → p-2e1acb31.entry.js} +1 -1
  101. package/dist/twilight/{p-e85c2ce3.entry.js → p-2f0c4c48.entry.js} +1 -1
  102. package/dist/twilight/{p-146fef48.entry.js → p-369e287b.entry.js} +1 -1
  103. package/dist/twilight/{p-27797654.entry.js → p-391bfab0.entry.js} +1 -1
  104. package/dist/twilight/{p-9f7048f9.entry.js → p-39fbc8df.entry.js} +1 -1
  105. package/dist/twilight/{p-2c10446c.entry.js → p-3d65ce04.entry.js} +1 -1
  106. package/dist/twilight/{p-7f980b83.entry.js → p-49d27a30.entry.js} +1 -1
  107. package/dist/twilight/{p-ead30e6f.entry.js → p-4b743277.entry.js} +1 -1
  108. package/dist/twilight/{p-4be84919.entry.js → p-50066053.entry.js} +1 -1
  109. package/dist/twilight/{p-e5fa1278.entry.js → p-5e393287.entry.js} +1 -1
  110. package/dist/twilight/{p-a962dc4e.entry.js → p-683db036.entry.js} +1 -1
  111. package/dist/twilight/{p-cafa3981.entry.js → p-69d77416.entry.js} +1 -1
  112. package/dist/twilight/{p-a1c13dc3.entry.js → p-6da8bb12.entry.js} +1 -1
  113. package/dist/twilight/{p-eaf534c7.entry.js → p-774db722.entry.js} +1 -1
  114. package/dist/twilight/{p-21474b0b.entry.js → p-7826e12d.entry.js} +1 -1
  115. package/dist/twilight/{p-f7a3fa8e.entry.js → p-7fec8b2b.entry.js} +1 -1
  116. package/dist/twilight/{p-CIpEMPXT.js → p-85r8le_w.js} +1 -1
  117. package/dist/twilight/{p-27735fc2.entry.js → p-89ed3133.entry.js} +1 -1
  118. package/dist/twilight/{p-CBEtXGh0.js → p-AkZZv6o3.js} +1 -1
  119. package/dist/twilight/{p-B65_j3d4.js → p-CDzETZL4.js} +1 -1
  120. package/dist/twilight/{p-BiU9nldp.js → p-CR3Odb2N.js} +1 -1
  121. package/dist/twilight/{p-DzTVR6sF.js → p-CkTB8LrG.js} +1 -1
  122. package/dist/twilight/{p-C8nDt0jG.js → p-CoViVjAD.js} +1 -1
  123. package/dist/twilight/{p-Czub2Z40.js → p-D9xbcyYI.js} +1 -1
  124. package/dist/twilight/{p-BakkriQz.js → p-Wr2wkBmL.js} +2 -2
  125. package/dist/twilight/{p-be48e8c4.entry.js → p-a4b4dfb6.entry.js} +1 -1
  126. package/dist/twilight/{p-0ae9e425.entry.js → p-a5611c44.entry.js} +1 -1
  127. package/dist/twilight/{p-dcf5a422.entry.js → p-b1eb710a.entry.js} +1 -1
  128. package/dist/twilight/{p-f2525950.entry.js → p-c4312308.entry.js} +1 -1
  129. package/dist/twilight/p-c7aec160.entry.js +11 -0
  130. package/dist/twilight/{p-c3bbc744.entry.js → p-d1e5e51e.entry.js} +1 -1
  131. package/dist/twilight/{p-8c264b4c.entry.js → p-d3fc316c.entry.js} +1 -1
  132. package/dist/twilight/{p-e7544665.entry.js → p-d70e73be.entry.js} +1 -1
  133. package/dist/twilight/{p-da06dd7e.entry.js → p-dbe530e9.entry.js} +1 -1
  134. package/dist/twilight/p-e0386eb6.entry.js +4 -0
  135. package/dist/twilight/{p-2a63d302.entry.js → p-e086a18a.entry.js} +1 -1
  136. package/dist/twilight/{p-cda9559e.entry.js → p-e41ed882.entry.js} +1 -1
  137. package/dist/twilight/{p-dd107ead.entry.js → p-ea727ca3.entry.js} +1 -1
  138. package/dist/twilight/{p-D6rcrZ5Y.js → p-xlB0zmD0.js} +1 -1
  139. package/dist/twilight/twilight.esm.js +1 -1
  140. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +5 -5
  141. package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +21 -19
  142. package/dist/types/components.d.ts +2 -2
  143. package/package.json +5 -5
  144. package/dist/twilight/p-0924f4fa.entry.js +0 -4
  145. package/dist/twilight/p-7ab35a9b.entry.js +0 -11
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,c as t,h as i,H as e,a as h}from"./p-DzTVR6sF.js";import{M as r}from"./p-DmgxDvXL.js";const l=class{constructor(i){s(this,i),this.verified=t(this,"verified"),this.translationLoaded=!1,this.display="modal",this.type="mobile",this.autoReload=!0,this.supportWebAuth=!0,this.resendAfter=30,this.isProfileVerify=!1,salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+this.type),this.modal?.setTitle(this.title)})),"inline"!=this.display?(salla.event.on("profile::verification",(s=>{let t=Array.isArray(s)?s[0]:s;this.isProfileVerify=!0,this.open(t),this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+t.type),this.modal?.setTitle(this.title)})),salla.event.on("modalClosed",(()=>{this.resendAfter=0,this.timer.innerHTML="30 : 00"}))):this.modal={open:()=>"",close:()=>"",setTitle:()=>""}}splitNumber(s){this.resetError();let t=s.data||s.target.value;t&&1!==t.length&&this.modifyNext(s.target,t)}modifyNext(s,t){s.value=t[0],t=t.substring(1),s.nextElementSibling&&t.length?this.modifyNext(s.nextElementSibling,t):s.nextElementSibling||0!==t.length?s.nextElementSibling&&0===t.length&&s.nextElementSibling.focus():s.focus()}checkAllInputs(){let s=!0;for(let t=0;t<this.otpInputs.length;t++)""===this.otpInputs[t].value&&(s=!1);return s}handleKeyUp(s){if(this.resetError(),["Alt","Shift","Control","AltGraph","Ctrl"].includes(s.key))return;let t=s.keyCode||s.charCode;s.target.value?(s.target.nextElementSibling?.focus(),s.target.nextElementSibling?.select()):[8,46].includes(t)&&(s.target.previousElementSibling?.focus(),s.target.previousElementSibling?.select()),s.target.value.length>1&&this.splitNumber(s)}handlePaste(s){this.resetError();let t=(salla.helpers.number(s.clipboardData.getData("text"))||"").replace(/[^0-9]/g,"");t=t.substring(0,this.otpInputs.length),this.otpInputs.forEach((s=>s.value="")),this.modifyNext(this.otpInputs[0],t)}handleInput(s){this.resetError(),salla.helpers.inputDigitsOnly(s.target),this.checkAllInputs()&&setTimeout((()=>{this.toggleOTPSubmit()}),100)}resetError(){this.hasError=!1,this.errorMessage=""}handleFocus(s){s.target!==this.firstOtpInput&&(""==this.firstOtpInput?.value&&this.firstOtpInput.focus(),""==s.target.previousElementSibling.value&&s.target.previousElementSibling.focus())}async getCode(){return this.code.value}async open(s){this.data=s,this.data.type=this.data.type||this.type,this.type=this.data.type,this.resendTimer(),this.otpInputs=this.body.querySelectorAll(".s-verify-input"),this.firstOtpInput=this.body.querySelector("#otp-1"),this.reset(),this.resetError(),"modal"==this.display&&this.modal?.setTitle(this.title),this.modal.open(),this.firstOtpInput?.addEventListener("input",(s=>this.splitNumber(s))),setTimeout((()=>this.otpInputs[0].focus()),100)}toggleOTPSubmit(){let s=[];if(this.otpInputs.forEach((t=>t.value&&s.push(t.value))),this.code.value=s.join(""),4===s.length)return this.btn.disable(),void this.btn.click();this.btn.enable()}reset(){this.otpInputs.forEach((s=>s.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){this.resendMessage.style.display="block",this.resend.style.display="none",this.resendAfter=30;let s=setInterval((()=>{this.resendAfter<=0?(clearInterval(s),this.resend.style.display="block",this.resendMessage.style.display="none"):(this.timer.innerHTML=`${this.resendAfter>=10?this.resendAfter:"0"+this.resendAfter} : 00`,this.resendAfter--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((s=>s.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(this.data))).finally((()=>this.resendTimer()))}submit(){if(this.code.value.length<4)return this.otpInputs[this.code.value.length].focus(),void salla.log("Trying to submit without 4 digits!");let s={code:this.code.value,...this.data};return this.btn.load().then((()=>this.btn.disable())).then((()=>this.isProfileVerify?salla.profile.verify(s):salla.auth.verify(s,this.supportWebAuth))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.close())).then((()=>this.autoReload&&window.location.reload())).catch((s=>{this.hasError=!0,this.errorMessage=s.response?.data?.error?.message||salla.lang.get("common.errors.error_occurred"),s.response?salla.logger.error(s):console.log("Unexpected error",s),this.btn.stop()&&this.btn.enable()&&this.reset()}))}render(){return"inline"==this.display?i(e,null,this.myBody()):i("salla-modal",{width:"xs",class:"s-verify",ref:s=>this.modal=s,"modal-title":this.title},i("span",{slot:"icon",class:"s-verify-header-icon",innerHTML:"mobile"==this.type?'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>android-phone</title>\n<path d="M22.667 0h-13.333c-2.941 0-5.333 2.392-5.333 5.333v21.333c0 2.941 2.392 5.333 5.333 5.333h13.333c2.941 0 5.333-2.392 5.333-5.333v-21.333c0-2.941-2.392-5.333-5.333-5.333zM25.333 26.667c0 1.471-1.196 2.667-2.667 2.667h-13.333c-1.471 0-2.667-1.196-2.667-2.667v-2.667h18.667zM25.333 21.333h-18.667v-16c0-1.471 1.196-2.667 2.667-2.667h13.333c1.471 0 2.667 1.196 2.667 2.667zM13.333 28h5.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333z"></path>\n</svg>\n':r}),this.myBody())}myBody(){return i("div",{class:"s-verify-body",ref:s=>this.body=s},i("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),i("slot",{name:"mobile"}),i("slot",{name:"email"}),i("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:s=>this.code=s}),i("div",{class:{"s-verify-codes":!0,"has-error":this.hasError},dir:"ltr"},[1,2,3,4].map((s=>i("input",{type:"number",autocomplete:"one-time-code",pattern:"[0-9]*",inputmode:"numeric",maxlength:"1",value:"",id:`otp-${s}`,class:{"s-verify-input":!0,"s-has-error":this.hasError},onInput:s=>this.handleInput(s),onPaste:s=>this.handlePaste(s),onKeyUp:s=>this.handleKeyUp(s),onFocus:s=>this.handleFocus(s),required:!0})))),this.hasError&&this.errorMessage?i("span",{class:"s-verify-error-message"},this.errorMessage):"",i("div",{slot:"footer",class:"s-verify-footer"},i("salla-button",{class:"s-verify-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:s=>this.btn=s},salla.lang.get("pages.profile.verify")),i("p",{class:"s-verify-resend-message",ref:s=>this.resendMessage=s},salla.lang.get("blocks.header.resend_after"),i("b",{class:"s-verify-timer",ref:s=>this.timer=s})),i("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:s=>this.resend=s},salla.lang.get("blocks.comments.submit"))),i("slot",{name:"after-footer"}))}get host(){return h(this)}};l.style="salla-verify{display:block}.s-verify-input{}.s-verify-input::-webkit-outer-spin-button,.s-verify-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.s-verify-input[type=number]{-moz-appearance:textfield}";export{l as salla_verify}
4
+ import{r as s,c as t,h as i,H as e,a as h}from"./p-CkTB8LrG.js";import{M as r}from"./p-DmgxDvXL.js";const l=class{constructor(i){s(this,i),this.verified=t(this,"verified"),this.translationLoaded=!1,this.display="modal",this.type="mobile",this.autoReload=!0,this.supportWebAuth=!0,this.resendAfter=30,this.isProfileVerify=!1,salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+this.type),this.modal?.setTitle(this.title)})),"inline"!=this.display?(salla.event.on("profile::verification",(s=>{let t=Array.isArray(s)?s[0]:s;this.isProfileVerify=!0,this.open(t),this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+t.type),this.modal?.setTitle(this.title)})),salla.event.on("modalClosed",(()=>{this.resendAfter=0,this.timer.innerHTML="30 : 00"}))):this.modal={open:()=>"",close:()=>"",setTitle:()=>""}}splitNumber(s){this.resetError();let t=s.data||s.target.value;t&&1!==t.length&&this.modifyNext(s.target,t)}modifyNext(s,t){s.value=t[0],t=t.substring(1),s.nextElementSibling&&t.length?this.modifyNext(s.nextElementSibling,t):s.nextElementSibling||0!==t.length?s.nextElementSibling&&0===t.length&&s.nextElementSibling.focus():s.focus()}checkAllInputs(){let s=!0;for(let t=0;t<this.otpInputs.length;t++)""===this.otpInputs[t].value&&(s=!1);return s}handleKeyUp(s){if(this.resetError(),["Alt","Shift","Control","AltGraph","Ctrl"].includes(s.key))return;let t=s.keyCode||s.charCode;s.target.value?(s.target.nextElementSibling?.focus(),s.target.nextElementSibling?.select()):[8,46].includes(t)&&(s.target.previousElementSibling?.focus(),s.target.previousElementSibling?.select()),s.target.value.length>1&&this.splitNumber(s)}handlePaste(s){this.resetError();let t=(salla.helpers.number(s.clipboardData.getData("text"))||"").replace(/[^0-9]/g,"");t=t.substring(0,this.otpInputs.length),this.otpInputs.forEach((s=>s.value="")),this.modifyNext(this.otpInputs[0],t)}handleInput(s){this.resetError(),salla.helpers.inputDigitsOnly(s.target),this.checkAllInputs()&&setTimeout((()=>{this.toggleOTPSubmit()}),100)}resetError(){this.hasError=!1,this.errorMessage=""}handleFocus(s){s.target!==this.firstOtpInput&&(""==this.firstOtpInput?.value&&this.firstOtpInput.focus(),""==s.target.previousElementSibling.value&&s.target.previousElementSibling.focus())}async getCode(){return this.code.value}async open(s){this.data=s,this.data.type=this.data.type||this.type,this.type=this.data.type,this.resendTimer(),this.otpInputs=this.body.querySelectorAll(".s-verify-input"),this.firstOtpInput=this.body.querySelector("#otp-1"),this.reset(),this.resetError(),"modal"==this.display&&this.modal?.setTitle(this.title),this.modal.open(),this.firstOtpInput?.addEventListener("input",(s=>this.splitNumber(s))),setTimeout((()=>this.otpInputs[0].focus()),100)}toggleOTPSubmit(){let s=[];if(this.otpInputs.forEach((t=>t.value&&s.push(t.value))),this.code.value=s.join(""),4===s.length)return this.btn.disable(),void this.btn.click();this.btn.enable()}reset(){this.otpInputs.forEach((s=>s.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){this.resendMessage.style.display="block",this.resend.style.display="none",this.resendAfter=30;let s=setInterval((()=>{this.resendAfter<=0?(clearInterval(s),this.resend.style.display="block",this.resendMessage.style.display="none"):(this.timer.innerHTML=`${this.resendAfter>=10?this.resendAfter:"0"+this.resendAfter} : 00`,this.resendAfter--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((s=>s.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(this.data))).finally((()=>this.resendTimer()))}submit(){if(this.code.value.length<4)return this.otpInputs[this.code.value.length].focus(),void salla.log("Trying to submit without 4 digits!");let s={code:this.code.value,...this.data};return this.btn.load().then((()=>this.btn.disable())).then((()=>this.isProfileVerify?salla.profile.verify(s):salla.auth.verify(s,this.supportWebAuth))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.close())).then((()=>this.autoReload&&window.location.reload())).catch((s=>{this.hasError=!0,this.errorMessage=s.response?.data?.error?.message||salla.lang.get("common.errors.error_occurred"),s.response?salla.logger.error(s):console.log("Unexpected error",s),this.btn.stop()&&this.btn.enable()&&this.reset()}))}render(){return"inline"==this.display?i(e,null,this.myBody()):i("salla-modal",{width:"xs",class:"s-verify",ref:s=>this.modal=s,"modal-title":this.title},i("span",{slot:"icon",class:"s-verify-header-icon",innerHTML:"mobile"==this.type?'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>android-phone</title>\n<path d="M22.667 0h-13.333c-2.941 0-5.333 2.392-5.333 5.333v21.333c0 2.941 2.392 5.333 5.333 5.333h13.333c2.941 0 5.333-2.392 5.333-5.333v-21.333c0-2.941-2.392-5.333-5.333-5.333zM25.333 26.667c0 1.471-1.196 2.667-2.667 2.667h-13.333c-1.471 0-2.667-1.196-2.667-2.667v-2.667h18.667zM25.333 21.333h-18.667v-16c0-1.471 1.196-2.667 2.667-2.667h13.333c1.471 0 2.667 1.196 2.667 2.667zM13.333 28h5.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333z"></path>\n</svg>\n':r}),this.myBody())}myBody(){return i("div",{class:"s-verify-body",ref:s=>this.body=s},i("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),i("slot",{name:"mobile"}),i("slot",{name:"email"}),i("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:s=>this.code=s}),i("div",{class:{"s-verify-codes":!0,"has-error":this.hasError},dir:"ltr"},[1,2,3,4].map((s=>i("input",{type:"number",autocomplete:"one-time-code",pattern:"[0-9]*",inputmode:"numeric",maxlength:"1",value:"",id:`otp-${s}`,class:{"s-verify-input":!0,"s-has-error":this.hasError},onInput:s=>this.handleInput(s),onPaste:s=>this.handlePaste(s),onKeyUp:s=>this.handleKeyUp(s),onFocus:s=>this.handleFocus(s),required:!0})))),this.hasError&&this.errorMessage?i("span",{class:"s-verify-error-message"},this.errorMessage):"",i("div",{slot:"footer",class:"s-verify-footer"},i("salla-button",{class:"s-verify-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:s=>this.btn=s},salla.lang.get("pages.profile.verify")),i("p",{class:"s-verify-resend-message",ref:s=>this.resendMessage=s},salla.lang.get("blocks.header.resend_after"),i("b",{class:"s-verify-timer",ref:s=>this.timer=s})),i("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:s=>this.resend=s},salla.lang.get("blocks.comments.submit"))),i("slot",{name:"after-footer"}))}get host(){return h(this)}};l.style="salla-verify{display:block}.s-verify-input{}.s-verify-input::-webkit-outer-spin-button,.s-verify-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.s-verify-input[type=number]{-moz-appearance:textfield}";export{l as salla_verify}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as a,h as s,H as t,a as e}from"./p-DzTVR6sF.js";const i=class{constructor(s){if(a(this,s),this.entity="product",this.specs=[],this.download=salla.lang.get("pages.thank_you.download"),this.entityId)try{return void(this.entityId=Array.isArray(this.entityId)?this.entityId:JSON.parse(this.entityId))}catch(a){salla.log("Bad json passed via entityId prop")}}getValue(a){if("file"===a.type)return`<a href="${a.value}" class="text-primary" target="_blank"><span class="sicon-download"></span> ${this.download}</a>`;if("url"===a.type)return`<a href="${a.value}" class="text-blue-700 underline" target="_blank">${a.value}</a>`;if("date"===a.type){const s=new Date(a.value);return`${String(s.getDate()).padStart(2,"0")}/${String(s.getMonth()+1).padStart(2,"0")}/${s.getFullYear()}`}return a.value}async componentWillLoad(){if(await salla.onReady(),!salla.config.get("store.features")?.includes("custom-fields"))return salla.logger.error("feature custom-fields is not activated");if(this.entityId||!salla.url.is_page("product.single")&&!salla.url.is_page("product.showNewUrls")||(this.entityId=salla.config.get("page.id")),!this.entityId)return salla.logger.error("can't render salla-metadata without enity-id prop!");await salla.lang.onLoaded(),this.download=salla.lang.get("pages.thank_you.download");const a=await Salla.api.metadata.fetchValues(this.entity,this.entityId);this.specs=a.data[0]?.sections}render(){if(this.specs.length)return s(t,{class:"s-metadata-wrapper"},this.specs.map((a=>s("div",{class:"s-metadata-box"},s("div",{class:"s-metadata-box-header"},s("i",{class:"sicon-list"}),a.name),a.fields.map((a=>s("div",{class:"s-metadata-row"},s("p",{class:"s-metadata-row-name"},a.name),s("p",{class:"s-metadata-row-value",innerHTML:this.getValue(a)}))))))))}get host(){return e(this)}};i.style="";export{i as salla_metadata}
4
+ import{r as a,h as t,H as s,a as e}from"./p-CkTB8LrG.js";const i=class{constructor(t){if(a(this,t),this.entity="product",this.specs=[],this.download=salla.lang.get("pages.thank_you.download"),this.entityId)try{return void(this.entityId=Array.isArray(this.entityId)?this.entityId:JSON.parse(this.entityId))}catch(a){salla.log("Bad json passed via entityId prop")}}getValue(a){if("file"===a.type)return`<a href="${a.value}" class="text-primary" target="_blank"><span class="sicon-download"></span> ${this.download}</a>`;if("url"===a.type)return`<a href="${a.value}" class="text-blue-700 underline" target="_blank">${a.value}</a>`;if("date"===a.type){const t=new Date(a.value);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}return a.value}async componentWillLoad(){if(await salla.onReady(),!salla.config.get("store.features")?.includes("custom-fields"))return salla.logger.error("feature custom-fields is not activated");if(this.entityId||!salla.url.is_page("product.single")&&!salla.url.is_page("product.showNewUrls")||(this.entityId=salla.config.get("page.id")),!this.entityId)return salla.logger.error("can't render salla-metadata without enity-id prop!");await salla.lang.onLoaded(),this.download=salla.lang.get("pages.thank_you.download");const a=await Salla.api.metadata.fetchValues(this.entity,this.entityId);this.specs=a.data[0]?.sections}render(){if(this.specs.length)return t(s,{class:"s-metadata-wrapper"},this.specs.map((a=>t("div",{class:"s-metadata-box"},t("div",{class:"s-metadata-box-header"},t("i",{class:"sicon-list"}),a.name),a.fields.map((a=>t("div",{class:"s-metadata-row"},t("p",{class:"s-metadata-row-name"},a.name),t("p",{class:"s-metadata-row-value",innerHTML:this.getValue(a)}))))))))}get host(){return e(this)}};i.style="";export{i as salla_metadata}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,F as e,H as a}from"./p-DzTVR6sF.js";const r=class{constructor(t){s(this,t)}parseOrderDetailsData(s){this.parsedOrderDetailsData=s,this.parsedOrderDetailsData="string"==typeof this.orderDetails?JSON.parse(s):s}componentWillLoad(){this.parseOrderDetailsData(this.orderDetails),console.log("Parent componentWillLoad - parsedOrderDetailsData:",this.parsedOrderDetailsData)}renderOrderDetailsContent(){return this.parsedOrderDetailsData?[this.parsedOrderDetailsData.options&&this.parsedOrderDetailsData.options.length>0&&t("salla-order-details-options",{options:this.parsedOrderDetailsData.options}),this.parsedOrderDetailsData.sub_products&&this.parsedOrderDetailsData.sub_products.length>0&&t(e,null,t("h2",{class:"s-order-details-bundle-title"},salla.lang.get("pages.orders.sub_products")),t("div",{class:"s-order-details-bundle-content"},this.parsedOrderDetailsData.sub_products.map((s=>t("salla-order-details-multiple-bundle-product",{key:s?.id,productDetails:s})))))]:(console.warn("No parsedOrderDetailsData available"),null)}render(){return t(a,{key:"ca263aa861d52fdf36b6a842f6e58d07f27a6d1f",class:"s-order-details-wrapper"},this.renderOrderDetailsContent())}static get watchers(){return{orderDetails:["parseOrderDetailsData"]}}};r.style="";export{r as salla_order_details}
4
+ import{r as s,h as t,F as e,H as a}from"./p-CkTB8LrG.js";const r=class{constructor(t){s(this,t)}parseOrderDetailsData(s){this.parsedOrderDetailsData=s,this.parsedOrderDetailsData="string"==typeof this.orderDetails?JSON.parse(s):s}componentWillLoad(){this.parseOrderDetailsData(this.orderDetails),console.log("Parent componentWillLoad - parsedOrderDetailsData:",this.parsedOrderDetailsData)}renderOrderDetailsContent(){return this.parsedOrderDetailsData?[this.parsedOrderDetailsData.options&&this.parsedOrderDetailsData.options.length>0&&t("salla-order-details-options",{options:this.parsedOrderDetailsData.options}),this.parsedOrderDetailsData.sub_products&&this.parsedOrderDetailsData.sub_products.length>0&&t(e,null,t("h2",{class:"s-order-details-bundle-title"},salla.lang.get("pages.orders.sub_products")),t("div",{class:"s-order-details-bundle-content"},this.parsedOrderDetailsData.sub_products.map((s=>t("salla-order-details-multiple-bundle-product",{key:s?.id,productDetails:s})))))]:(console.warn("No parsedOrderDetailsData available"),null)}render(){return t(a,{key:"ca263aa861d52fdf36b6a842f6e58d07f27a6d1f",class:"s-order-details-wrapper"},this.renderOrderDetailsContent())}static get watchers(){return{orderDetails:["parseOrderDetailsData"]}}};r.style="";export{r as salla_order_details}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t}from"./p-DzTVR6sF.js";import{S as i,A as e}from"./p-yRO-ZESF.js";import{G as c}from"./p-C0JNGIpa.js";const a=class{constructor(t){s(this,t),this.internalOffers=[],this.showAll=!1,this.freeLabel="",this.receivedOffer="",this.discountAmountLabel="",this.showMoreOffers="",this.icons={DiscountCouponIcon:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>discount-coupon</title>\n<path d="M27 28h-22c-0.552 0-1-0.448-1-1v0c0-1.657-1.343-3-3-3v0c-0.552 0-1-0.448-1-1v0-12c0-0.552 0.448-1 1-1v0c1.657 0 3-1.343 3-3v0c0-0.552 0.448-1 1-1v0h22c0.552 0 1 0.448 1 1v0c0 1.657 1.343 3 3 3v0c0.552 0 1 0.448 1 1v0 12c0 0.552-0.448 1-1 1v0c-1.657 0-3 1.343-3 3v0c0 0.552-0.448 1-1 1v0zM5.9 26h20.2c0.415-1.964 1.936-3.485 3.867-3.894l0.033-0.006v-10.2c-1.964-0.415-3.485-1.936-3.894-3.867l-0.006-0.033h-20.2c-0.415 1.964-1.936 3.485-3.867 3.894l-0.033 0.006v10.2c1.964 0.415 3.485 1.936 3.894 3.867l0.006 0.033zM20 7h2v3h-2v-3zM20 12h2v4h-2v-4zM20 18h2v4h-2v-4zM20 24h2v3h-2v-3zM9 16c-1.657 0-3-1.343-3-3s1.343-3 3-3c1.657 0 3 1.343 3 3v0c0 1.657-1.343 3-3 3v0zM9 12c-0.552 0-1 0.448-1 1s0.448 1 1 1c0.552 0 1-0.448 1-1v0c0-0.552-0.448-1-1-1v0zM15 24c-1.657 0-3-1.343-3-3s1.343-3 3-3c1.657 0 3 1.343 3 3v0c0 1.657-1.343 3-3 3v0zM15 20c-0.552 0-1 0.448-1 1s0.448 1 1 1c0.552 0 1-0.448 1-1v0c0-0.552-0.448-1-1-1v0zM7 24c-0.552-0-1-0.448-1-1 0-0.244 0.088-0.468 0.233-0.642l-0.001 0.002 10-12c0.185-0.221 0.461-0.36 0.769-0.36 0.553 0 1.001 0.448 1.001 1.001 0 0.245-0.088 0.469-0.233 0.643l0.001-0.002-10 12c-0.185 0.22-0.46 0.358-0.767 0.358-0.001 0-0.002 0-0.003 0h0z"></path>\n</svg>\n',GiftIcon:c,FireIcon:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>fire</title>\n<path d="M21.56 3.009c-0.052-0.047-0.116-0.065-0.173-0.103-0.073-0.048-0.143-0.1-0.223-0.132-0.083-0.033-0.165-0.047-0.252-0.063-0.081-0.016-0.16-0.035-0.243-0.035-0.089 0-0.172 0.020-0.26 0.037-0.080 0.016-0.159 0.028-0.236 0.059-0.084 0.035-0.157 0.088-0.235 0.14-0.053 0.036-0.115 0.053-0.165 0.097-0.049 0.044-0.988 0.895-2.288 2.255-2.364-2.839-4.476-4.815-4.576-4.908-0.056-0.052-0.127-0.075-0.188-0.115-0.075-0.049-0.143-0.105-0.224-0.137-0.080-0.032-0.163-0.041-0.245-0.057-0.085-0.016-0.167-0.040-0.252-0.040-0.084 0-0.163 0.023-0.245 0.039-0.087 0.016-0.172 0.025-0.253 0.059-0.080 0.032-0.147 0.087-0.22 0.135-0.063 0.041-0.133 0.064-0.189 0.116-0.453 0.423-11.092 10.408-11.092 18.095 0 7.977 4.935 13.549 12 13.549h8.667c6.673 0 11.333-5.115 11.333-12.439 0-7.052-10.013-16.167-10.44-16.552zM20.667 29.333h-7.777c-2.924 0-4.889-2.044-4.889-5.084 0-2.317 2.816-6.441 4.888-8.887 0.76 0.909 2.755 3.397 3.969 5.869 0.212 0.431 0.639 0.715 1.117 0.743 0.489 0.031 0.937-0.203 1.197-0.605 0.552-0.849 1.109-1.596 1.497-2.093 1.491 1.897 3.331 4.78 3.331 6.399 0 2.188-1.34 3.659-3.333 3.659zM26.537 27.052c0.081-0.44 0.129-0.899 0.129-1.377 0-3.269-3.713-7.847-4.46-8.735l-0.523-0.617c-0.507-0.599-1.528-0.599-2.035 0l-0.531 0.627c-0.147 0.175-0.495 0.599-0.936 1.187-1.595-2.597-3.495-4.776-3.595-4.889l-0.697-0.793c-0.507-0.577-1.499-0.577-2.004 0l-0.697 0.795c-0.6 0.684-5.856 6.803-5.856 11.001 0 0.881 0.127 1.712 0.356 2.484-1.896-1.933-3.023-4.821-3.023-8.283 0-4.915 6.073-11.997 9.329-15.255 1.001 1.008 2.692 2.789 4.368 4.927 0.243 0.309 0.609 0.496 1.001 0.509h0.048c0.376 0 0.735-0.159 0.988-0.439 0.889-0.981 1.693-1.795 2.269-2.359 3.051 2.965 8.663 9.323 8.663 13.727 0 3.171-1.031 5.769-2.796 7.491z"></path>\n</svg>\n',SpecialDiscountIcon:i,TagMoneyIcon:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>tag-money</title>\n<path d="M20.567 11.433c-0.521-0.521-1.364-0.521-1.885 0l-0.524 0.524c-1.28-0.819-3.091-0.681-4.191 0.419-0.631 0.631-0.976 1.468-0.976 2.359 0 0.889 0.347 1.727 0.976 2.357l0.943 0.943c0.171 0.171 0.195 0.368 0.195 0.472s-0.025 0.301-0.196 0.472c-0.169 0.169-0.367 0.195-0.471 0.195s-0.301-0.025-0.472-0.195l-2.357-2.357c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l0.944 0.941-0.472 0.472c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l0.519-0.519c0.54 0.359 1.173 0.553 1.837 0.553 0.892 0 1.729-0.348 2.357-0.976 0.631-0.631 0.976-1.467 0.976-2.357s-0.347-1.727-0.976-2.357l-0.943-0.943c-0.26-0.26-0.26-0.684 0-0.944 0.259-0.259 0.683-0.261 0.944 0l1.885 1.887c0.521 0.521 1.364 0.521 1.885 0 0.521-0.52 0.521-1.364 0-1.885l-0.472-0.472 0.472-0.472c0.521-0.521 0.521-1.365 0.001-1.887zM28 0h-9.344c-1.059 0-2.056 0.411-2.809 1.153l-14.673 14.456c-1.56 1.56-1.561 4.097-0.001 5.657l9.56 9.56c0.755 0.755 1.76 1.172 2.828 1.173h0.003c1.068 0 2.072-0.416 2.833-1.179l14.451-14.668c0.743-0.753 1.153-1.751 1.153-2.809v-9.344c0-2.205-1.795-4-4-4zM29.333 13.344c0 0.353-0.137 0.685-0.385 0.937l-14.444 14.661c-0.252 0.252-0.587 0.391-0.941 0.391-0.001 0-0.001 0-0.001 0-0.356-0.001-0.691-0.139-0.943-0.392l-9.561-9.56c-0.52-0.52-0.52-1.365-0.005-1.88l14.667-14.449c0.253-0.248 0.585-0.385 0.937-0.385h9.344c0.736 0 1.333 0.597 1.333 1.333zM24 6.673c-0.737 0-1.333 0.604-1.333 1.341s0.596 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.015c0-0.737-0.596-1.327-1.333-1.327z"></path>\n</svg>\n'},this.visibleOffersCount=3,this.handleCartItemUpdated=s=>{const t=s.data.cart.items.find((s=>s.id===this.itemId));t?.id===this.itemId&&(this.internalQuantity=t.quantity,this.internalOffers=t.detailed_offers||[],this.internalProductPrice=t.product_price)},this.toggleShowAll=()=>{this.showAll=!this.showAll}}async componentWillLoad(){await Salla.onReady(),await salla.lang.onLoaded((()=>{this.freeLabel=salla.lang.get("common.elements.freeExclam"),this.receivedOffer=salla.lang.get("pages.cart.received_offer"),this.discountAmountLabel=salla.lang.get("pages.cart.discount_amount"),this.showMoreOffers=salla.lang.get("pages.cart.show_more_offers")})),this.internalQuantity=this.quantity,this.internalOffers=this.parseOffers(this.offers),this.internalProductPrice=this.productPrice}componentDidLoad(){salla.event.on("cart::item.updated",(s=>this.handleCartItemUpdated(s)))}parseOffers(s){try{return"string"!=typeof s?(console.warn("Offers is not a string. Returning as-is.",s),Array.isArray(s)?s:[]):JSON.parse(s||"[]")}catch(s){return console.error("Failed to parse offers",s),[]}}get visibleOffers(){return this.internalOffers.slice(0,this.visibleOffersCount)}get hiddenOffers(){return this.internalOffers.slice(this.visibleOffersCount)}getPaidQty(s,t){return s-t.free_quantity}renderOffer(s,i){const e=this.getPaidQty(s,i);return t("div",{class:"s-cart-item-offers-box"},i.free_quantity>0&&e>0&&t("div",{class:"s-cart-item-offers-paid-free"},t("div",{class:"s-cart-item-offers-line"},salla.helpers.number(e)," × ",t("span",{innerHTML:salla.money(this.internalProductPrice)})),t("div",{class:"s-cart-item-offers-line"},salla.helpers.number(i.free_quantity)," ×",t("span",{class:"s-cart-item-offers-regular-price",innerHTML:salla.money(this.internalProductPrice)}),t("span",{class:"s-cart-item-offers-free-label"},this.freeLabel))),t("div",{class:"s-cart-item-offers-details"},t("span",{class:"s-cart-item-offers-icon",innerHTML:this.icons[i.discount_icon]||""}),t("div",null,t("p",{class:"s-cart-item-offers-title"},this.receivedOffer.replace(":offer",i.offer_name)),t("p",{class:"s-cart-item-offers-discount"},t("span",{innerHTML:this.discountAmountLabel.replace(":amount",salla.money(i.discount_amount.toFixed(2)))})))))}render(){return this.internalOffers?.length?t("div",{class:"s-cart-item-offers-container",id:`offers_list_${this.itemId}`},this.visibleOffers.map((s=>this.renderOffer(this.internalQuantity,s))),this.internalOffers?.length>this.visibleOffersCount&&t("div",{class:"s-cart-item-offers-show-more"},t("button",{class:"s-cart-item-offers-show-more-btn",onClick:this.toggleShowAll,type:"button"},t("span",{class:"s-cart-item-offers-show-more-label"},"+",this.hiddenOffers.length," ",this.showMoreOffers,t("span",{innerHTML:e,class:{"s-cart-item-offers-arrow-icon":!0,"s-cart-item-offers-arrow-open":this.showAll}})))),this.showAll&&t("div",{class:"s-cart-item-offers-collapsed",id:`offers_${this.itemId}`},this.hiddenOffers.map((s=>this.renderOffer(this.internalQuantity,s))))):null}};a.style=":host{display:block}";export{a as salla_cart_item_offers}
4
+ import{r as s,h as t}from"./p-CkTB8LrG.js";import{S as i,A as e}from"./p-yRO-ZESF.js";import{G as c}from"./p-C0JNGIpa.js";const a=class{constructor(t){s(this,t),this.internalOffers=[],this.showAll=!1,this.freeLabel="",this.receivedOffer="",this.discountAmountLabel="",this.showMoreOffers="",this.icons={DiscountCouponIcon:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>discount-coupon</title>\n<path d="M27 28h-22c-0.552 0-1-0.448-1-1v0c0-1.657-1.343-3-3-3v0c-0.552 0-1-0.448-1-1v0-12c0-0.552 0.448-1 1-1v0c1.657 0 3-1.343 3-3v0c0-0.552 0.448-1 1-1v0h22c0.552 0 1 0.448 1 1v0c0 1.657 1.343 3 3 3v0c0.552 0 1 0.448 1 1v0 12c0 0.552-0.448 1-1 1v0c-1.657 0-3 1.343-3 3v0c0 0.552-0.448 1-1 1v0zM5.9 26h20.2c0.415-1.964 1.936-3.485 3.867-3.894l0.033-0.006v-10.2c-1.964-0.415-3.485-1.936-3.894-3.867l-0.006-0.033h-20.2c-0.415 1.964-1.936 3.485-3.867 3.894l-0.033 0.006v10.2c1.964 0.415 3.485 1.936 3.894 3.867l0.006 0.033zM20 7h2v3h-2v-3zM20 12h2v4h-2v-4zM20 18h2v4h-2v-4zM20 24h2v3h-2v-3zM9 16c-1.657 0-3-1.343-3-3s1.343-3 3-3c1.657 0 3 1.343 3 3v0c0 1.657-1.343 3-3 3v0zM9 12c-0.552 0-1 0.448-1 1s0.448 1 1 1c0.552 0 1-0.448 1-1v0c0-0.552-0.448-1-1-1v0zM15 24c-1.657 0-3-1.343-3-3s1.343-3 3-3c1.657 0 3 1.343 3 3v0c0 1.657-1.343 3-3 3v0zM15 20c-0.552 0-1 0.448-1 1s0.448 1 1 1c0.552 0 1-0.448 1-1v0c0-0.552-0.448-1-1-1v0zM7 24c-0.552-0-1-0.448-1-1 0-0.244 0.088-0.468 0.233-0.642l-0.001 0.002 10-12c0.185-0.221 0.461-0.36 0.769-0.36 0.553 0 1.001 0.448 1.001 1.001 0 0.245-0.088 0.469-0.233 0.643l0.001-0.002-10 12c-0.185 0.22-0.46 0.358-0.767 0.358-0.001 0-0.002 0-0.003 0h0z"></path>\n</svg>\n',GiftIcon:c,FireIcon:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>fire</title>\n<path d="M21.56 3.009c-0.052-0.047-0.116-0.065-0.173-0.103-0.073-0.048-0.143-0.1-0.223-0.132-0.083-0.033-0.165-0.047-0.252-0.063-0.081-0.016-0.16-0.035-0.243-0.035-0.089 0-0.172 0.020-0.26 0.037-0.080 0.016-0.159 0.028-0.236 0.059-0.084 0.035-0.157 0.088-0.235 0.14-0.053 0.036-0.115 0.053-0.165 0.097-0.049 0.044-0.988 0.895-2.288 2.255-2.364-2.839-4.476-4.815-4.576-4.908-0.056-0.052-0.127-0.075-0.188-0.115-0.075-0.049-0.143-0.105-0.224-0.137-0.080-0.032-0.163-0.041-0.245-0.057-0.085-0.016-0.167-0.040-0.252-0.040-0.084 0-0.163 0.023-0.245 0.039-0.087 0.016-0.172 0.025-0.253 0.059-0.080 0.032-0.147 0.087-0.22 0.135-0.063 0.041-0.133 0.064-0.189 0.116-0.453 0.423-11.092 10.408-11.092 18.095 0 7.977 4.935 13.549 12 13.549h8.667c6.673 0 11.333-5.115 11.333-12.439 0-7.052-10.013-16.167-10.44-16.552zM20.667 29.333h-7.777c-2.924 0-4.889-2.044-4.889-5.084 0-2.317 2.816-6.441 4.888-8.887 0.76 0.909 2.755 3.397 3.969 5.869 0.212 0.431 0.639 0.715 1.117 0.743 0.489 0.031 0.937-0.203 1.197-0.605 0.552-0.849 1.109-1.596 1.497-2.093 1.491 1.897 3.331 4.78 3.331 6.399 0 2.188-1.34 3.659-3.333 3.659zM26.537 27.052c0.081-0.44 0.129-0.899 0.129-1.377 0-3.269-3.713-7.847-4.46-8.735l-0.523-0.617c-0.507-0.599-1.528-0.599-2.035 0l-0.531 0.627c-0.147 0.175-0.495 0.599-0.936 1.187-1.595-2.597-3.495-4.776-3.595-4.889l-0.697-0.793c-0.507-0.577-1.499-0.577-2.004 0l-0.697 0.795c-0.6 0.684-5.856 6.803-5.856 11.001 0 0.881 0.127 1.712 0.356 2.484-1.896-1.933-3.023-4.821-3.023-8.283 0-4.915 6.073-11.997 9.329-15.255 1.001 1.008 2.692 2.789 4.368 4.927 0.243 0.309 0.609 0.496 1.001 0.509h0.048c0.376 0 0.735-0.159 0.988-0.439 0.889-0.981 1.693-1.795 2.269-2.359 3.051 2.965 8.663 9.323 8.663 13.727 0 3.171-1.031 5.769-2.796 7.491z"></path>\n</svg>\n',SpecialDiscountIcon:i,TagMoneyIcon:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>tag-money</title>\n<path d="M20.567 11.433c-0.521-0.521-1.364-0.521-1.885 0l-0.524 0.524c-1.28-0.819-3.091-0.681-4.191 0.419-0.631 0.631-0.976 1.468-0.976 2.359 0 0.889 0.347 1.727 0.976 2.357l0.943 0.943c0.171 0.171 0.195 0.368 0.195 0.472s-0.025 0.301-0.196 0.472c-0.169 0.169-0.367 0.195-0.471 0.195s-0.301-0.025-0.472-0.195l-2.357-2.357c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l0.944 0.941-0.472 0.472c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l0.519-0.519c0.54 0.359 1.173 0.553 1.837 0.553 0.892 0 1.729-0.348 2.357-0.976 0.631-0.631 0.976-1.467 0.976-2.357s-0.347-1.727-0.976-2.357l-0.943-0.943c-0.26-0.26-0.26-0.684 0-0.944 0.259-0.259 0.683-0.261 0.944 0l1.885 1.887c0.521 0.521 1.364 0.521 1.885 0 0.521-0.52 0.521-1.364 0-1.885l-0.472-0.472 0.472-0.472c0.521-0.521 0.521-1.365 0.001-1.887zM28 0h-9.344c-1.059 0-2.056 0.411-2.809 1.153l-14.673 14.456c-1.56 1.56-1.561 4.097-0.001 5.657l9.56 9.56c0.755 0.755 1.76 1.172 2.828 1.173h0.003c1.068 0 2.072-0.416 2.833-1.179l14.451-14.668c0.743-0.753 1.153-1.751 1.153-2.809v-9.344c0-2.205-1.795-4-4-4zM29.333 13.344c0 0.353-0.137 0.685-0.385 0.937l-14.444 14.661c-0.252 0.252-0.587 0.391-0.941 0.391-0.001 0-0.001 0-0.001 0-0.356-0.001-0.691-0.139-0.943-0.392l-9.561-9.56c-0.52-0.52-0.52-1.365-0.005-1.88l14.667-14.449c0.253-0.248 0.585-0.385 0.937-0.385h9.344c0.736 0 1.333 0.597 1.333 1.333zM24 6.673c-0.737 0-1.333 0.604-1.333 1.341s0.596 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.015c0-0.737-0.596-1.327-1.333-1.327z"></path>\n</svg>\n'},this.visibleOffersCount=3,this.handleCartItemUpdated=s=>{const t=s.data.cart.items.find((s=>s.id===this.itemId));t?.id===this.itemId&&(this.internalQuantity=t.quantity,this.internalOffers=t.detailed_offers||[],this.internalProductPrice=t.product_price)},this.toggleShowAll=()=>{this.showAll=!this.showAll}}async componentWillLoad(){await Salla.onReady(),await salla.lang.onLoaded((()=>{this.freeLabel=salla.lang.get("common.elements.freeExclam"),this.receivedOffer=salla.lang.get("pages.cart.received_offer"),this.discountAmountLabel=salla.lang.get("pages.cart.discount_amount"),this.showMoreOffers=salla.lang.get("pages.cart.show_more_offers")})),this.internalQuantity=this.quantity,this.internalOffers=this.parseOffers(this.offers),this.internalProductPrice=this.productPrice}componentDidLoad(){salla.event.on("cart::item.updated",(s=>this.handleCartItemUpdated(s)))}parseOffers(s){try{return"string"!=typeof s?(console.warn("Offers is not a string. Returning as-is.",s),Array.isArray(s)?s:[]):JSON.parse(s||"[]")}catch(s){return console.error("Failed to parse offers",s),[]}}get visibleOffers(){return this.internalOffers.slice(0,this.visibleOffersCount)}get hiddenOffers(){return this.internalOffers.slice(this.visibleOffersCount)}getPaidQty(s,t){return s-t.free_quantity}renderOffer(s,i){const e=this.getPaidQty(s,i);return t("div",{class:"s-cart-item-offers-box"},i.free_quantity>0&&e>0&&t("div",{class:"s-cart-item-offers-paid-free"},t("div",{class:"s-cart-item-offers-line"},salla.helpers.number(e)," × ",t("span",{innerHTML:salla.money(this.internalProductPrice)})),t("div",{class:"s-cart-item-offers-line"},salla.helpers.number(i.free_quantity)," ×",t("span",{class:"s-cart-item-offers-regular-price",innerHTML:salla.money(this.internalProductPrice)}),t("span",{class:"s-cart-item-offers-free-label"},this.freeLabel))),t("div",{class:"s-cart-item-offers-details"},t("span",{class:"s-cart-item-offers-icon",innerHTML:this.icons[i.discount_icon]||""}),t("div",null,t("p",{class:"s-cart-item-offers-title"},this.receivedOffer.replace(":offer",i.offer_name)),t("p",{class:"s-cart-item-offers-discount"},t("span",{innerHTML:this.discountAmountLabel.replace(":amount",salla.money(i.discount_amount.toFixed(2)))})))))}render(){return this.internalOffers?.length?t("div",{class:"s-cart-item-offers-container",id:`offers_list_${this.itemId}`},this.visibleOffers.map((s=>this.renderOffer(this.internalQuantity,s))),this.internalOffers?.length>this.visibleOffersCount&&t("div",{class:"s-cart-item-offers-show-more"},t("button",{class:"s-cart-item-offers-show-more-btn",onClick:this.toggleShowAll,type:"button"},t("span",{class:"s-cart-item-offers-show-more-label"},"+",this.hiddenOffers.length," ",this.showMoreOffers,t("span",{innerHTML:e,class:{"s-cart-item-offers-arrow-icon":!0,"s-cart-item-offers-arrow-open":this.showAll}})))),this.showAll&&t("div",{class:"s-cart-item-offers-collapsed",id:`offers_${this.itemId}`},this.hiddenOffers.map((s=>this.renderOffer(this.internalQuantity,s))))):null}};a.style=":host{display:block}";export{a as salla_cart_item_offers}
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as e,c as t,h as i,H as s}from"./p-CkTB8LrG.js";const a=class{constructor(i){e(this,i),this.prizeItemSelected=t(this,"prizeItemSelected")}onPrizeItemClick(){this.prizeItemSelected.emit(this.item)}render(){return i(s,{key:"1a3463c51bf3e3e250f62b65d3a81815ec465923"},i("div",{key:"03bf4d3e35b10d17a325ca4ef280cb384f3a76f4",onClick:this.onPrizeItemClick.bind(this)},i("img",{key:"a4d319b2daec5cdfec1c85910edea10bc1d1ab6c",class:"s-loyalty-prize-item-image",src:this.item.image,alt:this.item.name}),i("div",{key:"52059fafc318c1f5a6b0289669083476650f8761",class:"s-loyalty-prize-item-title"},this.item.name),i("div",{key:"a3e14e2d1bd86dc3e7dbd2e6c5115e119af965e5",class:"s-loyalty-prize-item-subtitle"},this.item.description),i("div",{key:"55df95c028748c0387dc75dc4ad35c7285c907af",class:"s-loyalty-prize-item-points"},this.item.cost_points," Points")))}};a.style="salla-loyalty-prize-item:hover{box-shadow:0 5px 15px 1px rgba(0, 0, 0, 0.04) !important}";export{a as salla_loyalty_prize_item}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as i,H as e}from"./p-DzTVR6sF.js";var s,a;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product"}(s||(s={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(a||(a={}));const n=class{constructor(i){t(this,i),this.offer=null,this.products={},this.isLoading=!1,this.canRender=!0}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.features")?.includes("conditional-offer")||""!==salla.storage.get("cart")&&!salla.storage.get("cart")?.summary?.count)throw new Error("feature or cart object does not existed")})).then((()=>salla.api.cart.offers())).then((({data:t})=>{if(this.offer=t.find((t=>"conditional"===t.type)),this.offer)return this.isLoading=!0,this.offer.details.discounts.unshift({value:0,min_spend:0}),this.updateInitialOfferValue();this.canRender=!1})).then((()=>{if(this.offer)return this.getProducts()})).then((()=>{this.offer&&salla.event.on("cart::updated",(t=>this.updateOfferValues(t)))})).catch((t=>{this.canRender=!1,salla.logger.warn("salla-conditional-offer:: ",t)})).finally((()=>{this.isLoading=!1}))}getProducts(){const t=this.offer.details.discounts.filter((({type:t})=>t===s.FREE_PRODUCT)).map((({value:t})=>t));if(t.length>0)return salla.product.fetch({source:"selected",source_value:t}).then((({data:t})=>{t.forEach((({id:t,url:i,image:e})=>{this.products[t]={url:i,image:e}}))}))}updateInitialOfferValue(){return salla.api.cart.details().then((({data:{cart:t}})=>this.updateOfferValues(t)))}updateOfferValues({items:t,sub_total:i}){const e=this.offer.details.based_on===a.PRODUCT_COUNT?t?.reduce(((t,{quantity:i})=>t+i),0)??0:i;return this.offer={...this.offer,details:{...this.offer?.details,current_value:e}},this.offer}getCheckpointContent(t){if(t.type===s.PERCENTAGE)return`${t.value}%`;if(t.type===s.FIXED)return salla.money(t.value);if(t.type!==s.FREE_PRODUCT)return salla.logger.error(`salla-conditional-offer:: unexpected type (${t.type})!`),"";const e=this.products[t.value];return e?i("a",{class:"s-conditional-offer-product-link",href:e.url},i("img",{class:"s-conditional-offer-checkpoint-image-content",loading:"lazy",decoding:"async",alt:e?.image?.alt||"",src:e?.image?.url})):(salla.logger.error(`salla-conditional-offer:: there is no product with id (${t.value})!`),"")}getOfferType(t){const i=this.offer.details?.based_on;return i===a.PRODUCT_COUNT?salla.lang.choice("blocks.header.products_count",t.min_spend):i===a.PRODUCT_PURCHASE?salla.money(t.min_spend):(salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${i}`),`${t.min_spend}`)}clamp(t,i,e){return Math.max(i,Math.min(t,e))}mapValueRanges(t,i,e,s,a){const n=(t-i)*(a-s)/(e-i)+s;return n===Number.POSITIVE_INFINITY?100:n===Number.NEGATIVE_INFINITY?0:this.clamp(n,0,100)}getCheckPointView(t,e){const s=this.offer.details.discounts.findIndex((({min_spend:i})=>i===t.min_spend)),a=this.mapValueRanges(this.offer.details.current_value,this.offer.details.discounts[s-1]?.min_spend??0,t.min_spend,0,100),n=t.min_spend<=this.offer.details.current_value;return i("div",{class:"s-conditional-offer-checkpoint-container"},e>0?[i("div",{key:"progress-line",class:"s-conditional-offer-progress-line-container"},i("div",{class:"s-conditional-offer-progress-line-inactive"}),i("div",{class:"s-conditional-offer-progress-line-active",style:{width:`${a}%`}})),i("div",{key:"checkpoint",class:"s-conditional-offer-checkpoint "+(n?"s-conditional-offer-active-checkpoint":"")},i("div",{class:"s-conditional-offer-item-avatar-content "+(n?"active":""),innerHTML:this.products&&this.getCheckpointContent(t)}),i("div",{class:"s-conditional-offer-checkpoint-label "+(n?"active":""),innerHTML:this.getOfferType(t)}))]:i("div",{key:"label",class:{"s-conditional-offer-checkpoint-label":!0,"first-checkpoint":0===e,active:n},innerHTML:this.getOfferType(t)}))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-container"},i("div",{class:"s-conditional-offer-skeleton-inner-container"},i("div",{class:"s-conditional-offer-skeleton-subtitle"},i("salla-skeleton",{height:"16px",width:"30%"})),i("div",{class:"s-conditional-offer-skeleton-subtitle"},i("salla-skeleton",{height:"16px",width:"35%"})),i("div",{class:"s-conditional-offer-skeleton-checkpoints-wrapper"},Array(3).fill(null).map((()=>[i("salla-skeleton",{key:"checkpoint-line",height:"8px"}),i("div",{key:"checkpoint"},i("salla-skeleton",{height:"60px",width:"60px",type:"circle"}))])))))}render(){return this.canRender?this.isLoading?this.getLoadingSkeletonView():this.offer?i(e,{class:"s-conditional-offer-container"},i("div",{class:"s-conditional-offer-title-wrapper"},i("div",{class:"s-conditional-offer-title"},this.offer.title),this.offer.description?i("div",{class:"s-conditional-offer-subtitle"},this.offer.description," ",i("i",{class:"sicon-information"})):null),i("div",{class:"s-conditional-offer-progress-container"},this.offer.details.discounts.map(((t,e)=>i("div",{class:{"flex-1":e>0},key:t.min_spend},this.getCheckPointView(t,e)))))):null:null}};n.style=":host{display:block}";export{n as salla_conditional_offer}
4
+ import{r as t,h as i,H as e}from"./p-CkTB8LrG.js";var s,a;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product"}(s||(s={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(a||(a={}));const n=class{constructor(i){t(this,i),this.offer=null,this.products={},this.isLoading=!1,this.canRender=!0}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.features")?.includes("conditional-offer")||""!==salla.storage.get("cart")&&!salla.storage.get("cart")?.summary?.count)throw new Error("feature or cart object does not existed")})).then((()=>salla.api.cart.offers())).then((({data:t})=>{if(this.offer=t.find((t=>"conditional"===t.type)),this.offer)return this.isLoading=!0,this.offer.details.discounts.unshift({value:0,min_spend:0}),this.updateInitialOfferValue();this.canRender=!1})).then((()=>{if(this.offer)return this.getProducts()})).then((()=>{this.offer&&salla.event.on("cart::updated",(t=>this.updateOfferValues(t)))})).catch((t=>{this.canRender=!1,salla.logger.warn("salla-conditional-offer:: ",t)})).finally((()=>{this.isLoading=!1}))}getProducts(){const t=this.offer.details.discounts.filter((({type:t})=>t===s.FREE_PRODUCT)).map((({value:t})=>t));if(t.length>0)return salla.product.fetch({source:"selected",source_value:t}).then((({data:t})=>{t.forEach((({id:t,url:i,image:e})=>{this.products[t]={url:i,image:e}}))}))}updateInitialOfferValue(){return salla.api.cart.details().then((({data:{cart:t}})=>this.updateOfferValues(t)))}updateOfferValues({items:t,sub_total:i}){const e=this.offer.details.based_on===a.PRODUCT_COUNT?t?.reduce(((t,{quantity:i})=>t+i),0)??0:i;return this.offer={...this.offer,details:{...this.offer?.details,current_value:e}},this.offer}getCheckpointContent(t){if(t.type===s.PERCENTAGE)return`${t.value}%`;if(t.type===s.FIXED)return salla.money(t.value);if(t.type!==s.FREE_PRODUCT)return salla.logger.error(`salla-conditional-offer:: unexpected type (${t.type})!`),"";const e=this.products[t.value];return e?i("a",{class:"s-conditional-offer-product-link",href:e.url},i("img",{class:"s-conditional-offer-checkpoint-image-content",loading:"lazy",decoding:"async",alt:e?.image?.alt||"",src:e?.image?.url})):(salla.logger.error(`salla-conditional-offer:: there is no product with id (${t.value})!`),"")}getOfferType(t){const i=this.offer.details?.based_on;return i===a.PRODUCT_COUNT?salla.lang.choice("blocks.header.products_count",t.min_spend):i===a.PRODUCT_PURCHASE?salla.money(t.min_spend):(salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${i}`),`${t.min_spend}`)}clamp(t,i,e){return Math.max(i,Math.min(t,e))}mapValueRanges(t,i,e,s,a){const n=(t-i)*(a-s)/(e-i)+s;return n===Number.POSITIVE_INFINITY?100:n===Number.NEGATIVE_INFINITY?0:this.clamp(n,0,100)}getCheckPointView(t,e){const s=this.offer.details.discounts.findIndex((({min_spend:i})=>i===t.min_spend)),a=this.mapValueRanges(this.offer.details.current_value,this.offer.details.discounts[s-1]?.min_spend??0,t.min_spend,0,100),n=t.min_spend<=this.offer.details.current_value;return i("div",{class:"s-conditional-offer-checkpoint-container"},e>0?[i("div",{key:"progress-line",class:"s-conditional-offer-progress-line-container"},i("div",{class:"s-conditional-offer-progress-line-inactive"}),i("div",{class:"s-conditional-offer-progress-line-active",style:{width:`${a}%`}})),i("div",{key:"checkpoint",class:"s-conditional-offer-checkpoint "+(n?"s-conditional-offer-active-checkpoint":"")},i("div",{class:"s-conditional-offer-item-avatar-content "+(n?"active":""),innerHTML:this.products&&this.getCheckpointContent(t)}),i("div",{class:"s-conditional-offer-checkpoint-label "+(n?"active":""),innerHTML:this.getOfferType(t)}))]:i("div",{key:"label",class:{"s-conditional-offer-checkpoint-label":!0,"first-checkpoint":0===e,active:n},innerHTML:this.getOfferType(t)}))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-container"},i("div",{class:"s-conditional-offer-skeleton-inner-container"},i("div",{class:"s-conditional-offer-skeleton-subtitle"},i("salla-skeleton",{height:"16px",width:"30%"})),i("div",{class:"s-conditional-offer-skeleton-subtitle"},i("salla-skeleton",{height:"16px",width:"35%"})),i("div",{class:"s-conditional-offer-skeleton-checkpoints-wrapper"},Array(3).fill(null).map((()=>[i("salla-skeleton",{key:"checkpoint-line",height:"8px"}),i("div",{key:"checkpoint"},i("salla-skeleton",{height:"60px",width:"60px",type:"circle"}))])))))}render(){return this.canRender?this.isLoading?this.getLoadingSkeletonView():this.offer?i(e,{class:"s-conditional-offer-container"},i("div",{class:"s-conditional-offer-title-wrapper"},i("div",{class:"s-conditional-offer-title"},this.offer.title),this.offer.description?i("div",{class:"s-conditional-offer-subtitle"},this.offer.description," ",i("i",{class:"sicon-information"})):null),i("div",{class:"s-conditional-offer-progress-container"},this.offer.details.discounts.map(((t,e)=>i("div",{class:{"flex-1":e>0},key:t.min_spend},this.getCheckPointView(t,e)))))):null:null}};n.style=":host{display:block}";export{n as salla_conditional_offer}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{e as t,f as i,i as s,d as e,r as a,h as r,a as n}from"./p-DzTVR6sF.js";import{S as o}from"./p-DiKTtDW5.js";import{H as l}from"./p-Dljb4XCt.js";import"./p-CgtvEd63.js";var c,h,u,f,d,p,v,m,g,w,b,y;function _(){if(w)return g;w=1;var e=i(),a=function(){if(h)return c;h=1;var i=t();return c=function(){return i.Date.now()}}(),r=function(){if(m)return v;m=1;var t=function(){if(p)return d;p=1;var t=function(){if(f)return u;f=1;var t=/\s/;return u=function(i){for(var s=i.length;s--&&t.test(i.charAt(s)););return s}}(),i=/^\s+/;return d=function(s){return s?s.slice(0,t(s)+1).replace(i,""):s}}(),e=i(),a=s(),r=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,o=/^0o[0-7]+$/i,l=parseInt;return v=function(i){if("number"==typeof i)return i;if(a(i))return NaN;if(e(i)){var s="function"==typeof i.valueOf?i.valueOf():i;i=e(s)?s+"":s}if("string"!=typeof i)return 0===i?i:+i;i=t(i);var c=n.test(i);return c||o.test(i)?l(i.slice(2),c?2:8):r.test(i)?NaN:+i}}(),n=Math.max,o=Math.min;return g=function(t,i,s){var l,c,h,u,f,d,p=0,v=!1,m=!1,g=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function w(i){var s=l,e=c;return l=c=void 0,p=i,u=t.apply(e,s)}function b(t){var s=t-d;return void 0===d||s>=i||s<0||m&&t-p>=h}function y(){var t=a();if(b(t))return _(t);f=setTimeout(y,function(t){var s=i-(t-d);return m?o(s,h-(t-p)):s}(t))}function _(t){return f=void 0,g&&l?w(t):(l=c=void 0,u)}function T(){var t=a(),s=b(t);if(l=arguments,c=this,d=t,s){if(void 0===f)return function(t){return p=t,f=setTimeout(y,i),v?w(t):u}(d);if(m)return clearTimeout(f),f=setTimeout(y,i),w(d)}return void 0===f&&(f=setTimeout(y,i)),u}return i=r(i)||0,e(s)&&(v=!!s.leading,h=(m="maxWait"in s)?n(r(s.maxWait)||0,i):h,g="trailing"in s?!!s.trailing:g),T.cancel=function(){void 0!==f&&clearTimeout(f),p=0,l=d=c=f=void 0},T.flush=function(){return void 0===f?u:_(a())},T},g}var T=e(function(){if(y)return b;y=1;var t=_(),s=i();return b=function(i,e,a){var r=!0,n=!0;if("function"!=typeof i)throw new TypeError("Expected a function");return s(a)&&(r="leading"in a?!!a.leading:r,n="trailing"in a?!!a.trailing:n),t(i,e,{leading:r,maxWait:e,trailing:n})}}());class k{constructor(t){this.grid=t,this.create=()=>{this.mutationObserver.observe(this.grid,{childList:!0});for(const t of Array.from(this.grid.children))this.resizeObserver.observe(t)},this.onContainerMutation=t=>{const i=t.flatMap((t=>Array.from(t.removedNodes))),s=t.flatMap((t=>Array.from(t.addedNodes)));for(const t of i)t instanceof Element&&this.resizeObserver.unobserve(t);for(const t of s)t instanceof Element&&this.resizeObserver.observe(t);i.length>0&&0===s.length&&this.update()},this.onChildrenResize=t=>{t.filter((t=>null!==t.target.parentElement)).length>0&&this.update()},this.update=T((()=>{const t=window.getComputedStyle(this.grid);if(!1===t.getPropertyValue("display").includes("grid"))return void this.clean();const i=function(t){return window.getComputedStyle(t).getPropertyValue("grid-template-columns").trim().split(/\s+(?=(?:[^()]*\([^()]*\))*[^()]*$)/)}(this.grid);if(i.length<=1)return void this.clean();const s=Number.parseFloat(t.getPropertyValue("row-gap").trim())||0,e=Array.from(this.grid.children);for(let t=0;t<i.length;t++){const i=e[t];i?.style.removeProperty("margin-top")}for(let t=0;t<e.length;t++){const a=e[t-i.length],r=e[t];if(void 0!==a&&void 0!==r){const t=a.getBoundingClientRect().bottom;r.style.removeProperty("margin-top");const i=r.getBoundingClientRect().top;if(i-s!==t){const e=Math.round(100*(t-(i-s)+Number.EPSILON))/100;r.style.setProperty("margin-top",`${e}px`)}}}}),32),this.destroy=()=>{this.resizeObserver.disconnect(),this.mutationObserver.disconnect(),this.clean()},this.clean=()=>{for(const t of Array.from(this.grid.children))t.style.removeProperty("margin-top")},this.mutationObserver=new MutationObserver(this.onContainerMutation),this.resizeObserver=new ResizeObserver(this.onChildrenResize),!1===CSS.supports("grid-template-rows","masonry")&&this.create()}[Symbol.dispose](){this.destroy()}}const E=class{constructor(t){a(this,t),this.reviews=[],this.isLoading=!1,this.pagination=null,this.sort="latest"}getUrlParams(){const t=new URLSearchParams(window.location.search);return{sort:t.get("sort")||null,page:Number.parseInt(t.get("page"))||1}}updateUrlParams(t){const i=new URL(window.location.href);for(const[s,e]of Object.entries(t))e?i.searchParams.set(s,e.toString()):i.searchParams.delete(s);window.history.replaceState({},"",i.toString())}fetchReviews(t,i){const s=this.getUrlParams();return salla.api.request("reviews",{params:{type:"products",format:"lite",per_page:8,page:i||s.page||1,sort:t||s.sort||null}})}async initializeMasonry(){const t=this.el.querySelector(".s-reviews-page-grid");if(t)try{new k(t),salla.logger.info("Masonry initialized successfully")}catch(t){salla.logger.error("Masonry initialization failed:",t)}}animateReviewCards(){const t=this.wrapper.querySelectorAll("salla-review-card:not(.animated)");l.animateItems(t)}initiateInfiniteScroll(){this.wrapper?(this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.pagination?.links?.next||null,history:!1,scrollThreshold:!1},!0),this.infiniteScroll?.on("request",(()=>{this.isLoading=!0})),this.infiniteScroll?.on("load",(t=>{this.pagination=t.pagination,this.reviews=[...this.reviews,...t.data],this.isLoading=!1,this.updateUrlParams({page:t.pagination.current_page})})),this.infiniteScroll?.on("error",(t=>{salla.logger.error("Error loading more reviews:",t),this.isLoading=!1}))):salla.logger.error("Wrapper is undefined. Cannot initiate infinite scroll.")}componentDidRender(){setTimeout((()=>{requestAnimationFrame(this.animateReviewCards.bind(this))}),176)}async componentWillLoad(){try{await salla.onReady(),this.langTitlesReviews=salla.lang.get("common.titles.reviews"),this.langSorting=salla.lang.get("pages.categories.sorting"),this.placeholderText=salla.lang.choice("pages.rating.reviews",0),this.langLoadMore=salla.lang.get("common.elements.load_more"),this.langSortByTopRating=salla.lang.get("pages.testimonials.sort_by_rating_desc"),this.langSortByMostRecent=salla.lang.get("pages.testimonials.sort_by_date_desc"),this.langSortByLeastRated=salla.lang.get("pages.testimonials.sort_by_rating_asc"),this.langSortByLeastRecent=salla.lang.get("pages.testimonials.sort_by_date_asc");const t=this.getUrlParams(),i=await this.fetchReviews(t.sort);this.sort=t.sort,this.reviews=i.data,this.pagination=i.pagination,this.langRatingReviews=salla.lang.choice("pages.rating.reviews",this.pagination?.total)}catch(t){salla.logger.error("Error loading reviews:",t)}}async handleSorting(t){const i=t.target.value;this.sort=i,this.updateUrlParams({sort:i,page:1});const s=await this.fetchReviews(i,1);this.reviews=s.data,this.pagination=s.pagination}async componentDidLoad(){await this.initializeMasonry(),this.initiateInfiniteScroll(),this.sort=this.getUrlParams().sort||"latest",this.updateUrlParams({sort:this.sort,page:1})}disconnectedCallback(){this.infiniteScroll&&this.infiniteScroll.destroy()}renderSortingOptions(){return[{value:"latest",label:this.langSortByMostRecent},{value:"oldest",label:this.langSortByLeastRecent},{value:"top_rating",label:this.langSortByTopRating},{value:"bottom_rating",label:this.langSortByLeastRated}].map((t=>r("option",{key:t.value,value:t.value,selected:t.value===this.sort},t.label)))}render(){return r("host",{key:"6d478caef9753d4aaf9ab1a5376961b748ec2088"},r("div",{key:"f84c127d660cba0890ba110b4d203e50fc1f2d8d",class:"s-reviews-page-header-wrapper"},r("h2",{key:"6c48e1343deaba4531987aefcc5888fc1e0d77ac",class:"s-reviews-page-title"},this.langTitlesReviews,r("span",{key:"fa9b923d592752b108da63efdf3167b118be65d0",class:"s-reviews-page-count"},"(",this.langRatingReviews,")")),r("div",{key:"52d0dd32e981721eb2529ed5d65769b078ad7538",class:"s-reviews-page-filter-wrapper"},r("label",{key:"0f7fe49f3ac27db63d8992efa2c3c04b3b19367d",class:"s-reviews-page-filter-label",htmlFor:"testimonials-filter"},this.langSorting),r("select",{key:"497563e494b7141c5a64dddc8cf4a202efba3776",onChange:t=>this.handleSorting(t),disabled:!this.reviews.length,class:"s-reviews-page-filter"},this.renderSortingOptions()))),this.reviews.length?r("main",{class:"s-reviews-page-grid",ref:t=>{this.wrapper=t}},this.reviews.map((t=>r("salla-review-card",{key:t.id,review:t})))):r("div",{class:"s-products-list-placeholder"},r("span",{innerHTML:o}),r("p",null,this.placeholderText)),this.pagination?.links?.next&&this.reviews.length?r("div",{class:"s-reviews-page-load-more-container"},r("salla-button",{class:"s-reviews-page-load-more-btn",loading:this.isLoading,onClick:()=>this.infiniteScroll?.loadNextPage(),onKeyUp:()=>this.infiniteScroll?.loadNextPage()},this.langLoadMore)):null)}get el(){return n(this)}};E.style=":host{display:block}";export{E as salla_reviews_page}
4
+ import{e as t,f as i,i as s,d as e,r as a,h as r,a as n}from"./p-CkTB8LrG.js";import{S as o}from"./p-DiKTtDW5.js";import{H as l}from"./p-Dljb4XCt.js";import"./p-CgtvEd63.js";var c,h,u,f,d,p,v,m,g,w,b,y;function _(){if(w)return g;w=1;var e=i(),a=function(){if(h)return c;h=1;var i=t();return c=function(){return i.Date.now()}}(),r=function(){if(m)return v;m=1;var t=function(){if(p)return d;p=1;var t=function(){if(f)return u;f=1;var t=/\s/;return u=function(i){for(var s=i.length;s--&&t.test(i.charAt(s)););return s}}(),i=/^\s+/;return d=function(s){return s?s.slice(0,t(s)+1).replace(i,""):s}}(),e=i(),a=s(),r=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,o=/^0o[0-7]+$/i,l=parseInt;return v=function(i){if("number"==typeof i)return i;if(a(i))return NaN;if(e(i)){var s="function"==typeof i.valueOf?i.valueOf():i;i=e(s)?s+"":s}if("string"!=typeof i)return 0===i?i:+i;i=t(i);var c=n.test(i);return c||o.test(i)?l(i.slice(2),c?2:8):r.test(i)?NaN:+i}}(),n=Math.max,o=Math.min;return g=function(t,i,s){var l,c,h,u,f,d,p=0,v=!1,m=!1,g=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function w(i){var s=l,e=c;return l=c=void 0,p=i,u=t.apply(e,s)}function b(t){var s=t-d;return void 0===d||s>=i||s<0||m&&t-p>=h}function y(){var t=a();if(b(t))return _(t);f=setTimeout(y,function(t){var s=i-(t-d);return m?o(s,h-(t-p)):s}(t))}function _(t){return f=void 0,g&&l?w(t):(l=c=void 0,u)}function k(){var t=a(),s=b(t);if(l=arguments,c=this,d=t,s){if(void 0===f)return function(t){return p=t,f=setTimeout(y,i),v?w(t):u}(d);if(m)return clearTimeout(f),f=setTimeout(y,i),w(d)}return void 0===f&&(f=setTimeout(y,i)),u}return i=r(i)||0,e(s)&&(v=!!s.leading,h=(m="maxWait"in s)?n(r(s.maxWait)||0,i):h,g="trailing"in s?!!s.trailing:g),k.cancel=function(){void 0!==f&&clearTimeout(f),p=0,l=d=c=f=void 0},k.flush=function(){return void 0===f?u:_(a())},k},g}var k=e(function(){if(y)return b;y=1;var t=_(),s=i();return b=function(i,e,a){var r=!0,n=!0;if("function"!=typeof i)throw new TypeError("Expected a function");return s(a)&&(r="leading"in a?!!a.leading:r,n="trailing"in a?!!a.trailing:n),t(i,e,{leading:r,maxWait:e,trailing:n})}}());class T{constructor(t){this.grid=t,this.create=()=>{this.mutationObserver.observe(this.grid,{childList:!0});for(const t of Array.from(this.grid.children))this.resizeObserver.observe(t)},this.onContainerMutation=t=>{const i=t.flatMap((t=>Array.from(t.removedNodes))),s=t.flatMap((t=>Array.from(t.addedNodes)));for(const t of i)t instanceof Element&&this.resizeObserver.unobserve(t);for(const t of s)t instanceof Element&&this.resizeObserver.observe(t);i.length>0&&0===s.length&&this.update()},this.onChildrenResize=t=>{t.filter((t=>null!==t.target.parentElement)).length>0&&this.update()},this.update=k((()=>{const t=window.getComputedStyle(this.grid);if(!1===t.getPropertyValue("display").includes("grid"))return void this.clean();const i=function(t){return window.getComputedStyle(t).getPropertyValue("grid-template-columns").trim().split(/\s+(?=(?:[^()]*\([^()]*\))*[^()]*$)/)}(this.grid);if(i.length<=1)return void this.clean();const s=Number.parseFloat(t.getPropertyValue("row-gap").trim())||0,e=Array.from(this.grid.children);for(let t=0;t<i.length;t++){const i=e[t];i?.style.removeProperty("margin-top")}for(let t=0;t<e.length;t++){const a=e[t-i.length],r=e[t];if(void 0!==a&&void 0!==r){const t=a.getBoundingClientRect().bottom;r.style.removeProperty("margin-top");const i=r.getBoundingClientRect().top;if(i-s!==t){const e=Math.round(100*(t-(i-s)+Number.EPSILON))/100;r.style.setProperty("margin-top",`${e}px`)}}}}),32),this.destroy=()=>{this.resizeObserver.disconnect(),this.mutationObserver.disconnect(),this.clean()},this.clean=()=>{for(const t of Array.from(this.grid.children))t.style.removeProperty("margin-top")},this.mutationObserver=new MutationObserver(this.onContainerMutation),this.resizeObserver=new ResizeObserver(this.onChildrenResize),!1===CSS.supports("grid-template-rows","masonry")&&this.create()}[Symbol.dispose](){this.destroy()}}const C=class{constructor(t){a(this,t),this.reviews=[],this.isLoading=!1,this.pagination=null,this.sort="latest"}getUrlParams(){const t=new URLSearchParams(window.location.search);return{sort:t.get("sort")||null,page:Number.parseInt(t.get("page"))||1}}updateUrlParams(t){const i=new URL(window.location.href);for(const[s,e]of Object.entries(t))e?i.searchParams.set(s,e.toString()):i.searchParams.delete(s);window.history.replaceState({},"",i.toString())}fetchReviews(t,i){const s=this.getUrlParams();return salla.api.request("reviews",{params:{type:"products",format:"lite",per_page:8,page:i||s.page||1,sort:t||s.sort||null}})}async initializeMasonry(){const t=this.el.querySelector(".s-reviews-page-grid");if(t)try{new T(t),salla.logger.info("Masonry initialized successfully")}catch(t){salla.logger.error("Masonry initialization failed:",t)}}animateReviewCards(){const t=this.wrapper.querySelectorAll("salla-review-card:not(.animated)");l.animateItems(t)}initiateInfiniteScroll(){this.wrapper?(this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.pagination?.links?.next||null,history:!1,scrollThreshold:!1},!0),this.infiniteScroll?.on("request",(()=>{this.isLoading=!0})),this.infiniteScroll?.on("load",(t=>{this.pagination=t.pagination,this.reviews=[...this.reviews,...t.data],this.isLoading=!1,this.updateUrlParams({page:t.pagination.current_page})})),this.infiniteScroll?.on("error",(t=>{salla.logger.error("Error loading more reviews:",t),this.isLoading=!1}))):salla.logger.error("Wrapper is undefined. Cannot initiate infinite scroll.")}componentDidRender(){setTimeout((()=>{requestAnimationFrame(this.animateReviewCards.bind(this))}),176)}async componentWillLoad(){try{await salla.onReady(),this.langTitlesReviews=salla.lang.get("common.titles.reviews"),this.langSorting=salla.lang.get("pages.categories.sorting"),this.placeholderText=salla.lang.choice("pages.rating.reviews",0),this.langLoadMore=salla.lang.get("common.elements.load_more"),this.langSortByTopRating=salla.lang.get("pages.testimonials.sort_by_rating_desc"),this.langSortByMostRecent=salla.lang.get("pages.testimonials.sort_by_date_desc"),this.langSortByLeastRated=salla.lang.get("pages.testimonials.sort_by_rating_asc"),this.langSortByLeastRecent=salla.lang.get("pages.testimonials.sort_by_date_asc");const t=this.getUrlParams(),i=await this.fetchReviews(t.sort);this.sort=t.sort,this.reviews=i.data,this.pagination=i.pagination,this.langRatingReviews=salla.lang.choice("pages.rating.reviews",this.pagination?.total)}catch(t){salla.logger.error("Error loading reviews:",t)}}async handleSorting(t){const i=t.target.value;this.sort=i,this.updateUrlParams({sort:i,page:1});const s=await this.fetchReviews(i,1);this.reviews=s.data,this.pagination=s.pagination}async componentDidLoad(){await this.initializeMasonry(),this.initiateInfiniteScroll(),this.sort=this.getUrlParams().sort||"latest",this.updateUrlParams({sort:this.sort,page:1})}disconnectedCallback(){this.infiniteScroll&&this.infiniteScroll.destroy()}renderSortingOptions(){return[{value:"latest",label:this.langSortByMostRecent},{value:"oldest",label:this.langSortByLeastRecent},{value:"top_rating",label:this.langSortByTopRating},{value:"bottom_rating",label:this.langSortByLeastRated}].map((t=>r("option",{key:t.value,value:t.value,selected:t.value===this.sort},t.label)))}render(){return r("host",{key:"6d478caef9753d4aaf9ab1a5376961b748ec2088"},r("div",{key:"f84c127d660cba0890ba110b4d203e50fc1f2d8d",class:"s-reviews-page-header-wrapper"},r("h2",{key:"6c48e1343deaba4531987aefcc5888fc1e0d77ac",class:"s-reviews-page-title"},this.langTitlesReviews,r("span",{key:"fa9b923d592752b108da63efdf3167b118be65d0",class:"s-reviews-page-count"},"(",this.langRatingReviews,")")),r("div",{key:"52d0dd32e981721eb2529ed5d65769b078ad7538",class:"s-reviews-page-filter-wrapper"},r("label",{key:"0f7fe49f3ac27db63d8992efa2c3c04b3b19367d",class:"s-reviews-page-filter-label",htmlFor:"testimonials-filter"},this.langSorting),r("select",{key:"497563e494b7141c5a64dddc8cf4a202efba3776",onChange:t=>this.handleSorting(t),disabled:!this.reviews.length,class:"s-reviews-page-filter"},this.renderSortingOptions()))),this.reviews.length?r("main",{class:"s-reviews-page-grid",ref:t=>{this.wrapper=t}},this.reviews.map((t=>r("salla-review-card",{key:t.id,review:t})))):r("div",{class:"s-products-list-placeholder"},r("span",{innerHTML:o}),r("p",null,this.placeholderText)),this.pagination?.links?.next&&this.reviews.length?r("div",{class:"s-reviews-page-load-more-container"},r("salla-button",{class:"s-reviews-page-load-more-btn",loading:this.isLoading,onClick:()=>this.infiniteScroll?.loadNextPage(),onKeyUp:()=>this.infiniteScroll?.loadNextPage()},this.langLoadMore)):null)}get el(){return n(this)}};C.style=":host{display:block}";export{C as salla_reviews_page}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as e,a as t}from"./p-DzTVR6sF.js";var i,r;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(i||(i={})),function(s){s.Conditional="conditional",s.PercentageOrFixed="fixed",s.DiscountsTable="discounts_table",s.Bank="bank",s.BuyXGetY="buy_x_get_y",s.SpecialPrice="special_price"}(r||(r={}));const a=class{constructor(e){s(this,e),this.productCardComponent="custom-salla-product-card",this.offersList=[],this.isMultipleBank=!1,this.isBankOffer=!1,this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),this.offer_with_price_text=salla.lang.get("pages.offer.with_price",{price:""}),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.multipleBankOfferTitleText=salla.lang.get("pages.offer.multiple_bank_offers_title"),this.multipleBankOfferTitleDescription=salla.lang.get("pages.offer.multiple_bank_offers_message"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),salla.lang.onLoaded((()=>{this.offer_with_price_text=salla.lang.get("pages.offer.with_price"),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.multipleBankOfferTitleText=salla.lang.get("pages.offer.multiple_bank_offers_title"),this.multipleBankOfferTitleDescription=salla.lang.get("pages.offer.multiple_bank_offers_message"),this.buy_quantity_text(0)})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug"),this.userCurrency=salla.config.get("currencies")[salla.config.get("user.currency_code")].symbol})),this.categorySlot=this.host.querySelector('[slot="category"]')?.innerHTML||'<a href={url} class="s-offer-slide-cat-entry"><i class={icon}></i><h4>{name}</h4></a>'}async getEndpointByPageName(){return this.currentPage==i.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==i.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){this.offersList.length&&this.canRender&&this.showOffer&&salla.event.emit("promotion::viewed",[{id:this.offersList[0].id,name:this.offersList[0].title,creative:this.offersList[0].description||"",position:1}])}emitPromotionClicked(s=1){this.offersList.length&&this.canRender&&this.showOffer&&salla.event.emit("promotion::clicked",[{id:this.offersList[0].id,name:this.offersList[0].title,creative:this.offersList[0].description||"",position:s}])}componentWillLoad(){return this.hasCustomComponent=!!customElements.get(this.productCardComponent),new Promise((s=>salla.onReady(s))).then((()=>{if(this.showOffer=!salla.url.is_page("product.single")||salla.config.get("store.settings.product.show_special_offers"),!this.showOffer)throw new Error("Merchant disabled showing the offers on product page")})).then((async()=>salla.api.request(await this.getEndpointByPageName()))).then((s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");const e=this.offersList.find((s=>[r.SpecialPrice,r.Bank,r.BuyXGetY,r.DiscountsTable].includes(s.type)));if(!e)throw new Error("salla-offers:: Offer type not supported yet!");if(e.type===r.DiscountsTable)return this.offersList=[e];if(this.isBankOffer=e.type===r.Bank)return this.offersList=this.offersList.filter((s=>s.type===r.Bank)),this.isMultipleBank=this.offersList.length>1,this.offersList;if(e.type===r.SpecialPrice){const s=e.details;return"product"===s.apply_to?salla.product.api.fetch({source:"selected",source_value:s.targets}).then((s=>(e.details.products=s.data,this.offersList=[e]))):salla.product.api.categories().then((t=>{const i=this.findCategories(t.data,s.targets);return e.details.categories=i,this.offersList=[e]}))}const t=e.details.get;return"products"===t.source?salla.product.api.fetch({source:"selected",source_value:t.source_value}).then((s=>(t.products=s.data,e.details.get=t,this.offersList=[e]))):salla.product.api.categories().then((s=>(t.categories=this.findCategories(s.data,t.source_value),e.details.get=t,this.offersList=[e])))})).then((s=>{salla.storage.set(this.getStorageKey(),{offers:s,stored_at:(new Date).getTime()}),this.canRender=!0})).catch((s=>{salla.logger.warn(s)}))}componentDidLoad(){let s=this.host.querySelector(".s-slider-block__title-nav");s?.classList.add("s-offer-bank-payment-nav"),this.emitPromotionViewed()}findCategories(s,e){let t=[];for(const i of s)e.includes(i.id_||i.id)&&t.push(i),i.sub_categories?.length>0&&(t=t.concat(this.findCategories(i.sub_categories,e)));return t}getStorageKey(){try{const s=salla.config.get("page.slug").replace(".","_"),e=salla.lang.getLocale(),t=salla.config.currency().code;if(!s||!e||!t)throw new Error("Unable to get the storage key.");return`s-offers-${s}-${salla.config.get("page.id")}-${e}-${t}`}catch(s){return""}}getOffersFromStorage(){let s=salla.storage.get(this.getStorageKey());return!s||s.stored_at<(new Date).getTime()-6e5?(salla.storage.remove(this.getStorageKey()),null):(this.canRender=!0,Promise.resolve(s.offers))}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=this.offersList[0],t={"block-title":this.isBankOffer?this.isMultipleBank?this.multipleBankOfferTitleText:null:s.title,"block-subTitle":this.isBankOffer?this.isMultipleBank?this.multipleBankOfferTitleDescription:null:s.description,"show-controls":this.isMultipleBank};return e("div",{class:"s-offer-wrapper",onClick:()=>this.emitPromotionClicked()},e("p",{class:"s-offer-corner-badge"},this.special_offer_text),e("salla-slider",{type:"carousel",id:"offer-slider",...t},e("div",{slot:"items"},this.renderSectionForOfferType(s.type))))}renderSectionForOfferType(s){return this.isBankOffer?this.renderBankSection():s==r.SpecialPrice?this.renderSpecialPriceSection():s==r.BuyXGetY?this.renderBuyXGetYSection():this.renderDiscountTableSection()}getCategoriesSection(s){return e("div",{class:"s-offer-slide-one-sixth swiper-slide",innerHTML:this.categorySlot.replace(/\{url\}/g,s.url).replace(/\{icon\}/g,s.icon||"sicon-store").replace(/\{name\}/g,s.name)})}renderBuyXGetYSection(){const s=this.offersList[0].details;return[s.get.products?.map((s=>e("div",{class:"s-offer-slide-one-fourth"},this.hasCustomComponent?e(this.productCardComponent,{product:s}):e("salla-product-card",{"shadow-on-hover":!0,product:s})))),s.get.categories?.map((s=>this.getCategoriesSection(s)))]}renderBankSection(){return this.offersList.map((s=>e("div",{class:{"s-offer-slide-one-sixth":this.isMultipleBank,"s-offer-bank-wrapper-sinlge-item":!this.isMultipleBank}},e("div",{class:{"s-offer-bank-wrapper":!0,"s-offer-slide-one-sixth":!this.isMultipleBank,"s-offer-bank-wrapper-multi-spacer":this.isMultipleBank}},e("div",{class:"s-offer-bank-logo"},e("img",{src:s.details.logo||salla.url.cdn("images/s-empty.png"),"data-src":s.details.logo,alt:s.title+" offer"})),e("ul",{class:"s-offer-bank-payment-wrapper"},s.details.payments.map((s=>e("li",{class:"s-offer-bank-payment-single"},e("img",{src:salla.url.cdn("images/payment/"+s+".png")||salla.url.cdn("images/s-empty.png"),"data-src":salla.url.cdn("images/payment/"+s+".png"),alt:"payment"}))))),this.isMultipleBank?e("p",{class:"s-offer-bank-payment-discount-percent"},`${this.product_discount_text} ${s.details.discount_value}${"percentage"===s.details.discount_type&&"%"}`):""),this.isMultipleBank?"":e("div",{class:"s-offer-bank-message s-offer-slide-one-fourth"},e("h2",null,this.offersList[0].title),e("p",{innerHTML:this.generateBankDescription(this.offersList[0].description,s.details.discount_value)})))))}generateBankDescription(s,e){return s.replace(new RegExp(`${e} %`),`<span class="s-offer-bank-message-amount">${e} %</span>`)}renderDiscountTableSection(){let s=this.offersList[0].details.show_price_after_discount;return this.offersList[0].details.discounts?.map((t=>e("div",{class:"s-offer-slide-one-fourth"},e("div",{class:"s-offer-slide-offer-entry"},e("div",{class:"s-offer-slide-offer-entry-price-quantity-container"},e("p",{class:"s-offer-slide-offer-entry-quantity"},this.buy_quantity_text(t.quantity)),s?e("div",{class:"s-offer-slide-offer-entry-price"},e("span",null,this.offer_with_price_text),e("span",{class:"s-offer-slide-offer-entry-price-amount"},t.discounted_amount)," ",e("span",null,this.userCurrency)):""),e("p",{class:"s-offer-slide-offer-entry-price-amount-percent"},this.with_discount_text,"(",e("span",null,t.percentage,!!t.percentage&&"%"),")")))))}renderSpecialPriceSection(){const s=this.offersList[0].details;return["product"===s.apply_to&&s.products?.map((s=>e("div",{class:"s-offer-slide-one-fourth"},this.hasCustomComponent?e(this.productCardComponent,{product:s}):e("salla-product-card",{"shadow-on-hover":!0,product:s})))),"category"===s.apply_to&&s.categories?.map((s=>this.getCategoriesSection(s)))]}get host(){return t(this)}};a.style='.s-offer-wrapper .s-slider-block__title h2{font-size:1.125rem;line-height:1.75rem;color:#f87171}.s-offer-wrapper .s-slider-block__title h2::before{font-family:"sallaicons";content:"\\ee30" !important;position:absolute;top:1rem;font-size:3rem;font-weight:400;line-height:1;color:#fef2f2}.s-offer-bank-wrapper-sinlge-item{display:flex;align-items:center !important;gap:14px}.s-offer-bank-wrapper{display:flex !important;width:100% !important}';export{a as salla_offer}
4
+ import{r as s,h as e,a as t}from"./p-CkTB8LrG.js";var i,r;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(i||(i={})),function(s){s.Conditional="conditional",s.PercentageOrFixed="fixed",s.DiscountsTable="discounts_table",s.Bank="bank",s.BuyXGetY="buy_x_get_y",s.SpecialPrice="special_price"}(r||(r={}));const a=class{constructor(e){s(this,e),this.productCardComponent="custom-salla-product-card",this.offersList=[],this.isMultipleBank=!1,this.isBankOffer=!1,this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),this.offer_with_price_text=salla.lang.get("pages.offer.with_price",{price:""}),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.multipleBankOfferTitleText=salla.lang.get("pages.offer.multiple_bank_offers_title"),this.multipleBankOfferTitleDescription=salla.lang.get("pages.offer.multiple_bank_offers_message"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),salla.lang.onLoaded((()=>{this.offer_with_price_text=salla.lang.get("pages.offer.with_price"),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.multipleBankOfferTitleText=salla.lang.get("pages.offer.multiple_bank_offers_title"),this.multipleBankOfferTitleDescription=salla.lang.get("pages.offer.multiple_bank_offers_message"),this.buy_quantity_text(0)})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug"),this.userCurrency=salla.config.get("currencies")[salla.config.get("user.currency_code")].symbol})),this.categorySlot=this.host.querySelector('[slot="category"]')?.innerHTML||'<a href={url} class="s-offer-slide-cat-entry"><i class={icon}></i><h4>{name}</h4></a>'}async getEndpointByPageName(){return this.currentPage==i.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==i.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){this.offersList.length&&this.canRender&&this.showOffer&&salla.event.emit("promotion::viewed",[{id:this.offersList[0].id,name:this.offersList[0].title,creative:this.offersList[0].description||"",position:1}])}emitPromotionClicked(s=1){this.offersList.length&&this.canRender&&this.showOffer&&salla.event.emit("promotion::clicked",[{id:this.offersList[0].id,name:this.offersList[0].title,creative:this.offersList[0].description||"",position:s}])}componentWillLoad(){return this.hasCustomComponent=!!customElements.get(this.productCardComponent),new Promise((s=>salla.onReady(s))).then((()=>{if(this.showOffer=!salla.url.is_page("product.single")||salla.config.get("store.settings.product.show_special_offers"),!this.showOffer)throw new Error("Merchant disabled showing the offers on product page")})).then((async()=>salla.api.request(await this.getEndpointByPageName()))).then((s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");const e=this.offersList.find((s=>[r.SpecialPrice,r.Bank,r.BuyXGetY,r.DiscountsTable].includes(s.type)));if(!e)throw new Error("salla-offers:: Offer type not supported yet!");if(e.type===r.DiscountsTable)return this.offersList=[e];if(this.isBankOffer=e.type===r.Bank)return this.offersList=this.offersList.filter((s=>s.type===r.Bank)),this.isMultipleBank=this.offersList.length>1,this.offersList;if(e.type===r.SpecialPrice){const s=e.details;return"product"===s.apply_to?salla.product.api.fetch({source:"selected",source_value:s.targets}).then((s=>(e.details.products=s.data,this.offersList=[e]))):salla.product.api.categories().then((t=>{const i=this.findCategories(t.data,s.targets);return e.details.categories=i,this.offersList=[e]}))}const t=e.details.get;return"products"===t.source?salla.product.api.fetch({source:"selected",source_value:t.source_value}).then((s=>(t.products=s.data,e.details.get=t,this.offersList=[e]))):salla.product.api.categories().then((s=>(t.categories=this.findCategories(s.data,t.source_value),e.details.get=t,this.offersList=[e])))})).then((s=>{salla.storage.set(this.getStorageKey(),{offers:s,stored_at:(new Date).getTime()}),this.canRender=!0})).catch((s=>{salla.logger.warn(s)}))}componentDidLoad(){let s=this.host.querySelector(".s-slider-block__title-nav");s?.classList.add("s-offer-bank-payment-nav"),this.emitPromotionViewed()}findCategories(s,e){let t=[];for(const i of s)e.includes(i.id_||i.id)&&t.push(i),i.sub_categories?.length>0&&(t=t.concat(this.findCategories(i.sub_categories,e)));return t}getStorageKey(){try{const s=salla.config.get("page.slug").replace(".","_"),e=salla.lang.getLocale(),t=salla.config.currency().code;if(!s||!e||!t)throw new Error("Unable to get the storage key.");return`s-offers-${s}-${salla.config.get("page.id")}-${e}-${t}`}catch(s){return""}}getOffersFromStorage(){let s=salla.storage.get(this.getStorageKey());return!s||s.stored_at<(new Date).getTime()-6e5?(salla.storage.remove(this.getStorageKey()),null):(this.canRender=!0,Promise.resolve(s.offers))}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=this.offersList[0],t={"block-title":this.isBankOffer?this.isMultipleBank?this.multipleBankOfferTitleText:null:s.title,"block-subTitle":this.isBankOffer?this.isMultipleBank?this.multipleBankOfferTitleDescription:null:s.description,"show-controls":this.isMultipleBank};return e("div",{class:"s-offer-wrapper",onClick:()=>this.emitPromotionClicked()},e("p",{class:"s-offer-corner-badge"},this.special_offer_text),e("salla-slider",{type:"carousel",id:"offer-slider",...t},e("div",{slot:"items"},this.renderSectionForOfferType(s.type))))}renderSectionForOfferType(s){return this.isBankOffer?this.renderBankSection():s==r.SpecialPrice?this.renderSpecialPriceSection():s==r.BuyXGetY?this.renderBuyXGetYSection():this.renderDiscountTableSection()}getCategoriesSection(s){return e("div",{class:"s-offer-slide-one-sixth swiper-slide",innerHTML:this.categorySlot.replace(/\{url\}/g,s.url).replace(/\{icon\}/g,s.icon||"sicon-store").replace(/\{name\}/g,s.name)})}renderBuyXGetYSection(){const s=this.offersList[0].details;return[s.get.products?.map((s=>e("div",{class:"s-offer-slide-one-fourth"},this.hasCustomComponent?e(this.productCardComponent,{product:s}):e("salla-product-card",{"shadow-on-hover":!0,product:s})))),s.get.categories?.map((s=>this.getCategoriesSection(s)))]}renderBankSection(){return this.offersList.map((s=>e("div",{class:{"s-offer-slide-one-sixth":this.isMultipleBank,"s-offer-bank-wrapper-sinlge-item":!this.isMultipleBank}},e("div",{class:{"s-offer-bank-wrapper":!0,"s-offer-slide-one-sixth":!this.isMultipleBank,"s-offer-bank-wrapper-multi-spacer":this.isMultipleBank}},e("div",{class:"s-offer-bank-logo"},e("img",{src:s.details.logo||salla.url.cdn("images/s-empty.png"),"data-src":s.details.logo,alt:s.title+" offer"})),e("ul",{class:"s-offer-bank-payment-wrapper"},s.details.payments.map((s=>e("li",{class:"s-offer-bank-payment-single"},e("img",{src:salla.url.cdn("images/payment/"+s+".png")||salla.url.cdn("images/s-empty.png"),"data-src":salla.url.cdn("images/payment/"+s+".png"),alt:"payment"}))))),this.isMultipleBank?e("p",{class:"s-offer-bank-payment-discount-percent"},`${this.product_discount_text} ${s.details.discount_value}${"percentage"===s.details.discount_type&&"%"}`):""),this.isMultipleBank?"":e("div",{class:"s-offer-bank-message s-offer-slide-one-fourth"},e("h2",null,this.offersList[0].title),e("p",{innerHTML:this.generateBankDescription(this.offersList[0].description,s.details.discount_value)})))))}generateBankDescription(s,e){return s.replace(new RegExp(`${e} %`),`<span class="s-offer-bank-message-amount">${e} %</span>`)}renderDiscountTableSection(){let s=this.offersList[0].details.show_price_after_discount;return this.offersList[0].details.discounts?.map((t=>e("div",{class:"s-offer-slide-one-fourth"},e("div",{class:"s-offer-slide-offer-entry"},e("div",{class:"s-offer-slide-offer-entry-price-quantity-container"},e("p",{class:"s-offer-slide-offer-entry-quantity"},this.buy_quantity_text(t.quantity)),s?e("div",{class:"s-offer-slide-offer-entry-price"},e("span",null,this.offer_with_price_text),e("span",{class:"s-offer-slide-offer-entry-price-amount"},t.discounted_amount)," ",e("span",null,this.userCurrency)):""),e("p",{class:"s-offer-slide-offer-entry-price-amount-percent"},this.with_discount_text,"(",e("span",null,t.percentage,!!t.percentage&&"%"),")")))))}renderSpecialPriceSection(){const s=this.offersList[0].details;return["product"===s.apply_to&&s.products?.map((s=>e("div",{class:"s-offer-slide-one-fourth"},this.hasCustomComponent?e(this.productCardComponent,{product:s}):e("salla-product-card",{"shadow-on-hover":!0,product:s})))),"category"===s.apply_to&&s.categories?.map((s=>this.getCategoriesSection(s)))]}get host(){return t(this)}};a.style='.s-offer-wrapper .s-slider-block__title h2{font-size:1.125rem;line-height:1.75rem;color:#f87171}.s-offer-wrapper .s-slider-block__title h2::before{font-family:"sallaicons";content:"\\ee30" !important;position:absolute;top:1rem;font-size:3rem;font-weight:400;line-height:1;color:#fef2f2}.s-offer-bank-wrapper-sinlge-item{display:flex;align-items:center !important;gap:14px}.s-offer-bank-wrapper{display:flex !important;width:100% !important}';export{a as salla_offer}