choco-one-click-payment 1.1.24 → 1.1.25
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/index.esm.js +2 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3399,7 +3399,7 @@ function De() {
|
|
|
3399
3399
|
return typeof document > "u" ? !1 : document.hidden || document.visibilityState === "hidden";
|
|
3400
3400
|
}
|
|
3401
3401
|
function ht(e, n) {
|
|
3402
|
-
j(e), e.config.onSuccess(n)
|
|
3402
|
+
j(e), e.config.onSuccess(n);
|
|
3403
3403
|
}
|
|
3404
3404
|
function _e(e) {
|
|
3405
3405
|
if (!e._pendingSuccessPayload || De()) return;
|
|
@@ -3977,8 +3977,7 @@ class oe {
|
|
|
3977
3977
|
}
|
|
3978
3978
|
}
|
|
3979
3979
|
close() {
|
|
3980
|
-
|
|
3981
|
-
(n = this.container) == null || n.classList.remove("choco-one-click-widget--visible"), setTimeout(() => this.config.onCancel(), 300);
|
|
3980
|
+
this.config.onCancel();
|
|
3982
3981
|
}
|
|
3983
3982
|
destroy() {
|
|
3984
3983
|
const n = document.getElementById("choco-one-click-widget");
|
package/dist/index.js
CHANGED
|
@@ -276,4 +276,4 @@
|
|
|
276
276
|
</defs>
|
|
277
277
|
</svg>
|
|
278
278
|
</span>
|
|
279
|
-
`,o.appendChild(s),o.appendChild(i),n.appendChild(o),$(e)}function re(e){e.loading=!0,$(e)}function j(e){var T,v,Q,_,m,P,k,w;e.loading=!1;const n=(T=e.container)==null?void 0:T.querySelector(".choco-widget-payment-method"),o=(v=e.container)==null?void 0:v.querySelector(".choco-widget-pay-button"),s=(Q=e.container)==null?void 0:Q.querySelector(".choco-widget-google-pay-button-slot button"),i=(_=e.container)==null?void 0:_.querySelector(".choco-widget-apple-pay-button-slot button"),u=(m=e.container)==null?void 0:m.querySelector(".choco-widget-google-pay-amount"),c=(P=e.container)==null?void 0:P.querySelector(".choco-widget-google-pay-row"),d=(k=e.container)==null?void 0:k.querySelector(".choco-widget-apple-pay-row"),g=(w=e.container)==null?void 0:w.querySelector(".choco-widget-balance-section"),C=e._isInteractionBlocked(),S=e.paymentMethodDisabled||C;n&&(n.disabled=S),o&&(o.disabled=C,o.classList.remove("choco-widget-pay-button--loading")),s&&(s.disabled=C),i&&(i.disabled=C),u==null||u.classList.toggle("choco-widget-wallet-blocked",C),u==null||u.setAttribute("aria-disabled",String(C)),c==null||c.classList.toggle("choco-widget-wallet-blocked",C),c==null||c.setAttribute("aria-disabled",String(C)),d==null||d.classList.toggle("choco-widget-wallet-blocked",C),d==null||d.setAttribute("aria-disabled",String(C)),g==null||g.classList.remove("disabled")}function $(e){var T,v,Q,_,m,P,k,w;const n=(T=e.container)==null?void 0:T.querySelector(".choco-widget-payment-method"),o=(v=e.container)==null?void 0:v.querySelector(".choco-widget-pay-button"),s=(Q=e.container)==null?void 0:Q.querySelector(".choco-widget-google-pay-button-slot button"),i=(_=e.container)==null?void 0:_.querySelector(".choco-widget-apple-pay-button-slot button"),u=(m=e.container)==null?void 0:m.querySelector(".choco-widget-google-pay-amount"),c=(P=e.container)==null?void 0:P.querySelector(".choco-widget-google-pay-row"),d=(k=e.container)==null?void 0:k.querySelector(".choco-widget-apple-pay-row"),g=(w=e.container)==null?void 0:w.querySelector(".choco-widget-balance-section"),C=e._isInteractionBlocked(),S=e.paymentMethodDisabled||C;g==null||g.classList.toggle("disabled",C),n&&(n.disabled=S),o&&(o.disabled=C,o.classList.toggle("choco-widget-pay-button--loading",e.loading)),s&&(s.disabled=C),i&&(i.disabled=C),u==null||u.classList.toggle("choco-widget-wallet-blocked",C),u==null||u.setAttribute("aria-disabled",String(C)),c==null||c.classList.toggle("choco-widget-wallet-blocked",C),c==null||c.setAttribute("aria-disabled",String(C)),d==null||d.classList.toggle("choco-widget-wallet-blocked",C),d==null||d.setAttribute("aria-disabled",String(C))}function rt(e){var o;if(e._isInteractionBlocked())return;const n=(o=e.container)==null?void 0:o.querySelector('[data-sheet="payment"]');n&&(n.classList.add("choco-widget-payment-sheet--open"),e.isPaymentSheetOpen=!0,ue(e))}function W(e){var o;const n=(o=e.container)==null?void 0:o.querySelector('[data-sheet="payment"]');if(n){Se(e);const s=n.querySelector(".choco-widget-sheet-content");s&&(s.style.transform="",s.classList.remove("choco-widget-sheet-content--dragging")),n.classList.remove("choco-widget-payment-sheet--open"),e.isPaymentSheetOpen=!1,e.isPaymentSheetEditMode&&(e.isPaymentSheetEditMode=!1,Ae(e),ue(e))}}function ue(e){var g;const n=(g=e.container)==null?void 0:g.querySelector('[data-sheet="payment"]');if(!n)return;const o=n.querySelector(".choco-widget-sheet-title"),s=n.querySelector('[data-action="close-sheet"]'),i=n.querySelector('[data-action="edit-sheet"]'),u=n.querySelector('[data-action="previous-sheet"]'),d=e.getAvailablePaymentMethods().some(C=>C.type==="card");e.isPaymentSheetEditMode?(n.classList.add("choco-widget-payment-sheet--edit"),o&&(o.textContent=e.t("editCards")),s&&(s.style.display="none"),i&&(i.style.display="none"),u&&(u.style.display="")):(n.classList.remove("choco-widget-payment-sheet--edit"),n.classList.toggle("choco-widget-payment-sheet--no-cards",!d),o&&(o.textContent=e.t("paymentMethods")),s&&(s.style.display=""),i&&(i.style.display=d?"":"none"),u&&(u.style.display="none"))}function ot(e){if(!e.addCardActionUrl||!e.container)return;const n=e.container.querySelector('[data-sheet="add-card"]'),o=e.container.querySelector("#choco-widget-add-card-iframe");n&&o&&(o.src=e.addCardActionUrl,n.classList.add("choco-widget-payment-sheet--open"),n.style.display="flex",n.setAttribute("aria-hidden","false"),e.isAddCardViewOpen=!0,on(e))}function oe(e){var s,i;const n=(s=e.container)==null?void 0:s.querySelector('[data-sheet="add-card"]'),o=(i=e.container)==null?void 0:i.querySelector("#choco-widget-add-card-iframe");n&&(n.classList.remove("choco-widget-payment-sheet--open"),n.style.display="none",n.setAttribute("aria-hidden","true")),o&&(o.src="about:blank"),e.addCardActionUrl=null,e.isAddCardViewOpen=!1,sn(e)}function on(e){e._boundAddCardMessage=n=>{var o;e.isAddCardViewOpen&&(o=n.data)!=null&&o.message&&n.origin==="https://rahmetapp.kz"&&re(e)},window.addEventListener("message",e._boundAddCardMessage)}function sn(e){e._boundAddCardMessage&&(window.removeEventListener("message",e._boundAddCardMessage),e._boundAddCardMessage=null)}function an(e,n){var c;e._pendingDeleteMethod=n;const o=(c=e.container)==null?void 0:c.querySelector('[data-sheet="payment"]');if(!o)return;o.classList.add("choco-widget-payment-sheet--delete-confirm");const s=o.querySelector(".choco-widget-sheet-title"),i=o.querySelector('[data-action="edit-sheet"]'),u=o.querySelector('[data-action="previous-sheet"]');s&&(s.textContent=e.t("confirmDeleteCard")),i&&(i.style.display="none"),u&&(u.style.display="none")}function Se(e){var o;e._pendingDeleteMethod=null,Re(e,!1);const n=(o=e.container)==null?void 0:o.querySelector('[data-sheet="payment"]');n==null||n.classList.remove("choco-widget-payment-sheet--delete-confirm"),ue(e)}function Re(e,n){var u,c,d;const o=(u=e.container)==null?void 0:u.querySelector(".choco-widget-sheet-delete-confirm-actions"),s=(c=e.container)==null?void 0:c.querySelector('[data-action="confirm-delete-cancel"]'),i=(d=e.container)==null?void 0:d.querySelector('[data-action="confirm-delete-submit"]');o==null||o.classList.toggle("choco-widget-sheet-delete-confirm-actions--loading",n),s&&(s.disabled=n),i&&(i.disabled=n,i.classList.toggle("choco-widget-delete-confirm-btn--loading",n))}async function cn(e,n){var s,i;const o=n==null?void 0:n.cardId;if(!(!o||(n==null?void 0:n.type)!=="card"))try{await Rt(e.apiUrl,e._getApiConfig(),o),e.checkoutContext=await Te(e.apiUrl,e._getApiConfig()),((s=e.selectedPaymentMethod)==null?void 0:s.type)==="card"&&((i=e.selectedPaymentMethod)==null?void 0:i.cardId)===o&&(e.selectedPaymentMethod=we(e.checkoutContext.data,e._getKaspiOptions()),e._emitPaymentMethodSelected(),tt(e)),Ae(e),e.config.onSuccess({message:e.t("cardDeleted")}),e.config.onCardDeleted&&e.config.onCardDeleted({cardId:o})}catch(u){e.config.onError({attributes:{message:(u==null?void 0:u.message)||e.t("paymentError")}})}}function st(e,n){if(!e._isInteractionBlocked()){if(e.selectedPaymentMethod=n,e._emitPaymentMethodSelected(),n.type==="new_card"){e._emitUserEvent("one_click_pay_method_resolved",{payment_method:n.type}),W(e),e.handlePayment();return}e._emitUserEvent("one_click_pay_method_resolved",{payment_method:e._getPaymentMethodForUserEvent()}),Ae(e),W(e),tt(e)}}function it(e,n){var s;const o=n.type||((s=n.data)==null?void 0:s.type);if(!o){console.warn("Unknown event format:",n);return}switch(o){case"order.paid":e._orderStatusResolved=!0,ee(e),ct(e,n);break;case"order.failed":e._orderStatusResolved=!0,ee(e),At(e,n);break;case"order.action_required":An(e,n);break;default:console.warn("Unknown event type:",o)}}function ee(e){e._orderStatusPollingId&&(clearInterval(e._orderStatusPollingId),e._orderStatusPollingId=null)}function le(e,n){ee(e),e._orderStatusResolved=!1;const o=6e3,s=5;let i=0;const u=async()=>{if(!e._orderStatusResolved){if(i>=s){ee(e),j(e),e.config.onError({attributes:{message:e.t("errorNoServerResponseRetry")}});return}i+=1;try{const{data:c}=await Mt(e.apiUrl,e._getApiConfig(),String(n)),d=c==null?void 0:c.status,g=(c==null?void 0:c.payload)||{};if(d==="success"){e._orderStatusResolved=!0,ee(e),ct(e,{id:String(g.id||n),attributes:{amount:g.amount,paid_at:g.paid_at||""}});return}d==="fail"&&(e._orderStatusResolved=!0,ee(e),At(e,{id:String(g.id||n),attributes:{message:g.message||e.t("paymentError")}}))}catch(c){console.warn("[Polling] checkOrderStatus error:",c)}}};e._orderStatusPollingId=setInterval(u,o),u()}function Oe(){return typeof document>"u"?!1:document.hidden||document.visibilityState==="hidden"}function at(e,n){j(e),e.config.onSuccess(n),e.config.backlink?window.location.href=e.config.backlink:e.destroy()}function Me(e){if(!e._pendingSuccessPayload||Oe())return;const n=e._pendingSuccessPayload;e._pendingSuccessPayload=null,at(e,n)}function ct(e,n){var i,u;e.isAddCardViewOpen&&oe(e);const o=n.attributes||((i=n.data)==null?void 0:i.attributes)||{},s={id:n.id||((u=n.data)==null?void 0:u.id),attributes:o};if(Oe()){e._pendingSuccessPayload=s;return}at(e,s)}function At(e,n){var s,i;e.isAddCardViewOpen&&oe(e),j(e);const o=n.attributes||((s=n.data)==null?void 0:s.attributes)||{};e.config.onError({id:n.id||((i=n.data)==null?void 0:i.id),attributes:o})}function An(e,n){var u,c,d;const o=n.attributes||((u=n.data)==null?void 0:u.attributes)||{},s=o.action_link||o.action_url,i=o.action_url_type||o.action_type||"redirect";if(!s){console.error(e.t("errorActionUrlMissing")),e.waitingForNewCardAction&&(e.waitingForNewCardAction=!1,j(e),e.config.onError({attributes:{message:e.t("errorNoServerResponse")}}));return}if(e.waitingForNewCardAction&&(e.waitingForNewCardAction=!1,e._clearNewCardActionTimeout()),i==="inner"){e.addCardActionUrl=s,j(e),e._showAddCardView();return}if(((c=e.selectedPaymentMethod)==null?void 0:c.type)==="kaspi_pay"){const g=n.id||((d=n.data)==null?void 0:d.id);if(g&&!e._orderStatusResolved&&!e._orderStatusPollingId&&le(e,String(g)),typeof e.config.onKaspiLink=="function"){e.config.onKaspiLink({action_link:s,action_url:s,action_type:i,event:n});return}}window.location.href=s}async function un(e){var o,s,i,u;if(!e.selectedPaymentMethod){e.config.onError({attributes:{message:e.t("errorPaymentMethodNotSelected")}});return}const{checkoutOptions:n}=e._getPaymentBreakdown();if(e._isBalanceFullyCoveringAmount()){re(e);try{const c=await Ye(e.apiUrl,e._getApiConfig(),e.deviceId,e.selectedPaymentMethod,n);await ut(e);const d=(c==null?void 0:c.id)??((o=c==null?void 0:c.data)==null?void 0:o.id);return d&&le(e,String(d)),c}catch(c){throw j(e),e.config.onError({attributes:{message:e._resolveErrorMessage(c)}}),c}}if(e.selectedPaymentMethod.type==="new_card"){await ln(e,n);return}if(e.selectedPaymentMethod.type==="apple_pay"){await dn(e,n);return}if(e.selectedPaymentMethod.type==="google_pay"){await hn(e,n);return}re(e);try{const c=await Ye(e.apiUrl,e._getApiConfig(),e.deviceId,e.selectedPaymentMethod,n);await ut(e);const d=(c==null?void 0:c.id)??((s=c==null?void 0:c.data)==null?void 0:s.id);if(d&&le(e,String(d)),((i=e.selectedPaymentMethod)==null?void 0:i.type)==="kaspi_pay"){const g=(c==null?void 0:c.attributes)||((u=c==null?void 0:c.data)==null?void 0:u.attributes)||{},C=g.action_link||g.action_url,S=g.action_url_type||g.action_type||"redirect";if(C)return typeof e.config.onKaspiLink=="function"?(e.config.onKaspiLink({action_link:C,action_url:C,action_type:S,event:c}),c):(window.location.href=C,c)}return c}catch(c){throw j(e),e.config.onError({message:e._resolveErrorMessage(c)}),c}}async function ut(e){var n,o;if(!(((n=e.selectedPaymentMethod)==null?void 0:n.type)!=="card"||!((o=e.selectedPaymentMethod)!=null&&o.cardId)))try{await Ot(e.apiUrl,e._getApiConfig(),e.selectedPaymentMethod.cardId)}catch(s){console.warn("Failed to mark selected card as default:",s)}}async function ln(e,n){re(e),e.waitingForNewCardAction=!0,e._setNewCardActionTimeout();try{await Nt(e.apiUrl,e._getApiConfig(),e.deviceId,n)}catch(o){e.waitingForNewCardAction=!1,e._clearNewCardActionTimeout(),j(e),e.config.onError({attributes:{message:e._resolveErrorMessage(o)}}),console.error("New card payment error:",o)}}async function dn(e,n){const o=window.ApplePaySession;if(!o||!o.canMakePayments()){e.config.onError({attributes:{message:e.t("errorApplePayUnsupported")}});return}const s={countryCode:e.config.currency==="GEL"?"GE":"KZ",currencyCode:e.config.currency,supportedNetworks:["visa","masterCard"],merchantCapabilities:["supports3DS"],total:{label:"Choco",amount:String(e._getPayableAmount()),type:"final"}},i=new o(3,s);i.onvalidatemerchant=async u=>{var c,d;try{const g=await Dt(e.apiUrl,e._getApiConfig(),u.validationURL),C=((d=(c=g==null?void 0:g.data)==null?void 0:c.attributes)==null?void 0:d.session)||g,S=JSON.parse(atob(C));i.completeMerchantValidation(S)}catch(g){console.error("Apple Pay session error:",g),i.abort(),e.config.onError({attributes:{message:e.t("errorApplePayInit")}})}},i.onpaymentauthorized=async u=>{var c;try{if(re(e),typeof e.config.onBeforeCheckout=="function"){const C=await e.config.onBeforeCheckout();C&&typeof C=="object"&&Object.assign(e.config,C)}const d=await Xt(e.apiUrl,e._getApiConfig(),e.deviceId,u.payment,n);i.completePayment(o.STATUS_SUCCESS);const g=(d==null?void 0:d.id)??((c=d==null?void 0:d.data)==null?void 0:c.id);g&&le(e,String(g))}catch(d){console.error("Apple Pay payment error:",d),i.completePayment(o.STATUS_FAILURE),j(e),e.config.onError({attributes:{message:e._resolveErrorMessage(d,"errorApplePayPayment")}})}},i.oncancel=()=>e.config.onCancel(),i.begin()}async function hn(e,n){var P,k,w,L,O,F;try{await e._loadGooglePaySdk()}catch(M){console.error("Google Pay SDK load error:",M),e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}const o=window.google;if(!(o!=null&&o.payments)){e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}const s=(P=e.checkoutContext)==null?void 0:P.data,i=((w=(k=s==null?void 0:s.payment_methods)==null?void 0:k.data)==null?void 0:w.attributes)||{},u=i.google_pay_settings||{};if(!(i.payment_method_google_pay==="enabled"||i.payment_method_google_pay===!0)){e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}const d=u==null?void 0:u.gateway,g=u==null?void 0:u.merchant_id;if(!d||!g){e.config.onError({attributes:{message:e.t("errorGooglePaySettingsUnavailable")}});return}const C=e.config.environment==="production",S=(u==null?void 0:u.merchant_name)||"Choco",T=u==null?void 0:u.google_merchant_id;if(C&&!T){e.config.onError({attributes:{message:e.t("errorGooglePaySettingsUnavailable")}});return}const v=Number(e._getCheckoutAmount()).toFixed(2),Q=new o.payments.api.PaymentsClient({environment:C?"PRODUCTION":"TEST"}),_=[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["VISA","MASTERCARD"],billingAddressRequired:!1},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:d,gatewayMerchantId:g}}}],m={apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:_,transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Итого",totalPrice:v,currencyCode:e.config.currency,countryCode:e.config.currency==="GEL"?"GE":"KZ"},merchantInfo:C?{merchantId:T,merchantName:S}:{merchantName:S}};console.log("paymentDataRequest",m);try{const M=await Q.isReadyToPay({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:_});if(!(M!=null&&M.result)){e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}re(e);const J=await Q.loadPaymentData(m),x=(O=(L=J==null?void 0:J.paymentMethodData)==null?void 0:L.tokenizationData)==null?void 0:O.token;if(!x)throw new Error(e.t("errorGooglePayPayment"));const q=JSON.parse(x),N=await Ut(e.apiUrl,e._getApiConfig(),e.deviceId,q,n),b=(N==null?void 0:N.id)??((F=N==null?void 0:N.data)==null?void 0:F.id);b&&le(e,String(b))}catch(M){j(e),M.statusCode==="CANCELED"?e.config.onCancel():(e.config.onError({attributes:{message:e._resolveErrorMessage(M,"errorGooglePayPayment")}}),console.error("Google Pay error:",M))}}function fn(e){var u,c,d,g,C,S,T,v,Q,_;const n=e.container;(u=n.querySelector('[data-action="pay"]'))==null||u.addEventListener("click",()=>e.handlePayment()),(c=n.querySelector('[data-action="change-method"]'))==null||c.addEventListener("click",()=>rt(e)),n.querySelectorAll('[data-action="close"]').forEach(m=>m.addEventListener("click",()=>e.close())),(d=n.querySelector('[data-action="close-sheet"]'))==null||d.addEventListener("click",()=>{e._pendingDeleteMethod?Se(e):W(e)}),(g=n.querySelector('[data-action="edit-sheet"]'))==null||g.addEventListener("click",()=>{e.isPaymentSheetEditMode=!0,Ae(e),ue(e)}),(C=n.querySelector('[data-action="previous-sheet"]'))==null||C.addEventListener("click",()=>{e.isPaymentSheetEditMode=!1,Ae(e),ue(e)}),(S=n.querySelector('[data-action="close-add-card"]'))==null||S.addEventListener("click",()=>oe(e)),(T=n.querySelector('[data-action="confirm-delete-cancel"]'))==null||T.addEventListener("click",()=>Se(e)),(v=n.querySelector('[data-action="confirm-delete-submit"]'))==null||v.addEventListener("click",()=>{if(e._pendingDeleteMethod){const m=e._pendingDeleteMethod;Re(e,!0),cn(e,m).then(()=>W(e)).finally(()=>Re(e,!1))}}),n.querySelectorAll(".choco-widget-method-item").forEach(m=>{m.addEventListener("click",P=>{const k=JSON.parse(P.currentTarget.getAttribute("data-method")||"{}");st(e,k)})});const o=n.querySelector('[data-sheet="payment"]');o&&(o.addEventListener("click",m=>{m.target===o&&W(e)}),pn(e,o));const s=n.querySelector('[data-action="toggle-balance"]');s&&((Q=s.querySelector("input[type='checkbox']"))==null||Q.addEventListener("change",m=>{e.useBalance=m.target.checked,e._updatePayButtonAmount()}));const i=n.querySelector('[data-action="toggle-bonuses"]');i&&((_=i.querySelector("input[type='checkbox']"))==null||_.addEventListener("change",m=>{e.useBonuses=m.target.checked,e.config.onAppliedBonus(e.useBonuses),e._updatePayButtonAmount()})),document.removeEventListener("keydown",e._boundKeyDown),document.addEventListener("keydown",e._boundKeyDown),nt(e)}function gn(e,n){var o,s;e.isOpen&&(n.key==="Escape"&&(n.preventDefault(),e._pendingDeleteMethod?Se(e):e.isAddCardViewOpen?oe(e):e.isPaymentSheetOpen?W(e):e.close()),n.key==="Enter"&&((s=(o=n.target)==null?void 0:o.dataset)==null?void 0:s.action)==="pay"&&(n.preventDefault(),e.handlePayment()))}function pn(e,n){const o=n.querySelector('[data-action="sheet-drag-handle"]'),s=n.querySelector(".choco-widget-sheet-content");if(!o||!s)return;const i=80;let u=0,c=0;const d=C=>{c=C.clientY;const S=Math.max(0,c-u);s.style.transform=`translateY(${S}px)`},g=C=>{o.releasePointerCapture(C.pointerId),o.removeEventListener("pointermove",d),o.removeEventListener("pointerup",g),o.removeEventListener("pointercancel",g);const S=Math.max(0,c-u);if(s.classList.remove("choco-widget-sheet-content--dragging"),S>=i){s.style.transform="translateY(100%)";const T=()=>{s.removeEventListener("transitionend",T),s.style.transform="",W(e)};s.addEventListener("transitionend",T)}else s.style.transform=""};o.addEventListener("pointerdown",C=>{!e.isPaymentSheetOpen||C.button!==0||(C.preventDefault(),u=C.clientY,c=C.clientY,s.classList.add("choco-widget-sheet-content--dragging"),o.setPointerCapture(C.pointerId),o.addEventListener("pointermove",d),o.addEventListener("pointerup",g),o.addEventListener("pointercancel",g))})}class te{static _getAuthStorageValue(n){return We(n)}static _setAuthStorageValue(n,o){_e(n,o)}static _removeAuthStorageValue(n){be(n)}static async logout(){Ge()}constructor(n){this.config=Ht(n),this.accessToken=null,this.deviceId=Fe(),this.apiUrl=yt(this.config.environment),this.translations=ae,this.checkoutContext=null,this.centrifuge=null,this.selectedPaymentMethod=null,this.container=null,this.isOpen=!1,this.isPaymentSheetOpen=!1,this.isPaymentSheetEditMode=!1,this.loading=!1,this.disabled=!1,this.paymentMethodDisabled=!1,this.useBalance=!1,this.useBonuses=!1,this.addCardActionUrl=null,this.isAddCardViewOpen=!1,this.waitingForNewCardAction=!1,this.newCardActionRequiredTimeoutId=null,this._googlePayScriptPromise=null,this._googlePayButtonRenderVersion=0,this._orderStatusPollingId=null,this._orderStatusResolved=!1,this._pendingDeleteMethod=null,this._pendingSuccessPayload=null,this._lifecycleListenersAttached=!1,this._boundAddCardMessage=null,this._boundKeyDown=o=>gn(this,o),this._boundVisibilityChange=()=>this._onVisibilityChange(),this._boundWindowFocus=()=>this._onWindowFocus(),this._boundPageShow=()=>this._onPageShow()}t(n,o={}){var u;const s=this.config.locale||"ru",i=((u=this.translations[s])==null?void 0:u[n])||this.translations.ru[n];return typeof i!="string"?n:i.replace(/{(\w+)}/g,(c,d)=>Object.prototype.hasOwnProperty.call(o,d)?String(o[d]):c)}_resolveErrorMessage(n,o="paymentError"){return(n==null?void 0:n.message)||this.t(o)}_getApiConfig(){return{...this.config,accessToken:this.accessToken}}_isInteractionBlocked(){return this.disabled||this.loading}_getBalanceAmount(){var i,u,c,d;const n=(d=(c=(u=(i=this.checkoutContext)==null?void 0:i.data)==null?void 0:u.balance)==null?void 0:c.data)==null?void 0:d.money,o=this.config.currency||"KZT",s=Number(n==null?void 0:n[o]);return Number.isFinite(s)&&s>0?s:0}_getBonusesAmount(){var o;const n=Number((o=this.config.bonuses)==null?void 0:o.amount);return Number.isFinite(n)&&n>0?n:0}_getBonusesPercent(){var o;const n=Number((o=this.config.bonuses)==null?void 0:o.percent);return!Number.isFinite(n)||n<=0?0:n>=100?100:n}_getAvailableBonus(){var o;const n=Number((o=this.config.bonuses)==null?void 0:o.availableBonus);return Number.isFinite(n)&&n>0?n:0}_getPaymentBreakdown(){const n=this.config.amount,o=this._getBalanceAmount(),s=this.useBalance?Math.min(o,n):0,i=n-s,u=this.useBalance&&s>=n,c=this.useBonuses?this._getAvailableBonus():0,d=Math.max(i-c,0),g=this.useBalance?n:d,C=this.useBalance&&!u;return{payableAmount:d,checkoutOptions:{checkoutAmount:g,forceBalanceMethod:u,useBalance:C}}}_getPayableAmount(){return this._getPaymentBreakdown().payableAmount}_isBalanceFullyCoveringAmount(){return this._getPaymentBreakdown().checkoutOptions.forceBalanceMethod}_getCheckoutAmount(){return this._getPaymentBreakdown().checkoutOptions.checkoutAmount??this.config.amount}_getPaymentMethodForUserEvent(){var n;return this._isBalanceFullyCoveringAmount()?"balance":((n=this.selectedPaymentMethod)==null?void 0:n.type)??null}_getKaspiOptions(){return{onlyKaspiAvailable:this.config.onlyKaspiAvailable,disableKaspi:this.config.disableKaspi}}_emitUserEvent(n,o={}){typeof this.config.onUserEvent=="function"&&this.config.onUserEvent({eventName:n,eventProperties:o})}_emitPaymentMethodSelected(n=this.selectedPaymentMethod){typeof this.config.onPaymentMethodSelected=="function"&&this.config.onPaymentMethodSelected(n||null)}_attachEventListeners(){fn(this)}_updatePayButtonAmount(){Qe(this)}_showAddCardView(){ot(this)}_closeAddCardView(){oe(this)}_setNewCardActionTimeout(){this._clearNewCardActionTimeout(),this.newCardActionRequiredTimeoutId=window.setTimeout(()=>{this.waitingForNewCardAction&&(this.waitingForNewCardAction=!1,j(this),this.config.onError({attributes:{message:this.t("errorNoServerResponseRetry")}})),this.newCardActionRequiredTimeoutId=null},6e4)}_clearNewCardActionTimeout(){this.newCardActionRequiredTimeoutId&&(window.clearTimeout(this.newCardActionRequiredTimeoutId),this.newCardActionRequiredTimeoutId=null)}_saveTokensToStorage(n,o){Le(n,o)}_clearAuthStorage(){Ge()}_getAuthStorageValue(n){return te._getAuthStorageValue(n)}_setAuthStorageValue(n,o){te._setAuthStorageValue(n,o)}_removeAuthStorageValue(n){te._removeAuthStorageValue(n)}_loadGooglePaySdk(){var n,o;return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Google Pay SDK requires browser environment")):(o=(n=window.google)==null?void 0:n.payments)!=null&&o.api?Promise.resolve():this._googlePayScriptPromise?this._googlePayScriptPromise:(this._googlePayScriptPromise=new Promise((s,i)=>{const u=document.querySelector('script[data-choco-google-pay-sdk="true"]');if(u){u.addEventListener("load",()=>s(),{once:!0}),u.addEventListener("error",()=>i(new Error("Failed to load Google Pay SDK")),{once:!0});return}const c=document.createElement("script");c.src="https://pay.google.com/gp/p/js/pay.js",c.async=!0,c.defer=!0,c.setAttribute("data-choco-google-pay-sdk","true"),c.onload=()=>s(),c.onerror=()=>i(new Error("Failed to load Google Pay SDK")),document.head.appendChild(c)}).finally(()=>{var s,i;(i=(s=window.google)==null?void 0:s.payments)!=null&&i.api||(this._googlePayScriptPromise=null)}),this._googlePayScriptPromise)}_attachLifecycleListeners(){this._lifecycleListenersAttached||(document.addEventListener("visibilitychange",this._boundVisibilityChange),window.addEventListener("focus",this._boundWindowFocus),window.addEventListener("pageshow",this._boundPageShow),this._lifecycleListenersAttached=!0)}_detachLifecycleListeners(){this._lifecycleListenersAttached&&(document.removeEventListener("visibilitychange",this._boundVisibilityChange),window.removeEventListener("focus",this._boundWindowFocus),window.removeEventListener("pageshow",this._boundPageShow),this._lifecycleListenersAttached=!1)}_onVisibilityChange(){Oe()||Me(this)}_onWindowFocus(){Me(this)}_onPageShow(){Me(this)}async _obtainTokenByRefreshOrTrackId(){await xt(this)}async _fetchCheckoutContextWithRetry(){try{this.checkoutContext=await Te(this.apiUrl,this._getApiConfig())}catch(n){if(n.status===401)this._removeAuthStorageValue("webPayToken"),await this._obtainTokenByRefreshOrTrackId(),this.checkoutContext=await Te(this.apiUrl,this._getApiConfig());else throw n}}_prerender(){en(this)}_render(){tn(this)}async init(){var n,o;try{if(this._prerender(),this._attachLifecycleListeners(),!this.config.clientId)return this.config.onError({attributes:{message:this.t("errorMissingTrackClient")}}),!1;if(this.accessToken=this._getAuthStorageValue("webPayToken"),!this.config.trackId&&!this.accessToken)return this.paymentMethodDisabled=!0,this._render(),!0;this.accessToken||await this._obtainTokenByRefreshOrTrackId();try{await this._fetchCheckoutContextWithRetry()}catch(i){const u=i;return this.config.onError({attributes:{message:u.message}}),!1}const s=je((o=(n=this.checkoutContext)==null?void 0:n.data)==null?void 0:o.socket_connections,i=>it(this,i));return s&&(this.centrifuge=s.centrifuge),this.selectedPaymentMethod=we(this.checkoutContext.data,this._getKaspiOptions()),this._emitPaymentMethodSelected(),this._render(),!0}catch(s){return console.error(`${this.t("errorWidgetInit")}:`,s),this.config.onError({attributes:{message:s.message}}),!1}}close(){var n;(n=this.container)==null||n.classList.remove("choco-one-click-widget--visible"),setTimeout(()=>this.config.onCancel(),300)}destroy(){const n=document.getElementById("choco-one-click-widget");n&&(n.style.display="none"),this._clearNewCardActionTimeout(),ee(this),this._pendingSuccessPayload=null,this._detachLifecycleListeners(),this.isAddCardViewOpen&&oe(this),this.centrifuge&&(this.centrifuge.disconnect(),this.centrifuge=null),document.removeEventListener("keydown",this._boundKeyDown),this.container&&(this.container.classList.remove("choco-one-click-widget--visible"),setTimeout(()=>{var o;(o=this.container)==null||o.remove(),this.container=null},300)),this.isOpen=!1,this.isPaymentSheetOpen=!1,this.isAddCardViewOpen=!1,this.selectedPaymentMethod=null}getAvailablePaymentMethods(){var n;return(n=this.checkoutContext)!=null&&n.data?wt(this.checkoutContext.data,o=>this.t(o),this._getKaspiOptions()):[]}async createOrder(){return un(this)}async pay(){try{await this.createOrder()}catch(n){console.error(`${this.t("errorPaymentProcess")}:`,n)}}async handlePayment(){if(!this._isInteractionBlocked()){this._emitUserEvent("one_click_pay_cta_tapped",{payment_method:this._getPaymentMethodForUserEvent()});try{if(this.config.onConfirmPay){this.config.onConfirmPay(this.selectedPaymentMethod||null);return}await this.pay()}catch(n){console.error(`${this.t("errorPaymentProcess")}:`,n)}}}openPaymentSheet(){rt(this)}closePaymentSheet(){W(this)}async updateAmount(n){if(typeof n!="number"||!Number.isFinite(n)||n<0)throw new Error("amount must be a non-negative number");this.config.amount=n,Qe(this)}async updateAvailableBonus(n){if(typeof n!="number"||!Number.isFinite(n)||n<0)throw new Error("availableBonus must be a non-negative number");this.config.bonuses&&(this.config.bonuses.availableBonus=n),Qe(this)}async updateLocale(n){if(typeof n!="string"||!this.translations[n])throw new Error(`Unsupported locale: ${n}`);if(this.config.locale=n,!this.container)return;const o=this.isPaymentSheetOpen,s=this.isAddCardViewOpen;if(this._render(),$(this),o){const i=this.container.querySelector('[data-sheet="payment"]');i&&(i.classList.add("choco-widget-payment-sheet--open"),this.isPaymentSheetOpen=!0)}s&&ot(this)}async setLoading(n){this.loading=!!n,$(this)}async setDisabled(n){this.disabled=!!n,$(this)}async setPreorderId(n){this.config.preorderId=n}async setMerchantOrderId(n){this.config.merchantOrderId=n}async logout(){await te.logout(),this.accessToken=null}async updateTrackId(n){var o,s;if(this.config.trackId=n,!this.config.clientId)return this.config.onError({attributes:{message:this.t("errorMissingTrackClient")}}),!1;try{this._prerender(),await this._obtainTokenByRefreshOrTrackId();try{await this._fetchCheckoutContextWithRetry()}catch(u){const c=u;return this.config.onError({attributes:{message:c.message}}),!1}this.centrifuge&&(this.centrifuge.disconnect(),this.centrifuge=null);const i=je((s=(o=this.checkoutContext)==null?void 0:o.data)==null?void 0:s.socket_connections,u=>it(this,u));return i&&(this.centrifuge=i.centrifuge),this.selectedPaymentMethod=we(this.checkoutContext.data,this._getKaspiOptions()),this._emitPaymentMethodSelected(),this.paymentMethodDisabled=!1,this._render(),!0}catch(i){return console.error(`${this.t("errorWidgetInit")}:`,i),this.config.onError({attributes:{message:i.message}}),!1}}async onConfirmPay(n){if(typeof n!="function")throw new Error("onConfirmPay callback must be a function");this.config.onConfirmPay=n}async onPaymentMethodSelected(n){if(typeof n!="function")throw new Error("onPaymentMethodSelected callback must be a function");this.config.onPaymentMethodSelected=n,this._emitPaymentMethodSelected()}async onKaspiLink(n){if(typeof n!="function")throw new Error("onKaspiLink callback must be a function");this.config.onKaspiLink=n}async onUserEvent(n){if(typeof n!="function")throw new Error("onUserEvent callback must be a function");this.config.onUserEvent=n}async onAppliedBonus(n){if(typeof n!="function")throw new Error("onAppliedBonus callback must be a function");this.config.onAppliedBonus=n}}return typeof window<"u"&&(window.ChocoOneClickWidget=te),te}));
|
|
279
|
+
`,o.appendChild(s),o.appendChild(i),n.appendChild(o),$(e)}function re(e){e.loading=!0,$(e)}function j(e){var T,v,Q,_,m,P,k,w;e.loading=!1;const n=(T=e.container)==null?void 0:T.querySelector(".choco-widget-payment-method"),o=(v=e.container)==null?void 0:v.querySelector(".choco-widget-pay-button"),s=(Q=e.container)==null?void 0:Q.querySelector(".choco-widget-google-pay-button-slot button"),i=(_=e.container)==null?void 0:_.querySelector(".choco-widget-apple-pay-button-slot button"),u=(m=e.container)==null?void 0:m.querySelector(".choco-widget-google-pay-amount"),c=(P=e.container)==null?void 0:P.querySelector(".choco-widget-google-pay-row"),d=(k=e.container)==null?void 0:k.querySelector(".choco-widget-apple-pay-row"),g=(w=e.container)==null?void 0:w.querySelector(".choco-widget-balance-section"),C=e._isInteractionBlocked(),S=e.paymentMethodDisabled||C;n&&(n.disabled=S),o&&(o.disabled=C,o.classList.remove("choco-widget-pay-button--loading")),s&&(s.disabled=C),i&&(i.disabled=C),u==null||u.classList.toggle("choco-widget-wallet-blocked",C),u==null||u.setAttribute("aria-disabled",String(C)),c==null||c.classList.toggle("choco-widget-wallet-blocked",C),c==null||c.setAttribute("aria-disabled",String(C)),d==null||d.classList.toggle("choco-widget-wallet-blocked",C),d==null||d.setAttribute("aria-disabled",String(C)),g==null||g.classList.remove("disabled")}function $(e){var T,v,Q,_,m,P,k,w;const n=(T=e.container)==null?void 0:T.querySelector(".choco-widget-payment-method"),o=(v=e.container)==null?void 0:v.querySelector(".choco-widget-pay-button"),s=(Q=e.container)==null?void 0:Q.querySelector(".choco-widget-google-pay-button-slot button"),i=(_=e.container)==null?void 0:_.querySelector(".choco-widget-apple-pay-button-slot button"),u=(m=e.container)==null?void 0:m.querySelector(".choco-widget-google-pay-amount"),c=(P=e.container)==null?void 0:P.querySelector(".choco-widget-google-pay-row"),d=(k=e.container)==null?void 0:k.querySelector(".choco-widget-apple-pay-row"),g=(w=e.container)==null?void 0:w.querySelector(".choco-widget-balance-section"),C=e._isInteractionBlocked(),S=e.paymentMethodDisabled||C;g==null||g.classList.toggle("disabled",C),n&&(n.disabled=S),o&&(o.disabled=C,o.classList.toggle("choco-widget-pay-button--loading",e.loading)),s&&(s.disabled=C),i&&(i.disabled=C),u==null||u.classList.toggle("choco-widget-wallet-blocked",C),u==null||u.setAttribute("aria-disabled",String(C)),c==null||c.classList.toggle("choco-widget-wallet-blocked",C),c==null||c.setAttribute("aria-disabled",String(C)),d==null||d.classList.toggle("choco-widget-wallet-blocked",C),d==null||d.setAttribute("aria-disabled",String(C))}function rt(e){var o;if(e._isInteractionBlocked())return;const n=(o=e.container)==null?void 0:o.querySelector('[data-sheet="payment"]');n&&(n.classList.add("choco-widget-payment-sheet--open"),e.isPaymentSheetOpen=!0,ue(e))}function W(e){var o;const n=(o=e.container)==null?void 0:o.querySelector('[data-sheet="payment"]');if(n){Se(e);const s=n.querySelector(".choco-widget-sheet-content");s&&(s.style.transform="",s.classList.remove("choco-widget-sheet-content--dragging")),n.classList.remove("choco-widget-payment-sheet--open"),e.isPaymentSheetOpen=!1,e.isPaymentSheetEditMode&&(e.isPaymentSheetEditMode=!1,Ae(e),ue(e))}}function ue(e){var g;const n=(g=e.container)==null?void 0:g.querySelector('[data-sheet="payment"]');if(!n)return;const o=n.querySelector(".choco-widget-sheet-title"),s=n.querySelector('[data-action="close-sheet"]'),i=n.querySelector('[data-action="edit-sheet"]'),u=n.querySelector('[data-action="previous-sheet"]'),d=e.getAvailablePaymentMethods().some(C=>C.type==="card");e.isPaymentSheetEditMode?(n.classList.add("choco-widget-payment-sheet--edit"),o&&(o.textContent=e.t("editCards")),s&&(s.style.display="none"),i&&(i.style.display="none"),u&&(u.style.display="")):(n.classList.remove("choco-widget-payment-sheet--edit"),n.classList.toggle("choco-widget-payment-sheet--no-cards",!d),o&&(o.textContent=e.t("paymentMethods")),s&&(s.style.display=""),i&&(i.style.display=d?"":"none"),u&&(u.style.display="none"))}function ot(e){if(!e.addCardActionUrl||!e.container)return;const n=e.container.querySelector('[data-sheet="add-card"]'),o=e.container.querySelector("#choco-widget-add-card-iframe");n&&o&&(o.src=e.addCardActionUrl,n.classList.add("choco-widget-payment-sheet--open"),n.style.display="flex",n.setAttribute("aria-hidden","false"),e.isAddCardViewOpen=!0,on(e))}function oe(e){var s,i;const n=(s=e.container)==null?void 0:s.querySelector('[data-sheet="add-card"]'),o=(i=e.container)==null?void 0:i.querySelector("#choco-widget-add-card-iframe");n&&(n.classList.remove("choco-widget-payment-sheet--open"),n.style.display="none",n.setAttribute("aria-hidden","true")),o&&(o.src="about:blank"),e.addCardActionUrl=null,e.isAddCardViewOpen=!1,sn(e)}function on(e){e._boundAddCardMessage=n=>{var o;e.isAddCardViewOpen&&(o=n.data)!=null&&o.message&&n.origin==="https://rahmetapp.kz"&&re(e)},window.addEventListener("message",e._boundAddCardMessage)}function sn(e){e._boundAddCardMessage&&(window.removeEventListener("message",e._boundAddCardMessage),e._boundAddCardMessage=null)}function an(e,n){var c;e._pendingDeleteMethod=n;const o=(c=e.container)==null?void 0:c.querySelector('[data-sheet="payment"]');if(!o)return;o.classList.add("choco-widget-payment-sheet--delete-confirm");const s=o.querySelector(".choco-widget-sheet-title"),i=o.querySelector('[data-action="edit-sheet"]'),u=o.querySelector('[data-action="previous-sheet"]');s&&(s.textContent=e.t("confirmDeleteCard")),i&&(i.style.display="none"),u&&(u.style.display="none")}function Se(e){var o;e._pendingDeleteMethod=null,Re(e,!1);const n=(o=e.container)==null?void 0:o.querySelector('[data-sheet="payment"]');n==null||n.classList.remove("choco-widget-payment-sheet--delete-confirm"),ue(e)}function Re(e,n){var u,c,d;const o=(u=e.container)==null?void 0:u.querySelector(".choco-widget-sheet-delete-confirm-actions"),s=(c=e.container)==null?void 0:c.querySelector('[data-action="confirm-delete-cancel"]'),i=(d=e.container)==null?void 0:d.querySelector('[data-action="confirm-delete-submit"]');o==null||o.classList.toggle("choco-widget-sheet-delete-confirm-actions--loading",n),s&&(s.disabled=n),i&&(i.disabled=n,i.classList.toggle("choco-widget-delete-confirm-btn--loading",n))}async function cn(e,n){var s,i;const o=n==null?void 0:n.cardId;if(!(!o||(n==null?void 0:n.type)!=="card"))try{await Rt(e.apiUrl,e._getApiConfig(),o),e.checkoutContext=await Te(e.apiUrl,e._getApiConfig()),((s=e.selectedPaymentMethod)==null?void 0:s.type)==="card"&&((i=e.selectedPaymentMethod)==null?void 0:i.cardId)===o&&(e.selectedPaymentMethod=we(e.checkoutContext.data,e._getKaspiOptions()),e._emitPaymentMethodSelected(),tt(e)),Ae(e),e.config.onSuccess({message:e.t("cardDeleted")}),e.config.onCardDeleted&&e.config.onCardDeleted({cardId:o})}catch(u){e.config.onError({attributes:{message:(u==null?void 0:u.message)||e.t("paymentError")}})}}function st(e,n){if(!e._isInteractionBlocked()){if(e.selectedPaymentMethod=n,e._emitPaymentMethodSelected(),n.type==="new_card"){e._emitUserEvent("one_click_pay_method_resolved",{payment_method:n.type}),W(e),e.handlePayment();return}e._emitUserEvent("one_click_pay_method_resolved",{payment_method:e._getPaymentMethodForUserEvent()}),Ae(e),W(e),tt(e)}}function it(e,n){var s;const o=n.type||((s=n.data)==null?void 0:s.type);if(!o){console.warn("Unknown event format:",n);return}switch(o){case"order.paid":e._orderStatusResolved=!0,ee(e),ct(e,n);break;case"order.failed":e._orderStatusResolved=!0,ee(e),At(e,n);break;case"order.action_required":An(e,n);break;default:console.warn("Unknown event type:",o)}}function ee(e){e._orderStatusPollingId&&(clearInterval(e._orderStatusPollingId),e._orderStatusPollingId=null)}function le(e,n){ee(e),e._orderStatusResolved=!1;const o=6e3,s=5;let i=0;const u=async()=>{if(!e._orderStatusResolved){if(i>=s){ee(e),j(e),e.config.onError({attributes:{message:e.t("errorNoServerResponseRetry")}});return}i+=1;try{const{data:c}=await Mt(e.apiUrl,e._getApiConfig(),String(n)),d=c==null?void 0:c.status,g=(c==null?void 0:c.payload)||{};if(d==="success"){e._orderStatusResolved=!0,ee(e),ct(e,{id:String(g.id||n),attributes:{amount:g.amount,paid_at:g.paid_at||""}});return}d==="fail"&&(e._orderStatusResolved=!0,ee(e),At(e,{id:String(g.id||n),attributes:{message:g.message||e.t("paymentError")}}))}catch(c){console.warn("[Polling] checkOrderStatus error:",c)}}};e._orderStatusPollingId=setInterval(u,o),u()}function Oe(){return typeof document>"u"?!1:document.hidden||document.visibilityState==="hidden"}function at(e,n){j(e),e.config.onSuccess(n)}function Me(e){if(!e._pendingSuccessPayload||Oe())return;const n=e._pendingSuccessPayload;e._pendingSuccessPayload=null,at(e,n)}function ct(e,n){var i,u;e.isAddCardViewOpen&&oe(e);const o=n.attributes||((i=n.data)==null?void 0:i.attributes)||{},s={id:n.id||((u=n.data)==null?void 0:u.id),attributes:o};if(Oe()){e._pendingSuccessPayload=s;return}at(e,s)}function At(e,n){var s,i;e.isAddCardViewOpen&&oe(e),j(e);const o=n.attributes||((s=n.data)==null?void 0:s.attributes)||{};e.config.onError({id:n.id||((i=n.data)==null?void 0:i.id),attributes:o})}function An(e,n){var u,c,d;const o=n.attributes||((u=n.data)==null?void 0:u.attributes)||{},s=o.action_link||o.action_url,i=o.action_url_type||o.action_type||"redirect";if(!s){console.error(e.t("errorActionUrlMissing")),e.waitingForNewCardAction&&(e.waitingForNewCardAction=!1,j(e),e.config.onError({attributes:{message:e.t("errorNoServerResponse")}}));return}if(e.waitingForNewCardAction&&(e.waitingForNewCardAction=!1,e._clearNewCardActionTimeout()),i==="inner"){e.addCardActionUrl=s,j(e),e._showAddCardView();return}if(((c=e.selectedPaymentMethod)==null?void 0:c.type)==="kaspi_pay"){const g=n.id||((d=n.data)==null?void 0:d.id);if(g&&!e._orderStatusResolved&&!e._orderStatusPollingId&&le(e,String(g)),typeof e.config.onKaspiLink=="function"){e.config.onKaspiLink({action_link:s,action_url:s,action_type:i,event:n});return}}window.location.href=s}async function un(e){var o,s,i,u;if(!e.selectedPaymentMethod){e.config.onError({attributes:{message:e.t("errorPaymentMethodNotSelected")}});return}const{checkoutOptions:n}=e._getPaymentBreakdown();if(e._isBalanceFullyCoveringAmount()){re(e);try{const c=await Ye(e.apiUrl,e._getApiConfig(),e.deviceId,e.selectedPaymentMethod,n);await ut(e);const d=(c==null?void 0:c.id)??((o=c==null?void 0:c.data)==null?void 0:o.id);return d&&le(e,String(d)),c}catch(c){throw j(e),e.config.onError({attributes:{message:e._resolveErrorMessage(c)}}),c}}if(e.selectedPaymentMethod.type==="new_card"){await ln(e,n);return}if(e.selectedPaymentMethod.type==="apple_pay"){await dn(e,n);return}if(e.selectedPaymentMethod.type==="google_pay"){await hn(e,n);return}re(e);try{const c=await Ye(e.apiUrl,e._getApiConfig(),e.deviceId,e.selectedPaymentMethod,n);await ut(e);const d=(c==null?void 0:c.id)??((s=c==null?void 0:c.data)==null?void 0:s.id);if(d&&le(e,String(d)),((i=e.selectedPaymentMethod)==null?void 0:i.type)==="kaspi_pay"){const g=(c==null?void 0:c.attributes)||((u=c==null?void 0:c.data)==null?void 0:u.attributes)||{},C=g.action_link||g.action_url,S=g.action_url_type||g.action_type||"redirect";if(C)return typeof e.config.onKaspiLink=="function"?(e.config.onKaspiLink({action_link:C,action_url:C,action_type:S,event:c}),c):(window.location.href=C,c)}return c}catch(c){throw j(e),e.config.onError({message:e._resolveErrorMessage(c)}),c}}async function ut(e){var n,o;if(!(((n=e.selectedPaymentMethod)==null?void 0:n.type)!=="card"||!((o=e.selectedPaymentMethod)!=null&&o.cardId)))try{await Ot(e.apiUrl,e._getApiConfig(),e.selectedPaymentMethod.cardId)}catch(s){console.warn("Failed to mark selected card as default:",s)}}async function ln(e,n){re(e),e.waitingForNewCardAction=!0,e._setNewCardActionTimeout();try{await Nt(e.apiUrl,e._getApiConfig(),e.deviceId,n)}catch(o){e.waitingForNewCardAction=!1,e._clearNewCardActionTimeout(),j(e),e.config.onError({attributes:{message:e._resolveErrorMessage(o)}}),console.error("New card payment error:",o)}}async function dn(e,n){const o=window.ApplePaySession;if(!o||!o.canMakePayments()){e.config.onError({attributes:{message:e.t("errorApplePayUnsupported")}});return}const s={countryCode:e.config.currency==="GEL"?"GE":"KZ",currencyCode:e.config.currency,supportedNetworks:["visa","masterCard"],merchantCapabilities:["supports3DS"],total:{label:"Choco",amount:String(e._getPayableAmount()),type:"final"}},i=new o(3,s);i.onvalidatemerchant=async u=>{var c,d;try{const g=await Dt(e.apiUrl,e._getApiConfig(),u.validationURL),C=((d=(c=g==null?void 0:g.data)==null?void 0:c.attributes)==null?void 0:d.session)||g,S=JSON.parse(atob(C));i.completeMerchantValidation(S)}catch(g){console.error("Apple Pay session error:",g),i.abort(),e.config.onError({attributes:{message:e.t("errorApplePayInit")}})}},i.onpaymentauthorized=async u=>{var c;try{if(re(e),typeof e.config.onBeforeCheckout=="function"){const C=await e.config.onBeforeCheckout();C&&typeof C=="object"&&Object.assign(e.config,C)}const d=await Xt(e.apiUrl,e._getApiConfig(),e.deviceId,u.payment,n);i.completePayment(o.STATUS_SUCCESS);const g=(d==null?void 0:d.id)??((c=d==null?void 0:d.data)==null?void 0:c.id);g&&le(e,String(g))}catch(d){console.error("Apple Pay payment error:",d),i.completePayment(o.STATUS_FAILURE),j(e),e.config.onError({attributes:{message:e._resolveErrorMessage(d,"errorApplePayPayment")}})}},i.oncancel=()=>e.config.onCancel(),i.begin()}async function hn(e,n){var P,k,w,L,O,F;try{await e._loadGooglePaySdk()}catch(M){console.error("Google Pay SDK load error:",M),e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}const o=window.google;if(!(o!=null&&o.payments)){e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}const s=(P=e.checkoutContext)==null?void 0:P.data,i=((w=(k=s==null?void 0:s.payment_methods)==null?void 0:k.data)==null?void 0:w.attributes)||{},u=i.google_pay_settings||{};if(!(i.payment_method_google_pay==="enabled"||i.payment_method_google_pay===!0)){e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}const d=u==null?void 0:u.gateway,g=u==null?void 0:u.merchant_id;if(!d||!g){e.config.onError({attributes:{message:e.t("errorGooglePaySettingsUnavailable")}});return}const C=e.config.environment==="production",S=(u==null?void 0:u.merchant_name)||"Choco",T=u==null?void 0:u.google_merchant_id;if(C&&!T){e.config.onError({attributes:{message:e.t("errorGooglePaySettingsUnavailable")}});return}const v=Number(e._getCheckoutAmount()).toFixed(2),Q=new o.payments.api.PaymentsClient({environment:C?"PRODUCTION":"TEST"}),_=[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["VISA","MASTERCARD"],billingAddressRequired:!1},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:d,gatewayMerchantId:g}}}],m={apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:_,transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Итого",totalPrice:v,currencyCode:e.config.currency,countryCode:e.config.currency==="GEL"?"GE":"KZ"},merchantInfo:C?{merchantId:T,merchantName:S}:{merchantName:S}};console.log("paymentDataRequest",m);try{const M=await Q.isReadyToPay({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:_});if(!(M!=null&&M.result)){e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}re(e);const J=await Q.loadPaymentData(m),x=(O=(L=J==null?void 0:J.paymentMethodData)==null?void 0:L.tokenizationData)==null?void 0:O.token;if(!x)throw new Error(e.t("errorGooglePayPayment"));const q=JSON.parse(x),N=await Ut(e.apiUrl,e._getApiConfig(),e.deviceId,q,n),b=(N==null?void 0:N.id)??((F=N==null?void 0:N.data)==null?void 0:F.id);b&&le(e,String(b))}catch(M){j(e),M.statusCode==="CANCELED"?e.config.onCancel():(e.config.onError({attributes:{message:e._resolveErrorMessage(M,"errorGooglePayPayment")}}),console.error("Google Pay error:",M))}}function fn(e){var u,c,d,g,C,S,T,v,Q,_;const n=e.container;(u=n.querySelector('[data-action="pay"]'))==null||u.addEventListener("click",()=>e.handlePayment()),(c=n.querySelector('[data-action="change-method"]'))==null||c.addEventListener("click",()=>rt(e)),n.querySelectorAll('[data-action="close"]').forEach(m=>m.addEventListener("click",()=>e.close())),(d=n.querySelector('[data-action="close-sheet"]'))==null||d.addEventListener("click",()=>{e._pendingDeleteMethod?Se(e):W(e)}),(g=n.querySelector('[data-action="edit-sheet"]'))==null||g.addEventListener("click",()=>{e.isPaymentSheetEditMode=!0,Ae(e),ue(e)}),(C=n.querySelector('[data-action="previous-sheet"]'))==null||C.addEventListener("click",()=>{e.isPaymentSheetEditMode=!1,Ae(e),ue(e)}),(S=n.querySelector('[data-action="close-add-card"]'))==null||S.addEventListener("click",()=>oe(e)),(T=n.querySelector('[data-action="confirm-delete-cancel"]'))==null||T.addEventListener("click",()=>Se(e)),(v=n.querySelector('[data-action="confirm-delete-submit"]'))==null||v.addEventListener("click",()=>{if(e._pendingDeleteMethod){const m=e._pendingDeleteMethod;Re(e,!0),cn(e,m).then(()=>W(e)).finally(()=>Re(e,!1))}}),n.querySelectorAll(".choco-widget-method-item").forEach(m=>{m.addEventListener("click",P=>{const k=JSON.parse(P.currentTarget.getAttribute("data-method")||"{}");st(e,k)})});const o=n.querySelector('[data-sheet="payment"]');o&&(o.addEventListener("click",m=>{m.target===o&&W(e)}),pn(e,o));const s=n.querySelector('[data-action="toggle-balance"]');s&&((Q=s.querySelector("input[type='checkbox']"))==null||Q.addEventListener("change",m=>{e.useBalance=m.target.checked,e._updatePayButtonAmount()}));const i=n.querySelector('[data-action="toggle-bonuses"]');i&&((_=i.querySelector("input[type='checkbox']"))==null||_.addEventListener("change",m=>{e.useBonuses=m.target.checked,e.config.onAppliedBonus(e.useBonuses),e._updatePayButtonAmount()})),document.removeEventListener("keydown",e._boundKeyDown),document.addEventListener("keydown",e._boundKeyDown),nt(e)}function gn(e,n){var o,s;e.isOpen&&(n.key==="Escape"&&(n.preventDefault(),e._pendingDeleteMethod?Se(e):e.isAddCardViewOpen?oe(e):e.isPaymentSheetOpen?W(e):e.close()),n.key==="Enter"&&((s=(o=n.target)==null?void 0:o.dataset)==null?void 0:s.action)==="pay"&&(n.preventDefault(),e.handlePayment()))}function pn(e,n){const o=n.querySelector('[data-action="sheet-drag-handle"]'),s=n.querySelector(".choco-widget-sheet-content");if(!o||!s)return;const i=80;let u=0,c=0;const d=C=>{c=C.clientY;const S=Math.max(0,c-u);s.style.transform=`translateY(${S}px)`},g=C=>{o.releasePointerCapture(C.pointerId),o.removeEventListener("pointermove",d),o.removeEventListener("pointerup",g),o.removeEventListener("pointercancel",g);const S=Math.max(0,c-u);if(s.classList.remove("choco-widget-sheet-content--dragging"),S>=i){s.style.transform="translateY(100%)";const T=()=>{s.removeEventListener("transitionend",T),s.style.transform="",W(e)};s.addEventListener("transitionend",T)}else s.style.transform=""};o.addEventListener("pointerdown",C=>{!e.isPaymentSheetOpen||C.button!==0||(C.preventDefault(),u=C.clientY,c=C.clientY,s.classList.add("choco-widget-sheet-content--dragging"),o.setPointerCapture(C.pointerId),o.addEventListener("pointermove",d),o.addEventListener("pointerup",g),o.addEventListener("pointercancel",g))})}class te{static _getAuthStorageValue(n){return We(n)}static _setAuthStorageValue(n,o){_e(n,o)}static _removeAuthStorageValue(n){be(n)}static async logout(){Ge()}constructor(n){this.config=Ht(n),this.accessToken=null,this.deviceId=Fe(),this.apiUrl=yt(this.config.environment),this.translations=ae,this.checkoutContext=null,this.centrifuge=null,this.selectedPaymentMethod=null,this.container=null,this.isOpen=!1,this.isPaymentSheetOpen=!1,this.isPaymentSheetEditMode=!1,this.loading=!1,this.disabled=!1,this.paymentMethodDisabled=!1,this.useBalance=!1,this.useBonuses=!1,this.addCardActionUrl=null,this.isAddCardViewOpen=!1,this.waitingForNewCardAction=!1,this.newCardActionRequiredTimeoutId=null,this._googlePayScriptPromise=null,this._googlePayButtonRenderVersion=0,this._orderStatusPollingId=null,this._orderStatusResolved=!1,this._pendingDeleteMethod=null,this._pendingSuccessPayload=null,this._lifecycleListenersAttached=!1,this._boundAddCardMessage=null,this._boundKeyDown=o=>gn(this,o),this._boundVisibilityChange=()=>this._onVisibilityChange(),this._boundWindowFocus=()=>this._onWindowFocus(),this._boundPageShow=()=>this._onPageShow()}t(n,o={}){var u;const s=this.config.locale||"ru",i=((u=this.translations[s])==null?void 0:u[n])||this.translations.ru[n];return typeof i!="string"?n:i.replace(/{(\w+)}/g,(c,d)=>Object.prototype.hasOwnProperty.call(o,d)?String(o[d]):c)}_resolveErrorMessage(n,o="paymentError"){return(n==null?void 0:n.message)||this.t(o)}_getApiConfig(){return{...this.config,accessToken:this.accessToken}}_isInteractionBlocked(){return this.disabled||this.loading}_getBalanceAmount(){var i,u,c,d;const n=(d=(c=(u=(i=this.checkoutContext)==null?void 0:i.data)==null?void 0:u.balance)==null?void 0:c.data)==null?void 0:d.money,o=this.config.currency||"KZT",s=Number(n==null?void 0:n[o]);return Number.isFinite(s)&&s>0?s:0}_getBonusesAmount(){var o;const n=Number((o=this.config.bonuses)==null?void 0:o.amount);return Number.isFinite(n)&&n>0?n:0}_getBonusesPercent(){var o;const n=Number((o=this.config.bonuses)==null?void 0:o.percent);return!Number.isFinite(n)||n<=0?0:n>=100?100:n}_getAvailableBonus(){var o;const n=Number((o=this.config.bonuses)==null?void 0:o.availableBonus);return Number.isFinite(n)&&n>0?n:0}_getPaymentBreakdown(){const n=this.config.amount,o=this._getBalanceAmount(),s=this.useBalance?Math.min(o,n):0,i=n-s,u=this.useBalance&&s>=n,c=this.useBonuses?this._getAvailableBonus():0,d=Math.max(i-c,0),g=this.useBalance?n:d,C=this.useBalance&&!u;return{payableAmount:d,checkoutOptions:{checkoutAmount:g,forceBalanceMethod:u,useBalance:C}}}_getPayableAmount(){return this._getPaymentBreakdown().payableAmount}_isBalanceFullyCoveringAmount(){return this._getPaymentBreakdown().checkoutOptions.forceBalanceMethod}_getCheckoutAmount(){return this._getPaymentBreakdown().checkoutOptions.checkoutAmount??this.config.amount}_getPaymentMethodForUserEvent(){var n;return this._isBalanceFullyCoveringAmount()?"balance":((n=this.selectedPaymentMethod)==null?void 0:n.type)??null}_getKaspiOptions(){return{onlyKaspiAvailable:this.config.onlyKaspiAvailable,disableKaspi:this.config.disableKaspi}}_emitUserEvent(n,o={}){typeof this.config.onUserEvent=="function"&&this.config.onUserEvent({eventName:n,eventProperties:o})}_emitPaymentMethodSelected(n=this.selectedPaymentMethod){typeof this.config.onPaymentMethodSelected=="function"&&this.config.onPaymentMethodSelected(n||null)}_attachEventListeners(){fn(this)}_updatePayButtonAmount(){Qe(this)}_showAddCardView(){ot(this)}_closeAddCardView(){oe(this)}_setNewCardActionTimeout(){this._clearNewCardActionTimeout(),this.newCardActionRequiredTimeoutId=window.setTimeout(()=>{this.waitingForNewCardAction&&(this.waitingForNewCardAction=!1,j(this),this.config.onError({attributes:{message:this.t("errorNoServerResponseRetry")}})),this.newCardActionRequiredTimeoutId=null},6e4)}_clearNewCardActionTimeout(){this.newCardActionRequiredTimeoutId&&(window.clearTimeout(this.newCardActionRequiredTimeoutId),this.newCardActionRequiredTimeoutId=null)}_saveTokensToStorage(n,o){Le(n,o)}_clearAuthStorage(){Ge()}_getAuthStorageValue(n){return te._getAuthStorageValue(n)}_setAuthStorageValue(n,o){te._setAuthStorageValue(n,o)}_removeAuthStorageValue(n){te._removeAuthStorageValue(n)}_loadGooglePaySdk(){var n,o;return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Google Pay SDK requires browser environment")):(o=(n=window.google)==null?void 0:n.payments)!=null&&o.api?Promise.resolve():this._googlePayScriptPromise?this._googlePayScriptPromise:(this._googlePayScriptPromise=new Promise((s,i)=>{const u=document.querySelector('script[data-choco-google-pay-sdk="true"]');if(u){u.addEventListener("load",()=>s(),{once:!0}),u.addEventListener("error",()=>i(new Error("Failed to load Google Pay SDK")),{once:!0});return}const c=document.createElement("script");c.src="https://pay.google.com/gp/p/js/pay.js",c.async=!0,c.defer=!0,c.setAttribute("data-choco-google-pay-sdk","true"),c.onload=()=>s(),c.onerror=()=>i(new Error("Failed to load Google Pay SDK")),document.head.appendChild(c)}).finally(()=>{var s,i;(i=(s=window.google)==null?void 0:s.payments)!=null&&i.api||(this._googlePayScriptPromise=null)}),this._googlePayScriptPromise)}_attachLifecycleListeners(){this._lifecycleListenersAttached||(document.addEventListener("visibilitychange",this._boundVisibilityChange),window.addEventListener("focus",this._boundWindowFocus),window.addEventListener("pageshow",this._boundPageShow),this._lifecycleListenersAttached=!0)}_detachLifecycleListeners(){this._lifecycleListenersAttached&&(document.removeEventListener("visibilitychange",this._boundVisibilityChange),window.removeEventListener("focus",this._boundWindowFocus),window.removeEventListener("pageshow",this._boundPageShow),this._lifecycleListenersAttached=!1)}_onVisibilityChange(){Oe()||Me(this)}_onWindowFocus(){Me(this)}_onPageShow(){Me(this)}async _obtainTokenByRefreshOrTrackId(){await xt(this)}async _fetchCheckoutContextWithRetry(){try{this.checkoutContext=await Te(this.apiUrl,this._getApiConfig())}catch(n){if(n.status===401)this._removeAuthStorageValue("webPayToken"),await this._obtainTokenByRefreshOrTrackId(),this.checkoutContext=await Te(this.apiUrl,this._getApiConfig());else throw n}}_prerender(){en(this)}_render(){tn(this)}async init(){var n,o;try{if(this._prerender(),this._attachLifecycleListeners(),!this.config.clientId)return this.config.onError({attributes:{message:this.t("errorMissingTrackClient")}}),!1;if(this.accessToken=this._getAuthStorageValue("webPayToken"),!this.config.trackId&&!this.accessToken)return this.paymentMethodDisabled=!0,this._render(),!0;this.accessToken||await this._obtainTokenByRefreshOrTrackId();try{await this._fetchCheckoutContextWithRetry()}catch(i){const u=i;return this.config.onError({attributes:{message:u.message}}),!1}const s=je((o=(n=this.checkoutContext)==null?void 0:n.data)==null?void 0:o.socket_connections,i=>it(this,i));return s&&(this.centrifuge=s.centrifuge),this.selectedPaymentMethod=we(this.checkoutContext.data,this._getKaspiOptions()),this._emitPaymentMethodSelected(),this._render(),!0}catch(s){return console.error(`${this.t("errorWidgetInit")}:`,s),this.config.onError({attributes:{message:s.message}}),!1}}close(){this.config.onCancel()}destroy(){const n=document.getElementById("choco-one-click-widget");n&&(n.style.display="none"),this._clearNewCardActionTimeout(),ee(this),this._pendingSuccessPayload=null,this._detachLifecycleListeners(),this.isAddCardViewOpen&&oe(this),this.centrifuge&&(this.centrifuge.disconnect(),this.centrifuge=null),document.removeEventListener("keydown",this._boundKeyDown),this.container&&(this.container.classList.remove("choco-one-click-widget--visible"),setTimeout(()=>{var o;(o=this.container)==null||o.remove(),this.container=null},300)),this.isOpen=!1,this.isPaymentSheetOpen=!1,this.isAddCardViewOpen=!1,this.selectedPaymentMethod=null}getAvailablePaymentMethods(){var n;return(n=this.checkoutContext)!=null&&n.data?wt(this.checkoutContext.data,o=>this.t(o),this._getKaspiOptions()):[]}async createOrder(){return un(this)}async pay(){try{await this.createOrder()}catch(n){console.error(`${this.t("errorPaymentProcess")}:`,n)}}async handlePayment(){if(!this._isInteractionBlocked()){this._emitUserEvent("one_click_pay_cta_tapped",{payment_method:this._getPaymentMethodForUserEvent()});try{if(this.config.onConfirmPay){this.config.onConfirmPay(this.selectedPaymentMethod||null);return}await this.pay()}catch(n){console.error(`${this.t("errorPaymentProcess")}:`,n)}}}openPaymentSheet(){rt(this)}closePaymentSheet(){W(this)}async updateAmount(n){if(typeof n!="number"||!Number.isFinite(n)||n<0)throw new Error("amount must be a non-negative number");this.config.amount=n,Qe(this)}async updateAvailableBonus(n){if(typeof n!="number"||!Number.isFinite(n)||n<0)throw new Error("availableBonus must be a non-negative number");this.config.bonuses&&(this.config.bonuses.availableBonus=n),Qe(this)}async updateLocale(n){if(typeof n!="string"||!this.translations[n])throw new Error(`Unsupported locale: ${n}`);if(this.config.locale=n,!this.container)return;const o=this.isPaymentSheetOpen,s=this.isAddCardViewOpen;if(this._render(),$(this),o){const i=this.container.querySelector('[data-sheet="payment"]');i&&(i.classList.add("choco-widget-payment-sheet--open"),this.isPaymentSheetOpen=!0)}s&&ot(this)}async setLoading(n){this.loading=!!n,$(this)}async setDisabled(n){this.disabled=!!n,$(this)}async setPreorderId(n){this.config.preorderId=n}async setMerchantOrderId(n){this.config.merchantOrderId=n}async logout(){await te.logout(),this.accessToken=null}async updateTrackId(n){var o,s;if(this.config.trackId=n,!this.config.clientId)return this.config.onError({attributes:{message:this.t("errorMissingTrackClient")}}),!1;try{this._prerender(),await this._obtainTokenByRefreshOrTrackId();try{await this._fetchCheckoutContextWithRetry()}catch(u){const c=u;return this.config.onError({attributes:{message:c.message}}),!1}this.centrifuge&&(this.centrifuge.disconnect(),this.centrifuge=null);const i=je((s=(o=this.checkoutContext)==null?void 0:o.data)==null?void 0:s.socket_connections,u=>it(this,u));return i&&(this.centrifuge=i.centrifuge),this.selectedPaymentMethod=we(this.checkoutContext.data,this._getKaspiOptions()),this._emitPaymentMethodSelected(),this.paymentMethodDisabled=!1,this._render(),!0}catch(i){return console.error(`${this.t("errorWidgetInit")}:`,i),this.config.onError({attributes:{message:i.message}}),!1}}async onConfirmPay(n){if(typeof n!="function")throw new Error("onConfirmPay callback must be a function");this.config.onConfirmPay=n}async onPaymentMethodSelected(n){if(typeof n!="function")throw new Error("onPaymentMethodSelected callback must be a function");this.config.onPaymentMethodSelected=n,this._emitPaymentMethodSelected()}async onKaspiLink(n){if(typeof n!="function")throw new Error("onKaspiLink callback must be a function");this.config.onKaspiLink=n}async onUserEvent(n){if(typeof n!="function")throw new Error("onUserEvent callback must be a function");this.config.onUserEvent=n}async onAppliedBonus(n){if(typeof n!="function")throw new Error("onAppliedBonus callback must be a function");this.config.onAppliedBonus=n}}return typeof window<"u"&&(window.ChocoOneClickWidget=te),te}));
|