diff --git a/packages/@hec.js/ui/dist/hec.esm.min.js b/packages/@hec.js/ui/dist/hec.esm.min.js index 3f854ba..ed90fab 100644 --- a/packages/@hec.js/ui/dist/hec.esm.min.js +++ b/packages/@hec.js/ui/dist/hec.esm.min.js @@ -1 +1 @@ -function q(t){let e=t.matchAll(/([^ {}\s]+)/g),n={meta:{},text:t,prop:null};for(let r of e)if(r[1].includes("=")){let a=r[1].split("=");n.meta[a[0]]=a[1].replaceAll(/'|"/g,"")}else n.prop=r[1];return n}var S={};var A=new WeakMap,N=t=>A.get(t),Et=t=>A.delete(t),F=t=>A.has(t),k=(t,e)=>{let n=N(t);n&&typeof n=="object"?A.set(t,Object.assign(n,e)):A.set(t,e)},p=t=>typeof t=="function"?p(t()):t;function d(t,e){let n=e.split(".");if(!e)return t;if(!t)return null;for(let r of n){if(["state"].includes(r)&&t?.state)return t[r];if(m(t)){let a=t()?.[r];if(m(a)){let s=new AbortController,o=h(a());a.subscribe({next:o},{signal:s.signal});let l=i=>{s.abort(),m(i[r])?(s=new AbortController,i[r].subscribe({next:o},{signal:s.signal}),o(i[r]())):o(i[r])};t.subscribe({next:l}),t=o}else t=t.map(s=>s&&s[r])}else if(typeof t=="function")t=p(t);else if(typeof t[r]<"u")typeof t[r]=="function"&&!m(t[r])?t=t[r].bind(t):t=t[r];else return}return t}function Lt(t,e){let n=e.split(".");if(!e||!t)return!1;for(let r of n){if(["loading","error"].includes(r)&&t?.loading&&t?.error)return t[r];if(typeof t=="function")t=p(t);else if(typeof t[r]<"u")t=t[r];else return!1}return!0}var U={items:new Map,setItem(t,e){this.items.set(t,e?.toString())},get length(){return this.items.keys().length},key(t){return Array.from(this.items.values()).at(t)},clear(){this.items.clear()},getItem(t){return this.items.get(t)},removeItem(t){this.items.delete(t)}},P=new Map;function gt(t){try{let e=window[t+"Storage"];return typeof e.length=="number"?e:U}catch{return U}}window.addEventListener("storage",t=>{if(!P.has(t.key))return;let e=P.get(t.key),n=t.storageArea.getItem(t.key);typeof n=="string"&&n!=="undefined"&&e.update(JSON.parse(n))});function h(t=null,e={}){if(e.id&&P.has(e.id))return P.get(e.id);let n=[],r=e.storage&>(e.storage),a=i=>{t=i,r&&r.setItem(e.id,JSON.stringify(t));for(let c of n)c.next(t)};function s(){return arguments.length&&t!==arguments[0]&&a(arguments[0]),t}let o=(i,c=null)=>{n.push(i),c?.signal.addEventListener("abort",()=>{let u=n.indexOf(i);u>-1&&n.splice(u,1)},{once:!0})};if(r){let i=r.getItem(e.id);a(typeof i=="string"&&i!=="undefined"?JSON.parse(i):t)}let l=Object.assign(s,{id:e.id,storage:e.storage,toString:()=>t?.toString(),set:i=>t=i,update:a,subscribe:o,map:i=>{let c=h(i(t)),u=new AbortController,b=c.subscribe;return o({next:f=>c(i(f))},{signal:u.signal}),Object.assign(c,{set:()=>null,subscribe:(f,y)=>{b(f,y),y?.signal.addEventListener("abort",()=>u.abort())}})},filter:i=>{let c=h(i(t)?t:null);return o({next:u=>i(u)?c(u):null}),Object.assign(c,{set:()=>null})}});return e.id&&P.set(e.id,l),l}function bt(t,e=[],n=null){for(let r of e)r.subscribe({next:()=>n=t(n)});return t(n)}function Mt(t,e=[],n=null){let r=h(null);return r(bt(a=>r(t(a)),e,n)),r}function xt(t,e=null){let n=h(e),r=h("loaded"),a=async()=>{if(r()!="pending"){try{r("pending"),n(await t()),r("loaded"),delete n.error}catch(s){r("error"),n.error=s}return n()}};return a(),Object.assign(n,{state:r,refetch:a})}function Wt(t,e,n=null){let r=xt(()=>e(p(t)),n);return m(t)&&t.subscribe({next:()=>r.refetch()}),r}function m(t){return t&&t.subscribe}function zt(t,e=[]){function n(){let r=h(null),a=null,s=o=>{a=o,r(t(o))};for(let o of e)o.subscribe({next:()=>r(t(a))});return Object.assign({provide:s},r)}return n}var yt=h({}),z=h(location.pathname),Q=window.history.pushState,wt=window.history.replaceState,W={updateQueued:!1},j=[],H=new WeakMap;function vt(t,e){let n=Array.from(t.path.matchAll(/\:/g)).length*25,r=Array.from(e.path.matchAll(/\:/g)).length*25;return n+=Array.from(t.path.matchAll(/\*/g)).length*150,r+=Array.from(e.path.matchAll(/\*/g)).length*150,n-r}function G(t){let e=t.node,n=t.path,r=e.parentElement?.closest("[data-route]"),a=H.get(r),s=a?.pattern?.pathname,o=a?.group??j;t.group=[],H.set(e,t),s&&(n=n=="/"?"":n,n=s.replaceAll(/[^\/a-zA-Z0-9]+$/gm,"")+n.replaceAll(/^[^\/a-zA-Z0-9]+/gm,"")),n=n.replaceAll(/\/+/g,"/").replace(/\/$/m,""),t.pattern=new URLPattern({pathname:n||"/"}),o.push(t),o.sort(vt),W.updateQueued||(W.updateQueued=!0,queueMicrotask(w))}var O=document.querySelector('head meta[name="route"]')||document.createElement("meta");O.name="route";O.content=location.pathname;document.head.append(O);var w=()=>{let t=location.href.replace(/index\.*[a-z0-9]*$/gm,"");z(t),yt(Object.fromEntries(new URLSearchParams(location.search)));let e=!1,n=r=>{let a=!1;for(let s of r){let o=s.pattern.test(t);s.update(!a&&o),!a&&o&&(a=!0,s.group.length?n(s.group):(e=!0,O.content=s.pattern.pathname))}return e};return W.updateQueued=!1,n(j)},St=t=>{let e=t.target.closest("a")?.href,n=new URL(e,location.href);e&&n.hostname==location.hostname&&j.some(r=>r.pattern.test(e))&&(Q.call(window.history,null,null,e),w()&&t.preventDefault())};window.addEventListener("popstate",w);window.addEventListener("hashchange",w);window.addEventListener("click",St);window.history.pushState=function(e,n,r){Q.call(window.history,e,n,r),w()};window.history.replaceState=function(e,n,r){wt.call(window.history,e,n,r),w()};var R=new WeakMap,At=new MutationObserver(t=>{for(let e of t)R.has(e.target)&&R.get(e.target)()}),J={select:"[data-match]",run:t=>{let e=t.dataset.match,n=s=>s.replace(/index\.*[a-z0-9]*$/gm,"");function r(){return n(new URL(t.dataset.route||t.getAttribute("href"),location.href).pathname)}let a=()=>{r()==n(location.pathname)?t.classList.add(e):t.classList.remove(e)};z.subscribe({next:a}),R.set(t,a),At.observe(t,{attributes:!0,attributeFilter:["href","data-route"]}),a(),t.removeAttribute("data-match")}};var D={number:t=>t.valueAsNumber,date:t=>t.valueAsDate,text:t=>t.value,checkbox:t=>t.checked,"":t=>t.value},Z={select:"[data-bind],[name]",run:(t,e)=>{let n=t.dataset.bind||t.getAttribute("name"),r=d(e,n);if(r){let a=s=>{t.type=="checkbox"?t.checked=s:t.value=s};a(p(r)),m(r)&&(r.subscribe({next:a}),t.addEventListener("input",()=>r(D[t.type]?.(t)??t.value)),t.addEventListener("change",()=>r(D[t.type]?.(t)??t.value)))}}};var E=new WeakMap,K=new IntersectionObserver(t=>{for(let e of t)if(e.isIntersecting&&E.has(e.target)){for(let n of E.get(e.target))n();E.delete(e.target),K.unobserve(e.target)}},{rootMargin:"256px"});function x(t){return new Promise(e=>{let n=E.get(t)??[];n.push(e),E.set(t,n),K.observe(t)})}var C=new WeakSet,X={select:"[data-include]",run:(t,e)=>{if(C.has(t)||t.children.length)return;C.add(t);let n=t.hasAttribute("data-lazy")&&t.closest("[hidden]"),r=async()=>{t.dispatchEvent(new CustomEvent("::load",{bubbles:!0}));let a=await fetch(t.dataset.include,{headers:{accept:"text/html,text/*"}});if(a.ok){let s=await a.text();t.dispatchEvent(new CustomEvent("::loaded",{bubbles:!0})),t.innerHTML=s;for(let o of t.childNodes)g(o,e);t.removeAttribute("data-include"),t.removeAttribute("data-lazy")}};t.hasAttribute("data-lazy")?x(t).then(r):r()}};var Y=new WeakSet,tt={select:"[data-for]",run:(t,e,n)=>{if(Y.has(t))return;let r=t.dataset.for.replace("let","").split("of"),a=r[0].split(","),s=r.at(-1).trim(),o=a[0].trim()==s?"__e":a[0].trim(),l=a[1]?.trim()??"__i",i=d(e,s),c=document.createComment(t.dataset.for);t.replaceWith(c),C.add(t);let u=()=>{let f=c;for(;(f=f.nextSibling)&&((f instanceof HTMLElement||f instanceof SVGElement)&&f.dataset.for==t.dataset.for);)f=f.previousSibling,f.nextSibling.remove()},b=f=>{if(u(),!f||!f[Symbol.iterator])return console.warn("data-for: The value given is not iterable.",{key:s,value:f});for(let y=0,M=c;y{let n=d(e,t.dataset.if||t.dataset.ifNot),r=document.createComment("if: "+(t.dataset.if||t.dataset.ifNot)),a=!!t.dataset.ifNot;t.replaceWith(r);let s=o=>{o=a?!o:o,!t.parentNode&&o?(t.hidden=!1,r.after(t)):t.localName!="link"&&t.remove()};s(p(n)),m(n)&&n.subscribe({next:s})}};var rt=new WeakSet,nt={select:"[data-lazy]",run:(t,e,n)=>{if(rt.has(t)||!t.childNodes.length)return;rt.add(t);let r=t.dataset.lazy,a=()=>{t.removeAttribute("data-lazy"),I(t,e);for(let s of t.childNodes)g(s,e)};r&&(t.addEventListener("::load",()=>t.classList.add(r),{once:!0}),t.addEventListener("::loaded",()=>t.classList.remove(r),{once:!0})),x(t).then(a),n()}};var at={select:"[data-on]",run:(t,e)=>{let n=r=>{let a=r.split(":"),s=a[0].trim(),o=a.at(-1).trim(),l=d(e,o);l&&t.addEventListener(s,l)};for(let r of t.dataset.on.split(","))n(r)}};var ot=t=>{let e=document.createElement("link");Object.assign(e,t),e.rel="preload",document.head.append(e)};var st=new WeakSet,it={select:"[data-preload]",run:t=>{if(st.has(t)||t.hidden)return;st.add(t);let e=()=>{let n=t.dataset.preload.split(",");for(let r of n){let a=r.split(":");ot({href:a[0],as:a[1]??"fetch"})}};t.hasAttribute("data-lazy")?x(t).then(e):e()}};var lt={select:"[data-route], [data-route-not]",run:async t=>{"URLPattern"in window||await import("https://kevinblt.github.io/hec/packages/@hec.js/ui/dist/urlpattnern.min.js");let e=t.dataset.route,n=document.createComment("route: "+e);G({path:e,update:a=>{if(a){if(t.hidden=!1,t.parentNode)return;n.after(t)}else t.localName!="link"&&t.remove()},node:t}),t.replaceWith(n)}};var B="[data-component], [data-view], [data-page]",T=(t,e=document.body,n=V)=>{let r=B.replaceAll("]",`="${t}"]`);e.matches(r)&&n(e,t);for(let a of e.querySelectorAll(r))n(a,t)};new MutationObserver(t=>{for(let e of t){for(let n of e.addedNodes)for(let r of Object.keys(v))T(r);for(let n of e.removedNodes)for(let r of Object.keys(v))n instanceof Element&&T(r,n,a=>a.dispatchEvent(new CustomEvent("::unmount")))}}).observe(document,{childList:!0,subtree:!0});var v={},L=new WeakMap;function V(t,e){L.has(t)||!v[e]||(v[e].use(t),L.set(t,v[e].component))}var _=class{constructor(e){Object.assign(this,e)}signals={};node;props;#t=null;on(e,n,r=null){this.node.addEventListener(e,n,r)}emit(e,n=null,r=!1){this.node.dispatchEvent(new CustomEvent(e,{detail:n,bubbles:r}))}async insert(e){this.#t??=this.node.hasAttribute("data-lazy"),this.#t?(this.emit("::load",null,!0),this.node.removeAttribute("data-lazy"),await x(this.node)):(this.emit("::load",null,!0),await Promise.resolve());let n=e(this.signals,this.node);(a=>{k(this,N(a));let s=Array.from(this.node.children);if(this.node.append(a),s.length){let o=this.node.querySelector("slot"),l=document.createComment("children/"),i=document.createComment("/children");o?o.replaceWith(l,...s,i):this.node.append(l,...s)}for(let o in this.props){let l=this.node.getAttribute(o)??"";this.node.hasAttribute(o)||this.node.setAttribute(o,this.props[o]?.toString()),l.startsWith("@")||this.signals[o].subscribe({next:i=>i==null?this.node.removeAttribute(o):this.node.setAttribute(o,i.toString())})}this.emit("::loaded",null,!0),this.node.dispatchEvent(new CustomEvent("::mount"))})(n instanceof Promise?await n:n)}attributeChange(e,n,r){let a=Object.entries(this.props).filter(s=>s[0].toLowerCase()==e)[0];if(r?.startsWith("@")){let s=this.node.parentNode,o=r.slice(1),l=d(N(s),o)??d(N(this.node),o);m(l)?this.signals[e]=l:(this.signals[a[0]]??=h(l),this.signals[a[0]](l))}else this.signals[a[0]]??=h(r),this.signals[a[0]](typeof a[1]=="number"?parseFloat(r):r)}};function ct(t,e,n){v[t]??={observer:new MutationObserver(r=>{for(let a of r)a.target instanceof Element&&L.get(a.target)?.attributeChange(a.attributeName,a.oldValue,a.target.getAttribute(a.attributeName))}),component:null,use(r){this.component=new _({props:e,node:r});for(let a of Object.keys(e))this.component.attributeChange(a,null,r.getAttribute(a)??e[a]);this.component.insert(n),this.observer.observe(r,{attributes:!0,attributeOldValue:!0,attributeFilter:Object.keys(e).map(a=>a.toLowerCase())})}},T(t,document.body)}var de=ct,he=ct;var ut={select:B,run:t=>{L.has(t)||V(t,t.dataset.component??t.dataset.view??t.dataset.page)}};var ft=[ut,tt,et,lt,it,X,at,Z,J,nt];var mt={};function _e(t,e={}){t instanceof URL&&(t=t.host==location.host?t.pathname:t.toString());let n=document.querySelector(`template[name="${t}"]`);if(!n){let r=document.querySelector('head meta[name="template-path"]');return mt[t]??=new Promise(async a=>{n=document.createElement("template"),n.setAttribute("id",t.toString()),n.innerHTML=await fetch(r?.content?.replaceAll("[name]",t.toString())??t).then(s=>s.text()),document.body.append(n),a(n)}),mt[t].then(a=>g(a.content.cloneNode(!0),e))}return g(n.content.cloneNode(!0),e)}function Be(t,e={}){let n=document.createElement("template");return n.dataset.name="anonymous",n.innerHTML=t,g(n.content.cloneNode(!0),e)}function g(t,e={}){let n=(r,a=new WeakSet)=>{let s=!1;if(!(F(r)||a.has(r))){if(r.nodeName=="#document-fragment"&&k(r,e),r instanceof HTMLElement||r instanceof SVGElement){k(r,e);for(let o of ft)r.matches(o.select)&&o.run(r,e,()=>s=!0);if(s)return;I(r,e)}else if(r instanceof Text&&r.textContent.includes("{{")){let o=r.textContent.split(/{{|}}/g);for(let l=0,i=r,c;lc.data=u),a.add(c),i.after(c),i=c;r.remove()}a.add(r);for(let o of r.childNodes)n(o,a)}};return n(t,new WeakSet),t}var I=(t,e)=>{let n=t.getAttributeNames();for(let r of n){let a=t.getAttribute(r);a?.includes("{{")&&pt(a,e,s=>{s=s.trim().replace(/ +/," "),s==="undefined"||s==="null"?t.removeAttribute(r):t.setAttribute(r,s)})}},pt=(t,e,n)=>{let r=t.match(/{{[^}]+}}/g).map(q),a=t,s=()=>{t=a;for(let o of r)t=t.replace(o.text,p(o.value));return t};for(let o of r){let l=null;if(o.prop[o.prop.length-1]===")"){let i=o.prop.split("("),c=d(e,i[1].substring(0,i[1].length-1).trim()),u=i[0].trim();l=d(e,u),l=l(),l.provide(p(c)),m(c)&&c.subscribe({next:b=>l.resolve(p(b))})}else l=d(e,o.prop);if(l==null&&console.warn(`{{ ${o.prop} }}: No value for this key`,{key:o.prop,value:l}),m(l)){let i=l;for(let c in o.meta)if(S[c]){let u=S[c];i=i.map(b=>u({value:b,key:o.prop,param:o.meta[c],options:o.meta}))}o.value=i,i.subscribe({next:()=>n(s())})}else{let i=l;for(let c in o.meta)if(S[c]){let u=S[c];i=u({value:p(l),key:o.prop,param:o.meta[c],options:o.meta})}o.value=()=>i}}n(s())};var dt=new WeakMap;function $e(t,e=null){document.dispatchEvent(new CustomEvent(t,{detail:e}))}function qe(t,e){let n=r=>e(r.detail);dt.set(e,n),document.addEventListener(t,n)}function Fe(t){return new Promise(e=>{let n=r=>e(r.detail);document.addEventListener(t,n,{once:!0})})}function Ue(t,e){document.removeEventListener(t,dt.get(e))}export{L as activeComponents,ct as component,B as componentSelector,Et as deletePropsOf,bt as effect,$e as emit,I as executeNodeAttributesTemplate,q as expression,p as f,Lt as hasProp,F as hasProps,m as isSignal,Mt as memo,Ue as off,qe as on,Fe as once,he as page,S as pipes,ft as plugins,d as prop,N as propsOf,zt as provider,xt as resource,Wt as resourceBy,k as setPropsOf,h as signal,_e as templateByName,g as templateByNode,Be as templateByString,V as useComponent,de as view}; +function q(t){let e=t.matchAll(/([^ {}\s]+)/g),n={meta:{},text:t,prop:null};for(let r of e)if(r[1].includes("=")){let o=r[1].split("=");n.meta[o[0]]=o[1].replaceAll(/'|"/g,"")}else n.prop=r[1];return n}var S={};var A=new WeakMap,N=t=>A.get(t),Et=t=>A.delete(t),F=t=>A.has(t),k=(t,e)=>{let n=N(t);n&&typeof n=="object"?A.set(t,Object.assign(n,e)):A.set(t,e)},p=t=>typeof t=="function"?p(t()):t;function d(t,e){let n=e.split(".");if(!e)return t;if(!t)return null;for(let r of n){if(["state"].includes(r)&&t?.state)return t[r];if(m(t)){let o=t()?.[r];if(m(o)){let s=new AbortController,a=h(o());o.subscribe({next:a},{signal:s.signal});let l=i=>{s.abort(),m(i[r])?(s=new AbortController,i[r].subscribe({next:a},{signal:s.signal}),a(i[r]())):a(i[r])};t.subscribe({next:l}),t=a}else t=t.map(s=>s&&s[r])}else if(typeof t=="function")t=p(t);else if(typeof t[r]<"u")typeof t[r]=="function"&&!m(t[r])?t=t[r].bind(t):t=t[r];else return}return t}function Lt(t,e){let n=e.split(".");if(!e||!t)return!1;for(let r of n){if(["loading","error"].includes(r)&&t?.loading&&t?.error)return t[r];if(typeof t=="function")t=p(t);else if(typeof t[r]<"u")t=t[r];else return!1}return!0}var U={items:new Map,setItem(t,e){this.items.set(t,e?.toString())},get length(){return this.items.keys().length},key(t){return Array.from(this.items.values()).at(t)},clear(){this.items.clear()},getItem(t){return this.items.get(t)},removeItem(t){this.items.delete(t)}},P=new Map;function gt(t){try{let e=window[t+"Storage"];return typeof e.length=="number"?e:U}catch{return U}}window.addEventListener("storage",t=>{if(!P.has(t.key))return;let e=P.get(t.key),n=t.storageArea.getItem(t.key);typeof n=="string"&&n!=="undefined"&&e.update(JSON.parse(n))});function h(t=null,e={}){if(e.id&&P.has(e.id))return P.get(e.id);let n=[],r=e.storage&>(e.storage),o=i=>{t=i,r&&r.setItem(e.id,JSON.stringify(t));for(let c of n)c.next(t)};function s(){return arguments.length&&t!==arguments[0]&&o(arguments[0]),t}let a=(i,c=null)=>{n.push(i),c?.signal.addEventListener("abort",()=>{let u=n.indexOf(i);u>-1&&n.splice(u,1)},{once:!0})};if(r){let i=r.getItem(e.id);o(typeof i=="string"&&i!=="undefined"?JSON.parse(i):t)}let l=Object.assign(s,{id:e.id,storage:e.storage,toString:()=>t?.toString(),set:i=>t=i,update:o,subscribe:a,map:i=>{let c=h(i(t)),u=new AbortController,b=c.subscribe;return a({next:f=>c(i(f))},{signal:u.signal}),Object.assign(c,{set:()=>null,subscribe:(f,y)=>{b(f,y),y?.signal.addEventListener("abort",()=>u.abort())}})},filter:i=>{let c=h(i(t)?t:null);return a({next:u=>i(u)?c(u):null}),Object.assign(c,{set:()=>null})}});return e.id&&P.set(e.id,l),l}function bt(t,e=[],n=null){for(let r of e)r.subscribe({next:()=>n=t(n)});return t(n)}function Mt(t,e=[],n=null){let r=h(null);return r(bt(o=>r(t(o)),e,n)),r}function xt(t,e=null){let n=h(e),r=h("loaded"),o=async()=>{if(r()!="pending"){try{r("pending"),n(await t()),r("loaded"),delete n.error}catch(s){r("error"),n.error=s}return n()}};return o(),Object.assign(n,{state:r,refetch:o})}function Wt(t,e,n=null){let r=xt(()=>e(p(t)),n);return m(t)&&t.subscribe({next:()=>r.refetch()}),r}function m(t){return t&&t.subscribe}function zt(t,e=[]){function n(){let r=h(null),o=null,s=a=>{o=a,r(t(a))};for(let a of e)a.subscribe({next:()=>r(t(o))});return Object.assign({provide:s},r)}return n}var yt=h({}),z=h(location.pathname),Q=window.history.pushState,wt=window.history.replaceState,W={updateQueued:!1},j=[],H=new WeakMap;function vt(t,e){let n=Array.from(t.path.matchAll(/\:/g)).length*25,r=Array.from(e.path.matchAll(/\:/g)).length*25;return n+=Array.from(t.path.matchAll(/\*/g)).length*150,r+=Array.from(e.path.matchAll(/\*/g)).length*150,n-r}function G(t){let e=t.node,n=t.path,r=e.parentElement?.closest("[data-route]"),o=H.get(r),s=o?.pattern?.pathname,a=o?.group??j;t.group=[],H.set(e,t),s&&(n=n=="/"?"":n,n=s.replaceAll(/[^\/a-zA-Z0-9]+$/gm,"")+n.replaceAll(/^[^\/a-zA-Z0-9]+/gm,"")),n=n.replaceAll(/\/+/g,"/").replace(/\/$/m,""),t.pattern=new URLPattern({pathname:n||"/"}),a.push(t),a.sort(vt),W.updateQueued||(W.updateQueued=!0,queueMicrotask(w))}var O=document.querySelector('head meta[name="route"]')||document.createElement("meta");O.name="route";O.content=location.pathname;document.head.append(O);var w=()=>{let t=location.href.replace(/index\.*[a-z0-9]*$/gm,"");z(t),yt(Object.fromEntries(new URLSearchParams(location.search)));let e=!1,n=r=>{let o=!1;for(let s of r){let a=s.pattern.test(t);s.update(!o&&a),!o&&a&&(o=!0,s.group.length?n(s.group):(e=!0,O.content=s.pattern.pathname))}return e};return W.updateQueued=!1,n(j)},St=t=>{let e=t.target.closest("a")?.href,n=new URL(e,location.href);e&&n.hostname==location.hostname&&j.some(r=>r.pattern.test(e))&&(Q.call(window.history,null,null,e),w()&&t.preventDefault())};window.addEventListener("popstate",w);window.addEventListener("hashchange",w);window.addEventListener("click",St);window.history.pushState=function(e,n,r){Q.call(window.history,e,n,r),w()};window.history.replaceState=function(e,n,r){wt.call(window.history,e,n,r),w()};var R=new WeakMap,At=new MutationObserver(t=>{for(let e of t)R.has(e.target)&&R.get(e.target)()}),J={select:"[data-match]",run:t=>{let e=t.dataset.match,n=s=>s.replace(/index\.*[a-z0-9]*$/gm,"");function r(){return n(new URL(t.dataset.route||t.getAttribute("href"),location.href).pathname)}let o=()=>{r()==n(location.pathname)?t.classList.add(e):t.classList.remove(e)};z.subscribe({next:o}),R.set(t,o),At.observe(t,{attributes:!0,attributeFilter:["href","data-route"]}),o(),t.removeAttribute("data-match")}};var D={number:t=>t.valueAsNumber,date:t=>t.valueAsDate,text:t=>t.value,checkbox:t=>t.checked,"":t=>t.value},Z={select:"[data-bind],[name]",run:(t,e)=>{let n=t.dataset.bind||t.getAttribute("name"),r=d(e,n);if(r){let o=s=>{t.type=="checkbox"?t.checked=s:t.value=s};o(p(r)),m(r)&&(r.subscribe({next:o}),t.addEventListener("input",()=>r(D[t.type]?.(t)??t.value)),t.addEventListener("change",()=>r(D[t.type]?.(t)??t.value)))}}};var E=new WeakMap,K=new IntersectionObserver(t=>{for(let e of t)if(e.isIntersecting&&E.has(e.target)){for(let n of E.get(e.target))n();E.delete(e.target),K.unobserve(e.target)}},{rootMargin:"256px"});function x(t){return new Promise(e=>{let n=E.get(t)??[];n.push(e),E.set(t,n),K.observe(t)})}var C=new WeakSet,X={select:"[data-include]",run:(t,e)=>{if(C.has(t)||t.children.length)return;C.add(t);let n=t.hasAttribute("data-lazy")&&t.closest("[hidden]"),r=async()=>{t.dispatchEvent(new CustomEvent("::load",{bubbles:!0}));let o=await fetch(t.dataset.include,{headers:{accept:"text/html,text/*"}});if(o.ok){let s=await o.text();t.dispatchEvent(new CustomEvent("::loaded",{bubbles:!0})),t.innerHTML=s;for(let a of t.childNodes)g(a,e);t.removeAttribute("data-include"),t.removeAttribute("data-lazy")}};t.hasAttribute("data-lazy")?x(t).then(r):r()}};var Y=new WeakSet,tt={select:"[data-for]",run:(t,e,n)=>{if(Y.has(t))return;let r=t.dataset.for.replace("let","").split("of"),o=r[0].split(","),s=r.at(-1).trim(),a=o[0].trim()==s?"__e":o[0].trim(),l=o[1]?.trim()??"__i",i=d(e,s),c=document.createComment(t.dataset.for);t.replaceWith(c),C.add(t);let u=()=>{let f=c;for(;(f=f.nextSibling)&&((f instanceof HTMLElement||f instanceof SVGElement)&&f.dataset.for==t.dataset.for);)f=f.previousSibling,f.nextSibling.remove()},b=f=>{if(u(),!f||!f[Symbol.iterator])return console.warn("data-for: The value given is not iterable.",{key:s,value:f});for(let y=0,M=c;y{let n=d(e,t.dataset.if||t.dataset.ifNot),r=document.createComment("if: "+(t.dataset.if||t.dataset.ifNot)),o=!!t.dataset.ifNot;t.replaceWith(r);let s=a=>{a=o?!a:a,!t.parentNode&&a?(t.hidden=!1,r.after(t)):t.localName!="link"&&t.remove()};s(p(n)),m(n)&&n.subscribe({next:s})}};var rt=new WeakSet,nt={select:"[data-lazy]",run:(t,e,n)=>{if(rt.has(t)||!t.childNodes.length)return;rt.add(t);let r=t.dataset.lazy,o=()=>{t.removeAttribute("data-lazy"),I(t,e);for(let s of t.childNodes)g(s,e)};r&&(t.addEventListener("::load",()=>t.classList.add(r),{once:!0}),t.addEventListener("::loaded",()=>t.classList.remove(r),{once:!0})),x(t).then(o),n()}};var ot={select:"[data-on]",run:(t,e)=>{let n=r=>{let o=r.split(":"),s=o[0].trim(),a=o.at(-1).trim(),l=d(e,a);l&&t.addEventListener(s,l)};for(let r of t.dataset.on.split(","))n(r)}};var at=t=>{let e=document.createElement("link");Object.assign(e,t),e.rel="preload",document.head.append(e)};var st=new WeakSet,it={select:"[data-preload]",run:t=>{if(st.has(t)||t.hidden)return;st.add(t);let e=()=>{let n=t.dataset.preload.split(",");for(let r of n){let o=r.split(":");at({href:o[0],as:o[1]??"fetch"})}};t.hasAttribute("data-lazy")?x(t).then(e):e()}};var lt={select:"[data-route], [data-route-not]",run:async t=>{"URLPattern"in window||await import("https://kevinblt.github.io/hec/packages/@hec.js/ui/dist/urlpattnern.min.js");let e=t.dataset.route,n=document.createComment("route: "+e);G({path:e,update:o=>{if(o){if(t.hidden=!1,t.parentNode)return;n.after(t)}else t.localName!="link"&&t.remove()},node:t}),t.replaceWith(n)}};var B="[data-component], [data-view], [data-page]",T=(t,e=document.body,n=V)=>{let r=B.replaceAll("]",`="${t}"]`);e.matches(r)&&n(e,t);for(let o of e.querySelectorAll(r))n(o,t)};new MutationObserver(t=>{for(let e of t){for(let n of e.addedNodes)for(let r of Object.keys(v))T(r);for(let n of e.removedNodes)for(let r of Object.keys(v))n instanceof Element&&T(r,n,o=>o.dispatchEvent(new CustomEvent("::unmount")))}}).observe(document,{childList:!0,subtree:!0});var v={},L=new WeakMap;function V(t,e){L.has(t)||!v[e]||(v[e].use(t),L.set(t,v[e].component))}var _=class{constructor(e){Object.assign(this,e)}signals={};node;props;#t=null;on(e,n,r=null){this.node.addEventListener(e,n,r)}emit(e,n=null,r=!1){this.node.dispatchEvent(new CustomEvent(e,{detail:n,bubbles:r}))}async insert(e){this.#t??=this.node.hasAttribute("data-lazy"),this.#t?(this.emit("::load",null,!0),this.node.removeAttribute("data-lazy"),await x(this.node)):(this.emit("::load",null,!0),await Promise.resolve());let n=e(this.signals,this.node);(o=>{k(this,N(o));let s=Array.from(this.node.childNodes);if(this.node.append(o),s.length){let a=this.node.querySelector("slot"),l=document.createComment("children/"),i=document.createComment("/children");a?a.replaceWith(l,...s,i):this.node.append(l,...s)}for(let a in this.props){let l=this.node.getAttribute(a)??"";this.node.hasAttribute(a)||this.node.setAttribute(a,this.props[a]?.toString()),l.startsWith("@")||this.signals[a].subscribe({next:i=>i==null?this.node.removeAttribute(a):this.node.setAttribute(a,i.toString())})}this.emit("::loaded",null,!0),this.node.dispatchEvent(new CustomEvent("::mount"))})(n instanceof Promise?await n:n)}attributeChange(e,n,r){let o=Object.entries(this.props).filter(s=>s[0].toLowerCase()==e)[0];if(r?.startsWith("@")){let s=this.node.parentNode,a=r.slice(1),l=d(N(s),a)??d(N(this.node),a);m(l)?this.signals[e]=l:(this.signals[o[0]]??=h(l),this.signals[o[0]](l))}else this.signals[o[0]]??=h(r),this.signals[o[0]](typeof o[1]=="number"?parseFloat(r):r)}};function ct(t,e,n){v[t]??={observer:new MutationObserver(r=>{for(let o of r)o.target instanceof Element&&L.get(o.target)?.attributeChange(o.attributeName,o.oldValue,o.target.getAttribute(o.attributeName))}),component:null,use(r){this.component=new _({props:e,node:r});for(let o of Object.keys(e))this.component.attributeChange(o,null,r.getAttribute(o)??e[o]);this.component.insert(n),this.observer.observe(r,{attributes:!0,attributeOldValue:!0,attributeFilter:Object.keys(e).map(o=>o.toLowerCase())})}},T(t,document.body)}var de=ct,he=ct;var ut={select:B,run:t=>{L.has(t)||V(t,t.dataset.component??t.dataset.view??t.dataset.page)}};var ft=[ut,tt,et,lt,it,X,ot,Z,J,nt];var mt={};function _e(t,e={}){t instanceof URL&&(t=t.host==location.host?t.pathname:t.toString());let n=document.querySelector(`template[name="${t}"]`);if(!n){let r=document.querySelector('head meta[name="template-path"]');return mt[t]??=new Promise(async o=>{n=document.createElement("template"),n.setAttribute("id",t.toString()),n.innerHTML=await fetch(r?.content?.replaceAll("[name]",t.toString())??t).then(s=>s.text()),document.body.append(n),o(n)}),mt[t].then(o=>g(o.content.cloneNode(!0),e))}return g(n.content.cloneNode(!0),e)}function Be(t,e={}){let n=document.createElement("template");return n.dataset.name="anonymous",n.innerHTML=t,g(n.content.cloneNode(!0),e)}function g(t,e={}){let n=(r,o=new WeakSet)=>{let s=!1;if(!(F(r)||o.has(r))){if(r.nodeName=="#document-fragment"&&k(r,e),r instanceof HTMLElement||r instanceof SVGElement){k(r,e);for(let a of ft)r.matches(a.select)&&a.run(r,e,()=>s=!0);if(s)return;I(r,e)}else if(r instanceof Text&&r.textContent.includes("{{")){let a=r.textContent.split(/{{|}}/g);for(let l=0,i=r,c;lc.data=u),o.add(c),i.after(c),i=c;r.remove()}o.add(r);for(let a of r.childNodes)n(a,o)}};return n(t,new WeakSet),t}var I=(t,e)=>{let n=t.getAttributeNames();for(let r of n){let o=t.getAttribute(r);o?.includes("{{")&&pt(o,e,s=>{s=s.trim().replace(/ +/," "),s==="undefined"||s==="null"?t.removeAttribute(r):t.setAttribute(r,s)})}},pt=(t,e,n)=>{let r=t.match(/{{[^}]+}}/g).map(q),o=t,s=()=>{t=o;for(let a of r)t=t.replace(a.text,p(a.value));return t};for(let a of r){let l=null;if(a.prop[a.prop.length-1]===")"){let i=a.prop.split("("),c=d(e,i[1].substring(0,i[1].length-1).trim()),u=i[0].trim();l=d(e,u),l=l(),l.provide(p(c)),m(c)&&c.subscribe({next:b=>l.resolve(p(b))})}else l=d(e,a.prop);if(l==null&&console.warn(`{{ ${a.prop} }}: No value for this key`,{key:a.prop,value:l}),m(l)){let i=l;for(let c in a.meta)if(S[c]){let u=S[c];i=i.map(b=>u({value:b,key:a.prop,param:a.meta[c],options:a.meta}))}a.value=i,i.subscribe({next:()=>n(s())})}else{let i=l;for(let c in a.meta)if(S[c]){let u=S[c];i=u({value:p(l),key:a.prop,param:a.meta[c],options:a.meta})}a.value=()=>i}}n(s())};var dt=new WeakMap;function $e(t,e=null){document.dispatchEvent(new CustomEvent(t,{detail:e}))}function qe(t,e){let n=r=>e(r.detail);dt.set(e,n),document.addEventListener(t,n)}function Fe(t){return new Promise(e=>{let n=r=>e(r.detail);document.addEventListener(t,n,{once:!0})})}function Ue(t,e){document.removeEventListener(t,dt.get(e))}export{L as activeComponents,ct as component,B as componentSelector,Et as deletePropsOf,bt as effect,$e as emit,I as executeNodeAttributesTemplate,q as expression,p as f,Lt as hasProp,F as hasProps,m as isSignal,Mt as memo,Ue as off,qe as on,Fe as once,he as page,S as pipes,ft as plugins,d as prop,N as propsOf,zt as provider,xt as resource,Wt as resourceBy,k as setPropsOf,h as signal,_e as templateByName,g as templateByNode,Be as templateByString,V as useComponent,de as view}; diff --git a/packages/@hec.js/ui/dist/hec.min.js b/packages/@hec.js/ui/dist/hec.min.js index db56d66..35eb53a 100644 --- a/packages/@hec.js/ui/dist/hec.min.js +++ b/packages/@hec.js/ui/dist/hec.min.js @@ -1 +1 @@ -(()=>{var wt=Object.create;var T=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,kt=Object.prototype.hasOwnProperty;var Nt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Pt=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},Et=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of St(e))!kt.call(t,o)&&o!==n&&T(t,o,{get:()=>e[o],enumerable:!(r=vt(e,o))||r.enumerable});return t};var Lt=(t,e,n)=>(n=t!=null?wt(At(t)):{},Et(e||!t||!t.__esModule?T(n,"default",{value:t,enumerable:!0}):n,t));var j={};Pt(j,{activeComponents:()=>N,component:()=>H,componentSelector:()=>W,deletePropsOf:()=>Ot,effect:()=>D,emit:()=>Ut,executeNodeAttributesTemplate:()=>M,expression:()=>I,f:()=>p,hasProp:()=>Ct,hasProps:()=>_,isSignal:()=>m,memo:()=>Wt,off:()=>Gt,on:()=>Ht,once:()=>Qt,page:()=>$t,pipes:()=>w,plugins:()=>Q,prop:()=>d,propsOf:()=>v,provider:()=>jt,resource:()=>Z,resourceBy:()=>zt,setPropsOf:()=>S,signal:()=>h,templateByName:()=>qt,templateByNode:()=>g,templateByString:()=>Ft,useComponent:()=>z,view:()=>Vt});function I(t){let e=t.matchAll(/([^ {}\s]+)/g),n={meta:{},text:t,prop:null};for(let r of e)if(r[1].includes("=")){let o=r[1].split("=");n.meta[o[0]]=o[1].replaceAll(/'|"/g,"")}else n.prop=r[1];return n}var w={};var P=new WeakMap,v=t=>P.get(t),Ot=t=>P.delete(t),_=t=>P.has(t),S=(t,e)=>{let n=v(t);n&&typeof n=="object"?P.set(t,Object.assign(n,e)):P.set(t,e)},p=t=>typeof t=="function"?p(t()):t;function d(t,e){let n=e.split(".");if(!e)return t;if(!t)return null;for(let r of n){if(["state"].includes(r)&&t?.state)return t[r];if(m(t)){let o=t()?.[r];if(m(o)){let s=new AbortController,a=h(o());o.subscribe({next:a},{signal:s.signal});let l=i=>{s.abort(),m(i[r])?(s=new AbortController,i[r].subscribe({next:a},{signal:s.signal}),a(i[r]())):a(i[r])};t.subscribe({next:l}),t=a}else t=t.map(s=>s&&s[r])}else if(typeof t=="function")t=p(t);else if(typeof t[r]<"u")typeof t[r]=="function"&&!m(t[r])?t=t[r].bind(t):t=t[r];else return}return t}function Ct(t,e){let n=e.split(".");if(!e||!t)return!1;for(let r of n){if(["loading","error"].includes(r)&&t?.loading&&t?.error)return t[r];if(typeof t=="function")t=p(t);else if(typeof t[r]<"u")t=t[r];else return!1}return!0}var J={items:new Map,setItem(t,e){this.items.set(t,e?.toString())},get length(){return this.items.keys().length},key(t){return Array.from(this.items.values()).at(t)},clear(){this.items.clear()},getItem(t){return this.items.get(t)},removeItem(t){this.items.delete(t)}},E=new Map;function Mt(t){try{let e=window[t+"Storage"];return typeof e.length=="number"?e:J}catch{return J}}window.addEventListener("storage",t=>{if(!E.has(t.key))return;let e=E.get(t.key),n=t.storageArea.getItem(t.key);typeof n=="string"&&n!=="undefined"&&e.update(JSON.parse(n))});function h(t=null,e={}){if(e.id&&E.has(e.id))return E.get(e.id);let n=[],r=e.storage&&Mt(e.storage),o=i=>{t=i,r&&r.setItem(e.id,JSON.stringify(t));for(let c of n)c.next(t)};function s(){return arguments.length&&t!==arguments[0]&&o(arguments[0]),t}let a=(i,c=null)=>{n.push(i),c?.signal.addEventListener("abort",()=>{let u=n.indexOf(i);u>-1&&n.splice(u,1)},{once:!0})};if(r){let i=r.getItem(e.id);o(typeof i=="string"&&i!=="undefined"?JSON.parse(i):t)}let l=Object.assign(s,{id:e.id,storage:e.storage,toString:()=>t?.toString(),set:i=>t=i,update:o,subscribe:a,map:i=>{let c=h(i(t)),u=new AbortController,b=c.subscribe;return a({next:f=>c(i(f))},{signal:u.signal}),Object.assign(c,{set:()=>null,subscribe:(f,y)=>{b(f,y),y?.signal.addEventListener("abort",()=>u.abort())}})},filter:i=>{let c=h(i(t)?t:null);return a({next:u=>i(u)?c(u):null}),Object.assign(c,{set:()=>null})}});return e.id&&E.set(e.id,l),l}function D(t,e=[],n=null){for(let r of e)r.subscribe({next:()=>n=t(n)});return t(n)}function Wt(t,e=[],n=null){let r=h(null);return r(D(o=>r(t(o)),e,n)),r}function Z(t,e=null){let n=h(e),r=h("loaded"),o=async()=>{if(r()!="pending"){try{r("pending"),n(await t()),r("loaded"),delete n.error}catch(s){r("error"),n.error=s}return n()}};return o(),Object.assign(n,{state:r,refetch:o})}function zt(t,e,n=null){let r=Z(()=>e(p(t)),n);return m(t)&&t.subscribe({next:()=>r.refetch()}),r}function m(t){return t&&t.subscribe}function jt(t,e=[]){function n(){let r=h(null),o=null,s=a=>{o=a,r(t(a))};for(let a of e)a.subscribe({next:()=>r(t(o))});return Object.assign({provide:s},r)}return n}var Rt=h({}),V=h(location.pathname),X=window.history.pushState,Tt=window.history.replaceState,B={updateQueued:!1},$=[],K=new WeakMap;function It(t,e){let n=Array.from(t.path.matchAll(/\:/g)).length*25,r=Array.from(e.path.matchAll(/\:/g)).length*25;return n+=Array.from(t.path.matchAll(/\*/g)).length*150,r+=Array.from(e.path.matchAll(/\*/g)).length*150,n-r}function Y(t){let e=t.node,n=t.path,r=e.parentElement?.closest("[data-route]"),o=K.get(r),s=o?.pattern?.pathname,a=o?.group??$;t.group=[],K.set(e,t),s&&(n=n=="/"?"":n,n=s.replaceAll(/[^\/a-zA-Z0-9]+$/gm,"")+n.replaceAll(/^[^\/a-zA-Z0-9]+/gm,"")),n=n.replaceAll(/\/+/g,"/").replace(/\/$/m,""),t.pattern=new URLPattern({pathname:n||"/"}),a.push(t),a.sort(It),B.updateQueued||(B.updateQueued=!0,queueMicrotask(A))}var O=document.querySelector('head meta[name="route"]')||document.createElement("meta");O.name="route";O.content=location.pathname;document.head.append(O);var A=()=>{let t=location.href.replace(/index\.*[a-z0-9]*$/gm,"");V(t),Rt(Object.fromEntries(new URLSearchParams(location.search)));let e=!1,n=r=>{let o=!1;for(let s of r){let a=s.pattern.test(t);s.update(!o&&a),!o&&a&&(o=!0,s.group.length?n(s.group):(e=!0,O.content=s.pattern.pathname))}return e};return B.updateQueued=!1,n($)},_t=t=>{let e=t.target.closest("a")?.href,n=new URL(e,location.href);e&&n.hostname==location.hostname&&$.some(r=>r.pattern.test(e))&&(X.call(window.history,null,null,e),A()&&t.preventDefault())};window.addEventListener("popstate",A);window.addEventListener("hashchange",A);window.addEventListener("click",_t);window.history.pushState=function(e,n,r){X.call(window.history,e,n,r),A()};window.history.replaceState=function(e,n,r){Tt.call(window.history,e,n,r),A()};var q=new WeakMap,Bt=new MutationObserver(t=>{for(let e of t)q.has(e.target)&&q.get(e.target)()}),tt={select:"[data-match]",run:t=>{let e=t.dataset.match,n=s=>s.replace(/index\.*[a-z0-9]*$/gm,"");function r(){return n(new URL(t.dataset.route||t.getAttribute("href"),location.href).pathname)}let o=()=>{r()==n(location.pathname)?t.classList.add(e):t.classList.remove(e)};V.subscribe({next:o}),q.set(t,o),Bt.observe(t,{attributes:!0,attributeFilter:["href","data-route"]}),o(),t.removeAttribute("data-match")}};var et={number:t=>t.valueAsNumber,date:t=>t.valueAsDate,text:t=>t.value,checkbox:t=>t.checked,"":t=>t.value},rt={select:"[data-bind],[name]",run:(t,e)=>{let n=t.dataset.bind||t.getAttribute("name"),r=d(e,n);if(r){let o=s=>{t.type=="checkbox"?t.checked=s:t.value=s};o(p(r)),m(r)&&(r.subscribe({next:o}),t.addEventListener("input",()=>r(et[t.type]?.(t)??t.value)),t.addEventListener("change",()=>r(et[t.type]?.(t)??t.value)))}}};var L=new WeakMap,nt=new IntersectionObserver(t=>{for(let e of t)if(e.isIntersecting&&L.has(e.target)){for(let n of L.get(e.target))n();L.delete(e.target),nt.unobserve(e.target)}},{rootMargin:"256px"});function x(t){return new Promise(e=>{let n=L.get(t)??[];n.push(e),L.set(t,n),nt.observe(t)})}var C=new WeakSet,ot={select:"[data-include]",run:(t,e)=>{if(C.has(t)||t.children.length)return;C.add(t);let n=t.hasAttribute("data-lazy")&&t.closest("[hidden]"),r=async()=>{t.dispatchEvent(new CustomEvent("::load",{bubbles:!0}));let o=await fetch(t.dataset.include,{headers:{accept:"text/html,text/*"}});if(o.ok){let s=await o.text();t.dispatchEvent(new CustomEvent("::loaded",{bubbles:!0})),t.innerHTML=s;for(let a of t.childNodes)g(a,e);t.removeAttribute("data-include"),t.removeAttribute("data-lazy")}};t.hasAttribute("data-lazy")?x(t).then(r):r()}};var at=new WeakSet,st={select:"[data-for]",run:(t,e,n)=>{if(at.has(t))return;let r=t.dataset.for.replace("let","").split("of"),o=r[0].split(","),s=r.at(-1).trim(),a=o[0].trim()==s?"__e":o[0].trim(),l=o[1]?.trim()??"__i",i=d(e,s),c=document.createComment(t.dataset.for);t.replaceWith(c),C.add(t);let u=()=>{let f=c;for(;(f=f.nextSibling)&&((f instanceof HTMLElement||f instanceof SVGElement)&&f.dataset.for==t.dataset.for);)f=f.previousSibling,f.nextSibling.remove()},b=f=>{if(u(),!f||!f[Symbol.iterator])return console.warn("data-for: The value given is not iterable.",{key:s,value:f});for(let y=0,R=c;y{let n=d(e,t.dataset.if||t.dataset.ifNot),r=document.createComment("if: "+(t.dataset.if||t.dataset.ifNot)),o=!!t.dataset.ifNot;t.replaceWith(r);let s=a=>{a=o?!a:a,!t.parentNode&&a?(t.hidden=!1,r.after(t)):t.localName!="link"&&t.remove()};s(p(n)),m(n)&&n.subscribe({next:s})}};var lt=new WeakSet,ct={select:"[data-lazy]",run:(t,e,n)=>{if(lt.has(t)||!t.childNodes.length)return;lt.add(t);let r=t.dataset.lazy,o=()=>{t.removeAttribute("data-lazy"),M(t,e);for(let s of t.childNodes)g(s,e)};r&&(t.addEventListener("::load",()=>t.classList.add(r),{once:!0}),t.addEventListener("::loaded",()=>t.classList.remove(r),{once:!0})),x(t).then(o),n()}};var ut={select:"[data-on]",run:(t,e)=>{let n=r=>{let o=r.split(":"),s=o[0].trim(),a=o.at(-1).trim(),l=d(e,a);l&&t.addEventListener(s,l)};for(let r of t.dataset.on.split(","))n(r)}};var ft=t=>{let e=document.createElement("link");Object.assign(e,t),e.rel="preload",document.head.append(e)};var mt=new WeakSet,pt={select:"[data-preload]",run:t=>{if(mt.has(t)||t.hidden)return;mt.add(t);let e=()=>{let n=t.dataset.preload.split(",");for(let r of n){let o=r.split(":");ft({href:o[0],as:o[1]??"fetch"})}};t.hasAttribute("data-lazy")?x(t).then(e):e()}};var dt={select:"[data-route], [data-route-not]",run:async t=>{"URLPattern"in window||await import("https://kevinblt.github.io/hec/packages/@hec.js/ui/dist/urlpattnern.min.js");let e=t.dataset.route,n=document.createComment("route: "+e);Y({path:e,update:o=>{if(o){if(t.hidden=!1,t.parentNode)return;n.after(t)}else t.localName!="link"&&t.remove()},node:t}),t.replaceWith(n)}};var W="[data-component], [data-view], [data-page]",F=(t,e=document.body,n=z)=>{let r=W.replaceAll("]",`="${t}"]`);e.matches(r)&&n(e,t);for(let o of e.querySelectorAll(r))n(o,t)};new MutationObserver(t=>{for(let e of t){for(let n of e.addedNodes)for(let r of Object.keys(k))F(r);for(let n of e.removedNodes)for(let r of Object.keys(k))n instanceof Element&&F(r,n,o=>o.dispatchEvent(new CustomEvent("::unmount")))}}).observe(document,{childList:!0,subtree:!0});var k={},N=new WeakMap;function z(t,e){N.has(t)||!k[e]||(k[e].use(t),N.set(t,k[e].component))}var U=class{constructor(e){Object.assign(this,e)}signals={};node;props;#t=null;on(e,n,r=null){this.node.addEventListener(e,n,r)}emit(e,n=null,r=!1){this.node.dispatchEvent(new CustomEvent(e,{detail:n,bubbles:r}))}async insert(e){this.#t??=this.node.hasAttribute("data-lazy"),this.#t?(this.emit("::load",null,!0),this.node.removeAttribute("data-lazy"),await x(this.node)):(this.emit("::load",null,!0),await Promise.resolve());let n=e(this.signals,this.node);(o=>{S(this,v(o));let s=Array.from(this.node.children);if(this.node.append(o),s.length){let a=this.node.querySelector("slot"),l=document.createComment("children/"),i=document.createComment("/children");a?a.replaceWith(l,...s,i):this.node.append(l,...s)}for(let a in this.props){let l=this.node.getAttribute(a)??"";this.node.hasAttribute(a)||this.node.setAttribute(a,this.props[a]?.toString()),l.startsWith("@")||this.signals[a].subscribe({next:i=>i==null?this.node.removeAttribute(a):this.node.setAttribute(a,i.toString())})}this.emit("::loaded",null,!0),this.node.dispatchEvent(new CustomEvent("::mount"))})(n instanceof Promise?await n:n)}attributeChange(e,n,r){let o=Object.entries(this.props).filter(s=>s[0].toLowerCase()==e)[0];if(r?.startsWith("@")){let s=this.node.parentNode,a=r.slice(1),l=d(v(s),a)??d(v(this.node),a);m(l)?this.signals[e]=l:(this.signals[o[0]]??=h(l),this.signals[o[0]](l))}else this.signals[o[0]]??=h(r),this.signals[o[0]](typeof o[1]=="number"?parseFloat(r):r)}};function H(t,e,n){k[t]??={observer:new MutationObserver(r=>{for(let o of r)o.target instanceof Element&&N.get(o.target)?.attributeChange(o.attributeName,o.oldValue,o.target.getAttribute(o.attributeName))}),component:null,use(r){this.component=new U({props:e,node:r});for(let o of Object.keys(e))this.component.attributeChange(o,null,r.getAttribute(o)??e[o]);this.component.insert(n),this.observer.observe(r,{attributes:!0,attributeOldValue:!0,attributeFilter:Object.keys(e).map(o=>o.toLowerCase())})}},F(t,document.body)}var Vt=H,$t=H;var ht={select:W,run:t=>{N.has(t)||z(t,t.dataset.component??t.dataset.view??t.dataset.page)}};var Q=[ht,st,it,dt,pt,ot,ut,rt,tt,ct];var gt={};function qt(t,e={}){t instanceof URL&&(t=t.host==location.host?t.pathname:t.toString());let n=document.querySelector(`template[name="${t}"]`);if(!n){let r=document.querySelector('head meta[name="template-path"]');return gt[t]??=new Promise(async o=>{n=document.createElement("template"),n.setAttribute("id",t.toString()),n.innerHTML=await fetch(r?.content?.replaceAll("[name]",t.toString())??t).then(s=>s.text()),document.body.append(n),o(n)}),gt[t].then(o=>g(o.content.cloneNode(!0),e))}return g(n.content.cloneNode(!0),e)}function Ft(t,e={}){let n=document.createElement("template");return n.dataset.name="anonymous",n.innerHTML=t,g(n.content.cloneNode(!0),e)}function g(t,e={}){let n=(r,o=new WeakSet)=>{let s=!1;if(!(_(r)||o.has(r))){if(r.nodeName=="#document-fragment"&&S(r,e),r instanceof HTMLElement||r instanceof SVGElement){S(r,e);for(let a of Q)r.matches(a.select)&&a.run(r,e,()=>s=!0);if(s)return;M(r,e)}else if(r instanceof Text&&r.textContent.includes("{{")){let a=r.textContent.split(/{{|}}/g);for(let l=0,i=r,c;lc.data=u),o.add(c),i.after(c),i=c;r.remove()}o.add(r);for(let a of r.childNodes)n(a,o)}};return n(t,new WeakSet),t}var M=(t,e)=>{let n=t.getAttributeNames();for(let r of n){let o=t.getAttribute(r);o?.includes("{{")&&bt(o,e,s=>{s=s.trim().replace(/ +/," "),s==="undefined"||s==="null"?t.removeAttribute(r):t.setAttribute(r,s)})}},bt=(t,e,n)=>{let r=t.match(/{{[^}]+}}/g).map(I),o=t,s=()=>{t=o;for(let a of r)t=t.replace(a.text,p(a.value));return t};for(let a of r){let l=null;if(a.prop[a.prop.length-1]===")"){let i=a.prop.split("("),c=d(e,i[1].substring(0,i[1].length-1).trim()),u=i[0].trim();l=d(e,u),l=l(),l.provide(p(c)),m(c)&&c.subscribe({next:b=>l.resolve(p(b))})}else l=d(e,a.prop);if(l==null&&console.warn(`{{ ${a.prop} }}: No value for this key`,{key:a.prop,value:l}),m(l)){let i=l;for(let c in a.meta)if(w[c]){let u=w[c];i=i.map(b=>u({value:b,key:a.prop,param:a.meta[c],options:a.meta}))}a.value=i,i.subscribe({next:()=>n(s())})}else{let i=l;for(let c in a.meta)if(w[c]){let u=w[c];i=u({value:p(l),key:a.prop,param:a.meta[c],options:a.meta})}a.value=()=>i}}n(s())};var xt=new WeakMap;function Ut(t,e=null){document.dispatchEvent(new CustomEvent(t,{detail:e}))}function Ht(t,e){let n=r=>e(r.detail);xt.set(e,n),document.addEventListener(t,n)}function Qt(t){return new Promise(e=>{let n=r=>e(r.detail);document.addEventListener(t,n,{once:!0})})}function Gt(t,e){document.removeEventListener(t,xt.get(e))}for(let t in j)globalThis[t]=j[t];})(); +(()=>{var wt=Object.create;var T=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty;var kt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Pt=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},Et=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of St(e))!Nt.call(t,o)&&o!==n&&T(t,o,{get:()=>e[o],enumerable:!(r=vt(e,o))||r.enumerable});return t};var Lt=(t,e,n)=>(n=t!=null?wt(At(t)):{},Et(e||!t||!t.__esModule?T(n,"default",{value:t,enumerable:!0}):n,t));var j={};Pt(j,{activeComponents:()=>k,component:()=>H,componentSelector:()=>W,deletePropsOf:()=>Ot,effect:()=>D,emit:()=>Ut,executeNodeAttributesTemplate:()=>M,expression:()=>I,f:()=>p,hasProp:()=>Ct,hasProps:()=>_,isSignal:()=>m,memo:()=>Wt,off:()=>Gt,on:()=>Ht,once:()=>Qt,page:()=>$t,pipes:()=>w,plugins:()=>Q,prop:()=>d,propsOf:()=>v,provider:()=>jt,resource:()=>Z,resourceBy:()=>zt,setPropsOf:()=>S,signal:()=>h,templateByName:()=>qt,templateByNode:()=>g,templateByString:()=>Ft,useComponent:()=>z,view:()=>Vt});function I(t){let e=t.matchAll(/([^ {}\s]+)/g),n={meta:{},text:t,prop:null};for(let r of e)if(r[1].includes("=")){let o=r[1].split("=");n.meta[o[0]]=o[1].replaceAll(/'|"/g,"")}else n.prop=r[1];return n}var w={};var P=new WeakMap,v=t=>P.get(t),Ot=t=>P.delete(t),_=t=>P.has(t),S=(t,e)=>{let n=v(t);n&&typeof n=="object"?P.set(t,Object.assign(n,e)):P.set(t,e)},p=t=>typeof t=="function"?p(t()):t;function d(t,e){let n=e.split(".");if(!e)return t;if(!t)return null;for(let r of n){if(["state"].includes(r)&&t?.state)return t[r];if(m(t)){let o=t()?.[r];if(m(o)){let s=new AbortController,a=h(o());o.subscribe({next:a},{signal:s.signal});let l=i=>{s.abort(),m(i[r])?(s=new AbortController,i[r].subscribe({next:a},{signal:s.signal}),a(i[r]())):a(i[r])};t.subscribe({next:l}),t=a}else t=t.map(s=>s&&s[r])}else if(typeof t=="function")t=p(t);else if(typeof t[r]<"u")typeof t[r]=="function"&&!m(t[r])?t=t[r].bind(t):t=t[r];else return}return t}function Ct(t,e){let n=e.split(".");if(!e||!t)return!1;for(let r of n){if(["loading","error"].includes(r)&&t?.loading&&t?.error)return t[r];if(typeof t=="function")t=p(t);else if(typeof t[r]<"u")t=t[r];else return!1}return!0}var J={items:new Map,setItem(t,e){this.items.set(t,e?.toString())},get length(){return this.items.keys().length},key(t){return Array.from(this.items.values()).at(t)},clear(){this.items.clear()},getItem(t){return this.items.get(t)},removeItem(t){this.items.delete(t)}},E=new Map;function Mt(t){try{let e=window[t+"Storage"];return typeof e.length=="number"?e:J}catch{return J}}window.addEventListener("storage",t=>{if(!E.has(t.key))return;let e=E.get(t.key),n=t.storageArea.getItem(t.key);typeof n=="string"&&n!=="undefined"&&e.update(JSON.parse(n))});function h(t=null,e={}){if(e.id&&E.has(e.id))return E.get(e.id);let n=[],r=e.storage&&Mt(e.storage),o=i=>{t=i,r&&r.setItem(e.id,JSON.stringify(t));for(let c of n)c.next(t)};function s(){return arguments.length&&t!==arguments[0]&&o(arguments[0]),t}let a=(i,c=null)=>{n.push(i),c?.signal.addEventListener("abort",()=>{let u=n.indexOf(i);u>-1&&n.splice(u,1)},{once:!0})};if(r){let i=r.getItem(e.id);o(typeof i=="string"&&i!=="undefined"?JSON.parse(i):t)}let l=Object.assign(s,{id:e.id,storage:e.storage,toString:()=>t?.toString(),set:i=>t=i,update:o,subscribe:a,map:i=>{let c=h(i(t)),u=new AbortController,b=c.subscribe;return a({next:f=>c(i(f))},{signal:u.signal}),Object.assign(c,{set:()=>null,subscribe:(f,y)=>{b(f,y),y?.signal.addEventListener("abort",()=>u.abort())}})},filter:i=>{let c=h(i(t)?t:null);return a({next:u=>i(u)?c(u):null}),Object.assign(c,{set:()=>null})}});return e.id&&E.set(e.id,l),l}function D(t,e=[],n=null){for(let r of e)r.subscribe({next:()=>n=t(n)});return t(n)}function Wt(t,e=[],n=null){let r=h(null);return r(D(o=>r(t(o)),e,n)),r}function Z(t,e=null){let n=h(e),r=h("loaded"),o=async()=>{if(r()!="pending"){try{r("pending"),n(await t()),r("loaded"),delete n.error}catch(s){r("error"),n.error=s}return n()}};return o(),Object.assign(n,{state:r,refetch:o})}function zt(t,e,n=null){let r=Z(()=>e(p(t)),n);return m(t)&&t.subscribe({next:()=>r.refetch()}),r}function m(t){return t&&t.subscribe}function jt(t,e=[]){function n(){let r=h(null),o=null,s=a=>{o=a,r(t(a))};for(let a of e)a.subscribe({next:()=>r(t(o))});return Object.assign({provide:s},r)}return n}var Rt=h({}),V=h(location.pathname),X=window.history.pushState,Tt=window.history.replaceState,B={updateQueued:!1},$=[],K=new WeakMap;function It(t,e){let n=Array.from(t.path.matchAll(/\:/g)).length*25,r=Array.from(e.path.matchAll(/\:/g)).length*25;return n+=Array.from(t.path.matchAll(/\*/g)).length*150,r+=Array.from(e.path.matchAll(/\*/g)).length*150,n-r}function Y(t){let e=t.node,n=t.path,r=e.parentElement?.closest("[data-route]"),o=K.get(r),s=o?.pattern?.pathname,a=o?.group??$;t.group=[],K.set(e,t),s&&(n=n=="/"?"":n,n=s.replaceAll(/[^\/a-zA-Z0-9]+$/gm,"")+n.replaceAll(/^[^\/a-zA-Z0-9]+/gm,"")),n=n.replaceAll(/\/+/g,"/").replace(/\/$/m,""),t.pattern=new URLPattern({pathname:n||"/"}),a.push(t),a.sort(It),B.updateQueued||(B.updateQueued=!0,queueMicrotask(A))}var O=document.querySelector('head meta[name="route"]')||document.createElement("meta");O.name="route";O.content=location.pathname;document.head.append(O);var A=()=>{let t=location.href.replace(/index\.*[a-z0-9]*$/gm,"");V(t),Rt(Object.fromEntries(new URLSearchParams(location.search)));let e=!1,n=r=>{let o=!1;for(let s of r){let a=s.pattern.test(t);s.update(!o&&a),!o&&a&&(o=!0,s.group.length?n(s.group):(e=!0,O.content=s.pattern.pathname))}return e};return B.updateQueued=!1,n($)},_t=t=>{let e=t.target.closest("a")?.href,n=new URL(e,location.href);e&&n.hostname==location.hostname&&$.some(r=>r.pattern.test(e))&&(X.call(window.history,null,null,e),A()&&t.preventDefault())};window.addEventListener("popstate",A);window.addEventListener("hashchange",A);window.addEventListener("click",_t);window.history.pushState=function(e,n,r){X.call(window.history,e,n,r),A()};window.history.replaceState=function(e,n,r){Tt.call(window.history,e,n,r),A()};var q=new WeakMap,Bt=new MutationObserver(t=>{for(let e of t)q.has(e.target)&&q.get(e.target)()}),tt={select:"[data-match]",run:t=>{let e=t.dataset.match,n=s=>s.replace(/index\.*[a-z0-9]*$/gm,"");function r(){return n(new URL(t.dataset.route||t.getAttribute("href"),location.href).pathname)}let o=()=>{r()==n(location.pathname)?t.classList.add(e):t.classList.remove(e)};V.subscribe({next:o}),q.set(t,o),Bt.observe(t,{attributes:!0,attributeFilter:["href","data-route"]}),o(),t.removeAttribute("data-match")}};var et={number:t=>t.valueAsNumber,date:t=>t.valueAsDate,text:t=>t.value,checkbox:t=>t.checked,"":t=>t.value},rt={select:"[data-bind],[name]",run:(t,e)=>{let n=t.dataset.bind||t.getAttribute("name"),r=d(e,n);if(r){let o=s=>{t.type=="checkbox"?t.checked=s:t.value=s};o(p(r)),m(r)&&(r.subscribe({next:o}),t.addEventListener("input",()=>r(et[t.type]?.(t)??t.value)),t.addEventListener("change",()=>r(et[t.type]?.(t)??t.value)))}}};var L=new WeakMap,nt=new IntersectionObserver(t=>{for(let e of t)if(e.isIntersecting&&L.has(e.target)){for(let n of L.get(e.target))n();L.delete(e.target),nt.unobserve(e.target)}},{rootMargin:"256px"});function x(t){return new Promise(e=>{let n=L.get(t)??[];n.push(e),L.set(t,n),nt.observe(t)})}var C=new WeakSet,ot={select:"[data-include]",run:(t,e)=>{if(C.has(t)||t.children.length)return;C.add(t);let n=t.hasAttribute("data-lazy")&&t.closest("[hidden]"),r=async()=>{t.dispatchEvent(new CustomEvent("::load",{bubbles:!0}));let o=await fetch(t.dataset.include,{headers:{accept:"text/html,text/*"}});if(o.ok){let s=await o.text();t.dispatchEvent(new CustomEvent("::loaded",{bubbles:!0})),t.innerHTML=s;for(let a of t.childNodes)g(a,e);t.removeAttribute("data-include"),t.removeAttribute("data-lazy")}};t.hasAttribute("data-lazy")?x(t).then(r):r()}};var at=new WeakSet,st={select:"[data-for]",run:(t,e,n)=>{if(at.has(t))return;let r=t.dataset.for.replace("let","").split("of"),o=r[0].split(","),s=r.at(-1).trim(),a=o[0].trim()==s?"__e":o[0].trim(),l=o[1]?.trim()??"__i",i=d(e,s),c=document.createComment(t.dataset.for);t.replaceWith(c),C.add(t);let u=()=>{let f=c;for(;(f=f.nextSibling)&&((f instanceof HTMLElement||f instanceof SVGElement)&&f.dataset.for==t.dataset.for);)f=f.previousSibling,f.nextSibling.remove()},b=f=>{if(u(),!f||!f[Symbol.iterator])return console.warn("data-for: The value given is not iterable.",{key:s,value:f});for(let y=0,R=c;y{let n=d(e,t.dataset.if||t.dataset.ifNot),r=document.createComment("if: "+(t.dataset.if||t.dataset.ifNot)),o=!!t.dataset.ifNot;t.replaceWith(r);let s=a=>{a=o?!a:a,!t.parentNode&&a?(t.hidden=!1,r.after(t)):t.localName!="link"&&t.remove()};s(p(n)),m(n)&&n.subscribe({next:s})}};var lt=new WeakSet,ct={select:"[data-lazy]",run:(t,e,n)=>{if(lt.has(t)||!t.childNodes.length)return;lt.add(t);let r=t.dataset.lazy,o=()=>{t.removeAttribute("data-lazy"),M(t,e);for(let s of t.childNodes)g(s,e)};r&&(t.addEventListener("::load",()=>t.classList.add(r),{once:!0}),t.addEventListener("::loaded",()=>t.classList.remove(r),{once:!0})),x(t).then(o),n()}};var ut={select:"[data-on]",run:(t,e)=>{let n=r=>{let o=r.split(":"),s=o[0].trim(),a=o.at(-1).trim(),l=d(e,a);l&&t.addEventListener(s,l)};for(let r of t.dataset.on.split(","))n(r)}};var ft=t=>{let e=document.createElement("link");Object.assign(e,t),e.rel="preload",document.head.append(e)};var mt=new WeakSet,pt={select:"[data-preload]",run:t=>{if(mt.has(t)||t.hidden)return;mt.add(t);let e=()=>{let n=t.dataset.preload.split(",");for(let r of n){let o=r.split(":");ft({href:o[0],as:o[1]??"fetch"})}};t.hasAttribute("data-lazy")?x(t).then(e):e()}};var dt={select:"[data-route], [data-route-not]",run:async t=>{"URLPattern"in window||await import("https://kevinblt.github.io/hec/packages/@hec.js/ui/dist/urlpattnern.min.js");let e=t.dataset.route,n=document.createComment("route: "+e);Y({path:e,update:o=>{if(o){if(t.hidden=!1,t.parentNode)return;n.after(t)}else t.localName!="link"&&t.remove()},node:t}),t.replaceWith(n)}};var W="[data-component], [data-view], [data-page]",F=(t,e=document.body,n=z)=>{let r=W.replaceAll("]",`="${t}"]`);e.matches(r)&&n(e,t);for(let o of e.querySelectorAll(r))n(o,t)};new MutationObserver(t=>{for(let e of t){for(let n of e.addedNodes)for(let r of Object.keys(N))F(r);for(let n of e.removedNodes)for(let r of Object.keys(N))n instanceof Element&&F(r,n,o=>o.dispatchEvent(new CustomEvent("::unmount")))}}).observe(document,{childList:!0,subtree:!0});var N={},k=new WeakMap;function z(t,e){k.has(t)||!N[e]||(N[e].use(t),k.set(t,N[e].component))}var U=class{constructor(e){Object.assign(this,e)}signals={};node;props;#t=null;on(e,n,r=null){this.node.addEventListener(e,n,r)}emit(e,n=null,r=!1){this.node.dispatchEvent(new CustomEvent(e,{detail:n,bubbles:r}))}async insert(e){this.#t??=this.node.hasAttribute("data-lazy"),this.#t?(this.emit("::load",null,!0),this.node.removeAttribute("data-lazy"),await x(this.node)):(this.emit("::load",null,!0),await Promise.resolve());let n=e(this.signals,this.node);(o=>{S(this,v(o));let s=Array.from(this.node.childNodes);if(this.node.append(o),s.length){let a=this.node.querySelector("slot"),l=document.createComment("children/"),i=document.createComment("/children");a?a.replaceWith(l,...s,i):this.node.append(l,...s)}for(let a in this.props){let l=this.node.getAttribute(a)??"";this.node.hasAttribute(a)||this.node.setAttribute(a,this.props[a]?.toString()),l.startsWith("@")||this.signals[a].subscribe({next:i=>i==null?this.node.removeAttribute(a):this.node.setAttribute(a,i.toString())})}this.emit("::loaded",null,!0),this.node.dispatchEvent(new CustomEvent("::mount"))})(n instanceof Promise?await n:n)}attributeChange(e,n,r){let o=Object.entries(this.props).filter(s=>s[0].toLowerCase()==e)[0];if(r?.startsWith("@")){let s=this.node.parentNode,a=r.slice(1),l=d(v(s),a)??d(v(this.node),a);m(l)?this.signals[e]=l:(this.signals[o[0]]??=h(l),this.signals[o[0]](l))}else this.signals[o[0]]??=h(r),this.signals[o[0]](typeof o[1]=="number"?parseFloat(r):r)}};function H(t,e,n){N[t]??={observer:new MutationObserver(r=>{for(let o of r)o.target instanceof Element&&k.get(o.target)?.attributeChange(o.attributeName,o.oldValue,o.target.getAttribute(o.attributeName))}),component:null,use(r){this.component=new U({props:e,node:r});for(let o of Object.keys(e))this.component.attributeChange(o,null,r.getAttribute(o)??e[o]);this.component.insert(n),this.observer.observe(r,{attributes:!0,attributeOldValue:!0,attributeFilter:Object.keys(e).map(o=>o.toLowerCase())})}},F(t,document.body)}var Vt=H,$t=H;var ht={select:W,run:t=>{k.has(t)||z(t,t.dataset.component??t.dataset.view??t.dataset.page)}};var Q=[ht,st,it,dt,pt,ot,ut,rt,tt,ct];var gt={};function qt(t,e={}){t instanceof URL&&(t=t.host==location.host?t.pathname:t.toString());let n=document.querySelector(`template[name="${t}"]`);if(!n){let r=document.querySelector('head meta[name="template-path"]');return gt[t]??=new Promise(async o=>{n=document.createElement("template"),n.setAttribute("id",t.toString()),n.innerHTML=await fetch(r?.content?.replaceAll("[name]",t.toString())??t).then(s=>s.text()),document.body.append(n),o(n)}),gt[t].then(o=>g(o.content.cloneNode(!0),e))}return g(n.content.cloneNode(!0),e)}function Ft(t,e={}){let n=document.createElement("template");return n.dataset.name="anonymous",n.innerHTML=t,g(n.content.cloneNode(!0),e)}function g(t,e={}){let n=(r,o=new WeakSet)=>{let s=!1;if(!(_(r)||o.has(r))){if(r.nodeName=="#document-fragment"&&S(r,e),r instanceof HTMLElement||r instanceof SVGElement){S(r,e);for(let a of Q)r.matches(a.select)&&a.run(r,e,()=>s=!0);if(s)return;M(r,e)}else if(r instanceof Text&&r.textContent.includes("{{")){let a=r.textContent.split(/{{|}}/g);for(let l=0,i=r,c;lc.data=u),o.add(c),i.after(c),i=c;r.remove()}o.add(r);for(let a of r.childNodes)n(a,o)}};return n(t,new WeakSet),t}var M=(t,e)=>{let n=t.getAttributeNames();for(let r of n){let o=t.getAttribute(r);o?.includes("{{")&&bt(o,e,s=>{s=s.trim().replace(/ +/," "),s==="undefined"||s==="null"?t.removeAttribute(r):t.setAttribute(r,s)})}},bt=(t,e,n)=>{let r=t.match(/{{[^}]+}}/g).map(I),o=t,s=()=>{t=o;for(let a of r)t=t.replace(a.text,p(a.value));return t};for(let a of r){let l=null;if(a.prop[a.prop.length-1]===")"){let i=a.prop.split("("),c=d(e,i[1].substring(0,i[1].length-1).trim()),u=i[0].trim();l=d(e,u),l=l(),l.provide(p(c)),m(c)&&c.subscribe({next:b=>l.resolve(p(b))})}else l=d(e,a.prop);if(l==null&&console.warn(`{{ ${a.prop} }}: No value for this key`,{key:a.prop,value:l}),m(l)){let i=l;for(let c in a.meta)if(w[c]){let u=w[c];i=i.map(b=>u({value:b,key:a.prop,param:a.meta[c],options:a.meta}))}a.value=i,i.subscribe({next:()=>n(s())})}else{let i=l;for(let c in a.meta)if(w[c]){let u=w[c];i=u({value:p(l),key:a.prop,param:a.meta[c],options:a.meta})}a.value=()=>i}}n(s())};var xt=new WeakMap;function Ut(t,e=null){document.dispatchEvent(new CustomEvent(t,{detail:e}))}function Ht(t,e){let n=r=>e(r.detail);xt.set(e,n),document.addEventListener(t,n)}function Qt(t){return new Promise(e=>{let n=r=>e(r.detail);document.addEventListener(t,n,{once:!0})})}function Gt(t,e){document.removeEventListener(t,xt.get(e))}for(let t in j)globalThis[t]=j[t];})(); diff --git a/packages/@hec.js/ui/lib/src/component.js b/packages/@hec.js/ui/lib/src/component.js index 67afe9a..9db3d5d 100644 --- a/packages/@hec.js/ui/lib/src/component.js +++ b/packages/@hec.js/ui/lib/src/component.js @@ -140,7 +140,7 @@ class Component { const append = (node) => { setPropsOf(this, propsOf(node)); - const children = Array.from(this.node.children); + const children = Array.from(this.node.childNodes); this.node.append(node);