PageSourceSearch

https://webook.com/assets/@wbk/payment-cL5x8D1N.js

js webook.com collected 2026-10-03 20:46:01 UTC 72,437 bytes, 7 lines download raw bytes

1import{r as b}from"../vendor-Cc9w-i99.js";import{u as Je,l as Ze,j as e,L as et,E as Q,H as tt,M as le}from"./hooks-FtCTMeyH.js";import{p as nt,F as at,A as st,G as rt,H as ot,I as it,J as lt,K as Re,L as ct,M as Ae,N as dt}from"./queue-8-09eRJS.js";import{u as ne,b as mt,C as N,a as ce}from"./currency-BxlCDaIM.js";import{E as he}from"./logger-DfNVpG3P.js";import{B as I,t as B,P as H,T as p,h as Te,S as ut,i as pt,j as yt,k as ht,R as Ie,l as Fe,I as L,O as Oe,D as ee,m as _t}from"./ui-DZdD23Ta.js";import{N as ve,O as je,Q as xt,w as ft,V as bt,R as vt,T as jt,Y as gt,Z as wt,_ as xe,$ as Nt,a0 as kt,a1 as qe,a2 as De,S as Pt,j as ge,m as K,a3 as fe,a4 as St,a5 as Ct,a6 as Mt,C as Et,a7 as be,a as $e,E as de,u as Rt,D as At}from"./svg-Bua7FxzL.js";import{b as R,l as Y,a as G,T as ae}from"./config-DuwrGB8a.js";import{OtpCheckPoint as Tt,useAuth as ue}from"./auth-Djoddyo0.js";import{u as we}from"./analytics-B-_ZPhJq.js";import{u as pe,C as te}from"../react-hook-form-D_m77UuM.js";var _a=5e5,It=Object.defineProperty,Ft=Object.defineProperties,Ot=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,Se=(t,n,s)=>n in t?It(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,v=(t,n)=>{for(var s in n||(n={}))We.call(n,s)&&Se(t,s,n[s]);if(me)for(var s of me(n))ze.call(n,s)&&Se(t,s,n[s]);return t},w=(t,n)=>Ft(t,Ot(n)),Be=(t,n)=>{var s={};for(var a in t)We.call(t,a)&&n.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&me)for(var a of me(t))n.indexOf(a)<0&&ze.call(t,a)&&(s[a]=t[a]);return s},$=(t,n,s)=>new Promise((a,r)=>{var o=c=>{try{i(s.next(c))}catch(u){r(u)}},l=c=>{try{i(s.throw(c))}catch(u){r(u)}},i=c=>c.done?a(c.value):Promise.resolve(c.value).then(o,l);i((s=s.apply(t,n)).next())}),qt=class{constructor(){this._config=null}get config(){return this._config}init(t){this._config=t}update(t){this._config=v(v({},this._config),t)}},Ce=new qt,Ne=(t,n,s="SAR")=>{const a=n.find(r=>r.conversionName===s);return a?a.conversionValue*t:0},Dt=(t,n,s="SAR")=>{const a=n.find(r=>r.conversionName===s);return a?+(t/a.conversionValue).toFixed(2):0},$t=({total:t,conversions:n,balance:s=0,userCurrency:a})=>{const r=Dt(t,n,a);return{orderPoints:r,maxRedeemable:Math.min(s,r),balanceValue:Ne(s,n,a),hasNoBalance:s<=0}},Ve=b.createContext(null),Z={coupon:{discount:0,ticket_ids:[],promo_code:""},saudi_redeem:null,saudi_redeem_total:0,enable_wallet_credits:!1,qitaf:null,mokafaa:null},Le=b.createContext(w(v({},Z),{setCoupon:()=>{},setSaudiRedeem:()=>{},setRedeemType:()=>{},setSelectedTickets:()=>{},setQitaf:()=>{},setMokafaa:()=>{}})),Wt=({children:t,locale:n,supportedCountryCode:s})=>{const[a,r]=b.useState(Z),{currency:o}=ne(),{data:l,isLoading:i}=st({lang:n,currency:o.shortCode,country:s}),c=_=>{r(x=>w(v({},x),{coupon:_}))},u=_=>{r(x=>w(v({},x),{redeem_type:_,coupon:x.redeem_type==="coupon"&&!_?Z.coupon:x.coupon,qitaf:Z.qitaf,mokafaa:x.mokafaa,saudi_redeem:x.saudi_redeem?w(v({},x.saudi_redeem),{quantity:x.redeem_type==="saudi_rewards"&&!_?0:x.saudi_redeem.quantity}):Z.saudi_redeem,enable_wallet_credits:_==="wallet"}))},d=_=>{r(x=>w(v({},x),{saudi_redeem:_}))},m=_=>{const x=_==null?void 0:_.reduce((k,j)=>(k[j._id]=(k[j._id]||0)+j.qty,k),{});r(k=>w(v({},k),{selectedTickets:x}))},y=_=>{r(x=>w(v({},x),{qitaf:_}))},f=_=>{r(x=>w(v({},x),{mokafaa:_}))},h=b.useMemo(()=>a.saudi_redeem?Ne(a.saudi_redeem.quantity,a.saudi_redeem.productConversion,l==null?void 0:l.currency):0,[a.saudi_redeem,l==null?void 0:l.currency]);return e.jsx(Le.Provider,{value:w(v({},a),{walletData:{currency:(l==null?void 0:l.currency)||"",total_balance:(l==null?void 0:l.total_balance)||0,loading:i},saudi_redeem_total:h,setCoupon:c,setRedeemType:u,setSaudiRedeem:d,setSelectedTickets:m,setQitaf:y,setMokafaa:f}),children:t})},zt=Wt,xa=t=>{var n=t,{children:s}=n,a=Be(n,["children"]),r,o,l,i,c,u;const{isIOS:d,isMac:m,isAndroid:y,isDesktop:f}=Je(),[h,_]=b.useState(w(v({},a),{isApplePayEnabled:(r=a.isApplePayEnabled)!=null?r:!0,isCouponEnabled:(o=a.isCouponEnabled)!=null?o:!0,isWalletEnabled:(l=a.isWalletEnabled)!=null?l:!0,paymentMethods:{}})),{data:x}=nt({lang:a.locale},{enabled:!a.user}),k=(i=a.user)!=null?i:x,{data:j,isLoading:C,error:M}=at({payable_id:a.payable.id||((c=Ce.config)==null?void 0:c.organizationId)||"",payable_type:a.payable.type,lang:a.locale,enable_payment_methods:a.event.enable_payment_methods},{enabled:!!a.event._id});b.useEffect(()=>{!d&&!m||Ze({id:"apple-pay-js",url:"https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",target:"head"}).finally(()=>{const S=(d||m)&&typeof window.ApplePaySession<"u"&&window.ApplePaySession.canMakePayments(),E=!a.isSeason&&h.isApplePayEnabled&&S;_(W=>w(v({},W),{canUseApplePay:E}))})},[h.isApplePayEnabled,d,m,a.isSeason]),b.useEffect(()=>{_(S=>w(v({},S),{canUseGooglePay:(y||f)&&h.isGooglePayEnabled}))},[y,f,h.isGooglePayEnabled]);const T=S=>{_(E=>w(v({},E),{paymentMethod:S}))},P=S=>{_(E=>w(v({},E),{isSubscriptionCreditsEnabled:S}))};return e.jsx(Ve.Provider,{value:w(v({},h),{user:k,locale:a.locale,checkoutFlowKey:(u=Ce.config)==null?void 0:u.checkoutFlowKey,isValid:!!h.paymentMethod,setPaymentMethod:T,setSubscriptionCreditsEnabled:P,paymentMethods:{methods:j,isLoading:C,errorMessage:M==null?void 0:M.message}}),children:e.jsx(zt,{locale:a.locale,supportedCountryCode:a.supportedCountryCode,children:s})})};function F(){const t=b.useContext(Ve);if(!t)throw new Error("usePayment must be used within an WbkPaymentProvider");return t}function O(){return b.useContext(Le)}var fa=({paytabs:t,applePay:n}={})=>{var s;const a=F(),r=O(),{mutateAsync:o,error:l}=rt(),{mutateAsync:i,error:c}=ot(),u=a.user,d=a.locale,m=a.currency||"SAR",y=((s=a.paymentMethod)==null?void 0:s.currency)||m,{data:f}=mt({currency:m.toLowerCase()}),_=(f||{})[y.toLowerCase()]||1;if(b.useEffect(()=>{t&&(a.paytabs=t)},[n,a,t]),!a||!r)throw new Error("usePayment must be used within an WbkPaymentProvider, refer to usage instructions: https://github.com/nadude/webook-frontend/blob/main/packages/payment/README.md");const x=k=>$(null,[k],function*({totals:j,resell:C}){var M,T;if(!n)throw new he({error:new Error("Apple Pay is not enabled, missing applePay config"),name:"ApplePayNotEnabledException"});const P=a.event,S=((T=(M=a.paymentMethod)==null?void 0:M.payment_method)==null?void 0:T.supported_networks)||["mada","visa","masterCard","amex","discover"];let E=j.net_after_discount;y!==m&&(E=E*_);const V={countryCode:(P==null?void 0:P.venue_country)||y.slice(0,2),currencyCode:y,merchantCapabilities:["supports3DS"],supportedNetworks:S,total:{label:`webook.com - ${P.title}`,amount:E.toFixed(2)}},q=new ApplePaySession(3,V);q.onvalidatemerchant=A=>$(null,null,function*(){var g;try{const D=yield o({event_id:P._id,validationUrl:A.validationURL,lang:d,email:u==null?void 0:u.email,entity_payment_method_id:(g=a.paymentMethod)==null?void 0:g.entity_payment_method_id,vertical:a.vertical});q.completeMerchantValidation(D)}catch{q.completePayment({status:ApplePaySession.STATUS_FAILURE}),n.onPaymentFailed()}}),q.onpaymentmethodselected=()=>{q.completePaymentMethodSelection({newTotal:V.total})},q.onpaymentauthorized=A=>$(null,null,function*(){try{const g=yield n.onPaymentAuthorized();if(!(g!=null&&g.payment_session_id)||!g.order_id)throw new he({error:new Error("Apple Pay Checkout v2 Did Not Return Payment Session ID"),name:"ApplePayCheckoutNoSessionIdException"});const D=j.net_after_discount*_,z=yield i({lang:d,order_id:g.order_id,payment_session_id:g.payment_session_id,apple_pay_token:A.payment.token,email:u==null?void 0:u.email,amount_sar:D,resell:C});if(!(z!=null&&z.order_id))throw new he({error:new Error("Apple Pay Checkout Proceed Did Not Return Order ID"),name:"ApplePayCheckoutProceedNoOrderIdException"});q.completePayment({status:ApplePaySession.STATUS_SUCCESS}),n.onPaymentSuccess(z)}catch{q.completePayment({status:ApplePaySession.STATUS_FAILURE}),n.onPaymentFailed()}}),q.begin()});return w(v(v({},a),r),{onApplePayPayment:x,error:l||c})},Bt=t=>{var n;const{paymentMethod:s}=F(),a=(t==null?void 0:t.card_used)===!0&&(t==null?void 0:t.name)!=null&&(t==null?void 0:t.discount_percentage)!=null?{name:t.name,card_ending:(n=t.card_ending)!=null?n:void 0,discount_percentage:t.discount_percentage}:void 0,r=!!a&&(s==null?void 0:s.type)==="credit_card";return{cardDiscountLimit:a,cardDiscountCapped:r}},ba=Bt,Vt=()=>{var t;const{event:n,isSeason:s,locale:a}=F(),{coupon:r,setCoupon:o,selectedTickets:l,saudi_redeem:i}=O(),{trackEvent:c}=we(),{mutateAsync:u,isPending:d,error:m}=it(),[y,f]=b.useState(r.promo_code),h=()=>$(null,null,function*(){if(y)try{const x=yield u(w(v({},s?{season_id:n==null?void 0:n._id}:{event_id:n==null?void 0:n._id}),{promo_code:y,ticket_ids:l?Object.keys(l):[],ticket_counts:l,locale:a,saudi_rewards:i==null?void 0:i.memberVerificationToken}));o(w(v({},x),{promo_code:y})),c({event:"promo_code_verified",data:{slug:n.slug,booking_type:n.contentful_entity_type}})}catch{}}),_=()=>{o({discount:0,promo_code:"",ticket_ids:[]})};return{promoCode:y,setPromoCode:f,isApplied:!!r.promo_code,appliedCode:r.promo_code,hasDiscountedTickets:((t=r.ticket_ids)==null?void 0:t.length)>0,isPending:d,error:m,canApply:!!(y!=null&&y.trim()),apply:h,remove:_}},Lt=Vt,Ut=[{label:"saudi_rewards",value:"saudi_rewards"},{label:"promo_code",value:"coupon"},{label:"qitaf",value:"qitaf"},{label:"mokafaa",value:"mokafaa"}
1],Qt=({isQitafEnabled:t,isSaudiRewardsEnabled:n,isMokafaaEnabled:s})=>Ut.filter(a=>a.value==="coupon"||a.value==="qitaf"&&t||a.value==="saudi_rewards"&&n||a.value==="mokafaa"&&s),Gt=({isWalletEnabled:t,balance:n,walletCurrency:s,eventCurrency:a,isSeason:r,couponDiscount:o,saudiRewardsQuantity:l})=>{const i=!!o||!!l,c=s===a;return{isSameCurrency:c,conflictingDiscount:i,visible:!!t&&c,enabled:!!t&&n>0&&!r&&!i}},Xt=()=>{const{isQitafEnabled:t,isSaudiRewardsEnabled:n,isMokafaaEnabled:s,isSubscriptionCreditsEnabled:a,event:r,user:o}=F(),{redeem_type:l,setRedeemType:i}=O(),{trackEvent:c}=we();return b.useEffect(()=>{o!=null&&o.saudi_reward_linked&&(o!=null&&o.saudi_reward_member_id)&&n&&i("saudi_rewards")},[o]),{options:b.useMemo(()=>Qt({isQitafEnabled:t,isSaudiRewardsEnabled:n,isMokafaaEnabled:s}),[t,n,s]),activeType:l,hidden:!!a,select:m=>{m==="saudi_rewards"&&c({event:"saudi_rewards_booking_clicked",data:{slug:r.slug,booking_type:r.contentful_entity_type}}),i(m===l?void 0:m)}}},Kt=Xt,Ht=t=>{const{currency:n}=F(),{saudi_redeem:s,saudi_redeem_total:a,setSaudiRedeem:r,walletData:o}=O(),l=(s==null?void 0:s.productConversion)||[],{orderPoints:i,maxRedeemable:c,balanceValue:u,hasNoBalance:d}=$t({total:t,conversions:l,balance:s==null?void 0:s.productBalance,userCurrency:o==null?void 0:o.currency});return{isVerified:!!s,memberId:s==null?void 0:s.memberId,balance:(s==null?void 0:s.productBalance)||0,balanceValue:u,hasNoBalance:d,redeemedPoints:(s==null?void 0:s.quantity)||0,redeemedValue:a,isRedeemed:((s==null?void 0:s.quantity)||0)>0,maxRedeemable:c,currency:n,walletCurrency:o==null?void 0:o.currency,valueOf:m=>Ne(m,l,o==null?void 0:o.currency),redeem:m=>s&&r(w(v({},s),{quantity:Math.min(m,i)})),clearPoints:()=>s&&r(w(v({},s),{quantity:0})),changeMember:()=>r(null)}},Ue=Ht,Yt=(t,{hasEventFees:n,hasSaudiRewards:s,isSubscriptionCreditsEnabled:a}={})=>{var r,o;const l=[{key:"subtotal",amount:t.gross}],i=(c,u=!0)=>{u&&c.amount&&l.push(c)};return i({key:"resell_fees",amount:t.resale_comission||0}),i({key:"tabby_fee",amount:t.tabby_fee||0}),i({key:"marketing",amount:((r=t.marketing)==null?void 0:r.fee)||0,label:(o=t.marketing)==null?void 0:o.title}),i({key:"discount",amount:t.discount_total||0,isCredit:!0}),i({key:"fees",amount:t.totalFee||0},n),i({key:"ticket_protection_fees",amount:t.refund_guarantee_fee||0}),i({key:"whatsapp_reminders_fees",amount:t.whatsapp_reminder_fee||0}),i({key:"vat",amount:t.vat||0}),i({key:"shipping_fee",amount:t.shipping_totals||0}),i({key:"saudi_rewards",amount:t.withdrawn_saudi_rewards||0,isCredit:!0},s),i({key:"security_deposit",amount:t.security_deposit||0,isCredit:!0}),i({key:"streaming_credits",amount:t.withdrawn_subscription_credits||0,isCredit:!0},a),l},Jt=(t,n)=>t>0&&!!n,Zt=t=>{const{event:n,currency:s="SAR",isSubscriptionCreditsEnabled:a}=F(),{coupon:r,saudi_redeem:o,enable_wallet_credits:l,mokafaa:i}=O(),{currency:c,active:u}=ne(),[d,m]=b.useState(!1),y=Jt(r.discount,t.discount_total);return{eventCurrency:s,lines:Yt(t,{hasEventFees:!!n.fees,hasSaudiRewards:!!(o!=null&&o.quantity),isSubscriptionCreditsEnabled:a}),hasCouponDiscount:y,promoCode:r.promo_code,redeemedPoints:o==null?void 0:o.quantity,showWalletCredit:!!l&&!!t.withdrawn_wallet_credits,mokafaa:i,showSaudiRewards:!!(o!=null&&o.quantity)&&!!t.withdrawn_saudi_rewards,showSubscriptionCredits:!!a&&!!t.withdrawn_subscription_credits,eventFees:n.fees,vatPercent:n==null?void 0:n.vat_percent,showOrganizerCurrency:!!u&&s!==c.shortCode,expanded:d,toggleExpanded:()=>m(f=>!f)}},en=Zt,tn=({withOtp:t=!0,alreadyOtpValidated:n}={})=>{const{enable_wallet_credits:s,walletData:a,setRedeemType:r,coupon:o,saudi_redeem:l,redeem_type:i}=O(),{isWalletEnabled:c,currency:u,isSubscriptionCreditsEnabled:d,isSeason:m}=F(),{currency:y}=ne(),[f,h]=b.useState(!1),_=(a==null?void 0:a.total_balance)||0,x=Gt({isWalletEnabled:c&&!!y.wallet_enabled,balance:_,walletCurrency:a==null?void 0:a.currency,eventCurrency:u,isSeason:m,couponDiscount:o.discount,saudiRewardsQuantity:l==null?void 0:l.quantity});b.useEffect(()=>{s&&d&&r(void 0)},[d,s]),b.useEffect(()=>{s&&!y.wallet_enabled&&r(void 0)},[y.wallet_enabled,s]);const k=j=>j&&t&&!n?(h(!0),!1):(r(j?"wallet":void 0),!0);return{isOn:i==="wallet",balance:_,walletCurrency:a==null?void 0:a.currency,eventCurrency:u,isLoading:!!(a!=null&&a.loading),hidden:!x.visible||!a,disabled:!x.enabled,otpRequired:f,dismissOtp:()=>h(!1),toggle:k,confirm:()=>{r("wallet"),h(!1)}}},nn=tn,an=(t,n)=>t?t.filter(s=>{switch(s.type){case"apple_pay":return n.isApplePayEnabled&&n.applePayAllowed&&n.canUseApplePay;case"benefit":return n.isBenefitPayEnabled;case"stc":return n.isStcPayEnabled;case"tabby":return n.isTabbyEnabled&&n.tabbyAllowed;case"wafacash":return n.isWafacashEnabled;case"multibanco":return n.isMultibancoEnabled;case"mbways":return n.isMbwaysEnabled;case"googlepay":return n.isGooglePayEnabled&&n.applePayAllowed&&n.canUseGooglePay;default:return!0}}):[],sn=t=>t.find(n=>n.is_default)||t[0],rn=(t,n)=>{var s;return(s=t==null?void 0:t.is_native)!=null?s:!!n},on=(t,n)=>!!n.is_native_payment_enabled||!!n.enable_payment_methods&&!!(t!=null&&t.some(s=>s.is_native)),Qe=({total:t,minOrderLimit:n,isTabbyEnabled:s})=>{const a=Number(n),r=!!a&&t<a;return{minAmount:a,belowMinimum:r,meetsMinimum:!!a&&t>=a,canPay:!!s&&!r,instalment:t/4}},ln=({total:t,applePayAllowed:n,tabbyAllowed:s})=>{const{event:a,paymentMethod:r,setPaymentMethod:o,paymentMethods:{methods:l,isLoading:i,errorMessage:c},isApplePayEnabled:u,canUseApplePay:d,isBenefitPayEnabled:m,isStcPayEnabled:y,isTabbyEnabled:f,isMultibancoEnabled:h,isMbwaysEnabled:_,isWafacashEnabled:x,isGooglePayEnabled:k,canUseGooglePay:j}=F(),{enable_wallet_credits:C}=O(),M=b.useMemo(()=>an(l,{isApplePayEnabled:u,canUseApplePay:d,applePayAllowed:n,isGooglePayEnabled:k,canUseGooglePay:j,isBenefitPayEnabled:m,isStcPayEnabled:y,isTabbyEnabled:f,tabbyAllowed:s,isWafacashEnabled:x,isMultibancoEnabled:h,isMbwaysEnabled:_}),[l,u,n,d,m,y,f,s,x,h,_,k,j]);b.useEffect(()=>{if(on(M,a)){if(r!=null&&r.type)return;o(void 0);return}if(!M.length){o(void 0);return}const P=sn(M);r||o(P),!n&&(r==null?void 0:r.type)==="apple_pay"&&o(P)},[M,n]);const T=Qe({total:t,minOrderLimit:a==null?void 0:a.tabby_min_order_limit,isTabbyEnabled:f});return{availableMethods:M,selectedMethod:r,isLoading:i,errorMessage:c,paymentDisabled:!!C&&t<=0,isMethodDisabled:P=>P==="tabby"&&!T.meetsMinimum,isNative:P=>rn(P,a.is_native_payment_enabled),select:P=>o(l==null?void 0:l.find(S=>S._id===P)),findMethod:P=>l==null?void 0:l.find(S=>S._id===P),setPaymentMethod:o}},cn=ln,dn=t=>{const{currency:n,event:s,isTabbyEnabled:a,paymentMethod:r,setPaymentMethod:o,paymentMethods:{methods:l}}=F(),i=Qe({total:t,minOrderLimit:s==null?void 0:s.tabby_min_order_limit,isTabbyEnabled:a});return b.useEffect(()=>
1{(r==null?void 0:r.type)==="tabby"&&!i.canPay&&o(l==null?void 0:l.find(c=>c.type==="credit_card"))},[i.canPay,l,r==null?void 0:r.type]),w(v({},i),{currency:n,total:t})},mn=dn,un=t=>{var n=t,{totals:s,className:a,currency:r}=n,o=Be(n,["totals","className","currency"]);const{paymentMethod:l,isValid:i}=F(),{t:c}=R(["payment_common"]),u=!i&&s.net_after_discount>0;return(l==null?void 0:l.type)==="apple_pay"&&s.net_after_discount>0?e.jsxs(I,w(v({theme:"action",type:"submit",disabled:u,form:"ticket-checkout-form",id:"proceed-to-payment",className:B("w-full items-center gap-0 py-3 font-semibold leading-none","data-[disabled=true]:!bg-input-disabled data-[disabled=true]:!text-text-disabled",a)},o),{children:[c("payment_common:pay_with"),e.jsx(ve,{className:"h-12 w-12"})]})):e.jsx(I,w(v({className:B("group w-full gap-2 py-3 text-center font-semibold data-[benefit=true]:enabled:bg-[#ED0E34] data-[stc=true]:enabled:bg-[#4F008F]","data-[disabled=true]:!bg-input-disabled data-[disabled=true]:!text-text-disabled",a),form:"ticket-checkout-form",type:"submit",id:"proceed-to-payment","data-testid":"ticketing_summary_proceed_to_payment","data-benefit":(l==null?void 0:l.type)==="benefit","data-stc":(l==null?void 0:l.type)==="stc",disabled:u},o),{children:s.net_after_discount<=0?e.jsx("span",{className:"whitespace-nowrap",children:c("payment_common:confirm_booking")}):(l==null?void 0:l.type)==="benefit"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:"/@wbk/payment/benefit_pay.png",className:"xs:inline hidden h-5 w-5 shrink-0",alt:c("payment_common:benefit")}),e.jsxs("span",{className:"whitespace-nowrap",children:[c("payment_common:pay_with")," ",c("payment_common:benefit")]})]}):(l==null?void 0:l.type)==="stc"?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"xs:inline hidden h-8 w-8 shrink-0",white:!0}),e.jsxs("span",{className:"whitespace-nowrap",children:[c("payment_common:pay_with")," ",c("payment_common:stc_pay")]})]}):(l==null?void 0:l.type)==="wafacash"?e.jsx(e.Fragment,{children:e.jsx("span",{className:"whitespace-nowrap",children:c("payment_common:create_payment_code")})}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xt,{className:"h-4 w-4 pb-0.5 group-data-[disabled=true]:grayscale"}),e.jsx("span",{className:"whitespace-nowrap",children:c("payment_common:confirm_and_pay")}),e.jsx(N,{originalPrice:s.net_after_discount,currency:r,priceClassName:"font-semibold",zeroAsFree:!0})]})}))},va=un,pn=({className:t="",withOtp:n=!0,alreadyOtpValidated:s,onSuccess:a,onChange:r})=>{const{t:o}=R("payment_common"),{isOn:l,balance:i,eventCurrency:c,isLoading:u,hidden:d,disabled:m,otpRequired:y,dismissOtp:f,toggle:h,confirm:_}=nn({withOtp:n,alreadyOtpValidated:s}),{organizationName:x}=Y();return u?e.jsx("div",{className:"bg-body-level-1 rounded-M h-20 w-full animate-pulse"}):d?null:e.jsxs(e.Fragment,{children:[e.jsx(H,{className:t,children:e.jsxs("label",{className:B("space-between flex cursor-pointer items-center justify-between gap-2 rounded-xl",m&&"cursor-not-allowed opacity-50"),children:[e.jsx(ft,{className:"h-6 w-6"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:o("payment_common:use_webook_credits",{organizationName:x||"webook.com"})})," ",e.jsx(p,{as:"div",variant:"body-XS",color:"text-secondary",className:"flex items-center gap-1",children:m?o("payment_common:cannot_use_webook_credits"):e.jsxs(e.Fragment,{children:[o("payment_common:webook_credits_balance"),e.jsx(N,{originalPrice:i,currency:c,className:"[&_svg]:h-3 [&_svg]:w-3",priceClassName:"text-body-XS"})]})})]}),e.jsx(Te,{checked:l,onChange:k=>{h(k)&&(r==null||r(k))},disabled:m,hideErrorSpace:!0,groupClassName:"ltr:ml-auto rtl:mr-auto"})]})}),e.jsx(Tt,{show:y,type:"verify_wallet",onClose:f,onSuccess:(k,j)=>{_(),a==null||a(j)}})]})},yn=pn,hn=({className:t,supported:n,canUseApplePay:s,withTabby:a,logosOnly:r})=>{const{t:o}=R("payment_common"),l=b.useMemo(()=>{const i=n===void 0?["mada","visa","apple_pay","master_card","american_express","union_pay"]:n,c=[];return i!=null&&i.includes("visa")&&c.push(bt),i!=null&&i.includes("mada")&&c.push(vt),!s&&(i!=null&&i.includes("apple_pay"))&&c.push(ve),i!=null&&i.includes("master_card")&&c.push(jt),i!=null&&i.includes("stc")&&c.push(je),i!=null&&i.includes("american_express")&&c.push(gt),i!=null&&i.includes("cmi")&&c.push(wt),a?c.push(xe):i!=null&&i.includes("tabb
1y")&&c.push(xe),i!=null&&i.includes("tamara")&&c.push(Nt),i!=null&&i.includes("union_pay")&&c.push(kt),i!=null&&i.includes("multibanco")&&c.push(qe),i!=null&&i.includes("mbways")&&c.push(De),c},[s,n,a]);return r?l.map((i,c)=>e.jsx(i,{className:t},c)):e.jsxs("div",{className:B("space-y-1",t),children:[e.jsx("p",{className:"text-text-secondary px-2 text-center text-xs",children:o("payment_common:guaranteed_payment")}),e.jsx("div",{className:"-mt-2 flex w-full flex-wrap items-center justify-center gap-4 p-1 pb-3 pt-1.5",children:l.map((i,c)=>e.jsx(i,{},c))})]})},_n=hn;function Me(t,n,s){return(n=function(a){var r=function(o,l){if(typeof o!="object"||!o)return o;var i=o[Symbol.toPrimitive];if(i!==void 0){var c=i.call(o,l);if(typeof c!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(o)}(a,"string");return typeof r=="symbol"?r:r+""}(n))in t?Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[n]=s,t}(function(t){return t.Production="production",t.Sandbox="sandbox",t})({});(function(t){return t.AlipayCn="alipay_cn",t.AlipayHk="alipay_hk",t.Alma="alma",t.Applepay="applepay",t.Bancontact="bancontact",t.Benefit="benefit",t.Bizum="bizum",t.Card="card",t.Dana="dana",t.Eps="eps",t.Gcash="gcash",t.Googlepay="googlepay",t.Ideal="ideal",t.Kakaopay="kakaopay",t.Klarna="klarna",t.Knet="knet",t.Mbway="mbway",t.MobilePay="mobilepay",t.Multibanco="multibanco",t.Octopus="octopus",t.P24="p24",t.PayNow="paynow",t.Paypal="paypal",t.Plaid="plaid",t.Qpay="qpay",t.RememberMe="remember_me",t.Sepa="sepa",t.StcPay="stcpay",t.StoredCard="stored_card",t.Swish="swish",t.Tabby="tabby",t.Tamara="tamara",t.TouchNGo="tng",t.Truemoney="truemoney",t.Twint="twint",t.Vipps="vipps",t.WeChatPay="wechatpay",t.Flow="flow",t.Authentication="authentication",t.CardCvv="card_cvv",t.ShippingAddress="shipping_address",t})({});(function(t){return t.Amex="american_express",t.CartesBancaires="cartes_bancaires",t.ChinaUnionPay="china_union_pay",t.DinersClub="diners_club_international",t.Discover="discover",t.JCB="jcb",t.Mada="mada",t.Mastercard="mastercard",t.Visa="visa",t})({});(function(t){return t.Charge="charge",t.Credit="credit",t.Debit="debit",t.DeferredDebit="deferred_debit",t.Prepaid="prepaid",t})({});(function(t){return t.DefaultOnly="default_only",t.All="all",t})({});(function(t){return t.AbovePayButton="above_pay_button",t.BelowPayButton="below_pay_button",t})({});(function(t){return t.Integration="Integration",t.Request="Request",t.PaymentMethod="PaymentMethod",t.Submit="Submit",t})({});(function(t){return t.PaymentMethodAttemptFailed="payment_method_attempt_failed",t})({});(function(t){return t.BrowserEnvironmentRequired="browser_environment_required",t.CallbackInvocationFailed="callback_invocation_failed",t.CallbackResultInvalid="callback_result_invalid",t.ComponentAlreadyMounted="component_already_mounted",t.ComponentIsAvailableNotChecked="component_is_available_not_checked",t.ComponentNotSupported="component_not_supported",t.ElementNotFound="element_not_found",t.MethodNotSupported="method_not_supported",t.PaymentSessionInvalid="payment_session_invalid",t.PaymentSessionRequired="payment_session_required",t})({});(function(t){return t.PaymentRequestAborted="payment_request_aborted",t.PaymentRequestDeclined="payment_request_declined",t.PaymentRequestFailed="payment_request_failed",t.NetworkError="network_error",t.TokenizeRequestFailed="tokenize_request_failed",t})({});(function(t){return t.ComponentInvalid="component_invalid",t})({});(function(t){return t.NotEnoughFunds="not_enough_funds",t.InvalidPaymentSessionData="invalid_payment_session_data",t.InvalidCustomerData="invalid_customer_data",t.CustomerMisconfiguration="customer_misconfiguration",t.MerchantMisconfiguration="merchant_misconfiguration",t.TryAgain="try_again",t.PaymentCancelled="payment_cancelled",t.PaymentExpired="payment_expired",t})({});(function(t){return t.CardNotSupported="card_not_supported",t})({});(function(t){return t.Subheading="subheading",t.Footnote="footnote",t.Button="button",t.Input="input",t.Label="label",t})({});const Ee="https://checkout-web-components.checkout.com/index.js";let oe=function(t){return t.Integration="Integration",t}({}),ie=function(t){return t.BrowserEnvironmentRequired="browser_environment_required",t.CheckoutWebComponentInstanceNotOnWindow="checkout_web_component_instance_not_on_window",t.ScriptFailed="script_failed",t.ScriptTimedOut="script_timed_out",t}({});
1class X extends Error{constructor({type:n,message:s,code:a}){super(`[${n}]: ${s} [${a}]`),Me(this,"type",void 0),Me(this,"code",void 0),Object.setPrototypeOf(this,X.prototype),this.type=n,this.code=a,this.name="CheckoutLoaderError"}}const xn=async t=>{if(typeof window>"u"||typeof document>"u")throw new X({type:oe.Integration,message:"CheckoutWebComponents can only run in a browser environment",code:ie.BrowserEnvironmentRequired});if(window.CheckoutWebComponents)return window.CheckoutWebComponents(t);const n=(a=>{const r=document.querySelectorAll(`script[src^="${Ee}"]`);if(r.length>0)for(let l=0;l<r.length;l++)r[l].remove();const o=document.createElement("script");return o.src=a,o.async=!0,document.head.appendChild(o),o})(Ee);return(await(async a=>new Promise((r,o)=>{a.addEventListener("load",()=>{window.CheckoutWebComponents?r(window.CheckoutWebComponents):o(new X({type:oe.Integration,message:"CheckoutWebComponents loaded but window.CheckoutWebComponents isn't present",code:ie.CheckoutWebComponentInstanceNotOnWindow}))}),a.addEventListener("error",()=>{o(new X({type:oe.Integration,message:"CheckoutWebComponents did not load due to script failing",code:ie.ScriptFailed}))}),setTimeout(()=>{o(new X({type:oe.Integration,message:"CheckoutWebComponents did not load due to script timing out",code:ie.ScriptTimedOut}))},3e4)}))(n))(t)};var fn=({className:t,method:n,environment:s,locale:a,showPayButton:r=!1,onRequestSession:o,onPaymentCompleted:l,onCheckoutError:i,onLoaderError:c,onValidityChange:u,onStageChange:d,disabled:m,ref:y})=>{const f=b.useRef(null),h=b.useRef(null),[_,x]=b.useState("idle"),{t:k}=R("payment_common"),j=n==="applepay"||n==="googlepay",{checkoutFlowKey:C}=F(),M=b.useRef(l),T=b.useRef(i),P=b.useRef(c),S=b.useRef(u),E=b.useRef(d),W=b.useRef(o),V=b.useRef(m);M.current=l,T.current=i,P.current=c,S.current=u,E.current=d,W.current=o,V.current=m;const q=g=>{var D;x(g),(D=E.current)==null||D.call(E,g)},A=b.useCallback(()=>$(null,null,function*(){var g,D,z;if(!(!f.current||!C)){q("loading"),(g=P.current)==null||g.call(P,"");try{const{paymentSession:U,orderId:ye}=yield W.current();if(!f.current)return;const ke=yield xn({paymentSession:U,publicKey:C,environment:s??(C.startsWith("pk_sbox")?"sandbox":"production"),locale:a,appearance:et(),componentOptions:{applepay:{buttonColor:"white"},googlepay:{buttonColor:"white"}},onPaymentCompleted:()=>{var J;return(J=M.current)==null?void 0:J.call(M,ye)},onError:(J,re)=>{var Pe;return(Pe=T.current)==null?void 0:Pe.call(T,re)}});if(!f.current)return;const se=j?ke.create(n,{handleClick:()=>$(null,null,function*(){return{continue:!V.current}})}):ke.create(n,{showPayButton:r,onChange:J=>{var re;(re=S.current)==null||re.call(S,J.isValid())}});if(h.current=se,!(yield se.isAvailable()))throw new Error(k("payment_common:unknown_error"));if(!f.current)return;se.mount(f.current),j||(D=S.current)==null||D.call(S,se.isValid()),q("ready")}catch(U){q("idle"),(z=P.current)==null||z.call(P,(U==null?void 0:U.message)||k("payment_common:unknown_error"))}}}),[s,j,a,n,C,r,k]);return b.useImperativeHandle(y,()=>({submit:()=>{var g;(g=h.current)==null||g.submit()},isValid:()=>{var g,D,z;return(z=(D=(g=h.current)==null?void 0:g.isValid)==null?void 0:D.call(g))!=null?z:!1},resetSession:()=>{var g;(g=h.current)==null||g.unmount(),h.current=null,A()}}),[A]),b.useEffect(()=>(A(),()=>{var g;(g=h.current)==null||g.unmount(),h.current=null}),[A]),e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
2          .checkout-flow-wrapper [borderbottomcolor='colorBorder'][borderbottomstyle='solid'] {
3            border-top-color: hsl(var(--bg-body-level-1)) !important;
4            border-right-color: hsl(var(--bg-body-level-1)) !important;
5            border-left-color: hsl(var(--bg-body-level-1)) !important;
6          }
7        `}),e.jsxs("div",{className:t,children:[_==="loading"&&e.jsx("div",{className:"flex h-12 items-center justify-center",children:e.jsx(ut,{className:"mx-auto h-7 w-7"})}),e.jsx("div",{ref:f,className:"checkout-flow-wrapper"})]})]})},bn=fn,vn={credit_card:"card",mada:"card",visa:"card",master_card:"card",american_express:"card",apple_pay:"applepay",googlepay:"googlepay",stc:"stcpay",benefit:"benefit"},jn=t=>{var n;if(t)return(n=vn[t])!=null?n:void 0},gn=({item:t})=>{var n,s,a,r,o,l;
7const{event:i,canUseApplePay:c}=F(),{t:u}=R("payment_common"),d=i.enable_payment_methods||t.type==="credit_card";return e.jsxs("div",{className:B("flex min-h-10 gap-3",i.enable_payment_methods?"items-start":"items-center"),children:[(n=t.payment_method)!=null&&n.icon?e.jsx(Fe,{src:t.payment_method.icon,alt:t.payment_method.name||u(`payment_common:${t.type}`),className:"h-6 w-7 shrink-0 object-contain pt-2"}):e.jsx(wn,{type:t.type}),e.jsxs("div",{className:"grow",children:[e.jsx(p,{variant:"label-M",children:((s=t.payment_method)==null?void 0:s.name)||u(`payment_common:${t.type}`)}),d&&e.jsx("div",{className:"flex gap-2",children:e.jsx(_n,{canUseApplePay:c,supported:i.enable_payment_methods?(a=t.payment_method)==null?void 0:a.codes:Array.isArray(i.card_types)?i.card_types.map(m=>m.code):void 0,className:"h-5 w-6 shrink-0 object-contain",logosOnly:!0})}),((r=t.payment_method)==null?void 0:r.description)&&e.jsx(p,{variant:"body-S",color:"text-secondary",children:i!=null&&i.enable_payment_methods?(o=t.payment_method)==null?void 0:o.description:u(`payment_common:${(l=t.payment_method)==null?void 0:l.description}`)})]})]})},wn=({type:t})=>{const{t:n}=R("payment_common");switch(t){case"apple_pay":return e.jsx(ve,{className:"h-6 w-9 shrink-0 object-contain"});case"credit_card":return e.jsx(fe,{className:"h-6 w-7 shrink-0 object-contain"});case"benefit":return e.jsx("div",{className:"h-6 w-7 shrink-0",children:e.jsx("img",{className:"shrink-0 object-contain",src:"/@wbk/payment/benefit_pay.png",alt:n("payment_common:benefit")})});case"stc":return e.jsx(je,{className:"h-6 w-7 shrink-0 object-contain"});case"wafacash":return e.jsx(Ct,{className:"h-6 w-6 shrink-0 object-contain"});case"multibanco":return e.jsx(qe,{className:"h-6 w-6 shrink-0 object-contain"});case"mbways":return e.jsx(De,{className:"h-6 w-6 shrink-0 object-contain"});case"googlepay":return e.jsx(St,{className:"h-6 w-9 shrink-0 object-contain"});default:return e.jsx(fe,{className:"h-6 w-7 shrink-0 object-contain"})}},Nn=gn,kn=({totals:t})=>{const{locale:n}=G(),{t:s}=R("payment_common"),{currency:a,minAmount:r,belowMinimum:o,instalment:l}=mn(t.net_after_discount);return e.jsx(Ie,{size:"2xl",bodyClassName:"!p-0",type:"modal",closeButton:!1,customAction:({close:i})=>e.jsx(I,{theme:"action",shape:"text",onClick:i,children:e.jsx(p,{variant:"label-M",children:s("payment_common:close")})}),render:({open:i})=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3",children:[e.jsx("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-white p-0.5 text-black",children:e.jsx(xe,{})}),e.jsxs("div",{className:"grow",children:[e.jsx(p,{variant:"label-M",children:s("payment_common:pay_with_tabby")}),e.jsx(p,{as:"div",variant:"body-S",children:o?e.jsxs("span",{children:[s("payment_common:tabby_minimum_amount"),e.jsx(N,{className:"inline-block ps-1 font-bold [&_svg]:h-3 [&_svg]:w-3",priceClassName:"text-body-S font-bold",originalPrice:r,currency:a})]}):e.jsx(e.Fragment,{children:e.jsxs(ae,{i18nKey:"tabby_payment_with_price_formal",ns:"payment_common",children:[e.jsx(N,{originalPrice:l,currency:a,className:"inline-block font-bold [&_svg]:h-3 [&_svg]:w-3",priceClassName:"text-body-S font-bold"}),e.jsx(I,{theme:"action",shape:"text",onClick:i,disabled:o,className:"p-0.5 text-sky-500 underline hover:text-sky-400 disabled:cursor-not-allowed"})]})})})]})]}),body:()=>e.jsx("iframe",{title:"Tabby Payment Installments",className:"mini-scrollbar h-[75vh] max-h-full w-full overflow-y-auto",src:o?`//checkout.tabby.ai/promos/product-page/installments/${n}/?installmentsCount=0`:`//checkout.tabby.ai/promos/product-page/installments/${n}/?currency=SAR&price=${t.net_after_discount}`})})},Pn=kn,Sn=({className:t,totals:n,loading:s,error:a,applePayEnable:r,tabbyEnable:o,inlineFlowRef:l,onRequestSession:i,onValidityChange:c,onPaymentCompleted:u,onCheckoutError:d,onLoaderError:m,validateOnChange:y,walletEnabled:f,onWalletOtp:h})=>{var _;const{checkoutFlowKey:x}=F(),{t:k}=R("payment_common"),{locale:j}=G(),{availableMethods:C,selectedMethod:M,isLoading:T,errorMessage:P,paymentDisabled:S,isMethodDisabled:E,isNative:W,findMethod:V,setPaymentMethod:q}=cn({total:n.net_after_discount,applePayAllowed:r,tabbyAllowed:o});return P?e.jsx("div",{className:t,children:e.jsx(p,{color:"error",children:P||k("payment_common:no_payment_methods_available")})}):e.jsx("div",{className:t,children:e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{children:e.jsx(p,{variant:"heading-M",children:k("payment_common:payment_method")})}),f&&e.jsx(yn,{withOtp:!0,onSuccess:h}),T?e.jsx("div",{className:"space-y-2",children:Array.from({length:2}).map((A,g)=>e.jsx("div",{className:"rounded-S bg-body-level-1 mt-2 h-16 w-full animate-pulse"},g))}):e.jsx(pt,{name:"payment-method-selector",value:S?"":(_=M==null?void 0:M._id)!=null?_:"",onValueChange:A=>$(null,null,function*(){const g=V(A);if(typeof y=="function"&&W(g)){(yield y(g==null?void 0:g.type))&&q(g);return}q(g)}),disabled:S||s,className:"space-y-2",children:C.map(A=>{const g=s||E(A.type),D=(M==null?void 0:M._id)===A._id,z=jn(A.type),U=W(A)&&z==="card",ye=D&&U&&i&&c&&u&&!!x;
7return e.jsxs(H,{className:B("has-[[data-state=checked]]:border-action hover:border-action/70 transition-colors",g&&"hover:border-paper cursor-not-allowed opacity-50"),children:[e.jsxs("label",{htmlFor:`payment-method-selector_${A._id}`,className:B("flex items-center justify-between gap-2",g?"cursor-not-allowed":"cursor-pointer"),children:[e.jsx("div",{className:"grow",children:A.type==="tabby"?e.jsx(Pn,{totals:n}):e.jsx(Nn,{item:A})}),e.jsx(yt,{value:A._id,id:`payment-method-selector_${A._id}`,disabled:g,"data-check":!0,"data-testid":`ui_radio_payment-method-selector_${A._id}`,className:B("border-input-border disabled:border-input-disabled peer h-[24px] w-[24px] shrink-0 rounded-full border-2 aria-checked:data-[check=true]:border-none","outline-action data-[state=checked]:border-action"),children:e.jsx(ht,{className:B("flex items-center justify-center rounded-full","bg-action text-action-contrast [&>svg]:h-full [&>svg]:w-full [&>svg]:rounded-full [&>svg]:p-1"),children:e.jsx(Pt,{})})})]}),e.jsx(ge,{initial:!1,children:ye&&e.jsx(K.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25,ease:[.04,.62,.23,.98]},className:"overflow-hidden",children:e.jsx(bn,{className:"mt-4 pt-4",ref:l,method:z,locale:j,showPayButton:!U,onRequestSession:i,onValidityChange:c,onPaymentCompleted:u,onCheckoutError:d,onLoaderError:m})},"expanded")})]},A._id)})}),a&&e.jsx("p",{className:"text-error my-1 min-h-[16px] text-xs",children:a})]})})},ja=Sn,Cn=({ref:t,cardDiscountLimit:n,onChoice:s})=>{const{t:a}=R("payment_common"),r=b.useRef(null);return b.useImperativeHandle(t,()=>({open:()=>{var o;return(o=r.current)==null?void 0:o.open()},close:()=>{var o;return(o=r.current)==null?void 0:o.close()}}),[]),n?e.jsx(Ie,{ignoreHistory:!0,ref:r,size:"lg",title:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"h-6 w-6"}),e.jsx(p,{variant:"heading-S",children:a("payment_common:card_discount_limit.title")})]}),customAction:()=>e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[e.jsx(I,{onClick:()=>{var o;(o=r.current)==null||o.close(),s("full_price")},className:"h-12 w-full",children:a("payment_common:card_discount_limit.continue_full_price")}),e.jsx(I,{theme:"action",shape:"outlined",className:"h-12 w-full",onClick:()=>{var o;(o=r.current)==null||o.close(),s("different_card")},children:a("payment_common:card_discount_limit.different_card")})]}),body:()=>e.jsx(p,{color:"text-secondary",children:a(n.card_ending?"payment_common:card_discount_limit.description":"payment_common:card_discount_limit.description_no_card_ending",{bank:n.name,cardEnding:n.card_ending,discountPercentage:n.discount_percentage})})}):null},ga=Cn,Mn=()=>{const{user:t}=ue(),{setSaudiRedeem:n}=O(),{mutateAsync:s,isPending:a,error:r,reset:o}=lt(),{event:l}=F(),{locale:i}=G(),{t:c}=R(["payment_common"]),{trackEvent:u}=we(),d=!!(t!=null&&t.saudi_reward_linked),m=(t==null?void 0:t.saudi_reward_member_id)||"",{handleSubmit:y,control:f,reset:h,formState:{isValid:_}}=pe({defaultValues:{memberId:m,memberPin:""}}),x=(j=m)=>{h({memberId:d?m:j,memberPin:""})};b.useEffect(()=>{d&&m&&x()},[d,m]);const k=j=>$(null,null,function*(){o();try{const C=yield s(w(v({memberPin:j.memberPin},j.memberId?{memberId:j.memberId}:{}),{lang:i}));n(w(v({},C),{quantity:0})),u({event:"saudi_rewards_booking_verified",data:{slug:l.slug,booking_type:l.contentful_entity_type}})}catch{}finally{x(j.memberId)}});return e.jsxs("div",{className:"space-y-2",children:[!d&&e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-2 rounded-[4px] bg-violet-950 p-2 text-sm text-violet-300",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg",children:"✨"}),e.jsx("p",{children:c("payment_common:link_saudi_rewards_account")}
7)]}),e.jsx(Fe,{width:75,height:35,src:`/@wbk/payment/saudi_rewards_${i==="ar"?"ar":"en"}.png`})]}),e.jsxs("form",{onSubmit:y(k),className:"space-y-2",children:[e.jsx(te,{control:f,name:"memberId",rules:{required:d?!1:c("payment_common:member_id_required")},render:({field:j,fieldState:{error:C}})=>e.jsx(L,w(v({},j),{value:j.value||"",label:e.jsx("span",{className:"text-sm",children:c("payment_common:enter_member_id")}),className:"w-full",placeholder:"SRXXXXXXXX",error:C==null?void 0:C.message}))}),e.jsx(te,{control:f,name:"memberPin",rules:{required:c("payment_common:security_pin_required")},render:({field:j,fieldState:{error:C}})=>e.jsx(L,w(v({},j),{type:"password",autoComplete:"one-time-code",label:e.jsx("span",{className:"text-sm",children:c("payment_common:enter_pin")}),className:"w-full",placeholder:c("payment_common:security_pin"),error:C==null?void 0:C.message}))}),(r==null?void 0:r.message)&&e.jsx("p",{className:"text-error py-2 text-sm",children:r.message}),e.jsx(I,{className:"ring-offset-body-level-2 mx-1 h-8 px-6 text-sm font-bold",theme:"primary",shape:"solid",type:"submit",id:"verify-saudi-reward-member","data-event-name":l==null?void 0:l.title,disabled:!_,loading:a,children:c("payment_common:verify")})]})]})},En=Mn,Rn=({totals:t})=>{const{isVerified:n}=Ue(t.net_after_discount);return e.jsx(ge,{mode:"wait",initial:!1,children:n?e.jsx(K.div,{initial:{opacity:0}
7,animate:{opacity:1},exit:{opacity:0},children:e.jsx(An,{totals:t})}):e.jsx(K.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:e.jsx(En,{})})})},An=({totals:t})=>{const{t:n}=R(["payment_common"]),{isVerified:s,memberId:a,balance:r,balanceValue:o,hasNoBalance:l,redeemedPoints:i,redeemedValue:c,isRedeemed:u,maxRedeemable:d,currency:m,walletCurrency:y,valueOf:f,redeem:h,clearPoints:_,changeMember:x}=Ue(t.net_after_discount),{control:k,setValue:j,handleSubmit:C,watch:M}=pe({defaultValues:{points:d||0}}),T=M("points"),P=T!==d;if(!s)return null;const S=()=>{j("points",d)};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"bg-body/20 mb-3 flex items-center gap-4 rounded-xl border border-white/10 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1 text-[13px]",children:[e.jsxs("span",{children:[n("payment_common:member_id"),":"]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{children:a}),e.jsx(I,{shape:"text",theme:"primary",className:"mx-1 p-0",onClick:x,children:n("payment_common:change")})]})]}),e.jsx("div",{className:"bg-body-dark/10 h-9 w-px"}),e.jsxs("div",{className:"flex flex-col gap-1 text-[13px]",children:[e.jsxs("span",{children:[n("payment_common:balance"),":"]}),e.jsxs("div",{children:[Q(r)," ",n("payment_common:pt")," ≈"," ",e.jsx(N,{originalPrice:o,currency:m,className:"inline-flex"})]})]})]}),l?e.jsx("p",{className:"text-error text-center text-sm",children:n("payment_common:not_enough_points")}):u?e.jsxs("div",{className:"flex items-center gap-1 text-[13px]",children:[n("payment_common:redeemed_balance",{amount:i})," =",e.jsx(N,{originalPrice:c,currency:y}),e.jsx(I,{shape:"text",theme:"primary",className:"mx-1 px-2 py-1",onClick:_,children:n("payment_common:change")})]}):e.jsx("form",{onSubmit:C(({points:E})=>h(E)),className:"mt-3",children:e.jsx("div",{className:"group relative w-full",children:e.jsx(te,{control:k,name:"points",rules:{required:n("payment_common:validation.required"),validate:{max:E=>E>d?n("payment_common:redeem_points_error_max",{max:d}):E<=r?!0:n("payment_common:redeem_points_error")}},render:({field:E,fieldState:{error:W}})=>e.jsxs("div",{children:[e.jsxs("div",{className:"relative [&>label]:text-sm [&>label]:font-normal",children:[e.jsx(L,w(v({type:"number",label:n("payment_common:redeem_label"),className:"w-full py-[12px]",placeholder:n("payment_common:redeem_placeholder"),error:W==null?void 0:W.message,hideErrorSpace:!0,hideErrorMark:!0},E),{value:E.value||""})),e.jsxs("div",{className:"absolute top-7 mx-2 flex h-[50px] items-center gap-2.5 ltr:right-0 rtl:left-0",children:[P&&e.jsx("button",{type:"button",className:"text-text-secondary text-sm",onClick:S,children:n("payment_common:max")}),e.jsx("div",{className:"bg-body-dark/10 h-8 w-px"}),e.jsx(I,{className:"h-8 text-sm font-bold",theme:"primary",shape:"solid",type:"submit",id:"checkout-apply-coupon",disabled:!T,children:n("payment_common:redeem")})]})]}),E.value?e.jsxs("div",{className:"text-text-secondary mt-2 flex items-center gap-1 text-[13px]",children:[e.jsx("span",{children:"="}),e.jsx(N,{originalPrice:f(E.value),currency:y})]}):null]})})})})]})},Tn=()=>{const{locale:t}=G(),{user:n}=ue(),{t:s}=R(["payment_common"]),{setQitaf:a}=O(),{control:r,handleSubmit:o,setError:l,formState:{isDirty:i}}=pe({defaultValues:{phone:""}}),{mutateAsync:c,isPending:u}=Re(),d=m=>$(null,null,function*(){var y;try{const f=(y=m.phone)!=null&&y.startsWith("0")?m.phone.slice(1):m.phone;yield c({phone:f,lang:t,email:n.email}),a({phone:m.phone})}catch(f){l("phone",{message:f==null?void 0:f.message})}});return e.jsxs("form",{onSubmit:o(d),className:"space-y-4",children:[e.jsx(te,{control:r,name:"phone",rules:{required:s("payment_common:validation.required")},render:({field:m,fieldState:{error:y}})=>e.jsxs("div",{className:"space-y-2 [&_label]:text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{htmlFor:"qitafPhone",children:s("payment_common:enter_qitaf_phone")}),e.jsx(be,{className:"h-8 w-8 shrink-0"})]}),e.jsxs("div",{className:"flex items-start",dir:"ltr",children:[e.jsxs("div",{className:"bg-input border-input-border text-text-secondary flex h-10 shrink-0 items-center justify-between gap-2 rounded-md rounded-r-none border border-r-0 p-2",dir:"ltr",children:[e.jsx("img",{className:"shrink-0",src:"https://wbk-assets-backup.s3.eu-west-1.amazonaws.com/flags/w80/sa.png",height:14,width:20,alt:"Saudi Arabia"}),e.jsx("div",{dir:"ltr",className:"font-sans",children:"+966"})]}),e.jsx(L,w(v({},m),{minLength:9,maxLength:10,type:"tel",error:y==null?void 0:y.message,groupClassName:"grow",className:"h-10 rounded-l-none font-sans",dir:"ltr",id:"qitafPhone"}))]})]})}
7),e.jsx(I,{type:"submit",className:"h-11 w-full capitalize",disabled:!i,loading:u,children:s("payment_common:auth.verify")})]})},In=Tn,Ge=({render:t,seconds:n})=>{const s=b.useId(),{count:a,reset:r,set:o}=tt({id:s,initialSeconds:n});return t({count:a,reset:r,set:o})},Fn=({totals:t})=>{const{user:n}=ue(),{t:s}=R(["payment_common"]),{organizationName:a}=Y(),[r,o]=b.useState({otp:"",amount:Math.ceil(t.net_after_discount)}),{qitaf:l,setQitaf:i,setRedeemType:c}=O(),{mutateAsync:u,error:d,isPending:m,reset:y}=ct();if(!l)return null;const f=()=>$(null,null,function*(){try{yield u({otp:Number(r.otp),amount:r.amount,phone:Number(l.phone),email:n.email}),i(v(v({},l),r)),c("wallet")}catch{}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Oe,{onChange:h=>o(w(v({},r),{otp:h})),shape:"contained",legend:e.jsx("p",{className:"mb-1 text-sm",children:s("payment_common:enter_qitaf_otp")}),onlyNumbers:!0,renderButton:({resetState:h})=>e.jsx("div",{className:"-mt-2 flex w-full justify-end",children:e.jsx(On,{resetState:()=>{h(),y()},phone:l.phone})}),error:d==null?void 0:d.message}),e.jsxs("div",{className:"relative [&_label]:text-sm",children:[e.jsx(L,{type:"number",label:s("payment_common:enter_qitaf_amount"),value:r.amount||"",onChange:h=>o(w(v({},r),{amount:Math.ceil(Number(h))})),max:t.net_after_discount,min:1,className:"[appearance:textfield] ltr:pr-10 rtl:pl-10 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),e.jsx("span",{className:"text-text-secondary absolute top-6 flex h-10 items-center justify-center ltr:right-2 rtl:left-2",children:"SAR"}),e.jsx("p",{className:"text-text-secondary mt-1 text-xs",children:s("payment_common:amount_as_whole_number")})]}),e.jsx(I,{disabled:r.otp.length<4||r.amount>Math.ceil(t.net_after_discount)||!r.amount,onClick:f,loading:m,className:"h-11 w-full",children:s("payment_common:redeem_to_wallet",{organizationName:a||"webook.com"})})]})},On=({phone:t,resetState:n})=>{const{locale:s}=G(),{t:a}=R(["payment_common"]),{mutateAsync:r,isPending:o}=Re(),{user:l}=ue(),i=()=>$(null,null,function*(){yield r({phone:t,lang:s,email:l.email})});return e.jsx(Ge,{seconds:60,render:({count:c,reset:u})=>e.jsxs("div",{className:"mt-4 flex items-center justify-center gap-2",children:[e.jsx("p",{className:"text-text-secondary mx-1 text-sm",children:a("payment_common:auth.didnt_receive_it")}),e.jsx(I,{type:"button",shape:"text",className:"px-2 py-1 text-sm",disabled:c>0,loading:o,onClick:()=>$(null,null,function*(){try{yield i(),u(),n()}catch{}}),id:"resend-qitaf-otp",children:`${a("payment_common:auth.resend_otp")} ${c>0?`(${c})`:""}`})]})})},qn=Fn,Dn=({totals:t})=>{const{t:n}=R(["payment_common"]),{organizationName:s}=Y(),{qitaf:a,setQitaf:r}=O(),o=a?a.otp?"success":"otp":"phone";return e.jsxs("div",{className:"border-paper space-y-3 rounded-xl border p-4",children:[!!a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-text-secondary mb-1 text-xs",children:n("payment_common:auth.mobile")}),e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx("span",{dir:"ltr",children:"+966"+a.phone}),o!=="phone"&&e.jsx(I,{shape:"text",onClick:()=>r(null),className:"p-1 text-xs",children:n("payment_common:change")})]})]}),o!=="success"&&e.jsx(be,{className:"h-8 w-8 shrink-0"})]}),o==="success"&&(a==null?void 0:a.amount)&&e.jsxs("div",{className:"relative z-10 flex items-center gap-4 border-t border-white/20 pt-2",children:[e.jsx("img",{src:"/@wbk/payment/firework_mini_once.gif",className:"absolute top-0 -z-[1] h-32 w-32 -translate-y-1/3 ltr:left-0 ltr:-translate-x-1/4 rtl:right-0 rtl:translate-x-1/4",alt:""}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(N,{className:"text-success-light text-lg font-black",originalPrice:a.amount,currency:"SAR"}),e.jsx("p",{className:"text-text-secondary text-xs",children:n("payment_common:redeemed_amount_in_wallet",{organizationName:s||"webook.com"})})]}),e.jsx(be,{className:"relative z-10 h-10 w-10 shrink-0"})]})]}),o==="phone"&&e.jsx(In,{}),o==="otp"&&e.jsx(qn,{totals:t})]})},$n=Dn,Wn=()=>{const{t}=R(["payment_common"]),{setMokafaa:n}=O(),{control:s,handleSubmit:a,setError:r,formState:{isDirty:o}}=pe({defaultValues:{phone:""}}),{mutateAsync:l,isPending:i}=Ae(),c=u=>$(null,null,function*(){try{const d=yield l({mobile:`966${u.phone.replace(/^0/,"")}`});n({phone:u.phone,otpToken:d.otp_token})}catch(d){r("phone",{message:d==null?void 0:d.message})}});return e.jsxs("form",{onSubmit:a(c),className:"space-y-4",children:[e.jsxs("div",{className:"bg-formula-primary-light rounded-S flex w-full shrink-0 items-center gap-3 px-4 py-2",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-white",children:e.jsx("img",{src:"/@wbk/payment/mokafaa-logo.png",alt:""})}),e.jsx(p,{variant:"label-S",children:t("payment_common:mokafaa_helper_banner")})]}),e.jsx(te,{control:s,name:"phone",rules:{required:t("payment_common:validation.required")},render:({field:u,fieldState:{error:d}})=>e.jsxs("div",{className:"space-y-2 [&_label]:text-sm",children:[e.jsx("label",{htmlFor:"mokafaaPhone",children:t("payment_common:mokafaa_phone_label")}),e.jsxs("div",{className:"flex items-start",dir:"ltr",children:[e.jsxs("div",{className:"bg-input border-input-border flex h-10 shrink-0 items-center justify-between gap-2 rounded-md rounded-r-none border border-r-0 p-2",dir:"ltr",children:[e.jsx("img",{className:"shrink-0",src:"https://wbk-assets-backup.s3.eu-west-1.amazonaws.com/flags/w80/sa.png",height:14,width:20,alt:"Saudi Arabia"}),e.jsx("div",{dir:"ltr",children:"+966"})]}),e.jsx(L,w(v({},u),{"data-testid":"mokafaa_phone_input",minLength:9,maxLength:10,type:"tel",error:!!d,hideErrorSpace:!0,groupClassName:"grow",className:"h-10 rounded-l-none",dir:"ltr",id:"mokafaaPhone"}))]}),!!(d!=null&&d.message)&&e.jsx(p,{variant:"body-XS",color:"error",children:d.message})]})}),e.jsx(I,{theme:"action",type:"submit",className:"w-full",disabled:!o,loading:i,children:t("payment_common:next")})]})},zn=Wn,_e=1,Bn=({totals:t})=>{const{t:n}=R(["payment_common"]),{organizationName:s}=Y(),[a,r]=b.useState({otp:"",amount:Math.ceil(t.net_after_discount)}),{mokafaa:o,setMokafaa:l}=O(),{mutateAsync:i,error:c,isPending:u,reset:d}=dt();if(!o)return null;const m=()=>$(null,null,function*(){try{yield i({mobile:`966${o.phone.replace(/^0/,"")}`,otpToken:o.otpToken,otp:a.otp,amount:a.amount}),l(v(v({},o),a))}catch{}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Oe,{onChange:y=>r(w(v({},a),{otp:y})),legend:e.jsx(p,{variant:"body-S",color:"text-secondary",className:"mb-4",children:n("payment_common:mokafaa_otp_prompt",{phone:`+966${o.phone}`})}),onlyNumbers:!0,renderButton:({resetState:y})=>e.jsx("div",{className:"-mt-2 w-full",children:e.jsx(Vn,{mobile:`966${o.phone.replace(/^0/,"")}`,onResend:f=>l(w(v({},o),{otpToken:f})),resetState:()=>{y(),d()}})}),error:c==null?void 0:c.message}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"relative [&_label]:text-sm",children:e.jsx(L,{type:"number",label:n("payment_common:enter_mokafaa_amount"),value:a.amount||"",onChange:y=>r(w(v({},a),{amount:Number(y)})),max:t.net_after_discount,min:_e,className:"[appearance:textfield] ltr:pr-10 rtl:pl-10 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",endIcon:e.jsx(p,{as:"span",variant:"body-S",color:"text-secondary",className:"flex h-10 items-center justify-center overflow-hidden px-3",children:"SAR"})})}),e.jsx(p,{variant:"body-S",color:"text-secondary",children:n("payment_common:mokafaa_min_amount",{amount:_e})})]}),e.jsx(I,{disabled:a.otp.length<4||a.amount>Math.ceil(t.net_after_discount)||a.amount<_e,onClick:m,loading:u,className:"h-11 w-full",children:u?null:n("payment_common:redeem_to_wallet",{organizationName:s||"webook.com"})})]})},Vn=({mobile:t,onResend:n,resetState:s})=>{const{t:a}=R(["payment_common"]),{mutateAsync:r,isPending:o,error:l}=Ae(),i=()=>$(null,null,function*(){const c=yield r({mobile:t});n(c.otp_token)});return e.jsx(Ge,{seconds:60,render:({count:c,reset:u})=>e.jsxs("div",{className:"mt-4 w-full space-y-1",children:[e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx(p,{variant:"body-S",color:"text-secondary",className:"mx-1",children:a("payment_common:auth.didnt_receive_it")}
7),e.jsx(I,{type:"button",shape:"text",className:"px-2 py-1 text-sm",disabled:c>0,loading:o,onClick:()=>$(null,null,function*(){try{yield i(),u(),s()}catch{}}),id:"resend-mokafaa-otp",children:`${a("payment_common:auth.resend_otp")} ${c>0?`(${c})`:""}`})]}),!!(l!=null&&l.message)&&e.jsx(p,{variant:"body-XS",color:"error",className:"text-center",children:l.message})]})})},Ln=Bn,Un=({totals:t})=>{const{t:n}=R(["payment_common"]),{mokafaa:s,setMokafaa:a}=O(),r=s!=null&&s.otp&&(s!=null&&s.amount)?"success":s!=null&&s.otpToken?"otp":"phone";return e.jsxs("div",{className:"space-y-4",children:[r!=="phone"&&e.jsxs(H,{border:!0,className:"flex items-center justify-between px-4 py-2",children:[e.jsxs("div",{children:[e.jsx(p,{variant:"body-S",color:"text-secondary",children:n("payment_common:mokafaa_member_phone_label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"body-S",dir:"ltr",children:"+966"+(s==null?void 0:s.phone)}),e.jsx(I,{shape:"text",theme:"primary",onClick:()=>a(null),className:"px-2 py-1",children:e.jsx(p,{variant:"body-S",children:n("payment_common:change")})})]})]}),e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-white",children:e.jsx("img",{src:"/@wbk/payment/mokafaa-logo.png",alt:""})})]}),r!=="success"&&e.jsxs("div",{className:"border-paper space-y-3 rounded-xl border p-4",children:[r==="phone"&&e.jsx(zn,{}),r==="otp"&&e.jsx(Ln,{totals:t})]})]})},Qn=Un,Gn=({isAppliedToAll:t})=>{const{event:n}=F(),{t:s}=R(["payment_common"]),{appliedCode:a,isApplied:r,hasDiscountedTickets:o,isPending:l,error:i,canApply:c,setPromoCode:u,apply:d,remove:m}=Lt();return e.jsxs("div",{children:[e.jsx("form",{onSubmit:y=>{y.preventDefault(),d()},children:e.jsxs("div",{className:"group relative w-full",children:[e.jsx(L,{defaultValue:a,"data-testid":"ticketing_summary_coupon_input",label:e.jsx("span",{className:"text-sm",children:s("payment_common:enter_coupon")}),disabled:r||l,className:o?"text-success-light":"",placeholder:s("payment_common:enter_coupon"),error:!!(i!=null&&i.message),hideErrorSpace:!0,hideErrorMark:!0,onChange:y=>{u(y)}}),e.jsx("div",{className:"absolute bottom-0 mx-2 flex h-[42px] items-center ltr:right-0 rtl:left-0",children:e.jsx(I,{className:`h-8 text-sm font-bold ${r?"bg-body-dark/10":""}`,theme:r?"white":"primary",shape:r?"text":"solid",type:r?"button":"submit",onClick:y=>{r&&(y.preventDefault(),m())},id:"checkout-apply-coupon","data-testid":"ticketing_summary_coupon_add_button","data-event-name":n==null?void 0:n.title,"data-promo":a,disabled:!c,loading:l,children:s(r?"payment_common:remove":"payment_common:apply")})})]})}),i!=null&&i.message?e.jsx(p,{color:"error",variant:"body-XS",className:"pt-1.5",children:i.message}):null,o?e.jsx("div",{className:"pt-1.5 text-sm text-green-500",children:s(t?"payment_common:coupon_all":"payment_common:coupon_some")}):null]})},Xn={saudi_rewards:Mt},Kn=({className:t,totals:n,isCouponAppliedToAll:s})=>{const{components:a}=F(),{t:r}=R("payment_common"),{options:o,activeType:l,hidden:i,select:c}=Kt();return i?null:e.jsxs("div",{className:t,children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:o.map(u=>{const d=u.value===l,m=Xn[u.value];return e.jsxs(I,{className:"border-paper aria-pressed:border-action shrink-0 px-2 py-1",shape:"outlined",theme:"action","data-testid":`ticketing_summary_redeem_${u.value}`,"aria-pressed":d,shiny:u.value==="saudi_rewards",onClick:()=>c(u.value),children:[m&&e.jsx(m,{"data-qitaf":u.value==="qitaf",className:"h-5 w-5 shrink-0 [&>rect]:data-[qitaf=true]:fill-transparent"}),e.jsx(p,{variant:"label-M",color:d?"text-primary":"text-secondary",children:r(`payment_common:${u.label}`)}),d&&e.jsx(Et,{className:"mt-px h-3 w-3"})]},u.value)})}),e.jsx(ge,{initial:!1,mode:"wait",children:e.jsx(K.div,{className:"max-w-lg overflow-hidden",initial:{height:0},animate:{height:l==="wallet"?0:"auto"},exit:{height:0},children:!!l&&e.jsx("div",{className:"pb-2 pt-4",children:l==="wallet"?null:l==="saudi_rewards"?e.jsx(Rn,{totals:n}):l==="qitaf"?e.jsx($n,{totals:n}):l==="mokafaa"?e.jsx(Qn,{totals:n}):a!=null&&a.CouponForm?e.jsx(a.CouponForm,{}):e.jsx(Gn,{isAppliedToAll:s})})},l)})]})},wa=Kn,Hn=({totals:t})=>{const{saudi_redeem:n}=O(),s=Math.floor(t.net_after_discount),a=!!n&&t.net_after_discount<=0;return t.net_after_discount<=0||a||!n?null:e.jsxs("div",{className:"relative !mt-4 flex items-center gap-2 rounded-md bg-vi
7olet-950 p-2 text-sm text-violet-300",children:[e.jsx("span",{className:"text-lg",children:"🎉"}),e.jsx("div",{children:e.jsx(ae,{i18nKey:"payment_common:earned",values:{earnedPoints:Q(s),count:s},children:e.jsx("span",{className:"text-orange-500"})})}),e.jsx("span",{className:"absolute top-0 h-3 w-3 -translate-y-1.5 rotate-45 bg-violet-950 ltr:right-7 rtl:left-7"})]})},Xe=Hn,Yn=({discount:t})=>t?e.jsxs(H,{surface:"level-1",className:"relative !mt-4 flex items-center gap-2 border-none",children:[e.jsx(p,{children:"🎉"}),e.jsx(p,{variant:"body-S",children:t})]}):null,Ke=Yn,Jn=({usedCredits:t,remainingCredits:n,plan:s})=>{const{isSubscriptionCreditsEnabled:a,setSubscriptionCreditsEnabled:r}=F(),{t:o}=R("ticketing_booking"),l=!n&&!t,i=!n;return b.useEffect(()=>{n&&a===void 0&&r(!0)},[n]),l?null:e.jsxs("label",{"data-disabled":i,className:"space-between flex cursor-pointer items-center justify-between gap-2 rounded-xl data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50",children:[e.jsx(At,{className:"h-6 w-6"}),e.jsxs("div",{children:[e.jsx(p,{variant:"label-M",children:o("payment_common:use_membership_benefits",{plan:o(s,{defaultValue:s})})}),e.jsx(p,{variant:"body-S",color:"text-secondary",children:n>1e4?o("payment_common:unlimited_streams"):o("payment_common:available_streams",{count:n})})]}),e.jsx(Te,{checked:a,onChange:()=>r(!a),disabled:i,hideErrorSpace:!0,groupClassName:"ltr:ml-auto rtl:mr-auto"})]})},Zn=Jn,ea=({totals:t})=>{const{t:n}=R(["payment_common"]),{mokafaa:s,enable_wallet_credits:a}=O();return!(s!=null&&s.otp)||!a||!t.withdrawn_wallet_credits?null:e.jsxs(H,{className:"flex items-center justify-between gap-4 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(p,{variant:"heading-XS",strong:!0,children:[n("payment_common:mokafaa_congratulations")," 🎉"]}),e.jsx(p,{variant:"body-S",color:"text-secondary",children:e.jsx(ae,{i18nKey:"payment_common:mokafaa_ribbon",values:{amount:s.amount||0},children:e.jsx(p,{as:"span",color:"primary",variant:"body-S"})})})]}),e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-white",children:e.jsx("img",{src:"/@wbk/payment/mokafaa-logo.png",alt:""})})]})},He=ea,ta=({title:t,description:n,amount:s,currency:a})=>e.jsxs(p,{as:"div",variant:"body-S",className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex w-full grow items-center gap-2",children:[e.jsx("p",{className:"text-text-secondary",children:t}),n&&e.jsx("div",{className:"relative grow",children:e.jsx(_t,{className:"p-2",side:"bottom",content:e.jsx("div",{className:"text-xs",dangerouslySetInnerHTML:{__html:n}}),children:e.jsx("span",{className:"font-inter bg-paper-level-1 focus:bg-paper-level-2 flex h-5 w-5 items-center justify-center rounded-full focus:outline-none",children:"i"})})})]}),e.jsx(N,{className:"text-text-secondary shrink-0",originalPrice:s,currency:a})]}),Ye=ta,na=({className:t,totals:n,title:s,discount:a,subscriptionCredits:r,redeemTravelNotice:o})=>{var l,i;const{locale:c}=G(),{currencies:u}=ne(),{t:d}=R("payment_common"),{eventCurrency:m,hasCouponDiscount:y,promoCode:f,redeemedPoints:h,showWalletCredit:_,showSaudiRewards:x,showSubscriptionCredits:k,showOrganizerCurrency:j,eventFees:C,vatPercent:M,expanded:T,toggleExpanded:P,mokafaa:S}=en(n),E=u.find(V=>V.shortCode===m),{organizationName:W}=Y();return e.jsxs("div",{className:B("space-y-2",t),children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(Zn,{usedCredits:r.used,remainingCredits:r.remaining,plan:r.plan}),e.jsx(ee,{className:"border-paper !mt-5 border-dashed"})]}),_&&e.jsxs(p,{as:"div",variant:"body-S",color:"success",className:"flex items-center justify-between",children:[e.jsx("p",{children:S!=null&&S.otp&&(S!=null&&S.amount)?d("payment_common:mokafaa_wallet_credit_label",{amount:Q(S.amount)}):d("payment_common:webook_credit",{organizationName:W||"webook.com"})}),e.jsx(N,{originalPrice:-n.withdrawn_wallet_credits,currency:m})]}),o&&e.jsxs(H,{className:"bg-notice text-body-light flex items-center gap-3",children:[e.jsx(Rt,{className:"h-6 w-6 shrink-0"}),e.jsx(p,{variant:"body-S",children:d("payment_common:redeem_travel_notice")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[s||e.jsxs("div",{className:"flex grow items-baseline gap-1","data-testid":"cart-total-amount",children:[e.jsx(p,{variant:"label-L",children:d("payment_common:total")}),e.jsx(p,{variant:"body-XS",color:"text-secondary",children:d("payment_common:vat_included")})]}
7),e.jsx(N,{originalPrice:n.net_after_discount,currency:m,className:"text-xl",changeable:!0})]}),e.jsxs(K.div,{initial:{height:0},animate:{height:T?"auto":0},transition:{duration:.2},className:"space-y-3 overflow-hidden",children:[e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between","data-testid":"cart-subtotal-amount",children:[e.jsx("p",{children:d("payment_common:subtotal")}),e.jsx(N,{originalPrice:n.gross,currency:m})]}),!!n.resale_comission&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between","data-testid":"resale-comission",children:[e.jsx("p",{children:d("payment_common:resell_fees")}),e.jsx(N,{originalPrice:n.resale_comission,currency:m})]}),!!n.tabby_fee&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between","data-testid":"cart-tabby-fee-amount",children:[e.jsx("p",{children:d("payment_common:tabby_fee")}),e.jsx(N,{originalPrice:n.tabby_fee,currency:m})]}),!!((l=n.marketing)!=null&&l.fee)&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between","data-testid":"cart-marketing-fee-amount",children:[e.jsx("p",{children:(i=n.marketing)==null?void 0:i.title}),e.jsx(N,{originalPrice:n.marketing.fee,currency:m})]}),!!n.discount_total&&e.jsxs(p,{as:"div",variant:"body-S",color:"success",className:"flex items-center justify-between",children:[e.jsx("p",{children:y?`${d("payment_common:promo_code")} (${f})`:d("payment_common:discount")}),e.jsx(N,{originalPrice:-n.discount_total,currency:m})]}),C&&!!n.totalFee&&e.jsx(Ye,{title:C.title,description:C.description,amount:n.totalFee,currency:m,"data-testid":"cart-innovation-fee-amount"}),!!n.refund_guarantee_fee&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between","data-testid":"cart-refund-guarantee-label",children:[e.jsx("p",{children:d("payment_common:ticket_protection_fees")}),e.jsx(N,{"data-testid":"cart-refund-guarantee-amount",originalPrice:n.refund_guarantee_fee,currency:m})]}),!!n.whatsapp_reminder_fee&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between","data-testid":"cart-whatsapp-reminder-label",children:[e.jsx("p",{children:d("payment_common:whatsapp_reminders_fees")}),e.jsx(N,{"data-testid":"cart-whatsapp-reminder-amount",originalPrice:n.whatsapp_reminder_fee,currency:m})]}),!!n.vat&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between","data-testid":"cart-vat-label",children:[e.jsx("p",{children:`${d("payment_common:vat")} ${M?`${M}%`:""}`}),e.jsx(N,{"data-testid":"cart-vat-amount",originalPrice:n.vat,currency:m})]}),!!n.shipping_totals&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between",children:[e.jsx("p",{children:d("payment_common:shipping_fee")}),e.jsx(N,{originalPrice:n.shipping_totals})]}),x&&e.jsxs(p,{as:"div",variant:"body-S",color:"success",className:"flex items-center justify-between",children:[e.jsxs("p",{children:[d("payment_common:saudi_rewards")," (",Q(h||0),")"]}),e.jsx(N,{originalPrice:-(n.withdrawn_saudi_rewards||0),currency:m})]}),!!n.security_deposit&&e.jsxs(p,{className:"flex items-center justify-between",color:"success",as:"div",children:[e.jsx("span",{children:d("payment_common:security_deposit")}),e.jsx(N,{originalPrice:n.security_deposit})]}),k&&e.jsxs(p,{as:"div",variant:"body-S",color:"success",className:"flex items-center justify-between",children:[e.jsx("p",{children:d("payment_common:streaming_credits")}),e.jsx(N,{originalPrice:-(n.withdrawn_subscription_credits||0),currency:m})]})]}),e.jsx(Xe,{totals:n}),e.jsx(He,{totals:n}),!!a&&e.jsx(Ke,{discount:a}),j&&e.jsxs("div",{className:"space-y-5 pt-2",children:[e.jsx(ee,{}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx(p,{strong:!0,children:d("payment_common:organizer_currency")}),e.jsx(p,{className:"text-end",strong:!0,children:`${Q(n.net_after_discount)} ${le({currencyCode:m,locale:c})}`})]}),e.jsx(ee,{}),e.jsxs("div",{className:"text-text-secondary flex items-center gap-2 text-sm",children:[e.jsx(de,{className:"h-5 w-5 shrink-0"}),e.jsx(p,{variant:"body-S",children:d("payment_common:organizer_currency_note1")})]}),e.jsxs("div",{className:"text-text-secondary flex items-center gap-2",children:[e.jsx(de,{className:"h-5 w-5 shrink-0"}),e.jsx(p,{variant:"body-S",children:e.jsxs(ae,{i18nKey:"organizer_currency_note2",ns:"payment_common",values:{actual:le({currencyCode:m,locale:c})},children:[e.jsx(ce,{className:"inline"}),e.jsx(ce,{className:"inline",currency:E})]})})]})]}),e.jsx("div",{className:"bg-paper-level-1 absolute bottom-0 left-1/2 h-9 w-52 -translate-x-1/2 overflow-hidden rounded-t-full",children:e.jsx(I,{shape:"text",theme:"action","data-testid":"show-detail
7s-btn",className:"group h-full w-full rounded-none p-0","aria-expanded":T,onClick:P,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"label-S",children:d("payment_common:show_details")}),e.jsx($e,{className:"h-3 w-3 rotate-90 transition-transform group-aria-[expanded=true]:-rotate-90"})]})})})]})},Na=na,aa=({className:t,totals:n,title:s,discount:a})=>{const{event:r,currency:o="SAR",isSubscriptionCreditsEnabled:l}=F(),{locale:i}=G(),{currency:c,active:u,currencies:d}=ne(),{coupon:m,saudi_redeem:y,enable_wallet_credits:f}=O(),{t:h}=R("payment_common"),[_,x]=b.useState(!0),{organizationName:k}=Y(),j=m.discount>0&&!!n.discount_total,C=!!(y!=null&&y.quantity),M=d.find(T=>T.shortCode===o);return e.jsxs("div",{className:B("space-y-2 pt-4",t),children:[e.jsxs(I,{shape:"text",theme:"action",className:"group flex w-full items-center justify-between gap-2 rounded-sm p-0.5","aria-expanded":_,onClick:()=>x(T=>!T),children:[e.jsx(p,{variant:"heading-S",children:h("payment_common:price_details")}),e.jsx($e,{className:"h-4 w-4 rotate-90 transition-transform group-aria-[expanded=true]:-rotate-90"})]}),e.jsxs(K.div,{initial:{height:0},animate:{height:_?"auto":0},transition:{duration:.2},className:"space-y-2 overflow-hidden",children:[f&&!!n.withdrawn_wallet_credits&&e.jsxs(p,{as:"div",variant:"body-S",color:"success",className:"flex items-center justify-between",children:[e.jsx("p",{children:h("payment_common:webook_credit",{organizationName:k||"webook.com"})}),e.jsx(N,{originalPrice:-n.withdrawn_wallet_credits,currency:o})]}),e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between",children:[e.jsx("p",{children:h("payment_common:subtotal")}),e.jsx(N,{originalPrice:n.gross,currency:o})]}),!!n.discount_total&&e.jsxs(p,{as:"div",variant:"body-S",color:"success",className:"flex items-center justify-between",children:[e.jsx("p",{children:j?`${h("payment_common:promo_code")} (${m.promo_code})`:h("payment_common:discount")}),e.jsx(N,{originalPrice:-n.discount_total,currency:o})]}),r.fees&&!!n.totalFee&&e.jsx(Ye,{title:r.fees.title,description:r.fees.description,amount:n.totalFee,currency:o}),!!n.refund_guarantee_fee&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between",children:[e.jsx("p",{children:`${h("payment_common:ticket_protection_fees")}`}),e.jsx(N,{originalPrice:n.refund_guarantee_fee})]}),!!n.whatsapp_reminder_fee&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between",children:[e.jsx("p",{children:`${h("payment_common:whatsapp_reminders_fees")}`}),e.jsx(N,{originalPrice:n.whatsapp_reminder_fee})]}),!!n.vat&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between",children:[e.jsx("p",{children:`${h("payment_common:vat")} ${r!=null&&r.vat_percent?`${r==null?void 0:r.vat_percent}%`:""}`}),e.jsx(N,{originalPrice:n.vat,currency:o})]}),!!n.shipping_totals&&e.jsxs(p,{as:"div",variant:"body-S",color:"text-secondary",className:"flex items-center justify-between",children:[e.jsx("p",{children:`${h("payment_common:shipping_fee")}`}),e.jsx(N,{originalPrice:n.shipping_totals})]}),C&&!!n.withdrawn_saudi_rewards&&e.jsxs(p,{as:"div",variant:"body-S",color:"success",className:"flex items-center justify-between",children:[e.jsxs("p",{children:[h("payment_common:saudi_rewards")," (",Q(y.quantity),")"]}),e.jsx(N,{originalPrice:-n.withdrawn_saudi_rewards,currency:o})]}),!!n.security_deposit&&e.jsxs(p,{className:"flex items-center justify-between",color:"success",as:"div",children:[e.jsx("span",{children:h("payment_common:security_deposit")}),e.jsx(N,{originalPrice:n.security_deposit})]}),l&&!!n.withdrawn_subscription_credits&&e.jsxs(p,{as:"div",variant:"body-S",color:"success",className:"flex items-center justify-between",children:[e.jsx("p",{children:h("payment_common:streaming_credits")}),e.jsx(N,{originalPrice:-n.withdrawn_subscription_credits,currency:o})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[s||e.jsxs("div",{className:"flex grow items-baseline gap-1",children:[e.jsx(p,{variant:"heading-M",children:h("payment_common:total")}),e.jsx(p,{variant:"body-XS",color:"text-secondary",children:h("payment_common:vat_included")})]}
7),e.jsx(N,{originalPrice:n.net_after_discount,currency:o,priceClassName:"text-xl font-semibold",currencyClassName:"text-text-secondary min-w-5 h-5"})]})]}),e.jsx(Xe,{totals:n}),e.jsx(He,{totals:n}),!!a&&e.jsx(Ke,{discount:a}),u&&o!==c.shortCode&&e.jsxs("div",{className:"space-y-5 pt-2",children:[e.jsx(ee,{}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx(p,{strong:!0,children:h("payment_common:organizer_currency")}),e.jsx(p,{className:"text-end",strong:!0,children:`${Q(n.net_after_discount)} ${le({currencyCode:o,locale:i})}`})]}),e.jsx(ee,{}),e.jsxs("div",{className:"text-text-secondary flex items-center gap-2 text-sm",children:[e.jsx(de,{className:"h-5 w-5 shrink-0"}),e.jsx(p,{variant:"body-S",children:h("payment_common:organizer_currency_note1")})]}),e.jsxs("div",{className:"text-text-secondary flex items-center gap-2",children:[e.jsx(de,{className:"h-5 w-5 shrink-0"}),e.jsx(p,{variant:"body-S",children:e.jsxs(ae,{i18nKey:"organizer_currency_note2",ns:"payment_common",values:{actual:le({currencyCode:o,locale:i})},children:[e.jsx(ce,{className:"inline"}),e.jsx(ce,{className:"inline",currency:M})]})})]})]})]})},ka=aa;export{va as B,ga as C,bn as F,_a as M,Ce as P,wa as R,Ye as T,xa as W,ja as a,_n as b,ba as c,ka as d,yn as e,Na as f,rn as i,jn as m,fa as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.