1System.register(["./helpers-D8waZai_.js","@vp/ctc-reader","@vp/auth"],(function(R,nt){"use strict";var T,E,y,v,m,g,N,b,_,S,O,$,V,L,z,A;return{setters:[function(c){T=c.C,E=c.a,y=c.b,v=c.i,m=c.f,g=c.c,N=c.D,b=c.V,_=c.d,S=c.e,O=c.g,$=c.h,V=c.I,L=c.S,R({COOKIE_DATA:c.j,EVENTS:c.E,QUERY_PARAMETERS:c.Q,appendSubtenant:c.b,executeAfterPricingContextEvent:c.k,getPcxtV3:c.l,initializePricingContext:c.m,isSubtenantMandatory:c.i})},function(c){z=c.default},function(c){A=c.default}],execute:(function(){let c;const ot=function(){if(typeof document>"u"||typeof document.cookie>"u")return;const e=(typeof window<"u"?window.location.hostname??"":"").split(".");for(let n=0;n<e.length-1;n++){const o=e.slice(n).join(".");document.cookie=`${T}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=.${o};path=/`}},h=function(t){const e=new Date,n=new Date(e.getTime()+1e3*604800),o=j(t),i=`${T}=${o};expires=${n.toUTCString()};SameSite=Strict;path=/`;typeof document<"u"&&typeof document.cookie<"u"&&(ot(),document.cookie=i),c=i},rt=function(){const t=new Date,e=new Date(t.getTime()+1e3*604800),o=`${T}=;expires=${e.toUTCString()};SameSite=Strict;path=/`;typeof document<"u"&&typeof document.cookie<"u"&&(document.cookie=o),c=o},it=()=>{const t=typeof document<"u"&&typeof document.cookie<"u"&&document.cookie!==""&&document.cookie.match(E)?document.cookie:c;try{const e=t.match(E);return e?e[2]:null}catch{return null}},j=function(t){return btoa(JSON.stringify(t)).replace(/\+/g,"-").replace(/=/g,"").replace(/\//g,"_")},ct=function(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=JSON.parse(atob(e));return typeof n.expiresAt=="string"&&(n.expiresAt=new Date(n.expiresAt)),n},st=()=>{const t=it();if(!t)return null;try{return ct(t)}catch(e){return console.error("Error decoding context string",e),null}},U=function(t){try{const e=z.getAllTreatments();return t?[...new Set([...t,...e])]:e}catch(e){console.log(`treatment initialization failed on: ${e.message}`)}return t},G=function(t){const e=new Date;return new Date(e.getTime()+t*6e4)},P=()=>new Date().toISOString(),at=function(t){return/\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2]\d|3[0-1])T(?:[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+|)(?:Z|(?:\+|\-)(?:\d{2}):?(?:\d{2}))/.test(t)},I=()=>{try{const t=new(A.WebAuth??A.default.WebAuth);return{authorization:t.getAuthorizationHeader(),shopperId:t.getCanonicalId()}}catch{return{}}},C=function(t){return!!(t&&t.shopperId&&t.authorization)},Q=async(t,e)=>{if(t===void 0||e===void 0)return;const n=e.toUpperCase(),o=t.toUpperCase();if(n==="VISTAPRINT"&&o==="FR"){if(window&&window.location&&window.location.host&&window.location.pathname&&window.location.host.includes("www.vistaprint.")){const{includedUrls:i}=await nt.import("./vat-fr-included-urls-B9d65g-m.js");return i.includes(window.location.pathname)}return!1}if(o==="SG"&&new Date().toISOString()>="2023-04-03T14:00:00.000Z")return!0;if(n==="VISTAPRINT"||n==="VISTAPRINT-FASHION-MASKS"||n==="VISTAPRINT-PAYPAL")switch(o){case"US":case"CA":case"NZ":case"SG":return!1;default:return!0}else if(n==="PROMOTIQUE")switch(o){case"DE":case"AU":case"IN":return!0;default:return!1}return!1},F=async(t,e,n)=>n.vatInclusive!==void 0?n.vatInclusive:t.vatInclusive!==void 0?t.vatInclusive:e.vatInclusive===void 0?Q(e.market,e.merchantId):e.vatInclusive;function dt(t){return new Promise((e,n)=>{setTimeout(()=>{n(new Error("Request timed out."))},t)})}function J(t,e){const n=new AbortController;return Promise.race([fetch(t,{...e,signal:n.signal}),dt(e.timeout)]).catch(o=>(o.message==="Request timed out."&&n.abort(),new Response(null,{status:408,statusText:"Request timed out."})))}const K=function(){return window&&window.location&&window.location.href?`pcxt-${encodeURIComponent(window.location.href.substring(0,100))}`:"pcxt"},Y="https://pricing-context-service.personalization.vpsvc.com",D=async function(t){if(!t.merchantId||!t.market||!t.shopperInfo)throw new Error("Missing input for pricing context service");const e=K(),n=`${Y}/v1/pricingContext/${t.merchantId}/${t.market}/${t.shopperInfo.shopperId}`;let o=`?developmentMode=${t.developmentMode}&Requestor=${e}`;t.subtenant&&(o=y(o,t.subtenant)),t.tenant&&(o+=`&tenant=${encodeURIComponent(t.tenant)}`),o+=t.effectiveDateTime?at(t.effectiveDateTime)?`&EffectiveDateTime=${t.effectiveDateTime}`:"&EffectiveDateTime=clear":"";const i=await J(n+encodeURI(o),{timeout:1500,headers:{"Content-Type":"application/json",Authorization:t.shopperInfo.authorization||""}});if(i.status>=400&&i.status<600)throw new Error(`Pricing Context Service returned ${i.status}`);return await i.json()},pt=async function(t){if(!t.merchantId||!t.market||!t.shopperInfo)throw new Error("Missing input for pricing context service");const e=K(),n=`${Y}/v1/pricingContext/${t.merchantId}/${t.market}/${t.shopperInfo.shopperId}
1/applyCoupon`;let o=`?developmentMode=${t.developmentMode}&Requestor=${e}`;t.subtenant&&(o=y(o,t.subtenant)),t.tenant&&(o+=`&tenant=${encodeURIComponent(t.tenant)}`);const i=await J(n+encodeURI(o),{method:"POST",body:JSON.stringify({couponCode:t.couponCode}),timeout:5e3,headers:{"Content-Type":"application/json",Authorization:t.shopperInfo.authorization||""}});if(i.status!==422&&i.status>=400&&i.status<600)throw new Error(`Pricing Context Service returned ${i.status}`);return await i.json()},ut="ubik-tenant-mappings",ft="ubik-user-context",H=t=>{if(typeof document>"u")return;const e=document.getElementById(t);if(e?.textContent)try{return JSON.parse(e.textContent)}catch{return}},mt=()=>H(ut)?.pricing||void 0,lt=()=>H(ft)?.tenant||void 0,w=t=>({merchant:mt()??t,tenant:lt()??t}),vt=function(){return["version","vatInclusive","expiresAt","developmentMode","shopperId","tenant"]},B=()=>({version:0,merchantId:void 0,market:void 0,couponCode:void 0,effectiveDateTime:void 0,customerGroups:void 0,vatInclusive:void 0,expiresAt:void 0,developmentMode:void 0,shopperId:void 0,subtenant:void 0,tenant:void 0}),f=(t=!1,e=!1)=>{const n=st();if(n===null)throw new Error("Pricing context module not initialized.");let o=n;try{if(t){const i=o;o=Object.keys(i).filter(r=>i[r]!==void 0).filter(r=>i[r]!=="").reduce((r,p)=>(r[p]=i[p],r),{version:0})}if(e){const i=o,a=vt();o=Object.keys(i).filter(p=>!a.includes(p)).reduce((p,s)=>(p[s]=i[s],p),{version:0})}return o.customerGroups=U(n.customerGroups),o}catch{throw new Error("Failed to decode pricing context string.")}},ht=function(){return j(f(!0,!0))},It=function(){const t=f();t.couponCode=void 0,t.expiresAt=G(5),h(t)},gt=(t=!1)=>{const e=f(!0,!0),n=Object.keys(e),o=e;let i=n.filter(r=>o[r]!==void 0).filter(r=>!Array.isArray(o[r])).map(r=>`${r}=${o[r]}`).join("&");const a=n.filter(r=>o[r]!==void 0).filter(r=>Array.isArray(o[r]));for(let r=0;r<a.length;r+=1){const p=a[r];if(p){const s=o[p].map(l=>`${p}=${l}`).join("&");i+=`&${s}`}}return t?encodeURI(i):i},W=function(t,e){return t.couponCode?t.couponCode.toUpperCase()===e?.toUpperCase():!e},X=async(t,e)=>{const n=I();if(!C(n))throw new Error("Missing shopper info");const{tenant:o}=w(t.tenant),i=await pt({merchantId:t.merchantId,market:t.market,shopperInfo:n,couponCode:e,developmentMode:!!t.developmentMode,subtenant:t.subtenant,tenant:o});return{nextContext:{...i.currentPricingContext,vatInclusive:t.vatInclusive,shopperId:n.shopperId,tenant:o},validationErrors:i.validationErrors||[],couponInfoLinks:i.couponInfoLinks||{}}},Z=async function({couponCode:t}){const e=f();if(!e.couponCode||e.couponCode.toUpperCase()!==t?.toUpperCase())try{const{nextContext:n,validationErrors:o,couponInfoLinks:i}=await X(e,t);return h(n),m(O,n),m(g,n),{couponApplied:W(n,t),validationErrors:o,couponInfoLinks:i,currentPricingContext:n}}catch{console.info("Retaining existing context")}return{couponApplied:W(e,t),validationErrors:["UnableToValidate"],couponInfoLinks:{},currentPricingContext:e}},Ct=async function(t){if(typeof t!="string"&&!(t instanceof String))throw new Error("Mu
1st pass a string for parameter 'effectiveDateTime'");const e=t.toString(),n=f();if(e!==n.effectiveDateTime)try{const o=I();if(!C(o))throw new Error("Missing shopper info to call for remote context");const{tenant:i}=w(n.tenant),r={...await D({merchantId:n.merchantId,market:n.market,shopperInfo:o,effectiveDateTime:e,developmentMode:!!n.developmentMode,subtenant:n.subtenant,tenant:i}),vatInclusive:n.vatInclusive,shopperId:o.shopperId,tenant:i};h(r),m(g,r),r.effectiveDateTime&&r.effectiveDateTime!==n.effectiveDateTime&&m(N,r)}catch{console.info("Retaining existing context")}},wt=function(t){const e=f();e.vatInclusive=t,h(e),m($,e),m(g,e)},M=function(){const t={};if(typeof window>"u"||typeof window.location>"u"||!window.location.search)return t;const e=new URLSearchParams(window.location.search.toUpperCase()),n=e.get(b);n&&(t.vatInclusive=n==="TRUE");const o=e.get(_);if(o&&(t.effectiveDateTime=o),Array.from(e.keys()).find(r=>r===S)!==void 0){const r=new URLSearchParams(window.location.search),p=Array.from(r.keys()).find(s=>s.toUpperCase()===S);t.couponCode=p?r.get(p)??void 0:void 0}return t},q=async()=>{const t=M();let e;try{e=f()}catch{return}if(!e.expiresAt||e.expiresAt.toISOString()<=P())return;const n=I(),o=n&&n.shopperId?n.shopperId:"";if(!C(n)||e===void 0||e.merchantId===void 0||e.market===void 0||v(e.merchantId)&&e.subtenant===void 0)return;const{tenant:i}=w(e.tenant);let a;try{a=await D({merchantId:e.merchantId,market:e.market,shopperInfo:n,effectiveDateTime:t.effectiveDateTime,developmentMode:!!e.developmentMode,subtenant:e.subtenant,tenant:i})}catch{return}a.customerGroups=U(a.customerGroups),a.vatInclusive=await F(e,a,t),a.shopperId=o,a.tenant=i;let r;try{r=f()}catch{return}e.merchantId!==r.merchantId||e.market!==r.market||(h(a),m(g,a))},tt=t=>{if(!(typeof t=="string"||t instanceof String))return;const e=t.toString();return e===""||e.toLowerCase()==="undefined"?void 0:e},xt=(t,e,n,o)=>{const i=I(),a=M(),{merchant:r,tenant:p}=w(tt(t));let s;try{s=f()}catch{s=B()}return r&&e&&n!==void 0?s.shopperId!==void 0&&(!i.shopperId||i.shopperId===s.shopperId)&&s.developmentMode===n&&s.expiresAt!==void 0&&s.expiresAt.toISOString()>P()&&s.merchantId===r.toUpperCase()&&s.market===e.toUpperCase()&&(!a.effectiveDateTime||s.effectiveDateTime===a.effectiveDateTime)&&(!a.couponCode||s.couponCode?.toUpperCase()===a.couponCode.toUpperCase())&&(!v(s.merchantId)||s.subtenant===o)&&s.tenant===p:!(s.merchantId===void 0||s.market===void 0||s.vatInclusive===void 0||v(s.merchantId)&&s.subtenant===void 0)};async function Tt(t,e,n=!1,o){const{merchant:i,tenant:a}=w(tt(t));
1if(i===void 0)throw new Error("Must pass a non-empty, defined string for parameter 'merchantId'");const r=i;if(!(typeof e=="string"||e instanceof String)||e===""||e.toLowerCase()==="undefined")throw new Error("Must pass a non-empty, defined string for parameter 'market'");const p=e.toString();if(v(r)&&(!(typeof o=="string"||o instanceof String)||o===""||o.toLowerCase()==="undefined"))throw new Error(`Must pass a non-empty, defined string for parameter 'subtenant' for merchantId ${r}`);const s=o?.toString(),l=M();let u;try{u=f()}catch{u=B()}const x=I(),k=x&&x.shopperId?x.shopperId:"",Et=u.developmentMode!==n||u.expiresAt===void 0||u.expiresAt.toISOString()<=P()||u.merchantId!==r.toUpperCase()||u.market!==p.toUpperCase()||l.effectiveDateTime&&u.effectiveDateTime!==l.effectiveDateTime||v(r)&&u.subtenant!==s||u.tenant!==a,yt=k!==""&&u.shopperId!==k;let d;if(Et||yt)try{if(!C(x))throw new Error("Missing shopper info to call for remote context");d=await D({merchantId:r,market:p,shopperInfo:x,effectiveDateTime:l.effectiveDateTime,developmentMode:n,subtenant:s,tenant:a})}catch{d=u,d.merchantId=r.toUpperCase(),d.market=e.toUpperCase(),d.expiresAt=G(1),d.developmentMode=n,d.subtenant=s}else d=u;if(d.customerGroups=U(d.customerGroups),d.vatInclusive=await F(u,d,l),d.shopperId=k,d.tenant=a,l.couponCode!==void 0&&d.couponCode?.toUpperCase()!==l.couponCode.toUpperCase())try{const{nextContext:St}=await X(d,l.couponCode);d=St}catch{console.info("Retaining context without coupon from query param")}return h(d),m(V,d),d}const et=R("default",{version:"@PCM_CURRENT_VERSION@",getPricingContext:f,getEncodedContextString:ht,getContextAsQueryString:gt,setEffectiveDateTime:Ct,setCouponCode:async function(e){if(typeof e=="string"||e instanceof String){const n=e.toString();return await Z({couponCode:n})}
1else throw new Error("Must pass a string for parameter 'couponCode'")},getCouponCode:function(){return f().couponCode},setVatInclusive:function(e){let n;if(typeof e=="boolean"||e instanceof Boolean)n=!!e;else if(e!==void 0&&e!==""&&(e.toUpperCase()==="TRUE"||e.toUpperCase()==="FALSE"))n=e.toUpperCase()==="TRUE";else throw new Error("Must pass a boolean for parameter 'isInclusive'");wt(n)},isVatInclusive:function(){return f().vatInclusive},isDefaultTaxInclusive:Q,orderPlaced:async function(){It(),await Z({})},isInitialized:xt,init:Tt,reset:()=>{rt()}});C(I())?q():window.addEventListener("userIdentity",function t(){window.removeEventListener("userIdentity",t),q()}),document.pcxtV3=et,m(L,{version:et.version})})}})); 2//# sourceMappingURL=pricing-context-module-ZfeFEy5Y.js.map
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.