1import{u as e,r as s,W as a,X as r,j as l}from"./main.1.45.0.js";import{L as t,W as i,H as o}from"./loyalty-login-prompt.component-B7GqSOSV.js";import{u as n,f as d,t as m,e as c}from"./loyalty-enrollment-form.component-j-q3BYWu.js";import"./button.component-XeC76gV5.js";import"./text-field.component-7Oz7seAU.js";import{U as _}from"./chip.component-Dao3K2Ky.js";import{S as u}from"./Skeleton-aIUMGYlj.js";import"./createSvgIcon-BKM72nfj.js";import"./DefaultPropsProvider-C2syA4QN.js";import"./LocalOffer-CaV4pcPm.js";import"./Typography-C-divtet.js";import"./Close-DmkQrzuU.js";import"./utils-DvjLjrK8.js";import"./inheritsLoose-Cagl8Uqp.js";import"./assertThisInitialized-PUtynf78.js";import"./Dialog-C1imcgja.js";import"./Paper-DpdCpDyz.js";import"./Slide-B1dyqnE5.js";import"./CircularProgress-d2-jiF45.js";import"./index-BzcYWA6j.js";import"./useSlot-uG0WYWb0.js";import"./Close-BPe70H7B.js";import"./FormControlLabel-C7OT43qt.js";import"./Stack-OSSMca52.js";import"./clsx-BeLtu-UY.js";import"./useThemeProps-CilF4Ygb.js";import"./getThemeProps-Hzf5EfZS.js";import"./Checkbox-CLrJ0rDN.js";import"./TextField-DuBg8nH-.js";import"./Button-D9wQSZ3k.js";const p="rewards-module__page___XqT5K",j="rewards-module__hero___Z3-Yr",h="rewards-module__heroNumber___MHoIP",x="rewards-module__heroLabel___N1Mjo",w="rewards-module__badges___rLUfi",N="rewards-module__tier___QqsT8",v="rewards-module__tierLabel___4WT2e",f="rewards-module__tierBar___kWNAH",g="rewards-module__tierFill___-5jWF",y="rewards-module__skeleton___tnAWj",b="rewards-module__section___Av5UF",P="rewards-module__sectionTitle___Vgc1e",S="rewards-module__message___wvP20",C="rewards-module__rewards___HAaFT",T="rewards-module__reward___ffiTX",D="rewards-module__rewardName___wJJ6W",W="rewards-module__rewardCost___xuDxL",F="rewards-module__timeline___Zb62X",L="rewards-module__event___SNLPY",R="rewards-module__eventMain___6y6uD",A="rewards-module__eventDesc___SwrWF",M="rewards-module__eventDate___t1DFo",z="rewards-module__eventPositive___-agPC",E="rewards-module__eventNegative___00zZ0";function k({config:k}){var H,I,X,U,Z,q,B,V,Y;const{loyaltyEnabled:J,rewardRedemptionEnabled:Q}=n("rewards_page"),$=e((e=>e.customer.loyalty)),{events:K,loading:O,error:G}=function(){const r=e((e=>e.customer.loyalty)),l="connected"===r.connectionStatus,t=r.loyaltyId,[i,o]=s.useState([]),[n,d]=s.useState(!1),[m,c]=s.useState(null);return s.useEffect((()=>{if(!l||!t)return;let e=!0;return d(!0),c(null),a.getPointsTimeline(t).then((s=>{e&&o(s)})).catch((()=>{e&&c("We couldn't load your points history.")})).finally((()=>{e&&d(!1)})),()=>{e=!1}}),[l,t]),{events:i,loading:n,error:m}}(),ee="connected"===$.connectionStatus,se=$.wallet,ae=s.useRef(!1);if(s.useEffect((()=>{var e,s;if(!J||!ee||!se||ae.current)return;ae.current=!0;const a=null!=(e=se.discountTemplates)?e:[],l=Number(null!=(s=se.loyaltyPoints)?s:0);r({surface:"rewards_page",rewardCount:a.length,eligibleRewardCount:a.filter((e=>{var s;return Number(null!=(s=e.pointsDeduction)?s:0)<=l})).length,pointsBalance:l,rewardRedemptionEnabled:Q})}),[J,ee,se,Q]),!J)return null;if(!ee)return l.jsx("div",{className:p,children:l.jsx(t,{storeName:null==k?void 0:k.storeName,surface:"rewards_page"})});const re=null!=(I=null==(H=$.wallet)?void 0:H.loyaltyPoints)?I:0,le=function(e,s){var a;if(!s||0===s.length)return null;const r=[...s].sort(((e,s)=>e.points-s.points)),l=r.find((s=>s.points>e));if(!l)return null;const t=[...r].reverse().find((s=>s.points<=e)),i=null!=(a=null==t?void 0:t.points)?a:0,o=Math.max(1,l.points-i);return{pct:Math.min(100,Math.max(0,(e-i)/o*100)),remaining:l.points-e}}(re,null==(X=$.programDetails)?void 0:X.tiers),te=null!=(Z=null==(U=$.wallet)?void 0:U.discountTemplates)?Z:[],ie=!$.wallet&&"loading"===$.walletStatus;return l.jsxs("div",{className:p,children:[l.jsxs("section",{className:j,children:[l.jsx("span",{className:h,children:ie?l.jsx(u,{variant:"text",width:120,className:y,sx:{mx:"auto"}}):d(re)}),l.jsx("span",{className:x,children:"Points balance"}),((null==(q=$.wallet)?void 0:q.top20)||(null==(B=$.wallet)?void 0:B.repeatCustomer))&&l.jsxs("div",{className:w,children:[(null==(V=$.wallet)?void 0:V.top20)&&l.jsx(_,{label:"VIP",color:"secondary-light",variant:"filled",size:"small",icon:l.jsx(i,{color:"inherit",fontSize:"small"})}),(null==(Y=$.wallet)?void 0:Y.repeatCustomer)&&l.jsx(_,{label:"Repeat Customer",color:"secondary-light",variant:"filled",size:"small",icon:l.jsx(o,{color:"inherit",fontSize:"small"})})]})]}),le&&l.jsxs("section",{className:N,children:[l.jsxs("div",{className:v,children:[l.jsx("span",{children:"Next reward"}),l.jsxs("span",{children:[d(le.remaining)," pts to go"]})]}),l.jsx("div",{className:f,children:l.jsx("div",{className:g,style:{width:`${le.pct}%`}})})]}),ie&&l.jsxs("section",{className:b,children:[l.jsx("h2",{className:P,children:"Available rewards"}),l.jsx("div",{className:C,children:[0,1].map((e=>l.jsx(u,{variant:"text",height:28,className:y},e)))})]}),!ie&&te.length>0&&l.jsxs("section",{className:b,children:[l.jsx("h2",{className:P,children:"Available rewards"}),l.jsx("ul",{className:C,children:te.map((e=>l.jsxs("li",{className:T,children:[l.jsx("span",{className:D,children:e.name}),e.pointsDeduction>0&&l.jsxs("span",{className:W,children:[d(e.pointsDeduction)," pts"]})]},e.id)))})]}),l.jsxs("section",{className:b,children:[l.jsx("h2",{className:P,children:"Points activity"}),O&&l.jsx("div",{className:F,children:[0,1,2].map((e=>l.jsx(u,{variant:"text",height:28,className:y},e)))}),!O&&G&&l.jsx("p",{className:S,children:G}),!O&&!G&&0===K.length&&l.jsx("p",{className:S,children:"No points activity yet."}),!O&&!G&&K.length>0&&l.jsx("ul",{className:F,children:K.map((e=>l.jsxs("li",{className:L,children:[l.jsxs("div",{className:R,children:[l.jsx("span",{className:A,children:e.description||m(e.type)}),l.jsx("span",{className:M,children:c(e.timestamp)})]}),l.jsxs("span",{className:e.pointsChange>=0?z:E,children:[e.pointsChange>=0?"+":"",d(e.pointsChange)]})]},e.id)))})]})]})}function H({config:e}){return l.jsx(k,{config:e})}k.displayName="RewardsPage",H.displayName="RewardsApp";export{H as default};
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.