UNPKG

@duetds/components

Version:

This package includes Duet Components and related tools.

1 lines 12.3 kB
const t=window,e=document,n={t:0,s:"",raf:t=>requestAnimationFrame(t),ael:(t,e,n,s)=>t.addEventListener(e,n,s),rel:(t,e,n,s)=>t.removeEventListener(e,n,s)},s=!!e.documentElement.attachShadow,o=(()=>{try{return new CSSStyleSheet,!0}catch(t){}return!1})(),l=new WeakMap,i=t=>l.get(t),r=(t,e)=>l.set(e.o=t,e),c=(t,e)=>e in t,a=t=>console.error(t),f=new Map,u=t.__stencil_cssshim;let $=0,d=!1;const p=[],m=[],h=[],w=t=>e=>{t.push(e),d||(d=!0,n.raf(b))},y=(t,e)=>{let n=0,s=0;for(;n<t.length&&(s=performance.now())<e;)try{t[n++](s)}catch(t){a(t)}n===t.length?t.length=0:0!==n&&t.splice(0,n)},b=()=>{$++,(t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){a(t)}t.length=0})(p);const t=2==(6&n.t)?performance.now()+7*Math.ceil($*(1/22)):1/0;y(m,t),y(h,t),m.length>0&&(h.push(...m),m.length=0),(d=p.length+m.length+h.length>0)?n.raf(b):$=0},g=w(m),v={},_=t=>null!=t,j=t=>t.toLowerCase(),k=t=>["object","function"].includes(typeof t),S=()=>t.CSS&&t.CSS.supports&&t.CSS.supports("color","var(--c)")?Promise.resolve():__sc_import_duet("./p-3ea8955c.js"),R=async()=>{{const n=Array.from(e.querySelectorAll("script")).find(t=>t.src.includes("/duet.esm.js")||"duet"===t.getAttribute("data-namespace")),s=new URL(".",new URL(n.getAttribute("data-resources-url")||n.src,t.location.href));return L(s.href),window.customElements||await __sc_import_duet("./p-a0c82e31.js"),s.href}},L=n=>{const s=`__sc_import_${"duet".replace(/\s|-/g,"_")}`;try{t[s]=new Function("w","return import(w);")}catch(o){const l=new Map;t[s]=o=>{const i=new URL(o,n).href;let r=l.get(i);if(!r){const n=e.createElement("script");n.type="module",n.src=URL.createObjectURL(new Blob([`import * as m from '${i}'; window.${s}.m = m;`],{type:"application/javascript"})),r=new Promise(e=>{n.onload=()=>{e(t[s].m),n.remove()}}),l.set(i,r),e.head.appendChild(n)}return r}}},M="http://www.w3.org/1999/xlink",O=new WeakMap,U=t=>"sc-"+t,x=(t,e,...n)=>{let s,o,l=null,i=!1,r=!1,c=[];const a=e=>{for(let n=0;n<e.length;n++)l=e[n],Array.isArray(l)?a(l):null!=l&&"boolean"!=typeof l&&((i="function"!=typeof t&&!k(l))&&(l=String(l)),i&&r?c[c.length-1].l+=l:c.push(i?{t:0,l}:l),r=i)};if(a(n),e){s=e.key||void 0,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,c,E);const f={t:0,i:t,u:c.length>0?c:null,$:void 0,p:e};return f.h=s,f.g=o,f},C={},E={forEach:(t,e)=>t.map(T).forEach(e),map:(t,e)=>t.map(T).map(e).map(A)},T=t=>({vattrs:t.p,vchildren:t.u,vkey:t.h,vname:t.g,vtag:t.i,vtext:t.l}),A=t=>({t:0,p:t.vattrs,u:t.vchildren,h:t.vkey,g:t.vname,i:t.vtag,l:t.vtext}),F=(t,e,s,o,l,i)=>{if(s!==o)if("class"!==e||l)if("style"===e){for(const e in s)o&&null!=o[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in o)s&&o[e]===s[e]||(e.includes("-")?t.style.setProperty(e,o[e]):t.style[e]=o[e])}else if("key"===e);else if("ref"===e)o&&o(t);else if(e.startsWith("on")&&!c(t,e))e=c(t,j(e))?j(e.substring(2)):j(e[2])+e.substring(3),s&&n.rel(t,e,s,!1),o&&n.ael(t,e,o,!1);else{const n=c(t,e),s=k(o);if((n||s&&null!==o)&&!l)try{t[e]=null==o&&-1===t.tagName.indexOf("-")?"":o}catch(t){}const r=!(!l||e===(e=e.replace(/^xlink\:?/,"")));null==o||!1===o?r?t.removeAttributeNS(M,j(e)):t.removeAttribute(e):(!n||4&i||l)&&!s&&(o=!0===o?"":o.toString(),r?t.setAttributeNS(M,j(e),o):t.setAttribute(e,o))}else{const e=P(s),n=P(t.className).filter(t=>!e.includes(t));t.className=n.concat(P(o).filter(t=>!n.includes(t))).join(" ")}},P=t=>t?t.split(" "):[],W=(t,e,n,s)=>{const o=11===e.$.nodeType&&e.$.host?e.$.host:e.$,l=t&&t.p||v,i=e.p||v;for(s in l)null==i[s]&&null!=l[s]&&F(o,s,l[s],void 0,n,e.t);for(s in i)F(o,s,l[s],i[s],n,e.t)};let D,N,q,B=!1,H=!1,V=!1,z=!1;const G=(t,n,s,o)=>{let l,i,r,c=n.u[s],a=0;if(B||(V=!0,"slot"===c.i&&(D&&o.classList.add(D+"-s"),c.t|=c.u?2:1)),_(c.l))c.$=e.createTextNode(c.l);else if(1&c.t)c.$=e.createTextNode("");else{if(l=c.$=z||"svg"===c.i?e.createElementNS("http://www.w3.org/2000/svg",c.i):e.createElement(2&c.t?"slot-fb":c.i),W(null,c,z="svg"===c.i||"foreignObject"!==c.i&&z),_(D)&&l["s-si"]!==D&&l.classList.add(l["s-si"]=D),c.u)for(a=0;a<c.u.length;++a)(i=G(t,c,a,l))&&l.appendChild(i);"svg"===c.i&&(z=!1)}return c.$["s-hn"]=q,3&c.t&&(c.$["s-sr"]=!0,c.$["s-cr"]=N,c.$["s-sn"]=c.g||"",(r=t&&t.u&&t.u[s])&&r.i===c.i&&t.$&&I(t.$,!1)),c.$},I=(t,e)=>{n.t|=1;const s=t.childNodes;for(let t=s.length-1;t>=0;t--){const n=s[t];n["s-hn"]!==q&&n["s-ol"]&&(Y(n).insertBefore(n,X(n)),n["s-ol"].remove(),n["s-ol"]=void 0,V=!0),e&&I(n,e)}n.t&=-2},J=(t,e,n,s,o,l)=>{let i,r=t["s-cr"]&&t["s-cr"].parentNode||t;for(r.shadowRoot&&j(r.tagName)===q&&(r=r.shadowRoot);o<=l;++o)s[o]&&(i=G(null,n,o,t))&&(s[o].$=i,r.insertBefore(i,X(e)))},K=(t,e,n,s)=>{for(;e<=n;++e)_(t[e])&&(s=t[e].$,st(t[e],!0),H=!0,s["s-ol"]?s["s-ol"].remove():I(s,!0),s.remove())},Q=(t,e)=>t.i===e.i&&("slot"===t.i?t.g===e.g:t.h===e.h),X=t=>t&&t["s-ol"]||t,Y=t=>(t["s-ol"]?t["s-ol"]:t).parentNode,Z=(t,e)=>{const n=e.$=t.$,s=t.u,o=e.u;let l;z=n&&_(n.parentNode)&&void 0!==n.ownerSVGElement,z="svg"===e.i||"foreignObject"!==e.i&&z,_(e.l)?(l=n["s-cr"])?l.parentNode.textContent=e.l:t.l!==e.l&&(n.textContent=e.l):("slot"===e.i||W(t,e,z),_(s)&&_(o)?((t,e,n,s)=>{let o,l,i=0,r=0,c=0,a=0,f=e.length-1,u=e[0],$=e[f],d=s.length-1,p=s[0],m=s[d];for(;i<=f&&r<=d;)if(null==u)u=e[++i];else if(null==$)$=e[--f];else if(null==p)p=s[++r];else if(null==m)m=s[--d];else if(Q(u,p))Z(u,p),u=e[++i],p=s[++r];else if(Q($,m))Z($,m),$=e[--f],m=s[--d];else if(Q(u,m))"slot"!==u.i&&"slot"!==m.i||I(u.$.parentNode,!1),Z(u,m),t.insertBefore(u.$,$.$.nextSibling),u=e[++i],m=s[--d];else if(Q($,p))"slot"!==u.i&&"slot"!==m.i||I($.$.parentNode,!1),Z($,p),t.insertBefore($.$,u.$),$=e[--f],p=s[++r];else{for(c=-1,a=i;a<=f;++a)if(e[a]&&_(e[a].h)&&e[a].h===p.h){c=a;break}c>=0?((l=e[c]).i!==p.i?o=G(e&&e[r],n,c,t):(Z(l,p),e[c]=void 0,o=l.$),p=s[++r]):(o=G(e&&e[r],n,r,t),p=s[++r]),o&&Y(u.$).insertBefore(o,X(u.$))}i>f?J(t,null==s[d+1]?null:s[d+1].$,n,s,r,d):r>d&&K(e,i,f)})(n,s,e,o):_(o)?(_(t.l)&&(n.textContent=""),J(n,null,e,o,0,o.length-1)):_(s)&&K(s,0,s.length-1)),z&&"svg"===e.i&&(z=!1)},tt=(t,e,n,s,o,l,i,r)=>{for(s=0,o=(n=t.childNodes).length;s<o;s++)if(1===(e=n[s]).nodeType){if(e["s-sr"])for(i=e["s-sn"],e.hidden=!1,l=0;l<o;l++)if(n[l]["s-hn"]!==e["s-hn"])if(r=n[l].nodeType,""!==i){if(1===r&&i===n[l].getAttribute("slot")){e.hidden=!0;break}}else if(1===r||3===r&&""!==n[l].textContent.trim()){e.hidden=!0;break}tt(e)}},et=[],nt=t=>{let e,n,s,o,l=t.childNodes,i=l.length,r=0,c=0,a=0;for(i=l.length;r<i;r++){if((e=l[r])["s-sr"]&&(n=e["s-cr"]))for(o=e["s-sn"],c=(s=n.parentNode.childNodes).length-1;c>=0;c--)(n=s[c])["s-cn"]||n["s-nr"]||n["s-hn"]===e["s-hn"]||((3===(a=n.nodeType)||8===a)&&""===o||1===a&&null===n.getAttribute("slot")&&""===o||1===a&&n.getAttribute("slot")===o)&&(et.some(t=>t.nodeToRelocate===n)||(H=!0,n["s-sn"]=o,et.push({slotRefNode:e,nodeToRelocate:n})));1===e.nodeType&&nt(e)}},st=(t,e)=>{t&&(t.p&&t.p.ref&&t.p.ref(e?null:t.$),t.u&&t.u.forEach(t=>{st(t,e)}))},ot=async(t,e)=>{if(t&&t[e])try{await t[e]()}catch(t){a(t)}},lt=async(t,e,n,s)=>{e.t|=16;const o=e.o;s&&await ot(o,"componentWillLoad"),g(()=>it(t,e,n,o,s))},it=(t,o,l,i,r)=>{o.t&=-17,t["s-lr"]=!1,r&&((t,n)=>{const o=((t,n,s,o)=>{let l=U(n.v),i=f.get(l);if(t=11===t.nodeType?t:e,i)if("string"==typeof i){let s,r=O.get(t=t.head||t);if(r||O.set(t,r=new Set),!r.has(l)){if(u){const t=(s=u.createHostStyle(o,l,i,!!(10&n.t)))["s-sc"];t&&(l=t,r=null)}else(s=e.createElement("style")).innerHTML=i;t.insertBefore(s,t.querySelector("link")),r&&r.add(l)}}else t.adoptedStyleSheets.includes(i)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,i]);return l})(s&&t.shadowRoot?t.shadowRoot:t.getRootNode(),n,0,t);10&n.t&&(t["s-sc"]=o,t.classList.add(o+"-h"))})(t,l),o.t|=4;try{((t,o,l,i)=>{q=j(t.tagName);const r=o._||{t:0},c=(t=>t&&t.i===C)(i)?i:x(null,null,i);if(l.j&&(c.p=c.p||{},l.j.forEach(([e,n])=>c.p[n]=t[e])),c.i=null,c.t|=4,o._=c,c.$=r.$=t.shadowRoot||t,D=t["s-sc"],N=t["s-cr"],B=s&&0!=(1&l.t),V=H=!1,Z(r,c),V){nt(c.$);for(let t=0;t<et.length;t++){const n=et[t];if(!n.nodeToRelocate["s-ol"]){const t=e.createTextNode("");t["s-nr"]=n.nodeToRelocate,n.nodeToRelocate.parentNode.insertBefore(n.nodeToRelocate["s-ol"]=t,n.nodeToRelocate)}}n.t|=1;for(let t=0;t<et.length;t++){const e=et[t],n=e.slotRefNode.parentNode;let s=e.slotRefNode.nextSibling,o=e.nodeToRelocate["s-ol"];for(;o=o.previousSibling;){let t=o["s-nr"];if(t&&t&&t["s-sn"]===e.nodeToRelocate["s-sn"]&&n===t.parentNode&&(t=t.nextSibling)&&t&&!t["s-nr"]){s=t;break}}(!s&&n!==e.nodeToRelocate.parentNode||e.nodeToRelocate.nextSibling!==s)&&e.nodeToRelocate!==s&&n.insertBefore(e.nodeToRelocate,s)}n.t&=-2}H&&tt(c.$),et.length=0})(t,o,l,i.render())}catch(t){a(t)}o.t&=-5,u&&u.updateHost(t),t["s-lr"]=!0,o.t|=2,t["s-rc"].length>0&&(t["s-rc"].forEach(t=>t()),t["s-rc"].length=0),rt(t,o)},rt=(t,s,o)=>{if(!t["s-al"]){const l=s.o,i=s.k;512&s.t||(s.t|=512,t.classList.add("hydrated"),ot(l,"componentDidLoad"),s.S(t),i||(e.documentElement.classList.add("hydrated"),setTimeout(()=>n.t|=2,999))),i&&((o=i["s-al"])&&(o.delete(t),0===o.size&&(i["s-al"]=void 0,i["s-init"]())),s.k=void 0)}},ct=(t,e,n)=>{if(e.R){t.watchers&&(e.L=t.watchers);const s=Object.entries(e.R),o=t.prototype;if(s.forEach(([t,[s]])=>{(31&s||2&n&&32&s)&&Object.defineProperty(o,t,{get(){return((t,e)=>i(t).M.get(e))(this,t)},set(n){((t,e,n,s)=>{const o=i(this),l=o.O,r=o.M.get(e),c=o.t;if(!((n=((t,e)=>null==t||k(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?parseFloat(t):1&e?String(t):t)(n,s.R[e][0]))===r||8&c&&void 0!==r)&&(o.M.set(e,n),o.o)){if(s.L&&1==(9&c)){const t=s.L[e];t&&t.forEach(t=>{try{o.o[t].call(o.o,n,r,e)}catch(t){a(t)}})}2==(22&c)&&lt(l,o,s,!1)}})(0,t,n,e)},configurable:!0,enumerable:!0})}),1&n){const n=new Map;o.attributeChangedCallback=function(t,e,s){const o=n.get(t);this[o]=(null!==s||"boolean"!=typeof this[o])&&s},t.observedAttributes=s.filter(([t,e])=>15&e[0]).map(([t,s])=>{const o=s[1]||t;return n.set(o,t),512&s[0]&&e.j.push([t,o]),o})}}return t},at=async(t,e,n,s,l)=>{if(0==(256&e.t)){e.t|=256,(l=await(t=>__sc_import_duet(`./${t.U}.entry.js`).then(e=>e[t.v.replace(/-/g,"_")],a))(n)).isProxied||(n.L=l.watchers,ct(l,n,2),l.isProxied=!0),e.t|=8;try{new l(e)}catch(t){a(t)}if(e.t&=-9,!l.isStyleRegistered&&l.style){let t=l.style,e=U(n.v);8&n.t&&(t=await __sc_import_duet("./p-549b16dd.js").then(n=>n.scopeCss(t,e,!1))),((t,e,n)=>{let s=f.get(t);o&&n?(s=s||new CSSStyleSheet).replace(e):s=e,f.set(t,s)})(e,t,!!(1&n.t)),l.isStyleRegistered=!0}}const i=e.k;i&&!i["s-lr"]&&i["s-rc"]?i["s-rc"].push(()=>at(t,e,n)):lt(t,e,n,!0)},ft=(o,r={})=>{const c=[],a=r.exclude||[],f=e.head,$=t.customElements,d=f.querySelector("meta[charset]"),p=e.createElement("style");Object.assign(n,r),n.s=new URL(r.resourcesUrl||"/",t.location.href).href,r.syncQueue&&(n.t|=4),o.forEach(t=>t[1].forEach(o=>{const r={t:o[0],v:o[1],R:o[2],C:o[3],j:[],L:{}};!s&&1&r.t&&(r.t|=8);const f=r.v;r.U=t[0],a.includes(f)||$.get(f)||(c.push(f),$.define(f,ct(class extends HTMLElement{constructor(t){super(t),t=this,this["s-lr"]=!1,this["s-rc"]=[],(t=>{{const e={t:0,O:t,M:new Map};e.T=new Promise(t=>e.S=t),l.set(t,e)}})(t),1&r.t&&(s?t.attachShadow({mode:"open"}):"shadowRoot"in t||(t.shadowRoot=t))}connectedCallback(){((t,s)=>{if(0==(1&n.t)){const n=i(t);if(!(1&n.t)){let o;n.t|=1,o||(4&s.t||8&s.t)&&((t,n)=>{let s;s="",(n=t["s-cr"]=e.createComment(""))["s-cn"]=!0,t.insertBefore(n,t.firstChild)})(t);{let e=t;for(;e=e.parentNode||e.host;)if(e["s-init"]&&!e["s-lr"]){n.k=e,(e["s-al"]=e["s-al"]||new Set).add(t);break}}s.R&&Object.entries(s.R).forEach(([e,[n]])=>{if(31&n&&t.hasOwnProperty(e)){const n=t[e];delete t[e],t[e]=n}}),at(t,n,s)}}})(this,r)}disconnectedCallback(){(t=>{if(0==(1&n.t)){const e=i(t);u&&u.removeHost(t),ot(e.o,"componentDidUnload")}})(this)}"s-init"(){const t=i(this);t.o&&rt(this,t)}"s-hmr"(t){}forceUpdate(){lt(this,i(this),r,!1)}componentOnReady(){return i(this).T}},r,1)))})),p.innerHTML=c+"{visibility:hidden}.hydrated{visibility:inherit}",p.setAttribute("data-styles",""),f.insertBefore(p,d?d.nextSibling:f.firstChild)},ut=(t,e,n)=>{const s=$t(t);return{emit:t=>s.dispatchEvent(new CustomEvent(e,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:t}))}},$t=t=>i(t).O;export{S as a,ft as b,ut as c,$t as g,x as h,R as p,r};