@twobirds/microcomponents 0.0.58 → 0.0.59

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.
Files changed (44) hide show
  1. package/assets/test.html +1 -1
  2. package/dist/MC.d.ts +1 -1
  3. package/dist/MC.d.ts.map +1 -1
  4. package/dist/MC.min.js +65 -26
  5. package/dist/MC.ts +130 -33
  6. package/dist/elements.min.js +1 -1
  7. package/dist/formvValues.min.js +1 -1
  8. package/dist/microcomponents.min.js +1 -1
  9. package/dist/observables.min.js +1 -1
  10. package/dist/selectors.min.js +1 -1
  11. package/dist/test.ts +17 -1
  12. package/package.json +3 -3
  13. package/public/MC.js +65 -26
  14. package/public/MC.js.map +1 -1
  15. package/public/MC.min.js +65 -26
  16. package/public/documentation/observables.md +1 -1
  17. package/public/elements.min.js +1 -1
  18. package/public/formvValues.min.js +1 -1
  19. package/public/microcomponents.min.js +1 -1
  20. package/public/observables.min.js +1 -1
  21. package/public/selectors.min.js +1 -1
  22. package/public/src/MC.ts +130 -33
  23. package/public/src/test.ts +17 -1
  24. package/public/test/child.js +15 -0
  25. package/public/test/child.js.map +1 -0
  26. package/public/test/grandchild.js +15 -0
  27. package/public/test/grandchild.js.map +1 -0
  28. package/public/test/grandparent.js +15 -1
  29. package/public/test/grandparent.js.map +1 -0
  30. package/public/test/greatgrandchild.js +29 -0
  31. package/public/test/greatgrandchild.js.map +1 -0
  32. package/public/test/parent.js +15 -0
  33. package/public/test/parent.js.map +1 -0
  34. package/public/test/testform.js +141 -1
  35. package/public/test/testform.js.map +1 -0
  36. package/public/test/testmc.js +10 -0
  37. package/public/test/testmc.js.map +1 -0
  38. package/public/test.html +1 -1
  39. package/public/test.js +4 -1
  40. package/public/test.js.map +1 -1
  41. package/src/MC.ts +130 -33
  42. package/src/test/testmc.ts +11 -0
  43. package/src/test.ts +17 -1
  44. package/webpack.config.js +39 -0
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.microcomponents=t():e.microcomponents=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return e&&e.constructor&&e.constructor===Object}function n(e){let t={};return[...Object.keys(e)].sort().forEach((a=>{r(e[a])?t[a]=n(e[a]):t[a]=e[a]})),t}function a(e,t=!0){let r={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const n=a(e[t],!1);for(const e in n)r[t+"."+e]=n[e]}else r[t]=e[t]})),t?n(r):r}function s(e,t){return JSON.stringify(a(e))===JSON.stringify(a(t))}function o(e,t={}){let r=e.constructor===String?e.split("."):e;if(t&&r[0]&&t[r[0]])return t[r[0]].constructor===Object&&r.length>1?o(r.splice(1),t[r[0]]):t[r[0]];console.warn("ns",r[0],"not in",t)}function c(e,t){var n=Array.from(arguments);if(n.length>2){for(;n.length>1;)n[0]=c(n[0],n[1]),n.splice(1,1);return n[0]}if("string"==typeof e)e.match(/\{[^\{\}]*\}/g)?.forEach((function(r){var n=o(r.substring(1,r.length-1),t);void 0!==n&&(e=e.replace(r,n))}));else if(r(e))switch(e.constructor){case Object:Object.keys(e).forEach((function(r){e.hasOwnProperty(r)&&(e[r]=c(e[r],t))}));break;case Array:e.forEach((function(r,n,a){a[n]=c(e[n],t)}))}return e}function i(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("")}function l(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}function u(e){let t=document.createElement("template");return e=e.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi,"<$1$2></$1>"),t.innerHTML=e,t.content.normalize(),Array.from(t.content.childNodes)}function h(e,t){const r=Object.getOwnPropertyDescriptors(e);for(const[e,n]of Object.entries(r))("get"in n||"set"in n)&&Object.defineProperty(t,e,n)}e.r(t),e.d(t,{$d:()=>Y,$t:()=>K,DC:()=>N,MC:()=>k,McBase:()=>x,McEvent:()=>p,addListener:()=>v,autoload:()=>M,copyGettersSetters:()=>h,debounce:()=>l,deepEqual:()=>s,defineCE:()=>$,flattenObject:()=>a,formValues:()=>se,getCE:()=>H,htmlToElements:()=>u,isNativeObject:()=>r,kebabToPascal:()=>i,nameSpace:()=>o,observe:()=>V,parse:()=>c,removeListener:()=>O,sortObject:()=>n});var f=new Function("try {return this===window;}catch(e){ return false;}");let d=new Set;f()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>d.add(e)));class p{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var m=new Function("try {return this===window;}catch(e){ return false;}");let b=new Set;function g(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function y(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function E(e){return e&&e instanceof HTMLElement}function v(e,t,r,n=!1,a=!1){let s={once:!1};n&&(s.capture=n),a&&(s.once=a),e.addEventListener(t,r,s)}function O(e,t,r){e.removeEventListener(t,r)}function w(e,t,r={}){let n=e;if(!n._mc){let t=N?.debug;N.debug=!1,n._mc=new N(e),N.debug=t,delete n._mc._mc}const a=n._mc;return t.length&&!a[t]&&(a[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function S(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function A(e,t,r={},n="l"){let a=e?._mc;if(!a)return;let s=t instanceof p?new p(t.type,t.data,"l"):new p(t,r,"l"),o="string"!=typeof t?t:new p(t,r,n);[...Object.values(a)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(s)})),/[ud]/.test(o.bubble)&&j(e,o)}function j(e,t){/[ud]/.test(t.bubble)&&setTimeout((()=>{if(-1===t.bubble.indexOf("l")&&(t.bubble+="l"),t.bubble.indexOf("u")>-1){let r=y(e,"",!0)?.[0].target;r&&N.trigger(r,t)}t.bubble.indexOf("d")>-1&&new Set(e._mc.children().map((e=>e?.target))).forEach((e=>{e&&N.trigger(e,t)}))}),0)}m()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>b.add(e)));class x{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==N&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!m()||e.constructor===N)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let a=/^one/.test(n),s=n.replace(/^on[e]{0,1}/,""),o=s.toLowerCase();a&&Object.defineProperty(e,"on"+s,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),b.has("on"+o)&&v(t,o,(e=>{r.trigger(s,e)}),!1,a)}))}}(this)}get target(){return this.#n.deref()}}class k extends x{_mc={};constructor(e){super(e)}static trigger=A;trigger(e,t={},r="l"){let n=this;if(n.constructor===k||n.constructor===N){let a=e instanceof p?new p(e.type,e.data,"l"):new p(e,t,"l"),s="string"!=typeof e?e:new p(e,t,r);return[...Object.getOwnPropertyNames(n)].forEach((e=>{n[e]?.trigger&&"function"==typeof n[e]?.trigger&&n[e]?.trigger(a)})),void(/[ud]/.test(s.bubble)&&j(n.target,s))}if(n instanceof k||n instanceof N){const n=this,a="string"!=typeof e?e:new p(e,t,r),s="on"+a.type[0].toUpperCase()+a.type.slice(1);if(a.bubble.indexOf("l")>-1&&(a.immediateStopped||"function"!=typeof n[s]||(n[s](a),n.hasOwnProperty(s)&&delete n[s])),a.stopped||"l"===a.bubble)return n;/[ud]/.test(a.bubble)&&j(n.target,a)}}}class N extends x{_mc={};constructor(e,t=!1){super(e)}static add=w;static remove=S;static trigger=A;trigger(e,t={},r){k.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return E(t)?y(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return E(t)?y(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!E(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const a=g([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),a}descendants(e=""){let t=this?.target;return E(t)?g([...t.querySelectorAll("*[_mc]")],e):[]}}let _=null;const T=new Map;function C(){document.querySelectorAll(':not(:defined),[_mc]:not([_mc=""])').forEach((e=>{(e.tagName.includes("-")?[e.tagName.toLowerCase()]:e.getAttribute("_mc").trim().split(" ")).forEach((t=>{let r=t.toLowerCase().split("-");if(r=r.join("/")+".js",e.tagName.includes("-")&&!T.has(e.tagName.toLowerCase())){const e=document.createElement("script");T.set(t,r),e.setAttribute("src",r),e.setAttribute("blocking","render"),e.setAttribute("type","module"),e.onload=()=>{T.delete(t)},document.head.append(e)}}))}))}let L=!1;function M(e=!0){return e?(L=e,_=new MutationObserver(C),setTimeout((()=>{_.observe(document.body,{childList:!0,subtree:!0}),C()}),5),L):(_?.disconnect(),_=null,L)}class P extends HTMLElement{constructor(){super()}connectedCallback(){N.trigger(this,"Connected")}disconnectedCallback(){N.trigger(this,"Disconnected")}adoptedCallback(){N.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){N.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function $(e,t,r=[]){if(customElements.get(e))return void console.warn(`IGNORED: Custom element "${e}" is already defined!`);if(!e.includes("-"))throw new Error('createCustomElement: tagName must contain at least one hyphen ("-").');let n=i(e);customElements.define(e,function(e,t){return Object.defineProperty(t,"name",{value:e})}(n,class extends P{instance;constructor(e){super();let r=new t(this,e);N.add(this,n,r)}static get observedAttributes(){return r}}))}function H(e){return customElements.get(e)}function q(e){return null!=e&&"object"==typeof e}function D(e){let t=new Set,r=/\{[^\{\}]*\}/g;return e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(r))).forEach((n=>{new Set(e.getAttribute(n)?.match(r)).forEach((e=>t.add(e.replace(/[\{\}]/g,""))))})),[...e.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(r))).forEach((e=>{(e.nodeValue||"").match(r).forEach((e=>{t.add(e.replace(/[\{\}]/g,""))}))})),[...t].map((e=>e.replace(/[\{\}]/g,"")))}const I=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class B extends N{data={};oldDisplay="";constructor(e){super(e);let t=this;D(e).forEach((e=>t.data[e]="")),V(t),t.#a(),delete t._mc}#a(){let e=this,t=e.target,r=!1;t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(t.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var a;e.data.observe((a=t.getAttribute(r),e=>{let s=a;n.forEach((t=>{s=s.replace(t,e[t.replace(/[\{\}]/g,"")])})),t.setAttribute(r,s)}))})),[...t.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((n=>{r=!0;let a=new Set(n.nodeValue.match(/\{[^\{\}]*\}/g));var s;e.data.observe((s=n.nodeValue,r=>{let o=s;a.forEach((e=>{o=o.replace(e,r[e.replace(/[\{\}]/g,"")])})),Object.keys(r).some((e=>!!r[e]))&&(e.oldDisplay?t.style=e.oldDisplay:t.removeAttribute("style"),delete e.oldDisplay),n.nodeValue=o})),e.oldDisplay=t.getAttribute("style)")||"",r&&!I.includes(t.constructor)&&"FIELDSET"!==t.tagName&&(t.style.display="none")}))}onData(e){let t=this,r={};Object.keys(e.data).forEach((n=>{t.data.hasOwnProperty(n)&&(r[n]=e.data[n])})),JSON.stringify(r)!==JSON.stringify(t.data)&&Object.assign(t.data,r)}}const V=(e,t)=>((t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return e;let r,n=e[t];if(!n.prototype)switch(typeof n){case"string":r=String;break;case"number":r=Number;break;case"boolean":r=Boolean;break;case"object":r=n instanceof Array?Array:Object;break;default:return}let o=class extends r{#s=!0;constructor(e){super(e),this.constructor.callbacks=[],q(e)&&Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]}))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this;if(q(t.valueOf())){!function(e){var t;(t=e,(t instanceof HTMLElement?[t]:[]).concat([...t.querySelectorAll("*")]).filter((e=>!!D(e).length)).filter((e=>"STYLE"!==e.tagName))).forEach((e=>{e?._mc?._placeholders||N.add(e,"_placeholders",new B(e))}))}(e);const r=[...e.querySelectorAll("[_mc]")].filter((e=>!!e?._mc?._placeholders)),n=function(e){let t=a(e);r.forEach((e=>{e&&e._mc.trigger("data",t)}))};t.constructor.callbacks.push(n),t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf(),t);return this}notify(e){let t=this,r=q(t.valueOf())&&t.valueOf()instanceof Array==0?structuredClone(Object.assign({},t)):t.valueOf();return void 0!==e&&(t.#s=e),t.constructor.callbacks.forEach((e=>{e(r)})),t}},c=new o(n);Object.defineProperty(e,t,{enumerable:!0,get(){if(q(c.valueOf())){let e=structuredClone(Object.assign({},c));setTimeout(l((function(){s(structuredClone(Object.assign({},c)),e)||c.notify()}),0),0)}return c},set(e){if(typeof e==typeof c.valueOf())if(q(c.valueOf())&&c.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},c));c instanceof o==0&&(c=new o(structuredClone(Object.assign({},e))),h(e,c),c.seal()),Object.assign(c,e),setTimeout(l((function(){s(structuredClone(Object.assign({},c)),t)||c.notify()}),0),0)}else{let t=c.valueOf(),r=c.constructor.callbacks;c=new o(e),c.constructor.callbacks=r,e!==t&&c.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof c.valueOf(),c,"- CANNOT BECOME:",typeof e)}}),e[t]=n})),e),z=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},J=e=>{let t=Y("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new G(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new R(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new W(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class F{constructor(e){}}class G extends F{#o;#e;#c;constructor(e,t){super(e),this.#o=e,this.#e=e.type,this.#c=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=Y(`input[type="radio"][name="${this.#o.getAttribute("name")}"]`,this.#c).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#o.checked;default:return t.#o.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=`input[type="radio"][name="${this.#o.getAttribute("name")}"]`,n=Y(r,this.#c);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const a=n.filter((t=>t.getAttribute("value")===e));if(!a.length)return;return void(a.array[0].checked=!0);case"checkbox":t.#o.checked=e;break;default:t.#o.value=e}}}class R extends F{#o;#i=!1;constructor(e){super(e),this.#o=e,this.#i="select-multiple"===e.type}get val(){const e=[];return Y(this.#o.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#i?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,Y(this.#o.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class W extends F{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value}set val(e){this.#o.value=e}}class Z{#l=new Set;get set(){return this.#l}get array(){return Array.from(this.#l)}set set(e){this.#l=e}get length(){return this.#l.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new U;return this.#l.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return Y(e,t).forEach((e=>{r.#l.add(e)})),r}addClass(...e){return e=z(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=Y(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=Y(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=Y(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{Y(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=Y(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,a=!1;return e&&(a=Y(e,t)),r.#l.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=Y([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#l.has(e)}hasClass(...e){return e=z(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)+1;a<r.length&&n.add(r.at(a))}})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#l.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){O(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let a=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(a,Array.from(arguments))}return o.cb=t,a.forEach((e=>{s.forEach((function(t){v(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){v(e,t,s,r,!0)}))})),s}parent(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=Y(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)-1;a>-1&&n.add(r.at(a))}})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=z(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=z(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,a=!1){let s,o={bubbles:r,cancelable:n,composed:a},c=e.indexOf(" ")>-1?e.split(" "):[e];return this.#l.forEach((e=>{c.forEach((function(r){s=new Event(r,o),s.data=t,e.dispatchEvent(s)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,a=J(r.array[0]);var s;return e?null!=(s=e)&&"object"==typeof s?(Object.assign(a,e),n=r):"string"==typeof e&&(void 0===t?n=a[e]:(a[e]=t,n=r)):n=Object.assign({},a),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=J(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return Y(this.array.at(e))}concat(e){let t=this;return(e instanceof Z?e.array:e).forEach((e=>{t.#l.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#l=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#l.add(e)})),this}shift(){let e=this,t=e.#l.size?e.array[0]:void 0;return t&&e.#l.delete(t),t}slice(e,t){return Y(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),Y(n)}}class U{#l=new Set;get set(){return this.#l}get array(){return Array.from(this.#l)}set set(e){this.#l=e}get length(){return this.#l.size}set length(e){}constructor(e,t=document.body){if(!e)return this;Y(e,t).forEach((e=>{K(e).forEach((e=>{this.#l.add(e)}))}))}$d(e,t=document.body){let r=new Z,n=new Set,a=!!e||!1,s=new Set;return a&&(s=Y(e,t).set),this.#l.forEach((e=>{a&&!s.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}descendants(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}first(e){let t=this,r=new Set;return t.#l.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#l.has(e)}last(e){let t=this,r=new Set;return t.#l.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#l.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);K([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){O(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){v(e._tg,`[TB]${t}`,s,!1,r)}))})),s}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(r,Array.from(arguments))}return a.cb=t,r.forEach((e=>{n.forEach((function(t){v(e._tg,`[TB]${t}`,a,!1,!0)}))})),a}parent(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}parents(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}prev(e){let t=this,r=new Set;return t.#l.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);K([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return K(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#l.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return K(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#l=new Set(e),t}push(e){return this.#l.add(e),this}shift(){let e=this.array.shift();return this.#l.delete(e),e}slice(e,t){return K(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return K(n)}}const Y=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{Y(e,t).forEach((e=>{r.add(e)}))})),new Z([...r])):new Z(e,t)},K=(e,t=document)=>Y(e,t).$t();class Q{constructor(e){}}class X extends Q{#o;constructor(e){super(e),this.#o=e}get val(){return new FormData(this.#o.form).get(this.#o.name)}set val(e){[...this.#o.form.querySelectorAll(`input[type="radio"][name="${this.#o.name}"]`)].filter((t=>t.getAttribute("value")===e)).shift().checked=!0}}class ee extends Q{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.checked}set val(e){this.#o.checked=e}}class te extends Q{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value}set val(e){this.#o.value=e}}class re extends Q{#o;#i=!1;constructor(e){super(e),this.#o=e,this.#i=e.multiple}get val(){const e=[];return[...this.#o.querySelectorAll("option")].filter((e=>e.selected)).forEach((t=>{e.push(t.value)})),this.#i?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,[...this.#o.querySelectorAll("option")].forEach((t=>{e.indexOf(t.value)>-1?t.selected=!0:t.selected=!1}))}}class ne extends Q{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value||""}set val(e){this.#o.value=e}}const ae=e=>{let t=[...(e||document).querySelectorAll("input,select,textarea")],r={};return t.forEach((e=>{const t=e.getAttribute("name");if(t){let n=!1;switch((e=>e.tagName.toLowerCase())(e)){case"input":switch(e.type){case"radio":n=new X(e);break;case"checkbox":n=new ee(e);break;default:n=new te(e)}break;case"select":n=new re(e);break;case"textarea":n=new ne(e);break;default:console.warn("handler missing:",t,"for",e.tagName.toLowerCase(),e)}n&&(N.add(e,t,n),Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:()=>n.val,set:e=>{n.val!==e&&(n.val=e)}}))}})),r};function se(e,t,r){let n=ae(r);e[t]=Object.assign({},n),V(e,t),h(n,e[t]),[...r.querySelectorAll("input, textarea, select")].forEach((r=>{v(r,"keyup",(r=>{e[t].notify()})),v(r,"change",(r=>{e[t].notify()})),v(r,"select",(r=>{e[t].notify()}))}))}return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.microcomponents=t():e.microcomponents=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return e&&e.constructor&&e.constructor===Object}function n(e){let t={};return[...Object.keys(e)].sort().forEach((s=>{r(e[s])?t[s]=n(e[s]):t[s]=e[s]})),t}function s(e,t=!0){let r={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const n=s(e[t],!1);for(const e in n)r[t+"."+e]=n[e]}else r[t]=e[t]})),t?n(r):r}function a(e,t){return JSON.stringify(s(e))===JSON.stringify(s(t))}function o(e,t={}){let r=e.constructor===String?e.split("."):e;if(t&&r[0]&&t[r[0]])return t[r[0]].constructor===Object&&r.length>1?o(r.splice(1),t[r[0]]):t[r[0]];console.warn("ns",r[0],"not in",t)}function c(e,t){var n=Array.from(arguments);if(n.length>2){for(;n.length>1;)n[0]=c(n[0],n[1]),n.splice(1,1);return n[0]}if("string"==typeof e)e.match(/\{[^\{\}]*\}/g)?.forEach((function(r){var n=o(r.substring(1,r.length-1),t);void 0!==n&&(e=e.replace(r,n))}));else if(r(e))switch(e.constructor){case Object:Object.keys(e).forEach((function(r){e.hasOwnProperty(r)&&(e[r]=c(e[r],t))}));break;case Array:e.forEach((function(r,n,s){s[n]=c(e[n],t)}))}return e}function i(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("")}function l(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}function u(e){let t=document.createElement("template");return e=e.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi,"<$1$2></$1>"),t.innerHTML=e,t.content.normalize(),Array.from(t.content.childNodes)}function f(e,t){const r=Object.getOwnPropertyDescriptors(e);for(const[e,n]of Object.entries(r))("get"in n||"set"in n)&&Object.defineProperty(t,e,n)}e.r(t),e.d(t,{$d:()=>U,$t:()=>Y,DC:()=>_,MC:()=>x,McBase:()=>k,McEvent:()=>p,addListener:()=>v,autoload:()=>L,copyGettersSetters:()=>f,debounce:()=>l,deepEqual:()=>a,defineCE:()=>$,flattenObject:()=>s,formValues:()=>se,getCE:()=>P,htmlToElements:()=>u,isNativeObject:()=>r,kebabToPascal:()=>i,nameSpace:()=>o,observe:()=>B,parse:()=>c,removeListener:()=>w,sortObject:()=>n});var h=new Function("try {return this===window;}catch(e){ return false;}");let d=new Set;h()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>d.add(e)));class p{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var m=new Function("try {return this===window;}catch(e){ return false;}");let b=new Set;function g(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function y(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function E(e){return e&&e instanceof HTMLElement}function v(e,t,r,n=!1,s=!1){let a={once:!1};n&&(a.capture=n),s&&(a.once=s),e.addEventListener(t,r,a)}function w(e,t,r){e.removeEventListener(t,r)}function O(e,t,r={}){let n=e;if(!n._mc){let t=_?.debug;_.debug=!1,n._mc=new _(e),_.debug=t,delete n._mc._mc}const s=n._mc;return t.length&&!s[t]&&(s[t]=r,e instanceof HTMLElement&&!e.getAttribute("_mc")&&e.setAttribute("_mc","")),r}function S(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function A(e,t,r={},n="l"){let s=e?._mc;if(!s)return;let a=t instanceof p?new p(t.type,t.data,"l"):new p(t,r,"l"),o="string"!=typeof t?t:new p(t,r,n);[...Object.values(s)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(a)})),/[ud]/.test(o.bubble)&&j(e,o)}function j(e,t){/[ud]/.test(t.bubble)&&setTimeout((()=>{if(-1===t.bubble.indexOf("l")&&(t.bubble+="l"),t.bubble.indexOf("u")>-1){let r=y(e,"",!0)?.[0].target;r&&_.trigger(r,t)}t.bubble.indexOf("d")>-1&&new Set(e._mc.children().map((e=>e?.target))).forEach((e=>{e&&_.trigger(e,t)}))}),0)}m()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>b.add(e)));class k{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==_&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!m()||e.constructor===_)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let s=/^one/.test(n),a=n.replace(/^on[e]{0,1}/,""),o=a.toLowerCase();s&&Object.defineProperty(e,"on"+a,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),b.has("on"+o)&&v(t,o,(e=>{r.trigger(a,e)}),!1,s)}))}}(this)}get target(){return this.#n.deref()}}class x extends k{_mc={};constructor(e){super(e)}static trigger=A;trigger(e,t={},r="l"){let n=this;if(n.constructor===x||n.constructor===_){let s=e instanceof p?new p(e.type,e.data,"l"):new p(e,t,"l"),a="string"!=typeof e?e:new p(e,t,r);return[...Object.getOwnPropertyNames(n)].forEach((e=>{n[e]?.trigger&&"function"==typeof n[e]?.trigger&&n[e]?.trigger(s)})),void(/[ud]/.test(a.bubble)&&j(n.target,a))}if(n instanceof x||n instanceof _){const n=this,s="string"!=typeof e?e:new p(e,t,r),a="on"+s.type[0].toUpperCase()+s.type.slice(1);if(s.bubble.indexOf("l")>-1&&(s.immediateStopped||"function"!=typeof n[a]||(n[a](s),n.hasOwnProperty(a)&&delete n[a])),s.stopped||"l"===s.bubble)return n;/[ud]/.test(s.bubble)&&j(n.target,s)}}}class _ extends k{_mc={};constructor(e,t=!1){super(e)}static add=O;static remove=S;static trigger=A;trigger(e,t={},r){x.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return E(t)?y(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return E(t)?y(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!E(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const s=g([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),s}descendants(e=""){let t=this?.target;return E(t)?g([...t.querySelectorAll("*[_mc]")],e):[]}}let T=null;function N(){[...document.querySelectorAll(":not(:defined)")].filter((e=>!!e&&!document.head.querySelector(`script[${e.tagName.toLowerCase()}]`))).forEach((e=>{const t=e.tagName.toLowerCase(),r="/"+t.split("-").join("/")+".js",n=document.createElement("script");n.setAttribute("src",r),n.setAttribute("blocking","render"),n.setAttribute("type","module"),n.setAttribute(t,""),n.onerror=()=>{console.error("could not load Custom Element code from",r)},document.head.append(n)})),[...document.querySelectorAll('[_mc]:not([_mc=""]')].filter((e=>!!e)).forEach((e=>{const t=e.getAttribute("_mc")?.split(" ").filter((e=>!!e&&!document.head.querySelector(`script[${e}]`)));t?.forEach((e=>{const t=document.createElement("script"),r="/"+e.split("-").join("/")+".js";t.setAttribute("src",r),t.setAttribute("blocking","render"),t.async=!0,t.setAttribute("type","module"),t.setAttribute(e,""),t.onload=()=>{setTimeout((function(){const t=document.createElement("script"),n=r;t.async=!0,t.setAttribute("type","module");const s=`\nimport _ from "${n}";\nimport {DC} from "./microcomponents.js";\n\n//console.log('use importFileName', '${n}');\n// console.log('use elementName', '${e}');\n\nconst elements = Array.from(document.querySelectorAll('[_mc*="${e}"]')).filter( element => element instanceof HTMLElement );\n\n// console.log('elements', elements);\nelements.forEach((element) => {\n\t// console.log('DC, element,class', DC, element, _);\n\tDC.add(element, _.name, new _(element));\n\telement.setAttribute('_mc', element.getAttribute('_mc').replace('${e}', '').replace( /ww/g, ' ').trim());\n});\nsetTimeout( () => {\n\t// console.log('remove callback script tag', '${e}'); \n\tdocument.body.querySelector('script[${e}]')?.remove();\n},0);\n`;t.innerHTML=s,document.body.append(t)}),0)},t.onerror=()=>{console.error("could not load DOM Component code from",r)},document.head.append(t)}))}))}new Map,new Map;let C=!1;function L(e=!0){return e?(C=e,T=new MutationObserver(N),setTimeout((()=>{T.observe(document.body,{childList:!0,subtree:!0}),N()}),5),C):(T?.disconnect(),T=null,C)}class M extends HTMLElement{constructor(){super()}connectedCallback(){_.trigger(this,"Connected")}disconnectedCallback(){_.trigger(this,"Disconnected")}adoptedCallback(){_.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){_.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function $(e,t,r=[]){if(customElements.get(e))return void console.warn(`IGNORED: Custom element "${e}" is already defined!`);if(!e.includes("-"))throw new Error('createCustomElement: tagName must contain at least one hyphen ("-").');let n=i(e);customElements.define(e,function(e,t){return Object.defineProperty(t,"name",{value:e})}(n,class extends M{instance;constructor(e){super();let r=new t(this,e);_.add(this,n,r)}static get observedAttributes(){return r}}))}function P(e){return customElements.get(e)}function H(e){return null!=e&&"object"==typeof e}function q(e){let t=new Set,r=/\{[^\{\}]*\}/g;return e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(r))).forEach((n=>{new Set(e.getAttribute(n)?.match(r)).forEach((e=>t.add(e.replace(/[\{\}]/g,""))))})),[...e.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(r))).forEach((e=>{(e.nodeValue||"").match(r).forEach((e=>{t.add(e.replace(/[\{\}]/g,""))}))})),[...t].map((e=>e.replace(/[\{\}]/g,"")))}const D=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class I extends _{data={};oldDisplay="";constructor(e){super(e);let t=this;q(e).forEach((e=>t.data[e]="")),B(t),t.#s(),delete t._mc}#s(){let e=this,t=e.target,r=!1;t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(t.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var s;e.data.observe((s=t.getAttribute(r),e=>{let a=s;n.forEach((t=>{a=a.replace(t,e[t.replace(/[\{\}]/g,"")])})),t.setAttribute(r,a)}))})),[...t.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((n=>{r=!0;let s=new Set(n.nodeValue.match(/\{[^\{\}]*\}/g));var a;e.data.observe((a=n.nodeValue,r=>{let o=a;s.forEach((e=>{o=o.replace(e,r[e.replace(/[\{\}]/g,"")])})),Object.keys(r).some((e=>!!r[e]))&&(e.oldDisplay?t.style=e.oldDisplay:t.removeAttribute("style"),delete e.oldDisplay),n.nodeValue=o})),e.oldDisplay=t.getAttribute("style)")||"",r&&!D.includes(t.constructor)&&"FIELDSET"!==t.tagName&&(t.style.display="none")}))}onData(e){let t=this,r={};Object.keys(e.data).forEach((n=>{t.data.hasOwnProperty(n)&&(r[n]=e.data[n])})),JSON.stringify(r)!==JSON.stringify(t.data)&&Object.assign(t.data,r)}}const B=(e,t)=>((t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return e;let r,n=e[t];if(!n.prototype)switch(typeof n){case"string":r=String;break;case"number":r=Number;break;case"boolean":r=Boolean;break;case"object":r=n instanceof Array?Array:Object;break;default:return}let o=class extends r{#a=!0;constructor(e){super(e),this.constructor.callbacks=[],H(e)&&Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]}))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this;if(H(t.valueOf())){!function(e){var t;(t=e,(t instanceof HTMLElement?[t]:[]).concat([...t.querySelectorAll("*")]).filter((e=>!!q(e).length)).filter((e=>"STYLE"!==e.tagName))).forEach((e=>{e?._mc?._placeholders||_.add(e,"_placeholders",new I(e))}))}(e);const r=[...e.querySelectorAll("[_mc]")].filter((e=>!!e?._mc?._placeholders)),n=function(e){let t=s(e);r.forEach((e=>{e&&e._mc.trigger("data",t)}))};t.constructor.callbacks.push(n),t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf(),t);return this}notify(e){let t=this,r=H(t.valueOf())&&t.valueOf()instanceof Array==0?structuredClone(Object.assign({},t)):t.valueOf();return void 0!==e&&(t.#a=e),t.constructor.callbacks.forEach((e=>{e(r)})),t}},c=new o(n);Object.defineProperty(e,t,{enumerable:!0,get(){if(H(c.valueOf())){let e=structuredClone(Object.assign({},c));setTimeout(l((function(){a(structuredClone(Object.assign({},c)),e)||c.notify()}),0),0)}return c},set(e){if(typeof e==typeof c.valueOf())if(H(c.valueOf())&&c.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},c));c instanceof o==0&&(c=new o(structuredClone(Object.assign({},e))),f(e,c),c.seal()),Object.assign(c,e),setTimeout(l((function(){a(structuredClone(Object.assign({},c)),t)||c.notify()}),0),0)}else{let t=c.valueOf(),r=c.constructor.callbacks;c=new o(e),c.constructor.callbacks=r,e!==t&&c.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof c.valueOf(),c,"- CANNOT BECOME:",typeof e)}}),e[t]=n})),e),V=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},z=e=>{let t=U("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let s;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":s=new J(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"select":s=new G(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"textarea":s=new R(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class F{constructor(e){}}class J extends F{#o;#e;#c;constructor(e,t){super(e),this.#o=e,this.#e=e.type,this.#c=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=U(`input[type="radio"][name="${this.#o.getAttribute("name")}"]`,this.#c).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#o.checked;default:return t.#o.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=`input[type="radio"][name="${this.#o.getAttribute("name")}"]`,n=U(r,this.#c);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const s=n.filter((t=>t.getAttribute("value")===e));if(!s.length)return;return void(s.array[0].checked=!0);case"checkbox":t.#o.checked=e;break;default:t.#o.value=e}}}class G extends F{#o;#i=!1;constructor(e){super(e),this.#o=e,this.#i="select-multiple"===e.type}get val(){const e=[];return U(this.#o.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#i?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,U(this.#o.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class R extends F{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value}set val(e){this.#o.value=e}}class W{#l=new Set;get set(){return this.#l}get array(){return Array.from(this.#l)}set set(e){this.#l=e}get length(){return this.#l.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new Z;return this.#l.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return U(e,t).forEach((e=>{r.#l.add(e)})),r}addClass(...e){return e=V(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=U(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=U(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=U(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{U(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=U(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=U([...n]),e){let n=U(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=U([...n]),e){let n=U(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,s=!1;return e&&(s=U(e,t)),r.#l.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=U([...n]),e&&r.filter((e=>s.has(e))),r}has(e){return this.#l.has(e)}hasClass(...e){return e=V(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=U([...n]),e){let n=U(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),s=r.indexOf(e)+1;s<r.length&&n.add(r.at(s))}})),r=U([...n]),e){let n=U(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#l.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){w(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let s=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(s,Array.from(arguments))}return o.cb=t,s.forEach((e=>{a.forEach((function(t){v(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(n,Array.from(arguments))}return a.cb=t,n.forEach((e=>{s.forEach((function(t){v(e,t,a,r,!0)}))})),a}parent(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=U([...n]),e){let n=U(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=U([...n]),e){let n=U(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=U(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),s=r.indexOf(e)-1;s>-1&&n.add(r.at(s))}})),r=U([...n]),e){let n=U(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=V(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=V(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,s=!1){let a,o={bubbles:r,cancelable:n,composed:s},c=e.indexOf(" ")>-1?e.split(" "):[e];return this.#l.forEach((e=>{c.forEach((function(r){a=new Event(r,o),a.data=t,e.dispatchEvent(a)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,s=z(r.array[0]);var a;return e?null!=(a=e)&&"object"==typeof a?(Object.assign(s,e),n=r):"string"==typeof e&&(void 0===t?n=s[e]:(s[e]=t,n=r)):n=Object.assign({},s),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=z(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return U(this.array.at(e))}concat(e){let t=this;return(e instanceof W?e.array:e).forEach((e=>{t.#l.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#l=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#l.add(e)})),this}shift(){let e=this,t=e.#l.size?e.array[0]:void 0;return t&&e.#l.delete(t),t}slice(e,t){return U(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),U(n)}}class Z{#l=new Set;get set(){return this.#l}get array(){return Array.from(this.#l)}set set(e){this.#l=e}get length(){return this.#l.size}set length(e){}constructor(e,t=document.body){if(!e)return this;U(e,t).forEach((e=>{Y(e).forEach((e=>{this.#l.add(e)}))}))}$d(e,t=document.body){let r=new W,n=new Set,s=!!e||!1,a=new Set;return s&&(a=U(e,t).set),this.#l.forEach((e=>{s&&!a.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}descendants(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}first(e){let t=this,r=new Set;return t.#l.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#l.has(e)}last(e){let t=this,r=new Set;return t.#l.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#l.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);Y([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){w(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(n,Array.from(arguments))}return a.cb=t,n.forEach((e=>{s.forEach((function(t){v(e._tg,`[TB]${t}`,a,!1,r)}))})),a}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(r,Array.from(arguments))}return s.cb=t,r.forEach((e=>{n.forEach((function(t){v(e._tg,`[TB]${t}`,s,!1,!0)}))})),s}parent(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}parents(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}prev(e){let t=this,r=new Set;return t.#l.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);Y([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return Y(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#l.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return Y(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#l=new Set(e),t}push(e){return this.#l.add(e),this}shift(){let e=this.array.shift();return this.#l.delete(e),e}slice(e,t){return Y(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return Y(n)}}const U=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{U(e,t).forEach((e=>{r.add(e)}))})),new W([...r])):new W(e,t)},Y=(e,t=document)=>U(e,t).$t();class K{constructor(e){}}class Q extends K{#o;constructor(e){super(e),this.#o=e}get val(){return new FormData(this.#o.form).get(this.#o.name)}set val(e){[...this.#o.form.querySelectorAll(`input[type="radio"][name="${this.#o.name}"]`)].filter((t=>t.getAttribute("value")===e)).shift().checked=!0}}class X extends K{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.checked}set val(e){this.#o.checked=e}}class ee extends K{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value}set val(e){this.#o.value=e}}class te extends K{#o;#i=!1;constructor(e){super(e),this.#o=e,this.#i=e.multiple}get val(){const e=[];return[...this.#o.querySelectorAll("option")].filter((e=>e.selected)).forEach((t=>{e.push(t.value)})),this.#i?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,[...this.#o.querySelectorAll("option")].forEach((t=>{e.indexOf(t.value)>-1?t.selected=!0:t.selected=!1}))}}class re extends K{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value||""}set val(e){this.#o.value=e}}const ne=e=>{let t=[...(e||document).querySelectorAll("input,select,textarea")],r={};return t.forEach((e=>{const t=e.getAttribute("name");if(t){let n=!1;switch((e=>e.tagName.toLowerCase())(e)){case"input":switch(e.type){case"radio":n=new Q(e);break;case"checkbox":n=new X(e);break;default:n=new ee(e)}break;case"select":n=new te(e);break;case"textarea":n=new re(e);break;default:console.warn("handler missing:",t,"for",e.tagName.toLowerCase(),e)}n&&(_.add(e,t,n),Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:()=>n.val,set:e=>{n.val!==e&&(n.val=e)}}))}})),r};function se(e,t,r){let n=ne(r);e[t]=Object.assign({},n),B(e,t),f(n,e[t]),[...r.querySelectorAll("input, textarea, select")].forEach((r=>{v(r,"keyup",(r=>{e[t].notify()})),v(r,"change",(r=>{e[t].notify()})),v(r,"select",(r=>{e[t].notify()}))}))}return t})()));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.observables=t():e.observables=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){let t={};return[...Object.keys(e)].sort().forEach((n=>{var o;(o=e[n])&&o.constructor&&o.constructor===Object?t[n]=r(e[n]):t[n]=e[n]})),t}function n(e,t=!0){let o={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const r=n(e[t],!1);for(const e in r)o[t+"."+e]=r[e]}else o[t]=e[t]})),t?r(o):o}function o(e,t){return JSON.stringify(n(e))===JSON.stringify(n(t))}function c(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}e.r(t),e.d(t,{observe:()=>S});var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;a()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>s.add(e)));class i{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var l=new Function("try {return this===window;}catch(e){ return false;}");let u=new Set;function f(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function d(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function p(e){return e&&e instanceof HTMLElement}function b(e,t,r={}){let n=e;if(!n._mc){let t=E?.debug;E.debug=!1,n._mc=new E(e),E.debug=t,delete n._mc._mc}const o=n._mc;return t.length&&!o[t]&&(o[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function g(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function m(e,t,r={},n="l"){let o=e?._mc;if(!o)return;let c=t instanceof i?new i(t.type,t.data,"l"):new i(t,r,"l"),a="string"!=typeof t?t:new i(t,r,n);[...Object.values(o)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(c)})),/[ud]/.test(a.bubble)&&h(e,a)}function h(e,t){/[ud]/.test(t.bubble)&&setTimeout((()=>{if(-1===t.bubble.indexOf("l")&&(t.bubble+="l"),t.bubble.indexOf("u")>-1){let r=d(e,"",!0)?.[0].target;r&&E.trigger(r,t)}t.bubble.indexOf("d")>-1&&new Set(e._mc.children().map((e=>e?.target))).forEach((e=>{e&&E.trigger(e,t)}))}),0)}l()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>u.add(e)));class y{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==E&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!l()||e.constructor===E)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let o=/^one/.test(n),c=n.replace(/^on[e]{0,1}/,""),a=c.toLowerCase();o&&Object.defineProperty(e,"on"+c,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),u.has("on"+a)&&function(e,t,r,n=!1,o=!1){let c={once:!1};n&&(c.capture=n),o&&(c.once=o),e.addEventListener(t,r,c)}(t,a,(e=>{r.trigger(c,e)}),!1,o)}))}}(this)}get target(){return this.#n.deref()}}class O extends y{_mc={};constructor(e){super(e)}static trigger=m;trigger(e,t={},r="l"){let n=this;if(n.constructor===O||n.constructor===E){let o=e instanceof i?new i(e.type,e.data,"l"):new i(e,t,"l"),c="string"!=typeof e?e:new i(e,t,r);return[...Object.getOwnPropertyNames(n)].forEach((e=>{n[e]?.trigger&&"function"==typeof n[e]?.trigger&&n[e]?.trigger(o)})),void(/[ud]/.test(c.bubble)&&h(n.target,c))}if(n instanceof O||n instanceof E){const n=this,o="string"!=typeof e?e:new i(e,t,r),c="on"+o.type[0].toUpperCase()+o.type.slice(1);if(o.bubble.indexOf("l")>-1&&(o.immediateStopped||"function"!=typeof n[c]||(n[c](o),n.hasOwnProperty(c)&&delete n[c])),o.stopped||"l"===o.bubble)return n;/[ud]/.test(o.bubble)&&h(n.target,o)}}}class E extends y{_mc={};constructor(e,t=!1){super(e)}static add=b;static remove=g;static trigger=m;trigger(e,t={},r){O.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return p(t)?d(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return p(t)?d(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!p(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const o=f([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),o}descendants(e=""){let t=this?.target;return p(t)?f([...t.querySelectorAll("*[_mc]")],e):[]}}function v(e){return null!=e&&"object"==typeof e}function w(e){let t=new Set,r=/\{[^\{\}]*\}/g;return e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(r))).forEach((n=>{new Set(e.getAttribute(n)?.match(r)).forEach((e=>t.add(e.replace(/[\{\}]/g,""))))})),[...e.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(r))).forEach((e=>{(e.nodeValue||"").match(r).forEach((e=>{t.add(e.replace(/[\{\}]/g,""))}))})),[...t].map((e=>e.replace(/[\{\}]/g,"")))}new Map;const j=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class _ extends E{data={};oldDisplay="";constructor(e){super(e);let t=this;w(e).forEach((e=>t.data[e]="")),S(t),t.#o(),delete t._mc}#o(){let e=this,t=e.target,r=!1;t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(t.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var o;e.data.observe((o=t.getAttribute(r),e=>{let c=o;n.forEach((t=>{c=c.replace(t,e[t.replace(/[\{\}]/g,"")])})),t.setAttribute(r,c)}))})),[...t.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((n=>{r=!0;let o=new Set(n.nodeValue.match(/\{[^\{\}]*\}/g));var c;e.data.observe((c=n.nodeValue,r=>{let a=c;o.forEach((e=>{a=a.replace(e,r[e.replace(/[\{\}]/g,"")])})),Object.keys(r).some((e=>!!r[e]))&&(e.oldDisplay?t.style=e.oldDisplay:t.removeAttribute("style"),delete e.oldDisplay),n.nodeValue=a})),e.oldDisplay=t.getAttribute("style)")||"",r&&!j.includes(t.constructor)&&"FIELDSET"!==t.tagName&&(t.style.display="none")}))}onData(e){let t=this,r={};Object.keys(e.data).forEach((n=>{t.data.hasOwnProperty(n)&&(r[n]=e.data[n])})),JSON.stringify(r)!==JSON.stringify(t.data)&&Object.assign(t.data,r)}}const S=(e,t)=>((t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return e;let r,a=e[t];if(!a.prototype)switch(typeof a){case"string":r=String;break;case"number":r=Number;break;case"boolean":r=Boolean;break;case"object":r=a instanceof Array?Array:Object;break;default:return}let s=class extends r{#c=!0;constructor(e){super(e),this.constructor.callbacks=[],v(e)&&Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]}))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this;if(v(t.valueOf())){!function(e){var t;(t=e,(t instanceof HTMLElement?[t]:[]).concat([...t.querySelectorAll("*")]).filter((e=>!!w(e).length)).filter((e=>"STYLE"!==e.tagName))).forEach((e=>{e?._mc?._placeholders||E.add(e,"_placeholders",new _(e))}))}(e);const r=[...e.querySelectorAll("[_mc]")].filter((e=>!!e?._mc?._placeholders)),o=function(e){let t=n(e);r.forEach((e=>{e&&e._mc.trigger("data",t)}))};t.constructor.callbacks.push(o),t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf(),t);return this}notify(e){let t=this,r=v(t.valueOf())&&t.valueOf()instanceof Array==0?structuredClone(Object.assign({},t)):t.valueOf();return void 0!==e&&(t.#c=e),t.constructor.callbacks.forEach((e=>{e(r)})),t}},i=new s(a);Object.defineProperty(e,t,{enumerable:!0,get(){if(v(i.valueOf())){let e=structuredClone(Object.assign({},i));setTimeout(c((function(){o(structuredClone(Object.assign({},i)),e)||i.notify()}),0),0)}return i},set(e){if(typeof e==typeof i.valueOf())if(v(i.valueOf())&&i.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},i));i instanceof s==0&&(i=new s(structuredClone(Object.assign({},e))),function(e,t){const r=Object.getOwnPropertyDescriptors(e);for(const[e,n]of Object.entries(r))("get"in n||"set"in n)&&Object.defineProperty(t,e,n)}(e,i),i.seal()),Object.assign(i,e),setTimeout(c((function(){o(structuredClone(Object.assign({},i)),t)||i.notify()}),0),0)}else{let t=i.valueOf(),r=i.constructor.callbacks;i=new s(e),i.constructor.callbacks=r,e!==t&&i.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof i.valueOf(),i,"- CANNOT BECOME:",typeof e)}}),e[t]=a})),e);return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.observables=t():e.observables=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){let t={};return[...Object.keys(e)].sort().forEach((n=>{var o;(o=e[n])&&o.constructor&&o.constructor===Object?t[n]=r(e[n]):t[n]=e[n]})),t}function n(e,t=!0){let o={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const r=n(e[t],!1);for(const e in r)o[t+"."+e]=r[e]}else o[t]=e[t]})),t?r(o):o}function o(e,t){return JSON.stringify(n(e))===JSON.stringify(n(t))}function c(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}e.r(t),e.d(t,{observe:()=>S});var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;a()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>s.add(e)));class i{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var l=new Function("try {return this===window;}catch(e){ return false;}");let u=new Set;function f(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function p(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function d(e){return e&&e instanceof HTMLElement}function b(e,t,r={}){let n=e;if(!n._mc){let t=E?.debug;E.debug=!1,n._mc=new E(e),E.debug=t,delete n._mc._mc}const o=n._mc;return t.length&&!o[t]&&(o[t]=r,e instanceof HTMLElement&&!e.getAttribute("_mc")&&e.setAttribute("_mc","")),r}function g(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function m(e,t,r={},n="l"){let o=e?._mc;if(!o)return;let c=t instanceof i?new i(t.type,t.data,"l"):new i(t,r,"l"),a="string"!=typeof t?t:new i(t,r,n);[...Object.values(o)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(c)})),/[ud]/.test(a.bubble)&&h(e,a)}function h(e,t){/[ud]/.test(t.bubble)&&setTimeout((()=>{if(-1===t.bubble.indexOf("l")&&(t.bubble+="l"),t.bubble.indexOf("u")>-1){let r=p(e,"",!0)?.[0].target;r&&E.trigger(r,t)}t.bubble.indexOf("d")>-1&&new Set(e._mc.children().map((e=>e?.target))).forEach((e=>{e&&E.trigger(e,t)}))}),0)}l()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>u.add(e)));class y{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==E&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!l()||e.constructor===E)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let o=/^one/.test(n),c=n.replace(/^on[e]{0,1}/,""),a=c.toLowerCase();o&&Object.defineProperty(e,"on"+c,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),u.has("on"+a)&&function(e,t,r,n=!1,o=!1){let c={once:!1};n&&(c.capture=n),o&&(c.once=o),e.addEventListener(t,r,c)}(t,a,(e=>{r.trigger(c,e)}),!1,o)}))}}(this)}get target(){return this.#n.deref()}}class O extends y{_mc={};constructor(e){super(e)}static trigger=m;trigger(e,t={},r="l"){let n=this;if(n.constructor===O||n.constructor===E){let o=e instanceof i?new i(e.type,e.data,"l"):new i(e,t,"l"),c="string"!=typeof e?e:new i(e,t,r);return[...Object.getOwnPropertyNames(n)].forEach((e=>{n[e]?.trigger&&"function"==typeof n[e]?.trigger&&n[e]?.trigger(o)})),void(/[ud]/.test(c.bubble)&&h(n.target,c))}if(n instanceof O||n instanceof E){const n=this,o="string"!=typeof e?e:new i(e,t,r),c="on"+o.type[0].toUpperCase()+o.type.slice(1);if(o.bubble.indexOf("l")>-1&&(o.immediateStopped||"function"!=typeof n[c]||(n[c](o),n.hasOwnProperty(c)&&delete n[c])),o.stopped||"l"===o.bubble)return n;/[ud]/.test(o.bubble)&&h(n.target,o)}}}class E extends y{_mc={};constructor(e,t=!1){super(e)}static add=b;static remove=g;static trigger=m;trigger(e,t={},r){O.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return d(t)?p(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return d(t)?p(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!d(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const o=f([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),o}descendants(e=""){let t=this?.target;return d(t)?f([...t.querySelectorAll("*[_mc]")],e):[]}}function w(e){return null!=e&&"object"==typeof e}function v(e){let t=new Set,r=/\{[^\{\}]*\}/g;return e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(r))).forEach((n=>{new Set(e.getAttribute(n)?.match(r)).forEach((e=>t.add(e.replace(/[\{\}]/g,""))))})),[...e.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(r))).forEach((e=>{(e.nodeValue||"").match(r).forEach((e=>{t.add(e.replace(/[\{\}]/g,""))}))})),[...t].map((e=>e.replace(/[\{\}]/g,"")))}new Map,new Map;const j=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class _ extends E{data={};oldDisplay="";constructor(e){super(e);let t=this;v(e).forEach((e=>t.data[e]="")),S(t),t.#o(),delete t._mc}#o(){let e=this,t=e.target,r=!1;t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(t.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var o;e.data.observe((o=t.getAttribute(r),e=>{let c=o;n.forEach((t=>{c=c.replace(t,e[t.replace(/[\{\}]/g,"")])})),t.setAttribute(r,c)}))})),[...t.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((n=>{r=!0;let o=new Set(n.nodeValue.match(/\{[^\{\}]*\}/g));var c;e.data.observe((c=n.nodeValue,r=>{let a=c;o.forEach((e=>{a=a.replace(e,r[e.replace(/[\{\}]/g,"")])})),Object.keys(r).some((e=>!!r[e]))&&(e.oldDisplay?t.style=e.oldDisplay:t.removeAttribute("style"),delete e.oldDisplay),n.nodeValue=a})),e.oldDisplay=t.getAttribute("style)")||"",r&&!j.includes(t.constructor)&&"FIELDSET"!==t.tagName&&(t.style.display="none")}))}onData(e){let t=this,r={};Object.keys(e.data).forEach((n=>{t.data.hasOwnProperty(n)&&(r[n]=e.data[n])})),JSON.stringify(r)!==JSON.stringify(t.data)&&Object.assign(t.data,r)}}const S=(e,t)=>((t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return e;let r,a=e[t];if(!a.prototype)switch(typeof a){case"string":r=String;break;case"number":r=Number;break;case"boolean":r=Boolean;break;case"object":r=a instanceof Array?Array:Object;break;default:return}let s=class extends r{#c=!0;constructor(e){super(e),this.constructor.callbacks=[],w(e)&&Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]}))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this;if(w(t.valueOf())){!function(e){var t;(t=e,(t instanceof HTMLElement?[t]:[]).concat([...t.querySelectorAll("*")]).filter((e=>!!v(e).length)).filter((e=>"STYLE"!==e.tagName))).forEach((e=>{e?._mc?._placeholders||E.add(e,"_placeholders",new _(e))}))}(e);const r=[...e.querySelectorAll("[_mc]")].filter((e=>!!e?._mc?._placeholders)),o=function(e){let t=n(e);r.forEach((e=>{e&&e._mc.trigger("data",t)}))};t.constructor.callbacks.push(o),t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf(),t);return this}notify(e){let t=this,r=w(t.valueOf())&&t.valueOf()instanceof Array==0?structuredClone(Object.assign({},t)):t.valueOf();return void 0!==e&&(t.#c=e),t.constructor.callbacks.forEach((e=>{e(r)})),t}},i=new s(a);Object.defineProperty(e,t,{enumerable:!0,get(){if(w(i.valueOf())){let e=structuredClone(Object.assign({},i));setTimeout(c((function(){o(structuredClone(Object.assign({},i)),e)||i.notify()}),0),0)}return i},set(e){if(typeof e==typeof i.valueOf())if(w(i.valueOf())&&i.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},i));i instanceof s==0&&(i=new s(structuredClone(Object.assign({},e))),function(e,t){const r=Object.getOwnPropertyDescriptors(e);for(const[e,n]of Object.entries(r))("get"in n||"set"in n)&&Object.defineProperty(t,e,n)}(e,i),i.seal()),Object.assign(i,e),setTimeout(c((function(){o(structuredClone(Object.assign({},i)),t)||i.notify()}),0),0)}else{let t=i.valueOf(),r=i.constructor.callbacks;i=new s(e),i.constructor.callbacks=r,e!==t&&i.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof i.valueOf(),i,"- CANNOT BECOME:",typeof e)}}),e[t]=a})),e);return t})()));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.selectors=t():e.selectors=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{$d:()=>E,$t:()=>m});var r=new Function("try {return this===window;}catch(e){ return false;}");let n=new Set;r()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>n.add(e)));var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;function i(e,t,r,n=!1,a=!1){let s={once:!1};n&&(s.capture=n),a&&(s.once=a),e.addEventListener(t,r,s)}function o(e,t,r){e.removeEventListener(t,r)}a()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>s.add(e))),new Map;const c=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},l=e=>{let t=E("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new f(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new u(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new d(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class h{constructor(e){}}class f extends h{#e;#t;#r;constructor(e,t){super(e),this.#e=e,this.#t=e.type,this.#r=t}get val(){let e,t=this;switch(t.#t){case"radio":const r=E(`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,this.#r).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#e.checked;default:return t.#e.value}return""}set val(e){let t=this;switch(t.#t){case"radio":const r=`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,n=E(r,this.#r);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const a=n.filter((t=>t.getAttribute("value")===e));if(!a.length)return;return void(a.array[0].checked=!0);case"checkbox":t.#e.checked=e;break;default:t.#e.value=e}}}class u extends h{#e;#n=!1;constructor(e){super(e),this.#e=e,this.#n="select-multiple"===e.type}get val(){const e=[];return E(this.#e.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#n?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,E(this.#e.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class d extends h{#e;constructor(e){super(e),this.#e=e}get val(){return this.#e.value}set val(e){this.#e.value=e}}class p{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new y;return this.#a.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return E(e,t).forEach((e=>{r.#a.add(e)})),r}addClass(...e){return e=c(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=E(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{E(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,a=!1;return e&&(a=E(e,t)),r.#a.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=E([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#a.has(e)}hasClass(...e){return e=c(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)+1;a<r.length&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#a.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){o(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let a=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(a,Array.from(arguments))}return o.cb=t,a.forEach((e=>{s.forEach((function(t){i(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e,t,s,r,!0)}))})),s}parent(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)-1;a>-1&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=c(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=c(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,a=!1){let s,i={bubbles:r,cancelable:n,composed:a},o=e.indexOf(" ")>-1?e.split(" "):[e];return this.#a.forEach((e=>{o.forEach((function(r){s=new Event(r,i),s.data=t,e.dispatchEvent(s)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,a=l(r.array[0]);var s;return e?null!=(s=e)&&"object"==typeof s?(Object.assign(a,e),n=r):"string"==typeof e&&(void 0===t?n=a[e]:(a[e]=t,n=r)):n=Object.assign({},a),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=l(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return E(this.array.at(e))}concat(e){let t=this;return(e instanceof p?e.array:e).forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#a=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#a.add(e)})),this}shift(){let e=this,t=e.#a.size?e.array[0]:void 0;return t&&e.#a.delete(t),t}slice(e,t){return E(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),E(n)}}class y{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}set length(e){}constructor(e,t=document.body){if(!e)return this;E(e,t).forEach((e=>{m(e).forEach((e=>{this.#a.add(e)}))}))}$d(e,t=document.body){let r=new p,n=new Set,a=!!e||!1,s=new Set;return a&&(s=E(e,t).set),this.#a.forEach((e=>{a&&!s.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}descendants(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}first(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#a.has(e)}last(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);m([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){o(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e._tg,`[TB]${t}`,s,!1,r)}))})),s}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(r,Array.from(arguments))}return a.cb=t,r.forEach((e=>{n.forEach((function(t){i(e._tg,`[TB]${t}`,a,!1,!0)}))})),a}parent(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}parents(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}prev(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);m([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return m(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return m(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#a=new Set(e),t}push(e){return this.#a.add(e),this}shift(){let e=this.array.shift();return this.#a.delete(e),e}slice(e,t){return m(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return m(n)}}const E=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{E(e,t).forEach((e=>{r.add(e)}))})),new p([...r])):new p(e,t)},m=(e,t=document)=>E(e,t).$t();return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.selectors=t():e.selectors=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{$d:()=>E,$t:()=>m});var r=new Function("try {return this===window;}catch(e){ return false;}");let n=new Set;r()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>n.add(e)));var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;function i(e,t,r,n=!1,a=!1){let s={once:!1};n&&(s.capture=n),a&&(s.once=a),e.addEventListener(t,r,s)}function o(e,t,r){e.removeEventListener(t,r)}a()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>s.add(e))),new Map,new Map;const c=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},l=e=>{let t=E("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new f(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new u(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new d(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class h{constructor(e){}}class f extends h{#e;#t;#r;constructor(e,t){super(e),this.#e=e,this.#t=e.type,this.#r=t}get val(){let e,t=this;switch(t.#t){case"radio":const r=E(`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,this.#r).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#e.checked;default:return t.#e.value}return""}set val(e){let t=this;switch(t.#t){case"radio":const r=`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,n=E(r,this.#r);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const a=n.filter((t=>t.getAttribute("value")===e));if(!a.length)return;return void(a.array[0].checked=!0);case"checkbox":t.#e.checked=e;break;default:t.#e.value=e}}}class u extends h{#e;#n=!1;constructor(e){super(e),this.#e=e,this.#n="select-multiple"===e.type}get val(){const e=[];return E(this.#e.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#n?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,E(this.#e.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class d extends h{#e;constructor(e){super(e),this.#e=e}get val(){return this.#e.value}set val(e){this.#e.value=e}}class p{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new y;return this.#a.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return E(e,t).forEach((e=>{r.#a.add(e)})),r}addClass(...e){return e=c(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=E(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{E(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,a=!1;return e&&(a=E(e,t)),r.#a.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=E([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#a.has(e)}hasClass(...e){return e=c(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)+1;a<r.length&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#a.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){o(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let a=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(a,Array.from(arguments))}return o.cb=t,a.forEach((e=>{s.forEach((function(t){i(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e,t,s,r,!0)}))})),s}parent(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)-1;a>-1&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=c(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=c(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,a=!1){let s,i={bubbles:r,cancelable:n,composed:a},o=e.indexOf(" ")>-1?e.split(" "):[e];return this.#a.forEach((e=>{o.forEach((function(r){s=new Event(r,i),s.data=t,e.dispatchEvent(s)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,a=l(r.array[0]);var s;return e?null!=(s=e)&&"object"==typeof s?(Object.assign(a,e),n=r):"string"==typeof e&&(void 0===t?n=a[e]:(a[e]=t,n=r)):n=Object.assign({},a),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=l(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return E(this.array.at(e))}concat(e){let t=this;return(e instanceof p?e.array:e).forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#a=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#a.add(e)})),this}shift(){let e=this,t=e.#a.size?e.array[0]:void 0;return t&&e.#a.delete(t),t}slice(e,t){return E(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),E(n)}}class y{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}set length(e){}constructor(e,t=document.body){if(!e)return this;E(e,t).forEach((e=>{m(e).forEach((e=>{this.#a.add(e)}))}))}$d(e,t=document.body){let r=new p,n=new Set,a=!!e||!1,s=new Set;return a&&(s=E(e,t).set),this.#a.forEach((e=>{a&&!s.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}descendants(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}first(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#a.has(e)}last(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);m([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){o(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e._tg,`[TB]${t}`,s,!1,r)}))})),s}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(r,Array.from(arguments))}return a.cb=t,r.forEach((e=>{n.forEach((function(t){i(e._tg,`[TB]${t}`,a,!1,!0)}))})),a}parent(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}parents(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}prev(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);m([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return m(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return m(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#a=new Set(e),t}push(e){return this.#a.add(e),this}shift(){let e=this.array.shift();return this.#a.delete(e),e}slice(e,t){return m(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return m(n)}}const E=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{E(e,t).forEach((e=>{r.add(e)}))})),new p([...r])):new p(e,t)},m=(e,t=document)=>E(e,t).$t();return t})()));
package/public/src/MC.ts CHANGED
@@ -111,7 +111,7 @@ function add(target: HTMLElement, key: string, element = {}): any {
111
111
  if (key.length && !_mc[key]) {
112
112
  _mc[key] = element;
113
113
  // add attribute if HTMLElement
114
- if (target instanceof HTMLElement) {
114
+ if (target instanceof HTMLElement && ! target.getAttribute('_mc') ) {
115
115
  target.setAttribute('_mc', '');
116
116
  }
117
117
  }
@@ -410,46 +410,140 @@ class DC extends McBase {
410
410
  }
411
411
  }
412
412
 
413
- export { addListener, removeListener, McBase, MC, DC, McEvent };
414
-
415
413
  let observer: MutationObserver | null = null;
416
- const unresolved = new Map();
417
414
 
418
- function loadit() {
419
- document
420
- .querySelectorAll(':not(:defined),[_mc]:not([_mc=""])')
415
+ /*
416
+ unresolvedCEs (code below this comment):
417
+
418
+ a repository (a hashmap) of undefined custom elements:
419
+ the name is the tagname of the micro component (like "my-custom-component")
420
+ if they are loading, the value is a script element
421
+ if they are loaded, the entry is deleted and the browser instanciates it automatically
422
+ if they cannot be loaded, the browser will throw an error
423
+
424
+ If the custom element ( defined by its tagname, like "my-custom-component") is not defined, it will be on-demand loaded:
425
+ The file name is assumed to be "/my/custom/component.js"
426
+ The file must define a custom element via the defineCE() function included in the "elements" module.
427
+ This function is a wrapper for customElementRegistry.define(), which you can also use directly in the imported code.
428
+
429
+ In general this behaves like a custom runtime import for custom elements in the browser.
430
+ The only difference is that the micro component is loaded only when needed, and not on page load.
431
+ */
432
+
433
+ const unresolvedCEs = new Map();
434
+
435
+ /*
436
+ MCs (code below this comment):
437
+ a repository (a hashmap) of micro components:
438
+ the name is the name of the micro component (like "my-mc")
439
+ if they are loading, the value is a script element
440
+ if they are loaded, the value is the micro component class itself
441
+
442
+ This is mostly used for old style progressive enhancement:
443
+ If the micro component ( defined in the HTMLElements "_mc" attribute, like "my-mc") is not defined, it will be on-demand loaded:
444
+ The file name is assumed to be "/my/mc.js"
445
+ The file needs to have a default export, and it should be a class that extends the DC class ( since it is in a HTMLElements attribute )
446
+
447
+ In general this behaves like a custom runtime import for classes in the browser.
448
+ The only difference is that the micro component is loaded only when needed, and not on page load.
449
+ */
450
+ const MCs = new Map();
451
+
452
+ function loadUndefinedMicroComponents() {
453
+
454
+ // load unresolved custom eleents
455
+ [ ...document.querySelectorAll(':not(:defined)') ] // undefined custom elements
456
+ .filter( (element) => !!element && !document.head.querySelector(`script[${element.tagName.toLowerCase()}]`) )
421
457
  .forEach((el) => {
422
- const load: string[] = el.tagName.includes('-')
423
- ? [el.tagName.toLowerCase()]
424
- : el.getAttribute('_mc')!.trim().split(' ');
458
+ const elementName = el.tagName.toLowerCase(),
459
+ fileName: string = '/'+elementName.split('-').join('/')+'.js';
460
+ //console.log('load undefined custom element',el);
425
461
 
426
- load.forEach((elementName) => {
427
- let fileName: any = elementName.toLowerCase().split('-');
428
- fileName = fileName.join('/') + '.js';
462
+ const se: HTMLScriptElement = document.createElement('script');
429
463
 
430
- // autoload web components
431
- // TBD: _mc components
432
- if (
433
- el.tagName.includes('-') &&
434
- !unresolved.has(el.tagName.toLowerCase())
435
- ) {
436
- const se: HTMLScriptElement = document.createElement('script');
464
+ se.setAttribute('src', fileName);
465
+ se.setAttribute('blocking', 'render');
466
+ se.setAttribute('type', 'module');
467
+ se.setAttribute( elementName, '');
437
468
 
438
- unresolved.set(elementName, fileName);
469
+ se.onerror = () => {
470
+ console.error('could not load Custom Element code from', fileName);
471
+ }
439
472
 
440
- se.setAttribute('src', fileName);
441
- se.setAttribute('blocking', 'render');
442
- se.setAttribute('type', 'module');
443
- se.onload = () => {
444
- // console.info('loaded', s);
445
- unresolved.delete(elementName);
446
- //console.log(unresolved);
447
- };
473
+ //console.info('load Custom Element', elementName);
474
+ document.head.append(se);
475
+
476
+ // instanciation of the micro component will be handled by the browser automatically
477
+ // module code must define the micro component class and add it to the customElementRegistry
478
+ });
479
+
480
+ [ ...document.querySelectorAll('[_mc]:not([_mc=""]') ] // undefined DOM components
481
+ .filter( (element) => !!element )
482
+ .forEach((el) => {
483
+ const toBeLoaded = el.getAttribute('_mc')?.split(' ').filter( m => !!m && !document.head.querySelector(`script[${m}]`) );
484
+
485
+
486
+ //console.log('load undefined DOM components',toBeLoaded);
487
+
488
+ toBeLoaded?.forEach( elementName => {
489
+ const se: HTMLScriptElement = document.createElement('script'),
490
+ fileName: string = '/'+elementName.split('-').join('/')+'.js';
491
+
492
+ se.setAttribute('src', fileName);
493
+ se.setAttribute('blocking', 'render');
494
+ se.async = true;
495
+ se.setAttribute('type', 'module');
496
+ se.setAttribute( elementName, '');
497
+
498
+ se.onload = () => {
499
+ // console.info('loaded MC', elementName);
500
+
501
+ // create callback script tag
502
+ setTimeout( function(){
503
+ // create callback script tag
504
+ const se: HTMLScriptElement = document.createElement('script');
505
+ const importFileName = fileName;
506
+
507
+ se.async = true;
508
+ se.setAttribute( 'type', 'module');
509
+
510
+ const code = /*javascript*/`
511
+ import _ from "${importFileName}";
512
+ import {DC} from "./microcomponents.js";
513
+
514
+ //console.log('use importFileName', '${importFileName}');
515
+ // console.log('use elementName', '${elementName}');
516
+
517
+ const elements = Array.from(document.querySelectorAll('[_mc*="${elementName}"]')).filter( element => element instanceof HTMLElement );
518
+
519
+ // console.log('elements', elements);
520
+ elements.forEach((element) => {
521
+ // console.log('DC, element,class', DC, element, _);
522
+ DC.add(element, _.name, new _(element));
523
+ element.setAttribute('_mc', element.getAttribute('_mc').replace('${elementName}', '').replace( /\w\w/g, ' ').trim());
524
+ });
525
+ setTimeout( () => {
526
+ // console.log('remove callback script tag', '${elementName}');
527
+ document.body.querySelector('script[${elementName}]')?.remove();
528
+ },0);
529
+ `;
530
+
531
+ //console.log('before innerHTML');
532
+ se.innerHTML = code;
533
+ //console.log('after innerHTML');
534
+ //console.log( 'callback script tag', se, code );
535
+ document.body.append(se);
536
+ }, 0);
537
+
538
+ }
448
539
 
449
- document.head.append(se);
540
+ se.onerror = () => {
541
+ console.error('could not load DOM Component code from', fileName);
450
542
  }
543
+
544
+ // console.info('load DOM Micro Component', elementName);
545
+ document.head.append(se);
451
546
  });
452
- //console.log(unresolved);
453
547
  });
454
548
  }
455
549
 
@@ -463,12 +557,15 @@ export function autoload(enable: boolean = true): boolean {
463
557
  }
464
558
 
465
559
  autoloadEnabled = enable;
466
- observer = new MutationObserver(loadit);
560
+ observer = new MutationObserver(loadUndefinedMicroComponents);
467
561
 
468
562
  setTimeout(() => {
469
563
  observer!.observe(document.body, { childList: true, subtree: true });
470
- loadit();
564
+ loadUndefinedMicroComponents();
471
565
  }, 5);
472
566
 
473
567
  return autoloadEnabled;
474
568
  }
569
+
570
+ export { addListener, removeListener, McBase, MC, DC, McEvent };
571
+
@@ -169,9 +169,25 @@ setTimeout(() => {
169
169
  'font-weight: normal;',
170
170
  element,
171
171
  'font-weight: bold;',
172
- '\n\nLook up code in the debugger: test.js\n\n'
172
+ '\n\nLook up code in the debugger: test.js\n'
173
173
  );
174
174
 
175
+ let form = ( document.querySelector('test-testform') as any);
176
+ let formData = form._mc.TestTestform.data;
177
+
178
+ console.log(
179
+ "\n\n%cRight-click this object and store it as a global variable:%c \n\n %O %c %s %c %s %c %s",
180
+ 'font-weight: bold;',
181
+ 'font-weight: normal;',
182
+ formData,
183
+ 'font-weight: bold;',
184
+ '\n\nYou can then use e.g. \n\n',
185
+ 'font-weight: normal;',
186
+ ' temp0.textInput = "whatever"',
187
+ 'font-weight: bold;',
188
+ '\n\nto change the form contents.\n'
189
+ );
190
+
175
191
  // will trigger the event on all micro components contained in <my-tag>
176
192
  DC.trigger(element, 'doSomething');
177
193
  }, 500);
@@ -0,0 +1,15 @@
1
+ import { DC, defineCE, getCE } from '.././microcomponents.js';
2
+ import { Grandchild } from './grandchild.js';
3
+ defineCE('test-child', class TestChild extends DC {
4
+ constructor(target) {
5
+ super(target);
6
+ }
7
+ onConnected() {
8
+ let that = this;
9
+ for (let x = 0; x < 10; x++) {
10
+ that.target.append(new Grandchild());
11
+ }
12
+ }
13
+ });
14
+ export const Child = getCE('test-child');
15
+ //# sourceMappingURL=child.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"child.js","sourceRoot":"","sources":["../../src/test/child.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,QAAQ,CACP,YAAY,EAEZ,MAAM,SAAU,SAAQ,EAAE;IACzB,YAAY,MAAmB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED,WAAW;QACV,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,UAAW,EAAE,CAAC,CAAC;QACvC,CAAC;IACF,CAAC;CACD,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { DC, defineCE, getCE } from '.././microcomponents.js';
2
+ import { Greatgrandchild } from './greatgrandchild.js';
3
+ defineCE('test-grandchild', class TestGrandchild extends DC {
4
+ constructor(target) {
5
+ super(target);
6
+ }
7
+ onConnected() {
8
+ let that = this;
9
+ for (let x = 0; x < 2; x++) {
10
+ that.target.append(new Greatgrandchild());
11
+ }
12
+ }
13
+ });
14
+ export const Grandchild = getCE('test-grandchild');
15
+ //# sourceMappingURL=grandchild.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grandchild.js","sourceRoot":"","sources":["../../src/test/grandchild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,QAAQ,CACP,iBAAiB,EAEjB,MAAM,cAAe,SAAQ,EAAE;IAC9B,YAAY,MAAmB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED,WAAW;QACV,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,eAAgB,EAAE,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC;CACD,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC"}
@@ -1 +1,15 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.grandparent=e():t.grandparent=e()}(self,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{GrandParent:()=>S});var r=new Function("try {return this===window;}catch(e){ return false;}");let n=new Set;r()&&Object.keys(HTMLElement.prototype).filter((t=>/^on/.test(t))).forEach((t=>n.add(t)));class o{#t;#e=!1;#r=!1;constructor(t,e={},r="l"){this.#t=t,this.data=e,this.bubble=r}get type(){return this.#t}get stopped(){return this.#e}get immediateStopped(){return this.#r}stopPropagation(){this.#e=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var s=new Function("try {return this===window;}catch(e){ return false;}");let c=new Set;function i(t,e){let r=[];return t.forEach((t=>{if(t&&t instanceof HTMLElement){const n=t?._mc;!e&&n?r=r.concat(Object.values(t._mc)):e&&n&&n[e]&&r.push(n[e])}})),r}function a(t,e,r=!0){let n=[];for(;t;){if(t._mc&&(e?e&&t._mc[e]&&n.push(t._mc[e]):n=n.concat(Object.values(t._mc)),r))return n;t=t.parentNode}return n}function l(t){return t&&t instanceof HTMLElement}function u(t,e,r={}){let n=t;if(!n._mc){let e=b?.debug;b.debug=!1,n._mc=new b(t),b.debug=e,delete n._mc._mc}const o=n._mc;return e.length&&!o[e]&&(o[e]=r,t instanceof HTMLElement&&t.setAttribute("_mc","")),r}function d(t,e){if(!e)return;const r=t?._mc||{};r&&r[e]&&delete r[e],!Object.keys(r).length&&t instanceof HTMLElement&&t.hasAttribute("_mc")&&t.removeAttribute("_mc")}function p(t,e,r={},n="l"){let s=t?._mc;if(!s)return;let c=e instanceof o?new o(e.type,e.data,"l"):new o(e,r,"l"),i="string"!=typeof e?e:new o(e,r,n);[...Object.values(s)].forEach((t=>{t?.trigger&&"function"==typeof t?.trigger&&t?.trigger(c)})),/[ud]/.test(i.bubble)&&g(t,i)}function g(t,e){/[ud]/.test(e.bubble)&&setTimeout((()=>{if(-1===e.bubble.indexOf("l")&&(e.bubble+="l"),e.bubble.indexOf("u")>-1){let r=a(t,"",!0)?.[0].target;r&&b.trigger(r,e)}e.bubble.indexOf("d")>-1&&new Set(t._mc.children().map((t=>t?.target))).forEach((t=>{t&&b.trigger(t,e)}))}),0)}s()&&Object.keys(HTMLElement.prototype).filter((t=>/^on/.test(t))).forEach((t=>c.add(t)));class f{#n;constructor(t,e=!1){var r;this.#n=new WeakRef(t||{}),(r=this).constructor!==b&&setTimeout((()=>{r.trigger("Init")}),0),function(t){if(!s()||t.constructor===b)return;const e=t.target;if(e instanceof HTMLElement){let r=t;Object.getOwnPropertyNames(r.constructor.prototype).filter((t=>/^on[A-Z]|one[A-Z]/.test(t)&&"function"==typeof r.constructor.prototype[t])).forEach((n=>{let o=/^one/.test(n),s=n.replace(/^on[e]{0,1}/,""),i=s.toLowerCase();o&&Object.defineProperty(t,"on"+s,{configurable:!0,enumerable:!1,writable:!0,value:t=>{r.constructor.prototype[n].bind(r)(t)}}),c.has("on"+i)&&function(t,e,r,n=!1,o=!1){let s={once:!1};n&&(s.capture=n),o&&(s.once=o),t.addEventListener(e,r,s)}(e,i,(t=>{r.trigger(s,t)}),!1,o)}))}}(this)}get target(){return this.#n.deref()}}class m extends f{_mc={};constructor(t){super(t)}static trigger=p;trigger(t,e={},r="l"){let n=this;if(n.constructor===m||n.constructor===b){let s=t instanceof o?new o(t.type,t.data,"l"):new o(t,e,"l"),c="string"!=typeof t?t:new o(t,e,r);return[...Object.getOwnPropertyNames(n)].forEach((t=>{n[t]?.trigger&&"function"==typeof n[t]?.trigger&&n[t]?.trigger(s)})),void(/[ud]/.test(c.bubble)&&g(n.target,c))}if(n instanceof m||n instanceof b){const n=this,s="string"!=typeof t?t:new o(t,e,r),c="on"+s.type[0].toUpperCase()+s.type.slice(1);if(s.bubble.indexOf("l")>-1&&(s.immediateStopped||"function"!=typeof n[c]||(n[c](s),n.hasOwnProperty(c)&&delete n[c])),s.stopped||"l"===s.bubble)return n;/[ud]/.test(s.bubble)&&g(n.target,s)}}}class b extends f{_mc={};constructor(t,e=!1){super(t)}static add=u;static remove=d;static trigger=p;trigger(t,e={},r){m.prototype.trigger.call(this,t,e,r)}parent(t=""){let e=this.target;return l(e)?a(e.parentNode,t,!0):[]}ancestors(t=""){let e=this?.target;return l(e)?a(this.target.parentNode,t,!1):[]}children(t=""){let e=this?.target;if(!l(e))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';e.setAttribute("temp_id",r);const o=i([...e.querySelectorAll(n)],t);return e.removeAttribute("temp_id"),o}descendants(t=""){let e=this?.target;return l(e)?i([...e.querySelectorAll("*[_mc]")],t):[]}}new Map;class h extends HTMLElement{constructor(){super()}connectedCallback(){b.trigger(this,"Connected")}disconnectedCallback(){b.trigger(this,"Disconnected")}adoptedCallback(){b.trigger(this,"Adopted")}attributeChangedCallback(t,e,r){b.trigger(this,"AttributeChanged",{name:t,oldValue:e,newValue:r})}}function y(t,e,r=[]){if(customElements.get(t))return void console.warn(`IGNORED: Custom element "${t}" is already defined!`);if(!t.includes("-"))throw new Error('createCustomElement: tagName must contain at least one hyphen ("-").');let n=t.split("-").map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join("");customElements.define(t,function(t,e){return Object.defineProperty(e,"name",{value:t})}(n,class extends h{instance;constructor(t){super();let r=new e(this,t);b.add(this,n,r)}static get observedAttributes(){return r}}))}function w(t){return customElements.get(t)}function _(t,e){return Math.floor(Math.random()*(e-t+1)+t)}y("test-greatgrandchild",class extends b{constructor(t){super(t)}onConnected(){this.updateStyle()}updateStyle(){this.target.setAttribute("style","border-color:rgb("+_(0,255)+","+_(0,255)+","+_(0,255)+")")}});const O=w("test-greatgrandchild");y("test-grandchild",class extends b{constructor(t){super(t)}onConnected(){let t=this;for(let e=0;e<2;e++)t.target.append(new O)}});const E=w("test-grandchild");y("test-child",class extends b{constructor(t){super(t)}onConnected(){let t=this;for(let e=0;e<10;e++)t.target.append(new E)}});const v=w("test-child");y("test-parent",class extends b{constructor(t){super(t)}onConnected(){let t=this;for(let e=0;e<5;e++)t.target.append(new v)}});const j=w("test-parent");y("test-grandparent",class extends b{constructor(t){super(t)}onConnected(){let t=this;for(let e=0;e<5;e++)t.target.append(new j)}});const S=w("test-grandparent");return e})()));
1
+ import { DC, defineCE, getCE } from '.././microcomponents.js';
2
+ import { Parent } from './parent.js';
3
+ defineCE('test-grandparent', class TestGrandparent extends DC {
4
+ constructor(target) {
5
+ super(target);
6
+ }
7
+ onConnected() {
8
+ let that = this;
9
+ for (let x = 0; x < 5; x++) {
10
+ that.target.append(new Parent());
11
+ }
12
+ }
13
+ });
14
+ export const GrandParent = getCE('test-grandparent');
15
+ //# sourceMappingURL=grandparent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grandparent.js","sourceRoot":"","sources":["../../src/test/grandparent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,QAAQ,CACP,kBAAkB,EAElB,MAAM,eAAgB,SAAQ,EAAE;IAC/B,YAAY,MAAmB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED,WAAW;QACV,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,MAAO,EAAE,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;CACD,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { DC, defineCE, getCE } from '.././microcomponents.js';
2
+ function random(min, max) {
3
+ var random = Math.floor(Math.random() * (max - min + 1) + min);
4
+ return random;
5
+ }
6
+ defineCE('test-greatgrandchild', class TestGreatgrandchild extends DC {
7
+ constructor(target) {
8
+ super(target);
9
+ }
10
+ onConnected() {
11
+ let that = this;
12
+ that.updateStyle();
13
+ }
14
+ updateStyle() {
15
+ var that = this;
16
+ function randomBorderColor() {
17
+ return ('rgb(' +
18
+ random(0, 255) +
19
+ ',' +
20
+ random(0, 255) +
21
+ ',' +
22
+ random(0, 255) +
23
+ ')');
24
+ }
25
+ that.target.setAttribute('style', 'border-color:' + randomBorderColor());
26
+ }
27
+ });
28
+ export const Greatgrandchild = getCE('test-greatgrandchild');
29
+ //# sourceMappingURL=greatgrandchild.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"greatgrandchild.js","sourceRoot":"","sources":["../../src/test/greatgrandchild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE9D,SAAS,MAAM,CAAC,GAAW,EAAE,GAAW;IACvC,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC;AACf,CAAC;AAED,QAAQ,CACP,sBAAsB,EAEtB,MAAM,mBAAoB,SAAQ,EAAE;IACnC,YAAY,MAAmB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED,WAAW;QACV,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,CAAC,WAAW,EAAE,CAAC;IACpB,CAAC;IAED,WAAW;QACV,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,SAAS,iBAAiB;YACzB,OAAO,CACN,MAAM;gBACN,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC;gBACd,GAAG;gBACH,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC;gBACd,GAAG;gBACH,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC;gBACd,GAAG,CACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,iBAAiB,EAAE,CAAC,CAAC;IAC1E,CAAC;CACD,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { DC, defineCE, getCE } from '.././microcomponents.js';
2
+ import { Child } from './child.js';
3
+ defineCE('test-parent', class Parent extends DC {
4
+ constructor(target) {
5
+ super(target);
6
+ }
7
+ onConnected() {
8
+ let that = this;
9
+ for (let x = 0; x < 5; x++) {
10
+ that.target.append(new Child());
11
+ }
12
+ }
13
+ });
14
+ export const Parent = getCE('test-parent');
15
+ //# sourceMappingURL=parent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent.js","sourceRoot":"","sources":["../../src/test/parent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,QAAQ,CACP,aAAa,EAEb,MAAM,MAAO,SAAQ,EAAE;IACtB,YAAY,MAAmB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED,WAAW;QACV,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAM,EAAE,CAAC,CAAC;QAClC,CAAC;IACF,CAAC;CACD,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC"}