PageSourceSearch

https://fluz.app/assets/GiftCardPurchaseStandalone-1PvIvl5G.js

js fluz.app collected 2026-09-24 08:55:35 UTC 17,025 bytes, 1 lines download raw bytes

1import{j as a}from"./jsx-runtime-Cf8x2fCZ.js";import{S as wt}from"./Sidebar-B86dHUsw.js";import{r as n}from"./index-DVyYOtpF.js";import{a as nt}from"./PurchaseContext-BLEE-h-F.js";import{c as Qe,g as s,S as Ze,E as bt,A as Tt,a as xt,C as Ot,R as vt,D as Pt,G as It,b as Ft}from"./AuthorizationStep-Cb-heQ9S.js";import{c as X}from"./index-CJx4bWmi.js";import{u as st,a as Ut}from"./routes-C9EA_30W.js";import{B as kt}from"./Button-Clh_B6Kd.js";import{f as Je,d as Mt}from"./display-currency-vGF_cvkI.js";import{u as Lt}from"./use-global-navigation-state-BPWgIn1r.js";import{T as et}from"./Tab-CAPOGu6l.js";import{e as tt}from"./index-Dpg_GuLI.js";import{F as Bt}from"./Fetchers-DgNj4GlA.js";import{b as he}from"./offer-BVeSIK9V.js";import{u as jt}from"./useStateList-8cA5AehK.js";import{W as q}from"./Wrapper-yjtMrLTu.js";import{a as rt,u as $t}from"./PaymentMethodsContext-CXAM3HTf.js";import{u as Dt}from"./useBackupPaymentValidation-D10dbkDg.js";import{u as Gt}from"./useAuthLink-B4udCxke.js";import{s as Vt}from"./shouldRenderMerchantCardImage-IzOA1kJA.js";import{u as qt}from"./useAlert-ChR9zHBI.js";import{u as Yt}from"./useVoucherDrawer-B2FlUshX.js";import{u as Ht}from"./index-CqxAvU2H.js";import{a as at}from"./components-SCA3sB3l.js";const zt=["AMOUNT_ENTRY","CONFIRMATION"];function Wt(pe){const{merchant:e,flow:y="regular"}=pe,{addAlert:C}=qt(),u=st(),R=!!u,P=typeof window<"u"?new URLSearchParams(window?.location?.search).get("fullscreen")==="true":!1,d=typeof window<"u"?new URLSearchParams(window?.location?.search).get("partnership"):null,T=e?.exclusive_rate?e?.exclusive_rate:typeof window<"u"?new URLSearchParams(window?.location?.search).get("exclusiveRate"):null,N=e?.initial_amount?e?.initial_quantity:typeof window<"u"?new URLSearchParams(window?.location?.search).get("quantity"):null,Y=e?.scheduled_purchase_frequency?e?.scheduled_purchase_frequency:typeof window<"u"?new URLSearchParams(window?.location?.search).get("scheduleFrequency"):null,H=e?.scheduled_purchase_cycles?e?.scheduled_purchase_cycles:typeof window<"u"?new URLSearchParams(window?.location?.search).get("cycles"):null,I=e?.initial_step?e?.initial_step:typeof window<"u"?new URLSearchParams(window?.location?.search).get("initialStep"):null,A=e?.initial_amount?e?.initial_amount:typeof window<"u"?new URLSearchParams(window?.location?.search).get("initialAmount"):null,K=n.useContext(nt),{dispatch:F,state:{purchaseAmount:U,paymentMethodRates:Ie,bankAccountId:k,purchaseQuantity:g,exclusiveRate:i,applyBalance:r,offers:me,backupBankCardId:w,selectedOffer:M}}=K,{setContextType:_e,setMerchant:ye,setSelectedOffer:Ce,setPaymentMethodRates:Q,setOffers:Z,setAmount:z,setQuantity:J,setExclusiveRate:ee,setExclusiveRateTransactions:te,setScheduleFrequency:ae,setCycles:Re}=F,Ae=Ht(),_=at({key:"merchant-data"}),[f,Fe]=n.useState(!1),[x,ne]=n.useState(),[se,re]=n.useState(!1),[Ee,Ue]=n.useState(),[Ne,ke]=n.useState(),[Se,L]=n.useState(),{getAuthLink:ie}=Gt(),[h,B]=n.useState(),j=rt(),$=j?.combinedPaymentMethods,S=j?.bankCards?.rows||[],[oe,E]=n.useState(""),{activeVouchersCount:Me}=Yt(),ce=at({key:"add-to-bag"}),{refetch:it}=$t(),Le=n.useRef();n.useEffect(()=>{Le.current==="submitting"&&ce.state==="idle"&&it(),Le.current=ce.state},[ce.state]);const D=ce.state==="submitting";n.useEffect(()=>{_e(e?.context_type||"NEW_PURCHASE")},[e?.context_type]),n.useEffect(()=>{Fe(!!T)},[T]);const Be=n.useCallback(t=>{ne(t);const{paymentMethodRates:c,merchantAndOffers:p,partnershipInfo:l,exclusiveRate:m,exclusiveRateTransactions:de}=t,{mappedRateServiceOffers:W,...ue}=p??{};l&&B(l);const fe=f?W?.fixedAndVariableOffersForER:W?.fixedAndVariableOffers,Ct=W?.fixedAndVariableOffers,Rt=W?.fixedAndVariableOffersForER,At=W?.fixedAndVariableOffersForERAll;ye(ue),Z(fe),Ue(Ct),ke(Rt),L(At);const Ye=fe?.fixed,He=Object.values(Ye??{}),ze={...fe?.variable||{},inStock:!0},We=A?Ye?.[A]??ze:void 0,Pe=He.reduce((G,V)=>G?he(V)>he(G)?V:G:V,He?.[0]),v=We?.inStock?We:he(fe?.variable)<he(Pe)&&Pe?.inStock?Pe:ze,Xe=v,Et=Xe?.exclusiveRateId?"exclusive":"standard";if(Ce(v,Et,Xe?.exclusiveRateId),R){if(c&&Q(c),A){if(v?.denominations_type===tt.OfferDenominationType.FIXED&&v?.inStock)z(A,!0);else if(v?.denominations_type!==tt.OfferDenominationType.FIXED){const Nt=v?.offer_rates?.[0]?.denominations?.[0]??"0",St=v?.offer_rates?.[0]?.denominations?.at(-1)??"0",gt=+Nt<=+A&&+St>=+A;z(A,gt)}}const G=ue?.initial_quantity,V=ue?.scheduled_purchase_frequency,Ke=ue?.scheduled_purchase_cycles;G&&g===1&&J(G,!0),V&&ae(V),Ke&&Re(Ke),m&&ee(m),de&&te(de)}},[f,R,_.data,g,e?.exclusive_rate,e?.exclusive_rate_transactions,e?.initial_amount,e?.initial_quantity,e?.scheduled_purchase_cycles,e?.scheduled_purchase_frequency]);n.useEffect(()=>{if(e?.merchantAndOffers)Be(e);else{if(!e?.slug&&e?.merchant_id){C({title:"Error loading offer",bodyText:`There was an error loading this offer. Error code: ${Qe.GiftCardErrorCode.INVALID_STATUS_OR_OWNER}`,state:"error",hiddenErrorCode:_?.data?.error,closeOnClickOutside:!0}),console.warn("no merchant ident",e);return}const t=new URLSearchParams;t.append("merchant-ident",e?.slug||e?.merchant_id),d&&t.append("partnership",d),T&&t.append("exclusiveRate",T),N&&t.append("quantity",N),Y&&t.append("scheduleFrequency",Y),H&&t.append("cycles",H),I&&t.append("initialStep",I),_.load(`${Bt.StandAloneGCPurchase}?${t.toString()}`)}},[T,N,I,e,d,H,Y]),n.useEffect(()=>{if(_?.data?.success===!1&&_?.data?.error){C({title:"Error loading offer",bodyText:`There was an error loading this offer. Error code: ${Qe.GiftCardErrorCode.UNABLE_TO_RETRIEVE}`,state:"error",hiddenErrorCode:_?.data?.error,closeOnClickOutside:!0});return}_.data&&!me&&Be(_.data)},[_.data]);const le=n.useMemo(()=>{const t=[...zt];if(!R)return t.splice(1,0,"AUTHORIZATION"),t;const c=t.pop();return t.push("RECURRING_PAYMENT"),t.push(c),i&&(i?.exclusiveRate?.tiers?.length??0)>0&&t.unshift("EXCLUSIVE_RATE"),t.push("DECLINED_PURCHASE"),t},[R,i]),{step:o,next:ge,prev:je,setStep:O}=jt(le,R?"AMOUNT_ENTRY":void 0),ot=n.useMemo(()=>{const t=e?.name||e?.merchantName||e?.merchant_name,c=t?.trim(),p=c&&/^[aeiou]/i.test(c)?"an":"a",l=c?`${c}
1 gift card`:"gift card";switch(o){case"EXCLUSIVE_RATE":return{title:t||"",description:"Reach the spend goal to unlock additional cashback."};case"AMOUNT_ENTRY":return{title:"Buy a gift card",description:`Select an amount to purchase ${p} ${l}.`};case"AUTHORIZATION":return{title:"Authorization",description:"Authorize"};case"CONFIRMATION":return{title:D?"Generating card...":"Review purchase",description:D?"This will only take a second":`${t} gift card`};case"RECURRING_PAYMENT":return{title:"Recurring payment",description:""};case"DECLINED_PURCHASE":return{title:"Error generating card",description:""};default:return{title:"",description:""}}},[o,e?.name,e?.merchantName,e?.merchant_name,f,i,D]),we=n.useMemo(()=>{if(o==="AMOUNT_ENTRY"&&le.includes("EXCLUSIVE_RATE")||o==="CONFIRMATION"||o==="RECURRING_PAYMENT"||o==="AUTHORIZATION")return je},[je,o,le]),ct=n.useCallback(()=>{re(!0)},[]),$e=t=>x?.[t]||void 0,De=$e("nonKycTransactionLimit"),{finalSpendPower:lt,tierLimitAmount:dt}=n.useMemo(()=>{const t=$?.find(c=>c.bank_account_id===k);return{finalSpendPower:t?.spend_power?.final_spend_power,tierLimitAmount:t?.spend_power?.tier_limits?.available_tier_limit}},[k,$]),be={};u?.user_payment_preferences&&u.user_payment_preferences.forEach(t=>{be[t.payment_method_role]=t});const Te=o==="AMOUNT_ENTRY"&&!r&&y!=="withdraw"&&!!k,ut=be?.backup_payment_method?.payment_method_id,xe=w||ut,b=Dt(Te,U*g,xe,k,S.map(t=>({bank_card_id:t.bank_card_id,card_status:t.card_status})),$),{uac:Ge,hasFundableSpendAccount:ft}=Ut("root"),ht=!Ge?.canPurchaseGiftCardWithAccountBalance&&!Ge?.canPurchaseGiftCardWithFundingSource&&!!ft,Oe=($?.length??0)!==0||ht,pt=f&&["AMOUNT_ENTRY","EXCLUSIVE_RATE"].includes(o),mt=U*g,ve=De?.isAmountForUnverifiedUser&&De.amount-mt<0,Ve=n.useCallback(()=>{window.dispatchEvent(new CustomEvent(q.KYC,{detail:{open:!0,eventName:q.KYC,onFailFn:()=>console.log("Fail"),onSuccessFn:()=>{}}}))},[]);n.useEffect(()=>{const t=b.totalAboveBackupLimit&&Te&&b.requiresBackupCard;F.setShowAddBackup(t)},[b.totalAboveBackupLimit,b.requiresBackupCard,Te]);const qe=n.useCallback(t=>{const{requiresBackupCard:c}=b;if(c){let p="Selected Bank Account";const l=b.selectedAccount;if(l){const m=l.nickname?l.nickname:l.account_name,de=l.last_four?`****${l.last_four}`:"";p=`${m} ${de}`}window.dispatchEvent(new CustomEvent(q.MANAGE_BACKUP_ACCOUNT,{detail:{open:!0,eventName:q.MANAGE_BACKUP_ACCOUNT,customProps:{availableOptions:S,selectedOption:S?.find(m=>m.bank_card_id===xe),customHeaderTitle:"Backup funding source required",customHeaderSubtitle:`To reattempt this transaction and to continue to use ${p} in the future, add or select a backup funding source.`,logo:{url:e?.logo_url,character:e?.name?.[0],showAlert:!0},flow:"PURCHASE"},onSuccessFn:m=>{m&&typeof m=="string"&&F.setBackupCardId(m)}}}));return}O(t)},[xe,b,S,e?.logo_url,e?.name,O]),_t=n.useMemo(()=>{const t=M?.offer_rates?.[0]?.cashback_voucher_reward_value,c=t!==void 0?Number(t)>=10:!1,p=Me&&c,l=e?Vt(e):!1,m=!D&&o==="CONFIRMATION"&&(!h?.enabled||!P)||o==="AMOUNT_ENTRY"&&f&&!i?.instant_rate||o==="AMOUNT_ENTRY"&&!!we||o==="RECURRING_PAYMENT";return{boostAvailable:p,shouldRenderCardImage:l,showBackButton:m}},[M?.offer_rates,Me,e,D,o,h?.enabled,f,i?.instant_rate,we,P]),yt=n.useCallback(()=>{if(y!=="withdraw"){if(!R&&o==="AMOUNT_ENTRY"){const t=Je(U,{minimumFractionDigits:1,style:"currency",currency:"USD"}),c=h??"",p=h?.enabled?`&partnership=${c}`:"",l=`${window.location.pathname}?amount=${t}&quantity=${g}${p}`;E(ie({overriddenRedirectToLink:l,isIframe:!0})),ge();return}if(o==="AUTHORIZATION"){if($?.length>0){O("AMOUNT_ENTRY");return}const t=Je(U,{minimumFractionDigits:1,style:"currency",currency:"USD"}),c=h??"",p=h?.enabled?`&partnership=${c}`:"",l=`${window.location.pathname}?amount=${t}&quantity=${g}&fullscreen=true${p}`;O("CONFIRMATION"),Ae(l);return}if(o==="AMOUNT_ENTRY")if(ve){Ve();return}else{qe("CONFIRMATION");return}if(!u?.user_pin_code&&Oe){se||window.dispatchEvent(new CustomEvent(q.CHANGE_PIN,{detail:{open:!0,eventName:q.CHANGE_PIN,customProps:{userCurrentPinHash:u?.user_pin_code},onFailFn:()=>null,onSuccessFn:()=>re(!0)}})),O("CONFIRMATION");return}ge()}},[y,o,u?.user_pin_code,Oe,ge,ve,qe,se,O]);return{merchant:K.state.merchant??e,flow:y,isExclusiveRate:f,exclusiveRate:i,fullMerchant:x,standardOffers:Ee,exclusiveRateOffers:Ne,exclusiveRateOffersAll:Se,headerLabels:ot,isCardGenerating:D,step:o,steps:le,setStep:O,onBack:we,hasFunding:Oe,backupPaymentValidation:b,handleFooterNext:yt,handleGetVerified:Ve,showExclusiveRateBadge:pt,getFullPurchaseInfo:$e,preferredPaymentMethods:be,onSuccesfulFundingSourceCreation:ct,finalSpendPower:lt,nonKYC_reachedLimit:ve,tierLimitAmount:dt,partnershipInfo:h,authLink:oe,conditionFlags:_t,fullscreen:P}}const Xt=1e3;function Ea(pe){const{onClose:e,flow:y="regular",merchant:C}=pe,{merchant:u,headerLabels:R,isCardGenerating:P,step:d,steps:T,setStep:N,onBack:Y,hasFunding:H,backupPaymentValidation:I,handleFooterNext:A,handleGetVerified:K,preferredPaymentMethods:F,onSuccesfulFundingSourceCreation:U,finalSpendPower:Ie,nonKYC_reachedLimit:k,tierLimitAmount:g,getFullPurchaseInfo:i,partnershipInfo:r,authLink:me,fullscreen:w,conditionFlags:M,exclusiveRateOffers:_e,exclusiveRateOffersAll:ye,standardOffers:Ce}=Wt({merchant:C,flow:y}),Q=C?.exclusive_rate,Z=C?.initial_amount,z=C?.initial_quantity,J=C?.scheduled_purchase_frequency,ee=C?.scheduled_purchase_cycles,te=C?.initial_step,ae=Lt(),Re=ae.includes("loading")||ae.includes("submitting"),[Ae,_]=n.useState(!1),[f,Fe]=n.useState(typeof window<"u"?window?.location?.pathname:""),x=st(),ne=!!x,se=n.useContext(nt),{dispatch:re,state:{purchaseAmount:Ee,paymentMethodRates:Ue,purchaseQuantity:Ne,selectedOffer:ke}}=se,{setDeclineCode:Se}=re,L=n.useCallback(()=>
1{if(f&&window.history.replaceState({},"",f),e)return e();setTimeout(()=>{Se(null)},Xt)},[e,f]);n.useEffect(()=>{if(typeof window>"u")return;const oe=window?.location?.pathname;if(oe.includes("/buy-gift-card")||oe.includes("/fluz-gift-card/"))return;const E=new URLSearchParams;Q&&E.append("exclusiveRate",Q),z&&E.append("quantity",""+z),Z&&E.append("amount",""+Z),J&&E.append("scheduleFrequency",J),ee&&E.append("cycles",""+ee),te&&E.append("initialStep",te),window.history.replaceState({},"",`/store/${u?.slug||u?.merchant_id}/buy-gift-card${E.size>0?"?"+E.toString():""}`)},[u?.slug,u?.merchant_id,f]);const ie=n.useMemo(()=>u?.logo_url,[u]),[h,B]=n.useState("OFFER_DETAILS"),j=n.useRef(null),S=rt()?.combinedPaymentMethods;return a.jsxs(wt,{open:!0,onSideBarClose:L,closeOnBackdropClick:!0,sideBarContentWrapperClasses:s["content-wrapper"],sideBarChildrenWrapperClasses:X(s["children-wrapper"]),innerModalBodyClassNames:s["inner-modal-body"],customFooterContainerClasses:s["footer-mobile-container"],contentRef:j,CustomFooter:a.jsx(Ft,{disableNext:!H&&ne||I.totalAboveBackupLimit&&I.requiresBackupCard,steps:T,setStep:N,onNextStep:A,onGetVerified:K,step:d,loading:!1,showGetVerified:k,onClose:L,flow:y,payments:S}),sideBarFooterClasses:s["sidebar-footer"],CustomHeader:a.jsx(It,{step:d,setStep:N,loading:P,tab:h,setTab:B,onBack:Y,flow:y,onClose:L,scrollbarRef:j,conditionFlags:M,headerLabels:R}),SubBodyComponent:r&&r?.enabled&&d==="AMOUNT_ENTRY"&&a.jsxs("div",{className:s["partnership-info-container"],children:[a.jsxs("div",{className:X(s["partnership-info"],{[s.fullscreen]:w}),children:[w&&a.jsx("h4",{className:s["partnership-info-header"],children:"Please note"}),r.isBusiness?a.jsxs("p",{className:s["partnership-info-text"],children:[w?`Any charge will show as ’${r.businessName}’ on your credit statement.`:`Please note: any charge will show as ’${r.businessName}’ on your credit statement.`,a.jsx("br",{}),r.businessPhone?`T: ${r.businessPhone} · `:r.phone?`T: ${r.phone} · `:"",r.email?`E: ${r.email}`:"",r.businessAddress?` · ${r.businessAddress}`:""]}):a.jsxs("p",{className:s["partnership-info-text"],children:[w?`Any charge will show as ’${r.name}’ on your credit statement.`:`Please note: any charge will show as ’${r.name}’ on your credit statement.`,a.jsx("br",{}),r.phone?`T: ${r.phone} · `:"","E: ",r.email,r.address?` · ${r.address}`:""]})]}),!w&&a.jsxs("div",{className:s["powered-by-fluz"],children:["Powered by",a.jsx(Ze,{width:"27px",height:"auto"})]})]}),children:[a.jsxs("div",{className:X(s["title-container"],{[s["hide-border-bottom"]]:d==="EXCLUSIVE_RATE"}),children:[a.jsxs("div",{children:[a.jsx("div",{className:s["primary-label"],children:R.title}),a.jsx("div",{className:s["secondary-label"],children:R.description}),d==="RECURRING_PAYMENT"&&a.jsxs("div",{className:s["recurring-payment-badge"],children:[a.jsx(kt,{hierarchy:"custom-fill",customFillBackgroundColor:"yellow",label:"Edit",rightSlot:"EditEmph",size:"xs",onClick:()=>{N("AMOUNT_ENTRY")}}),a.jsxs("div",{className:s["primary-label"],children:[Mt(Ee*Ne)," total "]})]})]}),!!ie&&a.jsx("img",{className:s["title-image"],src:ie,alt:"gift-card-lg-landscape"})]}),d==="EXCLUSIVE_RATE"&&a.jsxs("div",{className:s.tabs,children:[a.jsx(et,{label:"Offer details",active:h==="OFFER_DETAILS",onClick:()=>{B("OFFER_DETAILS")},gradient:"dual4"}),a.jsx(et,{label:"Transaction history",active:h==="TRANSACTION_HISTORY",onClick:()=>{B("TRANSACTION_HISTORY")},gradient:"dual4"})]}),w&&a.jsx("div",{className:s["header-root"],children:a.jsx("div",{className:s["header-actions"],children:a.jsx("div",{className:X(s["logo-container"],{[s.partnership]:r?.enabled}),children:a.jsxs("a",{href:"https://fluz.app",className:s.logo,children:[r?.enabled?"Powered by":"",a.jsx(Ze,{...r?.enabled?{width:"40px",height:"auto"}:{style:M.showBackButton?{marginLeft:"12px"}:void 0}})]})})})}),d==="EXCLUSIVE_RATE"&&a.jsx(bt,{tab:h,setTab:B}),d==="AUTHORIZATION"&&a.jsx(Tt,{link:me,next:A}),a.jsx("div",{className:X(s["full-height"],{[s["hidden-step"]]:d!=="AMOUNT_ENTRY"}),children:a.jsx(xt,{totalAvailableBalance:i("total_available_balance"),restrictedPaymentMethods:i("restrictedPaymentMethods"),paymentMethodRates:i("paymentMethodRates"),availableDenominations:i("availableDenominations"),preferredPaymentMethods:F,defaultBINOverage:i("defaultBINOverage"),setIsCreatingFundingSource:_,isCreatingFundingSource:Ae||Re,userAddresses:i("userAddresses"),onFundingSourceSuccess:U,isLoggedIn:ne,spendingStats:i("spendingStats"),setStep:N,finalSpendPower:Ie,tierLimitAmount:g,fluzPayOnly:y==="withdraw",flow:y,withdrawalData:void 0,hasPinCode:!!x?.user_pin_code,spendAccounts:i("spendAccounts")||[],fundableSpendAccountIds:i("fundableSpendAccountIds"),balance:x?.balance,payments:S,standardOffers:Ce,exclusiveRateOffers:_e,exclusiveRateOffersAll:ye,scrollC
1ontainerRef:j})}),d==="CONFIRMATION"&&a.jsx(Ot,{loading:P,user:x,btClientToken:i("btClientToken"),preferredPaymentMethods:F,setStep:N,payments:S,onClose:L,vouchers:i("vouchers")??[],boostAvailable:!!M.boostAvailable}),d==="RECURRING_PAYMENT"&&a.jsx(vt,{}),d==="DECLINED_PURCHASE"&&a.jsx(Pt,{payments:S,merchantName:u?.name||""})]})}export{Ea as G};

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.