1"use strict";(self.webpackChunkthor_app=self.webpackChunkthor_app||[]).push([[6246],{88169:function(e,t,n){n.d(t,{T:function(){return o}});var i=n(62415),a=n(92674);function s(e,t){if(1&e&&(i.\u0275\u0275elementStart(0,"span",4),i.\u0275\u0275text(1),i.\u0275\u0275elementEnd()),2&e){const e=i.\u0275\u0275nextContext();i.\u0275\u0275advance(1),i.\u0275\u0275textInterpolate(e.beforeText)}}function r(e,t){if(1&e&&(i.\u0275\u0275elementStart(0,"span",5),i.\u0275\u0275text(1),i.\u0275\u0275elementEnd()),2&e){const e=i.\u0275\u0275nextContext();i.\u0275\u0275advance(1),i.\u0275\u0275textInterpolate(e.afterText)}}let o=(()=>{class e{constructor(){this.disabled=!1,this.beforeText="",this.afterText="",this.applePayClick=new i.EventEmitter}onClick(){this.disabled||this.applePayClick.emit()}}return e.\u0275fac=function(t){return new(t||e)},e.\u0275cmp=i.\u0275\u0275defineComponent({type:e,selectors:[["apple-pay-express-button"]],inputs:{disabled:"disabled",beforeText:"beforeText",afterText:"afterText"},outputs:{applePayClick:"applePayClick"},decls:5,vars:4,consts:[["type","button",1,"apple-pay-express-btn",3,"disabled","click"],["class","btn-before",4,"ngIf"],[1,"btn-logo"],["class","btn-after",4,"ngIf"],[1,"btn-before"],[1,"btn-after"]],template:function(e,t){1&e&&(i.\u0275\u0275elementStart(0,"button",0),i.\u0275\u0275listener("click",function(){return t.onClick()}),i.\u0275\u0275template(1,s,2,1,"span",1),i.\u0275\u0275elementStart(2,"span",2),i.\u0275\u0275text(3,"Pay"),i.\u0275\u0275elementEnd(),i.\u0275\u0275template(4,r,2,1,"span",3),i.\u0275\u0275elementEnd()),2&e&&(i.\u0275\u0275property("disabled",t.disabled),i.\u0275\u0275attribute("aria-label","Checkout with Apple Pay"),i.\u0275\u0275advance(1),i.\u0275\u0275property("ngIf",t.beforeText),i.\u0275\u0275advance(3),i.\u0275\u0275property("ngIf",t.afterText))},directives:[a.O5],styles:['@charset "UTF-8";@-webkit-keyframes pulse{50%{opacity:.5}}@keyframes pulse{50%{opacity:.5}}@-webkit-keyframes loading-skeleton{0%{background-position:200% 0}to{background-position:-200% 0}}@keyframes loading-skeleton{0%{background-position:200% 0}to{background-position:-200% 0}}.apple-pay-express-btn[_ngcontent-%COMP%]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;vertical-align:middle;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;width:100%;height:48px;border:none;border-radius:4px;background-color:#000;color:#fff;cursor:pointer;padding:0 24px;grid-gap:2px;gap:2px;margin-top:10px}.apple-pay-express-btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.loading[_nghost-%COMP%] .apple-pay-express-btn[_ngcontent-%COMP%]{background:-webkit-gradient(linear,left top,right top,color-stop(25%,#e0e0e0),color-stop(50%,#f0f0f0),color-stop(75%,#e0e0e0));background:linear-gradient(90deg,#e0e0e0 25%,#f0f0f0 50%,#e0e0e0 75%);background-size:200% 100%;-webkit-animation:loading-skeleton 1.5s infinite;animation:loading-skeleton 1.5s infinite;opacity:1}.loading[_nghost-%COMP%] .apple-pay-express-btn[_ngcontent-%COMP%] .btn-before[_ngcontent-%COMP%], .loading[_nghost-%COMP%] .apple-pay-express-btn[_ngcontent-%COMP%] .btn-logo[_ngcontent-%COMP%], .loading[_nghost-%COMP%] .apple-pay-express-btn[_ngcontent-%COMP%] .btn-after[_ngcontent-%COMP%]{visibility:hidden}.btn-before[_ngcontent-%COMP%], .btn-after[_ngcontent-%COMP%]{font-size:16px;font-weight:500;color:#fff}.btn-before[_ngcontent-%COMP%]{margin-right:4px}.btn-after[_ngcontent-%COMP%]{margin-left:4px}.btn-logo[_ngcontent-%COMP%]{font-size:18px;font-weight:600;letter-spacing:-.3px;color:#fff}.btn-logo[_ngcontent-%COMP%]:before{content:"\\f8ff";font-family:"Apple Color Emoji",-apple-system,BlinkMacSystemFont,sans-serif;margin-left:2px;margin-right:2px;font-size:20px}']}),e})()},75765:function(e,t,n){n.d(t,{F:function(){return s}});var i=n(92674),a=n(62415);let s=(()=>{class e{}return e.\u0275fac=function(t){return new(t||e)},e.\u0275mod=a.\u0275\u0275defineNgModule({type:e}),e.\u0275inj=a.\u0275\u0275defineInjector({imports:[[i.ez]]}),e})()},67060:function(e,t,n){n.d(t,{R:function(){return f}});var i=n(85572),a=n(70013),s=n(70966),r=n(36047),o=n(62415),l=n(877),d=n(14905),c=n(17291),p=n(13074),h=n(17419),m=n(38592),u=n(36951),g=n(64084),y=n(68076);let f=(()=>{class e{constructor(e,t,n,i,a,s,r,o,l,d){this.stripeService=e,this.basketService=t,this.shareData=n,this.segmentService=i,this.router=a,this.store=s,this.api=r,this.endpoint=o,this.Authentication=l,this.analytics=d,this.applePayTrigger=!1,this.isAvailable=!0,this.selectedDeliveryOptionId=null,this.requestedDeliveryDate=null}
1getGroupedBasketItems(e,t,n){const i=this.basketService.getFullBasket(),a={};return(i||[]).forEach(e=>{var t,n,i,s;const r=(null===(n=null===(t=e.cards)||void 0===t?void 0:t[0])||void 0===n?void 0:n.format)||e.format||"",o=(null===(s=null===(i=e.cards)||void 0===i?void 0:i[0])||void 0===s?void 0:s.quantity)||1;a[r]=(a[r]||0)+o}),Object.entries(a).map(([i,a])=>({product_id:i,quantity:a,recipient_type:e,address:{postcode:t,country_code:n,postcode_prefix:t}}))}checkAvailability(e){return(0,i.mG)(this,void 0,void 0,function*(){if(!(yield this.basketService.isBasketReady()))return!1;const{available:t}=yield this.stripeService.applePayExpressCheck(e);return t&&(this.isAvailable=!0),t})}initExpressCheckout(e,t,n,a,s,r,o){return(0,i.mG)(this,void 0,void 0,function*(){if(this.requestedDeliveryDate=o||null,!this.isAvailable)return void this.shareData.trigger("showError","Apple Pay is not available on this device");const l=this.stripeService.createExpressPaymentRequest(t||"0",n,void 0,a);l&&(yield l.canMakePayment())?(l.on("cancel",()=>{this.segmentService.trackCustom({name:"Apple Pay Express Checkout Cancelled",data:{}}),this.applePayTrigger=!1}),l.on("shippingaddresschange",n=>(0,i.mG)(this,void 0,void 0,function*(){try{const i=n.shippingAddress||{},a=i.postalCode||i.postal_code||"",s=i.country||i.countryCode||"GB",o=yield this.fetchDeliveryOptions(e,a,s);if(!o.length)return void n.updateWith({status:"invalid_shipping_address"});const l=o[0];this.selectedDeliveryOptionId=(null==l?void 0:l.id)||null;const d=Math.round(100*Number(t)),c=(null==l?void 0:l.amount)||0,p=(null==r?void 0:r.amount)?Math.round(100*r.amount):0;n.updateWith({status:"success",shippingOptions:o,displayItems:this.buildDisplayItems(d,c,r),total:{label:"Thortful LTD",amount:d+c-p}})}catch(i){n.updateWith({status:"invalid_shipping_address"})}})),l.on("shippingoptionchange",e=>{const n=e.shippingOption;this.selectedDeliveryOptionId=(null==n?void 0:n.id)||null;const i=Math.round(100*Number(t)),a=(null==n?void 0:n.amount)||0,s=(null==r?void 0:r.amount)?Math.round(100*r.amount):0;e.updateWith({status:"success",displayItems:this.buildDisplayItems(i,a,r),total:{label:"Thortful LTD",amount:i+a-s}})}),!this.applePayTrigger&&(this.applePayTrigger=!0,l.on("paymentmethod",t=>{this.applePayTrigger=!1,n?this.Authentication.signInGuest(t.payerEmail,!0).then(()=>(0,i.mG)(this,void 0,void 0,function*(){yield this.basketService.pushLocalBasketToApiAsync().then(()=>{this.processExpressOrder(t,e,s)})})).catch(e=>{var n;t.complete("fail");const i=(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.message)||"Something went wrong with your payment. Please try again.";this.shareData.trigger("showError",i)}):this.processExpressOrder(t,e,s)}),l.show(),this.segmentService.trackCustom({name:"Apple Pay Express Checkout Sheet Displayed",data:{}}))):this.shareData.trigger("showError","Apple Pay is not available on this device")})}fetchDeliveryOptions(e,t,n){return(0,i.mG)(this,void 0,void 0,function*(){const a=this.getGroupedBasketItems("HOME_FILL"===e?"home_fill":"direct_send",t,n);try{const e=yield this.api.request(this.endpoint.deliveryOptions,{method:"POST",data:{items:a},useApiKeys:!0},!0).toPromise(),t=(null==e?void 0:e.delivery_options)||[],n=(Array.isArray(t)?t:[]).map(e=>{var t;const n=null===(t=e.products)||void 0===t?void 0:t[0],i=(null==n?void 0:n.cost)||0,a=(null==n?void 0:n.default_delivery_option)||!1;return{id:e.id||"standard",label:e.name||"Standard Delivery",detail
1:this.requestedDeliveryDate?"Arrives "+this.formatScheduledDate(this.requestedDeliveryDate):"Estimated "+this.getEstimatedDateString(e),amount:Math.round(100*i),_isDefault:a}});return n.sort((e,t)=>(t._isDefault?1:0)-(e._isDefault?1:0)),n.map(e=>(0,i._T)(e,["_isDefault"]))}catch(s){return[]}})}fetchExcludedDeliveryDates(){return(0,i.mG)(this,void 0,void 0,function*(){const e=this.getGroupedBasketItems("direct_send","SW1","GB");if(!e.length)return[];try{const t=yield this.api.request(this.endpoint.deliveryOptions,{method:"POST",data:{items:e},useApiKeys:!0},!0).toPromise(),n=((null==t?void 0:t.delivery_options)||[]).map(e=>e.excluded_delivery_days||[]).filter(e=>e.length>0);return n.length?n.reduce((e,t)=>e.filter(e=>t.includes(e))):[]}catch(t){return[]}})}processExpressOrder(e,t,n){var i;const o=(null===(i=e.paymentMethod)||void 0===i?void 0:i.billing_details)||{},l=o.address||{},d={payment_request:{payment_method:e.paymentMethod,payment_method_type:"STRIPE",brand:"apple",currency:"GBP"},billing_address:{name:o.name||"",email:o.email||"",phone:o.phone||"",line1:l.line1||"",line2:l.line2||"",city:l.city||"",state:l.state||"",postal_code:l.postal_code||"",country:l.country||""},discount_code:n||null,use_credits:!1,apply_donation:!1,checkout_flow:"APPLE_PAY_EXPRESS_CHECKOUT"};this.basketService.getCheckoutBasketApi().then(()=>{var n,i,a;this.basketService.setGroupedBasketRecipientType("HOME_FILL"===t?"home_fill":"direct_send");const s=e.shippingAddress||{},r={recipient:s.recipient||o.name||"",address1:(null===(n=s.addressLine)||void 0===n?void 0:n[0])||"",address2:(null===(i=s.addressLine)||void 0===i?void 0:i[1])||"",address3:(null===(a=s.addressLine)||void 0===a?void 0:a[2])||"",city:s.city||"",state:s.region||"",postcode:s.postalCode||s.postal_code||"",country:s.country||"",country_code:s.country||""};return this.basketService.setGroupedBasketDeliveryAddress(r),this.selectedDeliveryOptionId&&this.basketService.setGroupedBasketDeliveryOptionId(this.selectedDeliveryOptionId),this.basketService.setGroupedBasketDeliveryDate(this.requestedDeliveryDate),this.basketService.placeOrder(d,[])}).then(n=>{e.complete("success"),this.segmentService.trackCustom({name:"Express Checkout Completed",data:{fulfilment_type:t,payment_method:"APPLEPAY"}}),this.segmentService.track((0,a.uA)(...(0,a.Cx)(n),["content_type","product"],["content_ids",n.orders.reduce((e,{cards:t})=>e.concat(t.map(({card_id:e})=>e)),[])],["productType",(0,s.Jh)(n)],["payment_method","APPLEPAY"],["express_checkout","apple pay"],["guest_checkout",this.Authentication.isGuestUserLoggedIn()],(0,s.Je)())),this.analytics.completeAnalytics(n,r.L.APPLEPAY),this.router.navigate(["/order/confirmation"],{queryParams:{order_id:n.id}})}).catch(t=>{var n;e.complete("fail");const i=(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.message)||"Something went wrong with your payment. Please try again.";this.shareData.trigger("showError",i)})}getEstimatedDateString(e){const{earliest_delivery_date:t,latest_delivery_date:n}=e.first_available_delivery,i=new Date(n),a=this.dateToDisplayProps(i);let s=a.join(" ");if(t!==n){const t=new Date(e.first_available_delivery.earliest_delivery_date);s=`${this.dateToDisplayProps(t).filter((e,t)=>e!==a[t]).join(" ")} - ${s}`}return s}dateToDisplayProps(e){return[e.getDate(),e.toLocaleString("default",{month:"short"})]}buildDisplayItems(e,t,n){const i=[{label:"Items cost",amount:e},{label:"Delivery",amount:t}];return(null==n?void 0:n.amount)&&i.push({label:n.campaignName||"Discount",amount:-Math.round(100*n.amount)}),i}checkApplePaySupport(e){return(0,i.mG)(this,void 0,void 0,function*(){const{available:t}=yield this.stripeService.applePayExpressCheck(e);return t&&(this.isAvailable=!0),t})}initExpressCheckoutForCard(e,t,n,a,s){return(0,i.mG)(this,void 0,void 0,function*(){if(this.requestedDeliveryDate=s||null,!this.isAvailable)return void this.shareData.trigger("showError","Apple Pay is not available on this device");const r=this.stripeService.createExpressPaymentRequest(n||"0",a,void 0,0);r&&(yield r.canMakePayment())?(r.on("cancel",()=>{this.segmentService.trackCustom({name:"Apple Pay Express Checkout Cancelled",data:{context:"PLP"}}),this.applePayTrigger=!1}),r.on("shippingaddresschange",a=>(0,i.mG)(this,void 0,void 0,function*(){try{const i=a.shippingAddress||{},s=i.postalCode||i.postal_code||"",r=i.country||i.countryCode||"GB",o=yield this.fetchDeliveryOptionsForCard(e,t,s,r);if(!o.length)return void a.updateWith({status:"invalid_shipping_address"});const l=o[0];this.selectedDeliveryOptionId=(null==l?void 0:l.id)||null;const d=Math.round(100*Number(n)),c=(null==l?void 0:l.amount)||0;a.updateWith({status:"success",shippingOptions:o,displayItems:this.buildDisplayItems(d,c,{}),total:{label:"Thortful LTD",amount:d+c}})}catch(i){a.updateWith({status:"invalid_shipping_address"})}})),r.on("shippingoptionchange",e=>{const t=e.shippingOption;this.selectedDeliveryOptionId=(null==t?void 0:t.id)||null;const i=Math.round(100*Number(n)),a=(null==t?void 0:t.amount)||0;e.updateWith({status:"success",displayItems:this.buildDisplayItems(i,a,{}),total:{label:"Thortful LTD",amount:i+a}})}),!this.applePayTrigger&&(this.applePayTrigger=!0,r.on("paymentmethod",i=>{this.applePayTrigger=!1,a?this.Authentication.signInGuest(i.payerEmail,!0).then(()=>{this.processExpressOrderForCard(i,e,t,n)}).catch(e=>{var t;i.complete("fail"),this.shareData.trigger("showError",(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.message)||"Something went wrong with your payment. Please try again.")}):this.processExpressOrderForCard(i,e,t,n)}),r.show(),this.segmentService.trackCustom({name:"Apple Pay Express Checkout Sheet Displayed",data:{context:"PLP"}}))):this.shareData.trigger("showError","Apple Pay is not available on this device")})}fetchDeliveryOptionsForCard(e,t,n,a){return(0,i.mG)(this,void 0,void 0,function*(){const s=[{product_id:e.format,quantity:e.quantity||1,recipient_type:"HOME_FILL"===t?"home_fill":"direct_send",address:{postcode:n,country_code:a,postcode_prefix:n}}];try{const e=yield this.api.request(this.endpoint.deliveryOptions,{method:"POST",data:{items:s},useApiKeys:!0},!0).toPromise(),t=(null==e?void 0:e.delivery_options)||[],n=(Array.isArray(t)?t:[]).map(e=>{var t;const n=null===(t=e.products)||void 0===t?void 0:t[0],i=(null==n?void 0:n.cost)||0,a=(null==n?void 0:n.default_delivery_option)||!1;return{id:e.id||"standard",label:e.name||"Standard Delivery",detail
1:this.requestedDeliveryDate?"Arrives "+this.formatScheduledDate(this.requestedDeliveryDate):"Estimated "+this.getEstimatedDateString(e),amount:Math.round(100*i),_isDefault:a}});return n.sort((e,t)=>(t._isDefault?1:0)-(e._isDefault?1:0)),n.map(e=>(0,i._T)(e,["_isDefault"]))}catch(r){return[]}})}processExpressOrderForCard(e,t,n,i){var a,s,o,l;const d=(null===(a=e.paymentMethod)||void 0===a?void 0:a.billing_details)||{},c=d.address||{},p=e.shippingAddress||{},h={recipient_type:"HOME_FILL"===n?"home_fill":"direct_send",delivery_address:{recipient:p.recipient||d.name||"",address1:(null===(s=p.addressLine)||void 0===s?void 0:s[0])||"",address2:(null===(o=p.addressLine)||void 0===o?void 0:o[1])||"",address3:(null===(l=p.addressLine)||void 0===l?void 0:l[2])||"",city:p.city||"",state:p.region||"",postcode:p.postalCode||p.postal_code||"",country:p.country||"",country_code:p.country||""},delivery_option_id:this.selectedDeliveryOptionId||void 0,order_delivery:{dispatch_type:this.requestedDeliveryDate?"LATER":"IMMEDIATE",requested_arrival_date:this.requestedDeliveryDate?this.requestedDeliveryDate.toISOString().slice(0,10):null},cards:[{card_id:t.card_id,format:t.format,quantity:t.quantity||1}]},m={payment_request:{payment_method:e.paymentMethod,payment_method_type:"STRIPE",brand:"apple",currency:"GBP",should_use_paypal_orders_api_v2:!1},remote_client_id:"PLP_"+t.card_id+"_"+Date.now(),card_order_requests:[h],basket:!1,billing_address:{name:d.name||"",email:d.email||"",phone:d.phone||"",line1:c.line1||"",line2:c.line2||"",city:c.city||"",state:c.state||"",postal_code:c.postal_code||"",country:c.country||""},discount_code:null,use_credits:!1,apply_donation:!1,checkout_flow:"APPLE_PAY_EXPRESS_CHECKOUT"};this.api.request(this.endpoint.v3Order+"/place?create_reminders=false",{method:"POST",data:m,useEnvHeader:!0}).then(e=>{var t;return(null===(t=e.order_charge)||void 0===t?void 0:t.client_secret)?this.stripeService.placeOrder(e.id,e.order_charge.client_secret):e}).then(t=>{e.complete("success"),this.segmentService.trackCustom({name:"Express Checkout Completed",data:{fulfilment_type:n,payment_method:"APPLEPAY",context:"PLP"}}),this.analytics.completeAnalytics(t,r.L.APPLEPAY),this.router.navigate(["/order/confirmation"],{queryParams:{order_id:t.id}})}).catch(t=>{var n;e.complete("fail"),this.shareData.trigger("showError",(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.message)||"Something went wrong with your payment. Please try again.")})}formatScheduledDate(e){return this.dateToDisplayProps(e).join(" ")}}return e.\u0275fac=function(t){return new(t||e)(o.\u0275\u0275inject(l.t),o.\u0275\u0275inject(d.v),o.\u0275\u0275inject(c.u),o.\u0275\u0275inject(a.BP),o.\u0275\u0275inject(p.F0),o.\u0275\u0275inject(h.yh),o.\u0275\u0275inject(m.V),o.\u0275\u0275inject(u.F),o.\u0275\u0275inject(g.Vy),o.\u0275\u0275inject(y.c))},e.\u0275prov=o.\u0275\u0275defineInjectable({token:e,factory:e.\u0275fac,providedIn:"root"}),e})()},15786:function(e,t,n){n.d(t,{E:function(){return y}});var i=n(85572),a=n(62415),s=n(43188),r=n(14905),o=n(50774),l=n(67060),d=n(95178),c=n(92674);function p(e,t){1&e&&a.\u0275\u0275element(0,"div",20)}function h(e,t){if(1&e){const e=a.\u0275\u0275getCurrentView();a.\u0275\u0275elementStart(0,"div",14),a.\u0275\u0275listener("click",function(){const t=a.\u0275\u0275restoreView(e).$implicit;return a.\u0275\u0275nextContext().selectFulfilment(t.type)}),a.\u0275\u0275elementStart(1,"div",15),a.\u0275\u0275template(2,p,1,0,"div",16),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(3,"div",17),a.\u0275\u0275elementStart(4,"p",18),a.\u0275\u0275text(5),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(6,"p",19),a.\u0275\u0275text(7),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd()}if(2&e){const e=t.$implicit,n=a.\u0275\u0275nextContext();a.\u0275\u0275classProp("--selected",n.selectedFulfilment===e.type)("--disabled",e.disabled),a.\u0275\u0275advance(2),a.\u0275\u0275property("ngIf",n.selectedFulfilment===e.type),a.\u0275\u0275advance(3),a.\u0275\u0275textInterpolate(e.label),a.\u0275\u0275advance(2),a.\u0275\u0275textInterpolate(e.description)}}function m(e,t){1&e&&a.\u0275\u0275element(0,"div",20)}function u(e,t){1&e&&a.\u0275\u0275element(0,"div",20)}function g(e,t){if(1&e){const e=a.\u0275\u0275getCurrentView();a.\u0275\u0275elementStart(0,"div",21),a.\u0275\u0275elementStart(1,"p",22),a.\u0275\u0275text(2,"Delivery date"),a.\u0275\u0275elementEnd(),a.\u
10275\u0275elementStart(3,"div",23),a.\u0275\u0275listener("click",function(){return a.\u0275\u0275restoreView(e),a.\u0275\u0275nextContext().selectDeliveryTiming("ASAP")}),a.\u0275\u0275elementStart(4,"div",15),a.\u0275\u0275template(5,m,1,0,"div",16),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(6,"span"),a.\u0275\u0275text(7,"As soon as possible"),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(8,"div",23),a.\u0275\u0275listener("click",function(){return a.\u0275\u0275restoreView(e),a.\u0275\u0275nextContext().selectDeliveryTiming("SCHEDULED")}),a.\u0275\u0275elementStart(9,"div",15),a.\u0275\u0275template(10,u,1,0,"div",16),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(11,"span"),a.\u0275\u0275text(12),a.\u0275\u0275pipe(13,"date"),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(14,"datepicker",24),a.\u0275\u0275listener("emitDate",function(t){return a.\u0275\u0275restoreView(e),a.\u0275\u0275nextContext().onDateSelected(t)}),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd()}if(2&e){const e=a.\u0275\u0275nextContext();a.\u0275\u0275advance(5),a.\u0275\u0275property("ngIf","ASAP"===e.selectedDeliveryTiming),a.\u0275\u0275advance(5),a.\u0275\u0275property("ngIf","SCHEDULED"===e.selectedDeliveryTiming),a.\u0275\u0275advance(2),a.\u0275\u0275textInterpolate1("Schedule for later",e.scheduledDate?": "+a.\u0275\u0275pipeBind2(13,7,e.scheduledDate,"d MMMM yyyy"):"",""),a.\u0275\u0275advance(2),a.\u0275\u0275property("type","hide-field")("startDate",e.calendarMin)("maxDate",e.calendarMax)("disableDates",e.disableDates)}}let y=(()=>{class e{constructor(e,t,n,i){this.basketService=e,this.printerFormatsService=t,this.applePayExpressService=n,this.generalUtils=i,this.processing=!1,this.close=new a.EventEmitter,this.fulfilmentSelected=new a.EventEmitter,this.selectedFulfilment="HOME_FILL",this.selectedDeliveryTiming="ASAP",this.scheduledDate=null,this.calendarMin=new Date((new Date).setDate((new Date).getDate()+1)),this.calendarMax=new Date((new Date).getFullYear(),(new Date).getMonth()+3,(new Date).getDate()),this.excludedDates=[],this.fulfilmentOptions=[{type:"HOME_FILL",label:"Send to me",description:"Delivered with a blank spare envelope. Card Gifts come wrapped in a sleeve."},{type:"DIRECT_SEND",label:"Send to them",description:"Send directly to the recipient."}],this.holidayDates=[],this.disableDates=e=>{const t=e.getTime(),n=this.excludedDates.map(e=>new Date(e+"T00:00:00").getTime());return 0===e.getDay()||n.includes(t)||this.holidayDates.includes(t)}}ngOnInit(){this.specifyFulfilment(),this.fetchExcludedDates()}specifyFulfilment(){return(0,i.mG)(this,void 0,void 0,function*(){yield this.printerFormatsService.getStandaloneFormats();const e=this.basketService.processCardsBasketApi(),t=e.some(e=>e.quantity>1),n=e.some(e=>this.printerFormatsService.isProductStandalone(e.format));if(t||n){const e=this.fulfilmentOptions.find(e=>"DIRECT_SEND"===e.type);e.disabled=!0,e.description=n?"Not available for card packs":"Not available for multiple cards"}})}fetchExcludedDates(){this.applePayExpressService.fetchExcludedDeliveryDates().then(e=>{this.excludedDates=e}),this.generalUtils.serviceOptions.then(e=>{const t=e.date_information.holidays.filter(e=>e.royal_mail_applicable).map(e=>new Date(e.date).getTime());this.holidayDates=t})}selectFulfilment(e){const t=this.fulfilmentOptions.find(t=>t.type===e);(null==t?void 0:t.disabled)||(this.selectedFulfilment=e,"HOME_FILL"===e&&(this.selectedDeliveryTiming="ASAP",this.scheduledDate=null,this.datepicker.date=null))}selectDeliveryTiming(e){this.selectedDeliveryTiming=e,"ASAP"===e&&(this.scheduledDate=null,this.datepicker.date=null),"SCHEDULED"===e&&!this.scheduledDate&&(this.scheduledDate=this.calendarMin,this.datepicker.date=this.calendarMin,this.openCalendar())}onDateSelected(e){this.scheduledDate=e}openCalendar(){setTimeout(()=>{var e,t;return null===(t=null===(e=this.datepicker)||void 0===e?void 0:e.calendar)||void 0===t?void 0:t.open()})}onApplePayClick(){this.processing||this.fulfilmentSelected.emit({fulfilment:this.selectedFulfilment,scheduledDate:"SCHEDULED"===this.selectedDeliveryTiming?this.scheduledDate:null})}onClose(){this.close.emit()}}return e.\u0275fac=function(t){return new(t||e)(a.\u0275\u0275directiveInject(r.v),a.\u0275\u0275directiveInject(o.t),a.\u0275\u0275directiveInject(l.R),a.\u
10275\u0275directiveInject(d.w))},e.\u0275cmp=a.\u0275\u0275defineComponent({type:e,selectors:[["express-checkout-modal"]],viewQuery:function(e,t){if(1&e&&a.\u0275\u0275viewQuery(s.a,5),2&e){let e;a.\u0275\u0275queryRefresh(e=a.\u0275\u0275loadQuery())&&(t.datepicker=e.first)}},inputs:{processing:"processing"},outputs:{close:"close",fulfilmentSelected:"fulfilmentSelected"},decls:18,vars:4,consts:[[1,"express-checkout-overlay",3,"click"],[1,"express-checkout-modal"],[1,"modal-close"],[1,"mdi","mdi-close",3,"click"],[1,"modal-header"],[1,"title"],[1,"subtitle"],[1,"modal-body"],["class","fulfilment-option",3,"--selected","--disabled","click",4,"ngFor","ngForOf"],["class","delivery-date-section",4,"ngIf"],[1,"modal-footer"],[1,"apple-pay-btn",3,"disabled","click"],[1,"btn-text"],[1,"btn-logo"],[1,"fulfilment-option",3,"click"],[1,"radio-circle"],["class","radio-dot",4,"ngIf"],[1,"option-content"],[1,"option-label"],[1,"option-description"],[1,"radio-dot"],[1,"delivery-date-section"],[1,"delivery-date-label"],[1,"delivery-date-option",3,"click"],[3,"type","startDate","maxDate","disableDates","emitDate"]],template:function(e,t){1&e&&(a.\u0275\u0275elementStart(0,"div",0),a.\u0275\u0275listener("click",function(){return t.onClose()}),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(1,"div",1),a.\u0275\u0275elementStart(2,"div",2),a.\u0275\u0275elementStart(3,"i",3),a.\u0275\u0275listener("click",function(){return t.onClose()}),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(4,"div",4),a.\u0275\u0275elementStart(5,"h4",5),a.\u0275\u0275text(6,"Who do you want to send this card to?"),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(7,"p",6),a.\u0275\u0275text(8,"All the cards in your order will be sent together to the same address."),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(9,"div",7),a.\u0275\u0275template(10,h,8,7,"div",8),a.\u0275\u0275template(11,g,15,10,"div",9),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(12,"div",10),a.\u0275\u0275elementStart(13,"button",11),a.\u0275\u0275listener("click",function(){return t.onApplePayClick()}),a.\u0275\u0275elementStart(14,"span",12),a.\u0275\u0275text(15,"Checkout with"),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementStart(16,"span",13),a.\u0275\u0275text(17,"Pay"),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd(),a.\u0275\u0275elementEnd()),2&e&&(a.\u0275\u0275advance(10),a.\u0275\u0275property("ngForOf",t.fulfilmentOptions),a.\u
10275\u0275advance(1),a.\u0275\u0275property("ngIf","DIRECT_SEND"===t.selectedFulfilment),a.\u0275\u0275advance(2),a.\u0275\u0275property("disabled",t.processing),a.\u0275\u0275attribute("aria-label","Checkout with Apple Pay"))},directives:[c.sg,c.O5,s.a],pipes:[c.uU],styles:['@charset "UTF-8";.express-checkout-overlay[_ngcontent-%COMP%]{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#3b3b3b99;z-index:9998}.express-checkout-modal[_ngcontent-%COMP%]{position:fixed;left:50%;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:9999;background:#ffffff;border-radius:12px;width:calc(100vw - 32px);max-width:440px;max-height:calc(100vh - 44px);overflow-y:auto;padding:24px}@media (max-width: 768px){.express-checkout-modal[_ngcontent-%COMP%]{width:100vw;height:100vh;max-width:none;max-height:none;border-radius:0;top:0;left:0;-webkit-transform:none;transform:none}}.modal-close[_ngcontent-%COMP%]{position:absolute;right:12px;top:12px}.modal-close[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{font-size:24px;color:#000;cursor:pointer}.modal-header[_ngcontent-%COMP%]{margin-bottom:20px}.modal-header[_ngcontent-%COMP%] .title[_ngcontent-%COMP%]{font-size:20px;font-weight:900;margin:0 0 4px;color:#000}.modal-header[_ngcontent-%COMP%] .subtitle[_ngcontent-%COMP%]{font-size:14px;color:#666;margin:0}@media (max-width: 768px){.modal-header[_ngcontent-%COMP%]{margin:20px 0}}.modal-body[_ngcontent-%COMP%]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;grid-gap:12px;gap:12px;margin-bottom:20px}.radio-circle[_ngcontent-%COMP%]{width:22px;height:22px;min-width:22px;border-radius:50%;border:1px solid #000000;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;margin-top:2px;-webkit-transition:border-color .15s ease;transition:border-color .15s ease}.radio-dot[_ngcontent-%COMP%]{width:12px;height:12px;border-radius:50%;background:#ff6900}.fulfilment-option[_ngcontent-%COMP%]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;grid-gap:12px;gap:12px;padding:16px;border-radius:8px;border:1.5px solid #ebebeb;cursor:pointer;-webkit-transition:border-color .15s ease;transition:border-color .15s ease}.fulfilment-option.--selected[_ngcontent-%COMP%]{border-color:#ff6900;background:#F7EFE5}.fulfilment-option.--disabled[_ngcontent-%COMP%]{opacity:.5;cursor:not-allowed;pointer-events:none}.fulfilment-option.--selected[_ngcontent-%COMP%] .radio-circle[_ngcontent-%COMP%]{border-color:#ff6900}.fulfilment-option[_ngcontent-%COMP%] .option-content[_ngcontent-%COMP%]{-webkit-box-flex:1;-ms-flex:1;flex:1}.fulfilment-option[_ngcontent-%COMP%] .option-label[_ngcontent-%COMP%]{font-size:16px;font-weight:700;margin:0 0 2px;color:#000}.fulfilment-option[_ngcontent-%COMP%] .option-description[_ngcontent-%COMP%]{font-size:13px;color:#666;margin:0;line-height:1.4}.delivery-date-section[_ngcontent-%COMP%]{margin-top:16px;margin-bottom:20px}.delivery-date-section[_ngcontent-%COMP%] .delivery-date-label[_ngcontent-%COMP%]{font-size:16px;font-weight:700;margin:0 0 12px;color:#000}.delivery-date-section[_ngcontent-%COMP%] .delivery-date-option[_ngcontent-%COMP%]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;grid-gap:10px;gap:10px;cursor:pointer;padding:6px 0}.delivery-date-section[_ngcontent-%COMP%] .delivery-date-option[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:14px;color:#000}@media (max-width: 768px){.modal-footer[_ngcontent-%COMP%]{position:fixed;bottom:0;left:0;width:100%;padding:16px 24px}}.modal-footer[_ngcontent-%COMP%] .apple-pay-btn[_ngcontent-%COMP%]{width:100%;height:48px;border:none;border-radius:8px;background:#000000;color:#fff;font-size:16px;cursor:pointer;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.modal-footer[_ngcontent-%COMP%] .apple-pay-btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.modal-footer[_ngcontent-%COMP%] .apple-pay-btn[_ngcontent-%COMP%] .btn-text[_ngcontent-%COMP%]{font-size:16px;font-weight:500;letter-spacing:-.3px;color:#fff}.modal-footer[_ngcontent-%COMP%] .apple-pay-btn[_ngcontent-%COMP%] .btn-logo[_ngcontent-%COMP%]{font-size:18px;font-weight:600;letter-spacing:-.3px;color:#fff}.modal-footer[_ngcontent-%COMP%] .apple-pay-btn[_ngcontent-%COMP%] .btn-logo[_ngcontent-%COMP%]:before{content:"\\f8ff";font-family:"Apple Color Emoji",-apple-system,BlinkMacSystemFont,sans-serif;margin-left:2px;margin-right:2px;font-size:20px} .cdk-overlay-container{z-index:10000!important}']}),e})()},37849:function(e,t,n){n.d(t,{Z:function(){return o}});var i=n(92674),a=n(84215),s=n(37921),r=n(62415);let o=(()=>{class e{}return e.\u0275fac=function(t){return new(t||e)},e.\u0275mod=r.\u0275\u0275defineNgModule({type:e}),e.\u0275inj=r.\u0275\u0275defineInjector({imports:[[i.ez,a.Z,s.e]]}),e})()},36047:function(e,t,n){n.d(t,{F:function(){return oe},L:function(){return le}});var i=n(85572),a=n(36644),s=n(70013),r=n(20820),o=n(69556),l=n(70966),d=n(6650),c=n(8355),p=n(73403);const h=(0,s.jT)("Checkout Payment Method Selected");var m=n(59407),u=n(94906),g=n(62415),y=n(17291),f=n(31552),v=n(95178),b=n(37403),C=n(14905),x=n(13074),_=n(55519),P=n(68076),k=n(877),w=n(9265),S=n(17419),M=n(47623),E=n(2063),O=n(23576);function D(e,t){1&e&&(g.\u0275\u0275elementStart(0,"p",11),g.\u0275\u0275text(1,"Please choose one of the following payment methods"),g.\u0275\u0275elementEnd())}const A=function(e,t){return{"two-button-row":e,"one-button-row":t}};function I(e,t){if(1&e&&(g.\u0275\u0275elementStart(0,"div",12),g.\u0275\u0275element(1,"payment-info-banner",13),g.\u0275\u0275elementEnd()),2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275property("ngClass",g.\u0275\u0275pureFunction2(2,A,2===e.buttons.length,2!==e.buttons.length)),g.\u0275\u0275advance(1),g.\u0275\u0275property("message",e.subscriptionPaymentInfoBanner)}}function F(e,t){if(1&e&&(g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275template(1,D,2,0,"p",9),g.\u0275\u0275template(2,I,2,5,"div",10),g.\u0275\u0275elementContainerEnd()),2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlag","WAL-1461"),g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",e.BasketService.subscriptionIncludedOnBasket())}}function T(e,t){if(1&e&&(g.\u0275\u0275elementStart(0,"div",6),g.\u0275\u0275elementStart(1,"h4",7),g.\u0275\u0275text(2,"Choose your payment method"),g.\u0275\u0275elementEnd(),g.\u0275\u0275template(3,F,3,2,"ng-container",3),g.\u0275\u0275element(4,"thor-basket-buttons",8),g.\u0275\u0275elementEnd()),2&e){const e=g.\u0275\u0275nextContext();g.\u0275\u0275advance(3),g.\u0275\u0275property("featureFlag","WAL-1461"),g.\u0275\u0275advance(1),g.\u0275\u0275property("buttonsData",e.buttons)("selected",e.payWith)}}function L(e,t){if(1&e&&(g.\u0275\u0275elementStart(0,"div",20),g.\u0275\u0275text(1),g.\u0275\u0275elementEnd()),2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275advance(1),g.\u0275\u0275textInterpolate1("",e.applePayDiscountText," ")}}function B(e,t){1&e&&(g.\u0275\u0275elementStart(0,"div",21),g.\u0275\u0275text(1,"Or continue without the apple pay discount"),g.\u0275\u0275elementEnd())}const j=function(e){return{green:e}};function V(e,t){if(1&e&&(g.\u0275\u0275elementStart(0,"div",16),g.\u0275\u0275elementStart(1,"div",17),g.\u0275\u0275element(2,"thor-basket-buttons",8),g.\u0275\u0275template(3,L,2,1,"div",18),g.\u0275\u0275elementEnd(),g.\u0275\u0275template(4,B,2,0,"div",19),g.\u0275\u0275elementEnd()),2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(1),g.\u0275\u0275property("ngClass",g.\u0275\u0275pureFunction1(5,j,e.applePayPromoAvailable)),g.\u0275\u0275advance(1),g.\u0275\u0275property("buttonsData",e.applePayButton)("selected",e.payWith),g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",e.applePayPromoAvailable),g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",e.applePayPromoAvailable)}}function W(e,t){if(1&e&&(g.\u0275\u0275elementStart(0,"div",6),g.\u0275\u0275element(1,"thor-basket-buttons",22),g.\u0275\u0275elementEnd()),2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(1),g.\u0275\u0275property("buttonsData",e.buttons2)("inColumn",e.showApplePayButton)("selected",e.payWith)}}function U(e,t){if(1&e&&(g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275elementStart(1,"div",6),g.\u0275\u0275elementStart(2,"h4",7),g.\u0275\u0275text(3,"Choose your payment method"),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementEnd(),g.\u0275\u0275template(4,V,5,7,"div",14),g.\u0275\u0275template(5,W,2,3,"div",15),g.\u0275\u0275elementContainerEnd()),2&e){const e=g.\u0275\u0275nextContext();g.\u0275\u0275advance(4),g.\u0275\u0275property("ngIf",e.showApplePayButton&&e.loaded),g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",e.loaded)}}const G=function(e){return{disabled:e}};function R(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"button",30),g.\u0275\u0275listener("click",function(){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(3).selectCard()}),g.\u0275\u0275text(1),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275property("ngClass",g.\u0275\u0275pureFunction1(2,G,!e.isValid(e.selectedCard))),g.\u0275\u0275advance(1),g.\u0275\u0275textInterpolate1("",e.isValid(e.selectedCard)?"Continue with payment method":"Expired Card!"," ")}}function q(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275elementStart(1,"div",27),g.\u0275\u0275template(2,R,2,4,"button",28),g.\u0275\u0275elementStart(3,"button",29),g.\u0275\u0275listener("click",function(){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(2).addNewCard()}),g.\u0275\u0275text(4,"Add new card"),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementContainerEnd()}if(2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(2),g.\u0275\u0275property("ngIf",e.selectedCard)}}function z(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"button",35),g.\u0275\u0275listener("click",function(){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(3).selectCard()}),g.\u0275\u0275text(1),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275property("ngClass",g.\u0275\u0275pureFunction1(2,G,!e.isValid(e.selectedCard))),g.\u0275\u0275advance(1),g.\u0275\u0275textInterpolate(e.isValid(e.selectedCard)?"USE THIS CARD":"Expired Card!")}}function N(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275elementStart(1,"div",31),g.\u0275\u0275template(2,z,2,4,"button",32),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementStart(3,"h6",33),g.\u0275\u0275text(4,"Add new card"),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementStart(5,"a",34),g.\u0275\u0275listener("click",function(){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(2).addNewCard()}),g.\u0275\u0275text(6,"+"),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementContainerEnd()}if(2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(2),g.\u0275\u0275property("ngIf",e.selectedCard)}}function Y(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"div",23),g.\u0275\u0275elementStart(1,"h5",24),g.\u0275\u0275text(2),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementStart(3,"thor-credit-card-list",25),g.\u0275\u0275listener("selectedChange",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext().selectedCard=t})("selectedCardChange",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext().getCard(t)}),g.\u0275\u0275elementEnd(),g.\u0275\u0275template(4,q,5,1,"ng-container",3),g.\u0275\u0275template(5,N,7,1,"ng-container",26),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext();g.\u0275\u0275advance(2),g.\u0275\u0275textInterpolate1("Your Card",e.creditcards.length>
11?"s":"",""),g.\u0275\u0275advance(1),g.\u0275\u0275property("cardList",e.creditcards)("selected",e.selectedCard),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlag","WAL-1461"),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlagDisabled","WAL-1461")}}function H(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"div",40),g.\u0275\u0275elementStart(1,"input",41),g.\u0275\u0275listener("ngModelChange",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(3).creditCard.user_save_card_data_consent=t}),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementStart(2,"label",42),g.\u0275\u0275listener("click",function(){g.\u0275\u0275restoreView(e);const t=g.\u0275\u0275nextContext(3);return t.creditCard.user_save_card_data_consent=!t.creditCard.user_save_card_data_consent}),g.\u0275\u0275element(3,"div",43),g.\u0275\u0275element(4,"div",44),g.\u0275\u0275element(5,"div",45),g.\u0275\u0275text(6,"Save this card for future purchases"),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275advance(1),g.\u0275\u0275property("ngModel",e.creditCard.user_save_card_data_consent)}}function K(e,t){if(1&e&&(g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275template(1,H,7,1,"div",39),g.\u0275\u0275elementContainerEnd()),2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",e.isFullUserLoggedIn)}}function $(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275elementStart(1,"div",40),g.\u0275\u0275elementStart(2,"input",41),g.\u0275\u0275listener("ngModelChange",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(2).creditCard.user_save_card_data_consent=t}),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementStart(3,"label",42),g.\u0275\u0275listener("click",function(){g.\u0275\u0275restoreView(e);const t=g.\u0275\u0275nextContext(2);return t.creditCard.user_save_card_data_consent=!t.creditCard.user_save_card_data_consent}),g.\u0275\u0275element(4,"div",43),g.\u0275\u0275element(5,"div",44),g.\u0275\u0275element(6,"div",45),g.\u0275\u0275text(7,"Save this card for future purchases"),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementContainerEnd()}if(2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(2),g.\u0275\u0275property("ngModel",e.creditCard.user_save_card_data_consent)}}function J(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"div",48),g.\u0275\u0275elementStart(1,"input",49),g.\u0275\u0275listener("ngModelChange",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(3).useDeliveryAddress=t}),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementStart(2,"label",42),g.\u0275\u0275listener("click",function(){g.\u0275\u0275restoreView(e);const t=g.\u0275\u0275nextContext(3);return t.useDeliveryAddress=!t.useDeliveryAddress}),g.\u0275\u0275element(3,"div",43),g.\u0275\u0275element(4,"div",44),g.\u0275\u0275element(5,"div",45),g.\u0275\u0275text(6," Use delivery address as billing address"),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275advance(1),g.\u0275\u0275property("ngModel",e.useDeliveryAddress)}}function Z(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"button",58),g.\u0275\u0275listener("click",function(){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(4).setBillingAddressAndConfirmCard()}),g.\u0275\u0275text(1,"Use this card"),g.\u0275\u0275elementEnd()}}function Q(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"button",59),g.\u0275\u0275listener("click",function(){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(4).setBillingAddressAndConfirmCard()}),g.\u0275\u0275text(1,"Use this card"),g.\u0275\u0275elementEnd()}}function X(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"div",50),g.\u0275\u0275elementStart(1,"div",51),g.\u0275\u0275elementStart(2,"label",52),g.\u0275\u0275text(3,"Card Holder's Name "),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementStart(4,"input",53),g.\u0275\u0275listener("ngModelChange",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(3).billingAddressFromDelivery.recipient=t}),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementStart(5,"div",54),g.\u0275\u0275text(6),g.\u0275\u0275elementStart(7,"i",55),g.\u0275\u0275listener("click",function(){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(3).removeBillingAddressFromDelivery()}),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementEnd(),g.\u0275\u0275template(8,Z,2,0,"button",56),g.\u0275\u0275template(9,Q,2,0,"button",57),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275advance(4),g.\u0275\u0275property("ngModel",e.billingAddressFromDelivery.recipient),g.\u0275\u0275advance(2),g.\u0275\u0275textInterpolate(e.billingAddressFromDelivery.addressComplete),g.\u0275\u0275advance(2),g.\u0275\u0275property("featureFlag","WAL-1461"),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlagDisabled","WAL-1461")}}function ee(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"thor-address",61),g.\u0275\u0275listener("onAddressConfirmation",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(4).cardConfirmation(t)}),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext(4);
1g.\u0275\u0275property("addressData",e.creditCard.billing_address)("addressSettings",e.addressSettings)}}function te(e,t){if(1&e&&(g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275template(1,ee,1,2,"thor-address",60),g.\u0275\u0275elementContainerEnd()),2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",!e.useDeliveryAddress)}}function ne(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"thor-address",63),g.\u0275\u0275listener("onAddressConfirmation",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(4).cardConfirmation(t)}),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext(4);g.\u0275\u0275property("addressData",e.creditCard.billing_address)("addressSettings",e.addressSettings)}}function ie(e,t){if(1&e&&(g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275template(1,ne,1,2,"thor-address",62),g.\u0275\u0275elementContainerEnd()),2&e){const e=g.\u0275\u0275nextContext(3);g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",!e.useDeliveryAddress)}}function ae(e,t){if(1&e&&(g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275template(1,J,7,1,"div",46),g.\u0275\u0275template(2,X,10,4,"div",47),g.\u0275\u0275template(3,te,2,1,"ng-container",3),g.\u0275\u0275template(4,ie,2,1,"ng-container",26),g.\u0275\u0275elementContainerEnd()),2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",e.billingAddressFromDelivery),g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf",e.useDeliveryAddress&&e.billingAddressFromDelivery),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlag","WAL-1461"),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlagDisabled","WAL-1461")}}function se(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementContainerStart(0),g.\u0275\u0275elementStart(1,"thor-address",63),g.\u0275\u0275listener("onAddressConfirmation",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext(2).cardConfirmation(t)}),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementContainerEnd()}if(2&e){const e=g.\u0275\u0275nextContext(2);g.\u0275\u0275advance(1),g.\u0275\u0275property("addressData",e.creditCard.billing_address)("addressSettings",e.addressSettings)}}function re(e,t){if(1&e){const e=g.\u0275\u0275getCurrentView();g.\u0275\u0275elementStart(0,"form",36),g.\u0275\u0275elementStart(1,"stripe-component",37),g.\u0275\u0275listener("valid",function(t){return g.\u0275\u0275restoreView(e),g.\u0275\u0275nextContext().onStripeValidation(t)}),g.\u0275\u0275elementEnd(),g.\u0275\u0275template(2,K,2,1,"ng-container",3),g.\u0275\u0275template(3,$,8,1,"ng-container",26),g.\u0275\u0275elementStart(4,"h4",38),g.\u0275\u0275text(5,"Billing address"),g.\u0275\u0275elementEnd(),g.\u0275\u0275template(6,ae,5,4,"ng-container",3),g.\u0275\u0275template(7,se,2,2,"ng-container",26),g.\u0275\u0275elementEnd()}if(2&e){const e=g.\u0275\u0275nextContext();g.\u0275\u0275advance(1),g.\u0275\u0275property("confirmRequest",e.confirmRequest)("cardType",e.selectedPaymentMethod.name),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlag","WAL-1165"),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlagDisabled","WAL-1165"),g.\u0275\u0275advance(3),g.\u0275\u0275property("featureFlag","WAL-1296"),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlagDisabled","WAL-1296")}}let oe=(()=>{class e{constructor(e,t,n,i,a,s,r,o,l,c,p,h,m,u,g){this.ShareData=e,this.GoogleAnalytics=t,this.GeneralUtils=n,this.UserUtils=i,this.BasketService=a,this.router=s,this.PaymentMethodsUtils=r,this.Analytics=o,this.SegmentService=l,this.stripeService=c,this.giftService=p,this.Store=h,this.sanitizer=m,this.cardActionsService=u,this.thortfulSubscription=g,this.creditCard=this.BasketService.resetPayment(),this.creditcards=[],this.selectedPaymentMethod={name:"",image:""},this.buttons=[],this.loaded=!1,this.paymentBloomreachTracked=!1,this.useDeliveryAddress=!1,this.billingAddressFromDelivery=null,this.creditCardOptions=[{name:"visa",image:"img/template/payment-visa.svg"},{name:"mastercard",image:"img/template/payment-master-card.svg"},{name:"amex",image:"img/template/payment-american-express.svg"}],this.buttons1=[{image:"svg/apple_pay.svg",imageActive:"svg/apple_pay-white.svg",imageWidth:78,title:"",value:"Apple",btnClickFunction:()=>{this.payWith="Apple",this.updatePaymentMethod({brand:"apple",payment_method_type:"STRIPE",payment_method:{}}),this.paymentSelectedEvent("APPLEPAY")}},{image:"svg/creditcard.svg",imageWidth:49,title:"Debit/Credit card",value:"Card",btnClickFunction:()=>{this.payWith="Card",this.checkForCreditCards(),this.paymentSelectedEvent("STRIPE")}}],this.buttons2=[{imageWidth:55,image:"svg/creditcard.svg",imageActive:"svg/creditcard.svg",title:"Debit/Credit card",value:"Card",btnClickFunction:()=>{this.payWith="Card",this.checkForCreditCards(),this.paymentSelectedEvent("STRIPE")}}
1],this.buttons3=[{image:"svg/google_pay1.svg",imageActive:"svg/google_pay1.svg",imageWidth:78,title:"",value:"Google",btnClickFunction:()=>{this.payWith="Google",this.updatePaymentMethod({brand:"google",payment_method_type:"STRIPE",payment_method:{}}),this.paymentSelectedEvent("GOOGLEPAY")}},{image:"svg/creditcard.svg",imageWidth:49,title:"Debit/Credit card",value:"Card",btnClickFunction:()=>{this.payWith="Card",this.checkForCreditCards(),this.paymentSelectedEvent("STRIPE")}}],this.applePayButton=[{image:"svg/apple_pay.svg",imageActive:"svg/apple_pay-white.svg",imageWidth:78,title:"",value:"Apple",btnClickFunction:()=>{this.payWith="Apple",this.updatePaymentMethod({brand:"apple",payment_method_type:"STRIPE",payment_method:{}}),this.paymentSelectedEvent("APPLEPAY")}}],this.stripeValidation=!1,this.popup={},this.guestCheckoutEnabled=!1,this.subscriptionPaymentInfoBanner=this.sanitizer.bypassSecurityTrustHtml('<span>This payment method will be used for your <span class="bold-text">XTRAthortful subscription</span> and will renew each year.</span>'),this.triggerNewCardActionEvent=!1,this.Store.select("featureFlag","config","WEB-2469").pipe((0,d.P)(e=>"boolean"==typeof e)).subscribe(e=>{this.triggerNewCardActionEvent=e})}ngOnInit(){this.checkOptimiseConditions(),this.confirmRequest=!1,window.scroll(0,0),this.eventListener=this.ShareData.listen("basketUpdate",()=>{this.init()}),this.creditCard=this.BasketService.resetPayment(),this.addressSettings={confirmTitle:"USE THIS CARD",clearTitle:"Cancel",billingAddress:!0},this.init(),this.checkForCreditCards(),this.paymentStickyBtn={btnText:"CHOOSE PAYPAL",btnFunction:this.paymentStickyBtnClick,btnDisabled:!1},this.Store.select("featureFlag","config","applepay_promo").pipe((0,c.q)(1)).subscribe(e=>{this.applePayPromo=!!e}),this.Store.select("featureFlag","config","applepay_remove_discount").pipe((0,c.q)(1)).subscribe(e=>{this.removeDiscountEnabled=!!e}),(0,r.aj)([this.Store.select("featureFlag","config","WAL-1165"),this.Store.select("featureFlag","config","WAL-1461")]).pipe((0,d.P)(([e,t])=>"boolean"==typeof e&&"boolean"==typeof t)).subscribe(([e,t])=>{this.guestCheckoutEnabled=e,this.subscriptionsFFEnabled=t,t&&(this.useSubscriptionButtonsStyling(),this.addressSettings.confirmTitle="Use this card")})}checkoutPaymentBloomreachTrack(){this.paymentBloomreachTracked||(this.paymentBloomreachTracked=!0,(0,u.aZ)(u.pN.PAYMENT,this.basket,this.BasketService,this.guestCheckoutEnabled?this.UserUtils.isGuestUserLoggedIn():void 0))}ngOnDestroy(){this.eventListener.unsubscribe(),this.stripeSubscription&&this.stripeSubscription.unsubscribe()}init(){this.BasketService.basketReadyForCheckout().then(e=>{if(e){this.checkWarningMessage(),this.checkForCreditCards();let e=this.BasketService.getFullBasket();this.basket=e,this.getBillingAddressFromDelivery();let t={basket:e};this.triggerNewCardActionEvent?this.cardActionsService.trackPostCheckout("START_CHECKOUT",t.basket):this.Analytics.thorAnalyticsEvent("START_CHECKOUT",void 0,t),this.GoogleAnalytics.enhancedECommerce({},{step:2},!1),this.Analytics.customEvent("Checkout","Checkout Start","None"),this.items=e.reduce((e,{cards:t})=>e.concat(t.map(({card:e,format:t,category_names:n})=>{const i=(0,s.xo)(Object.assign(Object.assign({},e),{format:t,image:{large:e.image},item_options:[e.item_option]}));return i.push(["occasion_name",(null==n?void 0:n.join(","))||[]]),i.push(["card_type",e.price_class||[]]),(0,s.J3)(i)})),[]),this.basketSize=(0,l.yJ)(e),1===this.basketSize&&this.basket.some(e=>{var t,n,i,a,s,r,o,l,d,c;return(null!==(s=null===(a=null===(i=null!==(n=null===(t=e.formats)||void 0===t?void 0:t[0])&&void 0!==n?n:"")||void 0===i?void 0:i.toLowerCase)||void 0===a?void 0:a.call(i))&&void 0!==s?s:"")===(null!==(c=null===(d=null===(l=null!==(o=null===(r=this.thortfulSubscription.subscriptionItemOption)||void 0===r?void 0:r.format)&&void 0!==o?o:"")||void 0===l?void 0:l.toLowerCase)||void 0===d?void 0:d.call(l))&&void 0!==c?c:"")})&&this.router.navigate(["/basket"]),this.SegmentService.track((0,s.Q6)(["basket_size",this.basketSize],["payment_method",null],["items",this.items],["delivery_option_id",(0,m.L)(e)],(0,l.Je)(),...this.guestCheckoutEnabled?[["guest_checkout",this.UserUtils.isGuestUserLoggedIn()]]:[])),this.checkoutPaymentBloomreachTrack()}else this.router.navigate(["/delivery"])}),this.stripeInit()}
1isSameCard(e,t){var n=!0;for(var i in e)e[i]&&e[i]!=t[i]&&"$$hashKey"!=i&&(n=!1);return n}checkWarningMessage(){try{this.BasketService.checkWarningMessage()}catch(e){}}checkForCreditCards(){this.triggerPaymentMethodRequest||(this.triggerPaymentMethodRequest=!0,this.PaymentMethodsUtils.getPaymentMethods().then(e=>{if(e.length){this.payWith="Card",this.displayCreditCards=!0,this.creditcards=this.creditcards.length?this.creditcards:e;let n=this.creditcards.length,i=this.BasketService.paymentMethod.get();for(var t=0;t<n;t++)this.isSameCard(this.creditcards[t],i)?(this.selectedCard=this.creditcards[t],i.error&&i.billing_address&&i.billing_address.postcode&&(this.selectedPaymentMethod=this.creditCardOptions.find(e=>e.name==i.brand)||{name:"",image:""},this.creditCard=(0,a.Z)(this.selectedCard),this.creditCard.exp_month=this.creditCard.exp_month<10?"0"+this.creditCard.exp_month:this.creditCard.exp_month,this.creditCard.exp_year=this.creditCard.exp_year.toString().slice(2),this.displayCreditCards=!1,setTimeout(()=>{this.GeneralUtils.scrollToElement(document.getElementById("creditcard"),100,"smooth")},50))):!this.selectedCard&&this.isValid(this.creditcards[t])&&(this.selectedCard=this.creditcards[t])}else this.Analytics.customEvent("Checkout","Select Card","None");this.triggerPaymentMethodRequest=!1}).catch(e=>{this.triggerPaymentMethodRequest=!1}))}stripeInit(){this.ShareData.getProperty("device"),this.stripeSubscription=(0,r.aj)([(0,o.D)(this.stripeService.applePayCheck(void 0)),(0,o.D)(this.stripeService.googlePayCheck(void 0)),this.Store.select("featureFlag","config","applepay")]).subscribe(([e,t,n])=>{e.available&&n?(this.showApplePayButton=!0,this.loaded=!0,this.buttons=this.buttons1,this.Analytics.customEvent("Checkout","ApplePay Eligible","Apple - True")):t.available?(this.showGooglePayButton=!0,this.loaded=!0,this.buttons=this.buttons3):(this.loaded=!0,this.buttons=this.buttons2,this.removeApplePayDiscount(),this.Analytics.customEvent("Checkout","ApplePay Eligible","Apple - False"))},e=>{this.loaded=!0,this.buttons=this.buttons2,this.removeApplePayDiscount(),this.Analytics.customEvent("Checkout","ApplePay Eligible","Apple - False"),console.log(e)})}removeApplePayDiscount(){if(this.removeDiscountEnabled){const e=this.BasketService.orderCostValue();"APPLEPAY"===(null==e?void 0:e.discount_code)&&(this.BasketService.setDiscount(!1,null),this.SegmentService.track((0,s.aF)(["discount_code","APPLEPAY"],...(0,s.OL)(e,["discount_amount","discount_amount"],["discount_campaign","discount_campaign_name"]))))}}updatePaymentMethod(e){let t=this.BasketService.resetPayment();for(var n in t)e[n]&&(t[n]=e[n]);this.selectAndContinue(t)}selectAndContinue(e){e&&(this.applePayPromo&&this.applePayDiscount(e),window.scroll(0,0),this.BasketService.paymentMethod.set(e),this.GoogleAnalytics.enhancedECommerce({},{step:3},!1),this.router.navigate(["/confirm"]),this.Analytics.customEvent("Checkout","Select Method",this.payWith))}get applePayPromoAvailable(){var e;const t=(null===(e=this.basket)||void 0===e?void 0:e.length)&&[].concat(...this.basket.map(e=>e.cards));return t&&(0,p.P)(t)>=2}get applePayDiscountText(){const e=this.BasketService.orderCostValue();return"APPLEPAY"===(null==e?void 0:e.discount_code)?"Claim your 35% discount only with Apple Pay":"Recieve 35% discount with Apple Pay"}applePayDiscount(e){if("apple"===e.brand){const e=[].concat(...this.basket.map(e=>e.cards));(0,p.P)(e)>=2&&this.BasketService.setDiscount(!1,"APPLEPAY")}}selectCard(){this.isValid(this.selectedCard)&&this.updatePaymentMethod(this.selectedCard)}paymentStickyBtnClick(e){this.updatePaymentMethod({brand:"paypal",payment_method_type:"PAYPAL"})}validCvc(){this.creditCard.cvc&&(this.creditCard.cvc=this.creditCard.cvc.replace(/[^0-9]/g,""))}scrollTo(e){this.GeneralUtils.scrollToElement(e.target,100,"smooth")}validDate(e,t){if(e&&t){let n=new Date,i=n.getFullYear().toString(),a=t.toString(),s=Number(e),r=n.getMonth()+1;return i=Number(i[i.length-2]+i[i.length-1]),a=Number(a[a.length-2]+a[a.length-1]),!(s>12)&&(!(i>a||i==a&&r>s)||"Out of date")}return!1}cardType(e){return this.GeneralUtils.cardType(e)}cardNumbers(e){return e?e.split(" ").join("").length:0}addNewCard(){this.displayCreditCards=!1,this.selectedCard=null,this.Analytics.customEvent("Checkout","New Card","None")}cardConfirmation(e){this.creditCard.billing_address=e[0],this.stripeValidation?this.stripeService.stripeCheck(this.creditCard.billing_address).then(e=>{e.paymentMethod?(this.creditCard.method_id=null,this.creditCard.name=null,this.creditCard.payment_method_type="STRIPE",this.creditCard.payment_method=e.paymentMethod,e.paymentMethod.card&&(this.creditCard.brand=e.paymentMethod.card.brand||"unknown",this.creditCard.exp_month=e.paymentMethod.card.exp_month,this.creditCard.exp_year=e.paymentMethod.card.exp_year,this.creditCard.last4=e.paymentMethod.card.last4),this.isFullUserLoggedIn||(this.creditCard.user_save_address_payment_consent=this.creditCard.billing_address.user_address_consent),this.selectedCard&&this.creditcards.some((e,t)=>{if(this.isSameCard(e,this.selectedCard))return this.creditcards.splice(t,1),!0}),this.creditcards.push(this.creditCard),this.PaymentMethodsUtils.set
1LocalpaymentMethods(this.creditcards),this.displayCreditCards=!0,this.Analytics.customEvent("Checkout","Confirm Card","None"),this.updatePaymentMethod(this.creditcards[this.creditcards.length-1])):e.error&&this.ShareData.trigger("showError",e.error.message||e.error.code||"serverError")}).catch(e=>{console.log(e),this.ShareData.trigger("showError",e.message||e.data&&e.data.message||e.code||"serverError")}):(this.GeneralUtils.scrollToElement(document.querySelectorAll("form#creditcardForm")[0],50,"auto"),this.confirmRequest=!0)}isValid(e){return!0===this.validDate(e.exp_month,e.exp_year)}getCard(e){this.selectedCard=e}onStripeValidation(e){this.stripeValidation=e}checkOptimiseConditions(){this.addPaypal()}optimiseCheck(e){let t=e;if(0===t){let e=this.BasketService.getPaymentOptimise().name;e||(e=this.BasketService.optimiseRandRoot(t)),this.optimisePayment(e)}else this.addPaypal()}optimisePayment(e){"A-new-include-paypal"==e&&this.addPaypal(),this.Analytics.customEvent("Payment","Route",e),window.hj&&window.hj("tagRecording",["Payment "+e])}addPaypal(){return(0,i.mG)(this,void 0,void 0,function*(){if((yield this.Store.select("featureFlag","config","paypal_button").pipe((0,c.q)(1)).toPromise())&&(this.buttons1.push({image:this.subscriptionsFFEnabled?"svg/paypal-logo-full.svg":"svg/paypal-logo.svg",imageActive:this.subscriptionsFFEnabled?"svg/paypal-logo-full.svg":"svg/paypal-logo.svg",imageWidth:this.subscriptionsFFEnabled?103:45,title:this.subscriptionsFFEnabled?"":"PayPal",value:"PayPal",disabled:this.BasketService.subscriptionIncludedOnBasket(),btnClickFunction:()=>{this.payWith="PayPal",this.paymentSelectedEvent("PAYPAL"),this.updatePaymentMethod({brand:"paypal",payment_method_type:"PAYPAL"})}}),this.buttons2.unshift({image:this.subscriptionsFFEnabled?"svg/paypal-logo-full.svg":"svg/paypal-logo.svg",imageActive:this.subscriptionsFFEnabled?"svg/paypal-logo-full.svg":"svg/paypal-logo.svg",imageWidth:this.subscriptionsFFEnabled?103:45,title:this.subscriptionsFFEnabled?"":"PayPal",value:"PayPal",disabled:this.BasketService.subscriptionIncludedOnBasket(),btnClickFunction:()=>{this.payWith="PayPal",this.paymentSelectedEvent("PAYPAL"),this.updatePaymentMethod({brand:"paypal",payment_method_type:"PAYPAL"})}}),this.buttons3.push({image:this.subscriptionsFFEnabled?"svg/paypal-logo-full.svg":"svg/paypal-logo.svg",imageActive:this.subscriptionsFFEnabled?"svg/paypal-logo-full.svg":"svg/paypal-logo.svg",imageWidth:this.subscriptionsFFEnabled?103:45,title:this.subscriptionsFFEnabled?"":"PayPal",value:"PayPal",disabled:this.BasketService.subscriptionIncludedOnBasket(),btnClickFunction:()=>{this.payWith="PayPal",this.paymentSelectedEvent("PAYPAL"),this.updatePaymentMethod({brand:"paypal",payment_method_type:"PAYPAL"})}}),this.BasketService.subscriptionIncludedOnBasket())){const e=(e,t)=>"PayPal"===e.value?1:"PayPal"===t.value?-1:0;[this.buttons1,this.buttons2,this.buttons3].forEach(t=>t.sort((t,n)=>e(t,n)))}})}paymentSelectedEvent(e){this.SegmentService.track(h(["basket_size",this.basketSize],["payment_method",e],["items",this.items],...this.guestCheckoutEnabled?[["guest_checkout",this.UserUtils.isGuestUserLoggedIn()]]:[]))}get isFullUserLoggedIn(){return this.UserUtils.isFullUserLoggedIn()}getBillingAddressFromDelivery(){const e=(this.thortfulSubscription.subscriptionItemOption&&this.thortfulSubscription.subscriptionItemOption.format||"").toLowerCase(),t=this.basket&&this.basket.length&&this.basket.find(t=>{const n=t&&t.formats?t.formats:[];return!(e&&n&&n.some(t=>(t||"").toLowerCase()===e))&&t&&"home_fill"===t.recipient_type&&t.delivery_address&&t.delivery_address.valid_billing_address}),n=t?t.delivery_address:null;if(n){const e=["address1","address2","address3","city","postcode","country"],t=Object.keys(n).map(t=>e.includes(t)?n[t]:null,"").filter(e=>!!e).join(", ");n.addressComplete=t}this.billingAddressFromDelivery=n}setBillingAddressAndConfirmCard(){this.cardConfirmation([(0,a.Z)(this.billingAddressFromDelivery)])}removeBillingAddressFromDelivery(){this.useDeliveryAddress=!1}
1useSubscriptionButtonsStyling(){["1","2","3",""].forEach(e=>{const t=this["buttons"+e].findIndex(e=>"Card"===e.value);t>-1&&(this["buttons"+e][t].imageActive="svg/creditcard-icon-white.svg",this["buttons"+e][t].image="svg/creditcard-icon-black.svg",this["buttons"+e][t].imageWidth=24);const n=this["buttons"+e].findIndex(e=>"Google"===e.value);n>-1&&(this["buttons"+e][n].imageActive="svg/google-pay-full.svg",this["buttons"+e][n].image="svg/google-pay-full.svg",this["buttons"+e][n].imageWidth=69)})}}return e.\u0275fac=function(t){return new(t||e)(g.\u0275\u0275directiveInject(y.u),g.\u0275\u0275directiveInject(f.W),g.\u0275\u0275directiveInject(v.w),g.\u0275\u0275directiveInject(b.f),g.\u0275\u0275directiveInject(C.v),g.\u0275\u0275directiveInject(x.F0),g.\u0275\u0275directiveInject(_.t),g.\u0275\u0275directiveInject(P.c),g.\u0275\u0275directiveInject(s.BP),g.\u0275\u0275directiveInject(k.t),g.\u0275\u0275directiveInject(w.R),g.\u0275\u0275directiveInject(S.yh),g.\u0275\u0275directiveInject(M.H7),g.\u0275\u0275directiveInject(E.I),g.\u0275\u0275directiveInject(O._))},e.\u0275cmp=g.\u0275\u0275defineComponent({type:e,selectors:[["payment"]],decls:7,vars:4,consts:[[1,"basket-new-wrapper","content","padding"],["scroll-on-top","",1,"payment-wrapper"],["class","basket-buttons",4,"featureFlagDisabled"],[4,"featureFlag"],["class","payment-display",4,"ngIf"],["class","payment-inputs","id","creditcardForm",4,"ngIf"],[1,"basket-buttons"],[1,"sm","w900"],["className","payment",3,"buttonsData","selected"],["class","body",4,"featureFlag"],["class","payment-info-banner-container",3,"ngClass",4,"ngIf"],[1,"body"],[1,"payment-info-banner-container",3,"ngClass"],[3,"message"],["class","ng-container",4,"ngIf"],["class","basket-buttons",4,"ngIf"],[1,"ng-container"],[1,"basket-buttons",3,"ngClass"],["class","offer",4,"ngIf"],["class","no-offer",4,"ngIf"],[1,"offer"],[1,"no-offer"],["className","payment",3,"buttonsData","inColumn","selected"],[1,"payment-display"],[1,"w900"],[3,"cardList","selected","selectedChange","selectedCardChange"],[4,"featureFlagDisabled"],[1,"buttons","subscription-redesign"],["class","thor-btn block-btn orange-btn subscription-redesign",3,"ngClass","click",4,"ngIf"],[1,"thor-btn","subscription-redesign","add-card",3,"click"],[1,"thor-btn","block-btn","orange-btn","subscription-redesign",3,"ngClass","click"],[1,"buttons"],["class","thor-btn block-btn orange-btn",3,"ngClass","click",4,"ngIf"],[1,"lg","w900"],[1,"new-card","thor-btn","line-orange",3,"click"],[1,"thor-btn","block-btn","orange-btn",3,"ngClass","click"],["id","creditcardForm",1,"payment-inputs"],[3,"confirmRequest","cardType","valid"],[1,"sm","w900","billing-address"],["class","thor-checkbox p",4,"ngIf"],[1,"thor-checkbox","p"],["type","checkbox","name","saveCard",3,"ngModel","ngModelChange"],[3,"click"],[1,"unchecked"],[1,"hovered"],[1,"checked"],["class","thor-checkbox p use-delivery-billing-address-option",4,"ngIf"],["class","prefill-billing-address",4,"ngIf"],[1,"thor-checkbox","p","use-delivery-billing-address-option"],["type","checkbox","name","useDeliveryAddress",3,"ngModel","ngModelChange"],[1,"prefill-billing-address"],[1,"thor-input"],[1,"input-label"],["type","text","placeholder","e.g. Anna Smith","name","recipient","max-length","50","autocomplete","name","text-filtering","","data-hj-suppress","",1,"required",3,"ngModel","ngModelChange"],[1,"billing-address-from-delivery"],[1,"mdi","mdi-close",3,"click"],["class","thor-btn block-btn orange-btn subscription-redesign",3,"click",4,"featureFlag"],["class","thor-btn block-btn orange-btn",3,"click",4,"featureFlagDisabled"],[1,"thor-btn","block-btn","orange-btn","subscription-redesign",3,"click"],[1,"thor-btn","block-btn","orange-btn",3,"click"],["class","subscription-redesign",3,"addressData","addressSettings","onAddressConfirmation",4,"ngIf"],[1,"subscription-redesign",3,"addressData","addressSettings","onAddressConfirmation"],[3,"addressData","addressSettings","onAddressConfirmation",4,"ngIf"],[3,"addressData","addressSettings","onAddressConfirmation"]],template:function(e,t){1&e&&(g.\u0275\u0275elementStart(0,"div",0),g.\u0275\u0275element(1,"circle-steps"),g.\u0275\u0275elementStart(2,"div",1),g.\u0275\u0275template(3,T,5,3,"div",2),g.\u0275\u0275template(4,U,6,2,"ng-container",3),g.\u0275\u0275template(5,Y,6,5,"div",4),g.\u0275\u0275template(6,re,8,6,"form",5),g.\u0275\u0275elementEnd(),g.\u0275\u0275elementEnd()),2&e&&(g.\u0275\u0275advance(3),g.\u0275\u0275property("featureFlagDisabled","applepay_promo"),g.\u0275\u0275advance(1),g.\u0275\u0275property("featureFlag","applepay_promo"),g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf","Card"==t.payWith&&t.displayCreditCards),g.\u0275\u0275advance(1),g.\u0275\u0275property("ngIf","Card"==t.payWith&&!t.displayCreditCards))},styles:['.green[_ngcontent-%COMP%]{max-width:500px;margin:0 auto;background:#EDF9E7}.green[_ngcontent-%COMP%] .offer[_ngcontent-%COMP%]{text-align:center;font-size:16px;font-weight:700;padding-bottom:16px;color:#196141}.no-offer[_ngcontent-%COMP%]{font-weight:600;text-align:center;padding:50px 20px 20px}.payment-wrapper[_ngcontent-%COMP%]{padding:30px 0;min-height:500px;max-width:600px;margin:0 auto}.payment-wrapper[_ngcontent-%COMP%] .basket-buttons[_ngcontent-%COMP%]{padding:0 20px}.payment-wrapper[_ngcontent-%COMP%] .basket-buttons[_ngcontent-%COMP%] h4[_ng
1content-%COMP%]{text-align:center}.payment-wrapper[_ngcontent-%COMP%] .basket-buttons[_ngcontent-%COMP%] .body[_ngcontent-%COMP%]{font:normal 400 16px/100% Roboto,Arial,Helvetica,sans-serif;text-align:center}.payment-wrapper[_ngcontent-%COMP%] .pay-pal[_ngcontent-%COMP%]{margin:30px auto 36px;padding:0 20px}.payment-wrapper[_ngcontent-%COMP%] .pay-pal[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{text-align:center}.payment-wrapper[_ngcontent-%COMP%] .payment-inputs[_ngcontent-%COMP%]{max-width:500px;margin:20px auto;padding:0 20px}.payment-wrapper[_ngcontent-%COMP%] .payment-inputs[_ngcontent-%COMP%] h4.billing-address[_ngcontent-%COMP%]{margin-top:50px}.payment-wrapper[_ngcontent-%COMP%] .payment-inputs[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:5px 0}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] h5[_ngcontent-%COMP%]{text-align:center;margin:28px 0}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] h6[_ngcontent-%COMP%]{text-align:center;margin:30px 0 20px}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .buttons[_ngcontent-%COMP%]{padding:0 10px;text-align:center}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .buttons.subscription-redesign[_ngcontent-%COMP%]{padding:0 20px}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .buttons[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{max-width:200px}@media (min-width: 769px){.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .buttons[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{max-width:360px}}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .buttons[_ngcontent-%COMP%] button.subscription-redesign[_ngcontent-%COMP%]{width:100%;height:44px;max-width:unset;text-transform:none;border-radius:4px;margin-bottom:8px}@media (min-width: 769px){.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .buttons[_ngcontent-%COMP%] button.subscription-redesign[_ngcontent-%COMP%]{max-width:360px}}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .buttons[_ngcontent-%COMP%] button.subscription-redesign.add-card[_ngcontent-%COMP%]{border:#ff6900 1px solid;background-color:#fff;color:#ff6900}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .new-card[_ngcontent-%COMP%]{margin:auto;width:149.7px;display:block;height:90.4px;border-radius:5.9px;border:solid 3px #ff6900;font-size:72px;font-weight:200;line-height:45px;padding:19px 0}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] .orange-btn[_ngcontent-%COMP%]{margin:0 auto 24px}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] li.horizontal[_ngcontent-%COMP%]{display:inline-block}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] ul[_ngcontent-%COMP%]{margin:0 auto;padding:0 20px;text-align:center}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{-webkit-transition:width 2s,margin 2s,-webkit-transform .4s;transition:width 2s,margin 2s,-webkit-transform .4s;transition:width 2s,margin 2s,transform .4s;transition:width 2s,margin 2s,transform .4s,-webkit-transform .4s;-webkit-animation:.3s ease-out;animation:.3s ease-out;width:90px}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li.selected[_ngcontent-%COMP%]{-webkit-transform:scale(0);transform:scale(0);margin:0;width:0px}.payment-wrapper[_ngcontent-%COMP%] .payment-display[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] li[_ngcontent-%COMP%]:not(:last-child){margin-right:20px}.payment-wrapper[_ngcontent-%COMP%] li.horizontal[_ngcontent-%COMP%]{display:inline-block}.payment-wrapper[_ngcontent-%COMP%] .card-logo[_ngcontent-%COMP%]{margin:30px auto;max-width:310px}.payment-wrapper[_ngcontent-%COMP%] .card-logo[_ngcontent-%COMP%] li[_ngcontent-%COMP%]:not(:last-child){margin-right:20px}.payment-wrapper[_ngcontent-%COMP%] .card-logo[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:90px}.payment-wrapper[_ngcontent-%COMP%] .thor-input[_ngcontent-%COMP%] input[type=tel].cvc[_ngcontent-%COMP%]{font-family:"Roboto",sans-serif}@media (min-width: 769px){.payment-wrapper[_ngcontent-%COMP%] .sticky-button-payment[_ngcontent-%COMP%]{width:360px;margin:0 auto}}.payment-wrapper[_ngcontent-%COMP%] .payment-info-banner-container[_ngcontent-%COMP%]{width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;justify-self:center;margin:0 auto;max-width:unset}@media (min-width: 769px){.payment-wrapper[_ngcontent-%COMP%] .payment-info-banner-container[_ngcontent-%COMP%]{max-width:360px}.payment-wrapper[_ngcontent-%COMP%] .payment-info-banner-container.two-button-row[_ngcontent-%COMP%]{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;max-width:620px}}.use-delivery-billing-address-option[_ngcontent-%COMP%]{margin:20px 0}.prefill-billing-address[_ngcontent-%COMP%]{margin:20px 0;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;grid-gap:20px;gap:20px}.prefill-billing-address[_ngcontent-%COMP%] .input-label[_ngcontent-%COMP%]{font-size:16px}.prefill-billing-address[_ngcontent-%COMP%] .billing-address-from-delivery[_ngcontent-%COMP%]{width:100%;background-color:#f8f8f8;padding:12px 32px 12px 12px;position:relative;font-size:14px}.prefill-billing-address[_ngcontent-%COMP%] .billing-address-from-delivery[_ngcontent-%COMP%] .mdi-close[_ngcontent-%COMP%]{position:absolute;top:10px;right:12px;font-weight:bold;font-size:16px;color:#ff6900}.prefill-billing-address[_ngcontent-%COMP%] button.subscription-redesign[_ngcontent-%COMP%]{width:100%;height:44px;max-width:unset;text-transform:none;border-radius:4px}@media (min-width: 769px){.prefill-billing-address[_ngcontent-%COMP%] button.subscription-redesign[_ngcontent-%COMP%]{max-width:360px;-ms-flex-item-align:center;align-self:center}} thor-address.subscription-redesign button, thor-address.subscription-redesign .address-link{width:100%;height:44px;max-width:unset;text-transform:none;border-radius:4px;margin-bottom:8px!important}@media (min-width: 769px){ thor-address.subscription-redesign button, thor-address.subscription-redesign .address-link{max-width:360px}} thor-address.subscription-redesign .address-link{border:#ff6900 1px solid;background-color:#fff;color:#ff6900;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin:auto}@media (min-width: 769px){ thor-address.subscription-redesign .address-link{max-width:360px}}@media (min-width: 769px){ thor-address.subscription-redesign a.orange{font-size:16px!important}}']}),e})();var le=(()=>{return(e=le||(le={})).PAYPAL="PAYPAL",e.STRIPE="STRIPE",e.APPLEPAY="APPLEPAY",e.GOOGLEPAY="GOOGLEPAY",le;var e})()},73403:function(e,t,n){n.d(t,{P:function(){return a}});var i=n(95410);function a(e){return e.filter(e=>"A5"===e.format&&(e.price===i.g.Price||"STANDARD"===e.price_class)).reduce((e,t)=>
1e+t.quantity,0)}},55519:function(e,t,n){n.d(t,{t:function(){return l}});var i=n(62415),a=n(17291),s=n(38592),r=n(36951),o=n(37403);let l=(()=>{class e{constructor(e,t,n,i){this.ShareData=e,this.Api=t,this.Endpoint=n,this.UserUtils=i,this.localpaymentMethods=[],this.ShareData.listen("logoutSuccess",()=>{this.localpaymentMethods=[]})}getPaymentMethods(){return this.localpaymentMethods.length?Promise.resolve(this.localpaymentMethods):this.UserUtils.getPaymentMethods()}refreshPaymentMethod(){return this.UserUtils.getPaymentMethods().then(e=>{this.localpaymentMethods=e})}setLocalpaymentMethods(e){this.localpaymentMethods=e}deletePaymentMechanism(e){return this.Api.request(this.Endpoint.deletePaymentMech+"/"+e,{method:"DELETE"})}}return e.\u0275fac=function(t){return new(t||e)(i.\u0275\u0275inject(a.u),i.\u0275\u0275inject(s.V),i.\u0275\u0275inject(r.F),i.\u0275\u0275inject(o.f))},e.\u0275prov=i.\u0275\u0275defineInjectable({token:e,factory:e.\u0275fac,providedIn:"root"}),e})()}}]);
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.