mi-element 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/context.js CHANGED
@@ -37,10 +37,17 @@ class ContextRequestEvent extends Event {
37
37
  }
38
38
 
39
39
  class ContextConsumer {
40
+ #value;
40
41
  constructor(host, context, options) {
41
42
  const {subscribe: subscribe = !1, validate: validate = () => !0} = options || {};
42
43
  this.host = host, this.context = context, this.subscribe = !!subscribe, this.validate = validate,
43
- this.value = void 0, this.unsubscribe = void 0, this.host.addController?.(this);
44
+ this.unsubscribe = void 0, this.host.addController?.(this);
45
+ }
46
+ get() {
47
+ return this.#value;
48
+ }
49
+ get value() {
50
+ return this.#value;
44
51
  }
45
52
  hostConnected() {
46
53
  this.dispatchRequest();
@@ -53,7 +60,7 @@ class ContextConsumer {
53
60
  }
54
61
  _callback(value, unsubscribe) {
55
62
  unsubscribe && (this.subscribe ? this.unsubscribe && (this.unsubscribe !== unsubscribe && this.unsubscribe(),
56
- this.unsubscribe = unsubscribe) : unsubscribe()), this.validate(value) && (this.value = value,
63
+ this.unsubscribe = unsubscribe) : unsubscribe()), this.validate(value) && (this.#value = value,
57
64
  this.host.requestUpdate());
58
65
  }
59
66
  }
