@salla.sa/twilight-components 2.14.27 → 2.14.28
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.
- package/dist/cjs/app-globals-b3827cef.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-add-product-button_48.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +99 -32
- package/dist/cjs/salla-installment.cjs.entry.js.map +1 -1
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/collection/components/salla-installment/salla-installment.js +118 -33
- package/dist/collection/components/salla-installment/salla-installment.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/salla-installment.js +101 -33
- package/dist/components/salla-installment.js.map +1 -1
- package/dist/components/salla-quick-buy2.js.map +1 -1
- package/dist/esm/app-globals-c672447c.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-add-product-button_48.entry.js.map +1 -1
- package/dist/esm/salla-installment.entry.js +99 -32
- package/dist/esm/salla-installment.entry.js.map +1 -1
- package/dist/esm/twilight.js +1 -1
- package/dist/esm-es5/app-globals-c672447c.js.map +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/esm-es5/salla-add-product-button_48.entry.js.map +1 -1
- package/dist/esm-es5/salla-installment.entry.js +1 -1
- package/dist/esm-es5/salla-installment.entry.js.map +1 -1
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/esm-es5/twilight.js.map +1 -1
- package/dist/twilight/p-39996533.system.js +1 -1
- package/dist/twilight/p-39996533.system.js.map +1 -1
- package/dist/twilight/p-40f6f722.entry.js.map +1 -1
- package/dist/twilight/p-5e19dec7.system.entry.js +5 -0
- package/dist/twilight/p-5e19dec7.system.entry.js.map +1 -0
- package/dist/twilight/p-bded3619.system.entry.js.map +1 -1
- package/dist/twilight/p-c69ac412.js.map +1 -1
- package/dist/twilight/p-e46cdbcc.system.js.map +1 -1
- package/dist/twilight/p-edac071a.entry.js +5 -0
- package/dist/twilight/p-edac071a.entry.js.map +1 -0
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/twilight/twilight.esm.js.map +1 -1
- package/dist/types/components/salla-installment/salla-installment.d.ts +20 -2
- package/dist/types/components.d.ts +8 -0
- package/dist/types/global.d.ts +20 -0
- package/package.json +5 -5
- package/dist/twilight/p-19b0d8c5.entry.js +0 -5
- package/dist/twilight/p-19b0d8c5.entry.js.map +0 -1
- package/dist/twilight/p-2f50e3dc.system.entry.js +0 -5
- package/dist/twilight/p-2f50e3dc.system.entry.js.map +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
System.register(["./p-f422bbf9.system.js"],(function(t){"use strict";var e,i,a,r;return{setters:[function(t){e=t.r;i=t.h;a=t.H;r=t.g}],execute:function(){var o='salla-installment:empty{display:none}#tabbyPromoWrapper{background:white;border-radius:0.375rem;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);margin-bottom:20px}.salla-y #tabbyPromoWrapper{border:1px solid var(--color-grey-dark);border-radius:12px}#tabbyPromoWrapper:hover{-webkit-box-shadow:0 0 rgba(0, 0, 0, 0), 0 0 rgba(0, 0, 0, 0), 5px 10px 30px rgba(43, 45, 52, 0.0509803922);box-shadow:0 0 rgba(0, 0, 0, 0), 0 0 rgba(0, 0, 0, 0), 5px 10px 30px rgba(43, 45, 52, 0.0509803922)}#tabbyPromoWrapper #tabbyPromo *{font-family:var(--font-main)}#tabbyPromoWrapper #tabbyPromo>div>div{max-width:none;-webkit-box-shadow:none;box-shadow:none;border:none}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet{max-width:100%;min-height:100px;padding:18px 20px;border:none !important}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__text,#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__link{font-size:var(--font-sm);color:var(--color-text) !important}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__link{font-weight:bold}.tabby-promo-wrapper #tabby-promo{font-family:var(--font-main) !important}.tabby-promo-wrapper #tabby-promo .tabby-promo__feature-title{font-size:var(--font-md)}.tabby-promo-wrapper #tabby-promo .tabby-promo__feature-desc{font-size:var(--font-sm);line-height:20px}.tamara-product-widget{margin-bottom:20px}.tamara-product-widget,.spotii-wrapper{min-height:100px;position:relative;color:var(--color-text);font-size:var(--font-sm);line-height:1.25;padding:18px 20px 18px 100px !important;background:white;border-radius:0.375rem;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1)}.salla-y .tamara-product-widget,.salla-y .spotii-wrapper{border-radius:12px;border:1px solid var(--color-grey-dark)}.tamara-product-widget:hover,.spotii-wrapper:hover{-webkit-box-shadow:0 0 rgba(0, 0, 0, 0), 0 0 rgba(0, 0, 0, 0), 5px 10px 30px rgba(43, 45, 52, 0.0509803922);box-shadow:0 0 rgba(0, 0, 0, 0), 0 0 rgba(0, 0, 0, 0), 5px 10px 30px rgba(43, 45, 52, 0.0509803922)}.tamara-product-widget .spotii-logo,.spotii-wrapper .spotii-logo{float:left;margin:0 0 0 -75px}.ltr .tamara-product-widget,.ltr .spotii-wrapper{text-align:left;padding:18px 100px 18px 20px !important}.ltr .tamara-product-widget .spotii-logo,.ltr .spotii-wrapper .spotii-logo{float:right;margin:0 -75px 0 0}.ltr .tamara-product-widget .spotii-product-widget,.ltr .spotii-wrapper .spotii-product-widget{text-align:left !important}.spotii-wrapper{margin-bottom:20px}.spotii-wrapper .spotii-promo{font-size:var(--font-md)}.spotii-wrapper .spotii-product-widget{font-size:var(--font-sm) !important;margin-top:10px}.tamara-product-widget .tamara-logo{position:absolute;left:20px;top:18px;margin:0 !important}.ltr .tamara-product-widget .tamara-logo{right:20px;left:auto}.tamara-product-widget span{font-family:var(--font-main);font-size:var(--font-sm);color:var(--color-text)}.tamara-product-widget span:last-child{display:block;position:relative;margin-top:8px}.tamara-popup__wrap{overflow:auto !important}.s-installment-mispay-wrapper{font-family:"Noto Sans Arabic", sans-serif;font-size:14px;text-align:right;padding:24px 20px 24px 0px;gap:42px;direction:rtl;line-height:22px;color:rgb(0, 0, 0);min-width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;background-color:white;border-radius:10px;border:1px solid var(--07--Light-Theme-Gray-color-gray-300, #EEE);margin:15px 0;display:-ms-flexbox;display:flex;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1)}.s-installment-mispay-wrapper:hover{-webkit-box-shadow:0 0 rgba(0, 0, 0, 0), 0 0 rgba(0, 0, 0, 0), 5px 10px 30px rgba(43, 45, 52, 0.0509803922);box-shadow:0 0 rgba(0, 0, 0, 0), 0 0 rgba(0, 0, 0, 0), 5px 10px 30px rgba(43, 45, 52, 0.0509803922)}.s-installment-mispay-content{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;margin:15px !important}.s-installment-mispay-content-text{color:#292929;margin:0 16px 0 0;width:80%;position:absolute;left:14px;text-align:left}.s-installment-mispay-content img{height:28px;width:70px;display:inline-block;max-height:100%;vertical-align:middle;fill:none;stroke:unset;width:auto;position:absolute}.rtl .s-installment-mispay-content-text{right:14px;text-align:right;margin:0 0 0 16px}.rtl .s-installment-mispay-content img{left:14px !important}.ltr .s-installment-mispay-content img{right:14px !important}';var s=t("salla_installment",function(){function t(t){var i=this;e(this,t);this.tabbyBorderRemoved=false;this.tabbyRemoveBorderTries=0;this.price=undefined;this.language=salla.config.get("user.language_code");this.currency=salla.config.get("user.currency_code");this.country=salla.config.get("user.country_code");this.tabbyIsActive=undefined;this.spotiiIsActive=undefined;this.tamaraIsActive=undefined;this.mispayActive=undefined;this.installment_sheria_text=function(t){return salla.lang.get("pages.products.installments",t)};salla.lang.onLoaded((function(){i.installment_sheria_text({payment:salla.money(parseFloat(i.price)),amount:salla.money((parseFloat(i.price)/3).toFixed(2)),installments:3});var t=salla.config.get("store.settings.installments");if(t){i.tamaraIsActive=t.tamara;i.tabbyIsActive=t.tabby;i.spotiiIsActive=t.spotii;i.mispayActive=t.mispay}i.renderInstallments()}));salla.event.on("product::price.updated",(function(t){var e=t.data;if(!e.price||e.price==i.price){return}i.price=e.price;i.renderInstallments(true)}))}t.prototype.render=function(){var t;if(!this.isValidPrice(this.price)){return""}return i(a,null,this.tamaraIsActive&&(((t=this.tamaraIsActive)===null||t===void 0?void 0:t.publicKey)?i("div",{class:"mb-5"},i("tamara-widget",{type:"tamara-summary","inline-type":"2",amount:this.price})):i("div",{class:"tamara-product-widget","data-price":this.price,"data-currency":this.currency,"data-lang":this.language,"data-payment-type":"installment"})),this.tabbyIsActive?i("div",{id:"tabbyPromoWrapper"},i("div",{id:"tabbyPromo"})):"",this.spotiiIsActive?i("div",{class:"spotii-wrapper"},i("div",{class:"spotii-promo"})):"",this.shouldShowMispay()&&(this.mispayActive.publicKey?i("div",{class:"mb-5"},i("mispay-widget",{amount:this.price,lang:this.language})):i("div",{class:"s-installment-mispay-wrapper"},i("div",{class:"s-installment-mispay-content"},i("img",{src:salla.url.cdn("images/payment/png/mispay.png"),alt:"mispay"}),i("span",{class:"s-installment-mispay-content-text"},this.installment_sheria_text({payment:salla.money(parseFloat(this.price)),amount:salla.money((parseFloat(this.price)/4).toFixed(2)),installments:4}))))))};t.prototype.renderInstallments=function(t){var e=this;if(t===void 0){t=false}if(!this.isValidPrice(this.price)){return}if(this.tamaraIsActive){this.loadTamara({isUpdating:t})}if(this.tabbyIsActive){if(t){var i=this.host.querySelector("#tabbyPromoWrapper");if(i){i.remove()}var a=document.createElement("div");a.setAttribute("id","tabbyPromoWrapper");var r=document.createElement("div");r.setAttribute("id","tabbyPromo");a.appendChild(r);this.host.appendChild(a);var o=document.querySelector('script[src="https://checkout.tabby.ai/tabby-promo.js"]');if(o){o.remove()}}var s=document.createElement("script");s.setAttribute("src","https://checkout.tabby.ai/tabby-promo.js");document.head.appendChild(s);s.onload=function(){var t=window.TabbyPromo;new t({selector:"#tabbyPromo",currency:e.currency,price:e.price,lang:e.language,publicKey:salla.config.get("store.settings.installments.tabby.publicKey"),merchantCode:salla.config.get("store.settings.installments.tabby.merchantCode")});document.querySelectorAll(".tabby-promo-snippet__logo").forEach((function(t){t.setAttribute("aria-label","Tabby Logo")}))};this.removeTabbyBorder()}if(this.spotiiIsActive){if(t){var n=this.host.querySelector(".spotii-wrapper");if(n){n.remove()}var p=document.createElement("div");p.classList.add("spotii-wrapper");var l=document.createElement("div");l.classList.add("spotii-promo");p.appendChild(l);this.host.appendChild(p);var c=document.querySelector('script[src="'+salla.url.cdn("js/price-widget-ar-salla.js")+'"]');if(c){c.remove()}}var d=salla.money((Number(this.price)/3).toFixed(2));var b=salla.config.get("theme.is_rtl",true);window.spotiiConfig={targetXPath:[".spotii-wrapper"],renderToPath:[".spotii-promo"],numberOfPayment:3,currency:this.currency,templateLine:"${textOne} ${number} ${textTwo} "+d+"${logo} ${info}",textOne:b?"جزء الدفع على":"Split it into",textTwo:b?"أقساط متساوية بدون تكاليف اضافية بقيمة":"payments of",textThree:"مع",price:this.price};var m=document.createElement("script");m.setAttribute("src",salla.url.cdn("js/price-widget-ar-salla.js"));document.head.appendChild(m)}if(this.shouldShowMispay()&&this.mispayActive.publicKey){this.loadExternalScript({position:"head",src:"https://widget.mispay.co/v1/sdk.js?authorize=".concat(this.mispayActive.publicKey)})}};t.prototype.isValidPrice=function(t){var e=/^\d+(\.\d{1,2})?$/;var i=e.test(t);var a=parseFloat(t)>0;return i&&a};t.prototype.loadExternalScript=function(t){var e=t.src,i=t.onLoad,a=t.position;var r=document.createElement("script");r.src=e;r.onload=i;document[a].appendChild(r)};t.prototype.loadTamara=function(t){var e=this;var i=t.isUpdating;var a;var r=!!((a=this.tamaraIsActive)===null||a===void 0?void 0:a.publicKey);if(i){setTimeout((function(){var t,e;if(r){return(t=window.TamaraWidgetV2)===null||t===void 0?void 0:t.refresh()}(e=window.TamaraProductWidget)===null||e===void 0?void 0:e.render()}),300)}else{if(r){var o=salla.config.get("user.language_code");var s=["ar","en"].includes(o)?o:"ar";var n=this.currency.slice(0,-1);var p=["SA","AE","KW","BH","OM","QA"].includes(n)?n:null;if(!p){console.error("Tamara: Country code is not supported",n)}else{window.tamaraWidgetConfig={lang:s,country:p,publicKey:this.tamaraIsActive.publicKey,style:{fontSize:"14px"}};this.loadExternalScript({position:"head",src:"https://cdn.tamara.co/widget-v2/tamara-widget.js"})}}else{this.loadExternalScript({position:"head",src:"https://cdn.tamara.co/widget/product-widget.min.js",onLoad:function(){window.TamaraProductWidget.init({lang:e.language});setTimeout((function(){window.TamaraProductWidget.render()}),300)}})}}};t.prototype.shouldShowMispay=function(){return this.currency==="SAR"&&this.mispayActive&&parseInt(this.price)>=200};t.prototype.removeTabbyBorder=function(){var t=this;if(this.tabbyBorderRemoved||this.tabbyRemoveBorderTries>5){return}this.tabbyRemoveBorderTries++;setTimeout((function(){var e=document.querySelector("#tabbyPromo>div>div");e=e?e.shadowRoot.querySelector('div[class^="styles__tabby-promo-snippet--"]'):null;if(e){e.style="border: none; margin: 15px 0!important;";t.tabbyBorderRemoved=true}else{t.removeTabbyBorder()}}),this.tabbyRemoveBorderTries*500)};Object.defineProperty(t.prototype,"host",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());s.style=o}}}));
|
|
5
|
+
//# sourceMappingURL=p-5e19dec7.system.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["sallaInstallmentCss","SallaInstallment","exports","class_1","hostRef","_this","this","tabbyBorderRemoved","tabbyRemoveBorderTries","salla","config","get","replacement","lang","onLoaded","installment_sheria_text","payment","money","parseFloat","price","amount","toFixed","installments","installment","tamaraIsActive","tamara","tabbyIsActive","tabby","spotiiIsActive","spotii","mispayActive","mispay","renderInstallments","event","on","_c","data","prototype","render","isValidPrice","h","Host","_a","publicKey","class","type","currency","language","id","shouldShowMispay","src","url","cdn","alt","isUpdating","loadTamara","oldTabbyWrapper","host","querySelector","remove","tabbyPromoWrapper","document","createElement","setAttribute","tabbyPromo","appendChild","oldTabbyScript","tabbyScript","head","onload","TabbyPromo","window","selector","merchantCode","querySelectorAll","forEach","element","removeTabbyBorder","oldSpotiiWrapper","spotiiPromoWrapper","classList","add","spotiiPromo","oldSpotiiScript","Number","isRTL","spotiiConfig","targetXPath","renderToPath","numberOfPayment","templateLine","textOne","textTwo","textThree","spotiiScript","loadExternalScript","position","concat","pricePattern","isValid","test","isGreaterThanZero","onLoad","script","isV2Enabled","setTimeout","TamaraWidgetV2","refresh","_b","TamaraProductWidget","language_code","includes","countryCodeByCurrency","slice","country","console","error","tamaraWidgetConfig","style","fontSize","init","parseInt","promo","shadowRoot"],"sources":["src/components/salla-installment/salla-installment.scss?tag=salla-installment","src/components/salla-installment/salla-installment.tsx"],"sourcesContent":["/*\n The whole installment methods is a third-party widgets,\n So there aren't a custom classes (as other components) to style them.\n*/\n\nsalla-installment:empty {\n display: none;\n}\n\n/*\n* Installment::Tabby\n*/\n#tabbyPromoWrapper {\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n margin-bottom: 20px;\n\n .salla-y & {\n border: 1px solid var(--color-grey-dark);\n border-radius: 12px\n }\n\n &:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n\n #tabbyPromo {\n * {\n font-family: var(--font-main);\n }\n\n >div>div {\n max-width: none;\n //padding: 15px;\n box-shadow: none;\n border: none;\n }\n\n .tabby-promo-snippet {\n max-width: 100%;\n min-height: 100px;\n padding: 18px 20px;\n // border-color: var(--color-grey-dark);\n border: none !important;\n\n\n &__text,\n &__link {\n font-size: var(--font-sm);\n color: var(--color-text) !important;\n }\n\n &__link {\n font-weight: bold;\n }\n }\n }\n}\n\n.tabby-promo-wrapper {\n #tabby-promo {\n font-family: var(--font-main) !important;\n\n .tabby-promo {\n &__feature-title {\n font-size: var(--font-md);\n }\n\n &__feature-desc {\n font-size: var(--font-sm);\n line-height: 20px;\n }\n }\n }\n}\n\n/*\n* Installment::Tamara & Spotii\n*/\n.tamara-product-widget {\n margin-bottom: 20px;\n}\n\n.tamara-product-widget,\n.spotii-wrapper {\n min-height: 100px;\n position: relative;\n color: var(--color-text);\n font-size: var(--font-sm);\n line-height: 1.25;\n padding: 18px 20px 18px 100px !important;\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n\n .salla-y & {\n border-radius: 12px;\n border: 1px solid var(--color-grey-dark);\n }\n\n &:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n\n .spotii-logo {\n float: left;\n margin: 0 0 0 -75px;\n }\n}\n\n.ltr .tamara-product-widget,\n.ltr .spotii-wrapper {\n text-align: left;\n padding: 18px 100px 18px 20px !important;\n\n .spotii-logo {\n float: right;\n margin: 0 -75px 0 0;\n }\n\n .spotii-product-widget {\n text-align: left !important;\n }\n}\n\n.spotii-wrapper {\n margin-bottom: 20px;\n\n .spotii-promo {\n font-size: var(--font-md);\n }\n\n .spotii-product-widget {\n font-size: var(--font-sm) !important;\n margin-top: 10px;\n }\n}\n\n.tamara-product-widget {\n .tamara-logo {\n position: absolute;\n left: 20px;\n top: 18px;\n margin: 0 !important;\n\n .ltr & {\n right: 20px;\n left: auto;\n }\n }\n\n span {\n font-family: var(--font-main);\n font-size: var(--font-sm);\n color: var(--color-text);\n\n &:last-child {\n display: block;\n position: relative;\n margin-top: 8px;\n }\n }\n}\n\n.tamara-popup {\n &__wrap {\n overflow: auto !important;\n }\n}\n\n.s-installment-mispay-wrapper {\n font-family: \"Noto Sans Arabic\", sans-serif;\n font-size: 14px;\n text-align: right;\n padding: 24px 20px 24px 0px;\n gap: 42px;\n direction: rtl;\n line-height: 22px;\n color: rgb(0, 0, 0);\n min-width: 100%;\n box-sizing: border-box;\n position: relative;\n background-color: white;\n border-radius: 10px;\n border: 1px solid var(--07--Light-Theme-Gray-color-gray-300, #EEE);\n margin: 15px 0;\n display: flex;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.s-installment-mispay-wrapper:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n}\n\n.s-installment-mispay-content {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin: 15px !important;\n}\n\n.s-installment-mispay-content-text {\n color: #292929;\n margin: 0 16px 0 0;\n width: 80%;\n position: absolute;\n left: 14px;\n text-align: left;\n}\n\n\n.s-installment-mispay-content img {\n height: 28px;\n width: 70px;\n display: inline-block;\n max-height: 100%;\n vertical-align: middle;\n fill: none;\n stroke: unset;\n width: auto;\n position: absolute;\n}\n\n.rtl .s-installment-mispay-content-text {\n right: 14px;\n text-align: right;\n margin: 0 0 0 16px;\n}\n\n.rtl .s-installment-mispay-content img {\n left: 14px !important;\n}\n\n.ltr .s-installment-mispay-content img {\n right: 14px !important;\n}\n","import { Component, Host, h, Prop, State, Element } from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n @Element() host: HTMLElement;\n constructor() {\n salla.lang.onLoaded(() => {\n this.installment_sheria_text({\n payment: salla.money(parseFloat(this.price)),\n amount: salla.money((parseFloat(this.price) / 3).toFixed(2)),\n installments: 3,\n });\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = installment.tamara;\n this.tabbyIsActive = installment.tabby;\n this.spotiiIsActive = installment.spotii;\n this.mispayActive = installment.mispay;\n }\n this.renderInstallments();\n });\n\n salla.event.on('product::price.updated', ({ data }) => {\n if (!data.price || data.price == this.price) {\n return;\n }\n this.price = data.price;\n this.renderInstallments(true);\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n /**\n * Country code\n */\n @Prop() country: string = salla.config.get('user.country_code');\n\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n @State() tamaraIsActive: null | { publicKey: string };\n @State() mispayActive: null | { merchantCode: string; publicKey: string };\n\n @State() installment_sheria_text: (replacement: object) => string = replacement =>\n salla.lang.get('pages.products.installments', replacement);\n\n render() {\n if (!this.isValidPrice(this.price)) {\n return '';\n }\n return (\n <Host>\n {this.tamaraIsActive &&\n (this.tamaraIsActive?.publicKey ? (\n // Tamara widget v2\n <div class=\"mb-5\">\n <tamara-widget\n type=\"tamara-summary\"\n inline-type=\"2\"\n amount={this.price}\n ></tamara-widget>\n </div>\n ) : (\n // Tamara widget v1 fallback\n <div\n class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\"\n ></div>\n ))}\n\n {this.tabbyIsActive ? (\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n ) : (\n ''\n )}\n\n {this.spotiiIsActive ? (\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n ) : (\n ''\n )}\n\n {this.shouldShowMispay() &&\n (this.mispayActive.publicKey ? (\n <div class=\"mb-5\">\n <mispay-widget amount={this.price} lang={this.language}></mispay-widget>\n </div>\n ) : (\n <div class=\"s-installment-mispay-wrapper\">\n <div class=\"s-installment-mispay-content\">\n <img src={salla.url.cdn('images/payment/png/mispay.png')} alt=\"mispay\" />\n <span class=\"s-installment-mispay-content-text\">\n {this.installment_sheria_text({\n payment: salla.money(parseFloat(this.price)),\n amount: salla.money((parseFloat(this.price) / 4).toFixed(2)),\n installments: 4,\n })}\n </span>\n </div>\n </div>\n ))}\n </Host>\n );\n }\n\n renderInstallments(isUpdating: boolean = false) {\n if (!this.isValidPrice(this.price)) {\n return;\n }\n // Tamara\n if (this.tamaraIsActive) {\n this.loadTamara({ isUpdating });\n }\n\n // tabby\n if (this.tabbyIsActive) {\n if (isUpdating) {\n // remove #tabbyPromoWrapper and re append it\n var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');\n if (oldTabbyWrapper) {\n oldTabbyWrapper.remove();\n }\n\n var tabbyPromoWrapper = document.createElement('div');\n tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');\n var tabbyPromo = document.createElement('div');\n tabbyPromo.setAttribute('id', 'tabbyPromo');\n tabbyPromoWrapper.appendChild(tabbyPromo);\n this.host.appendChild(tabbyPromoWrapper);\n\n var oldTabbyScript = document.querySelector(\n 'script[src=\"https://checkout.tabby.ai/tabby-promo.js\"]',\n );\n if (oldTabbyScript) {\n oldTabbyScript.remove();\n }\n }\n\n var tabbyScript = document.createElement('script');\n tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(tabbyScript);\n tabbyScript.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n publicKey: salla.config.get('store.settings.installments.tabby.publicKey'),\n merchantCode: salla.config.get('store.settings.installments.tabby.merchantCode'),\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo');\n });\n };\n // this is a workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n if (isUpdating) {\n var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');\n if (oldSpotiiWrapper) {\n oldSpotiiWrapper.remove();\n }\n\n var spotiiPromoWrapper = document.createElement('div');\n spotiiPromoWrapper.classList.add('spotii-wrapper');\n var spotiiPromo = document.createElement('div');\n spotiiPromo.classList.add('spotii-promo');\n spotiiPromoWrapper.appendChild(spotiiPromo);\n this.host.appendChild(spotiiPromoWrapper);\n var oldSpotiiScript = document.querySelector(\n 'script[src=\"' + salla.url.cdn('js/price-widget-ar-salla.js') + '\"]',\n );\n if (oldSpotiiScript) {\n oldSpotiiScript.remove();\n }\n }\n\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: '${textOne} ${number} ${textTwo} ' + amount + '${logo} ${info}',\n //todo:: translate these\n textOne: isRTL ? 'جزء الدفع على' : 'Split it into',\n textTwo: isRTL ? 'أقساط متساوية بدون تكاليف اضافية بقيمة' : 'payments of',\n textThree: 'مع',\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n };\n\n var spotiiScript = document.createElement('script');\n spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(spotiiScript);\n // spotiiScript.onload = () => {\n // // setTimeout()\n // }\n }\n\n // Mispay\n if (this.shouldShowMispay() && this.mispayActive.publicKey) {\n this.loadExternalScript({\n position: 'head',\n src: `https://widget.mispay.co/v1/sdk.js?authorize=${this.mispayActive.publicKey}`,\n });\n }\n }\n\n private isValidPrice(price: string): boolean {\n const pricePattern = /^\\d+(\\.\\d{1,2})?$/;\n const isValid = pricePattern.test(price);\n const isGreaterThanZero = parseFloat(price) > 0;\n\n return isValid && isGreaterThanZero;\n }\n\n loadExternalScript({\n src,\n onLoad,\n position,\n }: {\n src: string;\n onLoad?: HTMLScriptElement['onload'];\n position: 'head' | 'body';\n }) {\n const script = document.createElement('script');\n script.src = src;\n script.onload = onLoad;\n document[position].appendChild(script);\n }\n\n loadTamara({ isUpdating }: { isUpdating: boolean }) {\n const isV2Enabled = !!this.tamaraIsActive?.publicKey;\n\n if (isUpdating) {\n setTimeout(() => {\n if (isV2Enabled) {\n return window.TamaraWidgetV2?.refresh();\n }\n\n // v1 fallback widget refresh\n window.TamaraProductWidget?.render();\n }, 300);\n } else {\n if (isV2Enabled) {\n const language_code = salla.config.get('user.language_code');\n const lang = ['ar', 'en'].includes(language_code) ? language_code : 'ar';\n // this used in case user change the currency to get the country code\n const countryCodeByCurrency = this.currency.slice(0, -1);\n const country = ['SA', 'AE', 'KW', 'BH', 'OM', 'QA'].includes(countryCodeByCurrency)\n ? countryCodeByCurrency\n : null;\n\n if (!country) {\n console.error('Tamara: Country code is not supported', countryCodeByCurrency);\n } else {\n window.tamaraWidgetConfig = {\n lang,\n country,\n publicKey: this.tamaraIsActive.publicKey,\n style: {\n fontSize: '14px',\n },\n };\n\n this.loadExternalScript({\n position: 'head',\n src: 'https://cdn.tamara.co/widget-v2/tamara-widget.js',\n });\n }\n } else {\n // v1 fallback widget\n this.loadExternalScript({\n position: 'head',\n src: 'https://cdn.tamara.co/widget/product-widget.min.js',\n onLoad: () => {\n window.TamaraProductWidget.init({ lang: this.language });\n setTimeout(() => {\n window.TamaraProductWidget.render();\n }, 300);\n },\n });\n }\n }\n }\n\n shouldShowMispay() {\n return this.currency === 'SAR' && this.mispayActive && parseInt(this.price) >= 200;\n }\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo\n ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]')\n : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries * 500);\n }\n}\n"],"mappings":";;;0JAAA,IAAMA,EAAsB,ohK,ICMfC,EAAgBC,EAAA,+BAI3B,SAAAC,EAAAC,GAAA,IAAAC,EAAAC,K,UAHQA,KAAAC,mBAA8B,MAC9BD,KAAAE,uBAAiC,E,mCAmCdC,MAAMC,OAAOC,IAAI,sB,cAIjBF,MAAMC,OAAOC,IAAI,sB,aAIlBF,MAAMC,OAAOC,IAAI,qB,kJAOyB,SAAAC,GAClE,OAAAH,MAAMI,KAAKF,IAAI,8BAA+BC,EAA9C,EAhDAH,MAAMI,KAAKC,UAAS,WAClBT,EAAKU,wBAAwB,CAC3BC,QAASP,MAAMQ,MAAMC,WAAWb,EAAKc,QACrCC,OAAQX,MAAMQ,OAAOC,WAAWb,EAAKc,OAAS,GAAGE,QAAQ,IACzDC,aAAc,IAEhB,IAAMC,EAAcd,MAAMC,OAAOC,IAAI,+BACrC,GAAIY,EAAa,CACflB,EAAKmB,eAAiBD,EAAYE,OAClCpB,EAAKqB,cAAgBH,EAAYI,MACjCtB,EAAKuB,eAAiBL,EAAYM,OAClCxB,EAAKyB,aAAeP,EAAYQ,M,CAElC1B,EAAK2B,oB,IAGPvB,MAAMwB,MAAMC,GAAG,0BAA0B,SAACC,G,IAAEC,EAAID,EAAAC,KAC9C,IAAKA,EAAKjB,OAASi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