UNPKG

mwcpl

Version:

Master's Web Component Pattern Library

1 lines 11.2 kB
let t,e,n,l=!1,o=!1,s=!1,r=!1,c=!1;const i="undefined"!=typeof window?window:{},a=i.CSS,f=i.document||{head:{}},u={t:0,l:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,l)=>t.addEventListener(e,n,l),rel:(t,e,n,l)=>t.removeEventListener(e,n,l)},p=(()=>(f.head.attachShadow+"").indexOf("[native")>-1)(),m=t=>Promise.resolve(t),w=(()=>{try{return new CSSStyleSheet,!0}catch(t){}return!1})(),$=new WeakMap,d=t=>"sc-"+t,h={},b=t=>"object"==(t=typeof t)||"function"===t,y=(t,e,...n)=>{let l=null,o=null,s=!1,r=!1,c=[];const i=e=>{for(let n=0;n<e.length;n++)l=e[n],Array.isArray(l)?i(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof t&&!b(l))&&(l+=""),s&&r?c[c.length-1].o+=l:c.push(s?g(null,l):l),r=s)};if(i(n),e){e.name&&(o=e.name);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter(e=>t[e]).join(" "))}}const a=g(t,null);return a.s=e,c.length>0&&(a.u=c),a.p=o,a},g=(t,e)=>({t:0,$:t,o:e,h:null,u:null,s:null,p:null}),_={},v=(t,e,n,l,o,s)=>{if(n!==l){let c=tt(t,e),a=e.toLowerCase();if("class"===e){const e=t.classList,o=M(n),s=M(l);e.remove(...o.filter(t=>t&&!s.includes(t))),e.add(...s.filter(t=>t&&!o.includes(t)))}else if(c||"o"!==e[0]||"n"!==e[1]){const i=b(l);if((c||i&&null!==l)&&!o)try{if(t.tagName.includes("-"))t[e]=l;else{let o=null==l?"":l;"list"===e?c=!1:null!=n&&t[e]==o||(t[e]=o)}}catch(r){}null==l||!1===l?t.removeAttribute(e):(!c||4&s||o)&&!i&&t.setAttribute(e,l=!0===l?"":l)}else e="-"===e[2]?e.slice(3):tt(i,a)?a.slice(2):a[2]+e.slice(3),n&&u.rel(t,e,n,!1),l&&u.ael(t,e,l,!1)}},j=/\s/,M=t=>t?t.split(j):[],R=(t,e,n,l)=>{const o=11===e.h.nodeType&&e.h.host?e.h.host:e.h,s=t&&t.s||h,r=e.s||h;for(l in s)l in r||v(o,l,s[l],void 0,n,e.t);for(l in r)v(o,l,s[l],r[l],n,e.t)},k=(o,c,i,a)=>{let u,p,m,w=c.u[i],$=0;if(l||(s=!0,"slot"===w.$&&(t&&a.classList.add(t+"-s"),w.t|=w.u?2:1)),null!==w.o)u=w.h=f.createTextNode(w.o);else if(1&w.t)u=w.h=f.createTextNode("");else{if(r||(r="svg"===w.$),u=w.h=f.createElementNS(r?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",2&w.t?"slot-fb":w.$),r&&"foreignObject"===w.$&&(r=!1),R(null,w,r),null!=t&&u["s-si"]!==t&&u.classList.add(u["s-si"]=t),w.u)for($=0;$<w.u.length;++$)p=k(o,w,$,u),p&&u.appendChild(p);"svg"===w.$?r=!1:"foreignObject"===u.tagName&&(r=!0)}return u["s-hn"]=n,3&w.t&&(u["s-sr"]=!0,u["s-cr"]=e,u["s-sn"]=w.p||"",m=o&&o.u&&o.u[i],m&&m.$===w.$&&o.h&&O(o.h,!1)),u},O=(t,e)=>{u.t|=1;const l=t.childNodes;for(let o=l.length-1;o>=0;o--){const t=l[o];t["s-hn"]!==n&&t["s-ol"]&&(P(t).insertBefore(t,C(t)),t["s-ol"].remove(),t["s-ol"]=void 0,s=!0),e&&O(t,e)}u.t&=-2},S=(t,e,l,o,s,r)=>{let c,i=t["s-cr"]&&t["s-cr"].parentNode||t;for(i.shadowRoot&&i.tagName===n&&(i=i.shadowRoot);s<=r;++s)o[s]&&(c=k(null,l,s,t),c&&(o[s].h=c,i.insertBefore(c,C(e))))},L=(t,e,n,l,s)=>{for(;e<=n;++e)(l=t[e])&&(o=!0,(s=l.h)["s-ol"]?s["s-ol"].remove():O(s,!0),s.remove())},U=(t,e)=>t.$===e.$&&("slot"!==t.$||t.p===e.p),C=t=>t&&t["s-ol"]||t,P=t=>(t["s-ol"]?t["s-ol"]:t).parentNode,T=(t,e)=>{const n=e.h=t.h,l=t.u,o=e.u,s=e.$,c=e.o;let i;null===c?(r="svg"===s||"foreignObject"!==s&&r,"slot"===s||R(t,e,r),null!==l&&null!==o?((t,e,n,l)=>{let o,s=0,r=0,c=e.length-1,i=e[0],a=e[c],f=l.length-1,u=l[0],p=l[f];for(;s<=c&&r<=f;)null==i?i=e[++s]:null==a?a=e[--c]:null==u?u=l[++r]:null==p?p=l[--f]:U(i,u)?(T(i,u),i=e[++s],u=l[++r]):U(a,p)?(T(a,p),a=e[--c],p=l[--f]):U(i,p)?("slot"!==i.$&&"slot"!==p.$||O(i.h.parentNode,!1),T(i,p),t.insertBefore(i.h,a.h.nextSibling),i=e[++s],p=l[--f]):U(a,u)?("slot"!==i.$&&"slot"!==p.$||O(a.h.parentNode,!1),T(a,u),t.insertBefore(a.h,i.h),a=e[--c],u=l[++r]):(o=k(e&&e[r],n,r,t),u=l[++r],o&&P(i.h).insertBefore(o,C(i.h)));s>c?S(t,null==l[f+1]?null:l[f+1].h,n,l,r,f):r>f&&L(e,s,c)})(n,l,e,o):null!==o?(null!==t.o&&(n.textContent=""),S(n,null,e,o,0,o.length-1)):null!==l&&L(l,0,l.length-1),r&&"svg"===s&&(r=!1)):(i=n["s-cr"])?i.parentNode.textContent=c:t.o!==c&&(n.data=c)},x=t=>{let e,n,l,o,s,r,c=t.childNodes;for(n=0,l=c.length;n<l;n++)if(e=c[n],1===e.nodeType){if(e["s-sr"])for(s=e["s-sn"],e.hidden=!1,o=0;o<l;o++)if(c[o]["s-hn"]!==e["s-hn"])if(r=c[o].nodeType,""!==s){if(1===r&&s===c[o].getAttribute("slot")){e.hidden=!0;break}}else if(1===r||3===r&&""!==c[o].textContent.trim()){e.hidden=!0;break}x(e)}},A=[],E=t=>{let e,n,l,s,r,c,i=0,a=t.childNodes,f=a.length;for(;i<f;i++){if(e=a[i],e["s-sr"]&&(n=e["s-cr"]))for(l=n.parentNode.childNodes,s=e["s-sn"],c=l.length-1;c>=0;c--)n=l[c],n["s-cn"]||n["s-nr"]||n["s-hn"]===e["s-hn"]||(F(n,s)?(r=A.find(t=>t.g===n),o=!0,n["s-sn"]=n["s-sn"]||s,r?r._=e:A.push({_:e,g:n}),n["s-sr"]&&A.map(t=>{F(t.g,n["s-sn"])&&(r=A.find(t=>t.g===n),r&&!t._&&(t._=r._))})):A.some(t=>t.g===n)||A.push({g:n}));1===e.nodeType&&E(e)}},F=(t,e)=>1===t.nodeType?null===t.getAttribute("slot")&&""===e||t.getAttribute("slot")===e:t["s-sn"]===e||""===e,H=t=>X(t).v,N=(t,e)=>{e&&!t.j&&e["s-p"].push(new Promise(e=>t.j=e))},W=(t,e)=>{if(t.t|=16,4&t.t)return void(t.t|=512);const n=t.M,l=()=>q(t,n,e);return N(t,t.R),G(void 0,()=>ut(l))},q=(r,c,i)=>{const a=r.v,m=a["s-rc"];i&&(t=>{const e=t.k,n=t.v,l=e.t,o=((t,e)=>{let n=d(e.O),l=ot.get(n);if(t=11===t.nodeType?t:f,l)if("string"==typeof l){let e,o=$.get(t=t.head||t);o||$.set(t,o=new Set),o.has(n)||(e=f.createElement("style"),e.innerHTML=l,t.insertBefore(e,t.querySelector("link")),o&&o.add(n))}else t.adoptedStyleSheets.includes(l)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,l]);return n})(p&&n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(r),((r,c)=>{const i=r.v,a=r.k,m=r.S||g(null,null),w=(t=>t&&t.$===_)(c)?c:y(null,null,c);if(n=i.tagName,a.L&&(w.s=w.s||{},a.L.map(([t,e])=>w.s[e]=i[t])),w.$=null,w.t|=4,r.S=w,w.h=m.h=i.shadowRoot||i,t=i["s-sc"],e=i["s-cr"],l=p&&0!=(1&a.t),o=!1,T(m,w),u.t|=1,s){let t,e,n,l,o,s;E(w.h);let r=0;for(;r<A.length;r++)t=A[r],e=t.g,e["s-ol"]||(n=f.createTextNode(""),n["s-nr"]=e,e.parentNode.insertBefore(e["s-ol"]=n,e));for(r=0;r<A.length;r++)if(t=A[r],e=t.g,t._){for(l=t._.parentNode,o=t._.nextSibling,n=e["s-ol"];n=n.previousSibling;)if(s=n["s-nr"],s&&s["s-sn"]===e["s-sn"]&&l===s.parentNode&&(s=s.nextSibling,!s||!s["s-nr"])){o=s;break}(!o&&l!==e.parentNode||e.nextSibling!==o)&&e!==o&&(!e["s-hn"]&&e["s-ol"]&&(e["s-hn"]=e["s-ol"].parentNode.nodeName),l.insertBefore(e,o))}else 1===e.nodeType&&(e.hidden=!0)}o&&x(w.h),u.t&=-2,A.length=0})(r,B(c)),r.t&=-17,r.t|=2,m&&(m.map(t=>t()),a["s-rc"]=void 0);{const t=a["s-p"],e=()=>D(r);0===t.length?e():(Promise.all(t).then(e),r.t|=4,t.length=0)}},B=t=>{try{t=t.render()}catch(e){et(e)}return t},D=t=>{const e=t.v,n=t.M,l=t.R;64&t.t||(t.t|=64,I(e),z(n,"componentDidLoad"),t.U(e),l||V()),t.j&&(t.j(),t.j=void 0),512&t.t&&ft(()=>W(t,!1)),t.t&=-517},V=()=>{I(f.documentElement),ft(()=>(t=>{const e=new CustomEvent("appload",{detail:{namespace:"mwcpl"}});return t.dispatchEvent(e),e})(i))},z=(t,e,n)=>{if(t&&t[e])try{return t[e](n)}catch(l){et(l)}},G=(t,e)=>t&&t.then?t.then(e):e(),I=t=>t.classList.add("hydrated"),J=(t,e,n)=>{if(e.C){const l=Object.entries(e.C),o=t.prototype;if(l.map(([t,[l]])=>{(31&l||2&n&&32&l)&&Object.defineProperty(o,t,{get(){return((t,e)=>X(this).P.get(e))(0,t)},set(n){((t,e,n,l)=>{const o=X(this),s=o.P.get(e),r=o.t,c=o.M;n=((t,e)=>null==t||b(t)?t:4&e?"false"!==t&&(""===t||!!t):1&e?t+"":t)(n,l.C[e][0]),8&r&&void 0!==s||n===s||(o.P.set(e,n),c&&2==(18&r)&&W(o,!1))})(0,t,n,e)},configurable:!0,enumerable:!0})}),1&n){const n=new Map;o.attributeChangedCallback=function(t,e,l){u.jmp(()=>{const e=n.get(t);this[e]=(null!==l||"boolean"!=typeof this[e])&&l})},t.observedAttributes=l.filter(([t,e])=>15&e[0]).map(([t,l])=>{const o=l[1]||t;return n.set(o,t),512&l[0]&&e.L.push([t,o]),o})}}return t},K=(t,e={})=>{const n=[],l=e.exclude||[],o=i.customElements,s=f.head,r=s.querySelector("meta[charset]"),c=f.createElement("style"),a=[];let m,$=!0;Object.assign(u,e),u.l=new URL(e.resourcesUrl||"./",f.baseURI).href,t.map(t=>t[1].map(e=>{const s={t:e[0],O:e[1],C:e[2],T:e[3]};s.C=e[2],s.L=[],!p&&1&s.t&&(s.t|=8);const r=s.O,c=class extends HTMLElement{constructor(t){super(t),Z(t=this,s),1&s.t&&(p?t.attachShadow({mode:"open"}):"shadowRoot"in t||(t.shadowRoot=t))}connectedCallback(){m&&(clearTimeout(m),m=null),$?a.push(this):u.jmp(()=>(t=>{if(0==(1&u.t)){const e=X(t),n=e.k,l=()=>{};if(!(1&e.t)){e.t|=1,12&n.t&&(t=>{const e=t["s-cr"]=f.createComment("");e["s-cn"]=!0,t.insertBefore(e,t.firstChild)})(t);{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){N(e,e.R=n);break}}n.C&&Object.entries(n.C).map(([e,[n]])=>{if(31&n&&t.hasOwnProperty(e)){const n=t[e];delete t[e],t[e]=n}}),(async(t,e,n,l,o)=>{if(0==(32&e.t)){e.t|=32;{if((o=lt(n)).then){const t=()=>{};o=await o,t()}o.isProxied||(J(o,n,2),o.isProxied=!0);const t=()=>{};e.t|=8;try{new o(e)}catch(c){et(c)}e.t&=-9,t()}const t=d(n.O);if(!ot.has(t)&&o.style){const e=()=>{};let l=o.style;8&n.t&&(l=await __sc_import_mwcpl("./p-f5bab17b.js").then(e=>e.scopeCss(l,t,!1))),((t,e,n)=>{let l=ot.get(t);w&&n?(l=l||new CSSStyleSheet,l.replace(e)):l=e,ot.set(t,l)})(t,l,!!(1&n.t)),e()}}const s=e.R,r=()=>W(e,!0);s&&s["s-rc"]?s["s-rc"].push(r):r()})(0,e,n)}l()}})(this))}disconnectedCallback(){u.jmp(()=>{})}forceUpdate(){(()=>{{const t=X(this);t.v.isConnected&&2==(18&t.t)&&W(t,!1)}})()}componentOnReady(){return X(this).A}};s.F=t[0],l.includes(r)||o.get(r)||(n.push(r),o.define(r,J(c,s,1)))})),c.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",c.setAttribute("data-styles",""),s.insertBefore(c,r?r.nextSibling:s.firstChild),$=!1,a.length?a.map(t=>t.connectedCallback()):u.jmp(()=>m=setTimeout(V,30))},Q=new WeakMap,X=t=>Q.get(t),Y=(t,e)=>Q.set(e.M=t,e),Z=(t,e)=>{const n={t:0,v:t,k:e,P:new Map};return n.A=new Promise(t=>n.U=t),t["s-p"]=[],t["s-rc"]=[],Q.set(t,n)},tt=(t,e)=>e in t,et=t=>console.error(t),nt=new Map,lt=t=>{const e=t.O.replace(/-/g,"_"),n=t.F,l=nt.get(n);return l?l[e]:__sc_import_mwcpl(`./${n}.entry.js`).then(t=>(nt.set(n,t),t[e]),et)},ot=new Map,st=[],rt=[],ct=(t,e)=>n=>{t.push(n),c||(c=!0,e&&4&u.t?ft(at):u.raf(at))},it=t=>{for(let n=0;n<t.length;n++)try{t[n](performance.now())}catch(e){et(e)}t.length=0},at=()=>{it(st),it(rt),(c=st.length>0)&&u.raf(at)},ft=t=>m().then(t),ut=ct(rt,!0),pt=()=>a&&a.supports&&a.supports("color","var(--c)")?m():__sc_import_mwcpl("./p-69b85284.js").then(()=>(u.H=i.__cssshim)?(!1).i():0),mt=()=>{u.H=i.__cssshim;const t=Array.from(f.querySelectorAll("script")).find(t=>/\/mwcpl(\.esm)?\.js($|\?|#)/.test(t.src)||"mwcpl"===t.getAttribute("data-stencil-namespace")),e=t["data-opts"]||{};return"onbeforeload"in t&&!history.scrollRestoration?{then(){}}:(e.resourcesUrl=new URL(".",new URL(t.getAttribute("data-resources-url")||t.src,i.location.href)).href,wt(e.resourcesUrl,t),i.customElements?m(e):__sc_import_mwcpl("./p-2347dcb6.js").then(()=>e))},wt=(t,e)=>{try{i.__sc_import_mwcpl=Function("w",`return import(w);//${Math.random()}`)}catch(n){const l=new Map;i.__sc_import_mwcpl=n=>{const o=new URL(n,t).href;let s=l.get(o);if(!s){const t=f.createElement("script");t.type="module",t.crossOrigin=e.crossOrigin,t.src=URL.createObjectURL(new Blob([`import * as m from '${o}'; window.__sc_import_mwcpl.m = m;`],{type:"application/javascript"})),s=new Promise(e=>{t.onload=()=>{e(i.__sc_import_mwcpl.m),t.remove()}}),l.set(o,s),f.head.appendChild(t)}return s}}};export{_ as H,pt as a,K as b,H as g,y as h,mt as p,Y as r}