package/dist/index.min.js CHANGED
@@ -1,4 +1,4 @@
1
- const t=[];class e extends EventTarget{#t;#e;constructor(t,e){super();const{equals:s}=e||{};this.#t=t,this.#e=s??((t,e)=>t===e)}get value(){return this.get()}set value(t){this.set(t)}get(){const e=t[t.length-1];return e&&e.add(this),this.#t}set(t){this.#e(this.#t,t)||(this.#t=t,this.dispatchEvent(new CustomEvent("signal")))}}const s=(t,s)=>t instanceof e?t:new e(t,s);function n(e){const s=new Set;t.push(s);try{e()}finally{t.pop()}for(const t of s)t.addEventListener("signal",e);return()=>{for(const t of s)t.removeEventListener("signal",e)}}class r{#s;#n;constructor(t){this.#s=new e,this.#n=n(()=>this.#s.set(t()))}get(){return this.#s.get()}unsubscribe(){this.#n()}}var i={State:e,Computed:r,createSignal:s,effect:n};const o="context-request";class c{constructor(t,e,n){this.host=t,this.context=e,this.state=s(n),this.host.addController?.(this)}hostConnected(){this.host.addEventListener(o,this.onContextRequest)}hostDisconnected(){this.host.removeEventListener(o,this.onContextRequest)}set(t){this.state.set(t)}get(){return this.state.get()}onContextRequest=t=>{if(t.context!==this.context)return;let e;t.stopPropagation(),t.subscribe&&(e=n(()=>{const s=this.get();e&&t.callback(s,e)})),t.callback(this.get(),e)}}class a extends Event{constructor(t,e,s){super(o,{bubbles:!0,composed:!0}),this.context=t,this.callback=e,this.subscribe=s}}class l{constructor(t,e,s){const{subscribe:n=!1,validate:r=()=>!0}=s||{};this.host=t,this.context=e,this.subscribe=!!n,this.validate=r,this.value=void 0,this.unsubscribe=void 0,this.host.addController?.(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new a(this.context,this._callback.bind(this),this.subscribe))}_callback(t,e){e&&(this.subscribe?this.unsubscribe&&(this.unsubscribe!==e&&this.unsubscribe(),this.unsubscribe=e):e()),this.validate(t)&&(this.value=t,this.host.requestUpdate())}}const u=(t="")=>t.replace(/([A-Z])/g,(t,e)=>`-${e.toLowerCase()}`),h=(t="")=>t.toLowerCase().replace(/[-_]\w/g,t=>t[1].toUpperCase());class d extends HTMLElement{#r={};#i=new Map;#o=new Map;#c=new Set;#a=new Set;#l={};#u=!1;static shadowRootOptions={mode:"open"};static template;static get attributes(){return{}}static get properties(){return{}}constructor(){super(),this.#h(this.constructor.attributes),this.#d(this.constructor.properties)}#p(t,e){this.#r[t]=s(e),Object.defineProperty(this,t,{enumerable:!0,get(){return this.#r[t].get()},set(e){const s=this.#r[t].get();s!==e&&(this.#r[t].set(e),this.#l[t]=s,this.requestUpdate())}})}#h(t={}){for(const[e,s]of Object.entries(t)){const t=b(s);this.#o.set(e,t.type),this.#i.set(e.toLowerCase(),e),this.#i.set(u(e),e),this.#p(e,t.value)}}#d(t={}){for(const[e,s]of Object.entries(t))this.#i.has(e)||e in this.#r||this.#p(e,s)}#f(t){return this.#i.get(t)||t}#b(t){return this.#o.get(t)}connectedCallback(){this.#a.forEach(t=>t.hostConnected?.());const{shadowRootOptions:t,template:e}=this.constructor;this.renderRoot=t?this.shadowRoot??this.attachShadow(t):this,this.addTemplate(e),this.render(),this.requestUpdate()}disconnectedCallback(){this.#c.forEach(t=>t()),this.#a.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){const n=this.#f(t),r=this.#b(n);this.#l[n]=this[n],this[n]=g(s,r),"Boolean"===r&&"false"===s&&this.removeAttribute(t),this.requestUpdate()}setAttribute(t,e){const s=this.#f(t);if(!(s in this.#r))return;const n=this.#b(s);"Boolean"===n?!0===e||""===e?super.setAttribute(t,""):super.removeAttribute(t):["String","Number"].includes(n??"")||!0===e?super.setAttribute(t,e):(this.#l[s]=this[s],this[s]=e,this.requestUpdate())}shouldUpdate(t){return!0}requestUpdate(){!this.#u&&this.isConnected&&(this.#u=!0,requestAnimationFrame(()=>{this.#u=!1;const t=this.#l;this.#l={},this.shouldUpdate(t)&&this.update(t)}))}addTemplate(t){if(!(t instanceof HTMLTemplateElement))throw new Error("template is not a HTMLTemplateElement");this.renderRoot.append(t.content.cloneNode(!0))}render(){}update(t){}on(t,e,s=this){s.addEventListener(t,e),this.#c.add(()=>s.removeEventListener(t,e))}once(t,e,s=this){s.addEventListener(t,e,{once:!0})}dispose(...t){for(const e of t){if("function"!=typeof e)throw new TypeError("listener must be a function");this.#c.add(e)}}addController(t){this.#a.add(t),this.isConnected&&t.hostConnected?.()}removeController(t){this.#a.delete(t)}}const p=(t,e,s)=>{e.observedAttributes=(e.observedAttributes||Object.keys(e.attributes||[])).map(t=>t.toLowerCase()),f(e),window.customElements.define(t,e,s)},f=t=>{if(t.template instanceof HTMLTemplateElement)return;const e=document.createElement("template");e.innerHTML=t.template,t.template=e},b=t=>{switch(t){case Boolean:return{value:void 0,type:"Boolean"};case Number:return{value:void 0,type:"Number"};case String:return{value:void 0,type:"String"};default:return{value:t,type:toString.call(t).slice(8,-1)}}},g=(t,e)=>{switch(e){case"Number":return(t=>{const e=Number(t);return isNaN(e)?t:e})(t);case"Boolean":return"false"!==t&&(""===t||!!t)}return t};class m extends String{}const v=t=>new m(t),w={"&":"&amp;","<":"&lt;",">":"&gt;","'":"&#39;",'"':"&quot;"},C=t=>t instanceof m?t:(""+t).replace(/&amp;/g,"&").replace(/[&<>'"]/g,t=>w[t]),y=(t,...e)=>v(String.raw({raw:t},...e.map(C)));function x(t){const e=t.querySelectorAll?.("[id]")||[],s={};for(const t of e)s[h(t.getAttribute("id")||t.nodeName.toLowerCase())]=t;return s}function A(t,e){const s={};for(const[n,r]of Object.entries(e))s[n]=t.querySelector?.(r);return s}class N extends e{constructor(t,e,s){super(e,s);for(const[e,s]of Object.entries(t))this[e]=t=>this.set(s(t)(this.get()))}}const S=t=>{const e=[];for(const[s,n]of Object.entries(t??{}))n&&e.push(s);return e.join(" ")},E=(t,e)=>{const{unit:s="px"}=e||{},n=[];for(const[e,r]of Object.entries(t??{})){if(null==r)continue;const t=Number.isFinite(r)?s:"";n.push(`${u(e)}:${r}${t}`)}return n.join(";")};let L=null;function k(t){t.adoptedStyleSheets.push(...(null===L&&(L=Array.from(document.styleSheets).map(({cssRules:t})=>{const e=new CSSStyleSheet,s=Array.from(t).map(t=>t.cssText).join(" ");return e.replaceSync(s),e})),L))}const{isArray:O}=Array,{getPrototypeOf:$,getOwnPropertyDescriptor:T}=Object,q=[],M=()=>document.createRange(),j=(t,e,s)=>(t.set(e,s),s),R=(t,e)=>e.reduceRight(W,t),W=(t,e)=>t.childNodes[e],{setPrototypeOf:B}=Object;let U;var D=(t,e,s)=>(U||(U=M()),s?U.setStartAfter(t):U.setStartBefore(t),U.setEndAfter(e),U.deleteContents(),t);const P=({firstChild:t,lastChild:e},s)=>D(t,e,s);let H=!1;const F=(t,e)=>H&&11===t.nodeType?1/e<0?e?P(t,!0):t.lastChild:e?t.valueOf():t.firstChild:t,_=t=>document.createComment(t);class z extends((t=>{function e(t){return B(t,new.target.prototype)}return e.prototype=t.prototype,e})(DocumentFragment)){#g=_("<>");#m=_("</>");#v=q;constructor(t){super(t),this.replaceChildren(this.#g,...t.childNodes,this.#m),H=!0}get firstChild(){return this.#g}get lastChild(){return this.#m}get parentNode(){return this.#g.parentNode}remove(){P(this,!1)}replaceWith(t){P(this,!0).replaceWith(t)}valueOf(){const{parentNode:t}=this;if(t===this)this.#v===q&&(this.#v=[...this.childNodes]);else{if(t){let{firstChild:t,lastChild:e}=this;for(this.#v=[t];t!==e;)this.#v.push(t=t.nextSibling)}this.replaceChildren(...this.#v)}return this}}const Z=(t,e,s)=>t.setAttribute(e,s),G=(t,e)=>t.removeAttribute(e);let V;const I=(t,e,s)=>{s=s.slice(1),V||(V=new WeakMap);const n=V.get(t)||j(V,t,{});let r=n[s];return r&&r[0]&&t.removeEventListener(s,...r),r=O(e)?e:[e,!1],n[s]=r,r[0]&&t.addEventListener(s,...r),e},J=(t,e)=>{const{t:s,n:n}=t;let r=!1;switch(typeof e){case"object":if(null!==e){(n||s).replaceWith(t.n=e.valueOf());break}case"undefined":r=!0;default:s.data=r?"":e,n&&(t.n=null,n.replaceWith(s))}return e},K=(t,e,s)=>t[s]=e,Q=(t,e,s)=>K(t,e,s.slice(1)),X=(t,e,s)=>null==e?(G(t,s),e):K(t,e,s),Y=(t,e)=>("function"==typeof e?e(t):e.current=t,e),tt=(t,e,s)=>(null==e?G(t,s):Z(t,s,e),e),et=(t,e,s)=>(t.toggleAttribute(s.slice(1),e),e),st=(t,e,s)=>{const{length:n}=e;if(t.data=`[${n}]`,n)return((t,e,s,n,r)=>{const i=s.length;let o=e.length,c=i,a=0,l=0,u=null;for(;a<o||l<c;)if(o===a){const e=c<i?l?n(s[l-1],-0).nextSibling:n(s[c],0):r;for(;l<c;)t.insertBefore(n(s[l++],1),e)}else if(c===l)for(;a<o;)u&&u.has(e[a])||t.removeChild(n(e[a],-1)),a++;else if(e[a]===s[l])a++,l++;else if(e[o-1]===s[c-1])o--,c--;else if(e[a]===s[c-1]&&s[l]===e[o-1]){const r=n(e[--o],-0).nextSibling;t.insertBefore(n(s[l++],1),n(e[a++],-0).nextSibling),t.insertBefore(n(s[--c],1),r),e[o]=s[c]}else{if(!u){u=new Map;let t=l;for(;t<c;)u.set(s[t],t++)}if(u.has(e[a])){const r=u.get(e[a]);if(l<r&&r<c){let i=a,h=1;for(;++i<o&&i<c&&u.get(e[i])===r+h;)h++;if(h>r-l){const i=n(e[a],0);for(;l<r;)t.insertBefore(n(s[l++],1),i)}else t.replaceChild(n(s[l++],1),n(e[a++],-1))}else a++}else t.removeChild(n(e[a++],-1))}return s})(t.parentNode,s,e,F,t);switch(s.length){case 1:s[0].remove();case 0:break;default:D(F(s[0],0),F(s.at(-1),-0),!1)}return q},nt=new Map([["aria",(t,e)=>{for(const s in e){const n=e[s],r="role"===s?s:`aria-${s}`;null==n?G(t,r):Z(t,r,n)}return e}],["class",(t,e)=>X(t,e,null==e?"class":"className")],["data",(t,e)=>{const{dataset:s}=t;for(const t in e)null==e[t]?delete s[t]:s[t]=e[t];return e}],["ref",Y],["style",(t,e)=>null==e?X(t,e,"style"):K(t.style,e,"cssText")]]),rt=(t,e,s)=>{switch(e[0]){case".":return Q;case"?":return et;case"@":return I;default:return s||"ownerSVGElement"in t?"ref"===e?Y:tt:nt.get(e)||(e in t?e.startsWith("on")?K:((t,e)=>{let s;do{s=T(t,e)}while(!s&&(t=$(t)));return s})(t,e)?.set?X:tt:tt)}},it=(t,e)=>(t.textContent=null==e?"":e,e),ot=(t,e,s)=>({a:t,b:e,c:s}),ct=(t,e,s,n)=>({v:q,u:t,t:e,n:s,c:n}),at=()=>ot(null,null,q);var lt=t=>(e,s)=>{const{a:n,b:r,c:i}=t(e,s),o=document.importNode(n,!0);let c=q;if(r!==q){c=[];for(let t,e,s=0;s<r.length;s++){const{a:n,b:i,c:a}=r[s],l=n===e?t:t=R(o,e=n);c[s]=ct(i,l,a,i===st?[]:i===J?at():null)}}return{b:i?o.firstChild:new z(o),c:c}};const ut=/^(?:plaintext|script|style|textarea|title|xmp)$/i,ht=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,dt=/<([a-zA-Z0-9]+[a-zA-Z0-9:._-]*)([^>]*?)(\/?)>/g,pt=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,ft=/[\x01\x02]/g;let bt,gt,mt=document.createElement("template");var vt=(t,e)=>{if(e)return bt||(bt=document.createElementNS("http://www.w3.org/2000/svg","svg"),gt=M(),gt.selectNodeContents(bt)),gt.createContextualFragment(t);mt.innerHTML=t;const{content:s}=mt;return mt=mt.cloneNode(!1),s};const wt=t=>{const e=[];let s;for(;s=t.parentNode;)e.push(e.indexOf.call(s.childNodes,t)),t=s;return e},Ct=()=>document.createTextNode(""),yt=new WeakMap,xt="isµ";var At=t=>(e,s)=>yt.get(e)||((t,e,s)=>{const n=vt(((t,e,s)=>{let n=0;return t.join("").trim().replace(dt,(t,e,n,r)=>`<${e}${n.replace(pt,"=$2$1").trimEnd()}${r?s||ht.test(e)?" /":`></${e}`:""}>`).replace(ft,t=>""===t?`\x3c!--${e+n++}--\x3e`:e+n++)})(t,xt,s),s),{length:r}=t;let i=q;if(r>1){const t=[],o=document.createTreeWalker(n,129);let c=0,a=`${xt}${c++}`;for(i=[];c<r;){const n=o.nextNode();if(8===n.nodeType){if(n.data===a){const s=O(e[c-1])?st:J;s===J&&t.push(n),i.push(ot(wt(n),s,null)),a=`${xt}${c++}`}}else{let t;for(;n.hasAttribute(a);){t||(t=wt(n));const e=n.getAttribute(a);i.push(ot(t,rt(n,e,s),e)),G(n,a),a=`${xt}${c++}`}!s&&ut.test(n.localName)&&n.textContent.trim()===`\x3c!--${a}--\x3e`&&(i.push(ot(t||wt(n),it,null)),a=`${xt}${c++}`)}}for(c=0;c<t.length;c++)t[c].replaceWith(Ct())}const{childNodes:o}=n;let{length:c}=o;return c<1?(c=1,n.appendChild(Ct())):1===c&&1!==r&&1!==o[0].nodeType&&(c=0),j(yt,t,ot(n,i,1===c))})(e,s,t);const Nt=lt(At(!1)),St=lt(At(!0)),Et=(t,{s:e,t:s,v:n})=>{if(t.a!==s){const{b:r,c:i}=(e?St:Nt)(s,n);t.a=s,t.b=r,t.c=i}for(let{c:e}=t,s=0;s<e.length;s++){const t=n[s],r=e[s];switch(r.u){case st:r.v=st(r.t,Lt(r.c,t),r.v);break;case J:const e=t instanceof kt?Et(r.c||(r.c=at()),t):(r.c=null,t);e!==r.v&&(r.v=J(r,e));break;default:t!==r.v&&(r.v=r.u(r.t,t,r.n,r.v))}}return t.b},Lt=(t,e)=>{let s=0,{length:n}=e;for(n<t.length&&t.splice(n);s<n;s++){const n=e[s];n instanceof kt?e[s]=Et(t[s]||(t[s]=at()),n):t[s]=null}return e};class kt{constructor(t,e,s){this.s=t,this.t=e,this.v=s}toDOM(t=at()){return Et(t,this)}}
2
- /*! (c) Andrea Giammarchi - MIT */const Ot=t=>(e,...s)=>new kt(t,e,s),$t=Ot(!1),Tt=Ot(!0),qt=new WeakMap;var Mt=(t,e,s)=>{const n=qt.get(t)||j(qt,t,at()),{b:r}=n,i=e,o=i instanceof kt?i.toDOM(n):i;return r!==o&&t.replaceChildren((n.b=o).valueOf()),t};
3
- /*! (c) Andrea Giammarchi - MIT */const jt=new WeakMap,Rt=t=>(e,s)=>{const n=jt.get(e)||j(jt,e,new Map);return n.get(s)||j(n,s,function(e,...s){return new kt(t,e,s).toDOM(this)}.bind(at()))},Wt=Rt(!1),Bt=Rt(!0),Ut=new FinalizationRegistry(([t,e,s])=>{t(e)}),Dt=Object.create(null),Pt=new WeakMap,Ht=t=>t();let Ft=!0;const _t=t=>(e,s)=>{if(Ft="function"!=typeof s,zt(e),Ft)return Mt(e,s);Ft=!0;const n=new WeakRef(e),r=t(()=>{Mt(n.deref(),s())});return Pt.set(e,r),((t,e,{debug:s,handler:n,return:r,token:i=t}=Dt)=>{const o=r||new Proxy(t,n||Dt),c=[o,[e,t,!!s]];return!1!==i&&c.push(i),Ut.register(...c),o})(r,Ht,{return:e})},zt=t=>{const e=Pt.get(t);var s;e&&(Ft&&Pt.delete(t),s=e,Ut.unregister(s),e())},Zt=_t(n);export{r as Computed,l as ContextConsumer,c as ContextProvider,a as ContextRequestEvent,kt as Hole,d as MiElement,i as Signal,e as State,N as Store,k as addGlobalStyles,_t as attach,nt as attr,S as classMap,g as convertType,s as createSignal,p as define,zt as detach,n as effect,y as esc,C as escHtml,$t as html,Wt as htmlFor,x as refsById,A as refsBySelector,Zt as render,E as styleMap,Tt as svg,Bt as svgFor,v as unsafeHtml};
1
+ const t=[];class e extends EventTarget{#t;#e;constructor(t,e){super();const{equals:s}=e||{};this.#t=t,this.#e=s??((t,e)=>t===e)}get value(){return this.get()}set value(t){this.set(t)}get(){const e=t[t.length-1];return e&&e.add(this),this.#t}set(t){this.#e(this.#t,t)||(this.#t=t,this.dispatchEvent(new CustomEvent("signal")))}}const s=(t,s)=>t instanceof e?t:new e(t,s);function n(e){const s=new Set;t.push(s);try{e()}finally{t.pop()}for(const t of s)t.addEventListener("signal",e);return()=>{for(const t of s)t.removeEventListener("signal",e)}}class r{#s;#n;constructor(t){this.#s=new e,this.#n=n(()=>this.#s.set(t()))}get(){return this.#s.get()}unsubscribe(){this.#n()}}var i={State:e,Computed:r,createSignal:s,effect:n};const o="context-request";class a{constructor(t,e,n){this.host=t,this.context=e,this.state=s(n),this.host.addController?.(this)}hostConnected(){this.host.addEventListener(o,this.onContextRequest)}hostDisconnected(){this.host.removeEventListener(o,this.onContextRequest)}set(t){this.state.set(t)}get(){return this.state.get()}onContextRequest=t=>{if(t.context!==this.context)return;let e;t.stopPropagation(),t.subscribe&&(e=n(()=>{const s=this.get();e&&t.callback(s,e)})),t.callback(this.get(),e)}}class c extends Event{constructor(t,e,s){super(o,{bubbles:!0,composed:!0}),this.context=t,this.callback=e,this.subscribe=s}}class l{#t;constructor(t,e,s){const{subscribe:n=!1,validate:r=()=>!0}=s||{};this.host=t,this.context=e,this.subscribe=!!n,this.validate=r,this.unsubscribe=void 0,this.host.addController?.(this)}get(){return this.#t}get value(){return this.#t}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new c(this.context,this._callback.bind(this),this.subscribe))}_callback(t,e){e&&(this.subscribe?this.unsubscribe&&(this.unsubscribe!==e&&this.unsubscribe(),this.unsubscribe=e):e()),this.validate(t)&&(this.#t=t,this.host.requestUpdate())}}const u=(t="")=>t.replace(/([A-Z])/g,(t,e)=>`-${e.toLowerCase()}`),h=(t="")=>t.toLowerCase().replace(/[-_]\w/g,t=>t[1].toUpperCase());class d extends HTMLElement{#r={};#i=new Map;#o=new Map;#a=new Set;#c=new Set;#l={};#u=!1;static shadowRootOptions={mode:"open"};static template;static get attributes(){return{}}static get properties(){return{}}constructor(){super(),this.#h(this.constructor.attributes),this.#d(this.constructor.properties)}#p(t,e){this.#r[t]=s(e),Object.defineProperty(this,t,{enumerable:!0,get(){return this.#r[t].get()},set(e){const s=this.#r[t].get();s!==e&&(this.#r[t].set(e),this.#l[t]=s,this.requestUpdate())}})}#h(t={}){for(const[e,s]of Object.entries(t)){const t=b(s);this.#o.set(e,t.type),this.#i.set(e.toLowerCase(),e),this.#i.set(u(e),e),this.#p(e,t.value)}}#d(t={}){for(const[e,s]of Object.entries(t))this.#i.has(e)||e in this.#r||this.#p(e,s)}#f(t){return this.#i.get(t)||t}#b(t){return this.#o.get(t)}connectedCallback(){this.#c.forEach(t=>t.hostConnected?.());const{shadowRootOptions:t,template:e}=this.constructor;this.renderRoot=t?this.shadowRoot??this.attachShadow(t):this,this.addTemplate(e),this.render(),this.requestUpdate()}disconnectedCallback(){this.#a.forEach(t=>t()),this.#c.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){const n=this.#f(t),r=this.#b(n);this.#l[n]=this[n],this[n]=g(s,r),"Boolean"===r&&"false"===s&&this.removeAttribute(t),this.requestUpdate()}setAttribute(t,e){const s=this.#f(t);if(!(s in this.#r))return;const n=this.#b(s);"Boolean"===n?!0===e||""===e?super.setAttribute(t,""):super.removeAttribute(t):["String","Number"].includes(n??"")||!0===e?super.setAttribute(t,e):(this.#l[s]=this[s],this[s]=e,this.requestUpdate())}shouldUpdate(t){return!0}requestUpdate(){!this.#u&&this.isConnected&&(this.#u=!0,requestAnimationFrame(()=>{this.#u=!1;const t=this.#l;this.#l={},this.shouldUpdate(t)&&this.update(t)}))}addTemplate(t){if(!(t instanceof HTMLTemplateElement))throw new Error("template is not a HTMLTemplateElement");this.renderRoot.append(t.content.cloneNode(!0))}render(){}update(t){}on(t,e,s=this){s.addEventListener(t,e),this.#a.add(()=>s.removeEventListener(t,e))}once(t,e,s=this){s.addEventListener(t,e,{once:!0})}dispose(...t){for(const e of t){if("function"!=typeof e)throw new TypeError("listener must be a function");this.#a.add(e)}}addController(t){this.#c.add(t),this.isConnected&&t.hostConnected?.()}removeController(t){this.#c.delete(t)}}const p=(t,e,s)=>{e.observedAttributes=(e.observedAttributes||Object.keys(e.attributes||[])).map(t=>t.toLowerCase()),f(e),window.customElements.define(t,e,s)},f=t=>{if(t.template instanceof HTMLTemplateElement)return;const e=document.createElement("template");e.innerHTML=t.template,t.template=e},b=t=>{switch(t){case Boolean:return{value:void 0,type:"Boolean"};case Number:return{value:void 0,type:"Number"};case String:return{value:void 0,type:"String"};default:return{value:t,type:toString.call(t).slice(8,-1)}}},g=(t,e)=>{switch(e){case"Number":return(t=>{const e=Number(t);return isNaN(e)?t:e})(t);case"Boolean":return"false"!==t&&(""===t||!!t)}return t};class m extends String{}const v=t=>new m(t),w={"&":"&amp;","<":"&lt;",">":"&gt;","'":"&#39;",'"':"&quot;"},C=t=>t instanceof m?t:(""+t).replace(/&amp;/g,"&").replace(/[&<>'"]/g,t=>w[t]),y=(t,...e)=>v(String.raw({raw:t},...e.map(C)));function x(t){const e=t.querySelectorAll?.("[id]")||[],s={};for(const t of e)s[h(t.getAttribute("id")||t.nodeName.toLowerCase())]=t;return s}function A(t,e){const s={};for(const[n,r]of Object.entries(e))s[n]=t.querySelector?.(r);return s}class N extends e{constructor(t,e,s){super(e,s);for(const[e,s]of Object.entries(t))this[e]=t=>this.set(s(t)(this.get()))}}const S=t=>{const e=[];for(const[s,n]of Object.entries(t??{}))n&&e.push(s);return e.join(" ")},E=(t,e)=>{const{unit:s="px"}=e||{},n=[];for(const[e,r]of Object.entries(t??{})){if(null==r)continue;const t=Number.isFinite(r)?s:"";n.push(`${u(e)}:${r}${t}`)}return n.join(";")};let L=null;function k(t){t.adoptedStyleSheets.push(...(null===L&&(L=Array.from(document.styleSheets).map(({cssRules:t})=>{const e=new CSSStyleSheet,s=Array.from(t).map(t=>t.cssText).join(" ");return e.replaceSync(s),e})),L))}const{isArray:O}=Array,{getPrototypeOf:$,getOwnPropertyDescriptor:T}=Object,q=[],M=()=>document.createRange(),j=(t,e,s)=>(t.set(e,s),s),R=(t,e)=>e.reduceRight(W,t),W=(t,e)=>t.childNodes[e],{setPrototypeOf:B}=Object;let U;var D=(t,e,s)=>(U||(U=M()),s?U.setStartAfter(t):U.setStartBefore(t),U.setEndAfter(e),U.deleteContents(),t);const P=({firstChild:t,lastChild:e},s)=>D(t,e,s);let H=!1;const F=(t,e)=>H&&11===t.nodeType?1/e<0?e?P(t,!0):t.lastChild:e?t.valueOf():t.firstChild:t,_=t=>document.createComment(t);class z extends((t=>{function e(t){return B(t,new.target.prototype)}return e.prototype=t.prototype,e})(DocumentFragment)){#g=_("<>");#m=_("</>");#v=q;constructor(t){super(t),this.replaceChildren(this.#g,...t.childNodes,this.#m),H=!0}get firstChild(){return this.#g}get lastChild(){return this.#m}get parentNode(){return this.#g.parentNode}remove(){P(this,!1)}replaceWith(t){P(this,!0).replaceWith(t)}valueOf(){const{parentNode:t}=this;if(t===this)this.#v===q&&(this.#v=[...this.childNodes]);else{if(t){let{firstChild:t,lastChild:e}=this;for(this.#v=[t];t!==e;)this.#v.push(t=t.nextSibling)}this.replaceChildren(...this.#v)}return this}}const Z=(t,e,s)=>t.setAttribute(e,s),G=(t,e)=>t.removeAttribute(e);let V;const I=(t,e,s)=>{s=s.slice(1),V||(V=new WeakMap);const n=V.get(t)||j(V,t,{});let r=n[s];return r&&r[0]&&t.removeEventListener(s,...r),r=O(e)?e:[e,!1],n[s]=r,r[0]&&t.addEventListener(s,...r),e},J=(t,e)=>{const{t:s,n:n}=t;let r=!1;switch(typeof e){case"object":if(null!==e){(n||s).replaceWith(t.n=e.valueOf());break}case"undefined":r=!0;default:s.data=r?"":e,n&&(t.n=null,n.replaceWith(s))}return e},K=(t,e,s)=>t[s]=e,Q=(t,e,s)=>K(t,e,s.slice(1)),X=(t,e,s)=>null==e?(G(t,s),e):K(t,e,s),Y=(t,e)=>("function"==typeof e?e(t):e.current=t,e),tt=(t,e,s)=>(null==e?G(t,s):Z(t,s,e),e),et=(t,e,s)=>(t.toggleAttribute(s.slice(1),e),e),st=(t,e,s)=>{const{length:n}=e;if(t.data=`[${n}]`,n)return((t,e,s,n,r)=>{const i=s.length;let o=e.length,a=i,c=0,l=0,u=null;for(;c<o||l<a;)if(o===c){const e=a<i?l?n(s[l-1],-0).nextSibling:n(s[a],0):r;for(;l<a;)t.insertBefore(n(s[l++],1),e)}else if(a===l)for(;c<o;)u&&u.has(e[c])||t.removeChild(n(e[c],-1)),c++;else if(e[c]===s[l])c++,l++;else if(e[o-1]===s[a-1])o--,a--;else if(e[c]===s[a-1]&&s[l]===e[o-1]){const r=n(e[--o],-0).nextSibling;t.insertBefore(n(s[l++],1),n(e[c++],-0).nextSibling),t.insertBefore(n(s[--a],1),r),e[o]=s[a]}else{if(!u){u=new Map;let t=l;for(;t<a;)u.set(s[t],t++)}if(u.has(e[c])){const r=u.get(e[c]);if(l<r&&r<a){let i=c,h=1;for(;++i<o&&i<a&&u.get(e[i])===r+h;)h++;if(h>r-l){const i=n(e[c],0);for(;l<r;)t.insertBefore(n(s[l++],1),i)}else t.replaceChild(n(s[l++],1),n(e[c++],-1))}else c++}else t.removeChild(n(e[c++],-1))}return s})(t.parentNode,s,e,F,t);switch(s.length){case 1:s[0].remove();case 0:break;default:D(F(s[0],0),F(s.at(-1),-0),!1)}return q},nt=new Map([["aria",(t,e)=>{for(const s in e){const n=e[s],r="role"===s?s:`aria-${s}`;null==n?G(t,r):Z(t,r,n)}return e}],["class",(t,e)=>X(t,e,null==e?"class":"className")],["data",(t,e)=>{const{dataset:s}=t;for(const t in e)null==e[t]?delete s[t]:s[t]=e[t];return e}],["ref",Y],["style",(t,e)=>null==e?X(t,e,"style"):K(t.style,e,"cssText")]]),rt=(t,e,s)=>{switch(e[0]){case".":return Q;case"?":return et;case"@":return I;default:return s||"ownerSVGElement"in t?"ref"===e?Y:tt:nt.get(e)||(e in t?e.startsWith("on")?K:((t,e)=>{let s;do{s=T(t,e)}while(!s&&(t=$(t)));return s})(t,e)?.set?X:tt:tt)}},it=(t,e)=>(t.textContent=null==e?"":e,e),ot=(t,e,s)=>({a:t,b:e,c:s}),at=(t,e,s,n)=>({v:q,u:t,t:e,n:s,c:n}),ct=()=>ot(null,null,q);var lt=t=>(e,s)=>{const{a:n,b:r,c:i}=t(e,s),o=document.importNode(n,!0);let a=q;if(r!==q){a=[];for(let t,e,s=0;s<r.length;s++){const{a:n,b:i,c:c}=r[s],l=n===e?t:t=R(o,e=n);a[s]=at(i,l,c,i===st?[]:i===J?ct():null)}}return{b:i?o.firstChild:new z(o),c:a}};const ut=/^(?:plaintext|script|style|textarea|title|xmp)$/i,ht=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,dt=/<([a-zA-Z0-9]+[a-zA-Z0-9:._-]*)([^>]*?)(\/?)>/g,pt=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,ft=/[\x01\x02]/g;let bt,gt,mt=document.createElement("template");var vt=(t,e)=>{if(e)return bt||(bt=document.createElementNS("http://www.w3.org/2000/svg","svg"),gt=M(),gt.selectNodeContents(bt)),gt.createContextualFragment(t);mt.innerHTML=t;const{content:s}=mt;return mt=mt.cloneNode(!1),s};const wt=t=>{const e=[];let s;for(;s=t.parentNode;)e.push(e.indexOf.call(s.childNodes,t)),t=s;return e},Ct=()=>document.createTextNode(""),yt=new WeakMap,xt="isµ";var At=t=>(e,s)=>yt.get(e)||((t,e,s)=>{const n=vt(((t,e,s)=>{let n=0;return t.join("").trim().replace(dt,(t,e,n,r)=>`<${e}${n.replace(pt,"=$2$1").trimEnd()}${r?s||ht.test(e)?" /":`></${e}`:""}>`).replace(ft,t=>""===t?`\x3c!--${e+n++}--\x3e`:e+n++)})(t,xt,s),s),{length:r}=t;let i=q;if(r>1){const t=[],o=document.createTreeWalker(n,129);let a=0,c=`${xt}${a++}`;for(i=[];a<r;){const n=o.nextNode();if(8===n.nodeType){if(n.data===c){const s=O(e[a-1])?st:J;s===J&&t.push(n),i.push(ot(wt(n),s,null)),c=`${xt}${a++}`}}else{let t;for(;n.hasAttribute(c);){t||(t=wt(n));const e=n.getAttribute(c);i.push(ot(t,rt(n,e,s),e)),G(n,c),c=`${xt}${a++}`}!s&&ut.test(n.localName)&&n.textContent.trim()===`\x3c!--${c}--\x3e`&&(i.push(ot(t||wt(n),it,null)),c=`${xt}${a++}`)}}for(a=0;a<t.length;a++)t[a].replaceWith(Ct())}const{childNodes:o}=n;let{length:a}=o;return a<1?(a=1,n.appendChild(Ct())):1===a&&1!==r&&1!==o[0].nodeType&&(a=0),j(yt,t,ot(n,i,1===a))})(e,s,t);const Nt=lt(At(!1)),St=lt(At(!0)),Et=(t,{s:e,t:s,v:n})=>{if(t.a!==s){const{b:r,c:i}=(e?St:Nt)(s,n);t.a=s,t.b=r,t.c=i}for(let{c:e}=t,s=0;s<e.length;s++){const t=n[s],r=e[s];switch(r.u){case st:r.v=st(r.t,Lt(r.c,t),r.v);break;case J:const e=t instanceof kt?Et(r.c||(r.c=ct()),t):(r.c=null,t);e!==r.v&&(r.v=J(r,e));break;default:t!==r.v&&(r.v=r.u(r.t,t,r.n,r.v))}}return t.b},Lt=(t,e)=>{let s=0,{length:n}=e;for(n<t.length&&t.splice(n);s<n;s++){const n=e[s];n instanceof kt?e[s]=Et(t[s]||(t[s]=ct()),n):t[s]=null}return e};class kt{constructor(t,e,s){this.s=t,this.t=e,this.v=s}toDOM(t=ct()){return Et(t,this)}}
2
+ /*! (c) Andrea Giammarchi - MIT */const Ot=t=>(e,...s)=>new kt(t,e,s),$t=Ot(!1),Tt=Ot(!0),qt=new WeakMap;var Mt=(t,e,s)=>{const n=qt.get(t)||j(qt,t,ct()),{b:r}=n,i=e,o=i instanceof kt?i.toDOM(n):i;return r!==o&&t.replaceChildren((n.b=o).valueOf()),t};
3
+ /*! (c) Andrea Giammarchi - MIT */const jt=new WeakMap,Rt=t=>(e,s)=>{const n=jt.get(e)||j(jt,e,new Map);return n.get(s)||j(n,s,function(e,...s){return new kt(t,e,s).toDOM(this)}.bind(ct()))},Wt=Rt(!1),Bt=Rt(!0),Ut=new FinalizationRegistry(([t,e,s])=>{t(e)}),Dt=Object.create(null),Pt=new WeakMap,Ht=t=>t();let Ft=!0;const _t=t=>(e,s)=>{if(Ft="function"!=typeof s,zt(e),Ft)return Mt(e,s);Ft=!0;const n=new WeakRef(e),r=t(()=>{Mt(n.deref(),s())});return Pt.set(e,r),((t,e,{debug:s,handler:n,return:r,token:i=t}=Dt)=>{const o=r||new Proxy(t,n||Dt),a=[o,[e,t,!!s]];return!1!==i&&a.push(i),Ut.register(...a),o})(r,Ht,{return:e})},zt=t=>{const e=Pt.get(t);var s;e&&(Ft&&Pt.delete(t),s=e,Ut.unregister(s),e())},Zt=_t(n);export{r as Computed,l as ContextConsumer,a as ContextProvider,c as ContextRequestEvent,kt as Hole,d as MiElement,i as Signal,e as State,N as Store,k as addGlobalStyles,_t as attach,nt as attr,S as classMap,g as convertType,s as createSignal,p as define,zt as detach,n as effect,y as esc,C as escHtml,$t as html,Wt as htmlFor,x as refsById,A as refsBySelector,Zt as render,E as styleMap,Tt as svg,Bt as svgFor,v as unsafeHtml};
4
4
  //# sourceMappingURL=index.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.min.js","sources":["../../mi-signal/dist/index.js","../src/context.js","../src/case.js","../src/element.js","../src/escape.js","../src/refs.js","../src/store.js","../src/styling.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/utils.js","../../../node_modules/.pnpm/custom-function@2.0.0/node_modules/custom-function/esm/factory.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/range.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/persistent-fragment.js","../../../node_modules/.pnpm/domconstants@1.1.6/node_modules/domconstants/esm/constants.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/handler.js","../../../node_modules/.pnpm/udomdiff@1.1.2/node_modules/udomdiff/esm/index.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/literals.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/creator.js","../../../node_modules/.pnpm/domconstants@1.1.6/node_modules/domconstants/esm/re.js","../../../node_modules/.pnpm/@webreflection+uparser@0.4.0/node_modules/@webreflection/uparser/esm/index.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/create-content.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/parser.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/rabbit.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/index.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/render/shared.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/keyed.js","../../../node_modules/.pnpm/gc-hook@0.4.1/node_modules/gc-hook/esm/index.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/render/reactive.js","../../mi-html/dist/index.js"],"sourcesContent":["const context = [];\n\nclass State extends EventTarget {\n #value;\n #equals;\n constructor(value, options) {\n super();\n const {equals: equals} = options || {};\n this.#value = value, this.#equals = equals ?? ((value, nextValue) => value === nextValue);\n }\n get value() {\n return this.get();\n }\n set value(nextValue) {\n this.set(nextValue);\n }\n get() {\n const running = context[context.length - 1];\n return running && running.add(this), this.#value;\n }\n set(nextValue) {\n this.#equals(this.#value, nextValue) || (this.#value = nextValue, this.dispatchEvent(new CustomEvent('signal')));\n }\n}\n\nconst createSignal = (initialValue, options) => initialValue instanceof State ? initialValue : new State(initialValue, options);\n\nfunction effect(cb) {\n const running = new Set;\n context.push(running);\n try {\n cb();\n } finally {\n context.pop();\n }\n for (const dep of running) dep.addEventListener('signal', cb);\n return () => {\n for (const dep of running) dep.removeEventListener('signal', cb);\n };\n}\n\nclass Computed {\n #state;\n #unsubscribe;\n constructor(cb) {\n this.#state = new State, this.#unsubscribe = effect(() => this.#state.set(cb()));\n }\n get() {\n return this.#state.get();\n }\n unsubscribe() {\n this.#unsubscribe();\n }\n}\n\nvar index = {\n State: State,\n Computed: Computed,\n createSignal: createSignal,\n effect: effect\n};\n\nexport { Computed, State, createSignal, index as default, effect };\n","/**\n * @see https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md\n */\n\nimport { createSignal, effect } from 'mi-signal'\n\n/**\n * @typedef {import('./element.js').HostController} HostController\n */\n/**\n * @typedef {string|Symbol} Context\n */\n\nconst CONTEXT_REQUEST = 'context-request'\n\n/**\n * @implements {HostController}\n */\nexport class ContextProvider {\n /**\n * @param {HTMLElement} host\n * @param {Context} context\n * @param {any} initialValue\n */\n constructor(host, context, initialValue) {\n this.host = host\n this.context = context\n this.state = createSignal(initialValue)\n // @ts-expect-error\n this.host.addController?.(this)\n }\n\n hostConnected() {\n // @ts-expect-error\n this.host.addEventListener(CONTEXT_REQUEST, this.onContextRequest)\n }\n\n hostDisconnected() {\n // @ts-expect-error\n this.host.removeEventListener(CONTEXT_REQUEST, this.onContextRequest)\n }\n\n /**\n * @param {any} newValue\n */\n set(newValue) {\n this.state.set(newValue)\n }\n\n /**\n * @returns {any}\n */\n get() {\n return this.state.get()\n }\n\n /**\n * @private\n * @param {ContextRequestEvent} ev\n */\n onContextRequest = (ev) => {\n if (ev.context !== this.context) {\n // event has wrong context\n return\n }\n ev.stopPropagation()\n let unsubscribe\n if (ev.subscribe) {\n unsubscribe = effect(() => {\n // needed to subscribe to signal\n const value = this.get()\n // don't call callback the first time where unsubscribe is not defined\n if (unsubscribe) ev.callback(value, unsubscribe)\n })\n }\n ev.callback(this.get(), unsubscribe)\n }\n}\n\nexport class ContextRequestEvent extends Event {\n /**\n * @param {Context} context\n * @param {(value: any, unsubscribe?: () => void) => void} callback\n * @param {boolean} [subscribe=false] subscribe to value changes\n */\n constructor(context, callback, subscribe) {\n super(CONTEXT_REQUEST, { bubbles: true, composed: true })\n this.context = context\n this.callback = callback\n this.subscribe = subscribe\n }\n}\n\n/**\n * @implements {HostController}\n */\nexport class ContextConsumer {\n /**\n * @param {HTMLElement} host\n * @param {Context} context\n * @param {object} [options]\n * @param {boolean} [options.subscribe=false] subscribe to value changes\n * @param {(any) => boolean} [options.validate] validation function\n */\n constructor(host, context, options) {\n const { subscribe = false, validate = () => true } = options || {}\n this.host = host\n this.context = context\n this.subscribe = !!subscribe\n this.validate = validate\n // initial value yet unknown\n this.value = undefined\n // unsubscribe function\n this.unsubscribe = undefined\n // add the controller in case of a MiElement otherwise call hostConnected()\n // and hostDisconnected() from the host element\n // @ts-expect-error\n this.host.addController?.(this)\n }\n\n hostConnected() {\n this.dispatchRequest()\n }\n\n hostDisconnected() {\n if (this.unsubscribe) {\n this.unsubscribe()\n this.unsubscribe = undefined\n }\n }\n\n dispatchRequest() {\n this.host.dispatchEvent(\n new ContextRequestEvent(\n this.context,\n this._callback.bind(this),\n this.subscribe\n )\n )\n }\n\n _callback(value, unsubscribe) {\n if (unsubscribe) {\n if (!this.subscribe) {\n // unsubscribe as we didn't ask for subscription\n unsubscribe()\n } else if (this.unsubscribe) {\n if (this.unsubscribe !== unsubscribe) {\n // looks there was a previous provider\n this.unsubscribe()\n }\n this.unsubscribe = unsubscribe\n }\n }\n if (!this.validate(value)) {\n return\n }\n this.value = value\n // @ts-expect-error\n this.host.requestUpdate()\n }\n}\n","/**\n * convert lowerCamelCase to kebab-case\n * @param {string} str\n * @returns {string}\n */\nexport const camelToKebabCase = (str = '') =>\n str.replace(/([A-Z])/g, (_, m) => `-${m.toLowerCase()}`)\n\n/**\n * convert kebab-case to lowerCamelCase\n * @param {string} str\n * @returns {string}\n */\nexport const kebabToCamelCase = (str = '') =>\n str.toLowerCase().replace(/[-_]\\w/g, (m) => m[1].toUpperCase())\n","import { camelToKebabCase } from './case.js'\nimport { createSignal } from 'mi-signal'\n\n/**\n * @typedef {object} HostController controller\n * @property {() => void} hostConnected is called when host element is added to\n * the DOM, usually with connectedCallback()\n * @property {() => void} hostDisconnected is called when host element is\n * removed from the DOM, usually with disconnectedCallback()\n */\n\n/**\n * class extending HTMLElement to enable deferred rendering on attribute changes\n * either via `setAttribute(name, value)` or `this[name] = value`.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement\n * @example\n * ```js\n * class Example extends MiElement {\n * // define all observed attributes with its default initial value.\n * // for yet to defined numbers, boolean or strings use `Number`, `Boolean`, `String`\n * // attributes are accessible via `this[prop]`\n * // avoid using attributes which are HTMLElement properties e.g. className\n * static get attributes () {\n * return { text: 'Hi', num: Number }\n * }\n * render() {\n * this.renderRoot.innerHTML = `<div></div>`\n * this.refs = {\n * div: this.renderRoot.querySelector('div')\n * }\n * }\n * // render method called every time an attribute changes\n * update() {\n * this.refs.div.textContent = this.text\n * }\n * }\n * // create a custom element with the `define` function (see below)\n * define('x-example', Example)\n * // create a DOM node and re-render via attribute or property changes\n * const elem = document.createElement('x-example')\n * elem.setAttribute('text', 'set attribute')\n * // or if change is triggered by property\n * elem.text = 'set property'\n * ```\n */\nexport class MiElement extends HTMLElement {\n /** all attributes are signals! */\n #attr = {}\n /**\n * lower-cased or kebab-case attribute names;\n * Map<lower-cased and kebab-cased attr name, camelCased attr name as string>\n * @type {Map<string, string>}\n */\n #attrLc = new Map()\n /**\n * initial types (from `static get attributes() { return {} }`)\n * Map<camelCased attribute name, type as string>\n * @type {Map<string,string>}\n */\n #types = new Map()\n #disposers = new Set()\n #controllers = new Set()\n #changedAttr = {}\n #dedupe = false\n\n /**\n * Default options used when calling `attachShadow`. Used in\n * `connectedCallback()`.\n * If override is `null`, no shadow-root will be attached.\n * @type {{mode: string}|null}\n */\n static shadowRootOptions = { mode: 'open' }\n\n /**\n * defines template for render().\n * @type {String|HTMLTemplateElement}\n */\n static template\n\n /**\n * observable attributes\n * @returns {Record<PropertyKey, unknown>|{}}\n */\n static get attributes() {\n return {}\n }\n /**\n * observable properties\n * @returns {Record<PropertyKey, unknown>|{}}\n */\n static get properties() {\n return {}\n }\n\n constructor() {\n super()\n // @ts-expect-error\n this.#observedAttributes(this.constructor.attributes)\n // @ts-expect-error\n this.#observedProperties(this.constructor.properties)\n }\n\n #observe(name, initialValue) {\n this.#attr[name] = createSignal(initialValue)\n Object.defineProperty(this, name, {\n enumerable: true,\n get() {\n return this.#attr[name].get()\n },\n set(newValue) {\n const oldValue = this.#attr[name].get()\n if (oldValue === newValue) return\n this.#attr[name].set(newValue)\n this.#changedAttr[name] = oldValue\n this.requestUpdate()\n }\n })\n }\n\n /**\n * requests update on component when property changes\n * @param {Record<string, any>} [attributes]\n */\n #observedAttributes(attributes = {}) {\n for (const [name, value] of Object.entries(attributes)) {\n const initial = initialValueType(value)\n this.#types.set(name, initial.type)\n this.#attrLc.set(name.toLowerCase(), name)\n this.#attrLc.set(camelToKebabCase(name), name)\n this.#observe(name, initial.value)\n }\n }\n\n /**\n * define (direct) properties\n * @param {Record<string, any>} [properties]\n */\n #observedProperties(properties = {}) {\n for (const [name, value] of Object.entries(properties)) {\n if (this.#attrLc.has(name) || name in this.#attr) {\n continue\n }\n this.#observe(name, value)\n }\n }\n\n /**\n * return camelCased value instead of possible lowercased\n * @param {string} name\n * @returns\n */\n #getName(name) {\n return this.#attrLc.get(name) || name\n }\n\n #getType(name) {\n return this.#types.get(name)\n }\n\n /**\n * creates the element's renderRoot, sets up styling\n * @category lifecycle\n */\n connectedCallback() {\n this.#controllers.forEach((controller) => controller.hostConnected?.())\n // create render root\n // @ts-expect-error\n const { shadowRootOptions, template } = this.constructor\n this.renderRoot = shadowRootOptions\n ? (this.shadowRoot ?? this.attachShadow(shadowRootOptions))\n : this\n this.addTemplate(template)\n // trigger initial rendering such that children can be added via JS\n this.render()\n // and update\n this.requestUpdate()\n }\n\n /**\n * unsubscribe from all events and disconnect controllers\n */\n disconnectedCallback() {\n // unsubscribe from all subscriptions\n this.#disposers.forEach((remover) => remover())\n // disconnect all controllers\n this.#controllers.forEach((controller) => controller.hostDisconnected?.())\n }\n\n /**\n * @param {string} name change attribute\n * @param {any} oldValue\n * @param {any} newValue new value\n */\n attributeChangedCallback(name, oldValue, newValue) {\n const attr = this.#getName(name)\n const type = this.#getType(attr)\n this.#changedAttr[attr] = this[attr]\n this[attr] = convertType(newValue, type)\n // correct initial setting of `trueish=\"false\"` otherwise there's no chance\n // to overwrite a trueish value. The case `falsish=\"true\"` is covered.\n if (type === 'Boolean' && newValue === 'false') {\n this.removeAttribute(name)\n }\n this.requestUpdate()\n }\n\n /**\n * Set string and number attributes on element only. Set all other values as\n * properties to avoid type conversion to and from string\n * @param {string} name\n * @param {any} newValue\n */\n setAttribute(name, newValue) {\n const attr = this.#getName(name)\n // only allow to change observedAttributes\n if (!(attr in this.#attr)) {\n return\n }\n const type = this.#getType(attr)\n\n // only set string values in these cases\n if (type === 'Boolean') {\n if (newValue === true || newValue === '') {\n super.setAttribute(name, '')\n } else {\n super.removeAttribute(name)\n }\n } else if (['String', 'Number'].includes(type ?? '') || newValue === true) {\n super.setAttribute(name, newValue)\n } else {\n this.#changedAttr[attr] = this[attr]\n this[attr] = newValue\n this.requestUpdate()\n }\n }\n\n /**\n * controls if component shall be updated\n * @param {Record<string,any>} [_changedAttributes] previous values of changed attributes\n * @returns {boolean}\n */\n shouldUpdate(_changedAttributes) {\n return true\n }\n\n /**\n * request rendering\n */\n requestUpdate() {\n if (this.#dedupe || !this.isConnected) return\n this.#dedupe = true\n requestAnimationFrame(() => {\n this.#dedupe = false\n // reset changed attributes\n const _changedAttributes = this.#changedAttr\n this.#changedAttr = {}\n if (this.shouldUpdate(_changedAttributes)) {\n this.update(_changedAttributes)\n }\n })\n }\n\n /**\n * adds a template to renderRoot\n * @param {HTMLTemplateElement} template\n */\n addTemplate(template) {\n if (!(template instanceof HTMLTemplateElement)) {\n throw new Error('template is not a HTMLTemplateElement')\n }\n this.renderRoot.append(template.content.cloneNode(true))\n }\n\n /**\n * initial rendering\n */\n render() {}\n\n /**\n * called every time the components needs a render update\n * @param {Record<string,any>} [_changedAttributes] previous values of changed\n * attributes\n */\n update(_changedAttributes) {}\n\n /**\n * Adds listener function for eventName. listener is removed before component\n * disconnects\n * @param {string} eventName\n * @param {EventListenerOrEventListenerObject} listener\n * @param {Node|Document|Window} [node=this]\n */\n on(eventName, listener, node = this) {\n node.addEventListener(eventName, listener)\n this.#disposers.add(() => node.removeEventListener(eventName, listener))\n }\n\n /**\n * Adds one-time listener function for eventName. The next time eventName is\n * triggered, this listener is removed and then invoked.\n * @param {string} eventName\n * @param {EventListenerOrEventListenerObject} listener\n * @param {Node|Document|Window} node\n */\n once(eventName, listener, node = this) {\n node.addEventListener(eventName, listener, { once: true })\n }\n\n /**\n * Unsubscribe a listener function for disposal on disconnectedCallback()\n * @param {...function} listeners\n */\n dispose(...listeners) {\n for (const listener of listeners) {\n if (typeof listener !== 'function') {\n throw new TypeError('listener must be a function')\n }\n this.#disposers.add(listener)\n }\n }\n\n /**\n * adds a connected controller\n * @param {HostController} controller\n */\n addController(controller) {\n this.#controllers.add(controller)\n if (this.isConnected) {\n // if already connected call hostConnected() immediately\n /* istanbul ignore next */\n controller.hostConnected?.()\n }\n }\n\n /**\n * removes a connected controller\n * @param {HostController} controller\n */\n /* istanbul ignore next 3 */\n removeController(controller) {\n this.#controllers.delete(controller)\n }\n}\n\n/**\n * defines a custom element adding observedAttributes from default static\n * attributes\n * NOTE: camelCased attributes get lowercased!\n * ```html\n * <custom-element myAttr=\"1\">\n * <!-- is equal to -->\n * <custom-element myattr=\"1\">\n * ```\n * @param {string} name custom element tag\n * @param {typeof MiElement} element\n * @param {object} [options]\n */\nexport const define = (name, element, options) => {\n // @ts-expect-error\n element.observedAttributes = // @ts-expect-error\n (element.observedAttributes || Object.keys(element.attributes || [])).map(\n (attr) => attr.toLowerCase()\n )\n renderTemplate(element)\n window.customElements.define(name, element, options)\n}\n\n// --- utils\n\n/**\n * convert (and cache) the static template to HTMLTemplateElement\n * @param {typeof MiElement} element\n */\nconst renderTemplate = (element) => {\n if (element.template instanceof HTMLTemplateElement) {\n return\n }\n const el = document.createElement('template')\n el.innerHTML = element.template\n element.template = el\n}\n\nconst initialValueType = (value) => {\n switch (value) {\n case Boolean:\n return { value: undefined, type: 'Boolean' }\n case Number:\n return { value: undefined, type: 'Number' }\n case String:\n return { value: undefined, type: 'String' }\n default:\n return { value, type: toString.call(value).slice(8, -1) }\n }\n}\n\nconst toNumber = (any) => {\n const n = Number(any)\n return isNaN(n) ? any : n\n}\n\nexport const convertType = (any, type) => {\n // setAttribute prevents passing Object or Array type. no further conversion required\n switch (type) {\n case 'Number':\n return toNumber(any)\n case 'Boolean':\n // boolean values are set via setAttribute as empty string\n if (any === 'false') {\n return false\n }\n return any === '' || !!any\n }\n return any\n}\n","class UnsafeHtml extends String {}\n\n/**\n * tag a string as html for not to be escaped\n * @param {string} str\n * @returns {string}\n */\n// @ts-expect-error\nexport const unsafeHtml = (str) => new UnsafeHtml(str)\n\nconst escMap = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n \"'\": '&#39;',\n '\"': '&quot;'\n}\n\n/**\n * escape HTML and prevent double escaping of '&'\n * @param {string} string - which requires escaping\n * @returns {string} escaped string\n * @example\n * escapeHTML('<h1>\"One\" & 'Two' &amp; Works</h1>')\n * //> &lt;h1&gt;&quot;One&quot; &amp; &#39;Two&#39; &amp; Works&lt;/h1&gt;\n */\nexport const escHtml = (string) =>\n // @ts-expect-error\n string instanceof UnsafeHtml\n ? string\n : ('' + string)\n .replace(/&amp;/g, '&')\n .replace(/[&<>'\"]/g, (tag) => escMap[tag])\n\n/**\n * template literal to HTML escape all values preventing XSS\n * @param {string[]} strings\n * @param {...any} vars\n * @returns {string}\n */\nexport const esc = (strings, ...vars) =>\n unsafeHtml(String.raw({ raw: strings }, ...vars.map(escHtml)))\n","import { kebabToCamelCase } from './case.js'\n\n/**\n * Helper function to find `id` attributes in `container`s node tree.\n * id names are camelCased, e.g. 'list-container' becomes 'listContainer'\n * @param {Element} container root element\n * @returns {Record<string, Node>|{}} record of found references\n * @example\n * el.innerHTML = `<p id>unnamed <span id=\"named\">and named</span> reference</p>`\n * references = refs(el)\n * //> references = { p: <p>, named: <span> }\n */\nexport function refsById(container) {\n const nodes = container.querySelectorAll?.('[id]') || []\n const found = {}\n for (const node of nodes) {\n const name = kebabToCamelCase(\n node.getAttribute('id') || node.nodeName.toLowerCase()\n )\n found[name] = node\n }\n return found\n}\n\n/**\n * Helper function to gather references by a map of selectors\n * @param {Element} container root element\n * @param {Record<string, string>} selectors\n * @returns {Record<string, Node>|{}}\n * @example\n * el.innerHTML = `<p>some <span>and other</span> reference</p>`\n * references = refs(el, { p: 'p', named: 'p > span' })\n * //> references = { p: <p>, named: <span> }\n */\nexport function refsBySelector(container, selectors) {\n const found = {}\n for (const [name, selector] of Object.entries(selectors)) {\n found[name] = container.querySelector?.(selector)\n }\n return found\n}\n","import { State } from 'mi-signal'\n\n/**\n * @typedef {import('./element.js').MiElement} MiElement\n */\n/**\n * @typedef {(state: any, data?: any) => any} Action\n */\n/**\n * @template T\n * @typedef {import('mi-signal').SignalOptions<T>} SignalOptions<T>\n */\n\n/**\n * Store implementing [Flux](https://www.npmjs.com/package/flux) pattern based\n * on Signals\n * @template T\n */\nexport class Store extends State {\n /**\n * @param {Record<string, Action>} actions\n * @param {T|null} [initialValue]\n * @param {SignalOptions<T>} [options]\n * @example\n * ```js\n * import { Signal, Store } from 'mi-element'\n * const actions = { increment: (by = 1) => (current) => current + by }\n * const initialValue = 1\n * const store = new Store(actions, initialValue)\n * // subscribe with a callback function\n * const unsubscribe = Signal.effect(() => console.log(`count is ${store.get()}`))\n * // change the store\n * store.increment(2) // increment by 2\n * //> count is 3\n * unsubscribe()\n * ```\n *\n * if `initialValue` is an object, the object's reference must be changed\n * using the spread operator, in order to notify on state changes, e.g.\n * ```js\n * const initialValue = { count: 0, other: 'foo' }\n * const actions = {\n * increment: (by = 1) => (state) => ({...state, count: state.count + by})\n * }\n * ```\n * or you change the signals options equality function\n * ```js\n * const actions = {\n * increment: (by = 1) => (state) => {\n * state.count += by\n * return state\n * }\n * }\n * const initialValue = { count: 0, other: 'foo' }\n * const options = { equals: (value, nextValue) => true }\n * const store = new Store(actions, initialValue, options)\n * ```\n */\n constructor(actions, initialValue, options) {\n super(initialValue, options)\n for (const [action, dispatcher] of Object.entries(actions)) {\n if (process.env.NODE_ENV !== 'production') {\n if (this[action]) {\n throw new Error(`action \"${action}\" is already defined`)\n }\n if (\n typeof dispatcher !== 'function' ||\n typeof dispatcher(undefined) !== 'function'\n ) {\n throw new Error(\n `action \"${action}\" must be a function of type \\`() => (state) => state\\``\n )\n }\n }\n this[action] = (data) => this.set(dispatcher(data)(this.get()))\n }\n }\n}\n","import { camelToKebabCase } from './case.js'\n\n/**\n * Construct className based on true-ish values of map\n * @param {{[name: string]: string | boolean | number}} map\n * @returns {string}\n */\nexport const classMap = (map) => {\n /** @type {string[]} */\n const acc = []\n for (const [name, value] of Object.entries(map ?? {})) {\n if (value) acc.push(name)\n }\n return acc.join(' ')\n}\n\n/**\n * Construct style from camelCased map.\n * @param {{[name: string]: string | number | undefined | null}} map\n * @param {object} [options]\n * @param {string} [options.unit] cssUnit for number values; default='px'\n * @returns {string}\n */\nexport const styleMap = (map, options) => {\n const { unit = 'px' } = options || {}\n const acc = []\n for (const [name, value] of Object.entries(map ?? {})) {\n if (value === null || value === undefined) continue\n const _unit = Number.isFinite(value) ? unit : ''\n acc.push(`${camelToKebabCase(name)}:${value}${_unit}`)\n }\n return acc.join(';')\n}\n\n// ----\n\nlet globalSheets = null\n/**\n * obtain and cache global stylesheets\n * @returns {CSSStyleSheet[]}\n */\nfunction getGlobalStyleSheets() {\n if (globalSheets === null) {\n globalSheets = Array.from(document.styleSheets).map(({ cssRules }) => {\n const sheet = new CSSStyleSheet()\n const css = Array.from(cssRules)\n .map((rule) => rule.cssText)\n .join(' ')\n sheet.replaceSync(css)\n return sheet\n })\n }\n return globalSheets\n}\n\n/**\n * apply global style sheets to shadowRoot\n * @param {ShadowRoot} renderRoot\n * @example\n * class MyComponent extends MiElement {\n * render() {\n * addGlobalStyles(this.renderRoot)\n * }\n * }\n */\nexport function addGlobalStyles(renderRoot) {\n renderRoot.adoptedStyleSheets.push(...getGlobalStyleSheets())\n}\n\n/**\n * Helper literal to show css styles in JS e.g. with\n * https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html\n */\nexport const css = (strings, ...values) =>\n String.raw({ raw: strings }, ...values)\n","const { isArray } = Array;\nconst { getPrototypeOf, getOwnPropertyDescriptor } = Object;\n\nexport { isArray };\n\nexport const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n\nexport const empty = [];\n\nexport const newRange = () => document.createRange();\n\n/**\n * Set the `key` `value` pair to the *Map* or *WeakMap* and returns the `value`\n * @template T\n * @param {Map | WeakMap} map\n * @param {any} key\n * @param {T} value\n * @returns {T}\n */\nexport const set = (map, key, value) => {\n map.set(key, value);\n return value;\n};\n\n/**\n * Return a descriptor, if any, for the referenced *Element*\n * @param {Element} ref\n * @param {string} prop\n * @returns \n */\nexport const gPD = (ref, prop) => {\n let desc;\n do { desc = getOwnPropertyDescriptor(ref, prop); }\n while(!desc && (ref = getPrototypeOf(ref)));\n return desc;\n};\n\n/* c8 ignore start */\n/**\n * @param {DocumentFragment} content\n * @param {number[]} path\n * @returns {Element}\n */\nexport const find = (content, path) => path.reduceRight(childNodesIndex, content);\nconst childNodesIndex = (node, i) => node.childNodes[i];\n/* c8 ignore stop */\n","const {setPrototypeOf} = Object;\n\n/**\n * @param {Function} Class any base class to extend without passing through it via super() call.\n * @returns {Function} an extensible class for the passed one.\n * @example\n * // creating this very same module utility\n * import custom from 'custom-function/factory';\n * const CustomFunction = custom(Function);\n * class MyFunction extends CustomFunction {}\n * const mf = new MyFunction(() => {});\n */\nexport default Class => {\n function Custom(target) {\n return setPrototypeOf(target, new.target.prototype);\n }\n Custom.prototype = Class.prototype;\n return Custom;\n};\n","import { newRange } from './utils.js';\n\nlet range;\n/**\n * @param {Node | Element} firstChild\n * @param {Node | Element} lastChild\n * @param {boolean} preserve\n * @returns\n */\nexport default (firstChild, lastChild, preserve) => {\n if (!range) range = newRange();\n /* c8 ignore start */\n if (preserve)\n range.setStartAfter(firstChild);\n else\n range.setStartBefore(firstChild);\n /* c8 ignore stop */\n range.setEndAfter(lastChild);\n range.deleteContents();\n return firstChild;\n};\n","import { DOCUMENT_FRAGMENT_NODE } from 'domconstants/constants';\nimport custom from 'custom-function/factory';\nimport drop from './range.js';\nimport { empty } from './utils.js';\n\n/**\n * @param {PersistentFragment} fragment\n * @returns {Node | Element}\n */\nconst remove = ({firstChild, lastChild}, preserve) => drop(firstChild, lastChild, preserve);\n\nlet checkType = false;\n\n/**\n * @param {Node} node\n * @param {1 | 0 | -0 | -1} operation\n * @returns {Node}\n */\nexport const diffFragment = (node, operation) => (\n checkType && node.nodeType === DOCUMENT_FRAGMENT_NODE ?\n ((1 / operation) < 0 ?\n (operation ? remove(node, true) : node.lastChild) :\n (operation ? node.valueOf() : node.firstChild)) :\n node\n);\n\nconst comment = value => document.createComment(value);\n\n/** @extends {DocumentFragment} */\nexport class PersistentFragment extends custom(DocumentFragment) {\n #firstChild = comment('<>');\n #lastChild = comment('</>');\n #nodes = empty;\n constructor(fragment) {\n super(fragment);\n this.replaceChildren(...[\n this.#firstChild,\n ...fragment.childNodes,\n this.#lastChild,\n ]);\n checkType = true;\n }\n get firstChild() { return this.#firstChild; }\n get lastChild() { return this.#lastChild; }\n get parentNode() { return this.#firstChild.parentNode; }\n remove() {\n remove(this, false);\n }\n replaceWith(node) {\n remove(this, true).replaceWith(node);\n }\n valueOf() {\n const { parentNode } = this;\n if (parentNode === this) {\n if (this.#nodes === empty)\n this.#nodes = [...this.childNodes];\n }\n else {\n /* c8 ignore start */\n // there are cases where a fragment might be just appended\n // out of the box without valueOf() invoke (first render).\n // When these are moved around and lose their parent and,\n // such parent is not the fragment itself, it's possible there\n // where changes or mutations in there to take care about.\n // This is a render-only specific issue but it's tested and\n // it's worth fixing to me to have more consistent fragments.\n if (parentNode) {\n let { firstChild, lastChild } = this;\n this.#nodes = [firstChild];\n while (firstChild !== lastChild)\n this.#nodes.push((firstChild = firstChild.nextSibling));\n }\n /* c8 ignore stop */\n this.replaceChildren(...this.#nodes);\n }\n return this;\n }\n}\n","export const ELEMENT_NODE = 1;\nexport const ATTRIBUTE_NODE = 2;\nexport const TEXT_NODE = 3;\nexport const COMMENT_NODE = 8;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_TYPE_NODE = 10;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\n","import udomdiff from 'udomdiff';\nimport { empty, gPD, isArray, set } from './utils.js';\nimport { diffFragment } from './persistent-fragment.js';\nimport drop from './range.js';\n\nconst setAttribute = (element, name, value) =>\n element.setAttribute(name, value);\n\n/**\n * @param {Element} element\n * @param {string} name\n * @returns {void}\n */\nexport const removeAttribute = (element, name) =>\n element.removeAttribute(name);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const aria = (element, value) => {\n for (const key in value) {\n const $ = value[key];\n const name = key === 'role' ? key : `aria-${key}`;\n if ($ == null) removeAttribute(element, name);\n else setAttribute(element, name, $);\n }\n return value;\n};\n\nlet listeners;\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const at = (element, value, name) => {\n name = name.slice(1);\n if (!listeners) listeners = new WeakMap;\n const known = listeners.get(element) || set(listeners, element, {});\n let current = known[name];\n if (current && current[0]) element.removeEventListener(name, ...current);\n current = isArray(value) ? value : [value, false];\n known[name] = current;\n if (current[0]) element.addEventListener(name, ...current);\n return value;\n};\n\n/** @type {WeakMap<Node, Element | import(\"./persistent-fragment.js\").PersistentFragment>} */\nconst holes = new WeakMap;\n\n/**\n * @template T\n * @param {import(\"./literals.js\").Detail} detail\n * @param {T} value\n * @returns {T}\n */\nexport const hole = (detail, value) => {\n const { t: node, n: hole } = detail;\n let nullish = false;\n switch (typeof value) {\n case 'object':\n if (value !== null) {\n (hole || node).replaceWith((detail.n = value.valueOf()));\n break;\n }\n case 'undefined':\n nullish = true;\n default:\n node.data = nullish ? '' : value;\n if (hole) {\n detail.n = null;\n hole.replaceWith(node);\n }\n break;\n }\n return value;\n};\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const className = (element, value) => maybeDirect(\n element, value, value == null ? 'class' : 'className'\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const data = (element, value) => {\n const { dataset } = element;\n for (const key in value) {\n if (value[key] == null) delete dataset[key];\n else dataset[key] = value[key];\n }\n return value;\n};\n\n/**\n * @template T\n * @param {Element | CSSStyleDeclaration} ref\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const direct = (ref, value, name) => (ref[name] = value);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const dot = (element, value, name) => direct(element, value, name.slice(1));\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const maybeDirect = (element, value, name) => (\n value == null ?\n (removeAttribute(element, name), value) :\n direct(element, value, name)\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const ref = (element, value) => (\n (typeof value === 'function' ?\n value(element) : (value.current = element)),\n value\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nconst regular = (element, value, name) => (\n (value == null ?\n removeAttribute(element, name) :\n setAttribute(element, name, value)),\n value\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const style = (element, value) => (\n value == null ?\n maybeDirect(element, value, 'style') :\n direct(element.style, value, 'cssText')\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const toggle = (element, value, name) => (\n element.toggleAttribute(name.slice(1), value),\n value\n);\n\n/**\n * @param {Node} node\n * @param {Node[]} value\n * @param {string} _\n * @param {Node[]} prev\n * @returns {Node[]}\n */\nexport const array = (node, value, prev) => {\n // normal diff\n const { length } = value;\n node.data = `[${length}]`;\n if (length)\n return udomdiff(node.parentNode, prev, value, diffFragment, node);\n /* c8 ignore start */\n switch (prev.length) {\n case 1:\n prev[0].remove();\n case 0:\n break;\n default:\n drop(\n diffFragment(prev[0], 0),\n diffFragment(prev.at(-1), -0),\n false\n );\n break;\n }\n /* c8 ignore stop */\n return empty;\n};\n\nexport const attr = new Map([\n ['aria', aria],\n ['class', className],\n ['data', data],\n ['ref', ref],\n ['style', style],\n]);\n\n/**\n * @param {HTMLElement | SVGElement} element\n * @param {string} name\n * @param {boolean} svg\n * @returns\n */\nexport const attribute = (element, name, svg) => {\n switch (name[0]) {\n case '.': return dot;\n case '?': return toggle;\n case '@': return at;\n default: return (\n svg || ('ownerSVGElement' in element) ?\n (name === 'ref' ? ref : regular) :\n (attr.get(name) || (\n name in element ?\n (name.startsWith('on') ?\n direct :\n (gPD(element, name)?.set ? maybeDirect : regular)\n ) :\n regular\n )\n )\n );\n }\n};\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const text = (element, value) => (\n (element.textContent = value == null ? '' : value),\n value\n);\n","/**\n * ISC License\n *\n * Copyright (c) 2020, Andrea Giammarchi, @WebReflection\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\n * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * @param {Node} parentNode The container where children live\n * @param {Node[]} a The list of current/live children\n * @param {Node[]} b The list of future children\n * @param {(entry: Node, action: number) => Node} get\n * The callback invoked per each entry related DOM operation.\n * @param {Node} [before] The optional node used as anchor to insert before.\n * @returns {Node[]} The same list of future children.\n */\nexport default (parentNode, a, b, get, before) => {\n const bLength = b.length;\n let aEnd = a.length;\n let bEnd = bLength;\n let aStart = 0;\n let bStart = 0;\n let map = null;\n while (aStart < aEnd || bStart < bEnd) {\n // append head, tail, or nodes in between: fast path\n if (aEnd === aStart) {\n // we could be in a situation where the rest of nodes that\n // need to be added are not at the end, and in such case\n // the node to `insertBefore`, if the index is more than 0\n // must be retrieved, otherwise it's gonna be the first item.\n const node = bEnd < bLength ?\n (bStart ?\n (get(b[bStart - 1], -0).nextSibling) :\n get(b[bEnd], 0)) :\n before;\n while (bStart < bEnd)\n parentNode.insertBefore(get(b[bStart++], 1), node);\n }\n // remove head or tail: fast path\n else if (bEnd === bStart) {\n while (aStart < aEnd) {\n // remove the node only if it's unknown or not live\n if (!map || !map.has(a[aStart]))\n parentNode.removeChild(get(a[aStart], -1));\n aStart++;\n }\n }\n // same node: fast path\n else if (a[aStart] === b[bStart]) {\n aStart++;\n bStart++;\n }\n // same tail: fast path\n else if (a[aEnd - 1] === b[bEnd - 1]) {\n aEnd--;\n bEnd--;\n }\n // The once here single last swap \"fast path\" has been removed in v1.1.0\n // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85\n // reverse swap: also fast path\n else if (\n a[aStart] === b[bEnd - 1] &&\n b[bStart] === a[aEnd - 1]\n ) {\n // this is a \"shrink\" operation that could happen in these cases:\n // [1, 2, 3, 4, 5]\n // [1, 4, 3, 2, 5]\n // or asymmetric too\n // [1, 2, 3, 4, 5]\n // [1, 2, 3, 5, 6, 4]\n const node = get(a[--aEnd], -0).nextSibling;\n parentNode.insertBefore(\n get(b[bStart++], 1),\n get(a[aStart++], -0).nextSibling\n );\n parentNode.insertBefore(get(b[--bEnd], 1), node);\n // mark the future index as identical (yeah, it's dirty, but cheap 👍)\n // The main reason to do this, is that when a[aEnd] will be reached,\n // the loop will likely be on the fast path, as identical to b[bEnd].\n // In the best case scenario, the next loop will skip the tail,\n // but in the worst one, this node will be considered as already\n // processed, bailing out pretty quickly from the map index check\n a[aEnd] = b[bEnd];\n }\n // map based fallback, \"slow\" path\n else {\n // the map requires an O(bEnd - bStart) operation once\n // to store all future nodes indexes for later purposes.\n // In the worst case scenario, this is a full O(N) cost,\n // and such scenario happens at least when all nodes are different,\n // but also if both first and last items of the lists are different\n if (!map) {\n map = new Map;\n let i = bStart;\n while (i < bEnd)\n map.set(b[i], i++);\n }\n // if it's a future node, hence it needs some handling\n if (map.has(a[aStart])) {\n // grab the index of such node, 'cause it might have been processed\n const index = map.get(a[aStart]);\n // if it's not already processed, look on demand for the next LCS\n if (bStart < index && index < bEnd) {\n let i = aStart;\n // counts the amount of nodes that are the same in the future\n let sequence = 1;\n while (++i < aEnd && i < bEnd && map.get(a[i]) === (index + sequence))\n sequence++;\n // effort decision here: if the sequence is longer than replaces\n // needed to reach such sequence, which would brings again this loop\n // to the fast path, prepend the difference before a sequence,\n // and move only the future list index forward, so that aStart\n // and bStart will be aligned again, hence on the fast path.\n // An example considering aStart and bStart are both 0:\n // a: [1, 2, 3, 4]\n // b: [7, 1, 2, 3, 6]\n // this would place 7 before 1 and, from that time on, 1, 2, and 3\n // will be processed at zero cost\n if (sequence > (index - bStart)) {\n const node = get(a[aStart], 0);\n while (bStart < index)\n parentNode.insertBefore(get(b[bStart++], 1), node);\n }\n // if the effort wasn't good enough, fallback to a replace,\n // moving both source and target indexes forward, hoping that some\n // similar node will be found later on, to go back to the fast path\n else {\n parentNode.replaceChild(\n get(b[bStart++], 1),\n get(a[aStart++], -1)\n );\n }\n }\n // otherwise move the source forward, 'cause there's nothing to do\n else\n aStart++;\n }\n // this node has no meaning in the future list, so it's more than safe\n // to remove it, and check the next live node out instead, meaning\n // that only the live list index should be forwarded\n else\n parentNode.removeChild(get(a[aStart++], -1));\n }\n }\n return b;\n};\n","import { empty } from './utils.js';\n\n/** @typedef {import(\"./persistent-fragment.js\").PersistentFragment} PersistentFragment */\n/** @typedef {import(\"./rabbit.js\").Hole} Hole */\n\n/** @typedef {unknown} Value */\n/** @typedef {Node | Element | PersistentFragment} Target */\n/** @typedef {null | undefined | string | number | boolean | Node | Element | PersistentFragment} DOMValue */\n/** @typedef {Hole | Node} ArrayValue */\n\nexport const abc = (a, b, c) => ({ a, b, c });\n\nexport const bc = (b, c) => ({ b, c });\n\n/**\n * @typedef {Object} Detail\n * @property {any} v the current value of the interpolation / hole\n * @property {function} u the callback to update the value\n * @property {Node} t the target comment node or element\n * @property {string | null | Node} n the attribute name, if any, or `null`\n * @property {Cache | ArrayValue[] | null} c the cache value for this detail\n */\n\n/**\n * @returns {Detail}\n */\nexport const detail = (u, t, n, c) => ({ v: empty, u, t, n, c });\n\n/**\n * @typedef {Object} Entry\n * @property {number[]} a the path to retrieve the node\n * @property {function} b the update function\n * @property {string | null} c the attribute name, if any, or `null`\n */\n\n/**\n * @typedef {Object} Cache\n * @property {null | TemplateStringsArray} a the cached template\n * @property {null | Node | PersistentFragment} b the node returned when parsing the template\n * @property {Detail[]} c the list of updates to perform\n */\n\n/**\n * @returns {Cache}\n */\nexport const cache = () => abc(null, null, empty);\n","import { PersistentFragment } from './persistent-fragment.js';\nimport { bc, detail } from './literals.js';\nimport { array, hole } from './handler.js';\nimport { empty, find } from './utils.js';\nimport { cache } from './literals.js';\n\n/** @param {(template: TemplateStringsArray, values: any[]) => import(\"./parser.js\").Resolved} parse */\nexport default parse => (\n /**\n * @param {TemplateStringsArray} template\n * @param {any[]} values\n * @returns {import(\"./literals.js\").Cache}\n */\n (template, values) => {\n const { a: fragment, b: entries, c: direct } = parse(template, values);\n const root = document.importNode(fragment, true);\n /** @type {import(\"./literals.js\").Detail[]} */\n let details = empty;\n if (entries !== empty) {\n details = [];\n for (let current, prev, i = 0; i < entries.length; i++) {\n const { a: path, b: update, c: name } = entries[i];\n const node = path === prev ? current : (current = find(root, (prev = path)));\n details[i] = detail(\n update,\n node,\n name,\n update === array ? [] : (update === hole ? cache() : null)\n );\n }\n }\n return bc(\n direct ? root.firstChild : new PersistentFragment(root),\n details,\n );\n }\n);\n","export const TEXT_ELEMENTS = /^(?:plaintext|script|style|textarea|title|xmp)$/i;\nexport const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;\n","import { VOID_ELEMENTS } from 'domconstants/re';\n\nconst elements = /<([a-zA-Z0-9]+[a-zA-Z0-9:._-]*)([^>]*?)(\\/?)>/g;\nconst attributes = /([^\\s\\\\>\"'=]+)\\s*=\\s*(['\"]?)\\x01/g;\nconst holes = /[\\x01\\x02]/g;\n\n// \\x01 Node.ELEMENT_NODE\n// \\x02 Node.ATTRIBUTE_NODE\n\n/**\n * Given a template, find holes as both nodes and attributes and\n * return a string with holes as either comment nodes or named attributes.\n * @param {string[]} template a template literal tag array\n * @param {string} prefix prefix to use per each comment/attribute\n * @param {boolean} xml enforces self-closing tags\n * @returns {string} X/HTML with prefixed comments or attributes\n */\nexport default (template, prefix, xml) => {\n let i = 0;\n return template\n .join('\\x01')\n .trim()\n .replace(\n elements,\n (_, name, attrs, selfClosing) => `<${\n name\n }${\n attrs.replace(attributes, '\\x02=$2$1').trimEnd()\n }${\n selfClosing ? (\n (xml || VOID_ELEMENTS.test(name)) ? ' /' : `></${name}`\n ) : ''\n }>`\n )\n .replace(\n holes,\n hole => hole === '\\x01' ? `<!--${prefix + i++}-->` : (prefix + i++)\n )\n ;\n};\n","import { SVG_NAMESPACE, newRange } from './utils.js';\n\nlet template = document.createElement('template'), svg, range;\n\n/**\n * @param {string} text\n * @param {boolean} xml\n * @returns {DocumentFragment}\n */\nexport default (text, xml) => {\n if (xml) {\n if (!svg) {\n svg = document.createElementNS(SVG_NAMESPACE, 'svg');\n range = newRange();\n range.selectNodeContents(svg);\n }\n return range.createContextualFragment(text);\n }\n template.innerHTML = text;\n const { content } = template;\n template = template.cloneNode(false);\n return content;\n};\n","import { COMMENT_NODE, ELEMENT_NODE } from 'domconstants/constants';\nimport { TEXT_ELEMENTS } from 'domconstants/re';\nimport parser from '@webreflection/uparser';\n\nimport { empty, isArray, set } from './utils.js';\nimport { abc } from './literals.js';\n\nimport { array, attribute, hole, text, removeAttribute } from './handler.js';\nimport createContent from './create-content.js';\n\n/** @typedef {import(\"./literals.js\").Entry} Entry */\n\n/**\n * @typedef {Object} Resolved\n * @param {DocumentFragment} f content retrieved from the template\n * @param {Entry[]} e entries per each hole in the template\n * @param {boolean} d direct node to handle\n */\n\n/**\n * @param {Element} node\n * @returns {number[]}\n */\nconst createPath = node => {\n const path = [];\n let parentNode;\n while ((parentNode = node.parentNode)) {\n path.push(path.indexOf.call(parentNode.childNodes, node));\n node = parentNode;\n }\n return path;\n};\n\nconst textNode = () => document.createTextNode('');\n\n/**\n * @param {TemplateStringsArray} template\n * @param {boolean} xml\n * @returns {Resolved}\n */\nconst resolve = (template, values, xml) => {\n const content = createContent(parser(template, prefix, xml), xml);\n const { length } = template;\n let entries = empty;\n if (length > 1) {\n const replace = [];\n const tw = document.createTreeWalker(content, 1 | 128);\n let i = 0, search = `${prefix}${i++}`;\n entries = [];\n while (i < length) {\n const node = tw.nextNode();\n // these are holes or arrays\n if (node.nodeType === COMMENT_NODE) {\n if (node.data === search) {\n // ⚠️ once array, always array!\n const update = isArray(values[i - 1]) ? array : hole;\n if (update === hole) replace.push(node);\n entries.push(abc(createPath(node), update, null));\n search = `${prefix}${i++}`;\n }\n }\n else {\n let path;\n // these are attributes\n while (node.hasAttribute(search)) {\n if (!path) path = createPath(node);\n const name = node.getAttribute(search);\n entries.push(abc(path, attribute(node, name, xml), name));\n removeAttribute(node, search);\n search = `${prefix}${i++}`;\n }\n // these are special text-only nodes\n if (\n !xml &&\n TEXT_ELEMENTS.test(node.localName) &&\n node.textContent.trim() === `<!--${search}-->`\n ) {\n entries.push(abc(path || createPath(node), text, null));\n search = `${prefix}${i++}`;\n }\n }\n }\n // can't replace holes on the fly or the tree walker fails\n for (i = 0; i < replace.length; i++)\n replace[i].replaceWith(textNode());\n }\n\n // need to decide if there should be a persistent fragment\n const { childNodes } = content;\n let { length: len } = childNodes;\n\n // html`` or svg`` to signal an empty content\n // these nodes can be passed directly as never mutated\n if (len < 1) {\n len = 1;\n content.appendChild(textNode());\n }\n // html`${'b'}` or svg`${[]}` cases\n else if (\n len === 1 &&\n // ignore html`static` or svg`static` because\n // these nodes can be passed directly as never mutated\n length !== 1 &&\n childNodes[0].nodeType !== ELEMENT_NODE\n ) {\n // use a persistent fragment for these cases too\n len = 0;\n }\n\n return set(cache, template, abc(content, entries, len === 1));\n};\n\n/** @type {WeakMap<TemplateStringsArray, Resolved>} */\nconst cache = new WeakMap;\nconst prefix = 'isµ';\n\n/**\n * @param {boolean} xml\n * @returns {(template: TemplateStringsArray, values: any[]) => Resolved}\n */\nexport default xml => (template, values) => cache.get(template) || resolve(template, values, xml);\n","import { array, hole } from './handler.js';\nimport { cache } from './literals.js';\nimport create from './creator.js';\nimport parser from './parser.js';\n\nconst createHTML = create(parser(false));\nconst createSVG = create(parser(true));\n\n/**\n * @param {import(\"./literals.js\").Cache} info\n * @param {Hole} hole\n * @returns {Node}\n */\nconst unroll = (info, { s, t, v }) => {\n if (info.a !== t) {\n const { b, c } = (s ? createSVG : createHTML)(t, v);\n info.a = t;\n info.b = b;\n info.c = c;\n }\n for (let { c } = info, i = 0; i < c.length; i++) {\n const value = v[i];\n const detail = c[i];\n switch (detail.u) {\n case array:\n detail.v = array(\n detail.t,\n unrollValues(detail.c, value),\n detail.v\n );\n break;\n case hole:\n const current = value instanceof Hole ?\n unroll(detail.c || (detail.c = cache()), value) :\n (detail.c = null, value)\n ;\n if (current !== detail.v)\n detail.v = hole(detail, current);\n break;\n default:\n if (value !== detail.v)\n detail.v = detail.u(detail.t, value, detail.n, detail.v);\n break;\n }\n }\n return info.b;\n};\n\n/**\n * @param {Cache} cache\n * @param {any[]} values\n * @returns {number}\n */\nconst unrollValues = (stack, values) => {\n let i = 0, { length } = values;\n if (length < stack.length) stack.splice(length);\n for (; i < length; i++) {\n const value = values[i];\n if (value instanceof Hole)\n values[i] = unroll(stack[i] || (stack[i] = cache()), value);\n else stack[i] = null;\n }\n return values;\n};\n\n/**\n * Holds all details needed to render the content on a render.\n * @constructor\n * @param {boolean} svg The content type.\n * @param {TemplateStringsArray} template The template literals used to the define the content.\n * @param {any[]} values Zero, one, or more interpolated values to render.\n */\nexport class Hole {\n constructor(svg, template, values) {\n this.s = svg;\n this.t = template;\n this.v = values;\n }\n toDOM(info = cache()) {\n return unroll(info, this);\n }\n};\n","/*! (c) Andrea Giammarchi - MIT */\nimport { Hole } from './rabbit.js';\nimport { attr } from './handler.js';\n\nimport render from './render/hole.js';\n\n/** @typedef {import(\"./literals.js\").Value} Value */\n\nconst tag = svg => (template, ...values) => new Hole(svg, template, values);\n\n/** @type {(template: TemplateStringsArray, ...values:Value[]) => Hole} A tag to render HTML content. */\nexport const html = tag(false);\n\n/** @type {(template: TemplateStringsArray, ...values:Value[]) => Hole} A tag to render SVG content. */\nexport const svg = tag(true);\n\nexport { Hole, render, attr };\n","import { Hole } from '../rabbit.js';\nimport { cache } from '../literals.js';\nimport { set } from '../utils.js';\n\n/** @type {WeakMap<Element | DocumentFragment, import(\"../literals.js\").Cache>} */\nconst known = new WeakMap;\n\n/**\n * Render with smart updates within a generic container.\n * @template T\n * @param {T} where the DOM node where to render content\n * @param {(() => Hole) | Hole} what the hole to render\n * @param {boolean} check does a `typeof` check (internal usage).\n * @returns\n */\nexport default (where, what, check) => {\n const info = known.get(where) || set(known, where, cache());\n const { b } = info;\n const hole = (check && typeof what === 'function') ? what() : what;\n const node = hole instanceof Hole ? hole.toDOM(info) : hole;\n if (b !== node)\n where.replaceChildren((info.b = node).valueOf());\n return where;\n};\n","/*! (c) Andrea Giammarchi - MIT */\nimport { Hole } from './rabbit.js';\nimport { attr } from './handler.js';\nimport { cache } from './literals.js';\nimport { set } from './utils.js';\nimport { html, svg } from './index.js';\n\nimport render from './render/keyed.js';\n\n/** @typedef {import(\"./literals.js\").Cache} Cache */\n/** @typedef {import(\"./literals.js\").Target} Target */\n/** @typedef {import(\"./literals.js\").Value} Value */\n\n/** @typedef {(ref:Object, key:string | number) => Tag} Bound */\n\n/**\n * @callback Tag\n * @param {TemplateStringsArray} template\n * @param {...Value} values\n * @returns {Target}\n */\n\nconst keyed = new WeakMap;\nconst createRef = svg => /** @type {Bound} */ (ref, key) => {\n /** @type {Tag} */\n function tag(template, ...values) {\n return new Hole(svg, template, values).toDOM(this);\n }\n\n const memo = keyed.get(ref) || set(keyed, ref, new Map);\n return memo.get(key) || set(memo, key, tag.bind(cache()));\n};\n\n/** @type {Bound} Returns a bound tag to render HTML content. */\nexport const htmlFor = createRef(false);\n\n/** @type {Bound} Returns a bound tag to render SVG content. */\nexport const svgFor = createRef(true);\n\nexport { Hole, render, html, svg, attr };\n","// (c) Andrea Giammarchi - ISC\n\nconst registry = new FinalizationRegistry(\n ([onGarbageCollected, held, debug]) => {\n // \"%cThis is a green text\", \"color:green\"\n if (debug) console.debug(`%c${String(held)}`, 'font-weight:bold', 'collected');\n onGarbageCollected(held);\n }\n);\n\nconst nullHandler = Object.create(null);\n\n/**\n * @template {unknown} H\n * @typedef {Object} GCHookOptions\n * @prop {boolean} [debug=false] if `true`, logs values once these can get collected.\n * @prop {ProxyHandler<object>} [handler] optional proxy handler to use instead of the default one.\n * @prop {H} [return=H] if specified, overrides the returned proxy with its value.\n * @prop {unknown} [token=H] it's the held value by default, but it can be any other token except the returned value itself.\n */\n\n/**\n * @template {unknown} H\n * @param {H} hold the reference to hold behind the scene and passed along the callback once it triggers.\n * @param {(held:H) => void} onGarbageCollected the callback that will receive the held value once its wrapper or indirect reference is no longer needed.\n * @param {GCHookOptions<H>} [options] an optional configuration object to change some default behavior.\n */\nexport const create = (\n hold,\n onGarbageCollected,\n { debug, handler, return: r, token = hold } = nullHandler\n) => {\n // if no reference to return is defined,\n // create a proxy for the held one and register that instead.\n /** @type {H} */\n const target = r || new Proxy(hold, handler || nullHandler);\n const args = [target, [onGarbageCollected, hold, !!debug]];\n if (token !== false) args.push(token);\n // register the target reference in a way that\n // the `onGarbageCollected(held)` callback will eventually notify.\n registry.register(...args);\n return target;\n};\n\n/**\n * If previously registered as either `token` or `hold` value, allow explicit removal of the entry in the registry.\n * @param {unknown} token the token used during registration. If no `token` was passed, this can be the same `hold` reference.\n * @returns {boolean} `true` if successfully unregistered.\n */\nexport const drop = token => registry.unregister(token);\n","import { create, drop } from 'gc-hook';\n\nimport render from './shared.js';\n\n/** @typedef {import(\"../rabbit.js\").Hole} Hole */\n\n/** @type {WeakMap<Element | DocumentFragment, Function>} */\nconst effects = new WeakMap;\n\n/**\n * @param {Function} dispose\n * @returns {void}\n */\nconst onGC = dispose => dispose();\n\nlet remove = true;\n\n/**\n * @param {Function} effect the reactive `effect` callback provided by a 3rd party library.\n * @returns \n */\nexport const attach = effect => {\n /**\n * Render with smart updates within a generic container.\n * If the `what` is a function, it automatically create\n * an effect for the render function.\n * @template T\n * @param {T} where the DOM node where to render content\n * @param {(() => Hole) | Hole} what the hole to render\n * @returns {T}\n */\n return (where, what) => {\n remove = typeof what !== 'function';\n detach(where);\n\n if (remove) return render(where, what, false);\n remove = true;\n\n const wr = new WeakRef(where);\n const dispose = effect(() => { render(wr.deref(), what(), false) });\n effects.set(where, dispose);\n return create(dispose, onGC, { return: where });\n };\n};\n\n/**\n * Allow manual cleanup of subscribed signals.\n * @param {Element} where a reference container previously used to render signals.\n */\nexport const detach = where => {\n const dispose = effects.get(where);\n if (dispose) {\n if (remove) effects.delete(where);\n drop(dispose);\n dispose();\n }\n};\n","import { effect } from 'mi-signal';\n\nexport { Computed, default as Signal, State, createSignal, effect } from 'mi-signal';\n\nimport { attach } from 'uhtml/reactive';\n\nexport * from 'uhtml/reactive';\n\nconst render = attach(effect);\n\nexport { render };\n"],"names":["context","State","EventTarget","value","equals","constructor","options","super","this","nextValue","get","set","running","length","add","dispatchEvent","CustomEvent","createSignal","initialValue","effect","cb","Set","push","pop","dep","addEventListener","removeEventListener","Computed","state","unsubscribe","index","CONTEXT_REQUEST","ContextProvider","host","addController","hostConnected","onContextRequest","hostDisconnected","newValue","ev","stopPropagation","subscribe","callback","ContextRequestEvent","Event","bubbles","composed","ContextConsumer","validate","undefined","dispatchRequest","_callback","bind","requestUpdate","camelToKebabCase","str","replace","_","m","toLowerCase","kebabToCamelCase","toUpperCase","MiElement","HTMLElement","attr","attrLc","Map","types","disposers","controllers","changedAttr","dedupe","static","mode","attributes","properties","observedAttributes","observedProperties","observe","name","Object","defineProperty","enumerable","oldValue","entries","initial","initialValueType","type","has","getName","getType","connectedCallback","forEach","controller","shadowRootOptions","template","renderRoot","shadowRoot","attachShadow","addTemplate","render","disconnectedCallback","remover","attributeChangedCallback","convertType","removeAttribute","setAttribute","includes","shouldUpdate","_changedAttributes","isConnected","requestAnimationFrame","update","HTMLTemplateElement","Error","append","content","cloneNode","on","eventName","listener","node","once","dispose","listeners","TypeError","removeController","delete","define","element","keys","map","renderTemplate","window","customElements","el","document","createElement","innerHTML","Boolean","Number","String","toString","call","slice","any","n","isNaN","toNumber","UnsafeHtml","unsafeHtml","escMap","escHtml","string","tag","esc","strings","vars","raw","refsById","container","nodes","querySelectorAll","found","getAttribute","nodeName","refsBySelector","selectors","selector","querySelector","Store","actions","action","dispatcher","data","classMap","acc","join","styleMap","unit","_unit","isFinite","globalSheets","addGlobalStyles","adoptedStyleSheets","Array","from","styleSheets","cssRules","sheet","CSSStyleSheet","css","rule","cssText","replaceSync","isArray","getPrototypeOf","getOwnPropertyDescriptor","empty","newRange","createRange","key","find","path","reduceRight","childNodesIndex","i","childNodes","setPrototypeOf","range","drop$1","firstChild","lastChild","preserve","setStartAfter","setStartBefore","setEndAfter","deleteContents","remove","drop","checkType","diffFragment","operation","nodeType","valueOf","comment","createComment","PersistentFragment","Class","Custom","target","prototype","custom","DocumentFragment","fragment","replaceChildren","parentNode","replaceWith","nextSibling","at","WeakMap","known","current","hole","detail","t","nullish","direct","ref","dot","maybeDirect","regular","toggle","toggleAttribute","array","prev","a","b","before","bLength","aEnd","bEnd","aStart","bStart","insertBefore","removeChild","sequence","replaceChild","udomdiff","$","dataset","style","attribute","svg","startsWith","prop","desc","gPD","text","textContent","abc","c","u","v","cache","create$1","parse","values","root","importNode","details","TEXT_ELEMENTS","VOID_ELEMENTS","elements","holes","createContent","xml","createElementNS","selectNodeContents","createContextualFragment","createPath","indexOf","textNode","createTextNode","prefix","parser","trim","attrs","selfClosing","trimEnd","test","tw","createTreeWalker","search","nextNode","hasAttribute","localName","len","appendChild","resolve","createHTML","create","createSVG","unroll","info","s","unrollValues","Hole","stack","splice","toDOM","html","render$1","where","what","check","keyed","createRef","memo","htmlFor","svgFor","registry","FinalizationRegistry","onGarbageCollected","held","debug","nullHandler","effects","onGC","attach","detach","wr","WeakRef","deref","hold","handler","return","r","token","Proxy","args","register","unregister"],"mappings":"AAAA,MAAMA,EAAU,GAEhB,MAAMC,UAAcC,YAClBC,GACAC,GACA,WAAAC,CAAYF,EAAOG,GACjBC,QACA,MAAOH,OAAQA,GAAUE,GAAW,CAAA,EACpCE,MAAKL,EAASA,EAAOK,MAAKJ,EAAUA,GAAM,EAAMD,EAAOM,IAAcN,IAAUM,EACjF,CACA,SAAIN,GACF,OAAOK,KAAKE,KACd,CACA,SAAIP,CAAMM,GACRD,KAAKG,IAAIF,EACX,CACA,GAAAC,GACE,MAAME,EAAUZ,EAAQA,EAAQa,OAAS,GACzC,OAAOD,GAAWA,EAAQE,IAAIN,MAAOA,MAAKL,CAC5C,CACA,GAAAQ,CAAIF,GACFD,MAAKJ,EAAQI,MAAKL,EAAQM,KAAeD,MAAKL,EAASM,EAAWD,KAAKO,cAAc,IAAIC,YAAY,WACvG,EAGG,MAACC,EAAe,CAACC,EAAcZ,IAAYY,aAAwBjB,EAAQiB,EAAe,IAAIjB,EAAMiB,EAAcZ,GAEvH,SAASa,EAAOC,GACd,MAAMR,EAAU,IAAIS,IACpBrB,EAAQsB,KAAKV,GACb,IACEQ,GACF,CAAC,QACCpB,EAAQuB,KACV,CACA,IAAK,MAAMC,KAAOZ,EAASY,EAAIC,iBAAiB,SAAUL,GAC1D,MAAO,KACL,IAAK,MAAMI,KAAOZ,EAASY,EAAIE,oBAAoB,SAAUN,GAEjE,CAEA,MAAMO,EACJC,GACAC,GACA,WAAAxB,CAAYe,GACVZ,MAAKoB,EAAS,IAAI3B,EAAOO,MAAKqB,EAAeV,EAAO,IAAMX,MAAKoB,EAAOjB,IAAIS,KAC5E,CACA,G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U,GDDVyB,MCEd3O,IACE+F,IAAQiI,GAAQ5N,OAAO8M,GDHXyB,ECIX3O,EDJoB0N,GAASqB,WAAWJ,GCK7C3O,MC9CEvB,GAASyP,GAAO1U","x_google_ignoreList":[8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}
1
+ {"version":3,"file":"index.min.js","sources":["../../mi-signal/dist/index.js","../src/context.js","../src/case.js","../src/element.js","../src/escape.js","../src/refs.js","../src/store.js","../src/styling.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/utils.js","../../../node_modules/.pnpm/custom-function@2.0.0/node_modules/custom-function/esm/factory.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/range.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/persistent-fragment.js","../../../node_modules/.pnpm/domconstants@1.1.6/node_modules/domconstants/esm/constants.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/handler.js","../../../node_modules/.pnpm/udomdiff@1.1.2/node_modules/udomdiff/esm/index.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/literals.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/creator.js","../../../node_modules/.pnpm/domconstants@1.1.6/node_modules/domconstants/esm/re.js","../../../node_modules/.pnpm/@webreflection+uparser@0.4.0/node_modules/@webreflection/uparser/esm/index.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/create-content.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/parser.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/rabbit.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/index.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/render/shared.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/keyed.js","../../../node_modules/.pnpm/gc-hook@0.4.1/node_modules/gc-hook/esm/index.js","../../../node_modules/.pnpm/uhtml@4.7.1/node_modules/uhtml/esm/render/reactive.js","../../mi-html/dist/index.js"],"sourcesContent":["const context = [];\n\nclass State extends EventTarget {\n #value;\n #equals;\n constructor(value, options) {\n super();\n const {equals: equals} = options || {};\n this.#value = value, this.#equals = equals ?? ((value, nextValue) => value === nextValue);\n }\n get value() {\n return this.get();\n }\n set value(nextValue) {\n this.set(nextValue);\n }\n get() {\n const running = context[context.length - 1];\n return running && running.add(this), this.#value;\n }\n set(nextValue) {\n this.#equals(this.#value, nextValue) || (this.#value = nextValue, this.dispatchEvent(new CustomEvent('signal')));\n }\n}\n\nconst createSignal = (initialValue, options) => initialValue instanceof State ? initialValue : new State(initialValue, options);\n\nfunction effect(cb) {\n const running = new Set;\n context.push(running);\n try {\n cb();\n } finally {\n context.pop();\n }\n for (const dep of running) dep.addEventListener('signal', cb);\n return () => {\n for (const dep of running) dep.removeEventListener('signal', cb);\n };\n}\n\nclass Computed {\n #state;\n #unsubscribe;\n constructor(cb) {\n this.#state = new State, this.#unsubscribe = effect(() => this.#state.set(cb()));\n }\n get() {\n return this.#state.get();\n }\n unsubscribe() {\n this.#unsubscribe();\n }\n}\n\nvar index = {\n State: State,\n Computed: Computed,\n createSignal: createSignal,\n effect: effect\n};\n\nexport { Computed, State, createSignal, index as default, effect };\n","/**\n * @see https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md\n */\n\nimport { createSignal, effect } from 'mi-signal'\n\n/**\n * @typedef {import('./element.js').HostController} HostController\n */\n/**\n * @typedef {string|Symbol} Context\n */\n\nconst CONTEXT_REQUEST = 'context-request'\n\n/**\n * @template T\n * @implements {HostController}\n */\nexport class ContextProvider {\n /**\n * @param {HTMLElement} host\n * @param {Context} context\n * @param {T|null} [initialValue]\n */\n constructor(host, context, initialValue) {\n this.host = host\n this.context = context\n this.state = createSignal(initialValue)\n // @ts-expect-error\n this.host.addController?.(this)\n }\n\n hostConnected() {\n // @ts-expect-error\n this.host.addEventListener(CONTEXT_REQUEST, this.onContextRequest)\n }\n\n hostDisconnected() {\n // @ts-expect-error\n this.host.removeEventListener(CONTEXT_REQUEST, this.onContextRequest)\n }\n\n /**\n * @param {T|null|undefined} newValue\n */\n set(newValue) {\n this.state.set(newValue)\n }\n\n /**\n * @returns {T|null|undefined}\n */\n get() {\n return this.state.get()\n }\n\n /**\n * @private\n * @param {ContextRequestEvent} ev\n */\n onContextRequest = (ev) => {\n if (ev.context !== this.context) {\n // event has wrong context\n return\n }\n ev.stopPropagation()\n let unsubscribe\n if (ev.subscribe) {\n unsubscribe = effect(() => {\n // needed to subscribe to signal\n const value = this.get()\n // don't call callback the first time where unsubscribe is not defined\n if (unsubscribe) ev.callback(value, unsubscribe)\n })\n }\n ev.callback(this.get(), unsubscribe)\n }\n}\n\n/**\n * @template T\n */\nexport class ContextRequestEvent extends Event {\n /**\n * @param {Context} context\n * @param {(value: T|null|undefined, unsubscribe?: () => void) => void} callback\n * @param {boolean} [subscribe=false] subscribe to value changes\n */\n constructor(context, callback, subscribe) {\n super(CONTEXT_REQUEST, { bubbles: true, composed: true })\n this.context = context\n this.callback = callback\n this.subscribe = subscribe\n }\n}\n\n/**\n * @template T\n * @implements {HostController}\n */\nexport class ContextConsumer {\n /**\n * @type {T|null|undefined}\n */\n #value\n\n /**\n * @param {HTMLElement} host\n * @param {Context} context\n * @param {object} [options]\n * @param {boolean} [options.subscribe=false] subscribe to value changes\n * @param {(any) => boolean} [options.validate] validation function\n */\n constructor(host, context, options) {\n const { subscribe = false, validate = () => true } = options || {}\n this.host = host\n this.context = context\n this.subscribe = !!subscribe\n this.validate = validate\n // unsubscribe function\n this.unsubscribe = undefined\n // add the controller in case of a MiElement otherwise call hostConnected()\n // and hostDisconnected() from the host element\n // @ts-expect-error\n this.host.addController?.(this)\n }\n\n /**\n * @returns {T|null|undefined}\n */\n get() {\n return this.#value\n }\n\n /**\n * @returns {T|null|undefined}\n */\n get value() {\n return this.#value\n }\n\n hostConnected() {\n this.dispatchRequest()\n }\n\n hostDisconnected() {\n if (this.unsubscribe) {\n this.unsubscribe()\n this.unsubscribe = undefined\n }\n }\n\n dispatchRequest() {\n this.host.dispatchEvent(\n new ContextRequestEvent(\n this.context,\n this._callback.bind(this),\n this.subscribe\n )\n )\n }\n\n _callback(value, unsubscribe) {\n if (unsubscribe) {\n if (!this.subscribe) {\n // unsubscribe as we didn't ask for subscription\n unsubscribe()\n } else if (this.unsubscribe) {\n if (this.unsubscribe !== unsubscribe) {\n // looks there was a previous provider\n this.unsubscribe()\n }\n this.unsubscribe = unsubscribe\n }\n }\n if (!this.validate(value)) {\n return\n }\n this.#value = value\n // @ts-expect-error\n this.host.requestUpdate()\n }\n}\n","/**\n * convert lowerCamelCase to kebab-case\n * @param {string} str\n * @returns {string}\n */\nexport const camelToKebabCase = (str = '') =>\n str.replace(/([A-Z])/g, (_, m) => `-${m.toLowerCase()}`)\n\n/**\n * convert kebab-case to lowerCamelCase\n * @param {string} str\n * @returns {string}\n */\nexport const kebabToCamelCase = (str = '') =>\n str.toLowerCase().replace(/[-_]\\w/g, (m) => m[1].toUpperCase())\n","import { camelToKebabCase } from './case.js'\nimport { createSignal } from 'mi-signal'\n\n/**\n * @typedef {object} HostController controller\n * @property {() => void} hostConnected is called when host element is added to\n * the DOM, usually with connectedCallback()\n * @property {() => void} hostDisconnected is called when host element is\n * removed from the DOM, usually with disconnectedCallback()\n */\n\n/**\n * class extending HTMLElement to enable deferred rendering on attribute changes\n * either via `setAttribute(name, value)` or `this[name] = value`.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement\n * @example\n * ```js\n * class Example extends MiElement {\n * // define all observed attributes with its default initial value.\n * // for yet to defined numbers, boolean or strings use `Number`, `Boolean`, `String`\n * // attributes are accessible via `this[prop]`\n * // avoid using attributes which are HTMLElement properties e.g. className\n * static get attributes () {\n * return { text: 'Hi', num: Number }\n * }\n * render() {\n * this.renderRoot.innerHTML = `<div></div>`\n * this.refs = {\n * div: this.renderRoot.querySelector('div')\n * }\n * }\n * // render method called every time an attribute changes\n * update() {\n * this.refs.div.textContent = this.text\n * }\n * }\n * // create a custom element with the `define` function (see below)\n * define('x-example', Example)\n * // create a DOM node and re-render via attribute or property changes\n * const elem = document.createElement('x-example')\n * elem.setAttribute('text', 'set attribute')\n * // or if change is triggered by property\n * elem.text = 'set property'\n * ```\n */\nexport class MiElement extends HTMLElement {\n /** all attributes are signals! */\n #attr = {}\n /**\n * lower-cased or kebab-case attribute names;\n * Map<lower-cased and kebab-cased attr name, camelCased attr name as string>\n * @type {Map<string, string>}\n */\n #attrLc = new Map()\n /**\n * initial types (from `static get attributes() { return {} }`)\n * Map<camelCased attribute name, type as string>\n * @type {Map<string,string>}\n */\n #types = new Map()\n #disposers = new Set()\n #controllers = new Set()\n #changedAttr = {}\n #dedupe = false\n\n /**\n * Default options used when calling `attachShadow`. Used in\n * `connectedCallback()`.\n * If override is `null`, no shadow-root will be attached.\n * @type {{mode: string}|null}\n */\n static shadowRootOptions = { mode: 'open' }\n\n /**\n * defines template for render().\n * @type {String|HTMLTemplateElement}\n */\n static template\n\n /**\n * observable attributes\n * @returns {Record<PropertyKey, unknown>|{}}\n */\n static get attributes() {\n return {}\n }\n /**\n * observable properties\n * @returns {Record<PropertyKey, unknown>|{}}\n */\n static get properties() {\n return {}\n }\n\n constructor() {\n super()\n // @ts-expect-error\n this.#observedAttributes(this.constructor.attributes)\n // @ts-expect-error\n this.#observedProperties(this.constructor.properties)\n }\n\n #observe(name, initialValue) {\n this.#attr[name] = createSignal(initialValue)\n Object.defineProperty(this, name, {\n enumerable: true,\n get() {\n return this.#attr[name].get()\n },\n set(newValue) {\n const oldValue = this.#attr[name].get()\n if (oldValue === newValue) return\n this.#attr[name].set(newValue)\n this.#changedAttr[name] = oldValue\n this.requestUpdate()\n }\n })\n }\n\n /**\n * requests update on component when property changes\n * @param {Record<string, any>} [attributes]\n */\n #observedAttributes(attributes = {}) {\n for (const [name, value] of Object.entries(attributes)) {\n const initial = initialValueType(value)\n this.#types.set(name, initial.type)\n this.#attrLc.set(name.toLowerCase(), name)\n this.#attrLc.set(camelToKebabCase(name), name)\n this.#observe(name, initial.value)\n }\n }\n\n /**\n * define (direct) properties\n * @param {Record<string, any>} [properties]\n */\n #observedProperties(properties = {}) {\n for (const [name, value] of Object.entries(properties)) {\n if (this.#attrLc.has(name) || name in this.#attr) {\n continue\n }\n this.#observe(name, value)\n }\n }\n\n /**\n * return camelCased value instead of possible lowercased\n * @param {string} name\n * @returns\n */\n #getName(name) {\n return this.#attrLc.get(name) || name\n }\n\n #getType(name) {\n return this.#types.get(name)\n }\n\n /**\n * creates the element's renderRoot, sets up styling\n * @category lifecycle\n */\n connectedCallback() {\n this.#controllers.forEach((controller) => controller.hostConnected?.())\n // create render root\n // @ts-expect-error\n const { shadowRootOptions, template } = this.constructor\n this.renderRoot = shadowRootOptions\n ? (this.shadowRoot ?? this.attachShadow(shadowRootOptions))\n : this\n this.addTemplate(template)\n // trigger initial rendering such that children can be added via JS\n this.render()\n // and update\n this.requestUpdate()\n }\n\n /**\n * unsubscribe from all events and disconnect controllers\n */\n disconnectedCallback() {\n // unsubscribe from all subscriptions\n this.#disposers.forEach((remover) => remover())\n // disconnect all controllers\n this.#controllers.forEach((controller) => controller.hostDisconnected?.())\n }\n\n /**\n * @param {string} name change attribute\n * @param {any} oldValue\n * @param {any} newValue new value\n */\n attributeChangedCallback(name, oldValue, newValue) {\n const attr = this.#getName(name)\n const type = this.#getType(attr)\n this.#changedAttr[attr] = this[attr]\n this[attr] = convertType(newValue, type)\n // correct initial setting of `trueish=\"false\"` otherwise there's no chance\n // to overwrite a trueish value. The case `falsish=\"true\"` is covered.\n if (type === 'Boolean' && newValue === 'false') {\n this.removeAttribute(name)\n }\n this.requestUpdate()\n }\n\n /**\n * Set string and number attributes on element only. Set all other values as\n * properties to avoid type conversion to and from string\n * @param {string} name\n * @param {any} newValue\n */\n setAttribute(name, newValue) {\n const attr = this.#getName(name)\n // only allow to change observedAttributes\n if (!(attr in this.#attr)) {\n return\n }\n const type = this.#getType(attr)\n\n // only set string values in these cases\n if (type === 'Boolean') {\n if (newValue === true || newValue === '') {\n super.setAttribute(name, '')\n } else {\n super.removeAttribute(name)\n }\n } else if (['String', 'Number'].includes(type ?? '') || newValue === true) {\n super.setAttribute(name, newValue)\n } else {\n this.#changedAttr[attr] = this[attr]\n this[attr] = newValue\n this.requestUpdate()\n }\n }\n\n /**\n * controls if component shall be updated\n * @param {Record<string,any>} [_changedAttributes] previous values of changed attributes\n * @returns {boolean}\n */\n shouldUpdate(_changedAttributes) {\n return true\n }\n\n /**\n * request rendering\n */\n requestUpdate() {\n if (this.#dedupe || !this.isConnected) return\n this.#dedupe = true\n requestAnimationFrame(() => {\n this.#dedupe = false\n // reset changed attributes\n const _changedAttributes = this.#changedAttr\n this.#changedAttr = {}\n if (this.shouldUpdate(_changedAttributes)) {\n this.update(_changedAttributes)\n }\n })\n }\n\n /**\n * adds a template to renderRoot\n * @param {HTMLTemplateElement} template\n */\n addTemplate(template) {\n if (!(template instanceof HTMLTemplateElement)) {\n throw new Error('template is not a HTMLTemplateElement')\n }\n this.renderRoot.append(template.content.cloneNode(true))\n }\n\n /**\n * initial rendering\n */\n render() {}\n\n /**\n * called every time the components needs a render update\n * @param {Record<string,any>} [_changedAttributes] previous values of changed\n * attributes\n */\n update(_changedAttributes) {}\n\n /**\n * Adds listener function for eventName. listener is removed before component\n * disconnects\n * @param {string} eventName\n * @param {EventListenerOrEventListenerObject} listener\n * @param {Node|Document|Window} [node=this]\n */\n on(eventName, listener, node = this) {\n node.addEventListener(eventName, listener)\n this.#disposers.add(() => node.removeEventListener(eventName, listener))\n }\n\n /**\n * Adds one-time listener function for eventName. The next time eventName is\n * triggered, this listener is removed and then invoked.\n * @param {string} eventName\n * @param {EventListenerOrEventListenerObject} listener\n * @param {Node|Document|Window} node\n */\n once(eventName, listener, node = this) {\n node.addEventListener(eventName, listener, { once: true })\n }\n\n /**\n * Unsubscribe a listener function for disposal on disconnectedCallback()\n * @param {...function} listeners\n */\n dispose(...listeners) {\n for (const listener of listeners) {\n if (typeof listener !== 'function') {\n throw new TypeError('listener must be a function')\n }\n this.#disposers.add(listener)\n }\n }\n\n /**\n * adds a connected controller\n * @param {HostController} controller\n */\n addController(controller) {\n this.#controllers.add(controller)\n if (this.isConnected) {\n // if already connected call hostConnected() immediately\n /* istanbul ignore next */\n controller.hostConnected?.()\n }\n }\n\n /**\n * removes a connected controller\n * @param {HostController} controller\n */\n /* istanbul ignore next 3 */\n removeController(controller) {\n this.#controllers.delete(controller)\n }\n}\n\n/**\n * defines a custom element adding observedAttributes from default static\n * attributes\n * NOTE: camelCased attributes get lowercased!\n * ```html\n * <custom-element myAttr=\"1\">\n * <!-- is equal to -->\n * <custom-element myattr=\"1\">\n * ```\n * @param {string} name custom element tag\n * @param {typeof MiElement} element\n * @param {object} [options]\n */\nexport const define = (name, element, options) => {\n // @ts-expect-error\n element.observedAttributes = // @ts-expect-error\n (element.observedAttributes || Object.keys(element.attributes || [])).map(\n (attr) => attr.toLowerCase()\n )\n renderTemplate(element)\n window.customElements.define(name, element, options)\n}\n\n// --- utils\n\n/**\n * convert (and cache) the static template to HTMLTemplateElement\n * @param {typeof MiElement} element\n */\nconst renderTemplate = (element) => {\n if (element.template instanceof HTMLTemplateElement) {\n return\n }\n const el = document.createElement('template')\n el.innerHTML = element.template\n element.template = el\n}\n\nconst initialValueType = (value) => {\n switch (value) {\n case Boolean:\n return { value: undefined, type: 'Boolean' }\n case Number:\n return { value: undefined, type: 'Number' }\n case String:\n return { value: undefined, type: 'String' }\n default:\n return { value, type: toString.call(value).slice(8, -1) }\n }\n}\n\nconst toNumber = (any) => {\n const n = Number(any)\n return isNaN(n) ? any : n\n}\n\nexport const convertType = (any, type) => {\n // setAttribute prevents passing Object or Array type. no further conversion required\n switch (type) {\n case 'Number':\n return toNumber(any)\n case 'Boolean':\n // boolean values are set via setAttribute as empty string\n if (any === 'false') {\n return false\n }\n return any === '' || !!any\n }\n return any\n}\n","class UnsafeHtml extends String {}\n\n/**\n * tag a string as html for not to be escaped\n * @param {string} str\n * @returns {string}\n */\n// @ts-expect-error\nexport const unsafeHtml = (str) => new UnsafeHtml(str)\n\nconst escMap = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n \"'\": '&#39;',\n '\"': '&quot;'\n}\n\n/**\n * escape HTML and prevent double escaping of '&'\n * @param {string} string - which requires escaping\n * @returns {string} escaped string\n * @example\n * escapeHTML('<h1>\"One\" & 'Two' &amp; Works</h1>')\n * //> &lt;h1&gt;&quot;One&quot; &amp; &#39;Two&#39; &amp; Works&lt;/h1&gt;\n */\nexport const escHtml = (string) =>\n // @ts-expect-error\n string instanceof UnsafeHtml\n ? string\n : ('' + string)\n .replace(/&amp;/g, '&')\n .replace(/[&<>'\"]/g, (tag) => escMap[tag])\n\n/**\n * template literal to HTML escape all values preventing XSS\n * @param {string[]} strings\n * @param {...any} vars\n * @returns {string}\n */\nexport const esc = (strings, ...vars) =>\n unsafeHtml(String.raw({ raw: strings }, ...vars.map(escHtml)))\n","import { kebabToCamelCase } from './case.js'\n\n/**\n * Helper function to find `id` attributes in `container`s node tree.\n * id names are camelCased, e.g. 'list-container' becomes 'listContainer'\n * @param {Element} container root element\n * @returns {Record<string, Node>|{}} record of found references\n * @example\n * el.innerHTML = `<p id>unnamed <span id=\"named\">and named</span> reference</p>`\n * references = refs(el)\n * //> references = { p: <p>, named: <span> }\n */\nexport function refsById(container) {\n const nodes = container.querySelectorAll?.('[id]') || []\n const found = {}\n for (const node of nodes) {\n const name = kebabToCamelCase(\n node.getAttribute('id') || node.nodeName.toLowerCase()\n )\n found[name] = node\n }\n return found\n}\n\n/**\n * Helper function to gather references by a map of selectors\n * @param {Element} container root element\n * @param {Record<string, string>} selectors\n * @returns {Record<string, Node>|{}}\n * @example\n * el.innerHTML = `<p>some <span>and other</span> reference</p>`\n * references = refs(el, { p: 'p', named: 'p > span' })\n * //> references = { p: <p>, named: <span> }\n */\nexport function refsBySelector(container, selectors) {\n const found = {}\n for (const [name, selector] of Object.entries(selectors)) {\n found[name] = container.querySelector?.(selector)\n }\n return found\n}\n","import { State } from 'mi-signal'\n\n/**\n * @typedef {import('./element.js').MiElement} MiElement\n */\n/**\n * @typedef {(state: any, data?: any) => any} Action\n */\n/**\n * @template T\n * @typedef {import('mi-signal').SignalOptions<T>} SignalOptions<T>\n */\n\n/**\n * Store implementing [Flux](https://www.npmjs.com/package/flux) pattern based\n * on Signals\n * @template T\n */\nexport class Store extends State {\n /**\n * @param {Record<string, Action>} actions\n * @param {T|null} [initialValue]\n * @param {SignalOptions<T>} [options]\n * @example\n * ```js\n * import { Signal, Store } from 'mi-element'\n * const actions = { increment: (by = 1) => (current) => current + by }\n * const initialValue = 1\n * const store = new Store(actions, initialValue)\n * // subscribe with a callback function\n * const unsubscribe = Signal.effect(() => console.log(`count is ${store.get()}`))\n * // change the store\n * store.increment(2) // increment by 2\n * //> count is 3\n * unsubscribe()\n * ```\n *\n * if `initialValue` is an object, the object's reference must be changed\n * using the spread operator, in order to notify on state changes, e.g.\n * ```js\n * const initialValue = { count: 0, other: 'foo' }\n * const actions = {\n * increment: (by = 1) => (state) => ({...state, count: state.count + by})\n * }\n * ```\n * or you change the signals options equality function\n * ```js\n * const actions = {\n * increment: (by = 1) => (state) => {\n * state.count += by\n * return state\n * }\n * }\n * const initialValue = { count: 0, other: 'foo' }\n * const options = { equals: (value, nextValue) => true }\n * const store = new Store(actions, initialValue, options)\n * ```\n */\n constructor(actions, initialValue, options) {\n super(initialValue, options)\n for (const [action, dispatcher] of Object.entries(actions)) {\n if (process.env.NODE_ENV !== 'production') {\n if (this[action]) {\n throw new Error(`action \"${action}\" is already defined`)\n }\n if (\n typeof dispatcher !== 'function' ||\n typeof dispatcher(undefined) !== 'function'\n ) {\n throw new Error(\n `action \"${action}\" must be a function of type \\`() => (state) => state\\``\n )\n }\n }\n this[action] = (data) => this.set(dispatcher(data)(this.get()))\n }\n }\n}\n","import { camelToKebabCase } from './case.js'\n\n/**\n * Construct className based on true-ish values of map\n * @param {{[name: string]: string | boolean | number}} map\n * @returns {string}\n */\nexport const classMap = (map) => {\n /** @type {string[]} */\n const acc = []\n for (const [name, value] of Object.entries(map ?? {})) {\n if (value) acc.push(name)\n }\n return acc.join(' ')\n}\n\n/**\n * Construct style from camelCased map.\n * @param {{[name: string]: string | number | undefined | null}} map\n * @param {object} [options]\n * @param {string} [options.unit] cssUnit for number values; default='px'\n * @returns {string}\n */\nexport const styleMap = (map, options) => {\n const { unit = 'px' } = options || {}\n const acc = []\n for (const [name, value] of Object.entries(map ?? {})) {\n if (value === null || value === undefined) continue\n const _unit = Number.isFinite(value) ? unit : ''\n acc.push(`${camelToKebabCase(name)}:${value}${_unit}`)\n }\n return acc.join(';')\n}\n\n// ----\n\nlet globalSheets = null\n/**\n * obtain and cache global stylesheets\n * @returns {CSSStyleSheet[]}\n */\nfunction getGlobalStyleSheets() {\n if (globalSheets === null) {\n globalSheets = Array.from(document.styleSheets).map(({ cssRules }) => {\n const sheet = new CSSStyleSheet()\n const css = Array.from(cssRules)\n .map((rule) => rule.cssText)\n .join(' ')\n sheet.replaceSync(css)\n return sheet\n })\n }\n return globalSheets\n}\n\n/**\n * apply global style sheets to shadowRoot\n * @param {ShadowRoot} renderRoot\n * @example\n * class MyComponent extends MiElement {\n * render() {\n * addGlobalStyles(this.renderRoot)\n * }\n * }\n */\nexport function addGlobalStyles(renderRoot) {\n renderRoot.adoptedStyleSheets.push(...getGlobalStyleSheets())\n}\n\n/**\n * Helper literal to show css styles in JS e.g. with\n * https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html\n */\nexport const css = (strings, ...values) =>\n String.raw({ raw: strings }, ...values)\n","const { isArray } = Array;\nconst { getPrototypeOf, getOwnPropertyDescriptor } = Object;\n\nexport { isArray };\n\nexport const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n\nexport const empty = [];\n\nexport const newRange = () => document.createRange();\n\n/**\n * Set the `key` `value` pair to the *Map* or *WeakMap* and returns the `value`\n * @template T\n * @param {Map | WeakMap} map\n * @param {any} key\n * @param {T} value\n * @returns {T}\n */\nexport const set = (map, key, value) => {\n map.set(key, value);\n return value;\n};\n\n/**\n * Return a descriptor, if any, for the referenced *Element*\n * @param {Element} ref\n * @param {string} prop\n * @returns \n */\nexport const gPD = (ref, prop) => {\n let desc;\n do { desc = getOwnPropertyDescriptor(ref, prop); }\n while(!desc && (ref = getPrototypeOf(ref)));\n return desc;\n};\n\n/* c8 ignore start */\n/**\n * @param {DocumentFragment} content\n * @param {number[]} path\n * @returns {Element}\n */\nexport const find = (content, path) => path.reduceRight(childNodesIndex, content);\nconst childNodesIndex = (node, i) => node.childNodes[i];\n/* c8 ignore stop */\n","const {setPrototypeOf} = Object;\n\n/**\n * @param {Function} Class any base class to extend without passing through it via super() call.\n * @returns {Function} an extensible class for the passed one.\n * @example\n * // creating this very same module utility\n * import custom from 'custom-function/factory';\n * const CustomFunction = custom(Function);\n * class MyFunction extends CustomFunction {}\n * const mf = new MyFunction(() => {});\n */\nexport default Class => {\n function Custom(target) {\n return setPrototypeOf(target, new.target.prototype);\n }\n Custom.prototype = Class.prototype;\n return Custom;\n};\n","import { newRange } from './utils.js';\n\nlet range;\n/**\n * @param {Node | Element} firstChild\n * @param {Node | Element} lastChild\n * @param {boolean} preserve\n * @returns\n */\nexport default (firstChild, lastChild, preserve) => {\n if (!range) range = newRange();\n /* c8 ignore start */\n if (preserve)\n range.setStartAfter(firstChild);\n else\n range.setStartBefore(firstChild);\n /* c8 ignore stop */\n range.setEndAfter(lastChild);\n range.deleteContents();\n return firstChild;\n};\n","import { DOCUMENT_FRAGMENT_NODE } from 'domconstants/constants';\nimport custom from 'custom-function/factory';\nimport drop from './range.js';\nimport { empty } from './utils.js';\n\n/**\n * @param {PersistentFragment} fragment\n * @returns {Node | Element}\n */\nconst remove = ({firstChild, lastChild}, preserve) => drop(firstChild, lastChild, preserve);\n\nlet checkType = false;\n\n/**\n * @param {Node} node\n * @param {1 | 0 | -0 | -1} operation\n * @returns {Node}\n */\nexport const diffFragment = (node, operation) => (\n checkType && node.nodeType === DOCUMENT_FRAGMENT_NODE ?\n ((1 / operation) < 0 ?\n (operation ? remove(node, true) : node.lastChild) :\n (operation ? node.valueOf() : node.firstChild)) :\n node\n);\n\nconst comment = value => document.createComment(value);\n\n/** @extends {DocumentFragment} */\nexport class PersistentFragment extends custom(DocumentFragment) {\n #firstChild = comment('<>');\n #lastChild = comment('</>');\n #nodes = empty;\n constructor(fragment) {\n super(fragment);\n this.replaceChildren(...[\n this.#firstChild,\n ...fragment.childNodes,\n this.#lastChild,\n ]);\n checkType = true;\n }\n get firstChild() { return this.#firstChild; }\n get lastChild() { return this.#lastChild; }\n get parentNode() { return this.#firstChild.parentNode; }\n remove() {\n remove(this, false);\n }\n replaceWith(node) {\n remove(this, true).replaceWith(node);\n }\n valueOf() {\n const { parentNode } = this;\n if (parentNode === this) {\n if (this.#nodes === empty)\n this.#nodes = [...this.childNodes];\n }\n else {\n /* c8 ignore start */\n // there are cases where a fragment might be just appended\n // out of the box without valueOf() invoke (first render).\n // When these are moved around and lose their parent and,\n // such parent is not the fragment itself, it's possible there\n // where changes or mutations in there to take care about.\n // This is a render-only specific issue but it's tested and\n // it's worth fixing to me to have more consistent fragments.\n if (parentNode) {\n let { firstChild, lastChild } = this;\n this.#nodes = [firstChild];\n while (firstChild !== lastChild)\n this.#nodes.push((firstChild = firstChild.nextSibling));\n }\n /* c8 ignore stop */\n this.replaceChildren(...this.#nodes);\n }\n return this;\n }\n}\n","export const ELEMENT_NODE = 1;\nexport const ATTRIBUTE_NODE = 2;\nexport const TEXT_NODE = 3;\nexport const COMMENT_NODE = 8;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_TYPE_NODE = 10;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\n","import udomdiff from 'udomdiff';\nimport { empty, gPD, isArray, set } from './utils.js';\nimport { diffFragment } from './persistent-fragment.js';\nimport drop from './range.js';\n\nconst setAttribute = (element, name, value) =>\n element.setAttribute(name, value);\n\n/**\n * @param {Element} element\n * @param {string} name\n * @returns {void}\n */\nexport const removeAttribute = (element, name) =>\n element.removeAttribute(name);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const aria = (element, value) => {\n for (const key in value) {\n const $ = value[key];\n const name = key === 'role' ? key : `aria-${key}`;\n if ($ == null) removeAttribute(element, name);\n else setAttribute(element, name, $);\n }\n return value;\n};\n\nlet listeners;\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const at = (element, value, name) => {\n name = name.slice(1);\n if (!listeners) listeners = new WeakMap;\n const known = listeners.get(element) || set(listeners, element, {});\n let current = known[name];\n if (current && current[0]) element.removeEventListener(name, ...current);\n current = isArray(value) ? value : [value, false];\n known[name] = current;\n if (current[0]) element.addEventListener(name, ...current);\n return value;\n};\n\n/** @type {WeakMap<Node, Element | import(\"./persistent-fragment.js\").PersistentFragment>} */\nconst holes = new WeakMap;\n\n/**\n * @template T\n * @param {import(\"./literals.js\").Detail} detail\n * @param {T} value\n * @returns {T}\n */\nexport const hole = (detail, value) => {\n const { t: node, n: hole } = detail;\n let nullish = false;\n switch (typeof value) {\n case 'object':\n if (value !== null) {\n (hole || node).replaceWith((detail.n = value.valueOf()));\n break;\n }\n case 'undefined':\n nullish = true;\n default:\n node.data = nullish ? '' : value;\n if (hole) {\n detail.n = null;\n hole.replaceWith(node);\n }\n break;\n }\n return value;\n};\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const className = (element, value) => maybeDirect(\n element, value, value == null ? 'class' : 'className'\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const data = (element, value) => {\n const { dataset } = element;\n for (const key in value) {\n if (value[key] == null) delete dataset[key];\n else dataset[key] = value[key];\n }\n return value;\n};\n\n/**\n * @template T\n * @param {Element | CSSStyleDeclaration} ref\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const direct = (ref, value, name) => (ref[name] = value);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const dot = (element, value, name) => direct(element, value, name.slice(1));\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const maybeDirect = (element, value, name) => (\n value == null ?\n (removeAttribute(element, name), value) :\n direct(element, value, name)\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const ref = (element, value) => (\n (typeof value === 'function' ?\n value(element) : (value.current = element)),\n value\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nconst regular = (element, value, name) => (\n (value == null ?\n removeAttribute(element, name) :\n setAttribute(element, name, value)),\n value\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const style = (element, value) => (\n value == null ?\n maybeDirect(element, value, 'style') :\n direct(element.style, value, 'cssText')\n);\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @param {string} name\n * @returns {T}\n */\nexport const toggle = (element, value, name) => (\n element.toggleAttribute(name.slice(1), value),\n value\n);\n\n/**\n * @param {Node} node\n * @param {Node[]} value\n * @param {string} _\n * @param {Node[]} prev\n * @returns {Node[]}\n */\nexport const array = (node, value, prev) => {\n // normal diff\n const { length } = value;\n node.data = `[${length}]`;\n if (length)\n return udomdiff(node.parentNode, prev, value, diffFragment, node);\n /* c8 ignore start */\n switch (prev.length) {\n case 1:\n prev[0].remove();\n case 0:\n break;\n default:\n drop(\n diffFragment(prev[0], 0),\n diffFragment(prev.at(-1), -0),\n false\n );\n break;\n }\n /* c8 ignore stop */\n return empty;\n};\n\nexport const attr = new Map([\n ['aria', aria],\n ['class', className],\n ['data', data],\n ['ref', ref],\n ['style', style],\n]);\n\n/**\n * @param {HTMLElement | SVGElement} element\n * @param {string} name\n * @param {boolean} svg\n * @returns\n */\nexport const attribute = (element, name, svg) => {\n switch (name[0]) {\n case '.': return dot;\n case '?': return toggle;\n case '@': return at;\n default: return (\n svg || ('ownerSVGElement' in element) ?\n (name === 'ref' ? ref : regular) :\n (attr.get(name) || (\n name in element ?\n (name.startsWith('on') ?\n direct :\n (gPD(element, name)?.set ? maybeDirect : regular)\n ) :\n regular\n )\n )\n );\n }\n};\n\n/**\n * @template T\n * @param {Element} element\n * @param {T} value\n * @returns {T}\n */\nexport const text = (element, value) => (\n (element.textContent = value == null ? '' : value),\n value\n);\n","/**\n * ISC License\n *\n * Copyright (c) 2020, Andrea Giammarchi, @WebReflection\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\n * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * @param {Node} parentNode The container where children live\n * @param {Node[]} a The list of current/live children\n * @param {Node[]} b The list of future children\n * @param {(entry: Node, action: number) => Node} get\n * The callback invoked per each entry related DOM operation.\n * @param {Node} [before] The optional node used as anchor to insert before.\n * @returns {Node[]} The same list of future children.\n */\nexport default (parentNode, a, b, get, before) => {\n const bLength = b.length;\n let aEnd = a.length;\n let bEnd = bLength;\n let aStart = 0;\n let bStart = 0;\n let map = null;\n while (aStart < aEnd || bStart < bEnd) {\n // append head, tail, or nodes in between: fast path\n if (aEnd === aStart) {\n // we could be in a situation where the rest of nodes that\n // need to be added are not at the end, and in such case\n // the node to `insertBefore`, if the index is more than 0\n // must be retrieved, otherwise it's gonna be the first item.\n const node = bEnd < bLength ?\n (bStart ?\n (get(b[bStart - 1], -0).nextSibling) :\n get(b[bEnd], 0)) :\n before;\n while (bStart < bEnd)\n parentNode.insertBefore(get(b[bStart++], 1), node);\n }\n // remove head or tail: fast path\n else if (bEnd === bStart) {\n while (aStart < aEnd) {\n // remove the node only if it's unknown or not live\n if (!map || !map.has(a[aStart]))\n parentNode.removeChild(get(a[aStart], -1));\n aStart++;\n }\n }\n // same node: fast path\n else if (a[aStart] === b[bStart]) {\n aStart++;\n bStart++;\n }\n // same tail: fast path\n else if (a[aEnd - 1] === b[bEnd - 1]) {\n aEnd--;\n bEnd--;\n }\n // The once here single last swap \"fast path\" has been removed in v1.1.0\n // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85\n // reverse swap: also fast path\n else if (\n a[aStart] === b[bEnd - 1] &&\n b[bStart] === a[aEnd - 1]\n ) {\n // this is a \"shrink\" operation that could happen in these cases:\n // [1, 2, 3, 4, 5]\n // [1, 4, 3, 2, 5]\n // or asymmetric too\n // [1, 2, 3, 4, 5]\n // [1, 2, 3, 5, 6, 4]\n const node = get(a[--aEnd], -0).nextSibling;\n parentNode.insertBefore(\n get(b[bStart++], 1),\n get(a[aStart++], -0).nextSibling\n );\n parentNode.insertBefore(get(b[--bEnd], 1), node);\n // mark the future index as identical (yeah, it's dirty, but cheap 👍)\n // The main reason to do this, is that when a[aEnd] will be reached,\n // the loop will likely be on the fast path, as identical to b[bEnd].\n // In the best case scenario, the next loop will skip the tail,\n // but in the worst one, this node will be considered as already\n // processed, bailing out pretty quickly from the map index check\n a[aEnd] = b[bEnd];\n }\n // map based fallback, \"slow\" path\n else {\n // the map requires an O(bEnd - bStart) operation once\n // to store all future nodes indexes for later purposes.\n // In the worst case scenario, this is a full O(N) cost,\n // and such scenario happens at least when all nodes are different,\n // but also if both first and last items of the lists are different\n if (!map) {\n map = new Map;\n let i = bStart;\n while (i < bEnd)\n map.set(b[i], i++);\n }\n // if it's a future node, hence it needs some handling\n if (map.has(a[aStart])) {\n // grab the index of such node, 'cause it might have been processed\n const index = map.get(a[aStart]);\n // if it's not already processed, look on demand for the next LCS\n if (bStart < index && index < bEnd) {\n let i = aStart;\n // counts the amount of nodes that are the same in the future\n let sequence = 1;\n while (++i < aEnd && i < bEnd && map.get(a[i]) === (index + sequence))\n sequence++;\n // effort decision here: if the sequence is longer than replaces\n // needed to reach such sequence, which would brings again this loop\n // to the fast path, prepend the difference before a sequence,\n // and move only the future list index forward, so that aStart\n // and bStart will be aligned again, hence on the fast path.\n // An example considering aStart and bStart are both 0:\n // a: [1, 2, 3, 4]\n // b: [7, 1, 2, 3, 6]\n // this would place 7 before 1 and, from that time on, 1, 2, and 3\n // will be processed at zero cost\n if (sequence > (index - bStart)) {\n const node = get(a[aStart], 0);\n while (bStart < index)\n parentNode.insertBefore(get(b[bStart++], 1), node);\n }\n // if the effort wasn't good enough, fallback to a replace,\n // moving both source and target indexes forward, hoping that some\n // similar node will be found later on, to go back to the fast path\n else {\n parentNode.replaceChild(\n get(b[bStart++], 1),\n get(a[aStart++], -1)\n );\n }\n }\n // otherwise move the source forward, 'cause there's nothing to do\n else\n aStart++;\n }\n // this node has no meaning in the future list, so it's more than safe\n // to remove it, and check the next live node out instead, meaning\n // that only the live list index should be forwarded\n else\n parentNode.removeChild(get(a[aStart++], -1));\n }\n }\n return b;\n};\n","import { empty } from './utils.js';\n\n/** @typedef {import(\"./persistent-fragment.js\").PersistentFragment} PersistentFragment */\n/** @typedef {import(\"./rabbit.js\").Hole} Hole */\n\n/** @typedef {unknown} Value */\n/** @typedef {Node | Element | PersistentFragment} Target */\n/** @typedef {null | undefined | string | number | boolean | Node | Element | PersistentFragment} DOMValue */\n/** @typedef {Hole | Node} ArrayValue */\n\nexport const abc = (a, b, c) => ({ a, b, c });\n\nexport const bc = (b, c) => ({ b, c });\n\n/**\n * @typedef {Object} Detail\n * @property {any} v the current value of the interpolation / hole\n * @property {function} u the callback to update the value\n * @property {Node} t the target comment node or element\n * @property {string | null | Node} n the attribute name, if any, or `null`\n * @property {Cache | ArrayValue[] | null} c the cache value for this detail\n */\n\n/**\n * @returns {Detail}\n */\nexport const detail = (u, t, n, c) => ({ v: empty, u, t, n, c });\n\n/**\n * @typedef {Object} Entry\n * @property {number[]} a the path to retrieve the node\n * @property {function} b the update function\n * @property {string | null} c the attribute name, if any, or `null`\n */\n\n/**\n * @typedef {Object} Cache\n * @property {null | TemplateStringsArray} a the cached template\n * @property {null | Node | PersistentFragment} b the node returned when parsing the template\n * @property {Detail[]} c the list of updates to perform\n */\n\n/**\n * @returns {Cache}\n */\nexport const cache = () => abc(null, null, empty);\n","import { PersistentFragment } from './persistent-fragment.js';\nimport { bc, detail } from './literals.js';\nimport { array, hole } from './handler.js';\nimport { empty, find } from './utils.js';\nimport { cache } from './literals.js';\n\n/** @param {(template: TemplateStringsArray, values: any[]) => import(\"./parser.js\").Resolved} parse */\nexport default parse => (\n /**\n * @param {TemplateStringsArray} template\n * @param {any[]} values\n * @returns {import(\"./literals.js\").Cache}\n */\n (template, values) => {\n const { a: fragment, b: entries, c: direct } = parse(template, values);\n const root = document.importNode(fragment, true);\n /** @type {import(\"./literals.js\").Detail[]} */\n let details = empty;\n if (entries !== empty) {\n details = [];\n for (let current, prev, i = 0; i < entries.length; i++) {\n const { a: path, b: update, c: name } = entries[i];\n const node = path === prev ? current : (current = find(root, (prev = path)));\n details[i] = detail(\n update,\n node,\n name,\n update === array ? [] : (update === hole ? cache() : null)\n );\n }\n }\n return bc(\n direct ? root.firstChild : new PersistentFragment(root),\n details,\n );\n }\n);\n","export const TEXT_ELEMENTS = /^(?:plaintext|script|style|textarea|title|xmp)$/i;\nexport const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;\n","import { VOID_ELEMENTS } from 'domconstants/re';\n\nconst elements = /<([a-zA-Z0-9]+[a-zA-Z0-9:._-]*)([^>]*?)(\\/?)>/g;\nconst attributes = /([^\\s\\\\>\"'=]+)\\s*=\\s*(['\"]?)\\x01/g;\nconst holes = /[\\x01\\x02]/g;\n\n// \\x01 Node.ELEMENT_NODE\n// \\x02 Node.ATTRIBUTE_NODE\n\n/**\n * Given a template, find holes as both nodes and attributes and\n * return a string with holes as either comment nodes or named attributes.\n * @param {string[]} template a template literal tag array\n * @param {string} prefix prefix to use per each comment/attribute\n * @param {boolean} xml enforces self-closing tags\n * @returns {string} X/HTML with prefixed comments or attributes\n */\nexport default (template, prefix, xml) => {\n let i = 0;\n return template\n .join('\\x01')\n .trim()\n .replace(\n elements,\n (_, name, attrs, selfClosing) => `<${\n name\n }${\n attrs.replace(attributes, '\\x02=$2$1').trimEnd()\n }${\n selfClosing ? (\n (xml || VOID_ELEMENTS.test(name)) ? ' /' : `></${name}`\n ) : ''\n }>`\n )\n .replace(\n holes,\n hole => hole === '\\x01' ? `<!--${prefix + i++}-->` : (prefix + i++)\n )\n ;\n};\n","import { SVG_NAMESPACE, newRange } from './utils.js';\n\nlet template = document.createElement('template'), svg, range;\n\n/**\n * @param {string} text\n * @param {boolean} xml\n * @returns {DocumentFragment}\n */\nexport default (text, xml) => {\n if (xml) {\n if (!svg) {\n svg = document.createElementNS(SVG_NAMESPACE, 'svg');\n range = newRange();\n range.selectNodeContents(svg);\n }\n return range.createContextualFragment(text);\n }\n template.innerHTML = text;\n const { content } = template;\n template = template.cloneNode(false);\n return content;\n};\n","import { COMMENT_NODE, ELEMENT_NODE } from 'domconstants/constants';\nimport { TEXT_ELEMENTS } from 'domconstants/re';\nimport parser from '@webreflection/uparser';\n\nimport { empty, isArray, set } from './utils.js';\nimport { abc } from './literals.js';\n\nimport { array, attribute, hole, text, removeAttribute } from './handler.js';\nimport createContent from './create-content.js';\n\n/** @typedef {import(\"./literals.js\").Entry} Entry */\n\n/**\n * @typedef {Object} Resolved\n * @param {DocumentFragment} f content retrieved from the template\n * @param {Entry[]} e entries per each hole in the template\n * @param {boolean} d direct node to handle\n */\n\n/**\n * @param {Element} node\n * @returns {number[]}\n */\nconst createPath = node => {\n const path = [];\n let parentNode;\n while ((parentNode = node.parentNode)) {\n path.push(path.indexOf.call(parentNode.childNodes, node));\n node = parentNode;\n }\n return path;\n};\n\nconst textNode = () => document.createTextNode('');\n\n/**\n * @param {TemplateStringsArray} template\n * @param {boolean} xml\n * @returns {Resolved}\n */\nconst resolve = (template, values, xml) => {\n const content = createContent(parser(template, prefix, xml), xml);\n const { length } = template;\n let entries = empty;\n if (length > 1) {\n const replace = [];\n const tw = document.createTreeWalker(content, 1 | 128);\n let i = 0, search = `${prefix}${i++}`;\n entries = [];\n while (i < length) {\n const node = tw.nextNode();\n // these are holes or arrays\n if (node.nodeType === COMMENT_NODE) {\n if (node.data === search) {\n // ⚠️ once array, always array!\n const update = isArray(values[i - 1]) ? array : hole;\n if (update === hole) replace.push(node);\n entries.push(abc(createPath(node), update, null));\n search = `${prefix}${i++}`;\n }\n }\n else {\n let path;\n // these are attributes\n while (node.hasAttribute(search)) {\n if (!path) path = createPath(node);\n const name = node.getAttribute(search);\n entries.push(abc(path, attribute(node, name, xml), name));\n removeAttribute(node, search);\n search = `${prefix}${i++}`;\n }\n // these are special text-only nodes\n if (\n !xml &&\n TEXT_ELEMENTS.test(node.localName) &&\n node.textContent.trim() === `<!--${search}-->`\n ) {\n entries.push(abc(path || createPath(node), text, null));\n search = `${prefix}${i++}`;\n }\n }\n }\n // can't replace holes on the fly or the tree walker fails\n for (i = 0; i < replace.length; i++)\n replace[i].replaceWith(textNode());\n }\n\n // need to decide if there should be a persistent fragment\n const { childNodes } = content;\n let { length: len } = childNodes;\n\n // html`` or svg`` to signal an empty content\n // these nodes can be passed directly as never mutated\n if (len < 1) {\n len = 1;\n content.appendChild(textNode());\n }\n // html`${'b'}` or svg`${[]}` cases\n else if (\n len === 1 &&\n // ignore html`static` or svg`static` because\n // these nodes can be passed directly as never mutated\n length !== 1 &&\n childNodes[0].nodeType !== ELEMENT_NODE\n ) {\n // use a persistent fragment for these cases too\n len = 0;\n }\n\n return set(cache, template, abc(content, entries, len === 1));\n};\n\n/** @type {WeakMap<TemplateStringsArray, Resolved>} */\nconst cache = new WeakMap;\nconst prefix = 'isµ';\n\n/**\n * @param {boolean} xml\n * @returns {(template: TemplateStringsArray, values: any[]) => Resolved}\n */\nexport default xml => (template, values) => cache.get(template) || resolve(template, values, xml);\n","import { array, hole } from './handler.js';\nimport { cache } from './literals.js';\nimport create from './creator.js';\nimport parser from './parser.js';\n\nconst createHTML = create(parser(false));\nconst createSVG = create(parser(true));\n\n/**\n * @param {import(\"./literals.js\").Cache} info\n * @param {Hole} hole\n * @returns {Node}\n */\nconst unroll = (info, { s, t, v }) => {\n if (info.a !== t) {\n const { b, c } = (s ? createSVG : createHTML)(t, v);\n info.a = t;\n info.b = b;\n info.c = c;\n }\n for (let { c } = info, i = 0; i < c.length; i++) {\n const value = v[i];\n const detail = c[i];\n switch (detail.u) {\n case array:\n detail.v = array(\n detail.t,\n unrollValues(detail.c, value),\n detail.v\n );\n break;\n case hole:\n const current = value instanceof Hole ?\n unroll(detail.c || (detail.c = cache()), value) :\n (detail.c = null, value)\n ;\n if (current !== detail.v)\n detail.v = hole(detail, current);\n break;\n default:\n if (value !== detail.v)\n detail.v = detail.u(detail.t, value, detail.n, detail.v);\n break;\n }\n }\n return info.b;\n};\n\n/**\n * @param {Cache} cache\n * @param {any[]} values\n * @returns {number}\n */\nconst unrollValues = (stack, values) => {\n let i = 0, { length } = values;\n if (length < stack.length) stack.splice(length);\n for (; i < length; i++) {\n const value = values[i];\n if (value instanceof Hole)\n values[i] = unroll(stack[i] || (stack[i] = cache()), value);\n else stack[i] = null;\n }\n return values;\n};\n\n/**\n * Holds all details needed to render the content on a render.\n * @constructor\n * @param {boolean} svg The content type.\n * @param {TemplateStringsArray} template The template literals used to the define the content.\n * @param {any[]} values Zero, one, or more interpolated values to render.\n */\nexport class Hole {\n constructor(svg, template, values) {\n this.s = svg;\n this.t = template;\n this.v = values;\n }\n toDOM(info = cache()) {\n return unroll(info, this);\n }\n};\n","/*! (c) Andrea Giammarchi - MIT */\nimport { Hole } from './rabbit.js';\nimport { attr } from './handler.js';\n\nimport render from './render/hole.js';\n\n/** @typedef {import(\"./literals.js\").Value} Value */\n\nconst tag = svg => (template, ...values) => new Hole(svg, template, values);\n\n/** @type {(template: TemplateStringsArray, ...values:Value[]) => Hole} A tag to render HTML content. */\nexport const html = tag(false);\n\n/** @type {(template: TemplateStringsArray, ...values:Value[]) => Hole} A tag to render SVG content. */\nexport const svg = tag(true);\n\nexport { Hole, render, attr };\n","import { Hole } from '../rabbit.js';\nimport { cache } from '../literals.js';\nimport { set } from '../utils.js';\n\n/** @type {WeakMap<Element | DocumentFragment, import(\"../literals.js\").Cache>} */\nconst known = new WeakMap;\n\n/**\n * Render with smart updates within a generic container.\n * @template T\n * @param {T} where the DOM node where to render content\n * @param {(() => Hole) | Hole} what the hole to render\n * @param {boolean} check does a `typeof` check (internal usage).\n * @returns\n */\nexport default (where, what, check) => {\n const info = known.get(where) || set(known, where, cache());\n const { b } = info;\n const hole = (check && typeof what === 'function') ? what() : what;\n const node = hole instanceof Hole ? hole.toDOM(info) : hole;\n if (b !== node)\n where.replaceChildren((info.b = node).valueOf());\n return where;\n};\n","/*! (c) Andrea Giammarchi - MIT */\nimport { Hole } from './rabbit.js';\nimport { attr } from './handler.js';\nimport { cache } from './literals.js';\nimport { set } from './utils.js';\nimport { html, svg } from './index.js';\n\nimport render from './render/keyed.js';\n\n/** @typedef {import(\"./literals.js\").Cache} Cache */\n/** @typedef {import(\"./literals.js\").Target} Target */\n/** @typedef {import(\"./literals.js\").Value} Value */\n\n/** @typedef {(ref:Object, key:string | number) => Tag} Bound */\n\n/**\n * @callback Tag\n * @param {TemplateStringsArray} template\n * @param {...Value} values\n * @returns {Target}\n */\n\nconst keyed = new WeakMap;\nconst createRef = svg => /** @type {Bound} */ (ref, key) => {\n /** @type {Tag} */\n function tag(template, ...values) {\n return new Hole(svg, template, values).toDOM(this);\n }\n\n const memo = keyed.get(ref) || set(keyed, ref, new Map);\n return memo.get(key) || set(memo, key, tag.bind(cache()));\n};\n\n/** @type {Bound} Returns a bound tag to render HTML content. */\nexport const htmlFor = createRef(false);\n\n/** @type {Bound} Returns a bound tag to render SVG content. */\nexport const svgFor = createRef(true);\n\nexport { Hole, render, html, svg, attr };\n","// (c) Andrea Giammarchi - ISC\n\nconst registry = new FinalizationRegistry(\n ([onGarbageCollected, held, debug]) => {\n // \"%cThis is a green text\", \"color:green\"\n if (debug) console.debug(`%c${String(held)}`, 'font-weight:bold', 'collected');\n onGarbageCollected(held);\n }\n);\n\nconst nullHandler = Object.create(null);\n\n/**\n * @template {unknown} H\n * @typedef {Object} GCHookOptions\n * @prop {boolean} [debug=false] if `true`, logs values once these can get collected.\n * @prop {ProxyHandler<object>} [handler] optional proxy handler to use instead of the default one.\n * @prop {H} [return=H] if specified, overrides the returned proxy with its value.\n * @prop {unknown} [token=H] it's the held value by default, but it can be any other token except the returned value itself.\n */\n\n/**\n * @template {unknown} H\n * @param {H} hold the reference to hold behind the scene and passed along the callback once it triggers.\n * @param {(held:H) => void} onGarbageCollected the callback that will receive the held value once its wrapper or indirect reference is no longer needed.\n * @param {GCHookOptions<H>} [options] an optional configuration object to change some default behavior.\n */\nexport const create = (\n hold,\n onGarbageCollected,\n { debug, handler, return: r, token = hold } = nullHandler\n) => {\n // if no reference to return is defined,\n // create a proxy for the held one and register that instead.\n /** @type {H} */\n const target = r || new Proxy(hold, handler || nullHandler);\n const args = [target, [onGarbageCollected, hold, !!debug]];\n if (token !== false) args.push(token);\n // register the target reference in a way that\n // the `onGarbageCollected(held)` callback will eventually notify.\n registry.register(...args);\n return target;\n};\n\n/**\n * If previously registered as either `token` or `hold` value, allow explicit removal of the entry in the registry.\n * @param {unknown} token the token used during registration. If no `token` was passed, this can be the same `hold` reference.\n * @returns {boolean} `true` if successfully unregistered.\n */\nexport const drop = token => registry.unregister(token);\n","import { create, drop } from 'gc-hook';\n\nimport render from './shared.js';\n\n/** @typedef {import(\"../rabbit.js\").Hole} Hole */\n\n/** @type {WeakMap<Element | DocumentFragment, Function>} */\nconst effects = new WeakMap;\n\n/**\n * @param {Function} dispose\n * @returns {void}\n */\nconst onGC = dispose => dispose();\n\nlet remove = true;\n\n/**\n * @param {Function} effect the reactive `effect` callback provided by a 3rd party library.\n * @returns \n */\nexport const attach = effect => {\n /**\n * Render with smart updates within a generic container.\n * If the `what` is a function, it automatically create\n * an effect for the render function.\n * @template T\n * @param {T} where the DOM node where to render content\n * @param {(() => Hole) | Hole} what the hole to render\n * @returns {T}\n */\n return (where, what) => {\n remove = typeof what !== 'function';\n detach(where);\n\n if (remove) return render(where, what, false);\n remove = true;\n\n const wr = new WeakRef(where);\n const dispose = effect(() => { render(wr.deref(), what(), false) });\n effects.set(where, dispose);\n return create(dispose, onGC, { return: where });\n };\n};\n\n/**\n * Allow manual cleanup of subscribed signals.\n * @param {Element} where a reference container previously used to render signals.\n */\nexport const detach = where => {\n const dispose = effects.get(where);\n if (dispose) {\n if (remove) effects.delete(where);\n drop(dispose);\n dispose();\n }\n};\n","import { effect } from 'mi-signal';\n\nexport { Computed, default as Signal, State, createSignal, effect } from 'mi-signal';\n\nimport { attach } from 'uhtml/reactive';\n\nexport * from 'uhtml/reactive';\n\nconst render = attach(effect);\n\nexport { render };\n"],"names":["context","State","EventTarget","value","equals","constructor","options","super","this","nextValue","get","set","running","length","add","dispatchEvent","CustomEvent","createSignal","initialValue","effect","cb","Set","push","pop","dep","addEventListener","removeEventListener","Computed","state","unsubscribe","index","CONTEXT_REQUEST","ContextProvider","host","addController","hostConnected","onContextRequest","hostDisconnected","newValue","ev","stopPropagation","subscribe","callback","ContextRequestEvent","Event","bubbles","composed","ContextConsumer","validate","undefined","dispatchRequest","_callback","bind","requestUpdate","camelToKebabCase","str","replace","_","m","toLowerCase","kebabToCamelCase","toUpperCase","MiElement","HTMLElement","attr","attrLc","Map","types","disposers","controllers","changedAttr","dedupe","static","mode","attributes","properties","observedAttributes","observedProperties","observe","name","Object","defineProperty","enumerable","oldValue","entries","initial","initialValueType","type","has","getName","getType","connectedCallback","forEach","controller","shadowRootOptions","template","renderRoot","shadowRoot","attachShadow","addTemplate","render","disconnectedCallback","remover","attributeChangedCallback","convertType","removeAttribute","setAttribute","includes","shouldUpdate","_changedAttributes","isConnected","requestAnimationFrame","update","HTMLTemplateElement","Error","append","content","cloneNode","on","eventName","listener","node","once","dispose","listeners","TypeError","removeController","delete","define","element","keys","map","renderTemplate","window","customElements","el","document","createElement","innerHTML","Boolean","Number","String","toString","call","slice","any","n","isNaN","toNumber","UnsafeHtml","unsafeHtml","escMap","escHtml","string","tag","esc","strings","vars","raw","refsById","container","nodes","querySelectorAll","found","getAttribute","nodeName","refsBySelector","selectors","selector","querySelector","Store","actions","action","dispatcher","data","classMap","acc","join","styleMap","unit","_unit","isFinite","globalSheets","addGlobalStyles","adoptedStyleSheets","Array","from","styleSheets","cssRules","sheet","CSSStyleSheet","css","rule","cssText","replaceSync","isArray","getPrototypeOf","getOwnPropertyDescriptor","empty","newRange","createRange","key","find","path","reduceRight","childNodesIndex","i","childNodes","setPrototypeOf","range","drop$1","firstChild","lastChild","preserve","setStartAfter","setStartBefore","setEndAfter","deleteContents","remove","drop","checkType","diffFragment","operation","nodeType","valueOf","comment","createComment","PersistentFragment","Class","Custom","target","prototype","custom","DocumentFragment","fragment","replaceChildren","parentNode","replaceWith","nextSibling","at","WeakMap","known","current","hole","detail","t","nullish","direct","ref","dot","maybeDirect","regular","toggle","toggleAttribute","array","prev","a","b","before","bLength","aEnd","bEnd","aStart","bStart","insertBefore","removeChild","sequence","replaceChild","udomdiff","$","dataset","style","attribute","svg","startsWith","prop","desc","gPD","text","textContent","abc","c","u","v","cache","create$1","parse","values","root","importNode","details","TEXT_ELEMENTS","VOID_ELEMENTS","elements","holes","createContent","xml","createElementNS","selectNodeContents","createContextualFragment","createPath","indexOf","textNode","createTextNode","prefix","parser","trim","attrs","selfClosing","trimEnd","test","tw","createTreeWalker","search","nextNode","hasAttribute","localName","len","appendChild","resolve","createHTML","create","createSVG","unroll","info","s","unrollValues","Hole","stack","splice","toDOM","html","render$1","where","what","check","keyed","createRef","memo","htmlFor","svgFor","registry","FinalizationRegistry","onGarbageCollected","held","debug","nullHandler","effects","onGC","attach","detach","wr","WeakRef","deref","hold","handler","return","r","token","Proxy","args","register","unregister"],"mappings":"AAAA,MAAMA,EAAU,GAEhB,MAAMC,UAAcC,YAClBC,GACAC,GACA,WAAAC,CAAYF,EAAOG,GACjBC,QACA,MAAOH,OAAQA,GAAUE,GAAW,CAAA,EACpCE,MAAKL,EAASA,EAAOK,MAAKJ,EAAUA,GAAM,EAAMD,EAAOM,IAAcN,IAAUM,EACjF,CACA,SAAIN,GACF,OAAOK,KAAKE,KACd,CACA,SAAIP,CAAMM,GACRD,KAAKG,IAAIF,EACX,CACA,GAAAC,GACE,MAAME,EAAUZ,EAAQA,EAAQa,OAAS,GACzC,OAAOD,GAAWA,EAAQE,IAAIN,MAAOA,MAAKL,CAC5C,CACA,GAAAQ,CAAIF,GACFD,MAAKJ,EAAQI,MAAKL,EAAQM,KAAeD,MAAKL,EAASM,EAAWD,KAAKO,cAAc,IAAIC,YAAY,WACvG,EAGG,MAACC,EAAe,CAACC,EAAcZ,IAAYY,aAAwBjB,EAAQiB,EAAe,IAAIjB,EAAMiB,EAAcZ,GAEvH,SAASa,EAAOC,GACd,MAAMR,EAAU,IAAIS,IACpBrB,EAAQsB,KAAKV,GACb,IACEQ,GACF,CAAC,QACCpB,EAAQuB,KACV,CACA,IAAK,MAAMC,KAAOZ,EAASY,EAAIC,iBAAiB,SAAUL,GAC1D,MAAO,KACL,IAAK,MAAMI,KAAOZ,EAASY,EAAIE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ACzCc,EAAO,CAAClI,EAAQ,CAACiH,EAAoBW,IAAQT,IAKnD,OAJc,IAAVa,GAAiBE,EAAKlV,KAAKgV,GAG/BjB,GAASoB,YAAYD,GACdlI,GCAE2F,CAAOtM,EAASiO,GAAM,CAAEQ,OAAQvB,KAQ9BiB,GAASjB,IACpB,MAAMlN,EAAUgO,GAAQjV,IAAImU,GDDVyB,MCEd3O,IACE+F,IAAQiI,GAAQ5N,OAAO8M,GDHXyB,ECIX3O,EDJoB0N,GAASqB,WAAWJ,GCK7C3O,MC9CEvB,GAASyP,GAAO1U","x_google_ignoreList":[8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mi-element",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Build lightweight reactive micro web-components",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/commenthol/mi-element/tree/main/packages/mi-element#readme",
@@ -74,27 +74,27 @@
74
74
  "types"
75
75
  ],
76
76
  "dependencies": {
77
- "mi-signal": "0.6.2"
77
+ "mi-signal": "0.6.3"
78
78
  },
79
79
  "devDependencies": {
80
- "@eslint/js": "^9.33.0",
80
+ "@eslint/js": "^9.34.0",
81
81
  "@rollup/plugin-node-resolve": "^16.0.1",
82
82
  "@rollup/plugin-terser": "^0.4.4",
83
83
  "@testing-library/dom": "^10.4.1",
84
84
  "@types/node": "^24.3.0",
85
85
  "@vitest/browser": "^3.2.4",
86
86
  "@vitest/coverage-istanbul": "^3.2.4",
87
- "eslint": "^9.33.0",
87
+ "eslint": "^9.34.0",
88
88
  "globals": "^16.3.0",
89
89
  "npm-run-all2": "^8.0.4",
90
- "playwright": "^1.54.2",
90
+ "playwright": "^1.55.0",
91
91
  "prettier": "^3.6.2",
92
92
  "rimraf": "^6.0.1",
93
- "rollup": "^4.46.3",
93
+ "rollup": "^4.48.1",
94
94
  "typescript": "^5.9.2",
95
- "vite": "^7.1.2",
95
+ "vite": "^7.1.3",
96
96
  "vitest": "^3.2.4",
97
- "mi-html": "0.6.2"
97
+ "mi-html": "0.6.3"
98
98
  },
99
99
  "scripts": {
100
100
  "all": "npm-run-all pretty lint test build types",
@@ -106,7 +106,9 @@
106
106
  "test": "vitest run --coverage",
107
107
  "test:browser": "vitest --coverage",
108
108
  "dev": "npm run test:browser",
109
- "types": "tsc",
109
+ "types": "npm-run-all types:pre types:post",
110
+ "types:pre": "rimraf types; tsc",
111
+ "types:post": "node scripts/types.js",
110
112
  "setup": "pnpm exec playwright install"
111
113
  }
112
114
  }
package/src/context.js CHANGED
@@ -14,13 +14,14 @@ import { createSignal, effect } from 'mi-signal'
14
14
  const CONTEXT_REQUEST = 'context-request'
15
15
 
16
16
  /**
17
+ * @template T
17
18
  * @implements {HostController}
18
19
  */
19
20
  export class ContextProvider {
20
21
  /**
21
22
  * @param {HTMLElement} host
22
23
  * @param {Context} context
23
- * @param {any} initialValue
24
+ * @param {T|null} [initialValue]
24
25
  */
25
26
  constructor(host, context, initialValue) {
26
27
  this.host = host
@@ -41,14 +42,14 @@ export class ContextProvider {
41
42
  }
42
43
 
43
44
  /**
44
- * @param {any} newValue
45
+ * @param {T|null|undefined} newValue
45
46
  */
46
47
  set(newValue) {
47
48
  this.state.set(newValue)
48
49
  }
49
50
 
50
51
  /**
51
- * @returns {any}
52
+ * @returns {T|null|undefined}
52
53
  */
53
54
  get() {
54
55
  return this.state.get()
@@ -77,10 +78,13 @@ export class ContextProvider {
77
78
  }
78
79
  }
79
80
 
81
+ /**
82
+ * @template T
83
+ */
80
84
  export class ContextRequestEvent extends Event {
81
85
  /**
82
86
  * @param {Context} context
83
- * @param {(value: any, unsubscribe?: () => void) => void} callback
87
+ * @param {(value: T|null|undefined, unsubscribe?: () => void) => void} callback
84
88
  * @param {boolean} [subscribe=false] subscribe to value changes
85
89
  */
86
90
  constructor(context, callback, subscribe) {
@@ -92,9 +96,15 @@ export class ContextRequestEvent extends Event {
92
96
  }
93
97
 
94
98
  /**
99
+ * @template T
95
100
  * @implements {HostController}
96
101
  */
97
102
  export class ContextConsumer {
103
+ /**
104
+ * @type {T|null|undefined}
105
+ */
106
+ #value
107
+
98
108
  /**
99
109
  * @param {HTMLElement} host
100
110
  * @param {Context} context
@@ -108,8 +118,6 @@ export class ContextConsumer {
108
118
  this.context = context
109
119
  this.subscribe = !!subscribe
110
120
  this.validate = validate
111
- // initial value yet unknown
112
- this.value = undefined
113
121
  // unsubscribe function
114
122
  this.unsubscribe = undefined
115
123
  // add the controller in case of a MiElement otherwise call hostConnected()
@@ -118,6 +126,20 @@ export class ContextConsumer {
118
126
  this.host.addController?.(this)
119
127
  }
120
128
 
129
+ /**
130
+ * @returns {T|null|undefined}
131
+ */
132
+ get() {
133
+ return this.#value
134
+ }
135
+
136
+ /**
137
+ * @returns {T|null|undefined}
138
+ */
139
+ get value() {
140
+ return this.#value
141
+ }
142
+
121
143
  hostConnected() {
122
144
  this.dispatchRequest()
123
145
  }
@@ -155,7 +177,7 @@ export class ContextConsumer {
155
177
  if (!this.validate(value)) {
156
178
  return
157
179
  }
158
- this.value = value
180
+ this.#value = value
159
181
  // @ts-expect-error
160
182
  this.host.requestUpdate()
161
183
  }
@@ -1,47 +1,52 @@
1
1
  /**
2
+ * @template T
2
3
  * @implements {HostController}
3
4
  */
4
- export class ContextProvider implements HostController {
5
+ export class ContextProvider<T> implements HostController {
5
6
  /**
6
7
  * @param {HTMLElement} host
7
8
  * @param {Context} context
8
- * @param {any} initialValue
9
+ * @param {T|null} [initialValue]
9
10
  */
10
- constructor(host: HTMLElement, context: Context, initialValue: any);
11
+ constructor(host: HTMLElement, context: Context, initialValue?: T | null);
11
12
  host: HTMLElement;
12
13
  context: Context;
13
- state: import("mi-signal").State<any>;
14
+ state: import("mi-signal").State<T | null | undefined>;
14
15
  hostConnected(): void;
15
16
  hostDisconnected(): void;
16
17
  /**
17
- * @param {any} newValue
18
+ * @param {T|null|undefined} newValue
18
19
  */
19
- set(newValue: any): void;
20
+ set(newValue: T | null | undefined): void;
20
21
  /**
21
- * @returns {any}
22
+ * @returns {T|null|undefined}
22
23
  */
23
- get(): any;
24
+ get(): T | null | undefined;
24
25
  /**
25
26
  * @private
26
27
  * @param {ContextRequestEvent} ev
27
28
  */
28
29
  private onContextRequest;
29
30
  }
30
- export class ContextRequestEvent extends Event {
31
+ /**
32
+ * @template T
33
+ */
34
+ export class ContextRequestEvent<T> extends Event {
31
35
  /**
32
36
  * @param {Context} context
33
- * @param {(value: any, unsubscribe?: () => void) => void} callback
37
+ * @param {(value: T|null|undefined, unsubscribe?: () => void) => void} callback
34
38
  * @param {boolean} [subscribe=false] subscribe to value changes
35
39
  */
36
- constructor(context: Context, callback: (value: any, unsubscribe?: () => void) => void, subscribe?: boolean);
40
+ constructor(context: Context, callback: (value: T | null | undefined, unsubscribe?: () => void) => void, subscribe?: boolean);
37
41
  context: Context;
38
- callback: (value: any, unsubscribe?: () => void) => void;
42
+ callback: (value: T | null | undefined, unsubscribe?: () => void) => void;
39
43
  subscribe: boolean | undefined;
40
44
  }
41
45
  /**
46
+ * @template T
42
47
  * @implements {HostController}
43
48
  */
44
- export class ContextConsumer implements HostController {
49
+ export class ContextConsumer<T> implements HostController {
45
50
  /**
46
51
  * @param {HTMLElement} host
47
52
  * @param {Context} context
@@ -57,12 +62,20 @@ export class ContextConsumer implements HostController {
57
62
  context: Context;
58
63
  subscribe: boolean;
59
64
  validate: (any: any) => boolean;
60
- value: any;
61
65
  unsubscribe: any;
66
+ /**
67
+ * @returns {T|null|undefined}
68
+ */
69
+ get(): T | null | undefined;
70
+ /**
71
+ * @returns {T|null|undefined}
72
+ */
73
+ get value(): T | null | undefined;
62
74
  hostConnected(): void;
63
75
  hostDisconnected(): void;
64
76
  dispatchRequest(): void;
65
77
  _callback(value: any, unsubscribe: any): void;
78
+ #private;
66
79
  }
67
80
  export type HostController = import("./element.js").HostController;
68
81
  export type Context = string | Symbol;
@@ -143,11 +143,11 @@ export class MiElement extends HTMLElement {
143
143
  * @param {HostController} controller
144
144
  */
145
145
  removeController(controller: HostController): void;
146
+ /**
147
+ * properties or attributes
148
+ */
149
+ [index: PropertyKey]: any;
146
150
  #private;
147
- /**
148
- * properties or attributes
149
- */
150
- [index: PropertyKey]: any
151
151
  }
152
152
  export function define(name: string, element: typeof MiElement, options?: object): void;
153
153
  export function convertType(any: any, type: any): any;
package/types/signal.d.ts DELETED
@@ -1,67 +0,0 @@
1
- /**
2
- * effect subscribes to state at first run only. Do not hide a signal.get()
3
- * inside conditionals!
4
- * @param {() => void|Promise<void>} cb
5
- */
6
- export function effect(cb: () => void | Promise<void>): () => void;
7
- /**
8
- * @template T
9
- * @typedef {(value?: T|null, nextValue?: T|null) => boolean} EqualsFn
10
- * Custom comparison function between old and new value
11
- * default `(value, nextValue) => value === nextValue`
12
- */
13
- /**
14
- * @template T
15
- * @typedef {{equals: EqualsFn<T>}} SignalOptions
16
- */
17
- /**
18
- * read- write signal
19
- * @template T
20
- */
21
- export class State<T> extends EventTarget {
22
- /**
23
- * @param {T|null} [value]
24
- * @param {SignalOptions<T>} [options]
25
- */
26
- constructor(value?: T | null, options?: SignalOptions<T>);
27
- /**
28
- * @returns {T|null|undefined}
29
- */
30
- get(): T | null | undefined;
31
- /**
32
- * @param {T|null|undefined} nextValue
33
- */
34
- set(nextValue: T | null | undefined): void;
35
- #private;
36
- }
37
- export function createSignal<T>(initialValue: T, options?: SignalOptions<T>): State<T>;
38
- /**
39
- * @template T
40
- */
41
- export class Computed<T> {
42
- /**
43
- * @param {() => T} cb
44
- */
45
- constructor(cb: () => T);
46
- /**
47
- * @template T
48
- * @returns {T}
49
- */
50
- get<T_1>(): T_1;
51
- #private;
52
- }
53
- declare namespace _default {
54
- export { State };
55
- export { Computed };
56
- export { createSignal };
57
- export { effect };
58
- }
59
- export default _default;
60
- /**
61
- * Custom comparison function between old and new value
62
- * default `(value, nextValue) => value === nextValue`
63
- */
64
- export type EqualsFn<T> = (value?: T | null, nextValue?: T | null) => boolean;
65
- export type SignalOptions<T> = {
66
- equals: EqualsFn<T>;
67
- };