PageSourceSearch

https://www.vistaprint.nl/assets/ubik/web/@vp/ubik-context/1.2.17/lib/web/systemjs/ubik-context-CH-yL_c5.js

js vistaprint.nl collected 2026-10-03 21:20:10 UTC 10,451 bytes, 2 lines download raw bytes

1System.register(["react/jsx-runtime","react","@vp/ubik-logging"],(function(s,O){"use strict";var g,_,F,l,p,H,w,L,P,U,C,K,$,N,W;return{setters:[function(i){g=i.jsx,_=i.jsxs,F=i.Fragment},function(i){l=i.default,p=i.useState,H=i.useLayoutEffect,w=i.useEffect,L=i.useContext,P=i.createContext,U=i.useId,C=i.useRef,K=i.lazy,$=i.useMemo,N=i.Suspense},function(i){W=i.createLogger}],execute:(function(){s({LazyIsland:Y,captureLazyIslandSnapshots:fe,lazyIsland:ve,useStyles:X});const i=s("StyleContext",l.createContext(void 0));function X(...t){const e=l.useContext(i);if(!e)throw new Error("useStyles must be used within a StyleContextProvider");const n=t.filter(r=>typeof r=="string");if(typeof window<"u"){const[r,d]=p(n);H(()=>{const a=e.insertCss(...r);return()=>{a()}},[r,e]),O.meta.hot&&w(()=>{if(!e.subscribe)return;const a=e.subscribe(o=>{const{oldStylesheet:f,newStylesheet:u}=o;if(r.some(c=>c===f)){const c=r.filter(y=>y!==f);d([...c,u])}});return()=>{a()}},[r,e])}else e.insertCss(...n)}const Ie=s("StyleContextProvider",({value:t,children:e})=>g(i.Provider,{value:t,children:e})),j=l.createContext({registerStyleKeys:t=>{}}),xe=s("SwanStyleRegistryProvider",j.Provider),Le=s("useSwanStyleKeys",t=>{const e=l.useContext(j),n=t.filter(r=>r!=="core");e.registerStyleKeys(["coreOmitVistaprint","utility",...n])}),Ee=s("useSwanFontKeys",t=>{});var ee=Object.defineProperty,te=(t,e,n)=>e in t?ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,A=(t,e,n)=>te(t,typeof e!="symbol"?e+"":e,n);class ne{constructor(){A(this,"subscribers",new Set),A(this,"eventListenerAdded",!1),A(this,"handleHMREvent",e=>{const{detail:n}=e;n.newStylesheet&&n.oldStylesheet&&this.subscribers.forEach(r=>r(n))})}subscribe(e){return this.subscribers.add(e),!this.eventListenerAdded&&typeof window<"u"&&window.addEventListener&&(window.addEventListener("ubik-style-hmr",this.handleHMREvent),this.eventListenerAdded=!0),()=>{this.subscribers.delete(e)}}}var re=Object.defineProperty,se=(t,e,n)=>e in t?re(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,b=(t,e,n)=>se(t,typeof e!="symbol"?e+"":e,n);class ie{constructor(e,n){this.onInsert=e,this.onRemove=n,b(this,"styles",new Set)}insertCss(...e){return e.forEach(n=>{this.insert(n)}),()=>{}}insert(e){return e.trim()?this.styles.has(e)?!1:(this.styles.add(e),this.onInsert?.(e),!0):!1}getStyles(){return Array.from(this.styles.values())}}const S=class v{constructor(e,n){this.onInsert=e,this.onRemove=n,v.initialize()}static initialize(){this.initialized||(typeof document<"u"&&Array.from(document.querySelectorAll("style")).forEac
1h(n=>{const r=n.textContent??"";r.trim()&&(this.styles.add(r),this.refCounts.set(r,1),this.styleElements.set(r,n))}),this.styleListener.subscribe(({oldStylesheet:e})=>{const n=this.styleElements.get(e);n&&(n.remove(),this.styleElements.delete(e)),this.styles.delete(e),this.refCounts.delete(e)}),this.initialized=!0)}insertCss(...e){const n=[];return e.forEach(r=>{if(!r.trim())return;n.push(r),this.insert(r)&&this.onInsert?.(r)}),()=>{n.forEach(r=>{this.remove(r)&&this.onRemove?.(r)})}}insert(e){if(!e.trim())return!1;const n=v.refCounts.get(e)??0;return v.refCounts.set(e,n+1),v.styles.has(e)?!1:(v.styles.add(e),!0)}remove(e){const n=v.refCounts.get(e)??0;return n===0?!1:n<=1?(v.styles.delete(e),v.refCounts.delete(e),!0):(v.refCounts.set(e,n-1),!1)}getStyles(){return Array.from(v.styles.values())}subscribe(e){return v.styleListener.subscribe(e)}};b(S,"styleListener",new ne),b(S,"initialized",!1),b(S,"styles",new Set),b(S,"refCounts",new Map),b(S,"styleElements",new Map);let I=S;const oe=()=>new I(t=>{let e=I.styleElements.get(t);e||(e=document.createElement("style"),e.textContent=t,document.head.appendChild(e),I.styleElements.set(t,e))},t=>{const e=I.styleElements.get(t);e&&(e.remove(),I.styleElements.delete(t))}),Pe=s("webStyleRegistry",()=>oe()),Ae=s("createStyleRegistry",(t,e)=>new ie(t,e)),k=s("UserContextContext",l.createContext(void 0)),ke=s("UserContextProvider",k.Provider),Te=s("useUserContext",()=>{const t=l.useContext(k);if(!t)throw new Error("useUserContext must be used within a UserContextProvider");return t.userContext}),Re=s("useUserContextTracker",()=>{const t=l.useContext(k);if(!t)throw new Error("useUserContext must be used within a UserContextProvider");return e=>{typeof window<"u"&&(e?.type==="experiment"||e?.type==="featureFlag")?O.import("@vp/ab-reader").then(n=>{n&&(n.initialize(),n.waitTillAvailable(1e3).then(r=>{if(!r){console.warn("AbReader is not available");return}const d=ue();e?.type==="experiment"&&!Object.keys(d.experiments).includes(e.name)&&n.fireImpression(e.name,e.variation),e?.type==="featureFlag"&&!Object.keys(d.featureFlags).includes(e.name)&&n.isFeatureEnabled(e.name)}))}):t.trackedUserContext.push(e)}}),ue=s("getContextTracking",()=>{const e=(typeof document<"u"?document.getElementById("ubik-context-tracking"):null)?.innerText;if(!e)return console.warn('User context not found with element with id "ubik-context-tracking"'),{experiments:{},treatments:{},featureFlags:{},campaigns:[]};try{return JSON.parse(e)}catch(n){return console.warn("Error parsing user context tracking",n),{experiments:{},treatments:{},featureFlags:{},campaigns:[]}}}),ze=s("trackRuntimeEvent",(t,e,n="click")=>{ae({triggerId:t,eventType:n,eventData:{data:e}})}),ae=s("track",async t=>{if(typeof window<"u"&&window._ubik&&!Array.isArray(window._ubik)){const e=window._ubik;if(e.track)try{await e.track(t)}catch(n){console.warn("Error tracking event",n)}else console.warn("Tracking is not available on ubik runtime")}else console.warn("Ubik runtime is not available")}),q=l.createContext({headingLevel:1}),Me=s("HeadingLevelProvider",q.Provider),Oe=s("useHeadingLevel",()=>l.useContext(q)),T=s("IdentityContext",l.createContext(void 0)),_e=s("createAuthConfig",({baseConfig:t,signInInfoText:e,developmentMode:n=!1})=>({...t,developmentMode:n,options:{...t.options,customText:e?JSON.stringify({signIn:{info:e}}):t.options?.customText}})),ce={signIn(){},signOut(){},onUserIdentityUpdate(){},getIdentity(){return{profile:{},accessToken:"",authorization:"",authorizationHeader:"",isSignedIn:!1}},getProfile(){return{}},getCanonicalId(){return""},getToken(){return""},getAuthorizationHeader(){return""},getAuthorization(){return""},isSignedIn(){return!1}};function D(t){return t==null}const Fe=s("IdentityProvider",({auth:t,children:e})=>{const[n,r]=p(void 0),[d,a]=p({auth:ce,signIn:()=>{},signOut:()=>{},identity:void 0,isIdentityInitialized:!1,isCustomer:!0,isSignedIn:!1});return w(()=>{if(typeof window<"u"&&window._ubik!==void 0&&!Array.isArray(window._ubik)){const o=window._ubik.getIdentity?.();D(o)||a(o)}else System.import("@vp/auth").then(r);typeof window<"u"&&window.addEventListener("_UBIK_Auth_updated",function(f){console.log(f);const u="detail"in f?f.detail:void 0;D(u)||a(u)})},[]),w(()=>{n&&n.init(t,()=>{const o=new n.WebAuth,f=o.getProfile()["https://claims.cimpress.io/is_customer"]!==void 0;o.onUserIdentityUpdate(u=>{if(!u)return;const c=!!u.authorizationHeader&&u.isSignedIn;
1a({auth:o,signIn:(y=[],h=[],m={})=>o.signIn(y,h,m),signOut:y=>o.signOut(y),isIdentityInitialized:!0,identity:u,isCustomer:f,isSignedIn:c})})})},[n]),g(T.Provider,{value:d,children:e})}),He=s("IdentityConsumer",T.Consumer),Ue=s("useIdentity",()=>{const t=L(T);if(t===void 0)throw new Error("useIdentity must be used within an IdentityProvider");return t}),B=s("LoggerContext",P(void 0)),R={},le=t=>`${t.serviceName}|${t.newrelicApplicationId}|${t.microAgentLogLevel}|${t.logLevel}`,de=t=>{const e=le(t);return R[e]||(R[e]=W(t)),R[e]},Ke=s("useLogger",()=>{const t=L(B);if(t===void 0)throw new Error("useLogger must be used within a LoggerProvider");return t}),$e=s("LoggerProvider",t=>{const e=de(t.loggerOptions||{serviceName:"defaultLogger"});return t.userContext!=null&&e.setContext({tenant:t.userContext.tenant,locale:t.userContext.locale,urlId:t.userContext.urlId}),g(B.Provider,{value:e,children:t.children})}),V=s("TenantMappingContext",l.createContext(void 0)),Ne=s("TenantMappingProvider",V.Provider),We=s("useTenantMappings",()=>{const t=l.useContext(V);if(t===void 0)throw new Error("useTenantMappings must be used within a TenantMappingProvider");return t}),E=new Map,z=new Map,J=P(null),x="data-ubik-island";function fe(t){if(t===null||typeof t.querySelectorAll!="function")return;t.querySelectorAll(`[${x}]`).forEach(n=>{const r=n.getAttribute(x);if(r===null||E.has(r))return;E.set(r,ge(n.innerHTML));const a=(typeof n.closest=="function"?n.parentElement?.closest(`[${x}]`)??null:null)?.getAttribute(x)??null;if(a!==null){const o=z.get(a)??[];o.push(r),z.set(a,o)}})}function ge(t){return t.replace(/<!--(?:\/?\$[?!~]?|\/?&)-->/g,"")}function ye(t){E.delete(t)}function he(t,e,n){const r=e==="eager",d=typeof document>"u",[a,o]=p(!1),f=n?.rootMargin??"200px",u=n?.timeout??2e3;return w(()=>{if(r||a)return;const c=()=>o(!0);if(e==="idle"){const y=typeof requestIdleCallback=="function"?requestIdleCallback:void 0;if(y){const m=y(c,{timeout:u});return()=>cancelIdleCallback(m)}const h=setTimeout(c,u);return()=>clearTimeout(h)}if(e==="visible"){const y=t.current;if(y===null||typeof IntersectionObserver>"u"){c();return}const h=new IntersectionObserver(m=>{m.some(M=>M.isIntersecting)&&c()},{rootMargin:f});return h.observe(y),()=>h.disconnect()}},[r,a,e,f,u,t]),r||d||a}function Y({load:t,componentProps:e,fallback:n=null,as:r="div",onLoad:d,loadOn:a="eager",loadOnOptions:o}){const f="island-"+U(),u=L(J),c=C(null);u!==null&&c.current===null&&(c.current=u.claim());const h=(u!==null&&c.current!==null?u.childIds[c.current]:void 0)??f,m=C(null);m.current===null&&(m.current=K(async()=>({default:await t()})));const M=m.current,Z=C(null),Ce=he(Z,a,o),G=E.get(h),Q=G!==void 0?g(we,{html:G}):n,be=C(0),Se=$(()=>({childIds:z.get(h)??[],claim:()=>be.current++}),[h]),pe=r;return g(J.Provider,{value:Se,children:g(pe,{ref:Z,[x]:h,suppressHydrationWarning:!0,children:g(N,{fallback:Q,children:Ce?_(F,{children:[g(M,{...e}),g(me,{id:h,onLoad:d})]}):Q})})})}function ve(t,e={}){function n(r){return g(Y,{load:t,componentProps:r,fallback:e.fallback,as:e.as,onLoad:e.onLoad,loadOn:e.loadOn,loadOnOptions:e.loadOnOptions})}return n}function me({id:t,onLoad:e}){const n=C(e);return n.current=e,w(()=>{ye(t),n.current?.()},[t]),null}function we({html:t}){return g("div",{style:{display:"contents"},suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:t}})}})}}));
2//# sourceMappingURL=ubik-context-CYHKN9x1.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.