UNPKG

@postnord/web-components

Version:
5 lines 2.77 kB
/*! * Built with Stencil * By PostNord. */ import{transformTag as n}from"@stencil/core/internal/client";const t=[];for(let n=0;n<256;++n)t.push((n+256).toString(16).slice(1));let o;const e=new Uint8Array(16);var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};const s="SE",u="DK",c="FI",i="NO",a="sv",d="en",p="da",f="fi",m="no",w=[s,"DK","FI","NO"],l=[a,d,p,f,m],y={SE:[a,d],DK:[p,d],FI:[f,a,d],NO:[m,d]},h={KB:1024,MB:1048576,GB:1048576,TB:1073741824},g=function(n){const t=/(\d+\.?\d*)\s?([a-zA-Z]{2})?$/;if(t.test(n)){const o=n.match(t),e=(o[2]||"").toLocaleUpperCase(),r=parseInt(o[1]);return e&&h[e]?r*h[e]:r}return 0};function b(){return window.innerWidth/16<55}function v(){const{matches:n}=window.matchMedia("(prefers-reduced-motion: reduce)");return n}const x=()=>r.randomUUID?r.randomUUID():function(n){const r=(n=n||{}).random??n.rng?.()??function(){if(!o){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");o=crypto.getRandomValues.bind(crypto)}return o(e)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(n,o=0){return(t[n[o+0]]+t[n[o+1]]+t[n[o+2]]+t[n[o+3]]+"-"+t[n[o+4]]+t[n[o+5]]+"-"+t[n[o+6]]+t[n[o+7]]+"-"+t[n[o+8]]+t[n[o+9]]+"-"+t[n[o+10]]+t[n[o+11]]+t[n[o+12]]+t[n[o+13]]+t[n[o+14]]+t[n[o+15]]).toLowerCase()}(r)}(undefined);function D(){return document?.querySelector("pn-topbar")?.offsetHeight||0}function I(){return b()&&document?.querySelector("pn-side-menu")?.offsetHeight||0}function B(){return b()?0:document?.querySelector("pn-side-menu")?.offsetWidth||0}function E(){const n=D()+I();return n>window.scrollY?n-window.scrollY:0}async function F(n){const t=()=>window.pnTopbar;function o(o){const e=o||t();return n.market=e.market,n.language=e.language,e.hasLoaded&&(t().onChangeMarket=t=>n.market=t,t().onChangeLanguage=t=>n.language=t),e}return await new Promise((e=>document.querySelector("pn-topbar")?t()?.hasLoaded?e(o()):void window.addEventListener("topbarLoaded",(()=>e(o()))):e(o({hasLoaded:!1,market:n.market||s,language:n.language||d}))))}const K=(t,o,e)=>{if(v())return;const{left:r,top:s,width:u,height:c}=o.getBoundingClientRect(),{clientX:i=0,clientY:a=0}=t||{},d=u>c?u:c,p=document.createElement(n("div"));p.classList.add("pn-ripple"),p.style.height=2*d+"px",p.style.width=2*d+"px",p.style.left=i>0?i-r+"px":"50%",p.style.top=a>0?a-s+"px":"50%",e?o.querySelector(e).appendChild(p):o.appendChild(p),setTimeout((()=>p.remove()),400)};export{u as D,c as F,i as N,s as S,y as a,D as b,I as c,p as d,d as e,f,g,B as h,b as i,E as j,F as k,l,w as m,m as n,K as o,v as r,a as s,x as u}