UNPKG

@duetds/components

Version:

This package includes Duet Core Components and related tools.

1 lines 15.1 kB
let t,e,n,l=0,o=!1,s=!1,r=!1,i=!1,c=!1;const a=window,u=document,f={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)},$=(()=>!!u.documentElement.attachShadow)(),d=(()=>{try{return new CSSStyleSheet,!0}catch(t){}return!1})(),m=new WeakMap,w=t=>m.get(t),p=(t,e)=>m.set(e.o=t,e),h=(t,e)=>e in t,y=t=>console.error(t),b=new Map,g=new Map,v=[],_=[],j=[],k=(t,e)=>n=>{t.push(n),o||(o=!0,e&&4&f.t?M(S):f.raf(S))},O=(t,e)=>{let n=0,l=0;for(;n<t.length&&(l=performance.now())<e;)try{t[n++](l)}catch(o){y(o)}n===t.length?t.length=0:0!==n&&t.splice(0,n)},S=()=>{l++,(t=>{for(let n=0;n<t.length;n++)try{t[n](performance.now())}catch(e){y(e)}t.length=0})(v);const t=2==(6&f.t)?performance.now()+10*Math.ceil(l*(1/22)):1/0;O(_,t),O(j,t),_.length>0&&(j.push(..._),_.length=0),(o=v.length+_.length+j.length>0)?f.raf(S):l=0},M=t=>Promise.resolve().then(t),x=k(_,!0),R={},L=t=>"object"==(t=typeof t)||"function"===t,U=()=>a.CSS&&a.CSS.supports&&a.CSS.supports("color","var(--c)")?Promise.resolve():__sc_import_duet("./p-d8631f0b.js").then(()=>{f.s=a.__stencil_cssshim}),P=async()=>{f.s=a.__stencil_cssshim;const t=new RegExp("/duet(\\.esm)?\\.js($|\\?|#)"),e=Array.from(u.querySelectorAll("script")).find(e=>t.test(e.src)||"duet"===e.getAttribute("data-stencil-namespace")),n=e["data-opts"];{const t=new URL(".",new URL(e.getAttribute("data-resources-url")||e.src,a.location.href));return E(t.href),window.customElements||await __sc_import_duet("./p-d0882b30.js"),Object.assign(Object.assign({},n),{resourcesUrl:t.href})}},E=t=>{const e=(()=>`__sc_import_${"duet".replace(/\s|-/g,"_")}`)();try{a[e]=new Function("w",`return import(w);//${Math.random()}`)}catch(n){const l=new Map;a[e]=n=>{const o=new URL(n,t).href;let s=l.get(o);if(!s){const t=u.createElement("script");t.type="module",t.src=URL.createObjectURL(new Blob([`import * as m from '${o}'; window.${e}.m = m;`],{type:"application/javascript"})),s=new Promise(n=>{t.onload=()=>{n(a[e].m),t.remove()}}),l.set(o,s),u.head.appendChild(t)}return s}}},C=new WeakMap,T=(t,e,n)=>{let l=g.get(t);d&&n?(l=l||new CSSStyleSheet).replace(e):l=e,g.set(t,l)},I=(t,e)=>{let n=A(e.i),l=g.get(n);if(t=11===t.nodeType?t:u,l)if("string"==typeof l){let e,o=C.get(t=t.head||t);o||C.set(t,o=new Set),o.has(n)||(t.host&&(e=t.firstElementChild)&&"STYLE"===e.tagName?e.innerHTML=l:((e=u.createElement("style")).innerHTML=l,t.insertBefore(e,t.querySelector("link"))),o&&o.add(n))}else t.adoptedStyleSheets.includes(l)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,l]);return n},A=t=>"sc-"+t,F=t=>t.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g,"$1{"),W=(t,e,...n)=>{let l=null,o=null,s=!1,r=!1,i=[];const c=e=>{for(let n=0;n<e.length;n++)l=e[n],Array.isArray(l)?c(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof t&&!L(l))&&(l=String(l)),s&&r?i[i.length-1].u+=l:i.push(s?D(null,l):l),r=s)};if(c(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(" "))}}if("function"==typeof t)return t(e,i,N);const a=D(t,null);return a.$=e,i.length>0&&(a.p=i),a.h=o,a},D=(t,e)=>({t:0,g:t,u:e,v:null,p:null,$:null,h:null}),H={},N={forEach:(t,e)=>t.map(q).forEach(e),map:(t,e)=>t.map(q).map(e).map(B)},q=t=>({vattrs:t.$,vchildren:t.p,vkey:t._,vname:t.h,vtag:t.g,vtext:t.u}),B=t=>{const e=D(t.vtag,t.vtext);return e.$=t.vattrs,e.p=t.vchildren,e._=t.vkey,e.h=t.vname,e},V=(t,e,n,l,o,s)=>{if(n===l)return;let r=h(t,e),i=e.toLowerCase();if("class"===e){const e=t.classList,o=z(n),s=z(l);e.remove(...o.filter(t=>t&&!s.includes(t))),e.add(...s.filter(t=>t&&!o.includes(t)))}else if("style"===e){for(const e in n)l&&null!=l[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in l)n&&l[e]===n[e]||(e.includes("-")?t.style.setProperty(e,l[e]):t.style[e]=l[e])}else if(r||"o"!==e[0]||"n"!==e[1]){const i=L(l);if((r||i&&null!==l)&&!o)try{if(t.tagName.includes("-"))t[e]=l;else{let o=null==l?"":l;"list"===e?r=!1:null!=n&&t[e]==o||(t[e]=o)}}catch(c){}null==l||!1===l?t.removeAttribute(e):(!r||4&s||o)&&!i&&t.setAttribute(e,l=!0===l?"":l)}else e="-"===e[2]?e.slice(3):h(a,i)?i.slice(2):i[2]+e.slice(3),n&&f.rel(t,e,n,!1),l&&f.ael(t,e,l,!1)},Y=/\s/,z=t=>t?t.split(Y):[],G=(t,e,n,l)=>{const o=11===e.v.nodeType&&e.v.host?e.v.host:e.v,s=t&&t.$||R,r=e.$||R;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)},J=(l,o,r,a)=>{let f,$,d,m=o.p[r],w=0;if(s||(i=!0,"slot"===m.g&&(t&&a.classList.add(t+"-s"),m.t|=m.p?2:1)),null!==m.u)f=m.v=u.createTextNode(m.u);else if(1&m.t)f=m.v=u.createTextNode("");else{if(c||(c="svg"===m.g),f=m.v=u.createElementNS(c?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",2&m.t?"slot-fb":m.g),c&&"foreignObject"===m.g&&(c=!1),G(null,m,c),(t=>null!=t)(t)&&f["s-si"]!==t&&f.classList.add(f["s-si"]=t),m.p)for(w=0;w<m.p.length;++w)($=J(l,m,w,f))&&f.appendChild($);"svg"===m.g?c=!1:"foreignObject"===f.tagName&&(c=!0)}return f["s-hn"]=n,3&m.t&&(f["s-sr"]=!0,f["s-cr"]=e,f["s-sn"]=m.h||"",(d=l&&l.p&&l.p[r])&&d.g===m.g&&l.v&&K(l.v,!1)),f},K=(t,e)=>{f.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"]&&(et(t).insertBefore(t,tt(t)),t["s-ol"].remove(),t["s-ol"]=void 0,i=!0),e&&K(t,e)}f.t&=-2},Q=(t,e,l,o,s,r)=>{let i,c=t["s-cr"]&&t["s-cr"].parentNode||t;for(c.shadowRoot&&c.tagName===n&&(c=c.shadowRoot);s<=r;++s)o[s]&&(i=J(null,l,s,t))&&(o[s].v=i,c.insertBefore(i,tt(e)))},X=(t,e,n,l,o)=>{for(;e<=n;++e)(l=t[e])&&(r=!0,(o=l.v)["s-ol"]?o["s-ol"].remove():K(o,!0),o.remove())},Z=(t,e)=>t.g===e.g&&("slot"!==t.g||t.h===e.h),tt=t=>t&&t["s-ol"]||t,et=t=>(t["s-ol"]?t["s-ol"]:t).parentNode,nt=(t,e)=>{const n=e.v=t.v,l=t.p,o=e.p;let s;c=n&&n.parentNode&&void 0!==n.ownerSVGElement,c="svg"===e.g||"foreignObject"!==e.g&&c,null===e.u?("slot"===e.g||G(t,e,c),null!==l&&null!==o?((t,e,n,l)=>{let o,s=0,r=0,i=e.length-1,c=e[0],a=e[i],u=l.length-1,f=l[0],$=l[u];for(;s<=i&&r<=u;)null==c?c=e[++s]:null==a?a=e[--i]:null==f?f=l[++r]:null==$?$=l[--u]:Z(c,f)?(nt(c,f),c=e[++s],f=l[++r]):Z(a,$)?(nt(a,$),a=e[--i],$=l[--u]):Z(c,$)?("slot"!==c.g&&"slot"!==$.g||K(c.v.parentNode,!1),nt(c,$),t.insertBefore(c.v,a.v.nextSibling),c=e[++s],$=l[--u]):Z(a,f)?("slot"!==c.g&&"slot"!==$.g||K(a.v.parentNode,!1),nt(a,f),t.insertBefore(a.v,c.v),a=e[--i],f=l[++r]):(o=J(e&&e[r],n,r,t),f=l[++r],o&&et(c.v).insertBefore(o,tt(c.v)));s>i?Q(t,null==l[u+1]?null:l[u+1].v,n,l,r,u):r>u&&X(e,s,i)})(n,l,e,o):null!==o?(null!==t.u&&(n.textContent=""),Q(n,null,e,o,0,o.length-1)):null!==l&&X(l,0,l.length-1)):(s=n["s-cr"])?s.parentNode.textContent=e.u:t.u!==e.u&&(n.data=e.u),c&&"svg"===e.g&&(c=!1)},lt=t=>{let e,n,l,o,s,r,i=t.childNodes;for(n=0,l=i.length;n<l;n++)if(1===(e=i[n]).nodeType){if(e["s-sr"])for(s=e["s-sn"],e.hidden=!1,o=0;o<l;o++)if(i[o]["s-hn"]!==e["s-hn"])if(r=i[o].nodeType,""!==s){if(1===r&&s===i[o].getAttribute("slot")){e.hidden=!0;break}}else if(1===r||3===r&&""!==i[o].textContent.trim()){e.hidden=!0;break}lt(e)}},ot=[],st=t=>{let e,n,l,o,s=t.childNodes,i=s.length,c=0,a=0,u=0;for(i=s.length;c<i;c++){if((e=s[c])["s-sr"]&&(n=e["s-cr"]))for(o=e["s-sn"],a=(l=n.parentNode.childNodes).length-1;a>=0;a--)(n=l[a])["s-cn"]||n["s-nr"]||n["s-hn"]===e["s-hn"]||((3===(u=n.nodeType)||8===u)&&""===o||1===u&&null===n.getAttribute("slot")&&""===o||1===u&&n.getAttribute("slot")===o)&&(ot.some(t=>t.j===n)||(r=!0,n["s-sn"]=o,ot.push({k:e,j:n})));1===e.nodeType&&st(e)}},rt=(t,e)=>{e&&!t.O&&e["s-p"].push(new Promise(e=>t.O=e))},it=(t,e,n,l)=>{if(e.t|=16,4&e.t)return void(e.t|=512);const o=e.o,s=()=>ct(t,e,n,o,l);let r;return rt(e,e.S),l&&(r=ft(o,"componentWillLoad")),$t(r,()=>x(s))},ct=(l,o,c,a,d)=>{const m=l["s-rc"];d&&((t,e)=>{const n=I($&&t.shadowRoot?t.shadowRoot:t.getRootNode(),e);10&e.t&&(t["s-sc"]=n,t.classList.add(n+"-h"),2&e.t&&t.classList.add(n+"-s"))})(l,c);try{((l,o,c,a)=>{n=l.tagName;const d=o.M||D(null,null),m=(t=>t&&t.g===H)(a)?a:W(null,null,a);if(c.R&&(m.$=m.$||{},c.R.forEach(([t,e])=>m.$[e]=l[t])),m.g=null,m.t|=4,o.M=m,m.v=d.v=l.shadowRoot||l,t=l["s-sc"],e=l["s-cr"],s=$&&0!=(1&c.t),r=!1,nt(d,m),i){st(m.v);for(let t=0;t<ot.length;t++){const e=ot[t];if(!e.j["s-ol"]){const t=u.createTextNode("");t["s-nr"]=e.j,e.j.parentNode.insertBefore(e.j["s-ol"]=t,e.j)}}f.t|=1;for(let t=0;t<ot.length;t++){const e=ot[t],n=e.k.parentNode;let l=e.k.nextSibling,o=e.j["s-ol"];for(;o=o.previousSibling;){let t=o["s-nr"];if(t&&t["s-sn"]===e.j["s-sn"]&&n===t.parentNode&&(!(t=t.nextSibling)||!t["s-nr"])){l=t;break}}(!l&&n!==e.j.parentNode||e.j.nextSibling!==l)&&e.j!==l&&n.insertBefore(e.j,l)}f.t&=-2}r&&lt(m.v),ot.length=0})(l,o,c,a.render())}catch(w){y(w)}o.t&=-17,o.t|=2,m&&(m.forEach(t=>t()),l["s-rc"]=void 0);{const t=l["s-p"],e=()=>at(l,o,c);0===t.length?e():(Promise.all(t).then(e),o.t|=4,t.length=0)}},at=(t,e,n)=>{const l=e.o,o=e.S;64&e.t||(e.t|=64,t.classList.add("hydrated"),ft(l,"componentDidLoad"),e.L(t),o||ut()),e.U(t),e.O&&(e.O(),e.O=void 0),512&e.t&&M(()=>it(t,e,n,!1)),e.t&=-517},ut=()=>{u.documentElement.classList.add("hydrated"),f.t|=2},ft=(t,e,n)=>{if(t&&t[e])try{return t[e](n)}catch(l){y(l)}},$t=(t,e)=>t&&t.then?t.then(e):e(),dt=(t,e,n)=>{if(e.P){t.watchers&&(e.C=t.watchers);const l=Object.entries(e.P),o=t.prototype;if(l.forEach(([t,[l]])=>{31&l||2&n&&32&l?Object.defineProperty(o,t,{get(){return((t,e)=>w(t).T.get(e))(this,t)},set(n){((t,e,n,l)=>{const o=w(this),s=o.I,r=o.T.get(e),i=o.t,c=o.o;if(!((n=((t,e)=>null==t||L(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?parseFloat(t):1&e?String(t):t)(n,l.P[e][0]))===r||8&i&&void 0!==r)&&(o.T.set(e,n),c)){if(l.C&&128&i){const t=l.C[e];t&&t.forEach(t=>{try{c[t](n,r,e)}catch(l){y(l)}})}2==(18&i)&&it(s,o,l,!1)}})(0,t,n,e)},configurable:!0,enumerable:!0}):1&n&&64&l&&Object.defineProperty(o,t,{value(...e){const n=w(this);return n.A.then(()=>n.o[t](...e))}})}),1&n){const n=new Map;o.attributeChangedCallback=function(t,e,l){f.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.R.push([t,o]),o})}}return t},mt=(t,e,n,l,o,s,r)=>{let i,c,a,f;if(1===s.nodeType){for((i=s.getAttribute("c-id"))&&((c=i.split("."))[0]!==r&&"0"!==c[0]||(a={t:0,F:c[0],W:c[1],D:c[2],H:c[3],g:s.tagName.toLowerCase(),v:s,$:null,p:null,_:null,h:null,u:null},e.push(a),s.removeAttribute("c-id"),t.p||(t.p=[]),t.p[a.H]=a,t=a,l&&"0"===a.D&&(l[a.H]=a.v))),f=s.childNodes.length-1;f>=0;f--)mt(t,e,n,l,o,s.childNodes[f],r);if(s.shadowRoot)for(f=s.shadowRoot.childNodes.length-1;f>=0;f--)mt(t,e,n,l,o,s.shadowRoot.childNodes[f],r)}else if(8===s.nodeType)(c=s.nodeValue.split("."))[1]!==r&&"0"!==c[1]||(a={t:0,F:c[1],W:c[2],D:c[3],H:c[4],v:s,$:null,p:null,_:null,h:null,g:null,u:null},"t"===(i=c[0])?(a.v=s.nextSibling,a.v&&3===a.v.nodeType&&(a.u=a.v.textContent,e.push(a),s.remove(),t.p||(t.p=[]),t.p[a.H]=a,l&&"0"===a.D&&(l[a.H]=a.v))):a.F===r&&("s"===i?(a.g="slot",s["s-sn"]=c[5]?a.h=c[5]:"",s["s-sr"]=!0,l&&(a.v=u.createElement(a.g),a.h&&a.v.setAttribute("name",a.h),s.parentNode.insertBefore(a.v,s),s.remove(),"0"===a.D&&(l[a.H]=a.v)),n.push(a),t.p||(t.p=[]),t.p[a.H]=a):"r"===i&&(l?s.remove():(o["s-cr"]=s,s["s-cn"]=!0))));else if(t&&"style"===t.g){const e=D(null,s.textContent);e.v=s,e.H="0",t.p=[e]}},wt=(t,e)=>{if(1===t.nodeType){let n=0;for(;n<t.childNodes.length;n++)wt(t.childNodes[n],e);if(t.shadowRoot)for(n=0;n<t.shadowRoot.childNodes.length;n++)wt(t.shadowRoot.childNodes[n],e)}else if(8===t.nodeType){const n=t.nodeValue.split(".");"o"===n[0]&&(e.set(n[1]+"."+n[2],t),t.nodeValue="",t["s-sd"]=""===n[3])}},pt=t=>{const e=t["s-cr"]=u.createComment("");e["s-cn"]=!0,t.insertBefore(e,t.firstChild)},ht=(t,e={})=>{const n=[],l=e.exclude||[],o=u.head,s=a.customElements,r=o.querySelector("meta[charset]"),i=u.createElement("style"),c=[];let d,p=!0;Object.assign(f,e),f.l=new URL(e.resourcesUrl||"./",u.baseURI).href,e.syncQueue&&(f.t|=4),f.t|=2;{const t=u.querySelectorAll("style[s-id]");for(let e=0;e<t.length;e++){const n=t[e];T(n.getAttribute("s-id"),F(n.innerHTML),!0)}}t.forEach(t=>t[1].forEach(e=>{const o={t:e[0],i:e[1],P:e[2],N:e[3]};o.P=e[2],o.R=[],o.C={},!$&&1&o.t&&(o.t|=8);const r=o.i,i=class extends HTMLElement{constructor(t){super(t),(t=>{const e={t:0,I:t,T:new Map};e.A=new Promise(t=>e.U=t),e.q=new Promise(t=>e.L=t),t["s-p"]=[],t["s-rc"]=[],m.set(t,e)})(t=this),1&o.t&&($?t.attachShadow({mode:"open"}):"shadowRoot"in t||(t.shadowRoot=t))}connectedCallback(){d&&(clearTimeout(d),d=null),p?c.push(this):f.jmp(()=>((t,e)=>{if(0==(1&f.t)){const n=()=>{},l=w(t);if(!(1&l.t)){let n;if(l.t|=1,n=t.getAttribute("s-id")){if($&&1&e.t){const n=I(t.shadowRoot,e);t.classList.remove(n+"-h",n+"-s")}((t,e,n,l)=>{const o=t.shadowRoot,s=[],r=o?[]:null,i=l.M=D(e,null);f.B||wt(u.body,f.B=new Map),t["s-id"]=n,t.removeAttribute("s-id"),mt(i,s,[],r,t,t,n),s.forEach(t=>{const n=t.F+"."+t.W,l=f.B.get(n),s=t.v;l&&(l["s-sd"]||"0"===t.F)&&l.parentNode.insertBefore(s,l.nextSibling),o||(s["s-hn"]=e,l&&(s["s-ol"]=l,s["s-ol"]["s-nr"]=s)),f.B.delete(n)}),o&&r.forEach(t=>{t&&o.appendChild(t)})})(t,e.i,n,l)}n||(4&e.t||8&e.t)&&pt(t);{let e=t;for(;e=e.parentNode||e.host;)if(1===e.nodeType&&e.hasAttribute("s-id")||e["s-p"]){rt(l,l.S=e);break}}e.P&&Object.entries(e.P).forEach(([e,[n]])=>{if(31&n&&t.hasOwnProperty(e)){const n=t[e];delete t[e],t[e]=n}}),M(()=>(async(t,e,n,l,o)=>{if(0==(32&e.t)){e.t|=32;{if((o=(t=>{const e=t.i.replace(/-/g,"_"),n=t.V,l=b.get(n);return l?l[e]:__sc_import_duet(`./${n}.entry.js`).then(t=>(b.set(n,t),t[e]),y)})(n)).then){const t=()=>{};o=await o,t()}o.isProxied||(n.C=o.watchers,dt(o,n,2),o.isProxied=!0);const t=()=>{};e.t|=8;try{new o(e)}catch(i){y(i)}e.t&=-9,e.t|=128,t()}const t=A(n.i);if(!g.has(t)&&o.style){const e=()=>{};let l=o.style;8&n.t&&(l=await __sc_import_duet("./p-affe7c09.js").then(e=>e.scopeCss(l,t,!1))),T(t,l,!!(1&n.t)),e()}}const s=e.S,r=()=>it(t,e,n,!0);s&&s["s-rc"]?s["s-rc"].push(r):r()})(t,l,e))}n()}})(this,o))}disconnectedCallback(){f.jmp(()=>(()=>{0==(1&f.t)&&ft(w(this).o,"componentDidUnload")})())}"s-hmr"(t){}forceUpdate(){((t,e)=>{{const n=w(t);2==(18&n.t)&&it(t,n,e,!1)}})(this,o)}componentOnReady(){return w(this).q}};o.V=t[0],l.includes(r)||s.get(r)||(n.push(r),s.define(r,dt(i,o,1)))})),i.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",i.setAttribute("data-styles",""),o.insertBefore(i,r?r.nextSibling:o.firstChild),p=!1,c.length>0?c.forEach(t=>t.connectedCallback()):f.jmp(()=>d=setTimeout(ut,30,"timeout"))},yt=(t,e,n)=>{const l=bt(t);return{emit:t=>l.dispatchEvent(new CustomEvent(e,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:t}))}},bt=t=>w(t).I,gt=()=>{(()=>{function t(n){if(9===n.keyCode){for(var l=document.querySelectorAll(".hydrated"),o=0;o<l.length;o++)l[o].classList.add("user-is-tabbing");window.removeEventListener("keydown",t),window.addEventListener("mousedown",e,!1)}}function e(){for(var n=document.querySelectorAll(".hydrated"),l=0;l<n.length;l++)n[l].classList.remove("user-is-tabbing");window.removeEventListener("mousedown",e),window.addEventListener("keydown",t,!1)}window.addEventListener("keydown",t,!1)})()};export{H,U as a,ht as b,bt as c,yt as d,gt as g,W as h,P as p,p as r};